diff options
author | Arno <am@disconnect.de> | 2010-07-31 11:05:59 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-07-31 11:05:59 +0200 |
commit | 6d3b28f9b12964b161b5a7ac0038435cfdd6e27b (patch) | |
tree | 59d49ee1ab59b53bb762135d70759350f4b44159 /archivetreeview.cpp | |
parent | 066cc53c2506fb7f7cb7b3b0d888243df611cacd (diff) | |
download | SheMov-6d3b28f9b12964b161b5a7ac0038435cfdd6e27b.tar.gz SheMov-6d3b28f9b12964b161b5a7ac0038435cfdd6e27b.tar.bz2 SheMov-6d3b28f9b12964b161b5a7ac0038435cfdd6e27b.zip |
Added database maintenance code
Implemented a function in MappingTableModel to remove all actors/genres
with no references in the according mapping table. Available through the
"File" menu.
Diffstat (limited to 'archivetreeview.cpp')
-rw-r--r-- | archivetreeview.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/archivetreeview.cpp b/archivetreeview.cpp index 1ae3cc8..1d66fbe 100644 --- a/archivetreeview.cpp +++ b/archivetreeview.cpp @@ -16,6 +16,7 @@ #include <QSettings> #include <QHash> #include <QProcess> +#include <QMessageBox> #include "archivetreeview.h" #include "smglobals.h" @@ -99,6 +100,34 @@ void ArchiveTreeView::setFileViewMode(int mode){ constructWindowTitle(); } +void ArchiveTreeView::cleanDatabase(const QString &table){ + MappingTableModel *model = 0; + if(table == "genres"){ + model = mGenresModel; + }else if(table == "actors"){ + model = mActorsModel; + } + Q_ASSERT(model); + QHash<QString, int> zeroUsers = model->zeroUsers(); + if(zeroUsers.isEmpty()){ + QMessageBox::information(this, tr("Message"), tr("Nothing to clean up!")); + return; + } + QString message = QString(tr("<p>Really delete these items from %1?<p>")).arg(table); + message.append("<ul>"); + QStringList userNames = zeroUsers.keys(); + qSort(userNames); + foreach(QString s, userNames){ + message.append(QString("<li>%1</li>").arg(s)); + } + message.append("</ul>"); + int answer = QMessageBox::question(this, tr("Question"), message, QMessageBox::Yes | QMessageBox::No); + if(answer == QMessageBox::Yes){ + QList<int> ids = zeroUsers.values(); + model->deleteItems(ids); + } +} + void ArchiveTreeView::currentChanged(const QItemSelection &selected, const QItemSelection &deselected){ Q_UNUSED(selected); Q_UNUSED(deselected); |