m_columnView(0),
m_fileItemDelegate(0),
m_selectionModel(0),
+ m_selectionChangedTimer(0),
m_dolphinModel(dolphinModel),
m_dirLister(dirLister),
m_proxyModel(proxyModel),
QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
if (active) {
- emit selectionChanged(selectedItems());
+ emitSelectionChangedSignal();
} else {
color.setAlpha(150);
}
emit itemTriggered(item); // caught by DolphinViewContainer or DolphinPart
}
+void DolphinView::emitDelayedSelectionChangedSignal()
+{
+ // Invoke emitSelectionChangedSignal() with a delay of 300 ms. This assures
+ // that fast selection changes don't result in expensive operations to
+ // collect all file items for the signal (see DolphinView::selectedItems()).
+ m_selectionChangedTimer->start();
+}
+
void DolphinView::emitSelectionChangedSignal()
{
emit selectionChanged(DolphinView::selectedItems());
m_selectionModel = view->selectionModel();
}
+ m_selectionChangedTimer = new QTimer(this);
+ m_selectionChangedTimer->setSingleShot(true);
+ m_selectionChangedTimer->setInterval(300);
+ connect(m_selectionChangedTimer, SIGNAL(timeout()),
+ this, SLOT(emitSelectionChangedSignal()));
+
// reparent the selection model, as it should not be deleted
// when deleting the model
m_selectionModel->setParent(this);
m_topLayout->insertWidget(1, view);
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
- this, SLOT(emitSelectionChangedSignal()));
+ this, SLOT(emitDelayedSelectionChangedSignal()));
connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(emitContentsMoved()));
connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)),
m_view(0),
m_filterBar(0),
m_statusBar(0),
+ m_statusBarTimer(0),
m_dirLister(0),
m_proxyModel(0)
{
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
connect(m_dirLister, SIGNAL(clear()),
- this, SLOT(updateStatusBar()));
+ this, SLOT(delayedStatusBarUpdate()));
connect(m_dirLister, SIGNAL(percent(int)),
this, SLOT(updateProgress(int)));
- connect(m_dirLister, SIGNAL(deleteItem(const KFileItem&)),
- this, SLOT(updateStatusBar()));
+ connect(m_dirLister, SIGNAL(itemsDeleted(const KFileItemList&)),
+ this, SLOT(delayedStatusBarUpdate()));
connect(m_dirLister, SIGNAL(completed()),
this, SLOT(slotDirListerCompleted()));
connect(m_dirLister, SIGNAL(infoMessage(const QString&)),
this, SLOT(saveRootUrl(const KUrl&)));
connect(m_view, SIGNAL(redirection(KUrl, KUrl)),
this, SLOT(redirect(KUrl, KUrl)));
+ connect(m_view, SIGNAL(selectionChanged(const KFileItemList&)),
+ this, SLOT(delayedStatusBarUpdate()));
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
this, SLOT(restoreView(const KUrl&)));
this, SLOT(slotHistoryChanged()));
m_statusBar = new DolphinStatusBar(this, m_view);
+ m_statusBarTimer = new QTimer(this);
+ m_statusBarTimer->setSingleShot(true);
+ m_statusBarTimer->setInterval(300);
+ connect(m_statusBarTimer, SIGNAL(timeout()),
+ this, SLOT(updateStatusBar()));
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(settings->filterBar());
return m_urlNavigator->isUrlEditable();
}
+void DolphinViewContainer::delayedStatusBarUpdate()
+{
+ // Invoke updateStatusBar() with a small delay. This assures that
+ // when a lot of delayedStatusBarUpdates() are done in a short time,
+ // no bottleneck is given.
+ m_statusBarTimer->start();
+}
+
+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->statusBarText());
+ m_statusBar->setDefaultText(text);
+
+ if (updateStatusBarMsg) {
+ m_statusBar->setMessage(text, DolphinStatusBar::Default);
+ }
+}
+
void DolphinViewContainer::updateProgress(int percent)
{
if (!m_showProgress) {
m_showProgress = false;
}
- updateStatusBar();
+ delayedStatusBarUpdate();
QMetaObject::invokeMethod(this, "restoreContentsPos", Qt::QueuedConnection);
// Enable the 'File'->'Create New...' menu only if the directory
emit showFilterBarChanged(false);
}
-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->statusBarText());
- m_statusBar->setDefaultText(text);
-
- if (updateStatusBarMsg) {
- m_statusBar->setMessage(text, DolphinStatusBar::Default);
- }
-}
-
void DolphinViewContainer::setNameFilter(const QString& nameFilter)
{
m_view->setNameFilter(nameFilter);
- updateStatusBar();
+ delayedStatusBarUpdate();
}
void DolphinViewContainer::openContextMenu(const KFileItem& item,
*/
void showFilterBar(bool show);
+signals:
+ /**
+ * Is emitted whenever the filter bar has changed its visibility state.
+ */
+ void showFilterBarChanged(bool shown);
+
+private slots:
/**
* 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.
+ * of selected files and the sum of the filesize is shown. The update
+ * is done asynchronously, as getting the sum of the
+ * filesizes can be an expensive operation.
*/
- void updateStatusBar();
+ void delayedStatusBarUpdate();
-signals:
/**
- * Is emitted whenever the filter bar has changed its visibility state.
+ * Is invoked by DolphinViewContainer::delayedStatusBarUpdate() and
+ * updates the status bar synchronously.
*/
- void showFilterBarChanged(bool shown);
+ void updateStatusBar();
-private slots:
void updateProgress(int percent);
/**
DolphinView* m_view;
FilterBar* m_filterBar;
+
DolphinStatusBar* m_statusBar;
+ QTimer* m_statusBarTimer;
DolphinModel* m_dolphinModel;
DolphinDirLister* m_dirLister;