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
|
|
|
QIcon m_moreIcon;
|
|
|
|
FolderStatusDelegate();
|
2015-06-15 15:16:21 +03:00
|
|
|
|
|
|
|
enum datarole { FolderAliasRole = Qt::UserRole + 100,
|
2015-08-12 10:08:30 +03:00
|
|
|
HeaderRole,
|
2017-04-26 21:03:55 +03:00
|
|
|
FolderPathRole, // for a SubFolder it's the complete path
|
2015-06-15 15:16:21 +03:00
|
|
|
FolderSecondPathRole,
|
2017-07-12 15:50:51 +03:00
|
|
|
FolderConflictMsg,
|
2015-06-15 15:16:21 +03:00
|
|
|
FolderErrorMsg,
|
|
|
|
FolderSyncPaused,
|
|
|
|
FolderStatusIconRole,
|
|
|
|
FolderAccountConnected,
|
|
|
|
|
|
|
|
SyncProgressOverallPercent,
|
|
|
|
SyncProgressOverallString,
|
|
|
|
SyncProgressItemString,
|
|
|
|
WarningCount,
|
|
|
|
SyncRunning,
|
|
|
|
|
2015-07-14 12:03:25 +03:00
|
|
|
AddButton // 1 = enabled; 2 = disabled
|
2015-06-15 15:16:21 +03:00
|
|
|
};
|
|
|
|
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const Q_DECL_OVERRIDE;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const Q_DECL_OVERRIDE;
|
|
|
|
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index) Q_DECL_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
|
|
|
|
2015-07-06 16:41:38 +03:00
|
|
|
private:
|
|
|
|
static QString addFolderText();
|
2018-10-30 22:35:35 +03:00
|
|
|
QPersistentModelIndex _pressedIndex;
|
2015-06-15 15:16:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OCC
|