MauiKit Terminal

colorschemesmodel.cpp
1#include "colorschemesmodel.h"
2#include "lib/tools.h"
3#include "lib/ColorScheme.h"
4#include <QDebug>
5
6ColorSchemesModel::ColorSchemesModel(QObject *parent) : QAbstractListModel(parent)
7{
8
9}
10
11void ColorSchemesModel::classBegin()
12{
13}
14
15void ColorSchemesModel::componentComplete()
16{
17 this->setList();
18}
19
20void ColorSchemesModel::setList()
21{
22 m_list.clear();
23
25
27
28 m_list = manager->allColorSchemes();
29
30// qDebug() << "SETTING CS MODEL" << m_list;
31
33}
34
35
36int ColorSchemesModel::rowCount(const QModelIndex &parent) const
37{
38 if (parent.isValid())
39 {
40 return 0;
41 }
42
43 return m_list.count();
44}
45
46QVariant ColorSchemesModel::data(const QModelIndex &index, int role) const
47{
48 if (!index.isValid())
49 return QVariant();
50
51 auto item = m_list[index.row()];
52
53 switch(role)
54 {
55 case Role::Name: return item->name();
56 case Role::Background: return item->backgroundColor();
57 case Role::Foreground: return item->foregroundColor();
58 case Role::Highlight: return item->colorEntry(2).color;
59 case Role::Color3: return item->colorEntry(3).color;
60 case Role::Color4: return item->colorEntry(4).color;
61 case Role::Description: return item->description();
62 default: return QVariant();
63 }
64}
65
66QHash<int, QByteArray> ColorSchemesModel::roleNames() const
67{
68 return {{Role::Name, "name"},
69 {Role::Background, "background"},
70 {Role::Foreground, "foreground"},
71 {Role::Highlight, "highlight"},
72 {Role::Color3, "color3"},
73 {Role::Color4, "color4"},
74 {Role::Description, "description"}};
75}
static ColorSchemeManager * instance()
Returns the global color scheme manager instance.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
void clear()
qsizetype count() const const
bool isValid() const const
int row() const const
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:55:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.