From: Peter Penz Date: Sat, 20 Jan 2007 15:03:14 +0000 (+0000) Subject: Removed helper class ProgressIndicator (not needed anymore because of the use of... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/07e07fd522cc278dffccc3b8b6faded0f6f5df20 Removed helper class ProgressIndicator (not needed anymore because of the use of KonqUndoManager). svn path=/trunk/playground/utils/dolphin/; revision=625608 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e5816edf..175f31f51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,6 @@ set(dolphin_SRCS iconsviewsettingspage.cpp infosidebarpage.cpp main.cpp - progressindicator.cpp protocolcombo.cpp pixmapviewer.cpp renamedialog.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 45f99eaeb..de81af06d 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -29,7 +29,6 @@ #include "dolphinstatusbar.h" #include "dolphinapplication.h" #include "urlnavigator.h" -#include "progressindicator.h" #include "dolphinsettings.h" #include "bookmarkssidebarpage.h" #include "infosidebarpage.h" diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index bf92b34f4..470abe5b7 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -45,7 +45,6 @@ #include "dolphiniconsview.h" #include "dolphincontextmenu.h" #include "filterbar.h" -#include "progressindicator.h" #include "renamedialog.h" #include "urlnavigator.h" #include "viewproperties.h" @@ -242,11 +241,6 @@ void DolphinView::renameSelectedItems() assert(newName.contains('#')); const int urlsCount = urls.count(); - ProgressIndicator* progressIndicator = - new ProgressIndicator(mainWindow(), - i18n("Renaming items..."), - i18n("Renaming finished."), - urlsCount); // iterate through all selected items and rename them... const int replaceIndex = newName.indexOf('#'); @@ -262,8 +256,6 @@ void DolphinView::renameSelectedItems() const bool destExists = KIO::NetAccess::exists(dest, false, view); if (destExists) { - delete progressIndicator; - progressIndicator = 0; view->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name), DolphinStatusBar::Error); break; @@ -275,11 +267,7 @@ void DolphinView::renameSelectedItems() //undoMan.addCommand(command); } } - - progressIndicator->execOperation(); } - delete progressIndicator; - progressIndicator = 0; //undoMan.endMacro(); } diff --git a/src/progressindicator.cpp b/src/progressindicator.cpp deleted file mode 100644 index 6805788eb..000000000 --- a/src/progressindicator.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * peter.penz@gmx.at * - * * - * 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 program 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 program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "progressindicator.h" -#include "dolphinmainwindow.h" -#include "dolphinstatusbar.h" -#include - -ProgressIndicator::ProgressIndicator(DolphinMainWindow* mainWindow, - const QString& progressText, - const QString& finishedText, - int operationsCount) - : m_mainWindow(mainWindow), - m_showProgress(false), - m_operationsCount(operationsCount), - m_operationsIndex(0), - m_startTime(QTime::currentTime()), - m_finishedText(finishedText) -{ - DolphinStatusBar* statusBar = mainWindow->activeView()->statusBar(); - statusBar->clear(); - statusBar->setProgressText(progressText); - statusBar->setProgress(0); -} - - -ProgressIndicator::~ProgressIndicator() -{ - DolphinStatusBar* statusBar = m_mainWindow->activeView()->statusBar(); - statusBar->setProgressText(QString::null); - statusBar->setProgress(100); - statusBar->setMessage(m_finishedText, DolphinStatusBar::OperationCompleted); - - if (m_showProgress) { - m_mainWindow->setEnabled(true); - } -} - -void ProgressIndicator::execOperation() -{ - ++m_operationsIndex; - - if (!m_showProgress) { - const int elapsed = m_startTime.msecsTo(QTime::currentTime()); - if (elapsed > 500) { - // the operations took already more than 500 milliseconds, - // therefore show a progress indication - m_mainWindow->setEnabled(false); - m_showProgress = true; - } - } - - if (m_showProgress) { - const QTime currentTime = QTime::currentTime(); - if (m_startTime.msecsTo(currentTime) > 100) { - m_startTime = currentTime; - - DolphinStatusBar* statusBar = m_mainWindow->activeView()->statusBar(); - statusBar->setProgress((m_operationsIndex * 100) / m_operationsCount); -#warning "EVIL, DANGER, FIRE" - qApp->processEvents(); - statusBar->repaint(); - } - } -} - - diff --git a/src/progressindicator.h b/src/progressindicator.h deleted file mode 100644 index 542f776d3..000000000 --- a/src/progressindicator.h +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * peter.penz@gmx.at * - * * - * 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 program 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 program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ -#ifndef PROGRESSINDICATOR_H -#define PROGRESSINDICATOR_H - -#include - -class DolphinMainWindow; - -/** - * Allows to show a progress of synchronous operations. Sample code: - * \code - * const int operationsCount = 100; - * ProgressIndicator progressIndicator(i18n("Loading..."), - * i18n("Loading finished."), - * operationsCount); - * for (int i = 0; i < operationsCount; ++i) { - * progressIndicator.execOperation(); - * // do synchronous operation... - * } - * \endcode - * The progress indicator takes care to show the progress bar only after - * a delay of around 500 milliseconds. This means if all operations are - * executing within 500 milliseconds, no progress bar is shown at all. - * As soon as the progress bar is shown, the application still may process - * events, but the the Dolphin main widget is disabled. - * - * @author Peter Penz - */ -class ProgressIndicator -{ -public: - /** - * @param mainWindow The mainwindow this statusbar should operate on - * @param progressText Text for the progress bar (e. g. "Loading..."). - * @param finishedText Text which is displayed after the operations have been finished - * (e. g. "Loading finished."). - * @param operationsCount Number of operations. - */ - ProgressIndicator(DolphinMainWindow *mainWindow, - const QString& progressText, - const QString& finishedText, - int operationsCount); - - /** - * Sets the progress to 100 % and displays the 'finishedText' property - * in the status bar. - */ - ~ProgressIndicator(); - - /** - * Increases the progress and should be invoked - * before each operation. - */ - void execOperation(); - -private: - DolphinMainWindow *m_mainWindow; - bool m_showProgress; - int m_operationsCount; - int m_operationsIndex; - QTime m_startTime; - QString m_finishedText; -}; - -#endif