Warning, file /plasma/plasma-workspace/kcms/colors/colorsmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2007 Jeremy Whiting <jpwhiting@kde.org>
0004     SPDX-FileCopyrightText: 2016 Olivier Churlaud <olivier@churlaud.com>
0005     SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de>
0006 
0007     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0008 */
0009 
0010 #pragma once
0011 
0012 #include <QAbstractListModel>
0013 #include <QPalette>
0014 #include <QString>
0015 #include <QVector>
0016 
0017 struct ColorsModelData {
0018     QString display;
0019     QString schemeName;
0020     QPalette palette;
0021     QColor activeTitleBarBackground;
0022     QColor activeTitleBarForeground;
0023     bool removable;
0024     bool accentActiveTitlebar;
0025     bool pendingDeletion;
0026     bool tints;
0027     qreal tintFactor;
0028 };
0029 Q_DECLARE_TYPEINFO(ColorsModelData, Q_MOVABLE_TYPE);
0030 
0031 class ColorsModel : public QAbstractListModel
0032 {
0033     Q_OBJECT
0034 
0035     Q_PROPERTY(QString selectedScheme READ selectedScheme WRITE setSelectedScheme NOTIFY selectedSchemeChanged)
0036     Q_PROPERTY(int selectedSchemeIndex READ selectedSchemeIndex NOTIFY selectedSchemeIndexChanged)
0037 
0038 public:
0039     ColorsModel(QObject *parent);
0040     ~ColorsModel() override;
0041 
0042     enum Roles {
0043         SchemeNameRole = Qt::UserRole + 1,
0044         PaletteRole,
0045         // Colors which aren't in QPalette
0046         ActiveTitleBarBackgroundRole,
0047         ActiveTitleBarForegroundRole,
0048         DisabledText,
0049         RemovableRole,
0050         AccentActiveTitlebarRole,
0051         PendingDeletionRole,
0052         Tints,
0053         TintFactor,
0054     };
0055 
0056     int rowCount(const QModelIndex &parent) const override;
0057     QVariant data(const QModelIndex &index, int role) const override;
0058     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0059     QHash<int, QByteArray> roleNames() const override;
0060 
0061     QString selectedScheme() const;
0062     void setSelectedScheme(const QString &scheme);
0063 
0064     int indexOfScheme(const QString &scheme) const;
0065     int selectedSchemeIndex() const;
0066 
0067     QStringList pendingDeletions() const;
0068     void removeItemsPendingDeletion();
0069 
0070     void load();
0071 
0072 Q_SIGNALS:
0073     void selectedSchemeChanged(const QString &scheme);
0074     void selectedSchemeIndexChanged();
0075 
0076     void pendingDeletionsChanged();
0077 
0078 private:
0079     QString m_selectedScheme;
0080 
0081     QVector<ColorsModelData> m_data;
0082 };