+
+void DolphinCategoryDrawer::mouseButtonPressed(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event)
+{
+ if (!index.isValid()) {
+ event->ignore();
+ return;
+ }
+ const QString category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
+ int iconSize = KIconLoader::global()->currentSize(KIconLoader::Small);
+ if (this->category == category) {
+ QRect iconAllRect(blockRect);
+ iconAllRect.setTop(iconAllRect.top() + 4);
+ iconAllRect.setLeft(iconAllRect.right() - 16 - 7);
+ iconAllRect.setSize(QSize(iconSize, iconSize));
+ if (iconAllRect.contains(pos)) {
+ event->accept();
+ hotSpotPressed = SelectAllHotSpot;
+ categoryPressed = index;
+ return;
+ }
+ QRect iconNoneRect(blockRect);
+ iconNoneRect.setTop(iconNoneRect.top() + 4);
+ iconNoneRect.setLeft(iconNoneRect.right() - 16 * 2 - 7 * 2);
+ iconNoneRect.setSize(QSize(iconSize, iconSize));
+ if (iconNoneRect.contains(pos)) {
+ event->accept();
+ hotSpotPressed = UnselectAllHotSpot;
+ categoryPressed = index;
+ return;
+ }
+ }
+ event->ignore();
+}
+
+void DolphinCategoryDrawer::mouseButtonReleased(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event)
+{
+ if (!index.isValid() || hotSpotPressed == NoneHotSpot || categoryPressed != index) {
+ event->ignore();
+ return;
+ }
+ categoryPressed = QModelIndex();
+ const QString category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
+ int iconSize = KIconLoader::global()->currentSize(KIconLoader::Small);
+ if (this->category == category) {
+ QRect iconAllRect(blockRect);
+ iconAllRect.setTop(iconAllRect.top() + 4);
+ iconAllRect.setLeft(iconAllRect.right() - 16 - 7);
+ iconAllRect.setSize(QSize(iconSize, iconSize));
+ if (iconAllRect.contains(pos)) {
+ if (hotSpotPressed == SelectAllHotSpot) {
+ event->accept();
+ emit actionRequested(SelectAll, index);
+ } else {
+ event->ignore();
+ hotSpotPressed = NoneHotSpot;
+ }
+ return;
+ }
+ QRect iconNoneRect(blockRect);
+ iconNoneRect.setTop(iconNoneRect.top() + 4);
+ iconNoneRect.setLeft(iconNoneRect.right() - 16 * 2 - 7 * 2);
+ iconNoneRect.setSize(QSize(iconSize, iconSize));
+ if (iconNoneRect.contains(pos)) {
+ if (hotSpotPressed == UnselectAllHotSpot) {
+ event->accept();
+ emit actionRequested(UnselectAll, index);
+ } else {
+ event->ignore();
+ hotSpotPressed = NoneHotSpot;
+ }
+ return;
+ }
+ }
+ event->ignore();
+}
+
+void DolphinCategoryDrawer::mouseMoved(const QModelIndex &index, const QRect &blockRect, QMouseEvent *event)
+{
+ event->ignore();
+ if (!index.isValid()) {
+ return;
+ }
+ pos = event->pos();
+ category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
+}
+
+void DolphinCategoryDrawer::mouseLeft(const QModelIndex &index, const QRect &blockRect)
+{
+ pos = QPoint();
+ category = QString();
+}