[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: [Semi-patch] Dolphin statusbar in Konqueror
From: Simon St James <kdedevel () etotheipiplusone ! com>
Date: 2008-08-26 19:18:11
Message-ID: 200808262018.11815.kdedevel () etotheipiplusone ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi all,
One of these days I'm going to submit a patch that just works, with no known \
side-effects or drawbacks.
Today is not that day :)
Please find attached what I hope will be the beginning of a fix for:
https://bugs.kde.org/show_bug.cgi?id=155636
The bulk of the patch is factoring the status bar logic out of DolphinViewContainer \
and into a class called, for the time being, StatusBarHandler (something like \
DolphinStatusBarController might be better, if rather verbose). I'm going with this \
approach as I'm guessing exporting DolphinViewContainer in the Part might be rather \
awkward, but do correct me if I'm wrong :)
The actual bit that pokes the status bar into Konqueror is in DolphinPart and is \
currently #if 0'd out, for two reasons:
1) Cosmetic - the capacity bar is a little taller than the standard status bar area:
http://etotheipiplusone.com/konq-statusbar.png
2) Functional, and a blocker - Konqueror relies on its built-in status bar text label \
for the "right-click brings up the Split/ Lock/ Close View" menu, and the Dolphin bar \
currently replaces this, removing the ability to summon this menu.
I suppose there are two main choices here:
A) we can either attempt to re-instate this right-click menu behaviour, but I cannot \
really think of a clean and foolproof way of doing this without making some ugly \
changes to Konqueror and/ or some ugly Konqueror-specific changes to Dolphin; or
B) we can follow KHTMLParts' lead and, in "KPart"-mode (i.e. when embedded in \
Konqueror), not use our own text label to show the message, and instead use the KPart \
system's own status bar text message stuff (the KPart system also provides a progress \
widget which we can use in place of m_progressBar).
The disadvantage is that, in KPart mode, we'll lose those cute little Info, Error etc \
icons next to the status message, and we'll have to either modify DolphinStatusBar so \
that it can operate in two different modes (one using a label & progress bar for the \
messages/ progress; the other emitting the relevant signals for use by the KParts \
system). This might involve creating an AbstractStatusBar class with \
DolphinStatusBar and, say, DolphinPartStatusBar as implementations.
As always, comments, plans, re-namings and nitpicks appreciated :)
I've not documented this heavily but will do so if the general approach is approved. \
Best Wishes,
Simon
[Attachment #5 (text/html)]
<html><head><meta name="qrichtext" content="1" /></head><body \
style="font-size:9pt;font-family:Sans Serif"> <p>Hi all,</p>
<p></p>
<p>One of these days I'm going to submit a patch that just works, with no known \
side-effects or drawbacks.</p> <p></p>
<p>Today is not that day :)</p>
<p></p>
<p>Please find attached what I hope will be the beginning of a fix for:</p>
<p></p>
<p>https://bugs.kde.org/show_bug.cgi?id=155636</p>
<p></p>
<p>The bulk of the patch is factoring the status bar logic out of \
DolphinViewContainer and into a class called, for the time being, StatusBarHandler \
(something like DolphinStatusBarController might be better, if rather verbose). I'm \
going with this approach as I'm guessing exporting DolphinViewContainer in the Part \
might be rather awkward, but do correct me if I'm wrong :)</p> <p></p>
<p>The actual bit that pokes the status bar into Konqueror is in DolphinPart and is \
currently #if 0'd out, for two reasons:</p> <p></p>
<p>1) Cosmetic - the capacity bar is a little taller than the standard status bar \
area:</p> <p></p>
<p>http://etotheipiplusone.com/konq-statusbar.png</p>
<p></p>
<p>2) Functional, and a blocker - Konqueror relies on its built-in status bar text \
label for the "right-click brings up the Split/ Lock/ Close View" menu, and \
the Dolphin bar currently replaces this, removing the ability to summon this \
menu.</p> <p></p>
<p>I suppose there are two main choices here: </p>
<p></p>
<p>A) we can either attempt to re-instate this right-click menu behaviour, but I \
cannot really think of a clean and foolproof way of doing this without making some \
ugly changes to Konqueror and/ or some ugly Konqueror-specific changes to Dolphin; \
or</p> <p></p>
<p>B) we can follow KHTMLParts' lead and, in "KPart"-mode (i.e. when \
embedded in Konqueror), not use our own text label to show the message, and instead \
use the KPart system's own status bar text message stuff (the KPart system also \
provides a progress widget which we can use in place of m_progressBar). </p> <p></p>
<p>The disadvantage is that, in KPart mode, we'll lose those cute little Info, Error \
etc icons next to the status message, and we'll have to either modify \
DolphinStatusBar so that it can operate in two different modes (one using a label \
& progress bar for the messages/ progress; the other emitting the relevant \
signals for use by the KParts system). This might involve creating an \
AbstractStatusBar class with DolphinStatusBar and, say, DolphinPartStatusBar as \
implementations. </p> <p></p>
<p>As always, comments, plans, re-namings and nitpicks appreciated :)</p>
<p></p>
<p>I've not documented this heavily but will do so if the general approach is \
approved. </p> <p></p>
<p>Best Wishes,</p>
<p>Simon</p>
</body></html>
["dolphin-statusbar-factor.patch" (text/x-diff)]
Index: src/dolphinstatusbar.h
===================================================================
--- src/dolphinstatusbar.h (revision 851802)
+++ src/dolphinstatusbar.h (working copy)
@@ -22,6 +22,7 @@
#define DOLPHINSTATUSBAR_H
#include <khbox.h>
+#include "libdolphin_export.h"
class DolphinView;
class KUrl;
@@ -36,7 +37,7 @@
* The statusbar allows to show messages and progress
* information.
*/
-class DolphinStatusBar : public KHBox
+class LIBDOLPHINPRIVATE_EXPORT DolphinStatusBar : public KHBox
{
Q_OBJECT
Index: src/dolphinpart.h
===================================================================
--- src/dolphinpart.h (revision 851802)
+++ src/dolphinpart.h (working copy)
@@ -22,6 +22,7 @@
#include <kparts/part.h>
#include <kparts/browserextension.h>
+#include <kparts/statusbarextension.h>
class KNewMenu;
class DolphinViewActionHandler;
class QActionGroup;
@@ -29,6 +30,9 @@
class KFileItemList;
class KFileItem;
class DolphinPartBrowserExtension;
+class DolphinStatusBar;
+class StatusBarHandler;
+class DolphinPartStatusBarExtension;
class DolphinSortFilterProxyModel;
class DolphinModel;
class KDirLister;
@@ -191,6 +195,9 @@
DolphinModel* m_dolphinModel;
DolphinSortFilterProxyModel* m_proxyModel;
DolphinPartBrowserExtension* m_extension;
+ DolphinStatusBar* m_statusBar;
+ StatusBarHandler* m_statusBarHandler;
+ DolphinPartStatusBarExtension *m_statusBarExtension;
KNewMenu* m_newMenu;
QString m_nameFilter;
Q_DISABLE_COPY(DolphinPart)
@@ -213,4 +220,16 @@
DolphinPart* m_part;
};
+class DolphinPartStatusBarExtension : public KParts::StatusBarExtension
+{
+ Q_OBJECT
+public:
+ DolphinPartStatusBarExtension( DolphinPart* part )
+ : KParts::StatusBarExtension( part ), m_part(part) {}
+private:
+ DolphinPart* m_part;
+};
+
+
+
#endif /* DOLPHINPART_H */
Index: src/statusbarhandler.cpp
===================================================================
--- src/statusbarhandler.cpp (revision 0)
+++ src/statusbarhandler.cpp (revision 0)
@@ -0,0 +1,160 @@
+#include "statusbarhandler.h"
+
+#include "dolphinstatusbar.h"
+#include "dolphinview.h"
+
+#include <kdirlister.h>
+#include <kfileitem.h>
+#include <klocale.h>
+
+StatusBarHandler::StatusBarHandler(DolphinStatusBar *statusBar, DolphinView* view, \
KDirLister* dirLister) : + QObject(view),
+ m_statusBar(statusBar),
+ m_view(view),
+ m_dirLister(dirLister),
+ m_showProgress(false)
+{
+ connect(m_dirLister, SIGNAL(clear()),
+ this, SLOT(updateStatusBar()));
+ connect(m_dirLister, SIGNAL(percent(int)),
+ this, SLOT(updateProgress(int)));
+ connect(m_dirLister, SIGNAL(deleteItem(const KFileItem&)),
+ this, SLOT(updateStatusBar()));
+ connect(m_dirLister, SIGNAL(completed()),
+ this, SLOT(slotDirListerCompleted()));
+ connect(m_dirLister, SIGNAL(infoMessage(const QString&)),
+ this, SLOT(showInfoMessage(const QString&)));
+ connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
+ this, SLOT(showErrorMessage(const QString&)));
+ connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
+ this, SLOT(showItemInfo(KFileItem)));
+ connect(m_view, SIGNAL(errorMessage(const QString&)),
+ this, SLOT(showErrorMessage(const QString&)));
+ connect(m_view, SIGNAL(infoMessage(const QString&)),
+ this, SLOT(showInfoMessage(const QString&)));
+ connect(m_view, SIGNAL(operationCompletedMessage(const QString&)),
+ this, SLOT(showOperationCompletedMessage(const QString&)));
+ connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
+ this, SLOT(updateStatusBar()));
+}
+
+StatusBarHandler::~StatusBarHandler()
+{
+}
+
+void StatusBarHandler::slotDirListerCompleted()
+{
+ if (m_showProgress) {
+ m_statusBar->setProgressText(QString());
+ m_statusBar->setProgress(100);
+ m_showProgress = false;
+ }
+
+ updateStatusBar();
+}
+
+void StatusBarHandler::updateProgress(int percent)
+{
+}
+
+void StatusBarHandler::showItemInfo(const KFileItem& item)
+{
+ if (item.isNull()) {
+ m_statusBar->clear();
+ } else {
+ m_statusBar->setMessage(item.getStatusBarInfo(), DolphinStatusBar::Default);
+ }
+}
+
+void StatusBarHandler::showInfoMessage(const QString& msg)
+{
+ m_statusBar->setMessage(msg, DolphinStatusBar::Information);
+}
+
+void StatusBarHandler::showErrorMessage(const QString& msg)
+{
+ m_statusBar->setMessage(msg, DolphinStatusBar::Error);
+}
+
+void StatusBarHandler::showOperationCompletedMessage(const QString& msg)
+{
+ m_statusBar->setMessage(msg, DolphinStatusBar::OperationCompleted);
+}
+
+void StatusBarHandler::updateStatusBar()
+{
+ if (m_statusBar == 0)
+ return;
+
+ // As the item count information is less important
+ // in comparison with other messages, it should only
+ // be shown if:
+ // - the status bar is empty or
+ // - shows already the item count information or
+ // - shows only a not very important information
+ // - if any progress is given don't show the item count info at all
+ const QString msg(m_statusBar->message());
+ const bool updateStatusBarMsg = (msg.isEmpty() ||
+ (msg == m_statusBar->defaultText()) ||
+ (m_statusBar->type() == DolphinStatusBar::Information)) &&
+ (m_statusBar->progress() == 100);
+
+ const QString text(m_view->hasSelection() ? selectionStatusBarText() : \
defaultStatusBarText()); + m_statusBar->setDefaultText(text);
+
+ if (updateStatusBarMsg) {
+ m_statusBar->setMessage(text, DolphinStatusBar::Default);
+ }
+}
+
+QString StatusBarHandler::defaultStatusBarText() const
+{
+ int folderCount = 0;
+ int fileCount = 0;
+ m_view->calculateItemCount(fileCount, folderCount);
+ return KIO::itemsSummaryString(fileCount + folderCount,
+ fileCount,
+ folderCount,
+ 0, false);
+}
+
+QString StatusBarHandler::selectionStatusBarText() const
+{
+ QString text;
+ const KFileItemList list = m_view->selectedItems();
+ if (list.isEmpty()) {
+ // when an item is triggered, it is temporary selected but selectedItems()
+ // will return an empty list
+ return QString();
+ }
+
+ int fileCount = 0;
+ int folderCount = 0;
+ KIO::filesize_t byteSize = 0;
+ KFileItemList::const_iterator it = list.begin();
+ const KFileItemList::const_iterator end = list.end();
+ while (it != end) {
+ const KFileItem& item = *it;
+ if (item.isDir()) {
+ ++folderCount;
+ } else {
+ ++fileCount;
+ byteSize += item.size();
+ }
+ ++it;
+ }
+
+ if (folderCount > 0) {
+ text = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", \
folderCount); + if (fileCount > 0) {
+ text += ", ";
+ }
+ }
+
+ if (fileCount > 0) {
+ const QString sizeText(KIO::convertSize(byteSize));
+ text += i18ncp("@info:status", "1 File selected (%2)", "%1 Files selected \
(%2)", fileCount, sizeText); + }
+
+ return text;
+}
\ No newline at end of file
Index: src/statusbarhandler.h
===================================================================
--- src/statusbarhandler.h (revision 0)
+++ src/statusbarhandler.h (revision 0)
@@ -0,0 +1,66 @@
+#include <QObject>
+#include "libdolphin_export.h"
+
+class DolphinStatusBar;
+class DolphinView;
+class KDirLister;
+class KFileItem;
+class KFileItemList;
+
+// TODO, if general approach approved: document, ensure correct coding style, \
copyright headers, etc. +// Currently becomes child of view - maybe child of \
statusBar would be better ... ? Manual deletion ... ? Name - DolphinStatusController, \
perhaps? +
+class LIBDOLPHINPRIVATE_EXPORT StatusBarHandler : public QObject
+{
+ Q_OBJECT
+public:
+ StatusBarHandler(DolphinStatusBar *statusBar, DolphinView* view, KDirLister* \
dirLister); + ~StatusBarHandler();
+public slots:
+ /**
+ * Updates the statusbar to reflect the current content.
+ */
+ void slotDirListerCompleted();
+
+ void updateProgress(int percent);
+
+ /**
+ * Shows the information for the item \a item inside the statusbar. If the
+ * item is null, the default statusbar information is shown.
+ */
+ void showItemInfo(const KFileItem& item);
+
+ /** Shows the information \a msg inside the statusbar. */
+ void showInfoMessage(const QString& msg);
+
+ /** Shows the error message \a msg inside the statusbar. */
+ void showErrorMessage(const QString& msg);
+
+ /** Shows the "operation completed" message \a msg inside the statusbar. */
+ void showOperationCompletedMessage(const QString& msg);
+
+ /**
+ * Updates the number of items (= number of files + number of
+ * directories) in the statusbar. If files are selected, the number
+ * of selected files and the sum of the filesize is shown.
+ */
+ void updateStatusBar();
+
+ /**
+ * Returns the default text of the status bar, if no item is
+ * selected.
+ */
+ QString defaultStatusBarText() const;
+
+ /**
+ * Returns the text for the status bar, if at least one item
+ * is selected.
+ */
+ QString selectionStatusBarText() const;
+
+private:
+ DolphinStatusBar *m_statusBar;
+ DolphinView *m_view;
+ KDirLister *m_dirLister;
+ bool m_showProgress;
+};
\ No newline at end of file
Index: src/dolphinpart.cpp
===================================================================
--- src/dolphinpart.cpp (revision 851802)
+++ src/dolphinpart.cpp (working copy)
@@ -22,6 +22,8 @@
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
#include "dolphinmodel.h"
+#include "dolphinstatusbar.h"
+#include "statusbarhandler.h"
#include <konq_fileitemcapabilities.h>
#include <konq_operations.h>
@@ -41,20 +43,24 @@
#include <kauthorized.h>
#include <knewmenu.h>
#include <kmenu.h>
+#include <kstatusbar.h>
#include <QActionGroup>
#include <QApplication>
#include <QClipboard>
+#include <QLabel>
K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& \
args)
- : KParts::ReadOnlyPart(parent)
+ : KParts::ReadOnlyPart(parent),
+ m_statusBar(0)
{
Q_UNUSED(args)
setComponentData(DolphinPartFactory::componentData(), false);
m_extension = new DolphinPartBrowserExtension(this);
+ m_statusBarExtension = new DolphinPartStatusBarExtension(this);
// make sure that other apps using this part find Dolphin's view-file-columns \
icons KIconLoader::global()->addAppDir("dolphin");
@@ -244,6 +250,21 @@
bool DolphinPart::openUrl(const KUrl& url)
{
+#if 0
+ // Commented out until status bar problems are resolved.
+ if (m_statusBar == 0)
+ {
+ // The API docs for StatusBarExtension warns that we should not
+ // add items immediately after creation. We've followed KHTMLPart's example
+ // and delayed the addition until openUrl(...)
+ m_statusBar = new DolphinStatusBar(m_statusBarExtension->statusBar(), url);
+ m_statusBar->show();
+ connect(m_view, SIGNAL(urlChanged(const KUrl&)),
+ m_statusBar, SLOT(updateSpaceInfoContent(const KUrl&)));
+ m_statusBarHandler = new StatusBarHandler(m_statusBar, m_view, m_dirLister);
+ m_statusBarExtension->addStatusBarItem(m_statusBar , 100, false);
+ }
+#endif
bool reload = arguments().reload();
// A bit of a workaround so that changing the namefilter works: force reload.
// Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
Index: src/dolphinviewcontainer.h
===================================================================
--- src/dolphinviewcontainer.h (revision 851802)
+++ src/dolphinviewcontainer.h (working copy)
@@ -43,8 +43,10 @@
class DolphinMainWindow;
class DolphinSortFilterProxyModel;
class DolphinStatusBar;
+class StatusBarHandler;
class QModelIndex;
+
/**
* @short Represents a view for the directory content
* including the navigation bar, filter bar and status bar.
@@ -128,11 +130,9 @@
void showFilterBarChanged(bool shown);
private slots:
- void updateProgress(int percent);
/**
- * Assures that the viewport position is restored and updates the
- * statusbar to reflect the current content.
+ * Assures that the viewport position is restored,
*/
void slotDirListerCompleted();
@@ -141,21 +141,6 @@
*/
void slotItemTriggered(const KFileItem& item);
- /**
- * Shows the information for the item \a item inside the statusbar. If the
- * item is null, the default statusbar information is shown.
- */
- void showItemInfo(const KFileItem& item);
-
- /** Shows the information \a msg inside the statusbar. */
- void showInfoMessage(const QString& msg);
-
- /** Shows the error message \a msg inside the statusbar. */
- void showErrorMessage(const QString& msg);
-
- /** Shows the "operation completed" message \a msg inside the statusbar. */
- void showOperationCompletedMessage(const QString& msg);
-
void closeFilterBar();
/**
@@ -203,17 +188,7 @@
void saveRootUrl(const KUrl& url);
private:
- /**
- * Returns the default text of the status bar, if no item is
- * selected.
- */
- QString defaultStatusBarText() const;
- /**
- * Returns the text for the status bar, if at least one item
- * is selected.
- */
- QString selectionStatusBarText() const;
private:
bool m_showProgress;
@@ -226,6 +201,7 @@
FilterBar* m_filterBar;
DolphinStatusBar* m_statusBar;
+ StatusBarHandler* m_statusBarHandler;
DolphinModel* m_dolphinModel;
DolphinDirLister* m_dirLister;
Index: src/dolphinviewcontainer.cpp
===================================================================
--- src/dolphinviewcontainer.cpp (revision 851802)
+++ src/dolphinviewcontainer.cpp (working copy)
@@ -47,6 +47,7 @@
#include "dolphincolumnview.h"
#include "dolphincontroller.h"
#include "dolphinstatusbar.h"
+#include "statusbarhandler.h"
#include "dolphinmainwindow.h"
#include "dolphindirlister.h"
#include "dolphinsortfilterproxymodel.h"
@@ -70,6 +71,7 @@
m_view(0),
m_filterBar(0),
m_statusBar(0),
+ m_statusBarHandler(0),
m_dirLister(0),
m_proxyModel(0)
{
@@ -103,19 +105,6 @@
m_proxyModel->setSourceModel(m_dolphinModel);
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
- connect(m_dirLister, SIGNAL(clear()),
- this, SLOT(updateStatusBar()));
- connect(m_dirLister, SIGNAL(percent(int)),
- this, SLOT(updateProgress(int)));
- connect(m_dirLister, SIGNAL(deleteItem(const KFileItem&)),
- this, SLOT(updateStatusBar()));
- connect(m_dirLister, SIGNAL(completed()),
- this, SLOT(slotDirListerCompleted()));
- connect(m_dirLister, SIGNAL(infoMessage(const QString&)),
- this, SLOT(showInfoMessage(const QString&)));
- connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
- this, SLOT(showErrorMessage(const QString&)));
-
m_view = new DolphinView(this,
url,
m_dirLister,
@@ -127,14 +116,6 @@
this, SLOT(openContextMenu(KFileItem, const KUrl&)));
connect(m_view, SIGNAL(contentsMoved(int, int)),
this, SLOT(saveContentsPos(int, int)));
- connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
- this, SLOT(showItemInfo(KFileItem)));
- connect(m_view, SIGNAL(errorMessage(const QString&)),
- this, SLOT(showErrorMessage(const QString&)));
- connect(m_view, SIGNAL(infoMessage(const QString&)),
- this, SLOT(showInfoMessage(const QString&)));
- connect(m_view, SIGNAL(operationCompletedMessage(const QString&)),
- this, SLOT(showOperationCompletedMessage(const QString&)));
connect(m_view, SIGNAL(itemTriggered(KFileItem)),
this, SLOT(slotItemTriggered(KFileItem)));
connect(m_view, SIGNAL(startedPathLoading(const KUrl&)),
@@ -146,6 +127,7 @@
m_statusBar = new DolphinStatusBar(this, url);
connect(m_view, SIGNAL(urlChanged(const KUrl&)),
m_statusBar, SLOT(updateSpaceInfoContent(const KUrl&)));
+ m_statusBarHandler = new StatusBarHandler(m_statusBar, m_view, m_dirLister);
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(settings->filterBar());
@@ -208,35 +190,8 @@
return m_urlNavigator->isUrlEditable();
}
-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);
- }
-}
-
void DolphinViewContainer::slotDirListerCompleted()
{
- if (m_showProgress) {
- m_statusBar->setProgressText(QString());
- m_statusBar->setProgress(100);
- m_showProgress = false;
- }
-
- updateStatusBar();
QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
// Enable the 'File'->'Create New...' menu only if the directory
@@ -252,88 +207,12 @@
}
}
-void DolphinViewContainer::showItemInfo(const KFileItem& item)
-{
- if (item.isNull()) {
- m_statusBar->clear();
- } else {
- m_statusBar->setMessage(item.getStatusBarInfo(), DolphinStatusBar::Default);
- }
-}
-
-void DolphinViewContainer::showInfoMessage(const QString& msg)
-{
- m_statusBar->setMessage(msg, DolphinStatusBar::Information);
-}
-
-void DolphinViewContainer::showErrorMessage(const QString& msg)
-{
- m_statusBar->setMessage(msg, DolphinStatusBar::Error);
-}
-
-void DolphinViewContainer::showOperationCompletedMessage(const QString& msg)
-{
- m_statusBar->setMessage(msg, DolphinStatusBar::OperationCompleted);
-}
-
void DolphinViewContainer::closeFilterBar()
{
m_filterBar->hide();
emit showFilterBarChanged(false);
}
-QString DolphinViewContainer::defaultStatusBarText() const
-{
- int folderCount = 0;
- int fileCount = 0;
- m_view->calculateItemCount(fileCount, folderCount);
- return KIO::itemsSummaryString(fileCount + folderCount,
- fileCount,
- folderCount,
- 0, false);
-}
-
-QString DolphinViewContainer::selectionStatusBarText() const
-{
- QString text;
- const KFileItemList list = m_view->selectedItems();
- if (list.isEmpty()) {
- // when an item is triggered, it is temporary selected but selectedItems()
- // will return an empty list
- return QString();
- }
-
- int fileCount = 0;
- int folderCount = 0;
- KIO::filesize_t byteSize = 0;
- KFileItemList::const_iterator it = list.begin();
- const KFileItemList::const_iterator end = list.end();
- while (it != end) {
- const KFileItem& item = *it;
- if (item.isDir()) {
- ++folderCount;
- } else {
- ++fileCount;
- byteSize += item.size();
- }
- ++it;
- }
-
- if (folderCount > 0) {
- text = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", \
folderCount);
- if (fileCount > 0) {
- text += ", ";
- }
- }
-
- if (fileCount > 0) {
- const QString sizeText(KIO::convertSize(byteSize));
- text += i18ncp("@info:status", "1 File selected (%2)", "%1 Files selected \
(%2)", fileCount, sizeText);
- }
-
- return text;
-}
-
void DolphinViewContainer::showFilterBar(bool show)
{
Q_ASSERT(m_filterBar != 0);
@@ -342,25 +221,7 @@
void DolphinViewContainer::updateStatusBar()
{
- // As the item count information is less important
- // in comparison with other messages, it should only
- // be shown if:
- // - the status bar is empty or
- // - shows already the item count information or
- // - shows only a not very important information
- // - if any progress is given don't show the item count info at all
- const QString msg(m_statusBar->message());
- const bool updateStatusBarMsg = (msg.isEmpty() ||
- (msg == m_statusBar->defaultText()) ||
- (m_statusBar->type() == \
DolphinStatusBar::Information)) &&
- (m_statusBar->progress() == 100);
-
- const QString text(m_view->hasSelection() ? selectionStatusBarText() : \
defaultStatusBarText());
- m_statusBar->setDefaultText(text);
-
- if (updateStatusBarMsg) {
- m_statusBar->setMessage(text, DolphinStatusBar::Default);
- }
+ m_statusBarHandler->updateStatusBar();
}
void DolphinViewContainer::setNameFilter(const QString& nameFilter)
Index: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt (revision 851802)
+++ src/CMakeLists.txt (working copy)
@@ -30,6 +30,10 @@
dolphinsettings.cpp
dolphintooltip.cpp
dolphincategorydrawer.cpp
+ dolphinstatusbar.cpp
+ statusbarhandler.cpp
+ statusbarspaceinfo.cpp
+ statusbarmessagelabel.cpp
dolphinview.cpp
dolphinviewactionhandler.cpp
folderexpander.cpp
@@ -98,7 +102,6 @@
dolphinmainwindow.cpp
dolphinnewmenu.cpp
dolphinviewcontainer.cpp
- dolphinstatusbar.cpp
dolphindirlister.cpp
dolphincontextmenu.cpp
dolphinfileplacesview.cpp
@@ -118,8 +121,6 @@
settingspagebase.cpp
sidebarpage.cpp
startupsettingspage.cpp
- statusbarspaceinfo.cpp
- statusbarmessagelabel.cpp
treeviewcontextmenu.cpp
treeviewsidebarpage.cpp
sidebartreeview.cpp
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic