1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Removed helper class ProgressIndicator (not needed anymore because of the use of KonqUndoManager).

svn path=/trunk/playground/utils/dolphin/; revision=625608
This commit is contained in:
Peter Penz 2007-01-20 15:03:14 +00:00
parent a376e4d43e
commit 07e07fd522
5 changed files with 0 additions and 181 deletions

View File

@ -31,7 +31,6 @@ set(dolphin_SRCS
iconsviewsettingspage.cpp
infosidebarpage.cpp
main.cpp
progressindicator.cpp
protocolcombo.cpp
pixmapviewer.cpp
renamedialog.cpp

View File

@ -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"

View File

@ -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();
}

View File

@ -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 <QApplication>
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();
}
}
}

View File

@ -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 <qdatetime.h>
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 <peter.penz@gmx.at>
*/
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