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

« back to all changes in this revision

Viewing changes to libs/widgets/common/ditemdelegate.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 - common delegate code
 
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 DITEMDELEGATE_H
 
25
#define DITEMDELEGATE_H
 
26
 
 
27
// Qt includes
 
28
 
 
29
#include <QAbstractItemDelegate>
 
30
 
 
31
// Local includes
 
32
 
 
33
#include "digikam_export.h"
 
34
#include "thumbnailsize.h"
 
35
 
 
36
namespace Digikam
 
37
{
 
38
 
 
39
class DCategorizedView;
 
40
class DItemDelegatePriv;
 
41
 
 
42
class DIGIKAM_EXPORT DItemDelegate : public QAbstractItemDelegate
 
43
{
 
44
    Q_OBJECT
 
45
 
 
46
public:
 
47
 
 
48
    DItemDelegate(DCategorizedView *parent);
 
49
    ~DItemDelegate();
 
50
 
 
51
    /// Returns the gridsize to be set by the view. It's sizeHint plus spacing.
 
52
    virtual QSize gridSize() const = 0;
 
53
    virtual QPixmap pixmapForDrag(const QStyleOptionViewItem& option, const QList<QModelIndex>& indexes) const = 0;
 
54
 
 
55
    /** You must set these options from the view */
 
56
    virtual void setThumbnailSize(const ThumbnailSize& thumbSize) = 0;
 
57
    virtual void setSpacing(int spacing) = 0;
 
58
    /** Style option with standard values to use for cached rendering.
 
59
     *  option.rect shall be the viewport rectangle.
 
60
     *  Call on resize, font change.*/
 
61
    virtual void setDefaultViewOptions(const QStyleOptionViewItem& option) = 0;
 
62
 
 
63
    /** These methods take four parameters: The position on viewport, the rect on viewport,
 
64
     *  the index, and optionally a parameter into which, if the return value is true,
 
65
     *  a rectangle can be written for which the return value will be true as well. */
 
66
    virtual bool acceptsToolTip(const QPoint& pos, const QRect& visualRect,
 
67
                                const QModelIndex& index, QRect *tooltipRect = 0) const = 0;
 
68
    virtual bool acceptsActivation(const QPoint& pos, const QRect& visualRect,
 
69
                                   const QModelIndex& index, QRect *activationRect = 0) const = 0;
 
70
 
 
71
    // to be called by DCategorizedView only
 
72
    virtual void mouseMoved(QMouseEvent *e, const QRect& visualRect, const QModelIndex& index) = 0;
 
73
 
 
74
    static QString squeezedText(const QFontMetrics &fm, int width, const QString& text);
 
75
    static QString dateToString(const QDateTime& datetime);
 
76
 
 
77
Q_SIGNALS:
 
78
 
 
79
    void gridSizeChanged(const QSize& newSize);
 
80
    void visualChange();
 
81
 
 
82
protected:
 
83
 
 
84
    virtual void clearCaches();
 
85
 
 
86
    QString squeezedTextCached(QPainter* p, int width, const QString& text) const;
 
87
    QPixmap thumbnailBorderPixmap(const QSize& pixSize) const;
 
88
    QPixmap makeDragPixmap(const QStyleOptionViewItem& option, const QList<QModelIndex>& indexes,
 
89
                           const QPixmap& suggestedPixmap = QPixmap()) const;
 
90
 
 
91
private:
 
92
 
 
93
    DItemDelegatePriv* const d;
 
94
};
 
95
 
 
96
} // namespace Digikam
 
97
 
 
98
#endif /* IMAGEDELEGATE_H */