┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dolphincolumnview.cpp16
-rw-r--r--src/dolphincolumnview.h13
-rw-r--r--src/dolphincolumnwidget.cpp20
-rw-r--r--src/dolphincolumnwidget.h13
-rw-r--r--src/dolphinview.cpp32
-rw-r--r--src/dolphinview.h16
-rw-r--r--src/dolphinviewcontainer.cpp64
-rw-r--r--src/dolphinviewcontainer.h11
8 files changed, 125 insertions, 60 deletions
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp
index e8b75c532..c0f08eaeb 100644
--- a/src/dolphincolumnview.cpp
+++ b/src/dolphincolumnview.cpp
@@ -139,6 +139,18 @@ void DolphinColumnView::setRootUrl(const KUrl& url)
m_columns[0]->setUrl(url);
}
+void DolphinColumnView::setNameFilter(const QString& nameFilter)
+{
+ foreach (DolphinColumnWidget* column, m_columns) {
+ column->setNameFilter(nameFilter);
+ }
+}
+
+QString DolphinColumnView::nameFilter() const
+{
+ return activeColumn()->nameFilter();
+}
+
KUrl DolphinColumnView::rootUrl() const
{
return m_columns[0]->url();
@@ -208,6 +220,10 @@ void DolphinColumnView::showColumn(const KUrl& url)
columnIndex++;
DolphinColumnWidget* column = new DolphinColumnWidget(viewport(), this, childUrl);
+ const QString filter = nameFilter();
+ if (!filter.isEmpty()) {
+ column->setNameFilter(filter);
+ }
column->setActive(false);
m_columns.append(column);
diff --git a/src/dolphincolumnview.h b/src/dolphincolumnview.h
index 80228a84c..95a16a80d 100644
--- a/src/dolphincolumnview.h
+++ b/src/dolphincolumnview.h
@@ -24,6 +24,7 @@
#include <QAbstractItemView>
#include <QList>
+#include <QString>
#include <QStyleOption>
class DolphinColumnWidget;
@@ -69,6 +70,18 @@ public:
/** Returns the URL of the first column. */
KUrl rootUrl() const;
+ /**
+ * Filters the currently shown items by \a nameFilter. All items
+ * which contain the given filter string will be shown.
+ */
+ void setNameFilter(const QString& nameFilter);
+
+ /**
+ * Returns the currently used name filter. All items
+ * which contain the name filter will be shown.
+ */
+ QString nameFilter() const;
+
public slots:
/**
* Shows the column which represents the URL \a url. If the column
diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp
index 380573629..92fbd4e79 100644
--- a/src/dolphincolumnwidget.cpp
+++ b/src/dolphincolumnwidget.cpp
@@ -190,6 +190,26 @@ void DolphinColumnWidget::updateBackground()
update();
}
+void DolphinColumnWidget::setNameFilter(const QString& nameFilter)
+{
+ // The name filter of KDirLister does a 'hard' filtering, which
+ // means that only the items are shown where the names match
+ // exactly the filter. This is non-transparent for the user, which
+ // just wants to have a 'soft' filtering: does the name contain
+ // the filter string?
+ QString adjustedFilter(nameFilter);
+ adjustedFilter.insert(0, '*');
+ adjustedFilter.append('*');
+
+ m_dirLister->setNameFilter(adjustedFilter);
+ m_dirLister->emitChanges();
+}
+
+QString DolphinColumnWidget::nameFilter() const
+{
+ return m_dirLister->nameFilter();
+}
+
void DolphinColumnWidget::dragEnterEvent(QDragEnterEvent* event)
{
if (event->mimeData()->hasUrls()) {
diff --git a/src/dolphincolumnwidget.h b/src/dolphincolumnwidget.h
index 03e082658..7636655a9 100644
--- a/src/dolphincolumnwidget.h
+++ b/src/dolphincolumnwidget.h
@@ -84,6 +84,19 @@ public:
*/
void updateBackground();
+ /**
+ * Filters the currently shown items by \a nameFilter. All items
+ * which contain the given filter string will be shown.
+ */
+ void setNameFilter(const QString& nameFilter);
+
+ /**
+ * Returns the currently used name filter. All items
+ * which contain the name filter will be shown.
+ */
+ QString nameFilter() const;
+
+
protected:
virtual QStyleOptionViewItem viewOptions() const;
virtual void dragEnterEvent(QDragEnterEvent* event);
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 8361ceb06..59341b65b 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -493,6 +493,38 @@ void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
emit startedPathLoading(url);
}
+void DolphinView::setNameFilter(const QString& nameFilter)
+{
+ // The name filter of KDirLister does a 'hard' filtering, which
+ // means that only the items are shown where the names match
+ // exactly the filter. This is non-transparent for the user, which
+ // just wants to have a 'soft' filtering: does the name contain
+ // the filter string?
+ QString adjustedFilter(nameFilter);
+ adjustedFilter.insert(0, '*');
+ adjustedFilter.append('*');
+
+ m_dirLister->setNameFilter(adjustedFilter);
+ m_dirLister->emitChanges();
+
+ if (isColumnViewActive()) {
+ // adjusting the directory lister is not enough in the case of the
+ // column view, as each column has its own directory lister internally...
+ m_columnView->setNameFilter(nameFilter);
+ }
+}
+
+void DolphinView::calculateItemCount(int& fileCount, int& folderCount)
+{
+ foreach (KFileItem item, m_dirLister->items()) {
+ if (item.isDir()) {
+ ++folderCount;
+ } else {
+ ++fileCount;
+ }
+ }
+}
+
void DolphinView::setUrl(const KUrl& url)
{
updateView(url, KUrl());
diff --git a/src/dolphinview.h b/src/dolphinview.h
index 9291ea8b9..4e76c87c2 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -304,6 +304,21 @@ public:
*/
void updateView(const KUrl& url, const KUrl& rootUrl);
+ /**
+ * Filters the currently shown items by \a nameFilter. All items
+ * which contain the given filter string will be shown.
+ */
+ void setNameFilter(const QString& nameFilter);
+
+ /**
+ * Calculates the number of currently shown files into
+ * \a fileCount and the number of folders into \a folderCount.
+ * It is recommend using this method instead of asking the
+ * directory lister or the model directly, as it takes
+ * filtering and hierarchical previews into account.
+ */
+ void calculateItemCount(int& fileCount, int& folderCount);
+
public slots:
/**
* Changes the directory to \a url. If the current directory is equal to
@@ -319,6 +334,7 @@ public slots:
*/
void changeSelection(const KFileItemList& selection);
+
signals:
/**
* Is emitted if the view has been activated by e. g. a mouse click.
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index 65e587fb2..1f419d099 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -62,8 +62,6 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
const KUrl& url) :
QWidget(parent),
m_showProgress(false),
- m_folderCount(0),
- m_fileCount(0),
m_mainWindow(mainWindow),
m_topLayout(0),
m_urlNavigator(0),
@@ -108,7 +106,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
connect(m_dirLister, SIGNAL(deleteItem(const KFileItem&)),
this, SLOT(updateStatusBar()));
connect(m_dirLister, SIGNAL(completed()),
- this, SLOT(updateItemCount()));
+ this, SLOT(slotDirListerCompleted()));
connect(m_dirLister, SIGNAL(infoMessage(const QString&)),
this, SLOT(showInfoMessage(const QString&)));
connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
@@ -148,7 +146,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(settings->filterBar());
connect(m_filterBar, SIGNAL(filterChanged(const QString&)),
- this, SLOT(changeNameFilter(const QString&)));
+ this, SLOT(setNameFilter(const QString&)));
connect(m_filterBar, SIGNAL(closeRequest()),
this, SLOT(closeFilterBar()));
@@ -292,7 +290,7 @@ void DolphinViewContainer::updateProgress(int percent)
}
}
-void DolphinViewContainer::updateItemCount()
+void DolphinViewContainer::slotDirListerCompleted()
{
if (m_showProgress) {
m_statusBar->setProgressText(QString());
@@ -300,23 +298,6 @@ void DolphinViewContainer::updateItemCount()
m_showProgress = false;
}
- KFileItemList items(m_dirLister->items());
- KFileItemList::const_iterator it = items.begin();
- const KFileItemList::const_iterator end = items.end();
-
- m_fileCount = 0;
- m_folderCount = 0;
-
- while (it != end) {
- const KFileItem item = *it;
- if (item.isDir()) {
- ++m_folderCount;
- } else {
- ++m_fileCount;
- }
- ++it;
- }
-
updateStatusBar();
QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
@@ -349,24 +330,12 @@ void DolphinViewContainer::closeFilterBar()
QString DolphinViewContainer::defaultStatusBarText() const
{
- int m_fileCount = 0;
- int m_folderCount = 0;
-
- for (int i = 0; i < m_proxyModel->rowCount(); i++)
- {
- if (m_dolphinModel->itemForIndex(m_proxyModel->mapToSource(m_proxyModel->index(i, m_proxyModel->sortColumn()))).isDir())
- {
- m_folderCount++;
- }
- else
- {
- m_fileCount++;
- }
- }
-
- return KIO::itemsSummaryString(m_fileCount + m_folderCount,
- m_fileCount,
- m_folderCount,
+ int folderCount = 0;
+ int fileCount = 0;
+ m_view->calculateItemCount(fileCount, folderCount);
+ return KIO::itemsSummaryString(fileCount + folderCount,
+ fileCount,
+ folderCount,
0, false);
}
@@ -440,20 +409,9 @@ void DolphinViewContainer::updateStatusBar()
}
}
-void DolphinViewContainer::changeNameFilter(const QString& nameFilter)
+void DolphinViewContainer::setNameFilter(const QString& nameFilter)
{
- // The name filter of KDirLister does a 'hard' filtering, which
- // means that only the items are shown where the names match
- // exactly the filter. This is non-transparent for the user, which
- // just wants to have a 'soft' filtering: does the name contain
- // the filter string?
- QString adjustedFilter(nameFilter);
- adjustedFilter.insert(0, '*');
- adjustedFilter.append('*');
-
- m_dirLister->setNameFilter(adjustedFilter);
- m_dirLister->emitChanges();
-
+ m_view->setNameFilter(nameFilter);
updateStatusBar();
}
diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h
index b908e6ea0..abaf2e34e 100644
--- a/src/dolphinviewcontainer.h
+++ b/src/dolphinviewcontainer.h
@@ -145,10 +145,10 @@ private slots:
void updateProgress(int percent);
/**
- * Updates the number of items (= number of directories + number of files)
- * and shows this information in the statusbar.
+ * Assures that the viewport position is restored and updates the
+ * statusbar to reflect the current content.
*/
- void updateItemCount();
+ void slotDirListerCompleted();
/**
* Handles clicking on an item
@@ -173,7 +173,7 @@ private slots:
* Filters the currently shown items by \a nameFilter. All items
* which contain the given filter string will be shown.
*/
- void changeNameFilter(const QString& nameFilter);
+ void setNameFilter(const QString& nameFilter);
/**
* Opens the context menu on the current mouse position.
@@ -229,9 +229,6 @@ private:
private:
bool m_showProgress;
- int m_folderCount;
- int m_fileCount;
-
DolphinMainWindow* m_mainWindow;
QVBoxLayout* m_topLayout;
KUrlNavigator* m_urlNavigator;