keepassxc/src/gui/DatabaseWidget.h

145 lines
3.8 KiB
C
Raw Normal View History

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
class ChangeMasterKeyWidget;
class DatabaseSettingsWidget;
2010-08-24 16:26:52 -04:00
class Database;
2010-10-06 13:40:50 -04:00
class EditEntryWidget;
class EditGroupWidget;
2010-10-06 13:40:50 -04:00
class Entry;
2010-08-24 16:26:52 -04:00
class EntryView;
class Group;
2010-08-24 16:26:52 -04:00
class GroupView;
class QMenu;
2010-08-24 16:26:52 -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:
enum Mode
{
2012-04-25 14:22:55 -04:00
None,
ViewMode,
EditMode
};
enum Action
{
GroupNew,
GroupEdit,
GroupDelete,
EntryNew,
EntryClone,
EntryEditView,
EntryDelete,
EntryCopyUsername,
EntryCopyPassword
};
2010-08-24 16:26:52 -04:00
explicit DatabaseWidget(Database* db, QWidget* parent = 0);
~DatabaseWidget();
GroupView* groupView();
EntryView* entryView();
bool dbHasKey();
2012-04-21 13:06:28 -04:00
bool canDeleteCurrentGoup();
int addWidget(QWidget* w);
void setCurrentIndex(int index);
DatabaseWidget::Mode currentMode();
bool actionEnabled(Action action);
Q_SIGNALS:
void closeRequest();
2012-04-25 14:22:55 -04:00
void currentModeChanged(DatabaseWidget::Mode mode);
public Q_SLOTS:
2011-12-27 10:04:59 -05:00
void createEntry();
void cloneEntry();
void deleteEntry();
void copyUsername();
void copyPassword();
void createGroup();
void deleteGroup();
void switchToEntryEdit();
void switchToGroupEdit();
void switchToMasterKeyChange();
void switchToDatabaseSettings();
void toggleSearch();
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();
void switchToView(bool accepted);
2012-05-20 17:14:34 -04:00
void switchToHistoryView(Entry* entry);
void switchToEntryEdit(Entry* entry);
2011-12-27 10:04:59 -05:00
void switchToEntryEdit(Entry* entry, bool create);
void switchToGroupEdit(Group* entry, bool create);
void updateMasterKey(bool accepted);
void emitCurrentModeChanged();
void clearLastGroup(Group* group);
void search();
2012-05-27 07:19:12 -04:00
void startSearch();
void startSearchTimer();
void showSearch();
void closeSearch();
2012-05-27 10:53:07 -04:00
void updateGroupActions(Group* group);
void updateEntryActions();
void showGroupContextMenu(const QPoint& pos);
void showEntryContextMenu(const QPoint& pos);
2010-10-06 13:40:50 -04:00
2010-08-24 16:26:52 -04:00
private:
2012-04-23 13:44:43 -04:00
Database* const m_db;
const QScopedPointer<Ui::SearchWidget> m_searchUi;
QWidget* const m_searchWidget;
2010-10-06 13:40:50 -04:00
QWidget* m_mainWidget;
EditEntryWidget* m_editEntryWidget;
2012-05-15 14:12:05 -04:00
EditEntryWidget* m_historyEditEntryWidget;
EditGroupWidget* m_editGroupWidget;
ChangeMasterKeyWidget* m_changeMasterKeyWidget;
DatabaseSettingsWidget* m_databaseSettingsWidget;
2010-08-24 16:26:52 -04:00
GroupView* m_groupView;
EntryView* m_entryView;
Group* m_newGroup;
2011-12-27 10:04:59 -05:00
Entry* m_newEntry;
Group* m_newParent;
Group* m_lastGroup;
QTimer* m_searchTimer;
QMenu* m_menuGroup;
QAction* m_actionGroupNew;
QAction* m_actionGroupEdit;
QAction* m_actionGroupDelete;
QMenu* m_menuEntry;
QAction* m_actionEntryNew;
QAction* m_actionEntryClone;
QAction* m_actionEntryEditView;
QAction* m_actionEntryDelete;
QAction* m_actionEntryCopyUsername;
QAction* m_actionEntryCopyPassword;
2010-08-24 16:26:52 -04:00
};
#endif // KEEPASSX_DATABASEWIDGET_H