QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
freeterminalmodel.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef FREETERMINALMODEL_H
19#define FREETERMINALMODEL_H
20
21#include <QAbstractTableModel>
22#include <QPointer>
23#include <QStyledItemDelegate>
24
25#include "modelTerminalData.h"
26#include "../../qetproject.h"
27
28class RealTerminal;
29
33class FreeTerminalModel : public QAbstractTableModel
34{
35 public:
36 enum Column {
37 Label = 0,
38 XRef = 1,
39 Type = 2,
41 Led = 4,
42 Invalid = 99
43 };
44
45 static FreeTerminalModel::Column columnTypeForIndex(const QModelIndex &index);
46 Q_OBJECT
47
48 public:
49 explicit FreeTerminalModel(QETProject *project, QObject *parent = nullptr);
50
51 int rowCount(const QModelIndex &parent) const override;
52 int columnCount(const QModelIndex &parent) const override;
53 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
54 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
55 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
56 Qt::ItemFlags flags(const QModelIndex &index) const override;
57
58 void clear();
59 QVector<modelRealTerminalData> modifiedModelRealTerminalData() const;
60 modelRealTerminalData dataAtRow(int row) const;
61 QVector<QSharedPointer<RealTerminal>> realTerminalForIndex(const QModelIndexList &index_list) const;
62
63 private:
64 void fillTerminalVector();
65
66 private:
67 QPointer<QETProject> m_project;
68 QVector<QSharedPointer<RealTerminal>> m_terminal_vector;
69 QVector<modelRealTerminalData> m_real_t_data;
70 QHash<QSharedPointer<RealTerminal>, QVector<bool>> m_modified_cell;
71};
72
73class FreeTerminalModelDelegate : public QStyledItemDelegate
74{
75 Q_OBJECT
76
77 public:
78 FreeTerminalModelDelegate(QObject *parent = nullptr);
79
80 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
81 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
82};
83
84#endif // FREETERMINALMODEL_H
Definition freeterminalmodel.h:74
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Definition freeterminalmodel.cpp:358
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition freeterminalmodel.cpp:332
The FreeTerminalModel class.
Definition freeterminalmodel.h:34
void fillTerminalVector()
FreeTerminalModel::fillTerminalVector.
Definition freeterminalmodel.cpp:306
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
FreeTerminalModel::headerData.
Definition freeterminalmodel.cpp:200
QVector< modelRealTerminalData > m_real_t_data
Definition freeterminalmodel.h:69
QVector< modelRealTerminalData > modifiedModelRealTerminalData() const
FreeTerminalModel::modifiedModelRealTerminalData.
Definition freeterminalmodel.cpp:252
modelRealTerminalData dataAtRow(int row) const
FreeTerminalModel::dataAtRow.
Definition freeterminalmodel.cpp:270
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
FreeTerminalModel::data.
Definition freeterminalmodel.cpp:92
QHash< QSharedPointer< RealTerminal >, QVector< bool > > m_modified_cell
Definition freeterminalmodel.h:70
static FreeTerminalModel::Column columnTypeForIndex(const QModelIndex &index)
Definition freeterminalmodel.cpp:37
QVector< QSharedPointer< RealTerminal > > realTerminalForIndex(const QModelIndexList &index_list) const
FreeTerminalModel::realTerminalForIndex.
Definition freeterminalmodel.cpp:284
Column
Definition freeterminalmodel.h:36
@ Type
Definition freeterminalmodel.h:39
@ Led
Definition freeterminalmodel.h:41
@ Invalid
Definition freeterminalmodel.h:42
@ Label
Definition freeterminalmodel.h:37
@ Function
Definition freeterminalmodel.h:40
@ XRef
Definition freeterminalmodel.h:38
QPointer< QETProject > m_project
Definition freeterminalmodel.h:67
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition freeterminalmodel.cpp:220
int columnCount(const QModelIndex &parent) const override
FreeTerminalModel::columnCount.
Definition freeterminalmodel.cpp:80
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition freeterminalmodel.cpp:135
QVector< QSharedPointer< RealTerminal > > m_terminal_vector
Definition freeterminalmodel.h:68
void clear()
FreeTerminalModel::clear Clear the model and set it as the current state of the project.
Definition freeterminalmodel.cpp:238
int rowCount(const QModelIndex &parent) const override
FreeTerminalModel::rowCount.
Definition freeterminalmodel.cpp:69
Definition qetproject.h:62
The RealTerminal class Represent a real terminal. A real terminal can be a drawn terminal in a folio ...
Definition realterminal.h:43
Definition modelTerminalData.h:26