Commit 143f946b authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[kcms/cursor] Untabelify model

We don't need a table model here, a list model is enough
parent 628f7d7c
Pipeline #150882 passed with stage
in 11 minutes and 45 seconds
......@@ -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);
......
......@@ -28,7 +28,7 @@
#endif
CursorThemeModel::CursorThemeModel(QObject *parent)
: QAbstractTableModel(parent)
: QAbstractListModel(parent)
{
insertThemes();
}
......@@ -41,7 +41,7 @@ CursorThemeModel::~CursorThemeModel()
QHash<int, QByteArray> CursorThemeModel::roleNames() const
{
QHash<int, QByteArray> roleNames = QAbstractTableModel::roleNames();
QHash<int, QByteArray> 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) {
......
......@@ -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<int, QByteArray> 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;
}
Supports Markdown
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