bookmarkselector.cpp
urlbutton.cpp
dolphincontextmenu.cpp
+ dolphinsortfilterproxymodel.cpp
undomanager.cpp
progressindicator.cpp
iconsviewsettingspage.cpp
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
+ * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "dolphinsortfilterproxymodel.h"
+
+#include <kdirmodel.h>
+#include <kfileitem.h>
+
+DolphinSortFilterProxyModel::DolphinSortFilterProxyModel(QObject* parent) :
+ QSortFilterProxyModel(parent),
+ m_sorting(DolphinView::SortByName),
+ m_sortOrder(Qt::Ascending)
+{
+}
+
+DolphinSortFilterProxyModel::~DolphinSortFilterProxyModel()
+{
+}
+
+void DolphinSortFilterProxyModel::setSorting(DolphinView::Sorting sorting)
+{
+ if (sorting != m_sorting) {
+ m_sorting = sorting;
+ // TODO: how to trigger an update?
+ }
+}
+
+void DolphinSortFilterProxyModel::setSortOrder(Qt::SortOrder sortOrder)
+{
+ if (sortOrder != m_sortOrder) {
+ m_sortOrder = sortOrder;
+ // TODO: how to trigger an update?
+ }
+}
+
+bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
+ const QModelIndex& right) const
+{
+ // TODO: this is just a test implementation
+ KDirModel* model = static_cast<KDirModel*>(sourceModel());
+
+ KFileItem* leftItem = model->itemForIndex(left);
+ if (leftItem == 0) {
+ return true;
+ }
+
+ KFileItem* rightItem = model->itemForIndex(right);
+ if (rightItem == 0) {
+ return false;
+ }
+
+ return leftItem->name() > rightItem->name();
+}
+
+#include "dolphinsortfilterproxymodel.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef DOLPHINSORTFILTERPROXYMODEL_H
+#define DOLPHINSORTFILTERPROXYMODEL_H
+
+#include <QSortFilterProxyModel>
+#include <dolphinview.h>
+
+/**
+ * @brief Acts as proxy model for KDirModel to sort and filter
+ * KFileItems.
+ *
+ * TODO: implementation does not work yet (the method lessThan is
+ * not invoked)
+ */
+class DolphinSortFilterProxyModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+
+public:
+ DolphinSortFilterProxyModel(QObject* parent = 0);
+ virtual ~DolphinSortFilterProxyModel();
+
+ void setSorting(DolphinView::Sorting sorting);
+ DolphinView::Sorting sorting() const { return m_sorting; }
+
+ void setSortOrder(Qt::SortOrder sortOrder);
+ Qt::SortOrder sortOrder() const { return m_sortOrder; }
+
+protected:
+ virtual bool lessThan(const QModelIndex& left,
+ const QModelIndex& right) const;
+
+private:
+ DolphinView::Sorting m_sorting;
+ Qt::SortOrder m_sortOrder;
+};
+
+#endif
#include "dolphinstatusbar.h"
#include "dolphinmainwindow.h"
#include "dolphindirlister.h"
+#include "dolphinsortfilterproxymodel.h"
#include "viewproperties.h"
#include "dolphindetailsview.h"
#include "dolphiniconsview.h"
m_refreshing(false),
m_showProgress(false),
m_mode(mode),
- m_mainWindow(mainWindow),
- m_statusBar(0),
m_iconSize(0),
m_folderCount(0),
m_fileCount(0),
- m_filterBar(0)
+ m_mainWindow(mainWindow),
+ m_topLayout(0),
+ m_urlNavigator(0),
+ m_iconsView(0),
+ m_filterBar(0),
+ m_statusBar(0),
+ m_dirLister(0),
+ m_proxyModel(0)
{
hide();
setFocusPolicy(Qt::StrongFocus);
KDirModel* model = new KDirModel();
model->setDirLister(m_dirLister);
+
+ m_proxyModel = new DolphinSortFilterProxyModel(this);
+ m_proxyModel->setSourceModel(model);
+ m_proxyModel->setDynamicSortFilter(true);
+
m_iconsView->setModel(model);
KFileItemDelegate* delegate = new KFileItemDelegate(this);
ViewProperties props(url());
props.setSorting(sorting);
- KDirModel* dirModel = static_cast<KDirModel*>(m_iconsView->model());
- dirModel->sort(columnIndex(sorting), props.sortOrder());
+ m_proxyModel->setSorting(sorting);
emit sortingChanged(sorting);
}
DolphinView::Sorting DolphinView::sorting() const
{
- // TODO: instead of getting the sorting from the properties just fetch
- // them from KDirModel, if such an interface will be offered (David?)
- ViewProperties props(url());
- return props.sorting();
+ return m_proxyModel->sorting();
}
void DolphinView::setSortOrder(Qt::SortOrder order)
ViewProperties props(url());
props.setSortOrder(order);
- KDirModel* dirModel = static_cast<KDirModel*>(m_iconsView->model());
- dirModel->sort(columnIndex(props.sorting()), order);
+ m_proxyModel->setSortOrder(order);
emit sortOrderChanged(order);
}
Qt::SortOrder DolphinView::sortOrder() const
{
- // TODO: instead of getting the order from the properties just fetch
- // them from KDirModel, if such an interface will be offered (David?)
- ViewProperties props(url());
- return props.sortOrder();
+ return m_proxyModel->sortOrder();
}
void DolphinView::goBack()
class DolphinStatusBar;
class DolphinIconsView;
class DolphinDetailsView;
+class DolphinSortFilterProxyModel;
class ViewProperties;
class KProgress;
class FilterBar;
bool m_showProgress;
Mode m_mode;
+ int m_iconSize;
+ int m_folderCount;
+ int m_fileCount;
+
DolphinMainWindow* m_mainWindow;
QVBoxLayout* m_topLayout;
UrlNavigator* m_urlNavigator;
DolphinIconsView* m_iconsView;
+ FilterBar *m_filterBar;
DolphinStatusBar* m_statusBar;
- int m_iconSize;
- int m_folderCount;
- int m_fileCount;
-
DolphinDirLister* m_dirLister;
+ DolphinSortFilterProxyModel* m_proxyModel;
- FilterBar *m_filterBar;
};
#endif // _DOLPHINVIEW_H_