Added QxtItemDelegate::ProgressMinimumRole & ProgressMaximumRole.
This commit is contained in:
parent
d2bed25802
commit
3be029b041
1
CHANGES
1
CHANGES
|
@ -17,6 +17,7 @@ or online at http://docs.libqxt.org.
|
|||
* Improved QxtScheduleView
|
||||
* Added QxtSortFilterProxyModel
|
||||
* Improved QxtSpanSlider
|
||||
* Improved QxtItemDelegate
|
||||
|
||||
- QxtWeb
|
||||
* Added QxtWebCgiService
|
||||
|
|
|
@ -116,15 +116,18 @@ void QxtItemDelegatePrivate::paintMenu(QPainter* painter, const QStyleOptionView
|
|||
}
|
||||
}
|
||||
|
||||
void QxtItemDelegatePrivate::paintProgress(QPainter* painter, const QStyleOptionViewItem& option, int progress) const
|
||||
void QxtItemDelegatePrivate::paintProgress(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
QVariant min = index.data(QxtItemDelegate::ProgressMinimumRole);
|
||||
QVariant max = index.data(QxtItemDelegate::ProgressMaximumRole);
|
||||
|
||||
QStyleOptionProgressBar opt;
|
||||
opt.minimum = 0;
|
||||
opt.maximum = 100;
|
||||
opt.minimum = (min.isValid() && min.canConvert(QVariant::Int)) ? min.toInt() : 0;
|
||||
opt.maximum = (max.isValid() && max.canConvert(QVariant::Int)) ? max.toInt() : 100;
|
||||
opt.progress = index.data(QxtItemDelegate::ProgressValueRole).toInt();
|
||||
opt.rect = option.rect;
|
||||
opt.progress = progress;
|
||||
opt.textVisible = textVisible;
|
||||
opt.text = progressFormat.arg(progress);
|
||||
opt.text = progressFormat.arg(opt.progress);
|
||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &opt, painter, 0);
|
||||
}
|
||||
|
||||
|
@ -239,7 +242,7 @@ void QxtItemDelegate::setElideMode(Qt::TextElideMode mode)
|
|||
The default value is \b "%1%".
|
||||
|
||||
\note Progress bar is rendered for indices providing valid
|
||||
numerical data for \b ProgressRole.
|
||||
numerical data for \b ProgressValueRole.
|
||||
|
||||
\note \b \%1 is replaced by the progress percent.
|
||||
|
||||
|
@ -262,7 +265,7 @@ void QxtItemDelegate::setProgressTextFormat(const QString& format)
|
|||
The default value is \b true.
|
||||
|
||||
\note Progress bar is rendered for indices providing valid
|
||||
numerical data for \b ProgressRole.
|
||||
numerical data for \b ProgressValueRole.
|
||||
|
||||
\sa progressTextFormat, QxtItemDelegate::Role
|
||||
*/
|
||||
|
@ -339,10 +342,9 @@ void QxtItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
|
|||
QItemDelegate::paint(painter, option, index);
|
||||
|
||||
bool ok = false;
|
||||
const QVariant data = index.data(ProgressRole);
|
||||
const int progress = data.toInt(&ok);
|
||||
if (data.isValid() && ok)
|
||||
qxt_d().paintProgress(painter, option, progress);
|
||||
const QVariant data = index.data(ProgressValueRole);
|
||||
if (data.isValid() && data.canConvert(QVariant::Int))
|
||||
qxt_d().paintProgress(painter, option, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,12 @@ public:
|
|||
explicit QxtItemDelegate(QObject* parent = 0);
|
||||
virtual ~QxtItemDelegate();
|
||||
|
||||
enum Role { ProgressRole = Qt::UserRole + 328 };
|
||||
enum Role
|
||||
{
|
||||
ProgressValueRole = Qt::UserRole + 328,
|
||||
ProgressMinimumRole,
|
||||
ProgressMaximumRole
|
||||
};
|
||||
|
||||
Qxt::DecorationStyle decorationStyle() const;
|
||||
void setDecorationStyle(Qxt::DecorationStyle style);
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
void paintButton(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QTreeView* view) const;
|
||||
void paintMenu(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QTreeView* view) const;
|
||||
void paintProgress(QPainter* painter, const QStyleOptionViewItem& option, int progress) const;
|
||||
void paintProgress(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
void setCurrentEditor(QWidget* editor, const QModelIndex& index) const;
|
||||
|
||||
bool textVisible;
|
||||
|
|
Loading…
Reference in New Issue
Block a user