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();
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);
#include <QAbstractItemView>
#include <QList>
+#include <QString>
#include <QStyleOption>
class DolphinColumnWidget;
/** 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
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()) {
*/
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);
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());
*/
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
*/
void changeSelection(const KFileItemList& selection);
+
signals:
/**
* Is emitted if the view has been activated by e. g. a mouse click.
const KUrl& url) :
QWidget(parent),
m_showProgress(false),
- m_folderCount(0),
- m_fileCount(0),
m_mainWindow(mainWindow),
m_topLayout(0),
m_urlNavigator(0),
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&)),
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()));
}
}
-void DolphinViewContainer::updateItemCount()
+void DolphinViewContainer::slotDirListerCompleted()
{
if (m_showProgress) {
m_statusBar->setProgressText(QString());
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()));
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);
}
}
}
-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();
}
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
* 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.
private:
bool m_showProgress;
- int m_folderCount;
- int m_fileCount;
-
DolphinMainWindow* m_mainWindow;
QVBoxLayout* m_topLayout;
KUrlNavigator* m_urlNavigator;