mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-28 15:27:18 -05:00
Make the edit entry button work.
This commit is contained in:
parent
e11b0061d4
commit
73b84ff670
@ -25,6 +25,7 @@
|
|||||||
#include "format/KeePass2XmlReader.h"
|
#include "format/KeePass2XmlReader.h"
|
||||||
#include "gui/DatabaseWidget.h"
|
#include "gui/DatabaseWidget.h"
|
||||||
#include "gui/FileDialog.h"
|
#include "gui/FileDialog.h"
|
||||||
|
#include "gui/EntryView.h"
|
||||||
#include "gui/GroupView.h"
|
#include "gui/GroupView.h"
|
||||||
#include "gui/KeyOpenDialog.h"
|
#include "gui/KeyOpenDialog.h"
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ DatabaseManager::DatabaseManager(QTabWidget* tabWidget)
|
|||||||
, m_window(tabWidget->window())
|
, m_window(tabWidget->window())
|
||||||
{
|
{
|
||||||
connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int)));
|
connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int)));
|
||||||
|
connect(m_tabWidget, SIGNAL(currentChanged(int)), SLOT(emitEntrySelectionChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseManager::newDatabase()
|
void DatabaseManager::newDatabase()
|
||||||
@ -119,6 +121,18 @@ void DatabaseManager::openDatabaseCleanup()
|
|||||||
m_curDbStruct = DatabaseManagerStruct();
|
m_curDbStruct = DatabaseManagerStruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseManager::emitEntrySelectionChanged()
|
||||||
|
{
|
||||||
|
Database* db = indexDatabase(m_tabWidget->currentIndex());
|
||||||
|
|
||||||
|
bool isSingleEntrySelected = false;
|
||||||
|
if (db) {
|
||||||
|
isSingleEntrySelected = m_dbList[db].dbWidget->entryView()->isSingleEntrySelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EMIT entrySelectionChanged(isSingleEntrySelected);
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseManager::closeDatabase(Database* db)
|
void DatabaseManager::closeDatabase(Database* db)
|
||||||
{
|
{
|
||||||
Q_ASSERT(db);
|
Q_ASSERT(db);
|
||||||
@ -216,6 +230,13 @@ void DatabaseManager::createEntry()
|
|||||||
dbWidget->createEntry();
|
dbWidget->createEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseManager::editEntry()
|
||||||
|
{
|
||||||
|
Database* db = indexDatabase(m_tabWidget->currentIndex());
|
||||||
|
DatabaseWidget* dbWidget = m_dbList[db].dbWidget;
|
||||||
|
dbWidget->switchToEntryEdit();
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseManager::createGroup()
|
void DatabaseManager::createGroup()
|
||||||
{
|
{
|
||||||
Database* db = indexDatabase(m_tabWidget->currentIndex());
|
Database* db = indexDatabase(m_tabWidget->currentIndex());
|
||||||
@ -294,4 +315,5 @@ void DatabaseManager::insertDatabase(Database* db, const DatabaseManagerStruct&
|
|||||||
m_tabWidget->setCurrentIndex(index);
|
m_tabWidget->setCurrentIndex(index);
|
||||||
|
|
||||||
connect(db->metadata(), SIGNAL(nameTextChanged(Database*)), SLOT(updateTabName(Database*)));
|
connect(db->metadata(), SIGNAL(nameTextChanged(Database*)), SLOT(updateTabName(Database*)));
|
||||||
|
connect(dbStruct.dbWidget->entryView(), SIGNAL(entrySelectionChanged()), SLOT(emitEntrySelectionChanged()));
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ public Q_SLOTS:
|
|||||||
void saveDatabaseAs(int index = -1);
|
void saveDatabaseAs(int index = -1);
|
||||||
void closeDatabase(int index = -1);
|
void closeDatabase(int index = -1);
|
||||||
void createEntry();
|
void createEntry();
|
||||||
|
void editEntry();
|
||||||
void createGroup();
|
void createGroup();
|
||||||
void editGroup();
|
void editGroup();
|
||||||
|
|
||||||
@ -66,6 +67,10 @@ private Q_SLOTS:
|
|||||||
void openDatabaseDialog();
|
void openDatabaseDialog();
|
||||||
void openDatabaseRead();
|
void openDatabaseRead();
|
||||||
void openDatabaseCleanup();
|
void openDatabaseCleanup();
|
||||||
|
void emitEntrySelectionChanged();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void entrySelectionChanged(bool singleEntrySelected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int databaseIndex(Database* db);
|
int databaseIndex(Database* db);
|
||||||
|
@ -140,7 +140,7 @@ void DatabaseWidget::switchToGroupEdit(Group* group, bool create)
|
|||||||
}
|
}
|
||||||
void DatabaseWidget::switchToEntryEdit()
|
void DatabaseWidget::switchToEntryEdit()
|
||||||
{
|
{
|
||||||
// TODO switchToEntryEdit(m_entryView->currentEntry(), false);
|
switchToEntryEdit(m_entryView->currentEntry(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::switchToGroupEdit()
|
void DatabaseWidget::switchToGroupEdit()
|
||||||
|
@ -29,6 +29,7 @@ EntryView::EntryView(QWidget* parent)
|
|||||||
setRootIsDecorated(false);
|
setRootIsDecorated(false);
|
||||||
|
|
||||||
connect(this, SIGNAL(activated(const QModelIndex&)), SLOT(emitEntryActivated(const QModelIndex&)));
|
connect(this, SIGNAL(activated(const QModelIndex&)), SLOT(emitEntryActivated(const QModelIndex&)));
|
||||||
|
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntryView::setGroup(Group* group)
|
void EntryView::setGroup(Group* group)
|
||||||
@ -46,3 +47,14 @@ void EntryView::setModel(QAbstractItemModel* model)
|
|||||||
Q_UNUSED(model);
|
Q_UNUSED(model);
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entry* EntryView::currentEntry()
|
||||||
|
{
|
||||||
|
// TODO use selection instead of current?
|
||||||
|
return m_model->entryFromIndex(currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EntryView::isSingleEntrySelected()
|
||||||
|
{
|
||||||
|
return (selectionModel()->selectedRows().size() == 1);
|
||||||
|
}
|
||||||
|
@ -31,6 +31,8 @@ class EntryView : public QTreeView
|
|||||||
public:
|
public:
|
||||||
explicit EntryView(QWidget* parent = 0);
|
explicit EntryView(QWidget* parent = 0);
|
||||||
void setModel(QAbstractItemModel* model);
|
void setModel(QAbstractItemModel* model);
|
||||||
|
Entry* currentEntry();
|
||||||
|
bool isSingleEntrySelected();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setGroup(Group* group);
|
void setGroup(Group* group);
|
||||||
@ -40,6 +42,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void entryActivated(Entry* entry);
|
void entryActivated(Entry* entry);
|
||||||
|
void entrySelectionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntryModel* m_model;
|
EntryModel* m_model;
|
||||||
|
@ -31,6 +31,8 @@ MainWindow::MainWindow()
|
|||||||
m_dbManager = new DatabaseManager(m_ui->tabWidget);
|
m_dbManager = new DatabaseManager(m_ui->tabWidget);
|
||||||
|
|
||||||
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||||
|
connect(m_dbManager, SIGNAL(entrySelectionChanged(bool)), m_ui->actionEntryEdit, SLOT(setEnabled(bool)));
|
||||||
|
connect(m_dbManager, SIGNAL(entrySelectionChanged(bool)), m_ui->actionEntryDelete, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_dbManager, SLOT(newDatabase()));
|
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_dbManager, SLOT(newDatabase()));
|
||||||
connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), m_dbManager, SLOT(openDatabase()));
|
connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), m_dbManager, SLOT(openDatabase()));
|
||||||
@ -38,6 +40,7 @@ MainWindow::MainWindow()
|
|||||||
connect(m_ui->actionDatabaseSaveAs, SIGNAL(triggered()), m_dbManager, SLOT(saveDatabaseAs()));
|
connect(m_ui->actionDatabaseSaveAs, SIGNAL(triggered()), m_dbManager, SLOT(saveDatabaseAs()));
|
||||||
connect(m_ui->actionDatabaseClose, SIGNAL(triggered()), m_dbManager, SLOT(closeDatabase()));
|
connect(m_ui->actionDatabaseClose, SIGNAL(triggered()), m_dbManager, SLOT(closeDatabase()));
|
||||||
connect(m_ui->actionEntryNew, SIGNAL(triggered()), m_dbManager, SLOT(createEntry()));
|
connect(m_ui->actionEntryNew, SIGNAL(triggered()), m_dbManager, SLOT(createEntry()));
|
||||||
|
connect(m_ui->actionEntryEdit, SIGNAL(triggered()), m_dbManager, SLOT(editEntry()));
|
||||||
connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_dbManager, SLOT(createGroup()));
|
connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_dbManager, SLOT(createGroup()));
|
||||||
connect(m_ui->actionGroupEdit, SIGNAL(triggered()), m_dbManager, SLOT(editGroup()));
|
connect(m_ui->actionGroupEdit, SIGNAL(triggered()), m_dbManager, SLOT(editGroup()));
|
||||||
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close()));
|
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user