diff options
author | Arno <am@disconnect.de> | 2010-07-09 21:07:10 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-07-09 21:07:10 +0200 |
commit | d9d32f44d64834754650fc4fe70a4d7aae449e0c (patch) | |
tree | 9aab57b91222613020b9df1f369eda0c2358b7ab /mappingtablemodel.cpp | |
parent | 4f313fb96ada615b209a6e37832da140abf63b07 (diff) | |
download | SheMov-d9d32f44d64834754650fc4fe70a4d7aae449e0c.tar.gz SheMov-d9d32f44d64834754650fc4fe70a4d7aae449e0c.tar.bz2 SheMov-d9d32f44d64834754650fc4fe70a4d7aae449e0c.zip |
Final version of NewMovieWizard::accept() (hopefully)
Actually made this function work. Forgot to handle actors and genres.
Also several bugfixes in other parts:
-fix typo in FilesTreeModel query
-commit changes ind MappingTableModel::addItem, making the genre and
actor widgets work as intended
-remove redundant MappingTableModel::find(), already implemented in
SmTreeModel
-call next() instead of exec() in SeriesTreeModel::addSeriesPart. Query
is already executing if it's a select
-use QModelIndex::row() instead of column() in
MappingTableWidget::removeItem()
-add partNo to layout in MovieInfopage::MovieInfoPage()
-add convenience function setMappings() to MappingTableModel
Diffstat (limited to 'mappingtablemodel.cpp')
-rw-r--r-- | mappingtablemodel.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/mappingtablemodel.cpp b/mappingtablemodel.cpp index ad569ee..bcb601e 100644 --- a/mappingtablemodel.cpp +++ b/mappingtablemodel.cpp @@ -106,18 +106,19 @@ bool MappingTableModel::contains(const QString &value) const{ return mItemNames.contains(value); } -QModelIndex MappingTableModel::find(const QVariant &value, int column, const QModelIndex &parent) const{ - SmTreeItem *parentItem = root(); - if(parent.isValid()){ - parentItem = static_cast<SmTreeItem*>(parent.internalPointer()); - } - for(int i = 0; i < parentItem->childCount(); ++i){ - SmTreeItem *cur = parentItem->child(i); - if(cur->data(column) == value){ - return index(i, column, parent); +void MappingTableModel::setMappings(const QStringList &itemNames, int seriesPartId){ + if(seriesPartId == -1){ + return; + } + foreach(const QString name, itemNames){ + QModelIndex itemIdx = find(name); + if(!itemIdx.isValid()){ + addItem(name); } + itemIdx = find(name); + int itemId = itemIdx.data(ItemIdRole).toInt(); + addMapping(seriesPartId, itemId); } - return QModelIndex(); } bool MappingTableModel::addItem(const QVariant &name){ @@ -136,6 +137,7 @@ bool MappingTableModel::addItem(const QVariant &name){ data << newValue << newId; addRow(data, QModelIndex()); mItemNames << newValue; + mDb.commit(); emit needResort(); return true; } @@ -160,9 +162,9 @@ bool MappingTableModel::removeItem(const QModelIndex &idx){ return false; } -bool MappingTableModel::addMapping(int seriesId, int itemId){ +bool MappingTableModel::addMapping(int seriesPartId, int itemId){ mDb.transaction(); - mAddMappingQuery->bindValue(":id1", seriesId); + mAddMappingQuery->bindValue(":id1", seriesPartId); mAddMappingQuery->bindValue(":id2", itemId); if(!mAddMappingQuery->exec()){ mDb.rollback(); |