19 : QAbstractTableModel ( parent ),
30 if ( !parent.isValid() )
32 return this_structure.size();
40 if( !parent.isValid() ) {
41 return this_headers.size();
50 if ( index.isValid() )
52 TableNode * TableItem = getnode ( index );
54 if ( role == Qt::DisplayRole )
58 for ( QString
const & i : TableItem->
GetData() )
62 Data.append(i).append(space);
64 Data.remove(Data.length() - 2, 2);
66 return QVariant ( Data );
69 if ( role == Qt::ToolTipRole )
73 if ( role == Qt::FontRole )
76 return QFont (
"Helvetica", 10, -1,
79 return QFont (
"Courier", 10,
83 return QFont (
"SansSerif", 10, QFont::Bold );
87 if ( role == Qt::ForegroundRole )
101 if ( role == Qt::BackgroundRole )
104 if ( attr_node !=
nullptr ) {
105 auto val = attr_node->GetData();
106 if (val.size() == 1 &&
107 val[0].toStdString() == attr_node->GetAttribute().p_default_value) {
123 if ( !index.isValid() || role != Qt::EditRole )
128 TableNode * TableItem = getnode ( index );
130 QStringList OldDataList = TableItem->
GetData();
132 QStringList NewDataList = value.toStringList();
134 if ( NewDataList == OldDataList )
139 dref obj_desc = this_objects[index.row()];
164 if ( role == Qt::DisplayRole )
166 if ( orientation == Qt::Horizontal )
168 return this_headers.at ( section );
170 if ( orientation == Qt::Vertical )
176 if ( role == Qt::FontRole )
178 return QFont (
"Helvetica [Cronyx]", 10 );
186 if(index.isValid()) {
187 dref obj_desc = this_objects[index.row()];
192 return ( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable |
193 Qt::ItemIsDropEnabled );
197 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
202 return Qt::CopyAction;
208 types <<
"application/vnd.text.list";
214 int column,
const QModelIndex & parent )
222 if ( action == Qt::IgnoreAction )
227 if ( !data->hasFormat (
"application/vnd.text.list" ) )
233 QByteArray encodedData = data->data (
"application/vnd.text.list" );
235 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
237 QList<QStringList> newItems;
239 while ( !stream.atEnd() )
246 for (
int i = 0; i < newItems.size(); ++i )
248 if ( newItems.at ( 0 ).at ( 1 ) != newItems.at ( i ).at ( 1 ) )
256 BuildTableFromObject ( newItems );
273 setheader ( classinfo );
275 if (
treenode * NodeClass = dbaccess_guard->getnode ( cname ) )
277 std::vector<treenode *> classnodes
280 if ( include_derived )
283 for ( std::string
const & sbcname : classinfo.
p_subclasses )
285 if (
treenode * sbcnode = dbaccess_guard->getnode ( sbcname ) )
287 classnodes.push_back ( sbcnode );
295 for (
treenode * clelement : classnodes )
301 this_structure.append ( createrow ( child ) );
320 this_objects.append ( obj );
325 std::vector<dunedaq::conffwk::attribute_t>
const & attributes = cdef.
p_attributes;
326 std::vector<dunedaq::conffwk::relationship_t>
const & relations = cdef.
p_relationships;
328 assert ( attributes.size() + relations.size() < 1025 );
329 std::bitset<1024> hindex;
336 hindex.set ( column++, this_headers.contains ( QString::fromStdString ( attr.p_name ) ) );
341 hindex.set ( column++, this_headers.contains ( QString::fromStdString ( rel.p_name ) ) );
346 QList<TableNode *> Row;
348 QStringList {rownode->
GetData ( 0 ).toString()},
354 std::size_t column = 0;
361 if ( hindex[column++] )
368 values.append ( nodevalues->GetData ( 0 ).toString() );
390 for (
auto & List : this_structure )
395 this_objects.clear();
396 this_structure.clear();
397 this_headers.clear();
398 this_class_name = cname;
403 if ( !this_headers.contains (
"Object Name" ) )
405 this_headers.append (
"Object Name" );
410 if ( !this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
412 this_headers.append ( QString::fromStdString ( i.p_name ) );
418 if ( !this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
420 this_headers.append ( QString::fromStdString ( i.p_name ) );
428 reset ( BuildList.at ( 0 ).at ( 1 ) );
433 this_class_name.toStdString(),
436 setheader ( classinfo );
440 for (
const QStringList & i : BuildList )
442 QString name = i.at ( 0 );
444 this_structure.append ( createrow ( node ) );
453 return this_objects.at ( ObjectIndex ).
ref();
463 return this_class_name;
473 return &this_objects;
478 if ( Index.isValid() )
480 return this_structure.at ( Index.row() ).at ( Index.column() );
495 this->dropMimeData ( &data, action, 0, 0, dum );
500 if ( index.isValid() )
502 return this_objects[index.row()].ref();
505 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
510 if ( index.isValid() )
512 return class_type_info;
519 update_multiple_objects(objects);
528 if ( obj.class_name() == this_class_name.toStdString()
530 this_class_name.toStdString(), obj.class_name() ) )
534 handlerclass, QString::fromStdString ( obj.UID() ) );
536 if ( handlernode ==
nullptr )
538 handlernode =
new ObjectNode ( obj,
false, handlerclass );
541 emit layoutAboutToBeChanged();
546 auto sit = this_structure.begin();
547 auto it = this_objects.begin();
550 it != this_objects.end() and sit != this_structure.end()
551 and it->UID() < handlerobj.UID(); ++it, ++sit )
554 this_structure.insert ( ++sit, createrow ( handlernode ) );
556 this_objects.insert ( ++it, handlerobj );
561 emit layoutChanged();
568 if ( index.isValid() )
572 this->removeRows ( index.row(), 1, index.parent() );
574 catch ( daq::dbe::ObjectChangeWasNotSuccessful
const & err )
583 if ( index.isValid() )
585 type_datum * element = getnode ( index );
586 element->resetdata ( QStringList ( QString::fromStdString ( obj.ref().UID() ) ) );
587 this_objects[index.row()] = obj.ref();
588 emit dataChanged ( index, index );
596 if ( obj.class_name() == this_class_name.toStdString()
598 this_class_name.toStdString(), obj.class_name() ) )
601 handlerclass, QString::fromStdString ( obj.UID() ) );
605 auto sit = this_structure.begin();
606 auto it = this_objects.begin();
611 it != this_objects.end() and sit != this_structure.end()
612 and it->UID() != handlerobj.UID(); ++it, ++sit )
617 for ( TableNode * x : *sit )
623 *sit = createrow ( handlernode );
625 int row = index.row() == 0 ? 0 : index.row() - 1;
627 int column = index.column() == 0 ? 0 : index.column() - 1;
629 emit dataChanged ( createIndex ( row, column ), createIndex ( row + 1, column + 1 ) );
643 for (
int row = 0; row < this_objects.size(); ++row )
645 dref ListElement = this_objects.at ( row );
647 if ( ListElement.UID() == obj.UID() )
649 return this->index ( row, 0 );
653 return QModelIndex();
661 beginRemoveRows ( parent, row, row + count - 1 );
663 for ( ; count != 0; --count )
665 this_structure.removeOne ( this_structure.at ( row + count - 1 ) );
666 this_objects.removeAt ( row + count - 1 );
static QColor TableAttributeHighlightBackground
static QColor TableColorAttribute
Including DBE.
static QColor TableAttributeBackground
static QColor TableColorRelationship
const QVariant & get_tooltip() const
virtual QStringList GetData() const
static cptr< datahandler > gethandler()
static bool check_file_rw(const QString &FileName)
static bool derived(std::string const &fromclass, std::string const &aclass)
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
static treenode * findchild(treenode *top, QString const &name)
std::string contained_in() const
dunedaq::conffwk::ConfigObject & ref(bool check_null=true) const
static configobject::tref get(dbe::cokey const &desc)
void model_common_connections()
table(QObject *parent=nullptr)
Including QT Headers.
QList< type_datum * > createrow(treenode const *)
TableNode * getnode(const QModelIndex &Index) const
void reset(QString const &)
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, type_index const &parent) override
QList< dbe::dref > * GetTableObjects()
Qt::DropActions supportedDropActions() const override
int rowCount(type_index const &parent) const override
QStringList mimeTypes() const override
void setheader(dunedaq::conffwk::class_t const &)
QVariant data(type_index const &index, int role) const override
bool BuildTableFromObject(QList< QStringList > BuildList)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Qt::ItemFlags flags(type_index const &index) const override
bool setData(type_index const &index, const QVariant &value, int role) override
QString get_class_name() const
void slot_data_dropped(QMimeData const &, Qt::DropAction)
tref GetTableObject(int ObjectIndex) const
int columnCount(type_index const &parent) const override
bool BuildTableFromClass(const QString &ClassName, bool BuildSubClasses=false)
void objectsUpdated(const std::vector< dbe::dref > &objects)
virtual tref GetObject() const
QList< treenode * > GetChildren() const
virtual QVariant GetData(const int Column, int role=Qt::DisplayRole) const
#define MODEL_COMMON_INTERFACE_LOOKUP_IMPL(classname)
#define MODEL_REMOVE_ROWS_DEF(classname)
#define MODEL_COMMON_INTERFACE_RENAME_THAT_OBJ_IMPL(classname)
#define MODEL_COMMON_INTERFACE_UPDATE_THAT_OBJ_IMPL(classname)
#define MODEL_COMMON_INTERFACE_DELETE_THAT_OBJ_IMPL(classname)
#define MODEL_COMMON_INTERFACE_SLOTS_DEF(classname)
#define MODEL_COMMON_INTERFACE_CREATE_THAT_OBJ_IMPL(classname)
void relation(dbe::inner::configobject::tref src, dunedaq::conffwk::relationship_t const &edge, QStringList const &targets)
void attribute(dbe::inner::configobject::tref objectref, dunedaq::conffwk::attribute_t const &attribute_info, QStringList const &attribute_values)
std::string const parse(ers::Issue const &)
inner::configobject::tref tref
config_object_description dref
virtual type_class_info getclass(type_index const &index) const =0
virtual type_object_ref getobject(type_index const &index) const =0
virtual QAbstractItemModel * ReturnSourceModel() const =0
const std::vector< attribute_t > p_attributes
const std::vector< relationship_t > p_relationships
const std::vector< std::string > p_subclasses
std::string p_description