Commit 001aaf5c authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Kurt Hindenburg
Browse files

Remove the first item as default

parent 9d8e4729
...@@ -66,11 +66,14 @@ QVariant ProfileModel::data(const QModelIndex& idx, int role) const ...@@ -66,11 +66,14 @@ QVariant ProfileModel::data(const QModelIndex& idx, int role) const
} }
auto profile = m_profiles.at(idx.row()); auto profile = m_profiles.at(idx.row());
switch (idx.column()) { switch (idx.column()) {
case NAME: { case NAME: {
switch (role) { switch (role) {
case Qt::DisplayRole: { case Qt::DisplayRole: {
return QStringLiteral("%1%2").arg(profile->name(), (idx.row() == 0 ? i18n("(Default)") : QString())); return QStringLiteral("%1%2").arg(
profile->name(),
ProfileManager::instance()->defaultProfile() == profile ? i18n("(Default)") : QString());
} }
case Qt::DecorationRole: return QIcon::fromTheme(profile->icon()); case Qt::DecorationRole: return QIcon::fromTheme(profile->icon());
case Qt::FontRole: { case Qt::FontRole: {
...@@ -146,7 +149,6 @@ void ProfileModel::populate() ...@@ -146,7 +149,6 @@ void ProfileModel::populate()
beginResetModel(); beginResetModel();
m_profiles = ProfileManager::instance()->allProfiles(); m_profiles = ProfileManager::instance()->allProfiles();
ProfileManager::instance()->sortProfiles(m_profiles); ProfileManager::instance()->sortProfiles(m_profiles);
m_profiles.prepend(ProfileManager::instance()->defaultProfile());
endResetModel(); endResetModel();
} }
...@@ -166,10 +168,6 @@ void ProfileModel::remove(QExplicitlySharedDataPointer<Profile> profile) ...@@ -166,10 +168,6 @@ void ProfileModel::remove(QExplicitlySharedDataPointer<Profile> profile)
void ProfileModel::setDefault(QExplicitlySharedDataPointer<Profile> profile) void ProfileModel::setDefault(QExplicitlySharedDataPointer<Profile> profile)
{ {
if (m_profiles.count()) {
m_profiles.removeFirst();
m_profiles.prepend(profile);
}
emit dataChanged(index(0, 0), index(0, COLUMNS-1), {Qt::DisplayRole}); emit dataChanged(index(0, 0), index(0, COLUMNS-1), {Qt::DisplayRole});
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment