7 : QSortFilterProxyModel ( parent ),
8 Type ( RegExpFilterType ),
9 LevelRestriction ( 1000 ),
21 if ( index.isValid() )
23 QModelIndex sourceParent = mapToSource ( index );
24 return sourceModel()->hasChildren ( sourceParent );
34 if ( index.isValid() )
36 QModelIndex sourceParent = mapToSource ( index );
37 return sourceModel()->canFetchMore ( sourceParent );
47 QModelIndex sourceParent = mapToSource ( index );
48 sourceModel()->fetchMore ( sourceParent );
53 LevelRestriction = Levels;
64 QueryObjects = Objects;
74 if ( index.isValid() )
78 if ( UnderlyingModel )
80 return UnderlyingModel->
getnode ( index );
90 if ( index.isValid() )
92 QModelIndex sourceParent = mapToSource ( index );
101 throw daq::dbe::cannot_handle_invalid_qmodelindex (
ERS_HERE );
106 QModelIndex sourceParent = mapToSource ( index );
110 return my->
getclass ( sourceParent );
118 return sourceModel();
123 QueryObjects.clear();
133 type_index
const & source_parent )
const
135 treenode * NodeObject = getnode ( sourceModel()->index ( source_row, 0, source_parent ) );
144 if ( !source_parent.isValid() )
146 QModelIndex Index_1 = sourceModel()->index ( source_row, 1, source_parent );
148 if ( sourceModel()->data ( Index_1 ).toUInt() == 0 )
157 case RegExpFilterType:
158 return RegexpFilter ( source_row, source_parent );
160 case ObjectFilterType:
161 return ObjectFilter ( source_row, source_parent );
169 type_index
const & right )
const
171 if ( left.parent() == QModelIndex() || left.parent().parent() == QModelIndex() )
173 QVariant LeftData = sourceModel()->data ( left );
174 QVariant RightData = sourceModel()->data ( right );
176 switch ( LeftData.type() )
180 return ( LeftData.toUInt() < RightData.toUInt() );
183 return ( LeftData.toInt() < RightData.toInt() );
185 case QVariant::String:
186 return ( ( LeftData.toString() ).compare ( RightData.toString() ) > 0 );
199 int LevelRestriction )
const
201 if ( sourceModel()->canFetchMore ( SourceIndex ) )
203 sourceModel()->fetchMore ( SourceIndex );
206 if ( sourceModel()->data ( SourceIndex ).toString().contains ( filterRegExp() ) )
211 if ( LevelRestriction <= 1 )
216 for (
int i = 0; i < sourceModel()->rowCount ( SourceIndex ); ++i )
218 if ( AcceptItem ( SourceIndex.child ( i, 0 ), --LevelRestriction ) )
228 type_index
const & sourceParent )
const
230 if ( AtDepth ( sourceParent ) <= LevelRestriction )
232 QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
233 return AcceptItem ( index0, LevelRestriction );
240 type_index
const & sourceParent )
const
242 QModelIndex index0 = sourceModel()->index ( sourceRow, 0, sourceParent );
243 QString
id = sourceModel()->data ( index0 ).toString();
245 if ( ( filterRegExp() ).isEmpty() )
250 if ( AtDepth ( sourceParent ) > 2 )
255 if ( !sourceParent.isValid() )
257 for (
size_t i = 0; i < QueryObjects.size(); ++i )
258 if ( QString ( QueryObjects.at ( i ).class_name().c_str() ).compare (
id ) == 0 )
265 for (
size_t i = 0; i < QueryObjects.size(); ++i )
266 if (
id.compare ( QString ( QueryObjects.at ( i ).UID().c_str() ) ) == 0 )
278 QModelIndex CurrentIndex = SourceParent;
280 while ( CurrentIndex.isValid() )
282 CurrentIndex = CurrentIndex.parent();
300 QString::fromStdString ( obj.class_name() ) ) )
303 auto found = [&obj, classnode] (
int i )
305 return obj.UID() == classnode->GetChild ( i )->GetData ( 0 ).toString().toStdString();
309 int const childs = classnode->ChildCount();
311 for ( ; i < childs and not found ( i ); ++i )
314 return i == childs ? QModelIndex() : index ( i, 0, QModelIndex() );
317 return QModelIndex();
336 type_index
const mapped_index = this->mapFromSource ( index );
337 emit dataChanged ( mapped_index, mapped_index );
342 type_index
const mapped_index = this->mapFromSource ( index );
343 emit dataChanged ( mapped_index, mapped_index );
#define TREEMODEL_REMOVE_ROWS_DEF(classname)
static cptr< datahandler > gethandler()
void model_common_connections()
type_datum * getnode(const type_index &index) const override
int AtDepth(const QModelIndex &SourceParent) const
void SetFilterType(FilterType Filter)
bool canFetchMore(type_index const &index) const
treeselection(QObject *parent=0)
Including DBE.
bool hasChildren(type_index const &index) const
bool RegexpFilter(int sourceRow, const QModelIndex &sourceParent) const
std::vector< dbe::tref > GetQueryObjects()
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
type_datum * getnode(type_index const &index) const override
bool ObjectFilter(int sourceRow, const QModelIndex &sourceParent) const
void ToggleEmptyClasses(bool HideLocal)
void SetQueryObjects(std::vector< tref > Objects)
bool lessThan(const QModelIndex &left, const QModelIndex &right) const
void SetFilterRestrictionLevel(int Levels)
bool AcceptItem(const QModelIndex &SourceIndex, int LevelRestriction) const
void fetchMore(type_index const &index)
#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)
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