14 : QAbstractItemModel ( parent ),
15 abstract_classes_selectable ( false )
20 std::vector<std::string >> () )
33 type_index
const & parent )
const
40 return createIndex ( row, column, down );
50 if ( child.isValid() )
56 return createIndex ( up->
GetRow(), 0, up );
67 if ( !parent.isValid() )
73 ParentNode = getnode ( parent );
81 if ( parent.isValid() )
104 abstract_classes_selectable ?
105 ( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) : ( Qt::ItemIsSelectable );
109 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
113 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled );
118 if ( index.isValid() )
122 case Qt::ForegroundRole:
127 tref const & obj = onode->GetObject();
131 return QVariant ( QColor ( Qt::blue ) );
135 return QVariant ( QColor ( Qt::darkGray ) );
138 catch ( daq::dbe::config_object_retrieval_result_is_null
const & e )
147 case Qt::ToolTipRole:
148 if (
auto cnode =
dynamic_cast<ClassNode *
> ( getnode ( index ) ) )
150 return cnode->GetData ( index.column(), role );
154 case Qt::DisplayRole:
155 case Qt::DecorationRole:
156 return getnode ( index )->GetData ( index.column(), role );
166 if ( ( orientation == Qt::Horizontal ) && ( role == Qt::DisplayRole ) )
178 rows = onode->ChildCount();
180 beginInsertRows ( parent, position, position + rows - 1 );
182 std::string
const &
classname = onode->GetData (
188 for (
auto const & i : objects )
191 emit ObjectFile(QString::fromStdString(i.contained_in()));
206 if ( parent.isValid() )
208 treenode * ParentNode = getnode ( parent );
217 if ( parent.isValid() )
219 treenode * ParentNode = getnode ( parent );
223 insertRows ( 0, 0, parent );
231 if ( parent.isValid() )
233 treenode * ParentNode = getnode ( parent );
253 types <<
"application/vnd.text.list";
259 QMimeData * mimeData =
new QMimeData();
260 QByteArray encodedData;
262 QDataStream stream ( &encodedData, QIODevice::WriteOnly );
264 foreach ( QModelIndex index, indexes )
266 if ( index.isValid() && index.column() == 0 )
269 treenode * NodeObject = getnode ( index );
272 QString ObjectUid = QString::fromStdString ( Object.
UID() );
273 QString ObjectClassName = QString::fromStdString ( Object.
class_name() );
275 Text.append ( ObjectUid );
276 Text.append ( ObjectClassName );
282 mimeData->setData (
"application/vnd.text.list", encodedData );
287 type_index
const & RootIndex )
const
289 for (
int i = 0; i < rowCount ( RootIndex ); ++i )
291 QModelIndex ChildIndex = index ( i, 0, RootIndex );
292 treenode * ChildNode = getnode ( ChildIndex );
294 if ( NodeItem == ChildNode )
299 QModelIndex ChildChildIndex = getindex ( NodeItem, ChildIndex );
301 if ( ChildChildIndex.isValid() )
303 return ChildChildIndex;
307 return QModelIndex();
319 if ( index.isValid() )
321 return static_cast<treenode *
> ( index.internalPointer() );
329 if ( index.isValid() )
333 return ObjectItem->GetObject();
337 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
343 treenode *
Item = getnode ( index );
347 ClassNode * ClassItem =
dynamic_cast<ClassNode *
> (
Item );
349 if ( ClassItem !=
nullptr )
351 return ClassItem->GetClassInfo();
354 ObjectNode * ObjectItem =
dynamic_cast<ObjectNode *
> (
Item );
356 if ( ObjectItem !=
nullptr )
358 tref Object = ObjectItem->GetObject();
362 RelationshipNode * RelationshipItem =
dynamic_cast<RelationshipNode *
> (
Item );
364 if ( RelationshipItem !=
nullptr )
367 RelationshipItem->relation_t().p_type,
382 abstract_classes_selectable = val;
387 update_multiple_objects(objects);
396 QString::fromStdString ( obj.class_name() ) ) )
399 auto found = [&obj, classnode] (
int i )
401 return obj.UID() == classnode->GetChild ( i )->GetData ( 0 ).toString().toStdString();
405 int const childs = classnode->ChildCount();
407 for ( ; i < childs and not found ( i ); ++i )
411 QModelIndex parent_index = getindex ( classnode );
413 return childs == i ? QModelIndex() : index ( i, parent_index.column(), parent_index );
416 return QModelIndex();
426 layoutAboutToBeChanged();
427 new ObjectNode ( obj,
false, classnode );
431 emit layoutChanged();
438 if ( index.isValid() )
440 this->removeRows ( index.row(), 1, index.parent() );
446 if ( index.isValid() )
448 treenode * child = getnode ( index );
449 child->rename ( QString::fromStdString ( obj.ref().UID() ) );
450 emit dataChanged ( index, index );
458 if ( index.isValid() )
461 treenode * child = getnode ( index );
463 if ( treenode * parent = child->GetParent() )
465 emit layoutAboutToBeChanged();
466 parent->RemoveChild ( child );
467 new ObjectNode ( obj,
false, parent );
468 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 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
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
treenode * GetParent() const
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