1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : Qt item view for images
9
* Copyright (C) 2009-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option)
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* ============================================================ */
24
#ifndef DCATEGORIZEDVIEW_H
25
#define DCATEGORIZEDVIEW_H
29
#include "digikam_export.h"
30
#include "kcategorizedview.h"
32
class QSortFilterProxyModel;
38
class DCategorizedViewPriv;
39
class ImageModelDragDropHandler;
40
class ItemViewToolTip;
42
class DIGIKAM_EXPORT DCategorizedView : public KCategorizedView
48
DCategorizedView(QWidget *parent = 0);
51
virtual QSortFilterProxyModel *filterModel() const = 0;
53
DItemDelegate *delegate() const;
55
int numberOfSelectedIndexes() const;
57
/** Selects the index as current and scrolls to it */
61
void toPreviousIndex();
62
void toIndex(const QModelIndex& index);
63
void awayFromSelection();
65
void invertSelection();
67
void setToolTipEnabled(bool enabled);
68
bool isToolTipEnabled() const;
70
/** Sets the spacing. Does not use setSpacing()/spacing() from QListView */
71
void setSpacing(int spacing);
72
/** Set if the PointingHand Cursor should be shown over the activation area */
73
void setUsePointingHandCursor(bool useCursor);
74
/** Determine a step size for scrolling: The larger this number,
75
* the smaller and more precise is the scrolling. Default is 10. */
76
void setScrollStepGranularity(int factor);
86
/// Emitted when any selection change occurs. Any of the signals below will be emitted before.
87
void selectionChanged();
88
/// Emitted when the selection is completely cleared.
89
void selectionCleared();
94
/** For overlays: Like the respective parent class signals, but with additional info.
95
* Do not change the mouse events.
97
void clicked(const QMouseEvent *e, const QModelIndex& index);
98
void entered(const QMouseEvent *e, const QModelIndex& index);
99
/** Remember you may want to check if the event is accepted or ignored.
100
* This signal is emitted after being handled by this widget.
101
* You can accept it if ignored. */
102
void keyPressed(QKeyEvent *e);
106
virtual void slotThemeChanged();
107
virtual void slotSetupChanged();
109
void slotActivated(const QModelIndex& index);
110
void slotClicked(const QModelIndex& index);
111
void slotEntered(const QModelIndex& index);
112
void layoutAboutToBeChanged();
113
void layoutWasChanged();
117
void encodeIsCutSelection(QMimeData* mime, bool isCutSelection);
118
bool decodeIsCutSelection(const QMimeData *mimeData);
120
void setToolTip(ItemViewToolTip *tip);
121
void setItemDelegate(DItemDelegate *delegate);
122
void updateDelegateSizes();
123
void userInteraction();
125
/// Reimplement these in a subclass
126
virtual void showContextMenuOnIndex(QContextMenuEvent *event, const QModelIndex& index);
127
virtual void showContextMenu(QContextMenuEvent *event);
128
virtual void indexActivated(const QModelIndex& index);
129
virtual ImageModelDragDropHandler *dragDropHandler() const = 0;
131
/** Returns an index that is representative for the category at position pos */
132
QModelIndex indexForCategoryAt(const QPoint& pos) const;
134
// reimplemented from parent class
135
void contextMenuEvent(QContextMenuEvent* event);
136
void dragEnterEvent(QDragEnterEvent *event);
137
void dragMoveEvent(QDragMoveEvent *e);
138
void dropEvent(QDropEvent *e);
139
void keyPressEvent(QKeyEvent *event);
140
void mouseMoveEvent(QMouseEvent *event);
141
void mousePressEvent(QMouseEvent *event);
142
void mouseReleaseEvent(QMouseEvent *event);
143
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
144
void resizeEvent(QResizeEvent *e);
146
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
147
void rowsInserted(const QModelIndex &parent, int start, int end);
148
void selectionChanged(const QItemSelection &, const QItemSelection &);
149
void startDrag(Qt::DropActions supportedActions);
150
bool viewportEvent(QEvent *event);
151
void wheelEvent(QWheelEvent* event);
155
void slotGridSizeChanged(const QSize &);
159
void ensureSelectionAfterChanges();
163
DCategorizedViewPriv* const d;
166
} // namespace Digikam
168
#endif /* IMAGECATEGORIZEDVIEW_H */