Skip to content

Commit

Permalink
Fix incorrect member variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 10, 2018
1 parent 8ecb943 commit 06bb4d4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
72 changes: 35 additions & 37 deletions src/app/qgssettingstree.cpp
Expand Up @@ -60,37 +60,35 @@ QgsSettingsTree::QgsSettingsTree( QWidget *parent )
header()->resizeSection( 1, 100 );
header()->resizeSection( 2, 250 );

settings = nullptr;
refreshTimer.setInterval( 2000 );
autoRefresh = false;
mRefreshTimer.setInterval( 2000 );

groupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirClosedIcon ),
QIcon::Normal, QIcon::Off );
groupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirOpenIcon ),
QIcon::Normal, QIcon::On );
keyIcon = style()->standardIcon( QStyle::SP_FileIcon );
mGroupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirClosedIcon ),
QIcon::Normal, QIcon::Off );
mGroupIcon.addPixmap( style()->standardPixmap( QStyle::SP_DirOpenIcon ),
QIcon::Normal, QIcon::On );
mKeyIcon = style()->standardIcon( QStyle::SP_FileIcon );

setEditTriggers( QAbstractItemView::AllEditTriggers );

connect( &refreshTimer, &QTimer::timeout, this, &QgsSettingsTree::maybeRefresh );
connect( &mRefreshTimer, &QTimer::timeout, this, &QgsSettingsTree::maybeRefresh );
}

void QgsSettingsTree::setSettingsObject( QgsSettings *settings )
{
delete this->settings;
this->settings = settings;
delete this->mSettings;
this->mSettings = settings;
clear();

if ( settings )
{
settings->setParent( this );
refresh();
if ( autoRefresh )
refreshTimer.start();
if ( mAutoRefresh )
mRefreshTimer.start();
}
else
{
refreshTimer.stop();
mRefreshTimer.stop();
}
}

Expand All @@ -101,17 +99,17 @@ QSize QgsSettingsTree::sizeHint() const

void QgsSettingsTree::setAutoRefresh( bool autoRefresh )
{
this->autoRefresh = autoRefresh;
if ( settings )
this->mAutoRefresh = autoRefresh;
if ( mSettings )
{
if ( autoRefresh )
{
maybeRefresh();
refreshTimer.start();
mRefreshTimer.start();
}
else
{
refreshTimer.stop();
mRefreshTimer.stop();
}
}
}
Expand All @@ -124,21 +122,21 @@ void QgsSettingsTree::maybeRefresh()

void QgsSettingsTree::refresh()
{
if ( !settings )
if ( !mSettings )
return;

disconnect( this, &QTreeWidget::itemChanged,
this, &QgsSettingsTree::updateSetting );

settings->sync();
mSettings->sync();

// add any settings not in QgsSettings object, so it will show up in the tree view
QMap<QString, QStringList>::const_iterator it = settingsMap.constBegin();
while ( it != settingsMap.constEnd() )
QMap<QString, QStringList>::const_iterator it = mSettingsMap.constBegin();
while ( it != mSettingsMap.constEnd() )
{
if ( ! settings->contains( it.key() ) )
if ( ! mSettings->contains( it.key() ) )
{
settings->setValue( it.key(), it.value().at( 3 ) );
mSettings->setValue( it.key(), it.value().at( 3 ) );
}
++it;
}
Expand All @@ -153,7 +151,7 @@ bool QgsSettingsTree::event( QEvent *event )
{
if ( event->type() == QEvent::WindowActivate )
{
if ( isActiveWindow() && autoRefresh )
if ( isActiveWindow() && mAutoRefresh )
maybeRefresh();
}
return QTreeWidget::event( event );
Expand All @@ -165,16 +163,16 @@ void QgsSettingsTree::updateSetting( QTreeWidgetItem *item )
if ( key.isNull() )
return;

settings->setValue( key, item->data( 2, Qt::UserRole ) );
if ( autoRefresh )
mSettings->setValue( key, item->data( 2, Qt::UserRole ) );
if ( mAutoRefresh )
refresh();
}

void QgsSettingsTree::updateChildItems( QTreeWidgetItem *parent )
{
int dividerIndex = 0;

Q_FOREACH ( const QString &group, settings->childGroups() )
Q_FOREACH ( const QString &group, mSettings->childGroups() )
{
QTreeWidgetItem *child = nullptr;
int childIndex = findChild( parent, group, dividerIndex );
Expand All @@ -190,15 +188,15 @@ void QgsSettingsTree::updateChildItems( QTreeWidgetItem *parent )
{
child = createItem( group, parent, dividerIndex );
}
child->setIcon( 0, groupIcon );
child->setIcon( 0, mGroupIcon );
++dividerIndex;

settings->beginGroup( group );
mSettings->beginGroup( group );
updateChildItems( child );
settings->endGroup();
mSettings->endGroup();
}

Q_FOREACH ( const QString &key, settings->childKeys() )
Q_FOREACH ( const QString &key, mSettings->childKeys() )
{
QTreeWidgetItem *child = nullptr;
int childIndex = findChild( parent, key, 0 );
Expand All @@ -216,15 +214,15 @@ void QgsSettingsTree::updateChildItems( QTreeWidgetItem *parent )
{
child = createItem( key, parent, dividerIndex );
}
child->setIcon( 0, keyIcon );
child->setIcon( 0, mKeyIcon );
++dividerIndex;
}
else
{
child = childAt( parent, childIndex );
}

QVariant value = settings->value( key );
QVariant value = mSettings->value( key );
if ( value.type() == QVariant::Invalid )
{
child->setText( 1, QStringLiteral( "Invalid" ) );
Expand Down Expand Up @@ -259,10 +257,10 @@ QTreeWidgetItem *QgsSettingsTree::createItem( const QString &text,

QString key = itemKey( item );
QgsDebugMsgLevel( key, 4 );
if ( settingsMap.contains( key ) )
if ( mSettingsMap.contains( key ) )
{
QgsDebugMsgLevel( "contains!!!!", 4 );
QStringList values = settingsMap[ key ];
QgsDebugMsgLevel( QStringLiteral( "contains!!!!" ), 4 );
QStringList values = mSettingsMap[ key ];
item->setText( 3, values.at( 0 ) );
item->setToolTip( 0, values.at( 1 ) );
item->setToolTip( 2, values.at( 1 ) );
Expand Down
18 changes: 9 additions & 9 deletions src/app/qgssettingstree.h
Expand Up @@ -54,14 +54,14 @@ class QgsSettingsTree : public QTreeWidget
public:
explicit QgsSettingsTree( QWidget *parent = nullptr );

void setSettingsObject( QgsSettings *settings );
void setSettingsObject( QgsSettings *mSettings );
QSize sizeHint() const override;

void setSettingsMap( QMap< QString, QStringList > &map ) { settingsMap = map; }
void setSettingsMap( QMap< QString, QStringList > &map ) { mSettingsMap = map; }
QString itemKey( QTreeWidgetItem *item );

public slots:
void setAutoRefresh( bool autoRefresh );
void setAutoRefresh( bool mAutoRefresh );
void maybeRefresh();
void refresh();

Expand All @@ -80,13 +80,13 @@ class QgsSettingsTree : public QTreeWidget
int findChild( QTreeWidgetItem *parent, const QString &text, int startIndex );
void moveItemForward( QTreeWidgetItem *parent, int oldIndex, int newIndex );

QgsSettings *settings = nullptr;
QTimer refreshTimer;
bool autoRefresh;
QIcon groupIcon;
QIcon keyIcon;
QgsSettings *mSettings = nullptr;
QTimer mRefreshTimer;
bool mAutoRefresh = true;
QIcon mGroupIcon;
QIcon mKeyIcon;

QMap< QString, QStringList > settingsMap;
QMap< QString, QStringList > mSettingsMap;
};

#endif

0 comments on commit 06bb4d4

Please sign in to comment.