//connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotStarted()));
connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl)));
connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl)));
+ connect(m_dirLister, SIGNAL(percent(int)), this, SLOT(updateProgress(int)));
m_dolphinModel = new DolphinModel(this);
m_dolphinModel->setDirLister(m_dirLister);
this, SLOT(slotRequestUrlChange(KUrl)));
connect(m_view, SIGNAL(modeChanged()),
this, SIGNAL(viewModeChanged())); // relay signal
+
+ // Watch for changes that should result in updates to the
+ // status bar text.
+ connect(m_dirLister, SIGNAL(deleteItem(const KFileItem&)),
+ this, SLOT(updateStatusBar()));
+ connect(m_dirLister, SIGNAL(clear()),
+ this, SLOT(updateStatusBar()));
+
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
m_actionHandler->setCurrentView(m_view);
void DolphinPart::slotRequestItemInfo(const KFileItem& item)
{
emit m_extension->mouseOverInfo(item);
+ if (item.isNull()) {
+ updateStatusBar();
+ } else {
+ ReadOnlyPart::setStatusBarText(item.getStatusBarInfo());
+ }
}
void DolphinPart::slotItemTriggered(const KFileItem& item)
m_newMenu->setPopupFiles(url());
}
+void DolphinPart::updateStatusBar()
+{
+ emit ReadOnlyPart::setStatusBarText(m_view->statusBarText());
+}
+
+void DolphinPart::updateProgress(int percent)
+{
+ m_extension->loadingProgress(percent);
+}
+
#include "dolphinpart.moc"
*/
void updateNewMenu();
+ /**
+ * 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();
+
+ /**
+ * Notify container of folder loading progress.
+ */
+ void updateProgress(int percent);
+
private:
void createActions();
void createGoAction(const char* name, const char* iconName,
}
}
-void DolphinView::calculateItemCount(int& fileCount, int& folderCount)
+void DolphinView::calculateItemCount(int& fileCount, int& folderCount) const
{
- foreach (const KFileItem &item, m_dirLister->items()) {
+ foreach (const KFileItem& item, m_dirLister->items()) {
if (item.isDir()) {
++folderCount;
} else {
}
}
+QString DolphinView::statusBarText() const
+{
+ if (hasSelection()) {
+ // give a summary of the status of the selected files
+ QString text;
+ const KFileItemList list = 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;
+ } else {
+ // Give a summary of the status of the current folder.
+ int folderCount = 0;
+ int fileCount = 0;
+ calculateItemCount(fileCount, folderCount);
+ return KIO::itemsSummaryString(fileCount + folderCount,
+ fileCount,
+ folderCount,
+ 0, false);
+ }
+}
+
void DolphinView::setUrl(const KUrl& url)
{
// remember current item candidate (see restoreCurrentItem())
* directory lister or the model directly, as it takes
* filtering and hierarchical previews into account.
*/
- void calculateItemCount(int& fileCount, int& folderCount);
+ void calculateItemCount(int& fileCount, int& folderCount) const;
+
+ /**
+ * Returns a textual representation of the state of the current
+ * folder or selected items, suitable for use in the status bar.
+ */
+ QString statusBarText() const;
/**
* Updates the state of the 'Additional Information' actions in \a collection.
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);
(m_statusBar->type() == DolphinStatusBar::Information)) &&
(m_statusBar->progress() == 100);
- const QString text(m_view->hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
+ const QString text(m_view->statusBarText());
m_statusBar->setDefaultText(text);
if (updateStatusBarMsg) {
*/
void dropUrls(const KUrl& destination, QDropEvent* event);
-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;