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)
 
TableNodegetnode (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 17 of file tableselection.hpp.

Member Typedef Documentation

◆ type_datum

Member Enumeration Documentation

◆ FilterType

Enumerator
RegExpFilter 
ExactFilter 

Definition at line 30 of file tableselection.hpp.

Constructor & Destructor Documentation

◆ tableselection()

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

Definition at line 5 of file tableselection.cpp.

Member Function Documentation

◆ filterAcceptsRow()

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

Definition at line 80 of file tableselection.cpp.

82{
83 QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
84
85 if ( filterRegExp().isEmpty() )
86 {
87 return true;
88 }
89
90 switch ( Type )
91 {
93 if ( filterRegExp().indexIn ( sourceModel()->data ( index0 ).toString() ) != -1 )
94 {
95 return true;
96 }
97 else
98 {
99 return false;
100 }
101
103 return ( filterRegExp().exactMatch ( sourceModel()->data ( index0 ).toString() ) );
104
105 default:
106 return true;
107 }
108}

◆ getnode()

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

Definition at line 18 of file tableselection.cpp.

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

◆ lessThan()

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

Definition at line 110 of file tableselection.cpp.

112{
113 QVariant LeftData = sourceModel()->data ( left );
114 QVariant RightData = sourceModel()->data ( right );
115
116 switch ( LeftData.type() )
117 {
118 case QVariant::Bool:
119 case QVariant::UInt:
120 return ( LeftData.toUInt() < RightData.toUInt() );
121
122 case QVariant::Int:
123 return ( LeftData.toInt() < RightData.toInt() );
124
125 case QVariant::String:
126 {
127 const QString& l = LeftData.toString();
128 const QString& r = RightData.toString();
129
130 bool ok;
131 const double ld = l.toDouble(&ok);
132 if(ok == true) {
133 return ( ld < r.toDouble());
134 }
135
136 const qint64 lll = l.toLongLong(&ok);
137 if(ok == true) {
138 return (lll < r.toLongLong());
139 }
140
141 const quint64 lull = l.toULongLong(&ok);
142 if(ok == true) {
143 return (lull < r.toULongLong());
144 }
145
146 return ((l).compare(r) > 0);
147 }
148
149 default:
150 return false;
151 }
152
153 return true;
154}

◆ ResetModel()

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

Definition at line 74 of file tableselection.cpp.

75{
76 beginResetModel();
77 endResetModel();
78}

◆ setData()

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

Definition at line 40 of file tableselection.cpp.

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

◆ SetFilterType()

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

Definition at line 12 of file tableselection.cpp.

14{
15 Type = Filter;
16}

◆ 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 51 of file tableselection.hpp.

◆ Type

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

Definition at line 52 of file tableselection.hpp.


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