24 : QAbstractTableModel ( parent ),
35 if ( !parent.isValid() )
45 if( !parent.isValid() ) {
55 if ( index.isValid() )
59 if ( role == Qt::DisplayRole )
63 for ( QString
const & i : TableItem->
GetData() )
67 Data.append(i).append(space);
69 Data.remove(Data.length() - 2, 2);
71 return QVariant ( Data );
74 if ( role == Qt::ToolTipRole )
78 if ( role == Qt::FontRole )
81 return QFont (
"Helvetica", 10, -1,
84 return QFont (
"Courier", 10,
88 return QFont (
"SansSerif", 10, QFont::Bold );
92 if ( role == Qt::ForegroundRole )
111 if ( role == Qt::BackgroundRole )
114 if ( attr_node !=
nullptr ) {
115 auto val = attr_node->GetData();
116 if (val.size() == 1 &&
117 val[0].toStdString() == attr_node->GetAttribute().p_default_value) {
142 if ( !index.isValid() || role != Qt::EditRole )
149 QStringList OldDataList = TableItem->
GetData();
151 QStringList NewDataList = value.toStringList();
153 if ( NewDataList == OldDataList )
183 if ( role == Qt::DisplayRole )
185 if ( orientation == Qt::Horizontal )
189 if ( orientation == Qt::Vertical )
195 if ( role == Qt::FontRole )
197 return QFont (
"Helvetica [Cronyx]", 10 );
205 if(index.isValid()) {
211 return ( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable |
212 Qt::ItemIsDropEnabled );
216 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
221 return Qt::CopyAction;
227 types <<
"application/vnd.text.list";
233 int column,
const QModelIndex & parent )
241 if ( action == Qt::IgnoreAction )
246 if ( !
data->hasFormat (
"application/vnd.text.list" ) )
252 QByteArray encodedData =
data->data (
"application/vnd.text.list" );
254 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
256 QList<QStringList> newItems;
258 while ( !stream.atEnd() )
265 for (
int i = 0; i < newItems.size(); ++i )
267 if ( newItems.at ( 0 ).at ( 1 ) != newItems.at ( i ).at ( 1 ) )
294 if (
treenode * NodeClass = dbaccess_guard->getnode ( cname ) )
296 std::vector<treenode *> classnodes
299 if ( include_derived )
302 for ( std::string
const & sbcname : classinfo.
p_subclasses )
304 if (
treenode * sbcnode = dbaccess_guard->getnode ( sbcname ) )
306 classnodes.push_back ( sbcnode );
314 for (
treenode * clelement : classnodes )
344 std::vector<dunedaq::conffwk::attribute_t>
const & attributes = cdef.
p_attributes;
345 std::vector<dunedaq::conffwk::relationship_t>
const & relations = cdef.
p_relationships;
347 assert ( attributes.size() + relations.size() < 1025 );
348 std::bitset<1024> hindex;
355 hindex.set ( column++,
this_headers.contains ( QString::fromStdString ( attr.p_name ) ) );
360 hindex.set ( column++,
this_headers.contains ( QString::fromStdString ( rel.p_name ) ) );
365 QList<TableNode *> Row;
367 QStringList {rownode->
GetData ( 0 ).toString()},
373 std::size_t column = 0;
380 if ( hindex[column++] )
387 values.append ( nodevalues->GetData ( 0 ).toString() );
429 if ( !
this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
431 this_headers.append ( QString::fromStdString ( i.p_name ) );
437 if ( !
this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
439 this_headers.append ( QString::fromStdString ( i.p_name ) );
447 reset ( BuildList.at ( 0 ).at ( 1 ) );
459 for (
const QStringList & i : BuildList )
461 QString name = i.at ( 0 );
497 if ( Index.isValid() )
519 if ( index.isValid() )
521 return this_objects[index.row()].ref();
524 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
529 if ( index.isValid() )
531 return class_type_info;
534 return dunedaq::conffwk::class_t();
547 if ( obj.class_name() == this_class_name.toStdString()
549 this_class_name.toStdString(), obj.class_name() ) )
553 handlerclass, QString::fromStdString ( obj.UID() ) );
555 if ( handlernode ==
nullptr )
557 handlernode =
new ObjectNode ( obj,
false, handlerclass );
560 emit layoutAboutToBeChanged();
565 auto sit = this_structure.begin();
566 auto it = this_objects.begin();
569 it != this_objects.end() and sit != this_structure.end()
570 and it->UID() < handlerobj.UID(); ++it, ++sit )
573 this_structure.insert ( ++sit, createrow ( handlernode ) );
575 this_objects.insert ( ++it, handlerobj );
580 emit layoutChanged();
587 if ( index.isValid() )
591 this->removeRows ( index.row(), 1, index.parent() );
593 catch ( daq::dbe::ObjectChangeWasNotSuccessful
const & err )
602 if ( index.isValid() )
604 type_datum * element = getnode ( index );
605 element->resetdata ( QStringList ( QString::fromStdString ( obj.ref().UID() ) ) );
606 this_objects[index.row()] = obj.ref();
607 emit dataChanged ( index, index );
615 if ( obj.class_name() == this_class_name.toStdString()
617 this_class_name.toStdString(), obj.class_name() ) )
620 handlerclass, QString::fromStdString ( obj.UID() ) );
624 auto sit = this_structure.begin();
625 auto it = this_objects.begin();
630 it != this_objects.end() and sit != this_structure.end()
631 and it->UID() != handlerobj.UID(); ++it, ++sit )
636 for ( TableNode * x : *sit )
642 *sit = createrow ( handlernode );
644 int row = index.row() == 0 ? 0 : index.row() - 1;
646 int column = index.column() == 0 ? 0 : index.column() - 1;
648 emit dataChanged ( createIndex ( row, column ), createIndex ( row + 1, column + 1 ) );
662 for (
int row = 0; row < this_objects.size(); ++row )
664 dref ListElement = this_objects.at ( row );
666 if ( ListElement.UID() == obj.UID() )
668 return this->index ( row, 0 );
672 return QModelIndex();
680 beginRemoveRows ( parent, row, row + count - 1 );
682 for ( ; count != 0; --count )
684 this_structure.removeOne ( this_structure.at ( row + count - 1 ) );
685 this_objects.removeAt ( row + count - 1 );
static QColor TableRelationshipBackground
static QColor FileReadOnlyForeground
static QColor TableColorAttribute
Including DBE.
static QColor TableAttributeBackground
static QColor DefaultValueBackground
static QColor TableColorRelationship
static QColor FileReadOnlyBackground
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
static configobject::tref get(dbe::cokey const &desc)
void update_multiple_objects(std::vector< type_object_info > const &)
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)
QList< dref > this_objects
void objectsUpdated(const std::vector< dbe::dref > &objects)
QList< QList< TableNode * > > this_structure
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