diff --git a/krusader/CMakeLists.txt b/krusader/CMakeLists.txt --- a/krusader/CMakeLists.txt +++ b/krusader/CMakeLists.txt @@ -12,7 +12,6 @@ add_subdirectory(KViewer) add_subdirectory(Locate) add_subdirectory(MountMan) -add_subdirectory(Queue) add_subdirectory(Panel) add_subdirectory(Search) add_subdirectory(Splitter) @@ -57,7 +56,6 @@ Konfigurator KViewer MountMan - Queue VFS Search Splitter diff --git a/krusader/Dialogs/krdialogs.h b/krusader/Dialogs/krdialogs.h --- a/krusader/Dialogs/krdialogs.h +++ b/krusader/Dialogs/krdialogs.h @@ -61,46 +61,37 @@ */ static QUrl getFile(QString text, const QUrl& url, const QUrl& cwd); static QUrl getDir(QString text, const QUrl& url, const QUrl& cwd); - static QUrl getDir(QString text, const QUrl& url, const QUrl& cwd, bool & queue); - static QUrl getDir(QString text, const QUrl& url, const QUrl& cwd, bool & queue, bool & preserveAttrs); - static QUrl getDir(QString text, const QUrl& url, const QUrl& cwd, bool & queue, bool & preserveAttrs, QUrl &baseURL); + static QUrl getDir(QString text, const QUrl& url, const QUrl& cwd, bool & preserveAttrs); + static QUrl getDir(QString text, const QUrl& url, const QUrl& cwd, bool & preserveAttrs, QUrl &baseURL); }; class KUrlRequesterDlgForCopy : public QDialog { Q_OBJECT public: KUrlRequesterDlgForCopy(const QUrl& url, const QString& text, bool presAttrs, QWidget *parent, bool modal = true, QUrl baseURL = QUrl()); - KUrlRequesterDlgForCopy(); + KUrlRequesterDlgForCopy() {}; QUrl selectedURL() const; QUrl baseURL() const; bool preserveAttrs(); - bool enqueue() { - return queue; - } bool copyDirStructure(); void hidePreserveAttrs() { // preserveAttrsCB->hide(); } KUrlRequester *urlRequester(); -protected: - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; - private slots: - void slotQueue(); void slotTextChanged(const QString &); void slotDirStructCBChanged(); private: KUrlRequester *urlRequester_; QComboBox *baseUrlCombo; // QCheckBox *preserveAttrsCB; QCheckBox *copyDirStructureCB; QPushButton *okButton; - bool queue; }; class KRGetDate : public QDialog diff --git a/krusader/Dialogs/krdialogs.cpp b/krusader/Dialogs/krdialogs.cpp --- a/krusader/Dialogs/krdialogs.cpp +++ b/krusader/Dialogs/krdialogs.cpp @@ -44,7 +44,6 @@ #include "../VFS/vfs.h" #include "../defaults.h" - QUrl KChooseDir::getFile(QString text, const QUrl& url, const QUrl& cwd) { QScopedPointer dlg(new KUrlRequesterDialog(vfs::ensureTrailingSlash(url), text, krMainWindow)); @@ -60,41 +59,25 @@ return u; } - QUrl KChooseDir::getDir(QString text, const QUrl& url, const QUrl& cwd) { - QScopedPointer dlg(new KUrlRequesterDialog(vfs::ensureTrailingSlash(url), text, krMainWindow)); - dlg->urlRequester()->setStartDir(cwd); - dlg->urlRequester()->setMode(KFile::Directory); - dlg->exec(); - QUrl u = dlg->selectedUrl(); - if (u.scheme() == "zip" || u.scheme() == "krarc" || u.scheme() == "tar" || u.scheme() == "iso") { - if (QDir(u.path()).exists()) { - u.setScheme("file"); - } - } - return u; -} - -QUrl KChooseDir::getDir(QString text, const QUrl& url, const QUrl& cwd, bool &queue) -{ - QScopedPointer dlg(new KUrlRequesterDlgForCopy(vfs::ensureTrailingSlash(url), - text, false, krMainWindow)); + QScopedPointer dlg( + new KUrlRequesterDlgForCopy(vfs::ensureTrailingSlash(url), text, false, krMainWindow)); dlg->hidePreserveAttrs(); dlg->urlRequester()->setStartDir(cwd); dlg->urlRequester()->setMode(KFile::Directory); dlg->exec(); QUrl u = dlg->selectedURL(); - if (u.scheme() == "zip" || u.scheme() == "krarc" || u.scheme() == "tar" || u.scheme() == "iso") { + if (u.scheme() == "zip" || u.scheme() == "krarc" || u.scheme() == "tar" || + u.scheme() == "iso") { if (QDir(u.path()).exists()) { u.setScheme("file"); } } - queue = dlg->enqueue(); return u; } -QUrl KChooseDir::getDir(QString text, const QUrl& url, const QUrl& cwd, bool &queue, bool &preserveAttrs) +QUrl KChooseDir::getDir(QString text, const QUrl& url, const QUrl& cwd, bool &preserveAttrs) { QScopedPointer dlg(new KUrlRequesterDlgForCopy(vfs::ensureTrailingSlash(url), text, preserveAttrs, krMainWindow)); @@ -108,11 +91,10 @@ } } preserveAttrs = dlg->preserveAttrs(); - queue = dlg->enqueue(); return u; } -QUrl KChooseDir::getDir(QString text, const QUrl& url, const QUrl& cwd, bool &queue, bool &preserveAttrs, QUrl &baseURL) +QUrl KChooseDir::getDir(QString text, const QUrl& url, const QUrl& cwd, bool &preserveAttrs, QUrl &baseURL) { QScopedPointer dlg(new KUrlRequesterDlgForCopy(vfs::ensureTrailingSlash(url), text, preserveAttrs, krMainWindow, @@ -132,13 +114,12 @@ baseURL = QUrl(); } preserveAttrs = dlg->preserveAttrs(); - queue = dlg->enqueue(); return u; } KUrlRequesterDlgForCopy::KUrlRequesterDlgForCopy(const QUrl &urlName, const QString& _text, bool /*presAttrs*/, QWidget *parent, bool modal, QUrl baseURL) - : QDialog(parent), baseUrlCombo(0), copyDirStructureCB(0), queue(false) + : QDialog(parent), baseUrlCombo(0), copyDirStructureCB(0) { setWindowModality(modal ? Qt::WindowModal : Qt::NonModal); @@ -189,33 +170,15 @@ okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); - QPushButton *queueButton = new QPushButton(i18n("F2 Queue"), this); - buttonBox->addButton(queueButton, QDialogButtonBox::ActionRole); connect(buttonBox, SIGNAL(accepted()), SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), SLOT(reject())); - connect(queueButton, SIGNAL(clicked()), SLOT(slotQueue())); connect(urlRequester_, SIGNAL(textChanged(QString)), SLOT(slotTextChanged(QString))); urlRequester_->setFocus(); bool state = !urlName.isEmpty(); okButton->setEnabled(state); } -KUrlRequesterDlgForCopy::KUrlRequesterDlgForCopy() -{ -} - -void KUrlRequesterDlgForCopy::keyPressEvent(QKeyEvent *e) -{ - switch (e->key()) { - case Qt::Key_F2: - slotQueue(); - return; - default: - QDialog::keyPressEvent(e); - } -} - bool KUrlRequesterDlgForCopy::preserveAttrs() { // return preserveAttrsCB->isChecked(); @@ -235,12 +198,6 @@ okButton->setEnabled(state); } -void KUrlRequesterDlgForCopy::slotQueue() -{ - queue = true; - accept(); -} - void KUrlRequesterDlgForCopy::slotDirStructCBChanged() { baseUrlCombo->setEnabled(copyDirStructureCB->isChecked()); diff --git a/krusader/Dialogs/packgui.h b/krusader/Dialogs/packgui.h --- a/krusader/Dialogs/packgui.h +++ b/krusader/Dialogs/packgui.h @@ -45,12 +45,10 @@ protected slots: void accept(); void reject(); - virtual void slotQueue(); public: static QString filename, destination, type; static QMap extraProps; - static bool queue; }; #endif diff --git a/krusader/Dialogs/packgui.cpp b/krusader/Dialogs/packgui.cpp --- a/krusader/Dialogs/packgui.cpp +++ b/krusader/Dialogs/packgui.cpp @@ -53,7 +53,6 @@ QString PackGUI::destination = 0; QString PackGUI::type = 0; QMap PackGUI::extraProps; -bool PackGUI::queue = false; PackGUI::PackGUI(QString defaultName, QString defaultPath, int noOfFiles, QString filename) : PackGUIBase(0) @@ -95,8 +94,6 @@ } checkConsistency(); - queue = false; - // and go on with the normal stuff dirData->setText(defaultPath); nameData->setText(defaultName); @@ -137,10 +134,3 @@ type.clear(); PackGUIBase::reject(); } - -void PackGUI::slotQueue() -{ - queue = true; - PackGUIBase::slotQueue(); -} - diff --git a/krusader/Dialogs/packguibase.h b/krusader/Dialogs/packguibase.h --- a/krusader/Dialogs/packguibase.h +++ b/krusader/Dialogs/packguibase.h @@ -77,7 +77,6 @@ QLineEdit* password; QLineEdit* passwordAgain; QLabel* passwordConsistencyLabel; - QPushButton* queueButton; QPushButton* okButton; QPushButton* cancelButton; QPushButton* advancedButton; @@ -96,12 +95,7 @@ void expand(); void checkConsistency(); -protected slots: - virtual void slotQueue(); - protected: - virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; - QHBoxLayout* hbox; QHBoxLayout* hbox_2; QHBoxLayout* hbox_3; diff --git a/krusader/Dialogs/packguibase.cpp b/krusader/Dialogs/packguibase.cpp --- a/krusader/Dialogs/packguibase.cpp +++ b/krusader/Dialogs/packguibase.cpp @@ -309,10 +309,6 @@ QSpacerItem* spacer_2 = new QSpacerItem(140, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); hbox_6->addItem(spacer_2); - queueButton = new QPushButton(this); - queueButton->setText(i18n("F2 Queue")); - hbox_6->addWidget(queueButton); - okButton = new QPushButton(this); okButton->setText(i18n("OK")); okButton->setDefault(true); @@ -325,7 +321,6 @@ grid->addLayout(hbox_6, 6, 0); // signals and slots connections - connect(queueButton, SIGNAL(clicked()), this, SLOT(slotQueue())); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(advancedButton, SIGNAL(clicked()), this, SLOT(expand())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); @@ -504,20 +499,3 @@ } return true; } - -void PackGUIBase::slotQueue() -{ - accept(); -} - -void PackGUIBase::keyPressEvent(QKeyEvent *e) -{ - switch (e->key()) { - case Qt::Key_F2: - slotQueue(); - return; - default: - QDialog::keyPressEvent(e); - } -} - diff --git a/krusader/Panel/listpanelactions.cpp b/krusader/Panel/listpanelactions.cpp --- a/krusader/Panel/listpanelactions.cpp +++ b/krusader/Panel/listpanelactions.cpp @@ -85,8 +85,6 @@ actF4 = action(i18n("Edit File"), 0, Qt::Key_F4, _func, SLOT(edit()) , "F4_Edit"); actF5 = action(i18n("Copy to other panel"), 0, Qt::Key_F5, _func, SLOT(copyFiles()) , "F5_Copy"); actF6 = action(i18n("Move..."), 0, Qt::Key_F6, _func, SLOT(moveFiles()) , "F6_Move"); - actShiftF5 = action(i18n("Copy by queue..."), 0, Qt::SHIFT + Qt::Key_F5, _func, SLOT(copyFilesByQueue()) , "F5_Copy_Queue"); - actShiftF6 = action(i18n("Move by queue..."), 0, Qt::SHIFT + Qt::Key_F6, _func, SLOT(moveFilesByQueue()) , "F6_Move_Queue"); actF7 = action(i18n("New Folder..."), "folder-new", Qt::Key_F7, _func, SLOT(mkdir()) , "F7_Mkdir"); actF8 = action(i18n("Delete"), "edit-delete", Qt::Key_F8, _func, SLOT(deleteFiles()) , "F8_Delete"); actF9 = action(i18n("Start Terminal Here"), "utilities-terminal", Qt::Key_F9, _func, SLOT(terminal()) , "F9_Terminal"); diff --git a/krusader/Panel/panelfunc.h b/krusader/Panel/panelfunc.h --- a/krusader/Panel/panelfunc.h +++ b/krusader/Panel/panelfunc.h @@ -77,14 +77,8 @@ void viewDlg(); void edit(); void editNew(); // create a new textfile and edit it - void copyFiles(bool enqueue = false); - void moveFiles(bool enqueue = false); - void copyFilesByQueue() { - copyFiles(true); - } - void moveFilesByQueue() { - moveFiles(true); - } + void copyFiles(); + void moveFiles(); /*! * asks the user the new directory name */ diff --git a/krusader/Panel/panelfunc.cpp b/krusader/Panel/panelfunc.cpp --- a/krusader/Panel/panelfunc.cpp +++ b/krusader/Panel/panelfunc.cpp @@ -89,7 +89,6 @@ #include "../Dialogs/checksumdlg.h" #include "../KViewer/krviewer.h" #include "../GUI/syncbrowsebutton.h" -#include "../Queue/queue_mgr.h" QPointer ListPanelFunc::copyToClipboardOrigin; @@ -606,10 +605,9 @@ fileToCreate = QUrl(); } -void ListPanelFunc::moveFiles(bool enqueue) +void ListPanelFunc::moveFiles() { PreserveMode pmode = PM_DEFAULT; - bool queue = enqueue; QStringList fileNames; panel->getSelectedNames(&fileNames); @@ -631,7 +629,7 @@ // ask the user for the copy dest virtualBaseURL = getVirtualBaseURL(); - dest = KChooseDir::getDir(s, dest, panel->virtualPath(), queue, preserveAttrs, virtualBaseURL); + dest = KChooseDir::getDir(s, dest, panel->virtualPath(), preserveAttrs, virtualBaseURL); if (dest.isEmpty()) return ; // the user canceled if (preserveAttrs) @@ -649,30 +647,7 @@ // file above the current item; panel->prepareToDelete(); - if (queue) { - KIOJobWrapper *job = 0; - if (!virtualBaseURL.isEmpty()) { - job = KIOJobWrapper::virtualMove(&fileNames, files(), dest, virtualBaseURL, pmode, true); - job->connectTo(SIGNAL(result(KJob*)), this, SLOT(refresh())); - if (dest.matches(panel->otherPanel()->virtualPath(), QUrl::StripTrailingSlash)) - job->connectTo(SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); - } else { - // you can rename only *one* file not a batch, - // so a batch dest must alwayes be a directory - if (fileNames.count() > 1) { - dest = vfs::ensureTrailingSlash(dest); - } - job = KIOJobWrapper::move(pmode, fileUrls, dest, true); - job->setAutoErrorHandlingEnabled(true); - // refresh our panel when done - job->connectTo(SIGNAL(result(KJob*)), this, SLOT(refresh())); - if (dest.matches(panel->virtualPath(), QUrl::StripTrailingSlash) || - KIO::upUrl(dest).matches(panel->virtualPath(), QUrl::StripTrailingSlash)) - // refresh our panel when done - job->connectTo(SIGNAL(result(KJob*)), this, SLOT(refresh())); - } - QueueManager::currentQueue()->enqueue(job); - } else if (!virtualBaseURL.isEmpty()) { + if (!virtualBaseURL.isEmpty()) { // keep the directory structure for virtual paths VirtualCopyJob *vjob = new VirtualCopyJob(&fileNames, files(), dest, virtualBaseURL, pmode, KIO::CopyJob::Move, true); connect(vjob, SIGNAL(result(KJob*)), this, SLOT(refresh())); @@ -806,10 +781,9 @@ return base; } -void ListPanelFunc::copyFiles(bool enqueue) +void ListPanelFunc::copyFiles() { PreserveMode pmode = PM_DEFAULT; - bool queue = enqueue; QStringList fileNames; panel->getSelectedNames(&fileNames); @@ -832,7 +806,7 @@ // ask the user for the copy dest virtualBaseURL = getVirtualBaseURL(); - dest = KChooseDir::getDir(s, dest, panel->virtualPath(), queue, preserveAttrs, virtualBaseURL); + dest = KChooseDir::getDir(s, dest, panel->virtualPath(), preserveAttrs, virtualBaseURL); if (dest.isEmpty()) return ; // the user canceled if (preserveAttrs) @@ -843,28 +817,7 @@ QList fileUrls = files() ->vfs_getFiles(fileNames); - if (queue) { - KIOJobWrapper *job = 0; - if (!virtualBaseURL.isEmpty()) { - job = KIOJobWrapper::virtualCopy(&fileNames, files(), dest, virtualBaseURL, pmode, true); - job->connectTo(SIGNAL(result(KJob*)), this, SLOT(refresh())); - if (dest.matches(panel->otherPanel()->virtualPath(), QUrl::StripTrailingSlash)) - job->connectTo(SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); - } else { - // you can rename only *one* file not a batch, - // so a batch dest must alwayes be a directory - if (fileNames.count() > 1) { - dest = vfs::ensureTrailingSlash(dest); - } - job = KIOJobWrapper::copy(pmode, fileUrls, dest, true); - job->setAutoErrorHandlingEnabled(true); - if (dest.matches(panel->virtualPath(), QUrl::StripTrailingSlash) || - KIO::upUrl(dest).matches(panel->virtualPath(), QUrl::StripTrailingSlash)) - // refresh our panel when done - job->connectTo(SIGNAL(result(KJob*)), this, SLOT(refresh())); - } - QueueManager::currentQueue()->enqueue(job); - } else if (!virtualBaseURL.isEmpty()) { + if (!virtualBaseURL.isEmpty()) { // keep the directory structure for virtual paths VirtualCopyJob *vjob = new VirtualCopyJob(&fileNames, files(), dest, virtualBaseURL, pmode, KIO::CopyJob::Copy, true); connect(vjob, SIGNAL(result(KJob*)), this, SLOT(refresh())); @@ -1082,24 +1035,14 @@ return; } - if (PackGUI::queue) { - KIOJobWrapper *job = KIOJobWrapper::pack(files()->vfs_getOrigin(), destURL, fileNames, - PackGUI::type, PackGUI::extraProps, true); - job->setAutoErrorHandlingEnabled(true); - - if (packToOtherPanel) - job->connectTo(SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); + PackJob * job = PackJob::createPacker(files()->vfs_getOrigin(), destURL, fileNames, PackGUI::type, PackGUI::extraProps); + job->setUiDelegate(new KIO::JobUiDelegate()); + KIO::getJobTracker()->registerJob(job); + job->ui()->setAutoErrorHandlingEnabled(true); - QueueManager::currentQueue()->enqueue(job); - } else { - PackJob * job = PackJob::createPacker(files()->vfs_getOrigin(), destURL, fileNames, PackGUI::type, PackGUI::extraProps); - job->setUiDelegate(new KIO::JobUiDelegate()); - KIO::getJobTracker()->registerJob(job); - job->ui()->setAutoErrorHandlingEnabled(true); + if (packToOtherPanel) + connect(job, SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); - if (packToOtherPanel) - connect(job, SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); - } } void ListPanelFunc::testArchive() @@ -1117,7 +1060,6 @@ void ListPanelFunc::unpack() { - QStringList fileNames; panel->getSelectedNames(&fileNames); if (fileNames.isEmpty()) @@ -1130,29 +1072,19 @@ s = i18np("Unpack %1 file to:", "Unpack %1 files to:", fileNames.count()); // ask the user for the copy dest - bool queue = false; - QUrl dest = KChooseDir::getDir(s, panel->otherPanel()->virtualPath(), panel->virtualPath(), queue); + QUrl dest = KChooseDir::getDir(s, panel->otherPanel()->virtualPath(), panel->virtualPath()); if (dest.isEmpty()) return ; // the user canceled bool packToOtherPanel = (dest.matches(panel->otherPanel()->virtualPath(), QUrl::StripTrailingSlash)); - if (queue) { - KIOJobWrapper *job = KIOJobWrapper::unpack(files()->vfs_getOrigin(), dest, fileNames, true); - job->setAutoErrorHandlingEnabled(true); - - if (packToOtherPanel) - job->connectTo(SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); + UnpackJob * job = UnpackJob::createUnpacker(files()->vfs_getOrigin(), dest, fileNames); + job->setUiDelegate(new KIO::JobUiDelegate()); + KIO::getJobTracker()->registerJob(job); + job->ui()->setAutoErrorHandlingEnabled(true); - QueueManager::currentQueue()->enqueue(job); - } else { - UnpackJob * job = UnpackJob::createUnpacker(files()->vfs_getOrigin(), dest, fileNames); - job->setUiDelegate(new KIO::JobUiDelegate()); - KIO::getJobTracker()->registerJob(job); - job->ui()->setAutoErrorHandlingEnabled(true); + if (packToOtherPanel) + connect(job, SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); - if (packToOtherPanel) - connect(job, SIGNAL(result(KJob*)), panel->otherPanel()->func, SLOT(refresh())); - } } // a small ugly function, used to prevent duplication of EVERY line of diff --git a/krusader/Queue/CMakeLists.txt b/krusader/Queue/CMakeLists.txt deleted file mode 100644 --- a/krusader/Queue/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -include_directories(${KF5_INCLUDES_DIRS} ${QT_INCLUDES}) - -set(Queue_SRCS - queue.cpp - queue_mgr.cpp - queuewidget.cpp - queuedialog.cpp) - -add_library(Queue STATIC ${Queue_SRCS}) - -target_link_libraries(Queue - KF5::ConfigCore - KF5::ConfigGui - KF5::I18n - KF5::KIOCore - KF5::WidgetsAddons -) diff --git a/krusader/Queue/queue.h b/krusader/Queue/queue.h deleted file mode 100644 --- a/krusader/Queue/queue.h +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#ifndef QUEUE_H -#define QUEUE_H - -#include "../VFS/kiojobwrapper.h" - -// QtCore -#include -#include -#include -#include - -class KJob; - -#define PERCENT_UNUSED -2 -#define PERCENT_UNKNOWN -1 - -/** - * Queue can hold anything which inherits KIO::Job, and schedule it, start it, stop etc... - * the main reason to hold the Job itself (at least for phase 1) is to keep the code - * in krusader relatively unchaged, and allow to create the job as usual and choose if - * to start it, or queue it. - * - */ -class Queue: public QObject -{ - Q_OBJECT -public: - Queue(const QString& name); - virtual ~Queue(); - - inline const QString& name() const { - return _name; - } - void enqueue(KIOJobWrapper *job); - int count() { - return _jobs.size(); - } - bool isSuspended() { - return _suspended; - } - QTime scheduleTime(); - int getPercent() { - return _percent; - } - void remove(KIOJobWrapper *); - - QList itemDescriptions(); - QList items(); - -public slots: - void suspend(); - void resume(); - void schedule(const QTime &); - -protected slots: - void slotJobDestroyed(QObject *); - void slotResult(KJob *); - void slotPercent(KJob *, unsigned long percent); - -protected: - QString _name; - QList _jobs; - bool _suspended; - QTimer _scheduleTimer; - QTime _scheduleTime; - int _percent; - -signals: - void showQueueDialog(); - void changed(); - void emptied(); - void stateChanged(); - void percent(Queue *, int value); -}; - -#endif // QUEUE_H diff --git a/krusader/Queue/queue.cpp b/krusader/Queue/queue.cpp deleted file mode 100644 --- a/krusader/Queue/queue.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#include "queue.h" -#include "../krglobal.h" - -// QtCore -#include - -#include -#include - -Queue::Queue(const QString& name): _name(name), _suspended(false), _percent(PERCENT_UNUSED) -{ - connect(&_scheduleTimer, SIGNAL(timeout()), this, SLOT(resume())); -} - -Queue::~Queue() -{ - foreach(KIOJobWrapper * job, _jobs) { - job->abort(); - delete job; - } - _jobs.clear(); - // TODO: save queue on delete? or just delete jobs -} - -void Queue::enqueue(KIOJobWrapper *job) -{ - bool isRunning = _jobs.count(); - _jobs.append(job); - connect(job, SIGNAL(destroyed(QObject *)), this, SLOT(slotJobDestroyed(QObject *))); - job->connectTo(SIGNAL(result(KJob*)), this, SLOT(slotResult(KJob*))); - job->connectTo(SIGNAL(percent(KJob*, unsigned long)), this, SLOT(slotPercent(KJob*, unsigned long))); - - if (!_suspended && !isRunning) { - job->start(); - slotPercent(0, PERCENT_UNKNOWN); - } - - emit changed(); - emit showQueueDialog(); -} - -void Queue::slotJobDestroyed(QObject * obj) -{ - KIOJobWrapper * jw = (KIOJobWrapper*) obj; - bool current = false; - if (_jobs.count() > 0 && _jobs[ 0 ] == jw) - current = true; - _jobs.removeAll(jw); - if (current) - slotPercent(0, PERCENT_UNUSED); - if (!_suspended && current && _jobs.count() > 0) { - _jobs[ 0 ]->start(); - slotPercent(0, PERCENT_UNKNOWN); - } - emit changed(); -} - -void Queue::slotResult(KJob * job) -{ - if (_jobs.count() > 0) { - KIOJobWrapper * jw = _jobs[ 0 ]; - KIO::Job * kjob = jw->job(); - if (kjob && kjob == job) { - slotPercent(0, PERCENT_UNUSED); - _jobs.removeAll(jw); - if (job->error() && _jobs.count() > 0) { - // what to do with the other elements in the queue - QString message = i18n("An error occurred during processing the queue.\n"); - if (job->error() == KIO::ERR_USER_CANCELED) - message = i18n("The last processed element in the queue was aborted.\n"); - message += i18n("Do you wish to continue with the next element, delete the queue or suspend the queue?"); - int res = KMessageBox::questionYesNoCancel(krMainWindow, message, - i18n("Krusader::Queue"), KStandardGuiItem::cont(), - KStandardGuiItem::del(), KGuiItem(i18n("Suspend"))); - switch (res) { - case KMessageBox::Yes: // continue - break; - case KMessageBox::No: // delete the queue - foreach(KIOJobWrapper * job, _jobs) { - job->abort(); - delete job; - } - _jobs.clear(); - emit changed(); - emit emptied(); - return; - default: // suspend - emit changed(); - suspend(); - return; - } - } - - emit changed(); - if (!_suspended) { - if (_jobs.count() > 0) { - _jobs[ 0 ]->start(); - slotPercent(0, PERCENT_UNKNOWN); - } else - emit emptied(); - } - } - } -} - -QList Queue::items() -{ - return _jobs; -} - -QList Queue::itemDescriptions() -{ - QList ret; - foreach(KIOJobWrapper *job, _jobs) { - ret.append(job->typeStr() + " : " + job->url().toDisplayString()); - } - return ret; -} - -void Queue::suspend() -{ - _suspended = true; - if ((_jobs.count() > 0) && _jobs[ 0 ]->isStarted()) - _jobs[ 0 ]->suspend(); - - emit stateChanged(); -} - -void Queue::resume() -{ - _suspended = false; - _scheduleTimer.stop(); - if (_jobs.count() > 0) { - if (_jobs[ 0 ]->isSuspended()) - _jobs[ 0 ]->resume(); - else if (!_jobs[ 0 ]->isStarted()) { - _jobs[ 0 ]->start(); - slotPercent(0, PERCENT_UNKNOWN); - } - } - - emit stateChanged(); -} - -void Queue::schedule(const QTime &time) -{ - QTime nowTime = QTime::currentTime(); - _suspended = true; - if ((_jobs.count() > 0) && _jobs[ 0 ]->isStarted()) - _jobs[ 0 ]->suspend(); - - int now = ((nowTime.hour() * 60) + nowTime.minute()) * 60 + nowTime.second(); - int schedule = ((time.hour() * 60) + time.minute()) * 60 + time.second(); - - int diff = schedule - now; - if (diff < 0) - diff += 24 * 60 * 60; // 1 day plus - - diff *= 1000; // milliseconds - _scheduleTime = time; - - _scheduleTimer.stop(); - _scheduleTimer.setSingleShot(true); - _scheduleTimer.start(diff); - - emit stateChanged(); -} - -QTime Queue::scheduleTime() -{ - if (_suspended && _scheduleTimer.isActive()) - return _scheduleTime; - else - return QTime(); -} - -void Queue::slotPercent(KJob *, unsigned long percent_) -{ - _percent = percent_; - emit percent(this, percent_); -} - -void Queue::remove(KIOJobWrapper * jw) -{ - bool current = false; - if (_jobs.count() > 0 && _jobs[ 0 ] == jw) - current = true; - _jobs.removeAll(jw); - jw->abort(); - delete jw; - if (current) - slotPercent(0, PERCENT_UNUSED); - if (!_suspended && current && _jobs.count() > 0) { - _jobs[ 0 ]->start(); - slotPercent(0, PERCENT_UNKNOWN); - } - emit changed(); -} diff --git a/krusader/Queue/queue_mgr.h b/krusader/Queue/queue_mgr.h deleted file mode 100644 --- a/krusader/Queue/queue_mgr.h +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#ifndef QUEUE_MGR_H -#define QUEUE_MGR_H - -#include "queue.h" - -// QtCore -#include -#include - -/** - * QueueManager holds multiple queues and has a static - * method that fetches a queue by name. calling it with - * no arguments will fetch the default queue - */ -class QueueManager : public QObject -{ - Q_OBJECT - - static QString defaultName(); -public: - QueueManager(QObject *parent = 0); - ~QueueManager(); - - static Queue* queue(const QString& queueName = defaultName()); - static QList queues(); - - static Queue* currentQueue(); - static void setCurrentQueue(Queue * queue); - static Queue* createQueue(const QString& queueName); - static void removeQueue(Queue * queue); - - static QueueManager * instance() { - return _self; - } - -protected slots: - void slotShowQueueDialog(); - void slotQueueEmptied(); - -signals: - void queueInserted(Queue *); - void queueDeleted(Queue *); - void currentChanged(Queue *); - void percent(Queue *, int); - -protected: - static QMap _queues; - static Queue * _current; - static QueueManager * _self; - static int _nextId; -}; - -#endif // QUEUE_MGR_H diff --git a/krusader/Queue/queue_mgr.cpp b/krusader/Queue/queue_mgr.cpp deleted file mode 100644 --- a/krusader/Queue/queue_mgr.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#include "queue_mgr.h" -#include "queuedialog.h" - -// QtCore -#include -#include -#include - -#include -#include - -#include "../krglobal.h" - -QMap QueueManager::_queues; -Queue * QueueManager::_current = 0; -QueueManager * QueueManager::_self = 0; -int QueueManager::_nextId = 1; - -QueueManager::QueueManager(QObject *parent): QObject(parent) -{ - _self = this; - QStringList queues; - queues << defaultName(); - int current = 0; - KConfigGroup group(krConfig, "QueueManager"); - queues = group.readEntry("Queues", queues); - current = group.readEntry("Active", current); - - const int queuesSize = queues.size(); - if (queuesSize == 0) - queues << defaultName(); - - QVector queueArray; - - foreach(const QString &queueName, queues) - queueArray.append(createQueue(queueName)); - - if (current < queuesSize) - setCurrentQueue(queueArray[ current ]); - else - setCurrentQueue(queueArray[ 0 ]); -} - -QueueManager::~QueueManager() -{ - QList idList; - QStringList nameList; - int currentId = 0; - QMap::iterator it; - for (it = _queues.begin(); it != _queues.end(); ++it) { - QString name = it.key(); - int id = (*it)->property("QueueID").toInt(); - if ((*it) == currentQueue()) - currentId = id; - - int pos = 0; - while (pos < idList.count() && idList[ pos ] < id) - pos++; - idList.insert(pos, id); - nameList.insert(pos, name); - - delete it.value(); - } - _queues.clear(); - QueueDialog::deleteDialog(); - - KConfigGroup group(krConfig, "QueueManager"); - group.writeEntry("Queues", nameList); - int active = 0; - for (int p = 0; p < idList.count(); p++) - if (idList[ p ] == currentId) { - active = p; - break; - } - group.writeEntry("Active", active); -} - -QString QueueManager::defaultName() -{ - return QString(i18n("default")); -} - -Queue* QueueManager::queue(const QString& queueName) -{ - if (!_queues.contains(queueName)) - return 0; - return _queues[queueName]; -} - -QList QueueManager::queues() -{ - return _queues.keys(); -} - -Queue* QueueManager::currentQueue() -{ - return _current; -} - -void QueueManager::setCurrentQueue(Queue * queue) -{ - if (queue == 0) - return; - - if (_queues.contains(queue->name())) { - _current = queue; - _self->emit currentChanged(queue); - } -} - -void QueueManager::slotShowQueueDialog() -{ - QueueDialog::showDialog(); -} - -void QueueManager::slotQueueEmptied() -{ - bool empty = true; - QList queues = _queues.values(); - foreach(Queue * queue, queues) { - if (queue->count() != 0) { - empty = false; - break; - } - } - if (empty) - QueueDialog::everyQueueIsEmpty(); -} - -Queue * QueueManager::createQueue(const QString& queueName) -{ - if (_queues.contains(queueName)) - return 0; - Queue *queue = new Queue(queueName); - int id = _nextId++; - queue->setProperty("QueueID", QVariant(id)); - connect(queue, SIGNAL(showQueueDialog()), _self, SLOT(slotShowQueueDialog())); - connect(queue, SIGNAL(emptied()), _self, SLOT(slotQueueEmptied())); - connect(queue, SIGNAL(percent(Queue *, int)), _self, SIGNAL(percent(Queue *, int))); - _queues.insert(queue->name(), queue); - _current = queue; - - _self->emit queueInserted(queue); - _self->emit currentChanged(queue); - return queue; -} - -void QueueManager::removeQueue(Queue * queue) -{ - if (_queues.count() < 2 && _queues.contains(queue->name())) - return; - - _self->emit queueDeleted(queue); - _queues.remove(queue->name()); - - QMap::iterator it; - _current = _queues.begin().value(); - _self->emit currentChanged(queue); - - delete queue; -} diff --git a/krusader/Queue/queuedialog.h b/krusader/Queue/queuedialog.h deleted file mode 100644 --- a/krusader/Queue/queuedialog.h +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#ifndef QUEUEDIALOG_H -#define QUEUEDIALOG_H - -// QtWidgets -#include - -class QToolButton; -class QueueWidget; -class QLabel; -class QProgressBar; -class Queue; - -class QueueDialog : public QDialog -{ - Q_OBJECT - -private: - QueueDialog(); - -public: - virtual ~QueueDialog(); - - static void showDialog(bool autoHide = true); - static void deleteDialog(); - static void everyQueueIsEmpty(); - -public slots: - void reject() Q_DECL_OVERRIDE; - - void slotUpdateToolbar(); - void slotPauseClicked(); - void slotScheduleClicked(); - void slotNewTab(); - void slotNextTab(); - void slotPrevTab(); - void slotDeleteCurrentTab(); - void slotPercentChanged(Queue *, int); - -protected: - void saveSettings(); - -private: - static QueueDialog * _queueDialog; - - QToolButton * _newTabButton; - QToolButton * _closeTabButton; - QToolButton * _pauseButton; - QToolButton * _scheduleButton; - - QProgressBar * _progressBar; - QueueWidget * _queueWidget; - QLabel * _statusLabel; - - bool _autoHide; -}; - -#endif // __QUEUEDIALOG_H__ - diff --git a/krusader/Queue/queuedialog.cpp b/krusader/Queue/queuedialog.cpp deleted file mode 100644 --- a/krusader/Queue/queuedialog.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#include "queuedialog.h" - -// QtWidgets -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "queuewidget.h" -#include "queue_mgr.h" -#include "../krglobal.h" - -class KrTimeDialog : public QDialog -{ -public: - KrTimeDialog(QWidget * parent = 0) : QDialog(parent) { - setWindowTitle(i18n("Krusader::Queue Manager")); - setWindowModality(Qt::WindowModal); - - QVBoxLayout *mainLayout = new QVBoxLayout; - setLayout(mainLayout); - - mainLayout->addWidget(new QLabel(i18n("Please enter the time to start processing the queue:"))); - - QTime time = QTime::currentTime(); - time = time.addSecs(60 * 60); // add 1 hour - _timeEdit = new QTimeEdit(time, this); - _timeEdit->setDisplayFormat("hh:mm:ss"); - mainLayout->addWidget(_timeEdit); - - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); - mainLayout->addWidget(buttonBox); - QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); - okButton->setDefault(true); - okButton->setShortcut(Qt::CTRL | Qt::Key_Return); - - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - - _timeEdit->setFocus(); - } - QTime getStartTime() { - return _timeEdit->time(); - } - -private: - QTimeEdit * _timeEdit; -}; - -QueueDialog * QueueDialog::_queueDialog = 0; - -QueueDialog::QueueDialog() : QDialog(), _autoHide(true) -{ - setWindowModality(Qt::NonModal); - setWindowTitle(i18n("Krusader::Queue Manager")); - - QVBoxLayout *mainLayout = new QVBoxLayout; - setLayout(mainLayout); - - QHBoxLayout * hbox2 = new QHBoxLayout; - - QAction *act = new QAction(this); - act->setIcon(QIcon::fromTheme("tab-new")); - act->setToolTip(i18n("Create a new queue")); - act->setShortcuts(QKeySequence::keyBindings(QKeySequence::AddTab)); - connect(act, SIGNAL(triggered(bool)), this, SLOT(slotNewTab())); - _newTabButton = new QToolButton(this); - _newTabButton->setDefaultAction(act); - hbox2->addWidget(_newTabButton); - - _closeTabButton = new QToolButton(this); - _closeTabButton->setIcon(QIcon::fromTheme("tab-close")); - _closeTabButton->setToolTip(i18n("Remove the current queue")); - _closeTabButton->setShortcut(QKeySequence::Close); - connect(_closeTabButton, SIGNAL(clicked()), this, SLOT(slotDeleteCurrentTab())); - hbox2->addWidget(_closeTabButton); - - _pauseButton = new QToolButton(this); - _pauseButton->setIcon(QIcon::fromTheme("media-playback-pause")); - _pauseButton->setShortcut(Qt::CTRL + Qt::Key_P); - connect(_pauseButton, SIGNAL(clicked()), this, SLOT(slotPauseClicked())); - hbox2->addWidget(_pauseButton); - - _progressBar = new QProgressBar(this); - _progressBar->setMinimum(0); - _progressBar->setMaximum(100); - _progressBar->setValue(0); - _progressBar->setFormat(i18n("unused")); - _progressBar->setTextVisible(true); - hbox2->addWidget(_progressBar); - - _scheduleButton = new QToolButton(this); - _scheduleButton->setIcon(QIcon::fromTheme("chronometer")); - _scheduleButton->setToolTip(i18n("Schedule queue starting (Ctrl+S)")); - _scheduleButton->setShortcut(Qt::CTRL + Qt::Key_S); - connect(_scheduleButton, SIGNAL(clicked()), this, SLOT(slotScheduleClicked())); - hbox2->addWidget(_scheduleButton); - - mainLayout->addLayout(hbox2); - - _queueWidget = new QueueWidget(this); - _queueWidget->setDocumentMode(true); - connect(_queueWidget, SIGNAL(currentChanged()), this, SLOT(slotUpdateToolbar())); - mainLayout->addWidget(_queueWidget); - - _statusLabel = new QLabel(this); - QSizePolicy statuspolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - statuspolicy.setHeightForWidth(_statusLabel->sizePolicy().hasHeightForWidth()); - _statusLabel->setSizePolicy(statuspolicy); - mainLayout->addWidget(_statusLabel); - - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); - mainLayout->addWidget(buttonBox); - - KConfigGroup group(krConfig, "QueueManager"); - int sizeX = group.readEntry("Window Width", -1); - int sizeY = group.readEntry("Window Height", -1); - int x = group.readEntry("Window X", -1); - int y = group.readEntry("Window Y", -1); - - if (sizeX != -1 && sizeY != -1) - resize(sizeX, sizeY); - else - resize(300, 400); - - if (x != -1 && y != -1) - move(x, y); - else - move(20, 20); - - slotUpdateToolbar(); - - QAction *nextTabAction = new QAction(this); - nextTabAction->setShortcuts(KStandardShortcut::tabNext()); - addAction(nextTabAction); - connect(nextTabAction, SIGNAL(triggered()), SLOT(slotNextTab())); - - QAction *prevTabAction = new QAction(this); - prevTabAction->setShortcuts(KStandardShortcut::tabPrev()); - addAction(prevTabAction); - connect(prevTabAction, SIGNAL(triggered()), SLOT(slotPrevTab())); - - QAction *deleteQueueAction = new QAction(this); - deleteQueueAction->setShortcut(Qt::Key_Delete); - addAction(deleteQueueAction); - connect(deleteQueueAction, SIGNAL(triggered()), _queueWidget, SLOT(deleteCurrent())); - - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(QueueManager::instance(), SIGNAL(queueInserted(Queue *)), this, SLOT(slotUpdateToolbar())); - connect(QueueManager::instance(), SIGNAL(percent(Queue *, int)), this, SLOT(slotPercentChanged(Queue *, int))); - - show(); - _queueWidget->currentWidget()->setFocus(); - - _queueDialog = this; -} - -QueueDialog::~QueueDialog() -{ - if (_queueDialog) - saveSettings(); - _queueDialog = 0; -} - -void QueueDialog::showDialog(bool autoHide) -{ - if (_queueDialog == 0) - _queueDialog = new QueueDialog(); - else { - _queueDialog->show(); - if (!autoHide) { - _queueDialog->raise(); - _queueDialog->activateWindow(); - } - } - if (!autoHide) - _queueDialog->_autoHide = false; -} - -void QueueDialog::everyQueueIsEmpty() -{ - if (_queueDialog->_autoHide && _queueDialog != 0 && !_queueDialog->isHidden()) - _queueDialog->reject(); -} - -void QueueDialog::reject() -{ - _autoHide = true; - saveSettings(); - QDialog::reject(); -} - -void QueueDialog::saveSettings() -{ - KConfigGroup group(krConfig, "QueueManager"); - group.writeEntry("Window Width", width()); - group.writeEntry("Window Height", height()); - group.writeEntry("Window X", x()); - group.writeEntry("Window Y", y()); -} - -void QueueDialog::deleteDialog() -{ - if (_queueDialog) - delete _queueDialog; -} - -void QueueDialog::slotUpdateToolbar() -{ - Queue * currentQueue = QueueManager::currentQueue(); - if (currentQueue) { - if (currentQueue->isSuspended()) { - _pauseButton->setIcon(QIcon::fromTheme("media-playback-start")); - _pauseButton->setToolTip(i18n("Start processing the queue (Ctrl+P)")); - QTime time = currentQueue->scheduleTime(); - if (time.isNull()) { - _statusLabel->setText(i18n("The queue is paused.")); - } else { - _statusLabel->setText(i18n("Scheduled to start at %1.", - time.toString("hh:mm:ss"))); - } - } else { - _statusLabel->setText(i18n("The queue is running.")); - _pauseButton->setIcon(QIcon::fromTheme("media-playback-pause")); - _pauseButton->setToolTip(i18n("Pause processing the queue (Ctrl+P)")); - } - - _closeTabButton->setEnabled(_queueWidget->count() > 1); - - slotPercentChanged(currentQueue, currentQueue->getPercent()); - } -} - -void QueueDialog::slotPauseClicked() -{ - Queue * currentQueue = QueueManager::currentQueue(); - if (currentQueue) { - if (currentQueue->isSuspended()) - currentQueue->resume(); - else - currentQueue->suspend(); - } -} - -void QueueDialog::slotScheduleClicked() -{ - QPointer dialog = new KrTimeDialog(this); - if (dialog->exec() == QDialog::Accepted) { - QTime startTime = dialog->getStartTime(); - Queue * queue = QueueManager::currentQueue(); - queue->schedule(startTime); - } - delete dialog; -} - -void QueueDialog::slotNewTab() -{ - bool ok = false; - QString queueName = QInputDialog::getText(this, i18n("Krusader::Queue Manager"), - i18n("Please enter the name of the new queue"), - QLineEdit::Normal, QString(), &ok); - - if (!ok || queueName.isEmpty()) - return; - - Queue * queue = QueueManager::createQueue(queueName); - if (queue == 0) { - KMessageBox::error(this, i18n("A queue already exists with this name.")); - } -} - -void QueueDialog::slotNextTab() -{ - int curr = _queueWidget->currentIndex(); - int count = _queueWidget->count(); - _queueWidget->setCurrentIndex((curr + 1) % count); -} - -void QueueDialog::slotPrevTab() -{ - int curr = _queueWidget->currentIndex(); - int count = _queueWidget->count(); - _queueWidget->setCurrentIndex((curr + count - 1) % count); -} - -void QueueDialog::slotDeleteCurrentTab() -{ - Queue * currentQueue = QueueManager::currentQueue(); - if (currentQueue) { - if (currentQueue->count() != 0) { - if (KMessageBox::warningContinueCancel(this, - i18n("Deleting the queue requires aborting all pending jobs. Do you wish to continue?"), - i18n("Warning")) != KMessageBox::Continue) return; - } - QueueManager::removeQueue(currentQueue); - } -} - -void QueueDialog::slotPercentChanged(Queue * queue, int percent) -{ - if (QueueManager::currentQueue() == queue) { - switch (percent) { - case PERCENT_UNUSED: - _progressBar->setMaximum(100); - _progressBar->setValue(0); - _progressBar->setFormat(i18n("unused")); - break; - case PERCENT_UNKNOWN: - if (_progressBar->maximum() != 0) { - _progressBar->setMaximum(0); - _progressBar->setFormat(""); - } - break; - default: - if (_progressBar->maximum() != 100) - _progressBar->setMaximum(100); - _progressBar->setValue(percent); - _progressBar->setFormat("%p%"); - break; - } - } -} - diff --git a/krusader/Queue/queuewidget.h b/krusader/Queue/queuewidget.h deleted file mode 100644 --- a/krusader/Queue/queuewidget.h +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#ifndef QUEUEWIDGET_H -#define QUEUEWIDGET_H - -// QtCore -#include -// QtWidgets -#include - -#include "queue.h" -#include "../GUI/krlistwidget.h" - -class KrQueueListWidget; - -class QueueWidget: public QTabWidget -{ - Q_OBJECT -public: - QueueWidget(QWidget * parent = 0); - ~QueueWidget(); - - -protected slots: - void deleteCurrent(); - void slotQueueAdded(Queue *); - void slotQueueDeleted(Queue *); - void slotCurrentChanged(Queue *); - void slotCurrentChanged(int); - -signals: - void currentChanged(); - -private: - QMap _queueWidgets; -}; - -class KrQueueListWidget : public KrListWidget -{ - Q_OBJECT -public: - KrQueueListWidget(Queue * queue, QWidget * parent); - Queue * queue() { - return _queue; - } - void deleteItem(QListWidgetItem * item); - -public slots: - void slotChanged(); - void slotItemRightClicked(QListWidgetItem *); - -signals: - void stateChanged(); - -private: - QPointer _queue; -}; - - -#endif // QUEUE_WIDGET_H diff --git a/krusader/Queue/queuewidget.cpp b/krusader/Queue/queuewidget.cpp deleted file mode 100644 --- a/krusader/Queue/queuewidget.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008-2009 Csaba Karai * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This package is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this package; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - *****************************************************************************/ - -#include "queuewidget.h" -#include "queue_mgr.h" - -// QtGui -#include -// QtWidgets -#include - -#include -#include - -QueueWidget::QueueWidget(QWidget * parent): QTabWidget(parent) -{ - QList queueList = QueueManager::queues(); - foreach(const QString &name, queueList) { - KrQueueListWidget * jobWidget = new KrQueueListWidget(QueueManager::queue(name), this); - connect(jobWidget, SIGNAL(stateChanged()), this, SIGNAL(currentChanged())); - addTab(jobWidget, name); - _queueWidgets[ name ] = jobWidget; - } - - connect(QueueManager::instance(), SIGNAL(queueInserted(Queue *)), this, SLOT(slotQueueAdded(Queue *))); - connect(QueueManager::instance(), SIGNAL(queueDeleted(Queue *)), this, SLOT(slotQueueDeleted(Queue *))); - connect(QueueManager::instance(), SIGNAL(currentChanged(Queue *)), this, SLOT(slotCurrentChanged(Queue *))); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); - - Queue * current = QueueManager::currentQueue(); - if (current) { - QString name = current->name(); - setCurrentWidget(_queueWidgets[ name ]); - } -} - - -QueueWidget::~QueueWidget() -{ -} - -void QueueWidget::slotQueueAdded(Queue * queue) -{ - KrQueueListWidget * jobWidget = new KrQueueListWidget(queue, this); - connect(jobWidget, SIGNAL(stateChanged()), this, SIGNAL(currentChanged())); - addTab(jobWidget, queue->name()); - _queueWidgets[ queue->name()] = jobWidget; - setCurrentWidget(jobWidget); -} - -void QueueWidget::slotQueueDeleted(Queue * queue) -{ - KrQueueListWidget * queueWidget = _queueWidgets[ queue->name()]; - _queueWidgets.remove(queue->name()); - int index = indexOf(queueWidget); - removeTab(index); - delete queueWidget; -} - -void QueueWidget::slotCurrentChanged(int index) -{ - KrQueueListWidget * queueWidget = dynamic_cast(widget(index)); - if (queueWidget->queue()) - QueueManager::setCurrentQueue(queueWidget->queue()); - - emit currentChanged(); -} - -void QueueWidget::slotCurrentChanged(Queue * queue) -{ - KrQueueListWidget * queueWidget = _queueWidgets[ queue->name()]; - setCurrentWidget(queueWidget); -} - -void QueueWidget::deleteCurrent() -{ - QWidget * current = currentWidget(); - if (current) { - KrQueueListWidget * lw = (KrQueueListWidget *)current; - QListWidgetItem * lvitem = lw->currentItem(); - if (lvitem == 0) - lvitem = lw->item(0); - if (lvitem) - lw->deleteItem(lvitem); - } -} - -class KrQueueListWidgetItem : public QListWidgetItem -{ -public: - KrQueueListWidgetItem(const QString & label_, KIOJobWrapper * job_) : - QListWidgetItem(label_), _job(job_) { - setToolTip(job_->toolTip()); - } - - KIOJobWrapper * job() { - return _job; - } - -private: - QPointer _job; -}; - -KrQueueListWidget::KrQueueListWidget(Queue * queue, QWidget * parent) : KrListWidget(parent), - _queue(queue) -{ - connect(queue, SIGNAL(changed()), this, SLOT(slotChanged())); - connect(queue, SIGNAL(stateChanged()), this, SIGNAL(stateChanged())); - connect(this, SIGNAL(itemRightClicked(QListWidgetItem *, const QPoint &)), - this, SLOT(slotItemRightClicked(QListWidgetItem *))); - slotChanged(); -} - -void KrQueueListWidget::slotChanged() -{ - clear(); - if (_queue) { - QList itdescs = _queue->itemDescriptions(); - QList items = _queue->items(); - for (int i = 0; i != items.count(); i++) - addItem(new KrQueueListWidgetItem(itdescs[ i ], items[ i ])); - } -} - -void KrQueueListWidget::slotItemRightClicked(QListWidgetItem * item) -{ - if (item) { - KrQueueListWidgetItem * kitem = (KrQueueListWidgetItem *)item; - if (kitem->job()) { - QMenu popup(this); - popup.setTitle(i18n("Queue Manager")); - QAction * actDelete = popup.addAction(i18n("Delete")); - QAction * res = popup.exec(QCursor::pos()); - - if (res == actDelete) - deleteItem(kitem); - } - } -} - -void KrQueueListWidget::deleteItem(QListWidgetItem * item) -{ - KrQueueListWidgetItem * kitem = (KrQueueListWidgetItem *)item; - if (kitem->job() && kitem->job()->isStarted()) { - if (KMessageBox::warningContinueCancel(this, - i18n("Deleting this job will abort the pending job. Do you wish to continue?"), - i18n("Warning")) != KMessageBox::Continue) - return; - } - if (kitem->job()) - _queue->remove(kitem->job()); -} diff --git a/krusader/kractions.h b/krusader/kractions.h --- a/krusader/kractions.h +++ b/krusader/kractions.h @@ -56,7 +56,7 @@ static QAction *actKonfigurator, *actToolsSetup, *actFind; static QAction *actRemoteEncoding; static QAction *actSelectColorMask, *actMultiRename, *actOpenLeftBm, *actOpenRightBm, *actAddBookmark; - static QAction *actSplit, *actQueueManager; + static QAction *actSplit; static QAction *actCombine; static QAction *actUserMenu; static QAction *actManageUseractions; diff --git a/krusader/kractions.cpp b/krusader/kractions.cpp --- a/krusader/kractions.cpp +++ b/krusader/kractions.cpp @@ -53,7 +53,6 @@ QAction *KrActions::actCompare = 0; QAction *KrActions::actDiskUsage = 0; -QAction *KrActions::actQueueManager = 0; QAction *KrActions::actHomeTerminal = 0; QAction *KrActions::actRemoteEncoding = 0; QAction *KrActions::actProfiles = 0; @@ -275,7 +274,6 @@ NEW_KACTION(actSyncDirs, i18n("Synchronize Fol&ders..."), "folder-sync", Qt::CTRL + Qt::Key_Y, SLOTS, SLOT(slotSynchronizeDirs()), "sync dirs"); #endif NEW_KACTION(actDiskUsage, i18n("D&isk Usage..."), "kr_diskusage", Qt::ALT + Qt::SHIFT + Qt::Key_S, SLOTS, SLOT(slotDiskUsage()), "disk usage"); - NEW_KACTION(actQueueManager, i18n("&Queue Manager..."), "document-multiple", Qt::ALT + Qt::SHIFT + Qt::Key_Q, SLOTS, SLOT(slotQueueManager()), "queue manager"); NEW_KACTION(actKonfigurator, i18n("Configure &Krusader..."), "configure", 0, SLOTS, SLOT(startKonfigurator()), "konfigurator"); NEW_KACTION(actSavePosition, i18n("Save &Position"), 0, 0, krusaderApp, SLOT(savePosition()), "save position"); NEW_KACTION(actCompare, i18n("Compare b&y Content..."), "kr_comparedirs", 0, SLOTS, SLOT(compareContent()), "compare"); diff --git a/krusader/krslots.h b/krusader/krslots.h --- a/krusader/krslots.h +++ b/krusader/krslots.h @@ -117,7 +117,6 @@ void slotSynchronizeDirs(QStringList selected = QStringList()); #endif void slotDiskUsage(); - void slotQueueManager(); void applicationStateChanged(); void jsConsole(); void saveNewToolbarConfig(); diff --git a/krusader/krslots.cpp b/krusader/krslots.cpp --- a/krusader/krslots.cpp +++ b/krusader/krslots.cpp @@ -95,7 +95,6 @@ #include "DiskUsage/diskusagegui.h" #include "krservices.h" #include "Panel/krviewitem.h" -#include "Queue/queuedialog.h" #include "krtrashhandler.h" #include "BookMan/krbookmarkhandler.h" #include "BookMan/krbookmarkbutton.h" @@ -724,11 +723,6 @@ DiskUsageGUI du(ACTIVE_FUNC->files()->vfs_getOrigin(), MAIN_VIEW); } -void KRslots::slotQueueManager() -{ - QueueDialog::showDialog(false); -} - void KRslots::applicationStateChanged() { if (MAIN_VIEW == 0) { /* CRASH FIX: it's possible that the method is called after destroying the main view */ diff --git a/krusader/krusader.h b/krusader/krusader.h --- a/krusader/krusader.h +++ b/krusader/krusader.h @@ -68,7 +68,6 @@ class KRPleaseWaitHandler; class UserMenu; class PopularUrls; -class QueueManager; class ViewActions; class ListPanelActions; class TabActions; @@ -153,7 +152,6 @@ static Krusader *App; // a kApp style pointer static QString AppName; // the name of the application PopularUrls *_popularUrls; // holds a sorted list of the most popular urls visited - QueueManager *queueManager; // return a path to a temp dir or file we can use. QString getTempDir(); QString getTempFile(); diff --git a/krusader/krusader.cpp b/krusader/krusader.cpp --- a/krusader/krusader.cpp +++ b/krusader/krusader.cpp @@ -94,7 +94,6 @@ #include "VFS/vfile.h" #include "VFS/krpermhandler.h" #include "MountMan/kmountman.h" -#include "Queue/queue_mgr.h" #include "Konfigurator/kgprotocols.h" #include "BookMan/krbookmarkhandler.h" #include "KViewer/krviewer.h" @@ -161,8 +160,6 @@ _popularUrls = new PopularUrls(this); - queueManager = new QueueManager(this); - // create the main view MAIN_VIEW = new KrusaderView(this); diff --git a/krusader/krusaderui.rc b/krusader/krusaderui.rc --- a/krusader/krusaderui.rc +++ b/krusader/krusaderui.rc @@ -105,7 +105,6 @@ -