DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbse::CustomTableModel Class Reference

#include <SchemaCustomTableModel.hpp>

Inheritance diagram for dbse::CustomTableModel:
[legend]
Collaboration diagram for dbse::CustomTableModel:
[legend]

Public Member Functions

 CustomTableModel (QStringList Headers, QObject *parent=nullptr)
 
 ~CustomTableModel ()
 
int rowCount (const QModelIndex &parent) const
 
int columnCount (const QModelIndex &parent) const
 
Qt::ItemFlags flags (const QModelIndex &index) const
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 
QVariant data (const QModelIndex &index, int role) const
 
QStringList getRowFromIndex (QModelIndex &index)
 
void setupModel ()
 
QStringList mimeTypes () const
 Drag/Drop Handlers.
 
QMimeData * mimeData (const QModelIndexList &indexes) const
 

Private Attributes

QStringList HeaderList
 
QList< QList< QString > > Data
 

Detailed Description

Definition at line 12 of file SchemaCustomTableModel.hpp.

Constructor & Destructor Documentation

◆ CustomTableModel()

dbse::CustomTableModel::CustomTableModel ( QStringList Headers,
QObject * parent = nullptr )
explicit

Definition at line 8 of file SchemaCustomTableModel.cpp.

9 : QAbstractTableModel ( parent ),
10 HeaderList ( Headers )
11{
12 setupModel();
13}

◆ ~CustomTableModel()

dbse::CustomTableModel::~CustomTableModel ( )

Definition at line 15 of file SchemaCustomTableModel.cpp.

16{
17}

Member Function Documentation

◆ columnCount()

int dbse::CustomTableModel::columnCount ( const QModelIndex & parent) const

Definition at line 25 of file SchemaCustomTableModel.cpp.

26{
27 Q_UNUSED ( parent )
28 return HeaderList.size();
29}

◆ data()

QVariant dbse::CustomTableModel::data ( const QModelIndex & index,
int role ) const

Definition at line 53 of file SchemaCustomTableModel.cpp.

54{
55 if ( role != Qt::DisplayRole )
56 {
57 return QVariant();
58 }
59
60 return Data.value ( index.row() ).value ( index.column() );
61}
QList< QList< QString > > Data

◆ flags()

Qt::ItemFlags dbse::CustomTableModel::flags ( const QModelIndex & index) const

Definition at line 31 of file SchemaCustomTableModel.cpp.

32{
33 Q_UNUSED ( index )
34 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
35}

◆ getRowFromIndex()

QStringList dbse::CustomTableModel::getRowFromIndex ( QModelIndex & index)

Definition at line 63 of file SchemaCustomTableModel.cpp.

64{
65 if ( !index.isValid() )
66 {
67 return QStringList();
68 }
69
70 return Data.at ( index.row() );
71}

◆ headerData()

QVariant dbse::CustomTableModel::headerData ( int section,
Qt::Orientation orientation,
int role ) const

Definition at line 37 of file SchemaCustomTableModel.cpp.

39{
40 if ( role != Qt::DisplayRole )
41 {
42 return QVariant();
43 }
44
45 if ( orientation == Qt::Horizontal )
46 {
47 return HeaderList.at ( section );
48 }
49
50 return QVariant();
51}

◆ mimeData()

QMimeData * dbse::CustomTableModel::mimeData ( const QModelIndexList & indexes) const

Definition at line 94 of file SchemaCustomTableModel.cpp.

95{
96 QMimeData * mimeData = new QMimeData();
97 QByteArray encodedData;
98
99 QDataStream stream ( &encodedData, QIODevice::WriteOnly );
100
101 foreach ( QModelIndex index, indexes )
102 {
103 if ( index.isValid() && index.column() == 0 )
104 {
105 QString ClassName = data ( index, Qt::DisplayRole ).toString();
106 stream << ClassName;
107 }
108 }
109
110 mimeData->setData ( "application/vnd.text.list", encodedData );
111 return mimeData;
112}
QMimeData * mimeData(const QModelIndexList &indexes) const
QVariant data(const QModelIndex &index, int role) const

◆ mimeTypes()

QStringList dbse::CustomTableModel::mimeTypes ( ) const

Drag/Drop Handlers.

Definition at line 87 of file SchemaCustomTableModel.cpp.

88{
89 QStringList types;
90 types << "application/vnd.text.list";
91 return types;
92}

◆ rowCount()

int dbse::CustomTableModel::rowCount ( const QModelIndex & parent) const

Definition at line 19 of file SchemaCustomTableModel.cpp.

20{
21 Q_UNUSED ( parent )
22 return Data.size();
23}

◆ setupModel()

void dbse::CustomTableModel::setupModel ( )

Definition at line 73 of file SchemaCustomTableModel.cpp.

74{
75 std::vector<OksClass *> ClassList;
77
78 for ( unsigned int i = 0; i < ClassList.size(); ++i )
79 {
80 QList<QString> Row;
81 OksClass * Class = ClassList.at ( i );
82 Row.append ( QString ( Class->get_name().c_str() ) );
83 Data.append ( Row );
84 }
85}
static KernelWrapper & GetInstance()
void GetClassList(std::vector< dunedaq::oks::OksClass * > &ClassList) const
The OKS class.
Definition class.hpp:200
const std::string & get_name() const noexcept
Definition class.hpp:363

Member Data Documentation

◆ Data

QList<QList<QString> > dbse::CustomTableModel::Data
private

Definition at line 30 of file SchemaCustomTableModel.hpp.

◆ HeaderList

QStringList dbse::CustomTableModel::HeaderList
private

Definition at line 29 of file SchemaCustomTableModel.hpp.


The documentation for this class was generated from the following files: