From f76b42f192a82f777cf77f3eecfab9ca7e31e396 Mon Sep 17 00:00:00 2001 From: Arno Date: Tue, 8 Jul 2014 08:13:30 +0200 Subject: Display unpack output in Dialog This was a difficult one. Got lost in the Semantics of QThread once again, but just 2 days later it works :) --- filesystemwidget.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'filesystemwidget.cpp') diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp index 983a40d..566919b 100644 --- a/filesystemwidget.cpp +++ b/filesystemwidget.cpp @@ -32,6 +32,7 @@ #include "smglobals.h" #include "delegates.h" #include "smdirmodel.h" +#include "smdialog.h" FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboardMode(None) { mModel = new FileSystemModel(this); @@ -78,6 +79,8 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar connect(mFileModel, SIGNAL(modelReset()), mFileView, SLOT(restoreSelection())); mPicViewer = SmGlobals::instance()->pictureViewer(); + mUnpackDlg = new UnpackDialog(this); + connect(mUnpackDlg, SIGNAL(workFinished()), this, SLOT(selectUnpackDir())); QWidget *fileWidget = new QWidget; mIconDirSplitter = new QSplitter(this); @@ -478,29 +481,24 @@ void FilesystemWidget::preview(){ } void FilesystemWidget::unpack(){ - QModelIndexList selectedIdxs = mFileView->selectionModel()->selectedIndexes(); + QModelIndexList selectedIdxs = mFileView->selectionModel()->selectedRows(); + mUnpackDlg->clearOutput(); + mUnpackDlg->setCloseEnabled(false); + mUnpackDlg->show(); foreach(QModelIndex idx, selectedIdxs){ - if(!idx.column() == SmDirModel::NameRole){ - return; - } QString mimeType = idx.data(SmDirModel::TypeRole).toString(); if(mimeType == "application/zip" || mimeType == "application/x-rar"){ - QString prg = "/usr/bin/7z"; - QString archive = idx.data(SmDirModel::NameRole).toString(); QStringList args = QStringList() << "-o/home/am/movs/pics/7z" << "-y" << "e" << idx.data(SmDirModel::FullPathRole).toString(); - QString msg = QString(tr("Unpacking %1")).arg(archive); - emit statusbarMessage(msg); - int retval = QProcess::execute(prg, args); - if(retval == 0){ - emit statusbarMessage(tr("Unpacking: success!")); - }else{ - emit statusbarMessage(tr("Unpacking: failed!")); - } + mUnpackDlg->appendCommand(args); } } - QModelIndex lastIdx = mModel->index("/home/am/movs/pics/7z"); - if(lastIdx.isValid()){ - mDirView->selectionModel()->setCurrentIndex(mDirProxy->mapFromSource(lastIdx), QItemSelectionModel::ClearAndSelect); + mUnpackDlg->doIt(); +} + +void FilesystemWidget::selectUnpackDir(){ + QModelIndex unpackDirIdx = mModel->index("/home/am/movs/pics/7z"); + if(unpackDirIdx.isValid()){ + mDirView->selectionModel()->setCurrentIndex(mDirProxy->mapFromSource(unpackDirIdx), QItemSelectionModel::ClearAndSelect); } } -- cgit v1.2.3-70-g09d2