2010-08-24 20:26:52 +00: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
|
|
|
|
|
|
2010-10-06 17:40:50 +00:00
|
|
|
#include <QtGui/QStackedWidget>
|
2010-08-24 20:26:52 +00:00
|
|
|
|
2012-01-13 16:52:37 +00:00
|
|
|
class ChangeMasterKeyWidget;
|
2012-04-19 14:20:20 +00:00
|
|
|
class DatabaseSettingsWidget;
|
2010-08-24 20:26:52 +00:00
|
|
|
class Database;
|
2010-10-06 17:40:50 +00:00
|
|
|
class EditEntryWidget;
|
2011-12-27 14:49:06 +00:00
|
|
|
class EditGroupWidget;
|
2010-10-06 17:40:50 +00:00
|
|
|
class Entry;
|
2010-08-24 20:26:52 +00:00
|
|
|
class EntryView;
|
2011-12-27 14:49:06 +00:00
|
|
|
class Group;
|
2010-08-24 20:26:52 +00:00
|
|
|
class GroupView;
|
|
|
|
|
|
2012-05-19 09:53:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
|
class SearchWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-06 17:40:50 +00:00
|
|
|
class DatabaseWidget : public QStackedWidget
|
2010-08-24 20:26:52 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2012-04-24 23:32:05 +00:00
|
|
|
enum Mode
|
|
|
|
|
{
|
2012-04-25 18:22:55 +00:00
|
|
|
None,
|
|
|
|
|
ViewMode,
|
|
|
|
|
EditMode
|
2012-04-24 23:32:05 +00:00
|
|
|
};
|
|
|
|
|
|
2010-08-24 20:26:52 +00:00
|
|
|
explicit DatabaseWidget(Database* db, QWidget* parent = 0);
|
2012-05-19 09:53:32 +00:00
|
|
|
~DatabaseWidget();
|
2011-12-27 14:49:06 +00:00
|
|
|
GroupView* groupView();
|
|
|
|
|
EntryView* entryView();
|
2012-04-16 19:03:35 +00:00
|
|
|
bool dbHasKey();
|
2012-05-15 19:10:39 +00:00
|
|
|
void cloneEntry();
|
2012-04-18 18:08:54 +00:00
|
|
|
void deleteEntry();
|
2012-04-21 17:06:28 +00:00
|
|
|
void deleteGroup();
|
2012-05-15 19:10:39 +00:00
|
|
|
|
2012-04-21 17:06:28 +00:00
|
|
|
bool canDeleteCurrentGoup();
|
2012-04-24 08:51:22 +00:00
|
|
|
int addWidget(QWidget* w);
|
|
|
|
|
void setCurrentIndex(int index);
|
2012-04-24 23:32:05 +00:00
|
|
|
DatabaseWidget::Mode currentMode();
|
2011-12-27 14:49:06 +00:00
|
|
|
|
2012-04-11 18:35:52 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
|
void closeRequest();
|
2012-04-25 18:22:55 +00:00
|
|
|
void currentModeChanged(DatabaseWidget::Mode mode);
|
2012-04-11 18:35:52 +00:00
|
|
|
|
2011-12-27 14:49:06 +00:00
|
|
|
public Q_SLOTS:
|
2011-12-27 15:04:59 +00:00
|
|
|
void createEntry();
|
2011-12-27 14:49:06 +00:00
|
|
|
void createGroup();
|
|
|
|
|
void switchToEntryEdit();
|
|
|
|
|
void switchToGroupEdit();
|
2012-01-13 16:52:37 +00:00
|
|
|
void switchToMasterKeyChange();
|
2012-04-19 14:20:20 +00:00
|
|
|
void switchToDatabaseSettings();
|
2012-05-19 09:53:32 +00:00
|
|
|
void toggleSearch();
|
2010-08-24 20:26:52 +00:00
|
|
|
|
2010-10-06 17:40:50 +00:00
|
|
|
private Q_SLOTS:
|
2012-05-15 18:12:05 +00:00
|
|
|
void switchBackToEntryEdit();
|
2011-12-27 14:49:06 +00:00
|
|
|
void switchToView(bool accepted);
|
2012-05-15 18:12:05 +00:00
|
|
|
void switchToHistoryView(Entry *entry);
|
2011-12-27 14:49:06 +00:00
|
|
|
void switchToEntryEdit(Entry* entry);
|
2011-12-27 15:04:59 +00:00
|
|
|
void switchToEntryEdit(Entry* entry, bool create);
|
2011-12-27 14:49:06 +00:00
|
|
|
void switchToGroupEdit(Group* entry, bool create);
|
2012-01-13 16:52:37 +00:00
|
|
|
void updateMasterKey(bool accepted);
|
2012-04-24 23:32:05 +00:00
|
|
|
void emitCurrentModeChanged();
|
2012-05-15 23:26:30 +00:00
|
|
|
void clearLastGroup(Group* group);
|
2012-05-19 09:53:32 +00:00
|
|
|
void search();
|
|
|
|
|
void startSearchTimer();
|
|
|
|
|
void showSearch();
|
|
|
|
|
void closeSearch();
|
2010-10-06 17:40:50 +00:00
|
|
|
|
2010-08-24 20:26:52 +00:00
|
|
|
private:
|
2012-05-14 14:27:59 +00:00
|
|
|
void truncateHistories();
|
|
|
|
|
|
2012-04-23 17:44:43 +00:00
|
|
|
Database* const m_db;
|
2012-05-19 09:53:32 +00:00
|
|
|
const QScopedPointer<Ui::SearchWidget> m_searchUi;
|
|
|
|
|
QWidget* const m_searchWidget;
|
2010-10-06 17:40:50 +00:00
|
|
|
QWidget* m_mainWidget;
|
2011-12-27 14:49:06 +00:00
|
|
|
EditEntryWidget* m_editEntryWidget;
|
2012-05-15 18:12:05 +00:00
|
|
|
EditEntryWidget* m_historyEditEntryWidget;
|
2011-12-27 14:49:06 +00:00
|
|
|
EditGroupWidget* m_editGroupWidget;
|
2012-01-13 16:52:37 +00:00
|
|
|
ChangeMasterKeyWidget* m_changeMasterKeyWidget;
|
2012-04-19 14:20:20 +00:00
|
|
|
DatabaseSettingsWidget* m_databaseSettingsWidget;
|
2010-08-24 20:26:52 +00:00
|
|
|
GroupView* m_groupView;
|
|
|
|
|
EntryView* m_entryView;
|
2011-12-27 14:49:06 +00:00
|
|
|
Group* m_newGroup;
|
2011-12-27 15:04:59 +00:00
|
|
|
Entry* m_newEntry;
|
|
|
|
|
Group* m_newParent;
|
2012-05-15 23:26:30 +00:00
|
|
|
Group* m_lastGroup;
|
2012-05-19 09:53:32 +00:00
|
|
|
QTimer* m_searchTimer;
|
2010-08-24 20:26:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // KEEPASSX_DATABASEWIDGET_H
|