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 )
106 if ( role == Qt::BackgroundRole )
109 if ( attr_node !=
nullptr ) {
110 auto val = attr_node->GetData();
111 if (val.size() == 1 &&
112 val[0].toStdString() == attr_node->GetAttribute().p_default_value) {
128 if ( !index.isValid() || role != Qt::EditRole )
135 QStringList OldDataList = TableItem->
GetData();
137 QStringList NewDataList = value.toStringList();
139 if ( NewDataList == OldDataList )
169 if ( role == Qt::DisplayRole )
171 if ( orientation == Qt::Horizontal )
175 if ( orientation == Qt::Vertical )
181 if ( role == Qt::FontRole )
183 return QFont (
"Helvetica [Cronyx]", 10 );
191 if(index.isValid()) {
197 return ( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable |
198 Qt::ItemIsDropEnabled );
202 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
207 return Qt::CopyAction;
213 types <<
"application/vnd.text.list";
219 int column,
const QModelIndex & parent )
227 if ( action == Qt::IgnoreAction )
232 if ( !
data->hasFormat (
"application/vnd.text.list" ) )
238 QByteArray encodedData =
data->data (
"application/vnd.text.list" );
240 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
242 QList<QStringList> newItems;
244 while ( !stream.atEnd() )
251 for (
int i = 0; i < newItems.size(); ++i )
253 if ( newItems.at ( 0 ).at ( 1 ) != newItems.at ( i ).at ( 1 ) )
280 if (
treenode * NodeClass = dbaccess_guard->getnode ( cname ) )
282 std::vector<treenode *> classnodes
285 if ( include_derived )
288 for ( std::string
const & sbcname : classinfo.
p_subclasses )
290 if (
treenode * sbcnode = dbaccess_guard->getnode ( sbcname ) )
292 classnodes.push_back ( sbcnode );
300 for (
treenode * clelement : classnodes )
330 std::vector<dunedaq::conffwk::attribute_t>
const & attributes = cdef.
p_attributes;
331 std::vector<dunedaq::conffwk::relationship_t>
const & relations = cdef.
p_relationships;
333 assert ( attributes.size() + relations.size() < 1025 );
334 std::bitset<1024> hindex;
341 hindex.set ( column++,
this_headers.contains ( QString::fromStdString ( attr.p_name ) ) );
346 hindex.set ( column++,
this_headers.contains ( QString::fromStdString ( rel.p_name ) ) );
351 QList<TableNode *> Row;
353 QStringList {rownode->
GetData ( 0 ).toString()},
359 std::size_t column = 0;
366 if ( hindex[column++] )
373 values.append ( nodevalues->GetData ( 0 ).toString() );
415 if ( !
this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
417 this_headers.append ( QString::fromStdString ( i.p_name ) );
423 if ( !
this_headers.contains ( QString::fromStdString ( i.p_name ) ) )
425 this_headers.append ( QString::fromStdString ( i.p_name ) );
433 reset ( BuildList.at ( 0 ).at ( 1 ) );
445 for (
const QStringList & i : BuildList )
447 QString name = i.at ( 0 );
483 if ( Index.isValid() )
505 if ( index.isValid() )
507 return this_objects[index.row()].ref();
510 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
515 if ( index.isValid() )
517 return class_type_info;
520 return dunedaq::conffwk::class_t();
533 if ( obj.class_name() == this_class_name.toStdString()
535 this_class_name.toStdString(), obj.class_name() ) )
539 handlerclass, QString::fromStdString ( obj.UID() ) );
541 if ( handlernode ==
nullptr )
543 handlernode =
new ObjectNode ( obj,
false, handlerclass );
546 emit layoutAboutToBeChanged();
551 auto sit = this_structure.begin();
552 auto it = this_objects.begin();
555 it != this_objects.end() and sit != this_structure.end()
556 and it->UID() < handlerobj.UID(); ++it, ++sit )
559 this_structure.insert ( ++sit, createrow ( handlernode ) );
561 this_objects.insert ( ++it, handlerobj );
566 emit layoutChanged();
573 if ( index.isValid() )
577 this->removeRows ( index.row(), 1, index.parent() );
579 catch ( daq::dbe::ObjectChangeWasNotSuccessful
const & err )
588 if ( index.isValid() )
590 type_datum * element = getnode ( index );
591 element->resetdata ( QStringList ( QString::fromStdString ( obj.ref().UID() ) ) );
592 this_objects[index.row()] = obj.ref();
593 emit dataChanged ( index, index );
601 if ( obj.class_name() == this_class_name.toStdString()
603 this_class_name.toStdString(), obj.class_name() ) )
606 handlerclass, QString::fromStdString ( obj.UID() ) );
610 auto sit = this_structure.begin();
611 auto it = this_objects.begin();
616 it != this_objects.end() and sit != this_structure.end()
617 and it->UID() != handlerobj.UID(); ++it, ++sit )
622 for ( TableNode * x : *sit )
628 *sit = createrow ( handlernode );
630 int row = index.row() == 0 ? 0 : index.row() - 1;
632 int column = index.column() == 0 ? 0 : index.column() - 1;
634 emit dataChanged ( createIndex ( row, column ), createIndex ( row + 1, column + 1 ) );
648 for (
int row = 0; row < this_objects.size(); ++row )
650 dref ListElement = this_objects.at ( row );
652 if ( ListElement.UID() == obj.UID() )
654 return this->index ( row, 0 );
658 return QModelIndex();
666 beginRemoveRows ( parent, row, row + count - 1 );
668 for ( ; count != 0; --count )
670 this_structure.removeOne ( this_structure.at ( row + count - 1 ) );
671 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
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