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

Member Typedef Documentation

◆ type_datum

Member Enumeration Documentation

◆ FilterType

Enumerator
RegExpFilter 
ExactFilter 

Definition at line 35 of file tableselection.hpp.

Constructor & Destructor Documentation

◆ tableselection()

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

Definition at line 10 of file tableselection.cpp.

11 : QSortFilterProxyModel ( parent ),
13{
15}

Member Function Documentation

◆ filterAcceptsRow()

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

Definition at line 85 of file tableselection.cpp.

87{
88 QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
89
90 if ( filterRegExp().isEmpty() )
91 {
92 return true;
93 }
94
95 switch ( Type )
96 {
98 if ( filterRegExp().indexIn ( sourceModel()->data ( index0 ).toString() ) != -1 )
99 {
100 return true;
101 }
102 else
103 {
104 return false;
105 }
106
108 return ( filterRegExp().exactMatch ( sourceModel()->data ( index0 ).toString() ) );
109
110 default:
111 return true;
112 }
113}

◆ getnode()

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

Definition at line 23 of file tableselection.cpp.

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

◆ lessThan()

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

Definition at line 115 of file tableselection.cpp.

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

◆ ResetModel()

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

Definition at line 79 of file tableselection.cpp.

80{
81 beginResetModel();
82 endResetModel();
83}

◆ setData()

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

Definition at line 45 of file tableselection.cpp.

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

◆ SetFilterType()

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

Definition at line 17 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 56 of file tableselection.hpp.

◆ Type

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

Definition at line 57 of file tableselection.hpp.


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