From dab3f05dcb2975c07247e3bebd8e9a7e8b9e83ce Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 10 Oct 2012 18:28:45 +0200 Subject: 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 --- seriestreewidget.cpp | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'seriestreewidget.cpp') diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index 2a487fb..49d5792 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -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 data; - data << tr("") << 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){ -- cgit v1.2.3-70-g09d2