20 : QAbstractItemModel (
parent ),
26 std::vector<std::string >> () )
39 type_index
const &
parent )
const
46 return createIndex ( row, column, down );
56 if ( child.isValid() )
62 return createIndex ( up->
GetRow(), 0, up );
111 ( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) : ( Qt::ItemIsSelectable );
115 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
119 return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled );
124 if (
index.isValid() )
128 case Qt::ForegroundRole:
133 tref const & obj = onode->GetObject();
144 catch ( daq::dbe::config_object_retrieval_result_is_null
const & e )
153 case Qt::BackgroundRole:
158 tref const & obj = onode->GetObject();
169 catch ( daq::dbe::config_object_retrieval_result_is_null
const & e )
178 case Qt::ToolTipRole:
181 return cnode->GetData (
index.column(), role );
185 case Qt::DisplayRole:
186 case Qt::DecorationRole:
197 if ( ( orientation == Qt::Horizontal ) && ( role == Qt::DisplayRole ) )
209 rows = onode->ChildCount();
211 beginInsertRows (
parent, position, position + rows - 1 );
213 std::string
const &
classname = onode->GetData (
219 for (
auto const & i : objects )
222 emit
ObjectFile(QString::fromStdString(i.contained_in()));
284 types <<
"application/vnd.text.list";
290 QMimeData *
mimeData =
new QMimeData();
291 QByteArray encodedData;
293 QDataStream stream ( &encodedData, QIODevice::WriteOnly );
295 foreach ( QModelIndex
index, indexes )
303 QString ObjectUid = QString::fromStdString ( Object.
UID() );
304 QString ObjectClassName = QString::fromStdString ( Object.
class_name() );
306 Text.append ( ObjectUid );
307 Text.append ( ObjectClassName );
313 mimeData->setData (
"application/vnd.text.list", encodedData );
318 type_index
const & RootIndex )
const
320 for (
int i = 0; i <
rowCount ( RootIndex ); ++i )
322 QModelIndex ChildIndex =
index ( i, 0, RootIndex );
325 if ( NodeItem == ChildNode )
330 QModelIndex ChildChildIndex =
getindex ( NodeItem, ChildIndex );
332 if ( ChildChildIndex.isValid() )
334 return ChildChildIndex;
338 return QModelIndex();
350 if (
index.isValid() )
360 if ( index.isValid() )
364 return ObjectItem->GetObject();
368 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
374 treenode * Item = getnode ( index );
378 ClassNode * ClassItem =
dynamic_cast<ClassNode *
> ( Item );
380 if ( ClassItem !=
nullptr )
382 return ClassItem->GetClassInfo();
385 ObjectNode * ObjectItem =
dynamic_cast<ObjectNode *
> ( Item );
387 if ( ObjectItem !=
nullptr )
389 tref Object = ObjectItem->GetObject();
393 RelationshipNode * RelationshipItem =
dynamic_cast<RelationshipNode *
> ( Item );
395 if ( RelationshipItem !=
nullptr )
398 RelationshipItem->relation_t().p_type,
403 return dunedaq::conffwk::class_t();
427 QString::fromStdString ( obj.class_name() ) ) )
430 auto found = [&obj, classnode] (
int i )
432 return obj.UID() == classnode->GetChild ( i )->GetData ( 0 ).toString().toStdString();
436 int const childs = classnode->ChildCount();
438 for ( ; i < childs and not found ( i ); ++i )
442 QModelIndex parent_index = getindex ( classnode );
444 return childs == i ? QModelIndex() : index ( i, parent_index.column(), parent_index );
447 return QModelIndex();
457 layoutAboutToBeChanged();
458 new ObjectNode ( obj,
false, classnode );
462 emit layoutChanged();
469 if ( index.isValid() )
471 this->removeRows ( index.row(), 1, index.parent() );
477 if ( index.isValid() )
479 treenode * child = getnode ( index );
480 child->rename ( QString::fromStdString ( obj.ref().UID() ) );
481 emit dataChanged ( index, index );
489 if ( index.isValid() )
492 treenode * child = getnode ( index );
494 if ( treenode * parent = child->GetParent() )
496 emit layoutAboutToBeChanged();
497 parent->RemoveChild ( child );
498 new ObjectNode ( obj,
false, parent );
499 emit layoutChanged();
#define TREEMODEL_REMOVE_ROWS_DEF(classname)
static QColor ObjectForeground
static QColor FileReadOnlyForeground
static QColor ObjectBackground
static QColor FileReadOnlyBackground
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