mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-01 17:24:48 +00:00
Place the external items at the end
This commit is contained in:
parent
9dfac82863
commit
a97fe3bc02
2 changed files with 15 additions and 6 deletions
|
|
@ -31,16 +31,23 @@ int QuickSettingsModel::rowCount(const QModelIndex &parent) const
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return m_children.count();
|
return m_children.count() + m_external.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QuickSettingsModel::data(const QModelIndex &index, int role) const
|
QVariant QuickSettingsModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid() || index.row() >= m_children.count() || role != Qt::UserRole) {
|
if (!index.isValid() || index.row() >= rowCount({}) || role != Qt::UserRole) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant::fromValue<QObject *>(m_children[index.row()]);
|
QObject *obj = nullptr;
|
||||||
|
if (index.row() < m_children.count()) {
|
||||||
|
obj = m_children[index.row()];
|
||||||
|
} else {
|
||||||
|
obj = m_external[index.row() - m_children.count()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant::fromValue<QObject *>(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickSettingsModel::classBegin()
|
void QuickSettingsModel::classBegin()
|
||||||
|
|
@ -64,7 +71,7 @@ void QuickSettingsModel::classBegin()
|
||||||
delete created;
|
delete created;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
include(createdSetting);
|
m_external += createdSetting;
|
||||||
}
|
}
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
|
|
@ -123,7 +130,8 @@ QQmlListProperty<QObject> QuickSetting::children()
|
||||||
|
|
||||||
void QuickSettingsModel::include(QuickSetting *item)
|
void QuickSettingsModel::include(QuickSetting *item)
|
||||||
{
|
{
|
||||||
beginInsertRows({}, m_children.count(), m_children.count());
|
const int c = m_children.count() + m_external.count();
|
||||||
m_children.append(item);
|
beginInsertRows({}, c, c);
|
||||||
|
m_external.append(item);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ Q_SIGNALS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QuickSetting *> m_children;
|
QList<QuickSetting *> m_children;
|
||||||
|
QList<QuickSetting *> m_external;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QUICKSETTINGSMODEL_H
|
#endif // QUICKSETTINGSMODEL_H
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue