26 , mSettingsSection(
"browser" )
63 void QgsBrowserTreeView::saveState()
68 settings.
setValue( expandedPathsKey(), expandedPaths );
72 void QgsBrowserTreeView::restoreState()
82 Q_FOREACH (
const QString& path, mExpandPaths )
86 expandIndexSet.
insert( expandIndex );
89 QgsDebugMsg(
"index for path " + path +
" not found" );
92 Q_FOREACH (
const QModelIndex& expandIndex, expandIndexSet )
94 expandTree( expandIndex );
116 expandTree( parentIndex );
119 bool QgsBrowserTreeView::treeExpanded(
const QModelIndex & index )
127 return treeExpanded( parentIndex );
169 if ( !treeExpanded( parentIndex ) )
171 Q_FOREACH (
const QString& path, mExpandPaths )
179 for (
int i = start; i <= end; i++ )
183 QString escapedChildPath = childPath;
184 escapedChildPath.
replace(
'|',
"\\|" );
186 QgsDebugMsgLevel(
"childPath = " + childPath +
" escapedChildPath = " + escapedChildPath, 2 );
187 if ( mExpandPaths.
contains( childPath ) || mExpandPaths.
indexOf(
QRegExp(
"^" + escapedChildPath +
"/.*" ) ) != -1 )
195 QString QgsBrowserTreeView::expandedPathsKey()
const 197 return '/' + mSettingsSection +
"/expandedPaths";
212 QStringList childrenPaths = expandedPathsList( childIndex );
213 if ( !childrenPaths.
isEmpty() )
215 paths.
append( childrenPaths );
virtual int rowCount(const QModelIndex &parent) const =0
virtual void setModel(QAbstractItemModel *model) override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
QModelIndex findPath(const QString &path, Qt::MatchFlag matchFlag=Qt::MatchExactly)
Return index of item with given path.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QString join(const QString &separator) const
const_iterator insert(const T &value)
QgsBrowserTreeView(QWidget *parent=nullptr)
void setValue(const QString &key, const QVariant &value)
void append(const T &value)
#define QgsDebugMsgLevel(str, level)
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
virtual void rowsInserted(const QModelIndex &parentIndex, int start, int end) override
virtual QVariant data(const QModelIndex &index, int role) const =0
bool isExpanded(const QModelIndex &index) const
virtual QModelIndex parent(const QModelIndex &index) const =0
QString & replace(int position, int n, QChar after)
bool hasExpandedDescendant(const QModelIndex &index) const
QVariant value(const QString &key, const QVariant &defaultValue) const
virtual void showEvent(QShowEvent *e) override
QStringList toStringList() const
virtual void setModel(QAbstractItemModel *model)
virtual void hideEvent(QHideEvent *e) override
int indexOf(const QRegExp &rx, int from) const
void expand(const QModelIndex &index)
QAbstractItemModel * model() const
bool removeOne(const T &value)