DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::models::tableselection Class Reference

#include <tableselection.hpp>

Inheritance diagram for dbe::models::tableselection:
[legend]
Collaboration diagram for dbe::models::tableselection:
[legend]

Public Types

enum  FilterType { RegExpFilter = 1 , ExactFilter = 2 }
typedef TableNode type_datum

Public Member Functions

 tableselection (QObject *parent=0)
void SetFilterType (FilterType Filter)
TableNode * getnode (const QModelIndex &index) const
bool setData (const QModelIndex &index, const QVariant &value, int role)
void ResetModel ()
Public Member Functions inherited from dbe::model_common_impl< tableselection >
bool delete_objects (type_indices::iterator, type_indices::iterator) override
bool update_objects (type_indices::iterator, type_indices::iterator) override
bool create_objects (type_indices::iterator, type_indices::iterator) override
Public Member Functions inherited from dbe::model_common_interface
virtual ~model_common_interface ()=default
Public Member Functions inherited from dbe::model_initiate_actions_interface
virtual ~model_initiate_actions_interface ()=default
Public Member Functions inherited from dbe::model_common_data_access_interface
virtual type_object_ref getobject (type_index const &index) const =0
virtual type_class_info getclass (type_index const &index) const =0
virtual QAbstractItemModel * ReturnSourceModel () const =0
virtual ~model_common_data_access_interface ()=default
Public Member Functions inherited from dbe::model_common_async_operations< tableselection >
MODEL_COMMON_TYPES_TOPLEVEL_DEFINITIONS model_common_async_operations ()
void model_common_connections ()

Protected Member Functions

bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const
bool lessThan (const QModelIndex &left, const QModelIndex &right) const
Protected Member Functions inherited from dbe::model_common_interface
virtual void remove_deleted_object (type_index const &index)=0
virtual void rename_contained_object (type_index const &index, type_object_info const &obj)=0
virtual void update_contained_object (type_index const &index, type_object_info const &obj)=0
virtual void create_contained_object (type_index const &index, type_object_info const &obj)=0
virtual type_index lookup (type_object_info const &)=0
QUuid getuuid () const
Protected Member Functions inherited from dbe::model_common_async_operations< tableselection >
void remove_object (type_object_info const &)
void create_object (type_object_info const &)
void rename_object (type_object_info const &)
void update_object (type_object_info const &)
void update_multiple_objects (std::vector< type_object_info > const &)

Private Slots

void slot_create_object (QString const &src, dref const &obj)
void slot_remove_object (QString const &src, dref const &obj)
void slot_update_object (QString const &src, dref const &obj)
void slot_rename_object (QString const &src, dref const &obj)

Private Attributes

QVariant LastSavedValue
FilterType Type

Detailed Description

Definition at line 20 of file tableselection.hpp.

Member Typedef Documentation

◆ type_datum

Member Enumeration Documentation

◆ FilterType

Enumerator
RegExpFilter 
ExactFilter 

Definition at line 32 of file tableselection.hpp.

Constructor & Destructor Documentation

◆ tableselection()

dbe::models::tableselection::tableselection ( QObject * parent = 0)

Definition at line 10 of file tableselection.cpp.

Member Function Documentation

◆ filterAcceptsRow()

bool dbe::models::tableselection::filterAcceptsRow ( int sourceRow,
const QModelIndex & sourceParent ) const
protected

Definition at line 75 of file tableselection.cpp.

76{
77 QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
78
79 if (filterRegExp().isEmpty()) {
80 return true;
81 }
82
83 switch (Type) {
85 if (filterRegExp().indexIn(sourceModel()->data(index0).toString()) != -1) {
86 return true;
87 } else {
88 return false;
89 }
90
92 return (filterRegExp().exactMatch(sourceModel()->data(index0).toString()));
93
94 default:
95 return true;
96 }
97}

◆ getnode()

dbe::TableNode * dbe::models::tableselection::getnode ( const QModelIndex & index) const

Definition at line 24 of file tableselection.cpp.

25{
26 if (index.isValid()) {
27 QModelIndex sourceParent = mapToSource(index);
28 dbe::models::table* my = dynamic_cast<dbe::models::table*>(sourceModel());
29
30 if (my != 0) {
31 return my->getnode(sourceParent);
32 } else {
33 return nullptr;
34 }
35 } else {
36 return nullptr;
37 }
38}
TableNode * getnode(const QModelIndex &Index) const
Definition table.cpp:442

◆ lessThan()

bool dbe::models::tableselection::lessThan ( const QModelIndex & left,
const QModelIndex & right ) const
protected

Definition at line 100 of file tableselection.cpp.

101{
102 QVariant LeftData = sourceModel()->data(left);
103 QVariant RightData = sourceModel()->data(right);
104
105 switch (LeftData.type()) {
106 case QVariant::Bool:
107 case QVariant::UInt:
108 return (LeftData.toUInt() < RightData.toUInt());
109
110 case QVariant::Int:
111 return (LeftData.toInt() < RightData.toInt());
112
113 case QVariant::String: {
114 const QString& l = LeftData.toString();
115 const QString& r = RightData.toString();
116
117 bool ok;
118 const double ld = l.toDouble(&ok);
119 if (ok == true) {
120 return (ld < r.toDouble());
121 }
122
123 const qint64 lll = l.toLongLong(&ok);
124 if (ok == true) {
125 return (lll < r.toLongLong());
126 }
127
128 const quint64 lull = l.toULongLong(&ok);
129 if (ok == true) {
130 return (lull < r.toULongLong());
131 }
132
133 return ((l).compare(r) > 0);
134 }
135
136 default:
137 return false;
138 }
139
140 return true;
141}

◆ ResetModel()

void dbe::models::tableselection::ResetModel ( )

Definition at line 68 of file tableselection.cpp.

69{
70 beginResetModel();
71 endResetModel();
72}

◆ setData()

bool dbe::models::tableselection::setData ( const QModelIndex & index,
const QVariant & value,
int role )

Definition at line 41 of file tableselection.cpp.

42{
43 if (index.isValid()) {
44 QModelIndex sourceParent;
45
46 int idx_row = index.row();
47 int idx_col = index.column();
48
49 try {
50 QModelIndex idx_index = this->index(idx_row, idx_col);
51 sourceParent = mapToSource(idx_index);
52 } catch (std::exception const& stderr) {
53 WARN("Error setting data", stderr.what());
54 return true;
55 }
56
57 bool success = sourceModel()->setData(sourceParent, value, role);
58 QModelIndex idx_index = this->index(idx_row, idx_col);
59 emit dataChanged(idx_index, idx_index);
60
61 return success;
62 } else {
63 return true;
64 }
65}
#define WARN(...)
Definition messenger.hpp:82

◆ SetFilterType()

void dbe::models::tableselection::SetFilterType ( FilterType Filter)

Definition at line 18 of file tableselection.cpp.

19{
20 Type = Filter;
21}

◆ slot_create_object

void dbe::models::tableselection::slot_create_object ( QString const & src,
dref const & obj )
privateslot

◆ slot_remove_object

void dbe::models::tableselection::slot_remove_object ( QString const & src,
dref const & obj )
privateslot

◆ slot_rename_object

void dbe::models::tableselection::slot_rename_object ( QString const & src,
dref const & obj )
privateslot

◆ slot_update_object

void dbe::models::tableselection::slot_update_object ( QString const & src,
dref const & obj )
privateslot

Member Data Documentation

◆ LastSavedValue

QVariant dbe::models::tableselection::LastSavedValue
private

Definition at line 54 of file tableselection.hpp.

◆ Type

FilterType dbe::models::tableselection::Type
private

Definition at line 55 of file tableselection.hpp.


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