52
52
addScope(new Scope("MockScope1", "People", true, this));
53
53
addScope(new Scope("MockScope2", "Music", false, this));
54
54
addScope(new Scope("clickscope", "Apps", true, this));
55
addScope(new Scope("MockScope5", "Videos", true, this));
55
addScope(new Scope("MockScope5", "Videos this is long ab cd ef gh ij kl", true, this));
56
56
addScope(new Scope("SingleCategoryScope", "Single", true, this, 1));
57
57
addScope(new Scope("MockScope4", "MS4", true, this));
58
58
addScope(new Scope("MockScope6", "MS6", true, this));
91
void Scopes::clearFavorites()
93
if (m_scopes.size() > 0) {
94
beginRemoveRows(QModelIndex(), 0, m_scopes.count()-1);
95
Q_FOREACH(Scope *scope, m_scopes) {
96
m_scopesOverview->setFavorite(scope, false);
91
103
void Scopes::load()
165
177
return m_scopesOverview;
168
QList<Scope*> Scopes::scopes() const
180
void Scopes::setFavorite(const QString& scopeId, bool favorite)
183
for (Scope *scope : m_scopes) {
184
// Check it's not already there
185
Q_ASSERT(scope->id() != scopeId);
187
for (Scope *scope : m_allScopes) {
188
if (scope->id() == scopeId) {
189
const int index = rowCount();
190
beginInsertRows(QModelIndex(), index, index);
193
m_scopesOverview->setFavorite(scope, true);
197
Q_ASSERT(false && "Unknown scopeId");
199
for (Scope *scope : m_scopes) {
200
if (scope->id() == scopeId) {
201
const int index = m_scopes.indexOf(scope);
202
beginRemoveRows(QModelIndex(), index, index);
203
m_scopes.removeAt(index);
205
m_scopesOverview->setFavorite(scope, false);
209
Q_ASSERT(false && "Unknown scopeId");
213
void Scopes::moveFavoriteTo(const QString& scopeId, int to)
216
for (int i = 0; i < m_scopes.count(); ++i) {
217
if (m_scopes[i]->id() == scopeId) {
222
Q_ASSERT(from != -1);
223
beginMoveRows(QModelIndex(), from, from, QModelIndex(), to + (to > from ? 1 : 0));
224
m_scopes.move(from, to);
226
m_scopesOverview->moveFavoriteTo(m_scopes[to], to);
229
QList<Scope*> Scopes::favScopes() const
173
QList<Scope*> Scopes::allScopes() const
234
QList<Scope*> Scopes::nonFavScopes() const
237
for (Scope *scope : m_allScopes) {
238
if (!m_scopes.contains(scope))
178
244
void Scopes::addScope(Scope* scope)