on xenial help sign in
Added TODOs, renamed addOption to addObject in GenericListModel.
9db4f20Pawel Stolowski
plugins/Unity/combinedfilteroptions.cpp+2−2
@@ -35,12 +35,12 @@ void CombinedFilterOptions::initList(const std::vector<unity::dash::FilterOption
35 unity::dash::FilterOption::Ptr option2 = list[i+1];
35 unity::dash::FilterOption::Ptr option2 = list[i+1];
36 auto co = new CombinedFilterOption(option1, option2, this);
36 auto co = new CombinedFilterOption(option1, option2, this);
37 connect(co, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged(bool)));
37 connect(co, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged(bool)));
38− addOption(co);
38+ addObject(co);
39 ++i;
39 ++i;
40 }
40 }
41 if (list.size() > 0) {
41 if (list.size() > 0) {
42 auto co = new CombinedFilterOption(list[i], nullptr, this);
42 auto co = new CombinedFilterOption(list[i], nullptr, this);
43− addOption(co);
43+ addObject(co);
44 }
44 }
45}
45}
46
46
plugins/Unity/filters.cpp+2−2
@@ -64,9 +64,8 @@ QVariant Filters::data(const QModelIndex& index, int role) const
64 return QVariant();
64 return QVariant();
65 }
65 }
66
66
67− Filter* filter = m_filters.at(index.row());
68−
69 if (role == Filters::RoleFilter) {
67 if (role == Filters::RoleFilter) {
68+ Filter* filter = m_filters.at(index.row());
70 return QVariant::fromValue(filter);
69 return QVariant::fromValue(filter);
71 } else {
70 } else {
72 return QVariant();
71 return QVariant();
@@ -133,6 +132,7 @@ void Filters::removeFilter(int index)
133
132
134int Filters::indexForFilter(unity::dash::Filter::Ptr unityFilter)
133int Filters::indexForFilter(unity::dash::Filter::Ptr unityFilter)
135{
134{
135+ // TODO: use a map
136 int index;
136 int index;
137 for (index=0; index<m_filters.count(); index++) {
137 for (index=0; index<m_filters.count(); index++) {
138 if (m_filters[index]->hasUnityFilter(unityFilter)) {
138 if (m_filters[index]->hasUnityFilter(unityFilter)) {
plugins/Unity/genericlistmodel.cpp+1−1
@@ -39,7 +39,7 @@ int GenericListModel::rowCount(const QModelIndex& /* parent */) const
39 return m_list.count();
39 return m_list.count();
40}
40}
41
41
42−void GenericListModel::addOption(QObject *option)
42+void GenericListModel::addObject(QObject *option)
43{
43{
44 int index = m_list.count();
44 int index = m_list.count();
45 beginInsertRows(QModelIndex(), index, index);
45 beginInsertRows(QModelIndex(), index, index);
plugins/Unity/genericlistmodel.h+4−1
@@ -24,6 +24,9 @@
24#include <QObject>
24#include <QObject>
25#include <QAbstractListModel>
25#include <QAbstractListModel>
26
26
27+/*
28+ * TODO: see if it'd be better to use QVariantListModel.
29+ */
27class Q_DECL_EXPORT GenericListModel : public QAbstractListModel
30class Q_DECL_EXPORT GenericListModel : public QAbstractListModel
28{
31{
29 Q_OBJECT
32 Q_OBJECT
@@ -33,7 +36,7 @@ public:
33
36
34 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
37 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
35 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
38 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
36− void addOption(QObject* option);
39+ void addObject(QObject* option);
37
40
38 QList<QObject *>::Iterator optionsBegin();
41 QList<QObject *>::Iterator optionsBegin();
39 QList<QObject *>::Iterator optionsEnd();
42 QList<QObject *>::Iterator optionsEnd();
plugins/Unity/ratingsfilter.cpp+1−1
@@ -54,7 +54,7 @@ void RatingsFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
54 for (int i=1; i<=5; i++) {
54 for (int i=1; i<=5; i++) {
55 auto opt = new RatingFilterOption(QString::number(i), i*0.2f, this);
55 auto opt = new RatingFilterOption(QString::number(i), i*0.2f, this);
56 connect(opt, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged()));
56 connect(opt, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged()));
57− m_options->addOption(opt);
57+ m_options->addObject(opt);
58 }
58 }
59
59
60 Q_EMIT ratingsChanged();
60 Q_EMIT ratingsChanged();