1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : Qt item view for images - common delegate code
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 DITEMDELEGATE_H
25
#define DITEMDELEGATE_H
29
#include <QAbstractItemDelegate>
33
#include "digikam_export.h"
34
#include "thumbnailsize.h"
39
class DCategorizedView;
40
class DItemDelegatePriv;
42
class DIGIKAM_EXPORT DItemDelegate : public QAbstractItemDelegate
48
DItemDelegate(DCategorizedView *parent);
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;
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;
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;
71
// to be called by DCategorizedView only
72
virtual void mouseMoved(QMouseEvent *e, const QRect& visualRect, const QModelIndex& index) = 0;
74
static QString squeezedText(const QFontMetrics &fm, int width, const QString& text);
75
static QString dateToString(const QDateTime& datetime);
79
void gridSizeChanged(const QSize& newSize);
84
virtual void clearCaches();
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;
93
DItemDelegatePriv* const d;
96
} // namespace Digikam
98
#endif /* IMAGEDELEGATE_H */