#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);
void DolphinView::selectAll()
{
- //fileView()->selectAll();
+ selectAll(QItemSelectionModel::Select);
}
void DolphinView::invertSelection()
{
- //fileView()->invertSelection();
+ selectAll(QItemSelectionModel::Toggle);
}
DolphinStatusBar* DolphinView::statusBar() const
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()
}
}
-/*KFileView* DolphinView::fileView() const
-{
- return (m_mode == DetailsView) ? static_cast<KFileView*>(m_iconsView) :
- static_cast<KFileView*>(m_iconsView);
-}*/
-
-Q3ScrollView* DolphinView::scrollView() const
-{
- return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
- // static_cast<Q3ScrollView*>(m_iconsView);
-}
-
-ItemEffectsManager* DolphinView::itemEffectsManager() const
-{
- return 0;
-}
-
void DolphinView::startDirLister(const KUrl& url, bool reload)
{
if (!url.isValid()) {
m_dirLister->setNameFilter(adjustedFilter);
m_dirLister->emitChanges();
-
- // TODO: this is a workaround for QIconView: the item position
- // stay as they are by filtering, only an inserting of an item
- // results to an automatic adjusting of the item position. In Qt4/KDE4
- // this workaround should get obsolete due to Interview.
- /*KFileView* view = fileView();
- if (view == m_iconsView) {
- KFileItem* first = view->firstFileItem();
- if (first != 0) {
- view->removeItem(first);
- view->insertItem(first);
- }
- }*/
}
void DolphinView::applyModeToView()
m_iconsView->setViewMode(QListView::ListMode);
m_iconsView->setGridSize(QSize(256, 24));
break;
-
- //case PreviewsView:
- // m_iconsView->setViewMode(QListView::IconMode);
- // m_iconsView->setGridSize(QSize(128, 128));
- // break;
}
}
return index;
}
+void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags)
+{
+ QItemSelectionModel* selectionModel = m_iconsView->selectionModel();
+ const QAbstractItemModel* itemModel = selectionModel->model();
+
+ const QModelIndex topLeft = itemModel->index(0, 0);
+ const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
+ itemModel->columnCount() - 1);
+
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, flags);
+}
+
#include "dolphinview.moc"