Show in-edit-mode warning when database is locked.

This commit is contained in:
Felix Geyer 2014-05-15 22:51:13 +02:00
parent 50cbd80925
commit cda5e990ac
3 changed files with 17 additions and 3 deletions

View File

@ -189,7 +189,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
if (dbName.right(1) == "*") {
dbName.chop(1);
}
if (dbStruct.dbWidget->currentMode() == DatabaseWidget::EditMode && db->hasKey()) {
if (dbStruct.dbWidget->isInEditMode() && db->hasKey()) {
QMessageBox::StandardButton result =
MessageBox::question(
this, tr("Close?"),

View File

@ -167,7 +167,7 @@ DatabaseWidget::~DatabaseWidget()
{
}
DatabaseWidget::Mode DatabaseWidget::currentMode()
DatabaseWidget::Mode DatabaseWidget::currentMode() const
{
if (currentWidget() == Q_NULLPTR) {
return DatabaseWidget::None;
@ -183,6 +183,19 @@ DatabaseWidget::Mode DatabaseWidget::currentMode()
}
}
bool DatabaseWidget::isInEditMode() const
{
if (currentMode() == DatabaseWidget::LockedMode) {
return m_widgetBeforeLock != Q_NULLPTR
&& m_widgetBeforeLock != m_mainWidget
&& m_widgetBeforeLock != m_unlockDatabaseWidget;
}
else {
return currentMode() == DatabaseWidget::EditMode;
}
}
void DatabaseWidget::emitCurrentModeChanged()
{
Q_EMIT currentModeChanged(currentMode());

View File

@ -68,12 +68,13 @@ public:
int addWidget(QWidget* w);
void setCurrentIndex(int index);
void setCurrentWidget(QWidget* widget);
DatabaseWidget::Mode currentMode();
DatabaseWidget::Mode currentMode() const;
void lock();
void updateFilename(const QString& filename);
int numberOfSelectedEntries();
QStringList customEntryAttributes();
bool isGroupSelected();
bool isInEditMode() const;
Q_SIGNALS:
void closeRequest();