Browse Source

Cleanup & refactor

adaptive-webui-19844
Chocobo1 8 years ago
parent
commit
59556dfc6a
  1. 17
      src/gui/properties/proplistdelegate.cpp
  2. 10
      src/gui/properties/proplistdelegate.h
  3. 2
      src/gui/search/searchlistdelegate.cpp
  4. 4
      src/gui/search/searchlistdelegate.h

17
src/gui/properties/proplistdelegate.cpp

@ -76,18 +76,18 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti @@ -76,18 +76,18 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
switch(index.column()) {
case PCSIZE:
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
break;
case REMAINING:
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
break;
case PROGRESS:
if (index.data().toDouble() >= 0) {
case PROGRESS: {
if (index.data().toDouble() < 0)
break;
QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble() * 100.;
newopt.rect = opt.rect;
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
newopt.progress = (int)progress;
newopt.progress = int(progress);
newopt.maximum = 100;
newopt.minimum = 0;
newopt.textVisible = true;
@ -95,14 +95,15 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti @@ -95,14 +95,15 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
newopt.state &= ~QStyle::State_Enabled;
newopt.palette = progressBarDisabledPalette();
}
else
else {
newopt.state |= QStyle::State_Enabled;
}
#ifndef Q_OS_WIN
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
QProxyStyle st("fusion");
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
QProxyStyle("fusion").drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
}
break;

10
src/gui/properties/proplistdelegate.h

@ -56,13 +56,13 @@ class PropListDelegate : public QItemDelegate @@ -56,13 +56,13 @@ class PropListDelegate : public QItemDelegate
public:
PropListDelegate(PropertiesWidget *properties);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent, 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 override;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &index) const override;
public slots:
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, 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 override;
signals:
void filteredFilesChanged() const;

2
src/gui/search/searchlistdelegate.cpp

@ -69,5 +69,5 @@ void SearchListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op @@ -69,5 +69,5 @@ void SearchListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
QWidget *SearchListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
{
// No editor here
return 0;
return nullptr;
}

4
src/gui/search/searchlistdelegate.h

@ -38,8 +38,8 @@ class SearchListDelegate: public QItemDelegate @@ -38,8 +38,8 @@ class SearchListDelegate: public QItemDelegate
public:
explicit SearchListDelegate(QObject *parent);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const override;
};
#endif

Loading…
Cancel
Save