diff --git a/kcms/cursortheme/kcmcursortheme.cpp b/kcms/cursortheme/kcmcursortheme.cpp index aa7bdc2c3..f845a2dea 100644 --- a/kcms/cursortheme/kcmcursortheme.cpp +++ b/kcms/cursortheme/kcmcursortheme.cpp @@ -67,7 +67,7 @@ CursorThemeConfig::CursorThemeConfig(QObject *parent, const KPluginMetaData &dat m_themeProxyModel->setSourceModel(m_themeModel); // sort ordering is already case-insensitive; match that for filtering too m_themeProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - m_themeProxyModel->sort(NameColumn, Qt::AscendingOrder); + m_themeProxyModel->sort(0, Qt::AscendingOrder); m_sizesModel = new QStandardItemModel(this); diff --git a/kcms/cursortheme/xcursor/thememodel.cpp b/kcms/cursortheme/xcursor/thememodel.cpp index 6e6af57b1..288a91c58 100644 --- a/kcms/cursortheme/xcursor/thememodel.cpp +++ b/kcms/cursortheme/xcursor/thememodel.cpp @@ -28,7 +28,7 @@ #endif CursorThemeModel::CursorThemeModel(QObject *parent) - : QAbstractTableModel(parent) + : QAbstractListModel(parent) { insertThemes(); } @@ -41,7 +41,7 @@ CursorThemeModel::~CursorThemeModel() QHash CursorThemeModel::roleNames() const { - QHash roleNames = QAbstractTableModel::roleNames(); + QHash roleNames = QAbstractListModel::roleNames(); roleNames[CursorTheme::DisplayDetailRole] = "description"; roleNames[CursorTheme::IsWritableRole] = "isWritable"; roleNames[CursorTheme::PendingDeletionRole] = "pendingDeletion"; @@ -59,30 +59,6 @@ void CursorThemeModel::refreshList() insertThemes(); } -QVariant CursorThemeModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - // Only provide text for the headers - if (role != Qt::DisplayRole) - return QVariant(); - - // Horizontal header labels - if (orientation == Qt::Horizontal) { - switch (section) { - case NameColumn: - return i18n("Name"); - - case DescColumn: - return i18n("Description"); - - default: - return QVariant(); - } - } - - // Numbered vertical header labels - return QString::number(section); -} - QVariant CursorThemeModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() < 0 || index.row() >= list.count()) @@ -92,24 +68,15 @@ QVariant CursorThemeModel::data(const QModelIndex &index, int role) const // Text label if (role == Qt::DisplayRole) { - switch (index.column()) { - case NameColumn: - return theme->title(); - - case DescColumn: - return theme->description(); - - default: - return QVariant(); - } + return theme->title(); } // Description for the first name column - if (role == CursorTheme::DisplayDetailRole && index.column() == NameColumn) + if (role == CursorTheme::DisplayDetailRole) return theme->description(); // Icon for the name column - if (role == Qt::DecorationRole && index.column() == NameColumn) + if (role == Qt::DecorationRole) return theme->icon(); if (role == CursorTheme::IsWritableRole) { diff --git a/kcms/cursortheme/xcursor/thememodel.h b/kcms/cursortheme/xcursor/thememodel.h index 292c50c5f..d3b3929c1 100644 --- a/kcms/cursortheme/xcursor/thememodel.h +++ b/kcms/cursortheme/xcursor/thememodel.h @@ -12,12 +12,6 @@ class QDir; class CursorTheme; -// The two TableView/TreeView columns provided by the model -enum Columns { - NameColumn = 0, - DescColumn, -}; - /** * The CursorThemeModel class provides a model for all locally installed * Xcursor themes, and the KDE/Qt legacy bitmap theme. @@ -43,7 +37,7 @@ enum Columns { * Calling defaultIndex() will return the index of the theme Xcursor * will use if the user hasn't explicitly configured a cursor theme. */ -class CursorThemeModel : public QAbstractTableModel +class CursorThemeModel : public QAbstractListModel { Q_OBJECT @@ -51,9 +45,7 @@ public: explicit CursorThemeModel(QObject *parent = nullptr); ~CursorThemeModel() override; QHash roleNames() const override; - inline int columnCount(const QModelIndex &parent = QModelIndex()) const override; inline int rowCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant data(const QModelIndex &index, int role) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; @@ -96,8 +88,3 @@ int CursorThemeModel::rowCount(const QModelIndex &) const { return list.count(); } - -int CursorThemeModel::columnCount(const QModelIndex &) const -{ - return 2; -}