File indexing completed on 2024-04-14 05:24:28

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef COLORSMODEL_H
0007 #define COLORSMODEL_H
0008 
0009 // local
0010 #include "../../lattecorona.h"
0011 #include "../../data/layoutcolordata.h"
0012 
0013 // Qt
0014 #include <QAbstractTableModel>
0015 #include <QModelIndex>
0016 
0017 
0018 namespace Latte {
0019 namespace Settings {
0020 namespace Model {
0021 
0022 class Colors : public QAbstractTableModel
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     enum ColorsRoles
0028     {
0029         IDROLE = Qt::UserRole + 1,
0030         NAMEROLE,
0031         PATHROLE,
0032         TEXTCOLORROLE
0033     };
0034 
0035     explicit Colors(QObject *parent, Latte::Corona *corona);
0036     ~Colors();
0037 
0038     int rowCount() const;
0039     int rowCount(const QModelIndex &parent) const override;
0040     int columnCount(const QModelIndex &parent) const override;
0041 
0042     int row(const QString &id);
0043 
0044     QString colorPath(const QString &color);
0045 
0046     QVariant data(const QModelIndex &index, int role) const override;
0047 
0048 private:
0049     void init();
0050     void add(const QString &newid, const QString &newname, const QString &newpath, const QString &newtextcolor);  
0051 
0052 private:
0053     QString m_colorsPath;
0054 
0055     QList<Latte::Data::LayoutColor> m_colorsTable;
0056 
0057     Latte::Corona *m_corona{nullptr};
0058 };
0059 
0060 }
0061 }
0062 }
0063 
0064 #endif