1 | /* |
2 | * Copyright (C) by Klaas Freitag <freitag@kde.org> |
3 | * Copyright (C) by Olivier Goffart <ogoffart@woboq.com> |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
12 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13 | * for more details. |
14 | */ |
15 | |
16 | #pragma once |
17 | #include <QStyledItemDelegate> |
18 | |
19 | namespace OCC { |
20 | |
21 | /** |
22 | * @brief The FolderStatusDelegate class |
23 | * @ingroup gui |
24 | */ |
25 | class FolderStatusDelegate : public QStyledItemDelegate |
26 | { |
27 | Q_OBJECT |
28 | public: |
29 | QIcon m_moreIcon; |
30 | FolderStatusDelegate(); |
31 | |
32 | enum datarole { FolderAliasRole = Qt::UserRole + 100, |
33 | , |
34 | FolderPathRole, // for a SubFolder it's the complete path |
35 | FolderSecondPathRole, |
36 | FolderConflictMsg, |
37 | FolderErrorMsg, |
38 | FolderInfoMsg, |
39 | FolderSyncPaused, |
40 | FolderStatusIconRole, |
41 | FolderAccountConnected, |
42 | |
43 | SyncProgressOverallPercent, |
44 | SyncProgressOverallString, |
45 | SyncProgressItemString, |
46 | WarningCount, |
47 | SyncRunning, |
48 | |
49 | AddButton // 1 = enabled; 2 = disabled |
50 | }; |
51 | void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const Q_DECL_OVERRIDE; |
52 | QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const Q_DECL_OVERRIDE; |
53 | bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, |
54 | const QModelIndex &index) Q_DECL_OVERRIDE; |
55 | |
56 | |
57 | /** |
58 | * return the position of the option button within the item |
59 | */ |
60 | static QRect optionsButtonRect(QRect within, Qt::LayoutDirection direction); |
61 | static QRect errorsListRect(QRect within, const QModelIndex &); |
62 | static int rootFolderHeightWithoutErrors(const QFontMetrics &fm, const QFontMetrics &aliasFm); |
63 | |
64 | private: |
65 | static QString addFolderText(); |
66 | }; |
67 | |
68 | } // namespace OCC |
69 | |