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::DisplayRole:
148 case Qt::DecorationRole:
149 return getnode ( index )->GetData ( index.column(), role );
159 if ( ( orientation == Qt::Horizontal ) && ( role == Qt::DisplayRole ) )
171 rows = onode->ChildCount();
173 beginInsertRows ( parent, position, position + rows - 1 );
175 std::string
const &
classname = onode->GetData (
181 for (
auto const & i : objects )
184 emit ObjectFile(QString::fromStdString(i.contained_in()));
199 if ( parent.isValid() )
201 treenode * ParentNode = getnode ( parent );
210 if ( parent.isValid() )
212 treenode * ParentNode = getnode ( parent );
216 insertRows ( 0, 0, parent );
224 if ( parent.isValid() )
226 treenode * ParentNode = getnode ( parent );
246 types <<
"application/vnd.text.list";
252 QMimeData * mimeData =
new QMimeData();
253 QByteArray encodedData;
255 QDataStream stream ( &encodedData, QIODevice::WriteOnly );
257 foreach ( QModelIndex index, indexes )
259 if ( index.isValid() && index.column() == 0 )
262 treenode * NodeObject = getnode ( index );
265 QString ObjectUid = QString::fromStdString ( Object.
UID() );
266 QString ObjectClassName = QString::fromStdString ( Object.
class_name() );
268 Text.append ( ObjectUid );
269 Text.append ( ObjectClassName );
275 mimeData->setData (
"application/vnd.text.list", encodedData );
280 type_index
const & RootIndex )
const
282 for (
int i = 0; i < rowCount ( RootIndex ); ++i )
284 QModelIndex ChildIndex = index ( i, 0, RootIndex );
285 treenode * ChildNode = getnode ( ChildIndex );
287 if ( NodeItem == ChildNode )
292 QModelIndex ChildChildIndex = getindex ( NodeItem, ChildIndex );
294 if ( ChildChildIndex.isValid() )
296 return ChildChildIndex;
300 return QModelIndex();
312 if ( index.isValid() )
314 return static_cast<treenode *
> ( index.internalPointer() );
322 if ( index.isValid() )
326 return ObjectItem->GetObject();
330 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
336 treenode *
Item = getnode ( index );
340 ClassNode * ClassItem =
dynamic_cast<ClassNode *
> (
Item );
342 if ( ClassItem !=
nullptr )
344 return ClassItem->GetClassInfo();
347 ObjectNode * ObjectItem =
dynamic_cast<ObjectNode *
> (
Item );
349 if ( ObjectItem !=
nullptr )
351 tref Object = ObjectItem->GetObject();
355 RelationshipNode * RelationshipItem =
dynamic_cast<RelationshipNode *
> (
Item );
357 if ( RelationshipItem !=
nullptr )
360 RelationshipItem->relation_t().p_type,
375 abstract_classes_selectable = val;
380 update_multiple_objects(objects);
389 QString::fromStdString ( obj.class_name() ) ) )
392 auto found = [&obj, classnode] (
int i )
394 return obj.UID() == classnode->GetChild ( i )->GetData ( 0 ).toString().toStdString();
398 int const childs = classnode->ChildCount();
400 for ( ; i < childs and not found ( i ); ++i )
404 QModelIndex parent_index = getindex ( classnode );
406 return childs == i ? QModelIndex() : index ( i, parent_index.column(), parent_index );
409 return QModelIndex();
418 layoutAboutToBeChanged();
419 new ObjectNode ( obj,
false, classnode );
423 emit layoutChanged();
430 if ( index.isValid() )
432 this->removeRows ( index.row(), 1, index.parent() );
438 if ( index.isValid() )
440 treenode * child = getnode ( index );
441 child->rename ( QString::fromStdString ( obj.ref().UID() ) );
442 emit dataChanged ( index, index );
450 if ( index.isValid() )
453 treenode * child = getnode ( index );
455 if ( treenode * parent = child->GetParent() )
457 emit layoutAboutToBeChanged();
458 parent->RemoveChild ( child );
459 new ObjectNode ( obj,
false, parent );
460 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