File indexing completed on 2024-05-12 04:19:50
0001 // vim: set tabstop=4 shiftwidth=4 expandtab: 0002 /* 0003 Gwenview: an image viewer 0004 Copyright 2008 Aurélien Gâteau <agateau@kde.org> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License 0008 as published by the Free Software Foundation; either version 2 0009 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; if not, write to the Free Software 0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. 0019 0020 */ 0021 #ifndef PREVIEWITEMDELEGATE_H 0022 #define PREVIEWITEMDELEGATE_H 0023 0024 #include <lib/gwenviewlib_export.h> 0025 0026 // Qt 0027 #include <QItemDelegate> 0028 0029 // KF 0030 0031 // Local 0032 0033 class QUrl; 0034 0035 namespace Gwenview 0036 { 0037 class ThumbnailView; 0038 0039 struct PreviewItemDelegatePrivate; 0040 0041 /** 0042 * An ItemDelegate which generates thumbnails for images. It also makes sure 0043 * all items are of the same size. 0044 */ 0045 class GWENVIEWLIB_EXPORT PreviewItemDelegate : public QItemDelegate 0046 { 0047 Q_OBJECT 0048 public: 0049 PreviewItemDelegate(ThumbnailView *); 0050 ~PreviewItemDelegate() override; 0051 0052 enum ContextBarAction { 0053 NoAction = 0, 0054 SelectionAction = 1, 0055 FullScreenAction = 2, 0056 RotateAction = 4, 0057 }; 0058 Q_DECLARE_FLAGS(ContextBarActions, ContextBarAction) 0059 0060 enum ThumbnailDetail { 0061 FileNameDetail = 1, 0062 DateDetail = 2, 0063 RatingDetail = 4, 0064 ImageSizeDetail = 8, 0065 FileSizeDetail = 16, 0066 }; 0067 // FIXME: Find out why this cause problems with Qt::Alignment in 0068 // PreviewItemDelegate! 0069 Q_DECLARE_FLAGS(ThumbnailDetails, ThumbnailDetail) 0070 0071 /** 0072 * Returns which thumbnail details are shown 0073 */ 0074 ThumbnailDetails thumbnailDetails() const; 0075 0076 void setThumbnailDetails(ThumbnailDetails); 0077 0078 ContextBarActions contextBarActions() const; 0079 0080 void setContextBarActions(ContextBarActions); 0081 0082 Qt::TextElideMode textElideMode() const; 0083 0084 void setTextElideMode(Qt::TextElideMode); 0085 0086 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0087 void setEditorData(QWidget *editor, const QModelIndex &index) const override; 0088 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; 0089 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0090 0091 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0092 QSize sizeHint(const QStyleOptionViewItem & /*option*/, const QModelIndex & /*index*/) const override; 0093 0094 Q_SIGNALS: 0095 void saveDocumentRequested(const QUrl &); 0096 void rotateDocumentLeftRequested(const QUrl &); 0097 void rotateDocumentRightRequested(const QUrl &); 0098 void showDocumentInFullScreenRequested(const QUrl &); 0099 void setDocumentRatingRequested(const QUrl &, int rating); 0100 0101 private Q_SLOTS: 0102 void setThumbnailSize(const QSize &); 0103 0104 void slotSaveClicked(); 0105 void slotRotateLeftClicked(); 0106 void slotRotateRightClicked(); 0107 void slotFullScreenClicked(); 0108 void slotToggleSelectionClicked(); 0109 void slotRowsChanged(); 0110 0111 protected: 0112 bool eventFilter(QObject *, QEvent *) override; 0113 0114 private: 0115 PreviewItemDelegatePrivate *const d; 0116 friend struct PreviewItemDelegatePrivate; 0117 }; 0118 0119 } // namespace 0120 0121 // See upper 0122 Q_DECLARE_OPERATORS_FOR_FLAGS(Gwenview::PreviewItemDelegate::ThumbnailDetails) 0123 Q_DECLARE_OPERATORS_FOR_FLAGS(Gwenview::PreviewItemDelegate::ContextBarActions) 0124 0125 #endif /* PREVIEWITEMDELEGATE_H */