Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Workspace
Commits
143f946b
Commit
143f946b
authored
Mar 04, 2022
by
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
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
kcms/cursortheme/kcmcursortheme.cpp
View file @
143f946b
...
...
@@ -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
);
...
...
kcms/cursortheme/xcursor/thememodel.cpp
View file @
143f946b
...
...
@@ -28,7 +28,7 @@
#endif
CursorThemeModel
::
CursorThemeModel
(
QObject
*
parent
)
:
QAbstract
Table
Model
(
parent
)
:
QAbstract
List
Model
(
parent
)
{
insertThemes
();
}
...
...
@@ -41,7 +41,7 @@ CursorThemeModel::~CursorThemeModel()
QHash
<
int
,
QByteArray
>
CursorThemeModel
::
roleNames
()
const
{
QHash
<
int
,
QByteArray
>
roleNames
=
QAbstract
Table
Model
::
roleNames
();
QHash
<
int
,
QByteArray
>
roleNames
=
QAbstract
List
Model
::
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
)
{
...
...
kcms/cursortheme/xcursor/thememodel.h
View file @
143f946b
...
...
@@ -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
QAbstract
Table
Model
class
CursorThemeModel
:
public
QAbstract
List
Model
{
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
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment