diff --git a/Maia/BackendLib/ThemesModel.cpp b/Maia/BackendLib/ThemesModel.cpp deleted file mode 100644 index 5d53aa1..0000000 --- a/Maia/BackendLib/ThemesModel.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "ThemesModel.hpp" - - -ThemesModel::ThemesModel(QObject *parent) - : QAbstractListModel(parent) -{ - initializeThemes(); -} - -void ThemesModel::initializeThemes() -{ - themes.push_back({ "Gnome", "Gnome", false }); - themes.push_back({ "Windows XP", "Windows XP", true }); -} - -int ThemesModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return static_cast(themes.size()); -} - -QVariant ThemesModel::data(const QModelIndex &index, int role) const -{ - if (index.row() < 0 || index.row() >= themes.size()){ - return QVariant(); - } - - const Theme &theme = themes[index.row()]; - if (role == ThemeIdRole){ - return theme.themeId; - } - else if (role == ThemeNameRole){ - return theme.themeName; - } - else if (role == ThemeActiveRole){ - return theme.themeActive; - } - return QVariant(); -} - -QHash ThemesModel::roleNames() const -{ - QHash roles; - roles[ThemeIdRole] = "themeId"; - roles[ThemeNameRole] = "themeName"; - roles[ThemeActiveRole] = "themeActive"; - return roles; -} - -void ThemesModel::setActiveFrontend(const QString& frontendId) -{ - qDebug() << __PRETTY_FUNCTION__; - - for (size_t i = 0; i < themes.size(); ++i) { - if (themes[i].themeId == frontendId && !themes[i].themeActive) { - themes[i].themeActive = true; - emit dataChanged(index(static_cast(i)), index(static_cast(i)), { ThemeActiveRole }); - } else if (themes[i].themeActive) { - themes[i].themeActive = false; - emit dataChanged(index(static_cast(i)), index(static_cast(i)), { ThemeActiveRole }); - } - } -}