1 /***************************************************************************
2 * Copyright (C) 2005 by Tarek Saidi *
3 * tarek.saidi@arcor.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef _GROUP_VIEW_H_
22 #define _GROUP_VIEW_H_
24 #include "Kdb3Database.h"
28 class KeepassGroupView:public QTreeWidget{
31 KeepassGroupView(QWidget* parent=0);
33 QList<GroupViewItem*>Items;
35 QMenu *ContextMenuSearchGroup;
36 GroupViewItem* SearchResultItem;
38 void showSearchResults();
39 void setCurrentGroup(IGroupHandle* group);
40 void selectFirstGroup();
44 void createGroup(const QString& title, quint32 image, GroupViewItem* group=NULL);
47 virtual void dragEnterEvent(QDragEnterEvent* event);
48 virtual void dragMoveEvent(QDragMoveEvent* event);
49 void entryDragMoveEvent(QDragMoveEvent* event);
50 virtual void dragLeaveEvent(QDragLeaveEvent* event);
51 virtual void dropEvent(QDropEvent* event);
52 void entryDropEvent(QDropEvent* event);
53 virtual void mousePressEvent(QMouseEvent *event);
54 virtual void mouseMoveEvent(QMouseEvent *event);
55 virtual void paintEvent (QPaintEvent* event);
56 virtual void contextMenuEvent(QContextMenuEvent* event);
57 void addChildren(GroupViewItem* item);
59 GroupViewItem* DragItem;
60 GroupViewItem* LastHoverItem;
63 enum GroupViewDragType{EntryDrag,GroupDrag};
64 GroupViewDragType DragType;
65 QList<QTreeWidgetItem*>* EntryDragItems;
68 void OnCurrentGroupChanged(QTreeWidgetItem*);
74 void OnHideSearchResults();
75 void OnItemExpanded(QTreeWidgetItem*);
76 void OnItemCollapsed(QTreeWidgetItem*);
80 void groupChanged(IGroupHandle* NewGroup);
81 void searchResultsSelected();
83 void entriesDropped();
87 class GroupViewItem:public QTreeWidgetItem{
90 GroupViewItem(QTreeWidget *parent);
91 GroupViewItem(QTreeWidget *parent, QTreeWidgetItem * preceding);
92 GroupViewItem(QTreeWidgetItem *parent);
93 GroupViewItem(QTreeWidgetItem *parent, QTreeWidgetItem * preceding);
94 bool operator<(const QTreeWidgetItem& other) const;
95 IGroupHandle* GroupHandle;