Skip to content
Permalink
Browse files

Fix incorrect member variable names

  • Loading branch information
nyalldawson committed Sep 10, 2018
1 parent 8ecb943 commit 06bb4d430d2dcaa8e4aca750bae3df36a65207af
Showing with 44 additions and 46 deletions.
  1. +35 −37 src/app/qgssettingstree.cpp
  2. +9 −9 src/app/qgssettingstree.h
@@ -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();
}
}

@@ -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();
}
}
}
@@ -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;
}
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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" ) );
@@ -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 ) );
@@ -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();

@@ -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.
You can’t perform that action at this time.