Indicate read-only state in window title.

This commit is contained in:
Florian Geyer 2012-05-28 18:38:33 +02:00
parent 5201001f3a
commit 8aefb1ed82
3 changed files with 32 additions and 1 deletions

View File

@ -387,6 +387,15 @@ void DatabaseTabWidget::toggleSearch()
currentDatabaseWidget()->toggleSearch();
}
bool DatabaseTabWidget::readOnly(int index)
{
if (index == -1) {
index = currentIndex();
}
return indexDatabaseManagerStruct(index).readOnly;
}
void DatabaseTabWidget::updateTabName(Database* db)
{
int index = databaseIndex(db);
@ -451,6 +460,21 @@ Database* DatabaseTabWidget::indexDatabase(int index)
return 0;
}
DatabaseManagerStruct DatabaseTabWidget::indexDatabaseManagerStruct(int index)
{
QWidget* dbWidget = widget(index);
QHashIterator<Database*, DatabaseManagerStruct> i(m_dbList);
while (i.hasNext()) {
i.next();
if (i.value().dbWidget == dbWidget) {
return i.value();
}
}
return DatabaseManagerStruct();
}
Database* DatabaseTabWidget::databaseFromDatabaseWidget(DatabaseWidget* dbWidget)
{
QHashIterator<Database*, DatabaseManagerStruct> i(m_dbList);

View File

@ -74,6 +74,7 @@ public Q_SLOTS:
void editGroup();
void deleteGroup();
void toggleSearch();
bool readOnly(int index = -1);
Q_SIGNALS:
void entrySelectionChanged(bool singleEntrySelected);
@ -96,6 +97,8 @@ private:
bool closeDatabase(Database* db);
int databaseIndex(Database* db);
Database* indexDatabase(int index);
DatabaseManagerStruct indexDatabaseManagerStruct(int index);
Database* databaseFromDatabaseWidget(DatabaseWidget* dbWidget);
void insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct);
void updateLastDatabases(const QString& filename);

View File

@ -225,7 +225,11 @@ void MainWindow::updateWindowTitle()
setWindowTitle(BaseWindowTitle);
}
else {
setWindowTitle(m_ui->tabWidget->tabText(index).append(" - ").append(BaseWindowTitle));
QString windowTitle = m_ui->tabWidget->tabText(index);
if (m_ui->tabWidget->readOnly(index)) {
windowTitle.append(" [").append(tr("read-only")).append("]");
}
setWindowTitle(windowTitle.append(" - ").append(BaseWindowTitle));
}
}