~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/widgets/common/dcategorizedview.h

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2010-04-09 21:30:01 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100409213001-4bfyibrd359rn7o3
Tags: 2:1.2.0-0ubuntu1
* New upstream release (LP: #560576)
* Remove all patches, fixed upstream
  - Remove quilt build-depend

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2010-01-16
 
7
 * Description : Qt item view for images
 
8
 *
 
9
 * Copyright (C) 2009-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 
10
 *
 
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)
 
15
 * any later version.
 
16
 *
 
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.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
#ifndef DCATEGORIZEDVIEW_H
 
25
#define DCATEGORIZEDVIEW_H
 
26
 
 
27
// Local includes
 
28
 
 
29
#include "digikam_export.h"
 
30
#include "kcategorizedview.h"
 
31
 
 
32
class QSortFilterProxyModel;
 
33
 
 
34
namespace Digikam
 
35
{
 
36
 
 
37
class DItemDelegate;
 
38
class DCategorizedViewPriv;
 
39
class ImageModelDragDropHandler;
 
40
class ItemViewToolTip;
 
41
 
 
42
class DIGIKAM_EXPORT DCategorizedView : public KCategorizedView
 
43
{
 
44
    Q_OBJECT
 
45
 
 
46
public:
 
47
 
 
48
    DCategorizedView(QWidget *parent = 0);
 
49
    ~DCategorizedView();
 
50
 
 
51
    virtual QSortFilterProxyModel *filterModel() const = 0;
 
52
 
 
53
    DItemDelegate *delegate() const;
 
54
 
 
55
    int numberOfSelectedIndexes() const;
 
56
 
 
57
    /** Selects the index as current and scrolls to it */
 
58
    void toFirstIndex();
 
59
    void toLastIndex();
 
60
    void toNextIndex();
 
61
    void toPreviousIndex();
 
62
    void toIndex(const QModelIndex& index);
 
63
    void awayFromSelection();
 
64
 
 
65
    void invertSelection();
 
66
 
 
67
    void setToolTipEnabled(bool enabled);
 
68
    bool isToolTipEnabled() const;
 
69
 
 
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);
 
77
 
 
78
public Q_SLOTS:
 
79
 
 
80
    virtual void cut();
 
81
    virtual void copy();
 
82
    virtual void paste();
 
83
 
 
84
Q_SIGNALS:
 
85
 
 
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();
 
90
 
 
91
    void zoomOutStep();
 
92
    void zoomInStep();
 
93
 
 
94
    /** For overlays: Like the respective parent class signals, but with additional info.
 
95
     *  Do not change the mouse events.
 
96
     */
 
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);
 
103
 
 
104
protected Q_SLOTS:
 
105
 
 
106
    virtual void slotThemeChanged();
 
107
    virtual void slotSetupChanged();
 
108
 
 
109
    void slotActivated(const QModelIndex& index);
 
110
    void slotClicked(const QModelIndex& index);
 
111
    void slotEntered(const QModelIndex& index);
 
112
    void layoutAboutToBeChanged();
 
113
    void layoutWasChanged();
 
114
 
 
115
protected:
 
116
 
 
117
    void encodeIsCutSelection(QMimeData* mime, bool isCutSelection);
 
118
    bool decodeIsCutSelection(const QMimeData *mimeData);
 
119
 
 
120
    void setToolTip(ItemViewToolTip *tip);
 
121
    void setItemDelegate(DItemDelegate *delegate);
 
122
    void updateDelegateSizes();
 
123
    void userInteraction();
 
124
 
 
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;
 
130
 
 
131
    /** Returns an index that is representative for the category at position pos */
 
132
    QModelIndex indexForCategoryAt(const QPoint& pos) const;
 
133
 
 
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);
 
145
    void reset();
 
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);
 
152
 
 
153
private Q_SLOTS:
 
154
 
 
155
    void slotGridSizeChanged(const QSize &);
 
156
 
 
157
private:
 
158
 
 
159
    void ensureSelectionAfterChanges();
 
160
 
 
161
private:
 
162
 
 
163
    DCategorizedViewPriv* const d;
 
164
};
 
165
 
 
166
} // namespace Digikam
 
167
 
 
168
#endif /* IMAGECATEGORIZEDVIEW_H */