summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2015-05-17 09:47:30 +0200
committerArno <am@disconnect.de>2015-05-17 09:47:30 +0200
commit6f8107c1cb22938ee4c91d0993dc82e624c7c8de (patch)
tree57fc6e6fcf82e76c06011707fb3dcbc0ebaa7580
parent8c0070a69df9337dee81d4a9d645dd9726564681 (diff)
downloadSheMov-6f8107c1cb22938ee4c91d0993dc82e624c7c8de.tar.gz
SheMov-6f8107c1cb22938ee4c91d0993dc82e624c7c8de.tar.bz2
SheMov-6f8107c1cb22938ee4c91d0993dc82e624c7c8de.zip
Fix removing files from NewMovieWizard
Removing files didn't work as expected: It removed files more or less at random, because the indexes were from the proxy and weren't mapped back to the source. While at it, make it possible to remove several files at once and change the label of the button to make clear that the files are only removed from the view.
-rw-r--r--newmoviewizard.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index 137f7c2..1989e64 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -308,6 +308,7 @@ void MovieInfoPage::setupGui(){
mFileView->setItemDelegateForColumn(WizardTreeModel::FilePart, new FileNoDelegate(mFileView));
mFileView->setSortingEnabled(true);
mFileView->header()->moveSection(1, 3);
+ mFileView->setSelectionMode(QAbstractItemView::ExtendedSelection);
//add + remove files
QHBoxLayout *fileButtonLayout = new QHBoxLayout;
@@ -318,7 +319,7 @@ void MovieInfoPage::setupGui(){
mAddFile = new QPushButton(tr("Add files..."));
fileButtonLayout->addWidget(mAddFile);
connect(mAddFile, SIGNAL(clicked()), this, SLOT(addFiles()));
- mRemoveFile = new QPushButton(tr("Remove file"));
+ mRemoveFile = new QPushButton(tr("Remove from list"));
fileButtonLayout->addWidget(mRemoveFile);
connect(mRemoveFile, SIGNAL(clicked()), this, SLOT(removeFile()));
@@ -467,11 +468,20 @@ void MovieInfoPage::addFiles(){
}
void MovieInfoPage::removeFile(){
- QModelIndexList selected = mFileView->selectionModel()->selectedRows();
+ QModelIndexList selected = mFileView->selectionModel()->selectedRows();
+ QList<QPersistentModelIndex> curSel;
+ foreach(QModelIndex idx, selected){
+ curSel << QPersistentModelIndex(idx);
+ }
if(selected.isEmpty()){
return;
}
- mFileModel->removeRows(selected.at(0).row(), 1, selected.at(0).parent());
+ foreach(QPersistentModelIndex pi, curSel){
+ QModelIndex cur = mProxy->mapToSource(pi);
+ if(cur.isValid()){
+ mFileModel->removeRow(cur.row(), cur.parent());
+ }
+ }
}
MovieMappingPage::MovieMappingPage(const QString &table, QWidget *parent) : QWizardPage(parent), mTable(table){