Changeset View
Changeset View
Standalone View
Standalone View
src/backend/generalTest/MyTableModel.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | File : MyTableModel.cpp | ||||
3 | Project : LabPlot | ||||
4 | Description : Derived class of QStandardItemModel | ||||
5 | -------------------------------------------------------------------- | ||||
6 | Copyright : (C) 2019 Devanshu Agarwal(agarwaldevanshu8@gmail.com) | ||||
7 | | ||||
8 | ***************************************************************************/ | ||||
9 | | ||||
10 | /*************************************************************************** | ||||
11 | * * | ||||
12 | * This program is free software; you can redistribute it and/or modify * | ||||
13 | * it under the terms of the GNU General Public License as published by * | ||||
14 | * the Free Software Foundation; either version 2 of the License, or * | ||||
15 | * (at your option) any later version. * | ||||
16 | * * | ||||
17 | * This program is distributed in the hope that it will be useful, * | ||||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
20 | * GNU General Public License for more details. * | ||||
21 | * * | ||||
22 | * You should have received a copy of the GNU General Public License * | ||||
23 | * along with this program; if not, write to the Free Software * | ||||
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, * | ||||
25 | * Boston, MA 02110-1301 USA * | ||||
26 | * * | ||||
27 | ***************************************************************************/ | ||||
28 | | ||||
29 | #include "backend/generalTest/MyTableModel.h" | ||||
30 | | ||||
31 | #include <QStandardItemModel> | ||||
32 | | ||||
33 | MyTableModel::MyTableModel(QObject* parent) : QStandardItemModel(parent) { | ||||
34 | } | ||||
35 | | ||||
36 | QVariant MyTableModel::data(const QModelIndex &index, int role) const { | ||||
37 | if (role == Qt::FontRole && (index.column() == 0 || index.row() == 0)) { | ||||
38 | QFont font; | ||||
39 | font.setBold(true); | ||||
40 | return font; | ||||
41 | } else if (role == Qt::ForegroundRole) { | ||||
42 | if (index.row() == 0) | ||||
43 | return QColor(Qt::white); | ||||
44 | if (index.column() == 0) | ||||
45 | return QColor(Qt::black); | ||||
46 | } | ||||
47 | else if (role == Qt::BackgroundRole) { | ||||
48 | if (index.row() == 0) | ||||
49 | return QColor(0x008b8b); | ||||
50 | if (index.column() == 0) | ||||
51 | return QColor(Qt::cyan); | ||||
52 | } | ||||
53 | | ||||
54 | return inherited::data(index, role); | ||||
55 | } | ||||
56 | | ||||
57 | | ||||
58 | |