on xenial help sign in
Compilation fixes. Generate ShowAllFilterOption ids automatically.
commit6b468235f54460af31485932ff2822618e9fae23 authorPawel Stolowski <pawel.stolowski@canonical.com> dateMon 26 Aug 2013, 19:04 (13 years ago) parentcb1f96e
3 files changed+12−8
plugins/Unity/genericoptionsmodel.cpp+3−3 plugins/Unity/showallfilteroption.cpp+6−4 plugins/Unity/showallfilteroption.h+3−1
plugins/Unity/genericoptionsmodel.cpp+3−3
@@ -29,7 +29,7 @@ GenericOptionsModel::GenericOptionsModel(bool showAllOption, QObject *parent)
2929{
3030 if (showAllOption)
3131 {
32− auto showAll = ShowAllFilterOption("TODO", this);
32+ auto showAll = new ShowAllFilterOption(this);
3333 connect(showAll, SIGNAL(activeChanged(bool)), this, SLOT(onOptionChanged()));
3434 connect(showAll, SIGNAL(activeChanged(bool)), this, SLOT(onShowAllClicked(bool)));
3535 addOption(showAll, 0);
@@ -60,7 +60,7 @@ QVariant GenericOptionsModel::data(const QModelIndex& index, int role) const
6060 return QVariant();
6161 }
6262
63− auto filterOption = (m_showAll != nullptr && index.row() == 0) ? m_showAll : m_options[index.row()];
63+ auto filterOption = m_options[index.row()];
6464 switch (role)
6565 {
6666 case GenericOptionsModel::RoleId:
@@ -81,7 +81,7 @@ QVariant GenericOptionsModel::data(const QModelIndex& index, int role) const
8181
8282int GenericOptionsModel::rowCount(const QModelIndex& /* parent */) const
8383{
84− return m_options.size;
84+ return m_options.size();
8585}
8686
8787void GenericOptionsModel::setActive(int idx, bool value)
plugins/Unity/showallfilteroption.cpp+6−4
@@ -22,11 +22,13 @@
2222
2323#include <libintl.h>
2424
25−ShowAllFilterOption::ShowAllFilterOption(const QString &id, QObject *parent) :
25+unsigned int ShowAllFilterOption::m_showAllCount = 0;
26+
27+ShowAllFilterOption::ShowAllFilterOption(QObject *parent) :
2628 AbstractFilterOption(parent),
27− m_active(false),
28− m_id(id)
29+ m_active(false)
2930{
31+ m_id = QString("show_all::%1").arg(m_showAllCount++);
3032}
3133
3234QString ShowAllFilterOption::id() const
@@ -36,7 +38,7 @@ QString ShowAllFilterOption::id() const
3638
3739QString ShowAllFilterOption::name() const
3840{
39− QString::fromUtf8(dgettext("unity", "All"));
41+ return QString::fromUtf8(dgettext("unity", "All"));
4042}
4143
4244QString ShowAllFilterOption::iconHint() const
plugins/Unity/showallfilteroption.h+3−1
@@ -28,7 +28,7 @@ class Q_DECL_EXPORT ShowAllFilterOption : public AbstractFilterOption
2828 Q_OBJECT
2929
3030public:
31− explicit ShowAllFilterOption(const QString &id, QObject *parent = nullptr);
31+ explicit ShowAllFilterOption(QObject *parent = nullptr);
3232
3333 /* getters */
3434 QString id() const override;
@@ -42,6 +42,8 @@ public:
4242private:
4343 bool m_active;
4444 QString m_id;
45+
46+ static unsigned int m_showAllCount;
4547};
4648
4749Q_DECLARE_METATYPE(ShowAllFilterOption*)