summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archivemodel.cpp18
-rw-r--r--archiveview.cpp7
-rw-r--r--archiveview.h2
-rw-r--r--shemov.cpp13
-rw-r--r--shemov.h1
5 files changed, 15 insertions, 26 deletions
diff --git a/archivemodel.cpp b/archivemodel.cpp
index cbca042..59d1e74 100644
--- a/archivemodel.cpp
+++ b/archivemodel.cpp
@@ -112,18 +112,20 @@ bool ArchiveModel::setData(const QModelIndex &idx, const QVariant &value, int ro
}
SmTreeItem *item = itemAt(idx);
int nodeType = item->data(Type).toInt();
- // handle duplicate key error!!!
+ QVariant id = item->data(GenericId);
QSqlQuery updateQuery(mDb);
if(nodeType == GenreNode){
- updateQuery.prepare("UPDATE genres SET tgenrename = :value WHERE igenres_id = :id");
+ updateQuery.prepare("SELECT update_genres(:value, :id)");
}else if(nodeType == ActorNode){
- updateQuery.prepare("UPDATE actors SET tactorname = :value WHERE iactors_id = :id");
+ updateQuery.prepare("SELECT update_actors(:value, :id)");
}else if(nodeType == SeriesNode){
- updateQuery.prepare("UPDATE series SET tseries_name = :value WHERE iseries_id = :id");
+ updateQuery.prepare("SELECT update_series(:value, :id)");
+ }else if(nodeType == SeriesPartNode){
+ updateQuery.prepare("SELECT move_to_series(:value, :id)");
+ id = item->data(SeriesPartId);
}else{
return false;
}
- QVariant id = item->data(GenericId);
updateQuery.bindValue(":value", value);
updateQuery.bindValue(":id", id);
mDb.transaction();
@@ -131,12 +133,10 @@ bool ArchiveModel::setData(const QModelIndex &idx, const QVariant &value, int ro
mDb.commit();
item->setData(Name, value);
emit dataChanged(idx, idx);
- if(nodeType == SeriesNode){
- emit needRefresh();
- return true;
- }
+ emit needRefresh();
writeCache(mOrder, root());
}else{
+ // cannot happen!
mDb.rollback();
emitDatabaseError(updateQuery.lastError());
}
diff --git a/archiveview.cpp b/archiveview.cpp
index c376c06..ca5615c 100644
--- a/archiveview.cpp
+++ b/archiveview.cpp
@@ -260,13 +260,8 @@ void ArchiveTree::setModel(ArchiveProxy *model){
QTreeView::setModel(model);
}
-void ArchiveTree::rename(){
+void ArchiveTree::edit(){
QModelIndex idx = currentIndex();
- /*int nodeType = idx.data(ArchiveModel::TypeRole).toInt();
- if(nodeType == ArchiveModel::SeriesPartNode){
- impossible();
- return;
- }*/
QString currentName = idx.data(ArchiveModel::NameRole).toString();
QString question = QString(tr("Rename %1 to:")).arg(currentName);
QString newName = QInputDialog::getText(this, tr("Rename"), question, QLineEdit::Normal, currentName);
diff --git a/archiveview.h b/archiveview.h
index fa9a1d5..e3dfba6 100644
--- a/archiveview.h
+++ b/archiveview.h
@@ -83,7 +83,7 @@ class ArchiveTree : public SmTreeView {
virtual void setModel(ArchiveProxy *model);
public slots:
- void rename();
+ void edit();
void remove();
void editActors();
void editGenres();
diff --git a/shemov.cpp b/shemov.cpp
index 5d94021..c8f61d3 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -747,14 +747,10 @@ void SheMov::createActions(){
// ArchiveView actions
ArchiveController *c = SmGlobals::instance()->archiveController();
- // rename
- mArchiveViewRenameA = new QAction(tr("Rename..."), this);
- mArchiveViewRenameA->setData(ArchiveModel::AllNodes & ArchiveModel::SeriesNode);
- connect(mArchiveViewRenameA, SIGNAL(triggered()), c->archiveTree(), SLOT(rename()));
- // remove
- mArchiveViewRemoveA = new QAction(tr("Remove..."), this);
- //mArchiveViewRemoveA->setData(ArchiveModel::RemoveNode);
- connect(mArchiveViewRemoveA, SIGNAL(triggered()), c->archiveTree(), SLOT(remove()));
+ // edit
+ mArchiveViewRenameA = new QAction(tr("Edit..."), this);
+ mArchiveViewRenameA->setData(ArchiveModel::AllNodes);
+ connect(mArchiveViewRenameA, SIGNAL(triggered()), c->archiveTree(), SLOT(edit()));
// edit actors
mArchiveViewActorsA = new QAction(tr("Edit actors..."), this);
mArchiveViewActorsA->setData(ArchiveModel::SeriesPartNode);
@@ -1012,7 +1008,6 @@ void SheMov::createMenus(){
// Archive tree (exp.)
ArchiveController *c = SmGlobals::instance()->archiveController();
c->addActionForTree(mArchiveViewRenameA);
- c->addActionForTree(mArchiveViewRemoveA);
c->addActionForTree(createSeparator());
c->addActionForTree(mArchiveViewActorsA);
c->addActionForTree(mArchiveViewGenresA);
diff --git a/shemov.h b/shemov.h
index db4dd67..100ae30 100644
--- a/shemov.h
+++ b/shemov.h
@@ -188,7 +188,6 @@ class SheMov : public QMainWindow {
//ArchiveView actions
QAction *mArchiveViewRenameA;
- QAction *mArchiveViewRemoveA;
QAction *mArchiveViewActorsA;
QAction *mArchiveViewGenresA;
QAction *mArchiveViewPartnoA;