2010-08-24 16:26:52 -04: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
|
|
|
|
|
2012-05-20 17:08:23 -04:00
|
|
|
#include <QtCore/QScopedPointer>
|
2010-10-06 13:40:50 -04:00
|
|
|
#include <QtGui/QStackedWidget>
|
2010-08-24 16:26:52 -04:00
|
|
|
|
2012-06-29 08:15:16 -04:00
|
|
|
#include "core/Global.h"
|
|
|
|
|
2012-01-13 11:52:37 -05:00
|
|
|
class ChangeMasterKeyWidget;
|
2012-06-28 03:21:15 -04:00
|
|
|
class DatabaseOpenWidget;
|
2012-04-19 10:20:20 -04:00
|
|
|
class DatabaseSettingsWidget;
|
2010-08-24 16:26:52 -04:00
|
|
|
class Database;
|
2010-10-06 13:40:50 -04:00
|
|
|
class EditEntryWidget;
|
2011-12-27 09:49:06 -05:00
|
|
|
class EditGroupWidget;
|
2010-10-06 13:40:50 -04:00
|
|
|
class Entry;
|
2010-08-24 16:26:52 -04:00
|
|
|
class EntryView;
|
2011-12-27 09:49:06 -05:00
|
|
|
class Group;
|
2010-08-24 16:26:52 -04:00
|
|
|
class GroupView;
|
2012-06-28 03:21:15 -04:00
|
|
|
class KeePass1OpenWidget;
|
|
|
|
class QFile;
|
2012-05-25 07:17:46 -04:00
|
|
|
class QMenu;
|
2012-10-12 06:12:00 -04:00
|
|
|
class UnlockDatabaseWidget;
|
2010-08-24 16:26:52 -04:00
|
|
|
|
2012-05-19 05:53:32 -04:00
|
|
|
namespace Ui {
|
|
|
|
class SearchWidget;
|
|
|
|
}
|
|
|
|
|
2010-10-06 13:40:50 -04:00
|
|
|
class DatabaseWidget : public QStackedWidget
|
2010-08-24 16:26:52 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-04-24 19:32:05 -04:00
|
|
|
enum Mode
|
|
|
|
{
|
2012-04-25 14:22:55 -04:00
|
|
|
None,
|
|
|
|
ViewMode,
|
2012-10-12 06:12:00 -04:00
|
|
|
EditMode,
|
|
|
|
LockedMode
|
2012-04-24 19:32:05 -04:00
|
|
|
};
|
|
|
|
|
2012-06-29 08:15:16 -04:00
|
|
|
explicit DatabaseWidget(Database* db, QWidget* parent = Q_NULLPTR);
|
2012-05-19 05:53:32 -04:00
|
|
|
~DatabaseWidget();
|
2011-12-27 09:49:06 -05:00
|
|
|
GroupView* groupView();
|
|
|
|
EntryView* entryView();
|
2012-07-06 13:21:19 -04:00
|
|
|
Database* database();
|
2012-04-16 15:03:35 -04:00
|
|
|
bool dbHasKey();
|
2012-04-21 13:06:28 -04:00
|
|
|
bool canDeleteCurrentGoup();
|
2012-08-01 04:35:37 -04:00
|
|
|
bool isInSearchMode();
|
2012-04-24 04:51:22 -04:00
|
|
|
int addWidget(QWidget* w);
|
|
|
|
void setCurrentIndex(int index);
|
2012-10-12 06:12:00 -04:00
|
|
|
void setCurrentWidget(QWidget* widget);
|
2012-04-24 19:32:05 -04:00
|
|
|
DatabaseWidget::Mode currentMode();
|
2012-10-12 06:12:00 -04:00
|
|
|
void lock();
|
|
|
|
void updateFilename(const QString& filename);
|
2011-12-27 09:49:06 -05:00
|
|
|
|
2012-04-11 14:35:52 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void closeRequest();
|
2012-04-25 14:22:55 -04:00
|
|
|
void currentModeChanged(DatabaseWidget::Mode mode);
|
2012-08-01 04:35:37 -04:00
|
|
|
void groupChanged();
|
|
|
|
void entrySelectionChanged();
|
2012-06-28 03:21:15 -04:00
|
|
|
void databaseChanged(Database* newDb);
|
2012-08-01 04:35:37 -04:00
|
|
|
void groupContextMenuRequested(const QPoint& globalPos);
|
|
|
|
void entryContextMenuRequested(const QPoint& globalPos);
|
2012-10-12 06:12:00 -04:00
|
|
|
void unlockedDatabase();
|
2012-04-11 14:35:52 -04:00
|
|
|
|
2011-12-27 09:49:06 -05:00
|
|
|
public Q_SLOTS:
|
2011-12-27 10:04:59 -05:00
|
|
|
void createEntry();
|
2012-05-25 07:17:46 -04:00
|
|
|
void cloneEntry();
|
|
|
|
void deleteEntry();
|
2012-05-26 10:20:32 -04:00
|
|
|
void copyUsername();
|
|
|
|
void copyPassword();
|
2012-10-23 18:15:23 -04:00
|
|
|
void copyAttribute(QAction* action);
|
2012-07-12 16:35:51 -04:00
|
|
|
void performAutoType();
|
2012-07-27 12:38:52 -04:00
|
|
|
void openUrl();
|
2013-04-07 15:05:52 -04:00
|
|
|
void openUrlForEntry(Entry* entry);
|
2011-12-27 09:49:06 -05:00
|
|
|
void createGroup();
|
2012-05-25 07:17:46 -04:00
|
|
|
void deleteGroup();
|
2011-12-27 09:49:06 -05:00
|
|
|
void switchToEntryEdit();
|
|
|
|
void switchToGroupEdit();
|
2012-01-13 11:52:37 -05:00
|
|
|
void switchToMasterKeyChange();
|
2012-04-19 10:20:20 -04:00
|
|
|
void switchToDatabaseSettings();
|
2012-07-06 12:50:52 -04:00
|
|
|
void switchToOpenDatabase(const QString& fileName);
|
|
|
|
void switchToOpenDatabase(const QString& fileName, const QString& password, const QString& keyFile);
|
|
|
|
void switchToImportKeepass1(const QString& fileName);
|
2012-05-19 05:53:32 -04:00
|
|
|
void toggleSearch();
|
2012-08-01 04:35:37 -04:00
|
|
|
void emitGroupContextMenuRequested(const QPoint& pos);
|
|
|
|
void emitEntryContextMenuRequested(const QPoint& pos);
|
2010-08-24 16:26:52 -04:00
|
|
|
|
2010-10-06 13:40:50 -04:00
|
|
|
private Q_SLOTS:
|
2012-05-15 14:12:05 -04:00
|
|
|
void switchBackToEntryEdit();
|
2011-12-27 09:49:06 -05:00
|
|
|
void switchToView(bool accepted);
|
2012-05-20 17:14:34 -04:00
|
|
|
void switchToHistoryView(Entry* entry);
|
2011-12-27 09:49:06 -05:00
|
|
|
void switchToEntryEdit(Entry* entry);
|
2011-12-27 10:04:59 -05:00
|
|
|
void switchToEntryEdit(Entry* entry, bool create);
|
2011-12-27 09:49:06 -05:00
|
|
|
void switchToGroupEdit(Group* entry, bool create);
|
2012-01-13 11:52:37 -05:00
|
|
|
void updateMasterKey(bool accepted);
|
2012-06-28 03:21:15 -04:00
|
|
|
void openDatabase(bool accepted);
|
2012-10-12 06:12:00 -04:00
|
|
|
void unlockDatabase(bool accepted);
|
2012-04-24 19:32:05 -04:00
|
|
|
void emitCurrentModeChanged();
|
2012-05-15 19:26:30 -04:00
|
|
|
void clearLastGroup(Group* group);
|
2012-05-19 05:53:32 -04:00
|
|
|
void search();
|
2012-05-27 07:19:12 -04:00
|
|
|
void startSearch();
|
2012-05-19 05:53:32 -04:00
|
|
|
void startSearchTimer();
|
|
|
|
void showSearch();
|
|
|
|
void closeSearch();
|
2010-10-06 13:40:50 -04:00
|
|
|
|
2010-08-24 16:26:52 -04:00
|
|
|
private:
|
2012-06-28 03:21:15 -04:00
|
|
|
Database* m_db;
|
2012-05-19 05:53:32 -04:00
|
|
|
const QScopedPointer<Ui::SearchWidget> m_searchUi;
|
|
|
|
QWidget* const m_searchWidget;
|
2010-10-06 13:40:50 -04:00
|
|
|
QWidget* m_mainWidget;
|
2011-12-27 09:49:06 -05:00
|
|
|
EditEntryWidget* m_editEntryWidget;
|
2012-05-15 14:12:05 -04:00
|
|
|
EditEntryWidget* m_historyEditEntryWidget;
|
2011-12-27 09:49:06 -05:00
|
|
|
EditGroupWidget* m_editGroupWidget;
|
2012-01-13 11:52:37 -05:00
|
|
|
ChangeMasterKeyWidget* m_changeMasterKeyWidget;
|
2012-04-19 10:20:20 -04:00
|
|
|
DatabaseSettingsWidget* m_databaseSettingsWidget;
|
2012-06-28 03:21:15 -04:00
|
|
|
DatabaseOpenWidget* m_databaseOpenWidget;
|
|
|
|
KeePass1OpenWidget* m_keepass1OpenWidget;
|
2012-10-12 06:12:00 -04:00
|
|
|
UnlockDatabaseWidget* m_unlockDatabaseWidget;
|
2010-08-24 16:26:52 -04:00
|
|
|
GroupView* m_groupView;
|
|
|
|
EntryView* m_entryView;
|
2011-12-27 09:49:06 -05:00
|
|
|
Group* m_newGroup;
|
2011-12-27 10:04:59 -05:00
|
|
|
Entry* m_newEntry;
|
|
|
|
Group* m_newParent;
|
2012-05-15 19:26:30 -04:00
|
|
|
Group* m_lastGroup;
|
2012-05-19 05:53:32 -04:00
|
|
|
QTimer* m_searchTimer;
|
2012-10-12 06:12:00 -04:00
|
|
|
QWidget* widgetBeforeLock;
|
|
|
|
QString m_filename;
|
2010-08-24 16:26:52 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KEEPASSX_DATABASEWIDGET_H
|