summaryrefslogtreecommitdiffstats
path: root/seriestreewidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'seriestreewidget.cpp')
-rw-r--r--seriestreewidget.cpp38
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){