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::FontRole )
72 return QFont (
"Helvetica", 10, -1,
75 return QFont (
"Courier", 10,
79 return QFont (
"SansSerif", 10, QFont::Bold );
83 if ( role == Qt::ForegroundRole )
104 if ( !index.isValid() || role != Qt::EditRole )
109 TableNode * TableItem = getnode ( index );
111 QStringList OldDataList = TableItem->
GetData();
113 QStringList NewDataList = value.toStringList();
115 if ( NewDataList == OldDataList )
120 dref obj_desc = this_objects[index.row()];
145 if ( role == Qt::DisplayRole )
147 if ( orientation == Qt::Horizontal )
149 return this_headers.at ( section );
151 else if ( orientation == Qt::Vertical) {
152 return QString::fromStdString(this_objects.at(section).UID());
156 if ( role == Qt::FontRole )
158 return QFont (
"Helvetica [Cronyx]", 10 );
166 if(index.isValid()) {
167 dref obj_desc = this_objects[index.row()];
172 return ( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable |
173 Qt::ItemIsDropEnabled );
177 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
182 return Qt::CopyAction;
188 types <<
"application/vnd.text.list";
194 int column,
const QModelIndex & parent )
202 if ( action == Qt::IgnoreAction )
207 if ( !data->hasFormat (
"application/vnd.text.list" ) )
213 QByteArray encodedData = data->data (
"application/vnd.text.list" );
215 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
217 QList<QStringList> newItems;
219 while ( !stream.atEnd() )
226 for (
int i = 0; i < newItems.size(); ++i )
228 if ( newItems.at ( 0 ).at ( 1 ) != newItems.at ( i ).at ( 1 ) )
236 BuildTableFromObject ( newItems );
253 setheader ( classinfo );
255 if (
treenode * NodeClass = dbaccess_guard->getnode ( cname ) )
257 std::vector<treenode *> classnodes
260 if ( include_derived )
263 for ( std::string
const & sbcname : classinfo.
p_subclasses )
265 if (
treenode * sbcnode = dbaccess_guard->getnode ( sbcname ) )
267 classnodes.push_back ( sbcnode );
275 for (
treenode * clelement : classnodes )
281 this_structure.append ( createrow ( child ) );
300 this_objects.append ( obj );
305 std::vector<dunedaq::conffwk::attribute_t>
const & attributes = cdef.
p_attributes;
306 std::vector<dunedaq::conffwk::relationship_t>
const & relations = cdef.
p_relationships;
308 assert ( attributes.size() + relations.size() < 1025 );
309 std::bitset<1024> hindex;
316 hindex.set ( c++, this_headers.contains ( QString::fromStdString ( a.p_name ) ) );
321 hindex.set ( c++, this_headers.contains ( QString::fromStdString ( r.p_name ) ) );
326 QList<TableNode *> Row;
327 Row.append (
new TableNode ( QStringList ( rownode->
GetData ( 0 ).toString() ) ) );
347 values.append ( nodevalues->GetData ( 0 ).toString() );
369 for (
auto & List : this_structure )
374 this_objects.clear();
375 this_structure.clear();
376 this_headers.clear();
377 this_class_name = cname;
382 if ( !this_headers.contains (
"Object Name" ) )
384 this_headers.append (
"Object Name" );
389 if ( !this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
391 this_headers.append ( QString::fromStdString ( i.p_name ) );
397 if ( !this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
399 this_headers.append ( QString::fromStdString ( i.p_name ) );
407 reset ( BuildList.at ( 0 ).at ( 1 ) );
412 this_class_name.toStdString(),
415 setheader ( classinfo );
419 for (
const QStringList & i : BuildList )
421 QString name = i.at ( 0 );
423 this_structure.append ( createrow ( node ) );
432 return this_objects.at ( ObjectIndex ).
ref();
442 return this_class_name;
452 return &this_objects;
457 if ( Index.isValid() )
459 return this_structure.at ( Index.row() ).at ( Index.column() );
474 this->dropMimeData ( &data, action, 0, 0, dum );
479 if ( index.isValid() )
481 return this_objects[index.row()].ref();
484 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
489 if ( index.isValid() )
491 return class_type_info;
498 update_multiple_objects(objects);
506 if ( obj.class_name() == this_class_name.toStdString()
508 this_class_name.toStdString(), obj.class_name() ) )
512 handlerclass, QString::fromStdString ( obj.UID() ) );
514 if ( handlernode ==
nullptr )
516 handlernode =
new ObjectNode ( obj,
false, handlerclass );
519 emit layoutAboutToBeChanged();
524 auto sit = this_structure.begin();
525 auto it = this_objects.begin();
528 it != this_objects.end() and sit != this_structure.end()
529 and it->UID() < handlerobj.UID(); ++it, ++sit )
532 this_structure.insert ( ++sit, createrow ( handlernode ) );
534 this_objects.insert ( ++it, handlerobj );
539 emit layoutChanged();
546 if ( index.isValid() )
550 this->removeRows ( index.row(), 1, index.parent() );
552 catch ( daq::dbe::ObjectChangeWasNotSuccessful
const & err )
561 if ( index.isValid() )
563 type_datum * element = getnode ( index );
564 element->resetdata ( QStringList ( QString::fromStdString ( obj.ref().UID() ) ) );
565 this_objects[index.row()] = obj.ref();
566 emit dataChanged ( index, index );
574 if ( obj.class_name() == this_class_name.toStdString()
576 this_class_name.toStdString(), obj.class_name() ) )
579 handlerclass, QString::fromStdString ( obj.UID() ) );
583 auto sit = this_structure.begin();
584 auto it = this_objects.begin();
589 it != this_objects.end() and sit != this_structure.end()
590 and it->UID() != handlerobj.UID(); ++it, ++sit )
595 for ( TableNode * x : *sit )
601 *sit = createrow ( handlernode );
603 int r = index.row() == 0 ? 0 : index.row() - 1;
605 int c = index.column() == 0 ? 0 : index.column() - 1;
607 emit dataChanged ( createIndex ( r, c ), createIndex ( r + 1, c + 1 ) );
621 for (
int row = 0; row < this_objects.size(); ++row )
623 dref ListElement = this_objects.at ( row );
625 if ( ListElement.UID() == obj.UID() )
627 return this->index ( row, 0 );
631 return QModelIndex();
639 beginRemoveRows ( parent, row, row + count - 1 );
641 for ( ; count != 0; --count )
643 this_structure.removeOne ( this_structure.at ( row + count - 1 ) );
644 this_objects.removeAt ( row + count - 1 );
static QColor TableColorAttribute
Including DBE.
static QColor TableColorRelationship
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