diff options
author | Arno <am@disconnect.de> | 2012-10-10 18:28:45 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-10-10 18:28:45 +0200 |
commit | dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce (patch) | |
tree | 70ee72f169620d5a6b07b7c116a0455183f6ef26 /seriestreewidget.cpp | |
parent | d562d4a3527044aaeb36534bc2d4b65b587c9bb3 (diff) | |
download | SheMov-dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce.tar.gz SheMov-dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce.tar.bz2 SheMov-dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce.zip |
SeriesTreeModel fix
* make it possible to delete whole series again. No code fix, just the
database layout: add on delete cascade to metadata
* get rid of propertiesdialog.{cpp,h}. It was useless and called from
the "Edit.." context menu. Code bloat, I guess...
* Do something useful when calling "Edit...". Rename Series or ask for a
new SeriesPart
Diffstat (limited to 'seriestreewidget.cpp')
-rw-r--r-- | seriestreewidget.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index 2a487fb..49d5792 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -21,6 +21,7 @@ #include <QSettings> #include <QFileInfo> #include <QComboBox> +#include <QInputDialog> #include <QFile> #include <QEvent> #include <QHoverEvent> @@ -44,7 +45,6 @@ #include "filestreemodel.h" #include "helper.h" #include "hoverwindow.h" -#include "propertiesdialog.h" SeriesTreeWidget::SeriesTreeWidget(QWidget *parent) : QWidget(parent){ //filter bar @@ -107,19 +107,6 @@ SeriesTreeWidget::~SeriesTreeWidget(){ delete mCompleterProducer; } -void SeriesTreeWidget::newSeries(){ - QList<QVariant> data; - data << tr("<New series>") << QVariant() << QVariant() << QVariant() << SeriesTreeModel::NewSeries; - if(mModel->addRow(data, QModelIndex())){ - QModelIndex newRow = mModel->index(mModel->rowCount(QModelIndex()) - 1, 0, QModelIndex()); - if(newRow.isValid()){ - QModelIndex proxyIndex = mProxy->mapFromSource(newRow); - mView->selectionModel()->select(proxyIndex, QItemSelectionModel::ClearAndSelect); - mView->edit(proxyIndex); - } - } -} - void SeriesTreeWidget::seriesAdded(QString seriesName, int seriesPart, bool resort){ if(resort){ mProxy->invalidate(); @@ -350,15 +337,20 @@ void SeriesTreeWidget::expandItems(const QStringList &items){ void SeriesTreeWidget::editItem(){ QModelIndex current = mView->selectionModel()->currentIndex(); - QModelIndex real = mProxy->mapToSource(current); - if(real.data(SeriesTreeModel::TypeRole).toInt() == SeriesTreeModel::Part){ - PropertiesDialog dlg(this); - dlg.populate(real.data(SeriesTreeModel::SeriesPartIdRole).toInt()); - dlg.exec(); - } - /*QModelIndex real = mProxy->mapToSource(current); - EditSeriesDialog dlg(real, this); - dlg.exec();*/ + if(current.data(SeriesTreeModel::TypeRole).toInt() == SeriesTreeModel::Series){ + seriesTree()->edit(current); + return; + } + if(current.data(SeriesTreeModel::TypeRole).toInt() == SeriesTreeModel::Part){ + int currentPart = current.data(SeriesTreeModel::SeriesPartRole).toInt(); + bool dlgOk = false; + int newPart = QInputDialog::getInt(this, tr("Enter new series part"), tr("New series part"), currentPart, 1, 1000, 1, &dlgOk); + if(dlgOk){ + QModelIndex real = mProxy->mapToSource(current); + QModelIndex part = mModel->index(real.row(), SeriesTreeModel::SeriesPart, real.parent()); + mModel->setData(part, newPart, Qt::EditRole); + } + } } void SeriesTreeWidget::producerFinished(QStringListModel *model){ |