mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Cleanup & refactor
This commit is contained in:
parent
86e82c71e5
commit
59556dfc6a
4 changed files with 31 additions and 30 deletions
|
@ -76,33 +76,34 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
||||||
|
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case PCSIZE:
|
case PCSIZE:
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
|
||||||
break;
|
|
||||||
case REMAINING:
|
case REMAINING:
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
|
||||||
break;
|
break;
|
||||||
case PROGRESS:
|
case PROGRESS: {
|
||||||
if (index.data().toDouble() >= 0) {
|
if (index.data().toDouble() < 0)
|
||||||
QStyleOptionProgressBar newopt;
|
break;
|
||||||
qreal progress = index.data().toDouble() * 100.;
|
|
||||||
newopt.rect = opt.rect;
|
QStyleOptionProgressBar newopt;
|
||||||
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
|
qreal progress = index.data().toDouble() * 100.;
|
||||||
newopt.progress = (int)progress;
|
newopt.rect = opt.rect;
|
||||||
newopt.maximum = 100;
|
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
|
||||||
newopt.minimum = 0;
|
newopt.progress = int(progress);
|
||||||
newopt.textVisible = true;
|
newopt.maximum = 100;
|
||||||
if (index.sibling(index.row(), PRIORITY).data().toInt() == prio::IGNORED) {
|
newopt.minimum = 0;
|
||||||
newopt.state &= ~QStyle::State_Enabled;
|
newopt.textVisible = true;
|
||||||
newopt.palette = progressBarDisabledPalette();
|
if (index.sibling(index.row(), PRIORITY).data().toInt() == prio::IGNORED) {
|
||||||
}
|
newopt.state &= ~QStyle::State_Enabled;
|
||||||
else
|
newopt.palette = progressBarDisabledPalette();
|
||||||
newopt.state |= QStyle::State_Enabled;
|
}
|
||||||
|
else {
|
||||||
|
newopt.state |= QStyle::State_Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
QProxyStyle st("fusion");
|
QProxyStyle("fusion").drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,13 +56,13 @@ class PropListDelegate : public QItemDelegate
|
||||||
public:
|
public:
|
||||||
PropListDelegate(PropertiesWidget *properties);
|
PropListDelegate(PropertiesWidget *properties);
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &index) const;
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &index) const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const;
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/* index */) const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void filteredFilesChanged() const;
|
void filteredFilesChanged() const;
|
||||||
|
|
|
@ -69,5 +69,5 @@ void SearchListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||||
QWidget *SearchListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
|
QWidget *SearchListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
// No editor here
|
// No editor here
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ class SearchListDelegate: public QItemDelegate
|
||||||
public:
|
public:
|
||||||
explicit SearchListDelegate(QObject *parent);
|
explicit SearchListDelegate(QObject *parent);
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const;
|
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue