コード例 #1
0
ファイル: settings.cpp プロジェクト: blockplanet/blockplanet
bool Settings::setEntry(const std::string &name, const void *data,
	bool set_group, bool set_default)
{
	Settings *old_group = NULL;

	if (!checkNameValid(name))
		return false;
	if (!set_group && !checkValueValid(*(const std::string *)data))
		return false;

	{
		MutexAutoLock lock(m_mutex);

		SettingsEntry &entry = set_default ? m_defaults[name] : m_settings[name];
		old_group = entry.group;

		entry.value    = set_group ? "" : *(const std::string *)data;
		entry.group    = set_group ? *(Settings **)data : NULL;
		entry.is_group = set_group;
	}

	delete old_group;

	return true;
}
コード例 #2
0
ファイル: kconstanteditor.cpp プロジェクト: KDE/kmplot
//BEGIN class KConstantEditor
KConstantEditor::KConstantEditor( QWidget * parent )
	: KDialog( parent )
{
	m_widget = new ConstantsEditorWidget( this );
	m_widget->layout()->setMargin( 0 );
	setMainWidget( m_widget );
	setButtons( Close );
	
	m_widget->cmdNew->setIcon( QIcon::fromTheme("document-new") );
	m_widget->cmdDelete->setIcon( QIcon::fromTheme("edit-delete") );
	
	setCaption( i18n("Constants Editor") );
    
    connect( this, SIGNAL(finished()), this, SLOT(dialogFinished()) );
	
	m_constantValidator = new ConstantValidator( this );
	m_widget->nameEdit->setValidator( m_constantValidator );
	
	updateConstantsList();
	
	connect( m_widget->nameEdit, SIGNAL( textEdited( const QString & ) ), this, SLOT( constantNameEdited( const QString & ) ) );
	connect( m_widget->valueEdit, SIGNAL( textEdited( const QString & ) ), this, SLOT( saveCurrentConstant() ) );
	
	connect( m_widget->nameEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( checkValueValid() ) );
	connect( m_widget->valueEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( checkValueValid() ) );
	
	connect( m_widget->cmdNew, SIGNAL( clicked() ), this, SLOT( cmdNew_clicked() ) );
	connect( m_widget->cmdDelete, SIGNAL( clicked() ), this, SLOT( cmdDelete_clicked() ) );
	
	connect( m_widget->constantList, SIGNAL(currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * )), this, SLOT(selectedConstantChanged( QTreeWidgetItem * )) );
	connect( m_widget->constantList, SIGNAL(itemClicked( QTreeWidgetItem *, int )), this, SLOT(itemClicked()) );
	
	connect( XParser::self()->constants(), SIGNAL(constantsChanged()), this, SLOT(updateConstantsList()) );
	
	checkValueValid();
}