summaryrefslogtreecommitdiffstats
path: root/archivetreeview.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-11-28 11:58:57 +0100
committerArno <am@disconnect.de>2010-11-28 11:58:57 +0100
commitd1837c9c92c9f38a464f0473001db4e9a57d44e7 (patch)
tree9d815a4c1e1c550871565c92d7e0c8f312f05f72 /archivetreeview.cpp
parenteb4139c5c525c03d4c75c0a47acc92157008ca06 (diff)
downloadSheMov-d1837c9c92c9f38a464f0473001db4e9a57d44e7.tar.gz
SheMov-d1837c9c92c9f38a464f0473001db4e9a57d44e7.tar.bz2
SheMov-d1837c9c92c9f38a464f0473001db4e9a57d44e7.zip
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.
Diffstat (limited to 'archivetreeview.cpp')
-rw-r--r--archivetreeview.cpp38
1 files changed, 38 insertions, 0 deletions
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){