Warning, file /office/calligra/libs/main/KoDocumentSectionDelegate.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002   Copyright (c) 2006 Gábor Lehel <illissius@gmail.com>
0003 
0004   This library is free software; you can redistribute it and/or
0005   modify it under the terms of the GNU Library General Public
0006   License as published by the Free Software Foundation; either
0007   version 2 of the License, or (at your option) any later version.
0008 
0009   This library is distributed in the hope that it will be useful,
0010   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012   Library General Public License for more details.
0013 
0014   You should have received a copy of the GNU Library General Public License
0015   along with this library; see the file COPYING.LIB.  If not, write to
0016   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017   Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KO_DOCUMENT_SECTION_DELEGATE_H
0021 #define KO_DOCUMENT_SECTION_DELEGATE_H
0022 
0023 #include <QAbstractItemDelegate>
0024 class KoDocumentSectionView;
0025 
0026 class KoDocumentSectionModel;
0027 
0028 /**
0029  * The KoDocumentSectionDelegate is the gui pendant of a
0030  * KoDocumentSectionModel: the graphical representation of one item in
0031  * a KoDocumentSectionView.
0032  */
0033 class KoDocumentSectionDelegate: public QAbstractItemDelegate
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     explicit KoDocumentSectionDelegate(KoDocumentSectionView *view, QObject *parent = 0);
0039     ~KoDocumentSectionDelegate() override;
0040 
0041     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0042     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0043     bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
0044 
0045     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0046     void setEditorData(QWidget *editor, const QModelIndex &index) const override;
0047     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
0048     void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
0049 
0050 protected:
0051     bool eventFilter(QObject *object, QEvent *event) override;
0052 
0053 
0054 private:
0055     typedef KoDocumentSectionModel Model;
0056     typedef KoDocumentSectionView View;
0057     class Private;
0058     Private* const d;
0059 
0060     static QStyleOptionViewItem getOptions(const QStyleOptionViewItem &option, const QModelIndex &index);
0061     int thumbnailHeight(const QStyleOptionViewItem &option, const QModelIndex &index) const;
0062     int availableWidth() const;
0063     int textBoxHeight(const QStyleOptionViewItem &option) const;
0064     QRect textRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
0065     QRect iconsRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
0066     QRect thumbnailRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
0067     QRect decorationRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
0068     QRect progressBarRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
0069     void drawText(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const;
0070     void drawIcons(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const;
0071     void drawThumbnail(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const;
0072     void drawDecoration(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const;
0073     void drawProgressBar(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const;
0074 };
0075 
0076 #endif