From 07f31c208790eaff918d7f08f442840c088dbe78 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 12 Nov 2009 22:45:47 +0000 Subject: [PATCH] Show a progress information when doing a Nepomuk search. As "sideeffect" some KDE3 relicts for the progress bar code have been removed too... svn path=/trunk/KDE/kdebase/apps/; revision=1048225 --- src/dolphinmainwindow.cpp | 6 +++++ src/dolphinviewcontainer.cpp | 22 +++------------- src/dolphinviewcontainer.h | 1 - src/statusbar/dolphinstatusbar.cpp | 41 ++++++++++++++++-------------- src/statusbar/dolphinstatusbar.h | 4 +-- 5 files changed, 34 insertions(+), 40 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index a83a95fc1..ee5994955 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1006,6 +1006,12 @@ void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& can void DolphinMainWindow::searchItems(const KUrl& url) { m_activeViewContainer->setUrl(url); + + // The Nepomuk IO-slave does not provide any progress information. Give + // an immediate hint to the user that a searching is done: + DolphinStatusBar* statusBar = m_activeViewContainer->statusBar(); + statusBar->setProgressText(i18nc("@info", "Searching...")); + statusBar->setProgress(-1); } void DolphinMainWindow::slotTabMoved(int from, int to) diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index ae6953aad..7bb4b7bec 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -67,7 +67,6 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, QWidget* parent, const KUrl& url) : QWidget(parent), - m_showProgress(false), m_isFolderWritable(false), m_mainWindow(mainWindow), m_topLayout(0), @@ -283,30 +282,17 @@ void DolphinViewContainer::updateStatusBar() void DolphinViewContainer::updateProgress(int percent) { - if (!m_showProgress) { - // Only show the directory loading progress if the status bar does - // not contain another progress information. This means that - // the directory loading progress information has the lowest priority. - const QString progressText(m_statusBar->progressText()); - const QString loadingText(i18nc("@info:progress", "Loading folder...")); - m_showProgress = progressText.isEmpty() || (progressText == loadingText); - if (m_showProgress) { - m_statusBar->setProgressText(loadingText); - m_statusBar->setProgress(0); - } - } - - if (m_showProgress) { - m_statusBar->setProgress(percent); + if (m_statusBar->progressText().isEmpty()) { + m_statusBar->setProgressText(i18nc("@info:progress", "Loading folder...")); } + m_statusBar->setProgress(percent); } void DolphinViewContainer::slotDirListerCompleted() { - if (m_showProgress) { + if (!m_statusBar->progressText().isEmpty()) { m_statusBar->setProgressText(QString()); m_statusBar->setProgress(100); - m_showProgress = false; } updateStatusBar(); diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 97bdccd2a..a691b278f 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -253,7 +253,6 @@ private slots: void slotHistoryChanged(); private: - bool m_showProgress; bool m_isFolderWritable; DolphinMainWindow* m_mainWindow; diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp index c36651e0b..79f2de2c4 100644 --- a/src/statusbar/dolphinstatusbar.cpp +++ b/src/statusbar/dolphinstatusbar.cpp @@ -191,6 +191,9 @@ QString DolphinStatusBar::progressText() const void DolphinStatusBar::setProgress(int percent) { + // show a busy indicator if a value < 0 is provided: + m_progressBar->setMaximum((percent < 0) ? 0 : 100); + if (percent < 0) { percent = 0; } else if (percent > 100) { @@ -206,7 +209,7 @@ void DolphinStatusBar::setProgress(int percent) m_progressBar->setValue(m_progress); if (!m_progressBar->isVisible() || (percent == 100)) { - QTimer::singleShot(300, this, SLOT(updateProgressInfo())); + updateProgressInfo(); } const QString& defaultText = m_messageLabel->defaultText(); @@ -252,24 +255,6 @@ void DolphinStatusBar::resizeEvent(QResizeEvent* event) QMetaObject::invokeMethod(this, "assureVisibleText", Qt::QueuedConnection); } -void DolphinStatusBar::updateProgressInfo() -{ - const bool isErrorShown = (m_messageLabel->type() == Error); - if (m_progress < 100) { - // show the progress information and hide the extensions - setExtensionsVisible(false); - if (!isErrorShown) { - m_progressText->show(); - m_progressBar->show(); - } - } else { - // hide the progress information and show the extensions - m_progressText->hide(); - m_progressBar->hide(); - assureVisibleText(); - } -} - void DolphinStatusBar::updateSpaceInfoContent(const KUrl& url) { m_spaceInfo->setUrl(url); @@ -322,6 +307,24 @@ void DolphinStatusBar::showZoomSliderToolTip(int zoomLevel) QApplication::sendEvent(m_zoomSlider, &toolTipEvent); } +void DolphinStatusBar::updateProgressInfo() +{ + const bool isErrorShown = (m_messageLabel->type() == Error); + if (m_progress < 100) { + // show the progress information and hide the extensions + setExtensionsVisible(false); + if (!isErrorShown) { + m_progressText->show(); + m_progressBar->show(); + } + } else { + // hide the progress information and show the extensions + m_progressText->hide(); + m_progressBar->hide(); + assureVisibleText(); + } +} + void DolphinStatusBar::setExtensionsVisible(bool visible) { bool spaceInfoVisible = visible; diff --git a/src/statusbar/dolphinstatusbar.h b/src/statusbar/dolphinstatusbar.h index a07313bab..2fed4788d 100644 --- a/src/statusbar/dolphinstatusbar.h +++ b/src/statusbar/dolphinstatusbar.h @@ -127,8 +127,6 @@ protected: virtual void resizeEvent(QResizeEvent* event); private slots: - void updateProgressInfo(); - /** * Is invoked, when the URL of the DolphinView, where the * statusbar belongs too, has been changed. The space information @@ -153,6 +151,8 @@ private slots: void showZoomSliderToolTip(int zoomLevel); private: + void updateProgressInfo(); + /** * Makes the space information widget and zoom slider widget * visible, if \a visible is true and the settings allow to show -- 2.47.3