From 066cc53c2506fb7f7cb7b3b0d888243df611cacd Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 30 Jul 2010 19:59:52 +0200 Subject: Bugfix commit The journey through the internals of SheMov started by fixing SeriesTreeWidget::readSettings(). The selected index didn't really get selected on startup because only QItemSelectionModel::setCurrendt() was called. Replace it with QItemSelectionModel::select() and QTreeView::setCurrent(). Also fix SeriesTreeWidget::writeSettings() to only write selected items to QSettings() when something is selected. While working on selections I realized that there is a serious bug in Helper::moveToArchive. The destination directory in the archive must be created if it doesn't exist. For a testcase I needed an easy way to move files back from the archive to incoming directory, so I added FilesTreeWiget::moveToDirectory(). This lets you move files from the FilesTreeWidget to any directory. During testing I realized that SeriesTreeWidget::deleteFromSeries() QMessageBox() doesn't show files when deleting a series part. Fixed that by adding SeriesParts to file list. Finally a newly added SeriesPart gets selected and selected by expanding it first and then calling QItemSelectionModel::select() To make a long story short: 1. fix SeriesTreeWidget::{read,write}Settings 2. add FilesTreeWidget::moveToDirectory() 3. fix SeriesTreeWidget::deleteFromSeries() QMessageBox 4. fix selecting newly added SeriesParts --- filestreewidget.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'filestreewidget.cpp') diff --git a/filestreewidget.cpp b/filestreewidget.cpp index d27a22e..a348ac4 100644 --- a/filestreewidget.cpp +++ b/filestreewidget.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include @@ -139,6 +141,23 @@ void FilesTreeWidget::removeFiles(){ } } +void FilesTreeWidget::moveToDirectory(){ + QModelIndexList selected = mView->selectionModel()->selectedRows(); + if(selected.isEmpty()){ + return; + } + QSettings s; + QString startDir = s.value("paths/selecteddir", QDir::homePath()).toString(); + QString dir = QFileDialog::getExistingDirectory(this, tr("Select directory"), startDir); + if(!dir.isEmpty()){ + foreach(QModelIndex i, selected){ + QString source = i.data(FilesTreeModel::FullPathRole).toString(); + QString destination = QString("%1/%2").arg(dir).arg(i.data(FilesTreeModel::FileNameRole).toString()); + QFile::rename(source, destination); + } + } +} + void FilesTreeWidget::fileSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous){ Q_UNUSED(previous); int seriesPartId = current.data(FilesTreeModel::SeriesPartIdRole).toInt(); -- cgit v1.2.3-70-g09d2