From d1837c9c92c9f38a464f0473001db4e9a57d44e7 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 28 Nov 2010 11:58:57 +0100 Subject: Added action to copy file path to clipboard 4 new actions to copy the file path to clipboard. It's either the unix full path, the unix dir, the windows full path or the windows dir. For the latter '/' is replaced with '\' and a drive letter is prepended. The drive letter is configurable in the ConfigurationDialog. While at it I revamped it and added another tab to make it more user friendly. --- archivetreeview.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'archivetreeview.cpp') diff --git a/archivetreeview.cpp b/archivetreeview.cpp index 8e55058..2260052 100644 --- a/archivetreeview.cpp +++ b/archivetreeview.cpp @@ -174,6 +174,34 @@ void ArchiveTreeView::selectMovie(const QModelIndex &idx){ mNoCoverDialog->hide(); } +void ArchiveTreeView::copyPath(int type){ + QModelIndexList selected = mFilesWidget->filesTree()->selectionModel()->selectedRows(); + if(selected.isEmpty()){ + return; + } + QString fullPath = selected.at(0).data(FilesTreeModel::FullPathRole).toString(); + QFileInfo fi(fullPath); + if(!fi.exists()){ + int dvdNo = selected.at(0).data(FilesTreeModel::DvdNoRole).toInt(); + QString msg = QString(tr("File not found. File is archived on DVD #%1")).arg(QString::number(dvdNo)); + QMessageBox::critical(this, tr("Error"), msg); + return; + } + QClipboard *clipBoard = QApplication::clipboard(); + if(type == UnixFullPath){ + clipBoard->setText(fi.absoluteFilePath()); + } + if(type == UnixDir){ + clipBoard->setText(fi.absolutePath()); + } + if(type == WindowsFullPath){ + clipBoard->setText(createWindowsPath(fi.absoluteFilePath())); + } + if(type == WindowsDir){ + clipBoard->setText(createWindowsPath(fi.absolutePath())); + } +} + void ArchiveTreeView::currentChanged(const QItemSelection &selected, const QItemSelection &deselected){ Q_UNUSED(selected); Q_UNUSED(deselected); @@ -267,6 +295,16 @@ void ArchiveTreeView::constructWindowTitle(){ emit needWindowTitleChange(mWindowTitle); } +const QString ArchiveTreeView::createWindowsPath(const QString &path) const{ + QString retval = path; + QSettings s; + const QString strip = s.value("paths/strippath").toString(); + retval.remove(strip); + retval.replace('/', '\\'); + retval = QString("%1\\%2").arg(s.value("paths/windowsdrive").toString()).arg(retval); + return retval; +} + //NoCoverMovieModel NoCoverMovieModel::NoCoverMovieModel(const QStringList &headers, QObject *parent) : SmTreeModel(headers, parent){ -- cgit v1.2.3-70-g09d2