~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to lib/thumbnailview/thumbnailview.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
class QDropEvent;
35
35
class QPixmap;
36
36
 
37
 
namespace Gwenview {
 
37
namespace Gwenview
 
38
{
38
39
 
39
40
class AbstractDocumentInfoProvider;
40
41
class AbstractThumbnailViewHelper;
41
42
 
42
43
struct ThumbnailViewPrivate;
43
 
class GWENVIEWLIB_EXPORT ThumbnailView : public QListView {
44
 
        Q_OBJECT
 
44
class GWENVIEWLIB_EXPORT ThumbnailView : public QListView
 
45
{
 
46
    Q_OBJECT
45
47
public:
46
 
        enum {
47
 
                MinThumbnailSize = 48,
48
 
                MaxThumbnailSize = 256
49
 
        };
50
 
        ThumbnailView(QWidget* parent);
51
 
        ~ThumbnailView();
52
 
 
53
 
        void setThumbnailViewHelper(AbstractThumbnailViewHelper* helper);
54
 
 
55
 
        AbstractThumbnailViewHelper* thumbnailViewHelper() const;
56
 
 
57
 
        void setDocumentInfoProvider(AbstractDocumentInfoProvider* provider);
58
 
 
59
 
        AbstractDocumentInfoProvider* documentInfoProvider() const;
60
 
 
61
 
        /**
62
 
         * Returns the thumbnail size.
63
 
         */
64
 
        int thumbnailSize() const;
65
 
 
66
 
        QPixmap thumbnailForIndex(const QModelIndex&, QSize* fullSize = 0);
67
 
 
68
 
        /**
69
 
         * Returns true if the document pointed by the index has been modified
70
 
         * inside Gwenview.
71
 
         */
72
 
        bool isModified(const QModelIndex&) const;
73
 
 
74
 
        /**
75
 
         * Returns true if the document pointed by the index is currently busy
76
 
         * (loading, saving, rotating...)
77
 
         */
78
 
        bool isBusy(const QModelIndex& index) const;
79
 
 
80
 
        virtual void setModel(QAbstractItemModel* model);
81
 
 
82
 
        /**
83
 
         * Publish this method so that delegates can call it.
84
 
         */
85
 
        using QListView::scheduleDelayedItemsLayout;
86
 
 
87
 
        /**
88
 
         * Returns the current pixmap to paint when drawing a busy index.
89
 
         */
90
 
        QPixmap busySequenceCurrentPixmap() const;
91
 
 
92
 
        void reloadThumbnail(const QModelIndex&);
 
48
    enum {
 
49
        MinThumbnailSize = 48,
 
50
        MaxThumbnailSize = 256
 
51
    };
 
52
    ThumbnailView(QWidget* parent);
 
53
    ~ThumbnailView();
 
54
 
 
55
    void setThumbnailViewHelper(AbstractThumbnailViewHelper* helper);
 
56
 
 
57
    AbstractThumbnailViewHelper* thumbnailViewHelper() const;
 
58
 
 
59
    void setDocumentInfoProvider(AbstractDocumentInfoProvider* provider);
 
60
 
 
61
    AbstractDocumentInfoProvider* documentInfoProvider() const;
 
62
 
 
63
    /**
 
64
     * Returns the thumbnail size.
 
65
     */
 
66
    int thumbnailSize() const;
 
67
 
 
68
    QPixmap thumbnailForIndex(const QModelIndex&, QSize* fullSize = 0);
 
69
 
 
70
    /**
 
71
     * Returns true if the document pointed by the index has been modified
 
72
     * inside Gwenview.
 
73
     */
 
74
    bool isModified(const QModelIndex&) const;
 
75
 
 
76
    /**
 
77
     * Returns true if the document pointed by the index is currently busy
 
78
     * (loading, saving, rotating...)
 
79
     */
 
80
    bool isBusy(const QModelIndex& index) const;
 
81
 
 
82
    virtual void setModel(QAbstractItemModel* model);
 
83
 
 
84
    /**
 
85
     * Publish this method so that delegates can call it.
 
86
     */
 
87
    using QListView::scheduleDelayedItemsLayout;
 
88
 
 
89
    /**
 
90
     * Returns the current pixmap to paint when drawing a busy index.
 
91
     */
 
92
    QPixmap busySequenceCurrentPixmap() const;
 
93
 
 
94
    void reloadThumbnail(const QModelIndex&);
93
95
 
94
96
Q_SIGNALS:
95
 
        /**
96
 
         * It seems we can't use the 'activated()' signal for now because it does
97
 
         * not know about KDE single vs doubleclick settings. The indexActivated()
98
 
         * signal replaces it.
99
 
         */
100
 
        void indexActivated(const QModelIndex&);
101
 
        void urlListDropped(const KUrl::List& lst, const KUrl& destination);
102
 
 
103
 
        void thumbnailSizeChanged(int);
104
 
 
105
 
        /**
106
 
         * Emitted whenever selectionChanged() is called.
107
 
         * This signal is suffixed with "Signal" because
108
 
         * QAbstractItemView::selectionChanged() is a slot.
109
 
         */
110
 
        void selectionChangedSignal(const QItemSelection&, const QItemSelection&);
111
 
 
112
 
        /**
113
 
         * Forward some signals from model, so that the delegate can use them
114
 
         */
115
 
        void rowsRemovedSignal(const QModelIndex& parent, int start, int end);
116
 
 
117
 
        void rowsInsertedSignal(const QModelIndex& parent, int start, int end);
118
 
 
 
97
    /**
 
98
     * It seems we can't use the 'activated()' signal for now because it does
 
99
     * not know about KDE single vs doubleclick settings. The indexActivated()
 
100
     * signal replaces it.
 
101
     */
 
102
    void indexActivated(const QModelIndex&);
 
103
    void urlListDropped(const KUrl::List& lst, const KUrl& destination);
 
104
 
 
105
    void thumbnailSizeChanged(int);
 
106
 
 
107
    /**
 
108
     * Emitted whenever selectionChanged() is called.
 
109
     * This signal is suffixed with "Signal" because
 
110
     * QAbstractItemView::selectionChanged() is a slot.
 
111
     */
 
112
    void selectionChangedSignal(const QItemSelection&, const QItemSelection&);
 
113
 
 
114
    /**
 
115
     * Forward some signals from model, so that the delegate can use them
 
116
     */
 
117
    void rowsRemovedSignal(const QModelIndex& parent, int start, int end);
 
118
 
 
119
    void rowsInsertedSignal(const QModelIndex& parent, int start, int end);
119
120
 
120
121
public Q_SLOTS:
121
 
        /**
122
 
         * Sets the thumbnail size, in pixels.
123
 
         */
124
 
        void setThumbnailSize(int pixel);
 
122
    /**
 
123
     * Sets the thumbnail size, in pixels.
 
124
     */
 
125
    void setThumbnailSize(int pixel);
125
126
 
126
 
        void scrollToSelectedIndex();
 
127
    void scrollToSelectedIndex();
127
128
 
128
129
protected:
129
 
        virtual void dragEnterEvent(QDragEnterEvent*);
130
 
 
131
 
        virtual void dragMoveEvent(QDragMoveEvent*);
132
 
 
133
 
        virtual void dropEvent(QDropEvent*);
134
 
 
135
 
        virtual void keyPressEvent(QKeyEvent*);
136
 
 
137
 
        virtual void resizeEvent(QResizeEvent*);
138
 
 
139
 
        virtual void scrollContentsBy(int dx, int dy);
140
 
 
141
 
        virtual void showEvent(QShowEvent*);
142
 
 
143
 
        virtual void wheelEvent(QWheelEvent*);
144
 
 
145
 
        virtual void startDrag(Qt::DropActions);
 
130
    virtual void dragEnterEvent(QDragEnterEvent*);
 
131
 
 
132
    virtual void dragMoveEvent(QDragMoveEvent*);
 
133
 
 
134
    virtual void dropEvent(QDropEvent*);
 
135
 
 
136
    virtual void keyPressEvent(QKeyEvent*);
 
137
 
 
138
    virtual void resizeEvent(QResizeEvent*);
 
139
 
 
140
    virtual void scrollContentsBy(int dx, int dy);
 
141
 
 
142
    virtual void showEvent(QShowEvent*);
 
143
 
 
144
    virtual void wheelEvent(QWheelEvent*);
 
145
 
 
146
    virtual void startDrag(Qt::DropActions);
146
147
 
147
148
protected Q_SLOTS:
148
 
        virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
149
 
        virtual void rowsInserted(const QModelIndex& parent, int start, int end);
150
 
        virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
151
 
        virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
 
149
    virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
 
150
    virtual void rowsInserted(const QModelIndex& parent, int start, int end);
 
151
    virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
 
152
    virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
152
153
 
153
154
private Q_SLOTS:
154
 
        void showContextMenu();
155
 
        void emitIndexActivatedIfNoModifiers(const QModelIndex&);
156
 
        void setThumbnail(const KFileItem&, const QPixmap&, const QSize&);
157
 
        void setBrokenThumbnail(const KFileItem&);
158
 
 
159
 
        /**
160
 
         * Generate thumbnail for @a index.
161
 
         */
162
 
        void updateThumbnail(const QModelIndex& index);
163
 
 
164
 
        /**
165
 
         * Tells the view the busy state of the document pointed by the index has changed.
166
 
         */
167
 
        void updateThumbnailBusyState(const QModelIndex& index, bool);
168
 
 
169
 
        /*
170
 
         * Cause a repaint of all busy indexes
171
 
         */
172
 
        void updateBusyIndexes();
173
 
 
174
 
        void generateThumbnailsForVisibleItems();
175
 
        void smoothNextThumbnail();
 
155
    void showContextMenu();
 
156
    void emitIndexActivatedIfNoModifiers(const QModelIndex&);
 
157
    void setThumbnail(const KFileItem&, const QPixmap&, const QSize&);
 
158
    void setBrokenThumbnail(const KFileItem&);
 
159
 
 
160
    /**
 
161
     * Generate thumbnail for @a index.
 
162
     */
 
163
    void updateThumbnail(const QModelIndex& index);
 
164
 
 
165
    /**
 
166
     * Tells the view the busy state of the document pointed by the index has changed.
 
167
     */
 
168
    void updateThumbnailBusyState(const QModelIndex& index, bool);
 
169
 
 
170
    /*
 
171
     * Cause a repaint of all busy indexes
 
172
     */
 
173
    void updateBusyIndexes();
 
174
 
 
175
    void generateThumbnailsForVisibleItems();
 
176
    void smoothNextThumbnail();
176
177
 
177
178
private:
178
 
        friend struct ThumbnailViewPrivate;
179
 
        ThumbnailViewPrivate * const d;
 
179
    friend struct ThumbnailViewPrivate;
 
180
    ThumbnailViewPrivate * const d;
180
181
};
181
182
 
182
183
} // namespace