2015-06-15 15:16:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@kde.org>
|
|
|
|
* Copyright (C) by Olivier Goffart <ogoffart@woboq.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
|
|
|
|
namespace OCC {
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The FolderStatusDelegate class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2015-06-15 15:16:21 +03:00
|
|
|
class FolderStatusDelegate : public QStyledItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2015-07-06 16:41:38 +03:00
|
|
|
public:
|
2015-11-06 18:10:03 +03:00
|
|
|
FolderStatusDelegate();
|
2015-06-15 15:16:21 +03:00
|
|
|
|
|
|
|
enum datarole { FolderAliasRole = Qt::UserRole + 100,
|
2017-05-17 11:55:42 +03:00
|
|
|
HeaderRole,
|
|
|
|
FolderPathRole, // for a SubFolder it's the complete path
|
|
|
|
FolderSecondPathRole,
|
2017-07-12 15:50:51 +03:00
|
|
|
FolderConflictMsg,
|
2017-05-17 11:55:42 +03:00
|
|
|
FolderErrorMsg,
|
2018-08-18 10:37:00 +03:00
|
|
|
FolderInfoMsg,
|
2017-05-17 11:55:42 +03:00
|
|
|
FolderSyncPaused,
|
|
|
|
FolderStatusIconRole,
|
|
|
|
FolderAccountConnected,
|
2015-06-15 15:16:21 +03:00
|
|
|
|
2017-05-17 11:55:42 +03:00
|
|
|
SyncProgressOverallPercent,
|
|
|
|
SyncProgressOverallString,
|
|
|
|
SyncProgressItemString,
|
|
|
|
WarningCount,
|
|
|
|
SyncRunning,
|
2019-01-23 01:16:57 +03:00
|
|
|
SyncDate,
|
2015-06-15 15:16:21 +03:00
|
|
|
|
2017-05-17 11:55:42 +03:00
|
|
|
AddButton // 1 = enabled; 2 = disabled
|
|
|
|
};
|
2018-11-11 13:09:29 +03:00
|
|
|
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override;
|
2017-05-17 11:55:42 +03:00
|
|
|
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
|
2018-11-11 13:09:29 +03:00
|
|
|
const QModelIndex &index) override;
|
2015-08-13 13:33:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* return the position of the option button within the item
|
|
|
|
*/
|
2016-01-13 13:42:49 +03:00
|
|
|
static QRect optionsButtonRect(QRect within, Qt::LayoutDirection direction);
|
2018-10-30 22:35:35 +03:00
|
|
|
static QRect addButtonRect(QRect within, Qt::LayoutDirection direction);
|
2017-07-04 15:08:41 +03:00
|
|
|
static QRect errorsListRect(QRect within);
|
2016-01-13 13:42:49 +03:00
|
|
|
static int rootFolderHeightWithoutErrors(const QFontMetrics &fm, const QFontMetrics &aliasFm);
|
2017-05-17 11:55:42 +03:00
|
|
|
|
2019-12-19 21:50:21 +03:00
|
|
|
public slots:
|
|
|
|
void slotStyleChanged();
|
|
|
|
|
2015-07-06 16:41:38 +03:00
|
|
|
private:
|
2019-12-19 21:50:21 +03:00
|
|
|
void customizeStyle();
|
|
|
|
|
2015-07-06 16:41:38 +03:00
|
|
|
static QString addFolderText();
|
2018-10-30 22:35:35 +03:00
|
|
|
QPersistentModelIndex _pressedIndex;
|
2019-12-19 21:50:21 +03:00
|
|
|
|
|
|
|
QIcon _iconMore;
|
2015-06-15 15:16:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OCC
|