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 _ENTRY_VIEW_H_
22 #define _ENTRY_VIEW_H_
24 #include "Kdb3Database.h"
27 enum SelectionState{NONE,SINGLE,MULTIPLE,SEARCHGROUP};
29 class EntryViewItem:public QTreeWidgetItem{
31 EntryViewItem(QTreeWidget *parent);
32 EntryViewItem(QTreeWidget *parent, QTreeWidgetItem * preceding);
33 EntryViewItem(QTreeWidgetItem *parent);
34 EntryViewItem(QTreeWidgetItem *parent, QTreeWidgetItem * preceding);
35 IEntryHandle* EntryHandle;
36 bool operator<(const QTreeWidgetItem& other) const;
38 int compare(const QTreeWidgetItem& other, int col, int index) const;
41 class KeepassEntryView:public QTreeWidget{
44 KeepassEntryView(QWidget* parent=0);
46 void showSearchResults();
47 void showGroup(IGroupHandle* group);
49 void retranslateColumns();
51 QList<EntryViewItem*>Items;
52 QList<IEntryHandle*> SearchResults;
54 void setCurrentEntry(IEntryHandle* entry);
55 inline IGroupHandle* getCurrentGroup() { return CurrentGroup; };
56 bool columnVisible(int col);
57 void setColumnVisible(int col, bool visible);
60 QClipboard* Clipboard;
61 QTimer ClipboardTimer;
63 QList<QTreeWidgetItem*> DragItems;
64 IGroupHandle* CurrentGroup;
65 enum EntryViewMode {Normal, ShowSearchResults};
66 EntryViewMode ViewMode;
67 bool AutoResizeColumns;
68 QList<int> columnSizes;
70 QString columnString(IEntryHandle* entry, int col, bool forceClearText=false);
71 inline QString columnStringView(EntryViewItem* item, int col, bool forceClearText=false) {
72 return columnString(item->EntryHandle, col, forceClearText);
74 void updateEntry(EntryViewItem*);
75 void editEntry(EntryViewItem*);
76 void createItems(QList<IEntryHandle*>& entries);
77 void saveHeaderView();
78 void restoreHeaderView();
80 void contextMenuEvent(QContextMenuEvent *event);
81 void paintEvent(QPaintEvent* event);
82 void resizeEvent(QResizeEvent* event);
83 void mousePressEvent(QMouseEvent *event);
84 void mouseMoveEvent(QMouseEvent *event);
87 void OnGroupChanged(IGroupHandle* group);
88 void OnShowSearchResults();
89 void OnEntryActivated(QTreeWidgetItem*,int);
90 void OnEntryDblClicked(QTreeWidgetItem*,int);
92 void OnItemsChanged();
94 void OnUsernameToClipboard();
95 void OnPasswordToClipboard();
97 void OnClipboardTimeOut();
100 void OnSaveAttachment();
104 void removeDragItems();
105 void OnEditOpenUrl();
106 void OnEditCopyUrl();
107 void resizeColumns();
111 void selectionChanged(SelectionState);
112 void requestCreateGroup(QString title, quint32 image, GroupViewItem* parent);
113 void viewModeChanged(bool searchResultMode);