19 : QAbstractItemModel (
parent ),
25 std::vector<std::string >> () )
38 type_index
const &
parent )
const
45 return createIndex ( row, column, down );
55 if ( child.isValid() )
61 return createIndex ( up->
GetRow(), 0, up );
110 ( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) : ( Qt::ItemIsSelectable );
114 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
118 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled );
123 if (
index.isValid() )
127 case Qt::ForegroundRole:
132 tref const & obj = onode->GetObject();
136 return QVariant ( QColor ( Qt::blue ) );
140 return QVariant ( QColor ( Qt::darkGray ) );
143 catch ( daq::dbe::config_object_retrieval_result_is_null
const & e )
152 case Qt::ToolTipRole:
155 return cnode->GetData (
index.column(), role );
159 case Qt::DisplayRole:
160 case Qt::DecorationRole:
171 if ( ( orientation == Qt::Horizontal ) && ( role == Qt::DisplayRole ) )
183 rows = onode->ChildCount();
185 beginInsertRows (
parent, position, position + rows - 1 );
187 std::string
const &
classname = onode->GetData (
193 for (
auto const & i : objects )
196 emit
ObjectFile(QString::fromStdString(i.contained_in()));
258 types <<
"application/vnd.text.list";
264 QMimeData *
mimeData =
new QMimeData();
265 QByteArray encodedData;
267 QDataStream stream ( &encodedData, QIODevice::WriteOnly );
269 foreach ( QModelIndex
index, indexes )
277 QString ObjectUid = QString::fromStdString ( Object.
UID() );
278 QString ObjectClassName = QString::fromStdString ( Object.
class_name() );
280 Text.append ( ObjectUid );
281 Text.append ( ObjectClassName );
287 mimeData->setData (
"application/vnd.text.list", encodedData );
292 type_index
const & RootIndex )
const
294 for (
int i = 0; i <
rowCount ( RootIndex ); ++i )
296 QModelIndex ChildIndex =
index ( i, 0, RootIndex );
299 if ( NodeItem == ChildNode )
304 QModelIndex ChildChildIndex =
getindex ( NodeItem, ChildIndex );
306 if ( ChildChildIndex.isValid() )
308 return ChildChildIndex;
312 return QModelIndex();
324 if (
index.isValid() )
334 if ( index.isValid() )
338 return ObjectItem->GetObject();
342 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
348 treenode * Item = getnode ( index );
352 ClassNode * ClassItem =
dynamic_cast<ClassNode *
> ( Item );
354 if ( ClassItem !=
nullptr )
356 return ClassItem->GetClassInfo();
359 ObjectNode * ObjectItem =
dynamic_cast<ObjectNode *
> ( Item );
361 if ( ObjectItem !=
nullptr )
363 tref Object = ObjectItem->GetObject();
367 RelationshipNode * RelationshipItem =
dynamic_cast<RelationshipNode *
> ( Item );
369 if ( RelationshipItem !=
nullptr )
372 RelationshipItem->relation_t().p_type,
377 return dunedaq::conffwk::class_t();
401 QString::fromStdString ( obj.class_name() ) ) )
404 auto found = [&obj, classnode] (
int i )
406 return obj.UID() == classnode->GetChild ( i )->GetData ( 0 ).toString().toStdString();
410 int const childs = classnode->ChildCount();
412 for ( ; i < childs and not found ( i ); ++i )
416 QModelIndex parent_index = getindex ( classnode );
418 return childs == i ? QModelIndex() : index ( i, parent_index.column(), parent_index );
421 return QModelIndex();
431 layoutAboutToBeChanged();
432 new ObjectNode ( obj,
false, classnode );
436 emit layoutChanged();
443 if ( index.isValid() )
445 this->removeRows ( index.row(), 1, index.parent() );
451 if ( index.isValid() )
453 treenode * child = getnode ( index );
454 child->rename ( QString::fromStdString ( obj.ref().UID() ) );
455 emit dataChanged ( index, index );
463 if ( index.isValid() )
466 treenode * child = getnode ( index );
468 if ( treenode * parent = child->GetParent() )
470 emit layoutAboutToBeChanged();
471 parent->RemoveChild ( child );
472 new ObjectNode ( obj,
false, parent );
473 emit layoutChanged();
#define TREEMODEL_REMOVE_ROWS_DEF(classname)
static cptr< datahandler > gethandler()
static bool check_file_rw(const QString &FileName)
static std::vector< dbe::inner::configobject::tref > objects(std::string const &cname, bool const keep_inherited=true)
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
static treenode * findchild(treenode *top, QString const &name)
std::string class_name() const
void update_multiple_objects(std::vector< type_object_info > const &)
void model_common_connections()
void objectsUpdated(const std::vector< dbe::dref > &objects)
void fetchMore(const type_index &parent) override
QVariant data(const type_index &index, int role=Qt::DisplayRole) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
type_index getindex(treenode *NodeItem, type_index const &RootIndex=QModelIndex()) const
bool setData(const type_index &index, const QVariant &value, int role) override
type_datum * getnode(const type_index &index) const override
type_index index(int row, int column, const type_index &parent) const override
bool canFetchMore(const type_index &parent) const override
bool insertRows(int position, int rows, const type_index &parent) override
bool abstract_classes_selectable
void ToggleAbstractClassesSelectable(bool)
QStringList mimeTypes() const override
bool hasChildren(const type_index &parent) const override
int columnCount(const type_index &parent) const override
type_index parent(const type_index &child) const override
QMimeData * mimeData(const QModelIndexList &indexes) const override
tree(const QStringList &Headers, QObject *parent=nullptr)
Qt::ItemFlags flags(const type_index &index) const override
int rowCount(const type_index &parent) const override
bool GetHasStructure() const
virtual tref GetObject() const
treenode * GetChild(const int Row) const
bool GetWasFetched() const
void SetWasFetched(bool Fetched)
#define MODEL_COMMON_INTERFACE_LOOKUP_IMPL(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)
inner::configobject::tref tref
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
char const *const dbe_lib_structure_version
Including QT Headers.
#define dbe_compiled_version