┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphiniconsview.cpp
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2010-03-14 16:31:16 +0000
committerRafael Fernández López <[email protected]>2010-03-14 16:31:16 +0000
commitc55ac460033175c5f0bef51e100d88c48e9d05d6 (patch)
tree6841a4e52830b20e471f11b6cee5a5cc758d9835 /src/dolphiniconsview.cpp
parentf2885d1ac237dcf1a3536e7a619275158fe2825d (diff)
Adapt DolphinCategoryDrawer to new changes on kdelibs :)
svn path=/trunk/KDE/kdebase/apps/; revision=1103215
Diffstat (limited to 'src/dolphiniconsview.cpp')
-rw-r--r--src/dolphiniconsview.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index ef3221422..46c27cd28 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -43,7 +43,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
DolphinSortFilterProxyModel* proxyModel) :
KCategorizedView(parent),
m_controller(controller),
- m_categoryDrawer(0),
+ m_categoryDrawer(new DolphinCategoryDrawer(this)),
m_extensionsFactory(0),
m_font(),
m_decorationSize(),
@@ -113,7 +113,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
m_displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
}
- m_categoryDrawer = new DolphinCategoryDrawer();
+ connect(m_categoryDrawer, SIGNAL(actionRequested(int,QModelIndex)), this, SLOT(categoryDrawerActionRequested(int,QModelIndex)));
setCategoryDrawer(m_categoryDrawer);
setFocus();
@@ -127,8 +127,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent,
DolphinIconsView::~DolphinIconsView()
{
- delete m_categoryDrawer;
- m_categoryDrawer = 0;
}
void DolphinIconsView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
@@ -424,6 +422,33 @@ void DolphinIconsView::slotGlobalSettingsChanged(int category)
}
}
+void DolphinIconsView::categoryDrawerActionRequested(int action, const QModelIndex &index)
+{
+ const QSortFilterProxyModel *model = dynamic_cast<const QSortFilterProxyModel*>(index.model());
+ const QModelIndex topLeft = model->index(index.row(), modelColumn());
+ QModelIndex bottomRight = topLeft;
+ const QString category = model->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
+ QModelIndex current = topLeft;
+ while (true) {
+ current = model->index(current.row() + 1, modelColumn());
+ const QString curCategory = model->data(model->index(current.row(), index.column()), KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
+ if (!current.isValid() || category != curCategory) {
+ break;
+ }
+ bottomRight = current;
+ }
+ switch (action) {
+ case DolphinCategoryDrawer::SelectAll:
+ selectionModel()->select(QItemSelection(topLeft, bottomRight), QItemSelectionModel::Select);
+ break;
+ case DolphinCategoryDrawer::UnselectAll:
+ selectionModel()->select(QItemSelection(topLeft, bottomRight), QItemSelectionModel::Deselect);
+ break;
+ default:
+ break;
+ }
+}
+
void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
{
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();