mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Remove dependency to Group- and EntryView from MainWindow.
This commit is contained in:
parent
b718e9d8f2
commit
9363d23e09
@ -811,3 +811,23 @@ void DatabaseWidget::updateFilename(const QString& fileName)
|
||||
{
|
||||
m_filename = fileName;
|
||||
}
|
||||
|
||||
int DatabaseWidget::numberOfSelectedEntries()
|
||||
{
|
||||
return m_entryView->numberOfSelectedEntries();
|
||||
}
|
||||
|
||||
QStringList DatabaseWidget::customEntryAttributes()
|
||||
{
|
||||
Entry* entry = m_entryView->currentEntry();
|
||||
if (!entry) {
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
return entry->attributes()->customKeys();
|
||||
}
|
||||
|
||||
bool DatabaseWidget::isGroupSelected()
|
||||
{
|
||||
return m_groupView->currentGroup() != Q_NULLPTR;
|
||||
}
|
||||
|
@ -71,6 +71,9 @@ public:
|
||||
DatabaseWidget::Mode currentMode();
|
||||
void lock();
|
||||
void updateFilename(const QString& filename);
|
||||
int numberOfSelectedEntries();
|
||||
QStringList customEntryAttributes();
|
||||
bool isGroupSelected();
|
||||
|
||||
Q_SIGNALS:
|
||||
void closeRequest();
|
||||
|
@ -23,15 +23,11 @@
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/FilePath.h"
|
||||
#include "core/InactivityTimer.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "gui/AboutDialog.h"
|
||||
#include "gui/DatabaseWidget.h"
|
||||
#include "gui/entry/EntryView.h"
|
||||
#include "gui/group/GroupView.h"
|
||||
|
||||
const QString MainWindow::BaseWindowTitle = "KeePassX";
|
||||
|
||||
@ -40,6 +36,8 @@ MainWindow::MainWindow()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size();
|
||||
|
||||
restoreGeometry(config()->get("window/Geometry").toByteArray());
|
||||
|
||||
setWindowIcon(filePath()->applicationIcon());
|
||||
@ -229,17 +227,16 @@ void MainWindow::updateCopyAttributesMenu()
|
||||
return;
|
||||
}
|
||||
|
||||
Entry* entry = dbWidget->entryView()->currentEntry();
|
||||
if (!entry || !dbWidget->entryView()->isSingleEntrySelected()) {
|
||||
if (!dbWidget->numberOfSelectedEntries() == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QAction*> actions = m_ui->menuEntryCopyAttribute->actions();
|
||||
for (int i = EntryAttributes::DefaultAttributes.size() + 1; i < actions.size(); i++) {
|
||||
for (int i = m_countDefaultAttributes + 1; i < actions.size(); i++) {
|
||||
delete actions[i];
|
||||
}
|
||||
|
||||
Q_FOREACH (const QString& key, entry->attributes()->customKeys()) {
|
||||
Q_FOREACH (const QString& key, dbWidget->customEntryAttributes()) {
|
||||
QAction* action = m_ui->menuEntryCopyAttribute->addAction(key);
|
||||
m_copyAdditionalAttributeActions->addAction(action);
|
||||
}
|
||||
@ -276,9 +273,9 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||
switch (mode) {
|
||||
case DatabaseWidget::ViewMode: {
|
||||
bool inSearch = dbWidget->isInSearchMode();
|
||||
bool singleEntrySelected = dbWidget->entryView()->isSingleEntrySelected();
|
||||
bool entriesSelected = !dbWidget->entryView()->selectionModel()->selectedRows().isEmpty();
|
||||
bool groupSelected = dbWidget->groupView()->currentGroup();
|
||||
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1;
|
||||
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0;
|
||||
bool groupSelected = dbWidget->isGroupSelected();
|
||||
|
||||
m_ui->actionEntryNew->setEnabled(!inSearch);
|
||||
m_ui->actionEntryClone->setEnabled(singleEntrySelected && !inSearch);
|
||||
|
@ -77,6 +77,7 @@ private:
|
||||
QActionGroup* m_copyAdditionalAttributeActions;
|
||||
QStringList m_openDatabases;
|
||||
InactivityTimer* m_inactivityTimer;
|
||||
int m_countDefaultAttributes;
|
||||
|
||||
Q_DISABLE_COPY(MainWindow)
|
||||
};
|
||||
|
@ -100,9 +100,14 @@ Entry* EntryView::currentEntry()
|
||||
}
|
||||
}
|
||||
|
||||
int EntryView::numberOfSelectedEntries()
|
||||
{
|
||||
return selectionModel()->selectedRows().size();
|
||||
}
|
||||
|
||||
bool EntryView::isSingleEntrySelected()
|
||||
{
|
||||
return (selectionModel()->selectedRows().size() == 1);
|
||||
return (numberOfSelectedEntries() == 1);
|
||||
}
|
||||
|
||||
void EntryView::setCurrentEntry(Entry* entry)
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
Entry* entryFromIndex(const QModelIndex& index);
|
||||
void setEntryList(const QList<Entry*>& entries);
|
||||
bool inEntryListMode();
|
||||
int numberOfSelectedEntries();
|
||||
|
||||
public Q_SLOTS:
|
||||
void setGroup(Group* group);
|
||||
|
Loading…
Reference in New Issue
Block a user