2010-08-24 22:26:52 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
* version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KEEPASSX_DATABASEWIDGET_H
|
|
|
|
#define KEEPASSX_DATABASEWIDGET_H
|
|
|
|
|
2013-10-03 15:18:16 +02:00
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QStackedWidget>
|
2010-08-24 22:26:52 +02:00
|
|
|
|
2015-01-11 16:20:59 +01:00
|
|
|
#include "core/Uuid.h"
|
2012-06-29 14:15:16 +02:00
|
|
|
|
2013-04-14 19:14:06 +02:00
|
|
|
#include "gui/entry/EntryModel.h"
|
|
|
|
|
2012-01-13 17:52:37 +01:00
|
|
|
class ChangeMasterKeyWidget;
|
2012-06-28 09:21:15 +02:00
|
|
|
class DatabaseOpenWidget;
|
2012-04-19 16:20:20 +02:00
|
|
|
class DatabaseSettingsWidget;
|
2010-08-24 22:26:52 +02:00
|
|
|
class Database;
|
2010-10-06 19:40:50 +02:00
|
|
|
class EditEntryWidget;
|
2011-12-27 15:49:06 +01:00
|
|
|
class EditGroupWidget;
|
2010-10-06 19:40:50 +02:00
|
|
|
class Entry;
|
2010-08-24 22:26:52 +02:00
|
|
|
class EntryView;
|
2011-12-27 15:49:06 +01:00
|
|
|
class Group;
|
2010-08-24 22:26:52 +02:00
|
|
|
class GroupView;
|
2012-06-28 09:21:15 +02:00
|
|
|
class KeePass1OpenWidget;
|
|
|
|
class QFile;
|
2012-05-25 13:17:46 +02:00
|
|
|
class QMenu;
|
2014-05-17 11:16:27 +02:00
|
|
|
class QSplitter;
|
2016-11-02 21:01:02 -04:00
|
|
|
class QLabel;
|
2012-10-12 12:12:00 +02:00
|
|
|
class UnlockDatabaseWidget;
|
2010-08-24 22:26:52 +02:00
|
|
|
|
2010-10-06 19:40:50 +02:00
|
|
|
class DatabaseWidget : public QStackedWidget
|
2010-08-24 22:26:52 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-04-25 01:32:05 +02:00
|
|
|
enum Mode
|
|
|
|
{
|
2012-04-25 20:22:55 +02:00
|
|
|
None,
|
|
|
|
ViewMode,
|
2012-10-12 12:12:00 +02:00
|
|
|
EditMode,
|
|
|
|
LockedMode
|
2012-04-25 01:32:05 +02:00
|
|
|
};
|
|
|
|
|
2015-07-24 18:28:12 +02:00
|
|
|
explicit DatabaseWidget(Database* db, QWidget* parent = nullptr);
|
2012-05-19 11:53:32 +02:00
|
|
|
~DatabaseWidget();
|
2012-07-06 19:21:19 +02:00
|
|
|
Database* database();
|
2014-05-15 22:53:59 +02:00
|
|
|
bool dbHasKey() const;
|
2014-05-15 22:56:36 +02:00
|
|
|
bool canDeleteCurrentGroup() const;
|
2014-05-15 22:53:59 +02:00
|
|
|
bool isInSearchMode() const;
|
2016-11-02 21:01:02 -04:00
|
|
|
QString getCurrentSearch();
|
2016-11-07 22:37:42 -05:00
|
|
|
Group* currentGroup() const;
|
2012-04-24 10:51:22 +02:00
|
|
|
int addWidget(QWidget* w);
|
|
|
|
void setCurrentIndex(int index);
|
2012-10-12 12:12:00 +02:00
|
|
|
void setCurrentWidget(QWidget* widget);
|
2014-05-15 22:51:13 +02:00
|
|
|
DatabaseWidget::Mode currentMode() const;
|
2012-10-12 12:12:00 +02:00
|
|
|
void lock();
|
|
|
|
void updateFilename(const QString& filename);
|
2014-05-15 22:53:59 +02:00
|
|
|
int numberOfSelectedEntries() const;
|
|
|
|
QStringList customEntryAttributes() const;
|
2014-05-17 11:21:50 +02:00
|
|
|
bool isGroupSelected() const;
|
2014-05-15 22:51:13 +02:00
|
|
|
bool isInEditMode() const;
|
2016-08-01 00:22:04 +02:00
|
|
|
bool isEditWidgetModified() const;
|
2014-05-17 11:16:27 +02:00
|
|
|
QList<int> splitterSizes() const;
|
|
|
|
void setSplitterSizes(const QList<int>& sizes);
|
2014-05-17 12:51:16 +02:00
|
|
|
QList<int> entryHeaderViewSizes() const;
|
|
|
|
void setEntryViewHeaderSizes(const QList<int>& sizes);
|
2015-01-11 16:20:59 +01:00
|
|
|
void clearAllWidgets();
|
2015-05-12 15:54:39 -04:00
|
|
|
bool currentEntryHasTitle();
|
|
|
|
bool currentEntryHasUsername();
|
|
|
|
bool currentEntryHasPassword();
|
|
|
|
bool currentEntryHasUrl();
|
|
|
|
bool currentEntryHasNotes();
|
2016-11-07 22:37:42 -05:00
|
|
|
GroupView* groupView();
|
|
|
|
EntryView* entryView();
|
2011-12-27 15:49:06 +01:00
|
|
|
|
2012-04-11 20:35:52 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void closeRequest();
|
2012-04-25 20:22:55 +02:00
|
|
|
void currentModeChanged(DatabaseWidget::Mode mode);
|
2012-08-01 10:35:37 +02:00
|
|
|
void groupChanged();
|
|
|
|
void entrySelectionChanged();
|
2012-06-28 09:21:15 +02:00
|
|
|
void databaseChanged(Database* newDb);
|
2016-11-07 22:37:42 -05:00
|
|
|
void databaseMerged(Database* mergedDb);
|
2012-08-01 10:35:37 +02:00
|
|
|
void groupContextMenuRequested(const QPoint& globalPos);
|
|
|
|
void entryContextMenuRequested(const QPoint& globalPos);
|
2012-10-12 12:12:00 +02:00
|
|
|
void unlockedDatabase();
|
2014-05-17 18:05:02 +02:00
|
|
|
void listModeAboutToActivate();
|
2014-05-17 11:16:27 +02:00
|
|
|
void listModeActivated();
|
2014-05-17 18:05:02 +02:00
|
|
|
void searchModeAboutToActivate();
|
2014-05-17 11:16:27 +02:00
|
|
|
void searchModeActivated();
|
|
|
|
void splitterSizesChanged();
|
2014-05-17 12:51:16 +02:00
|
|
|
void entryColumnSizesChanged();
|
2016-11-02 21:01:02 -04:00
|
|
|
void updateSearch(QString text);
|
2015-01-05 18:50:04 +09:00
|
|
|
|
2011-12-27 15:49:06 +01:00
|
|
|
public Q_SLOTS:
|
2011-12-27 16:04:59 +01:00
|
|
|
void createEntry();
|
2012-05-25 13:17:46 +02:00
|
|
|
void cloneEntry();
|
2013-10-08 21:36:01 +02:00
|
|
|
void deleteEntries();
|
2013-12-01 09:43:41 +01:00
|
|
|
void copyTitle();
|
2012-05-26 16:20:32 +02:00
|
|
|
void copyUsername();
|
|
|
|
void copyPassword();
|
2013-12-01 09:43:41 +01:00
|
|
|
void copyURL();
|
|
|
|
void copyNotes();
|
2012-10-24 00:15:23 +02:00
|
|
|
void copyAttribute(QAction* action);
|
2012-07-12 22:35:51 +02:00
|
|
|
void performAutoType();
|
2012-07-27 18:38:52 +02:00
|
|
|
void openUrl();
|
2013-04-07 21:05:52 +02:00
|
|
|
void openUrlForEntry(Entry* entry);
|
2011-12-27 15:49:06 +01:00
|
|
|
void createGroup();
|
2012-05-25 13:17:46 +02:00
|
|
|
void deleteGroup();
|
2016-11-07 22:37:42 -05:00
|
|
|
void switchToView(bool accepted);
|
2011-12-27 15:49:06 +01:00
|
|
|
void switchToEntryEdit();
|
|
|
|
void switchToGroupEdit();
|
2012-01-13 17:52:37 +01:00
|
|
|
void switchToMasterKeyChange();
|
2012-04-19 16:20:20 +02:00
|
|
|
void switchToDatabaseSettings();
|
2012-07-06 18:50:52 +02:00
|
|
|
void switchToOpenDatabase(const QString& fileName);
|
|
|
|
void switchToOpenDatabase(const QString& fileName, const QString& password, const QString& keyFile);
|
2016-11-07 22:37:42 -05:00
|
|
|
void switchToOpenMergeDatabase(const QString& fileName);
|
|
|
|
void switchToOpenMergeDatabase(const QString& fileName, const QString& password, const QString& keyFile);
|
2012-07-06 18:50:52 +02:00
|
|
|
void switchToImportKeepass1(const QString& fileName);
|
2016-11-02 21:01:02 -04:00
|
|
|
// Search related slots
|
|
|
|
void search(const QString& searchtext);
|
|
|
|
void setSearchCaseSensitive(bool state);
|
|
|
|
void setSearchCurrentGroup(bool state);
|
|
|
|
void endSearch();
|
2010-08-24 22:26:52 +02:00
|
|
|
|
2010-10-06 19:40:50 +02:00
|
|
|
private Q_SLOTS:
|
2013-04-14 19:14:06 +02:00
|
|
|
void entryActivationSignalReceived(Entry* entry, EntryModel::ModelColumn column);
|
2012-05-15 20:12:05 +02:00
|
|
|
void switchBackToEntryEdit();
|
2012-05-20 23:14:34 +02:00
|
|
|
void switchToHistoryView(Entry* entry);
|
2011-12-27 15:49:06 +01:00
|
|
|
void switchToEntryEdit(Entry* entry);
|
2011-12-27 16:04:59 +01:00
|
|
|
void switchToEntryEdit(Entry* entry, bool create);
|
2011-12-27 15:49:06 +01:00
|
|
|
void switchToGroupEdit(Group* entry, bool create);
|
2014-05-17 11:22:45 +02:00
|
|
|
void emitGroupContextMenuRequested(const QPoint& pos);
|
|
|
|
void emitEntryContextMenuRequested(const QPoint& pos);
|
2012-01-13 17:52:37 +01:00
|
|
|
void updateMasterKey(bool accepted);
|
2012-06-28 09:21:15 +02:00
|
|
|
void openDatabase(bool accepted);
|
2016-11-07 22:37:42 -05:00
|
|
|
void mergeDatabase(bool accepted);
|
2012-10-12 12:12:00 +02:00
|
|
|
void unlockDatabase(bool accepted);
|
2012-04-25 01:32:05 +02:00
|
|
|
void emitCurrentModeChanged();
|
2012-05-16 01:26:30 +02:00
|
|
|
void clearLastGroup(Group* group);
|
2010-10-06 19:40:50 +02:00
|
|
|
|
2010-08-24 22:26:52 +02:00
|
|
|
private:
|
2013-12-01 09:59:43 +01:00
|
|
|
void setClipboardTextAndMinimize(const QString& text);
|
2014-04-14 23:20:24 +02:00
|
|
|
void setIconFromParent();
|
2015-01-11 16:20:59 +01:00
|
|
|
void replaceDatabase(Database* db);
|
2013-12-01 09:59:43 +01:00
|
|
|
|
2012-06-28 09:21:15 +02:00
|
|
|
Database* m_db;
|
2010-10-06 19:40:50 +02:00
|
|
|
QWidget* m_mainWidget;
|
2011-12-27 15:49:06 +01:00
|
|
|
EditEntryWidget* m_editEntryWidget;
|
2012-05-15 20:12:05 +02:00
|
|
|
EditEntryWidget* m_historyEditEntryWidget;
|
2011-12-27 15:49:06 +01:00
|
|
|
EditGroupWidget* m_editGroupWidget;
|
2012-01-13 17:52:37 +01:00
|
|
|
ChangeMasterKeyWidget* m_changeMasterKeyWidget;
|
2012-04-19 16:20:20 +02:00
|
|
|
DatabaseSettingsWidget* m_databaseSettingsWidget;
|
2012-06-28 09:21:15 +02:00
|
|
|
DatabaseOpenWidget* m_databaseOpenWidget;
|
2016-11-07 22:37:42 -05:00
|
|
|
DatabaseOpenWidget* m_databaseOpenMergeWidget;
|
2012-06-28 09:21:15 +02:00
|
|
|
KeePass1OpenWidget* m_keepass1OpenWidget;
|
2012-10-12 12:12:00 +02:00
|
|
|
UnlockDatabaseWidget* m_unlockDatabaseWidget;
|
2014-05-17 11:16:27 +02:00
|
|
|
QSplitter* m_splitter;
|
2010-08-24 22:26:52 +02:00
|
|
|
GroupView* m_groupView;
|
|
|
|
EntryView* m_entryView;
|
2016-11-02 21:01:02 -04:00
|
|
|
QLabel* m_searchingLabel;
|
2011-12-27 15:49:06 +01:00
|
|
|
Group* m_newGroup;
|
2011-12-27 16:04:59 +01:00
|
|
|
Entry* m_newEntry;
|
|
|
|
Group* m_newParent;
|
2012-05-16 01:26:30 +02:00
|
|
|
Group* m_lastGroup;
|
2012-10-12 12:12:00 +02:00
|
|
|
QString m_filename;
|
2015-01-11 16:20:59 +01:00
|
|
|
Uuid m_groupBeforeLock;
|
2016-11-02 21:01:02 -04:00
|
|
|
|
|
|
|
// Search state
|
|
|
|
QString m_lastSearchText;
|
|
|
|
bool m_searchCaseSensitive;
|
|
|
|
bool m_searchCurrentGroup;
|
2010-08-24 22:26:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KEEPASSX_DATABASEWIDGET_H
|