Example #1
0
QString PyQtProjectItem::pyQtFilePath() const
{
#if defined( Q_OS_WIN )
    // system scope
    {
        const QSettings settings( "HKEY_LOCAL_MACHINE\\Software\\PyQt4", QSettings::NativeFormat );
        const QStringList versions = settings.childGroups();
        
        foreach ( const QString& version, versions ) {
            const QString installPath = settings.value( QString( "%1/InstallPath/." ).arg( version ) ).toString();
            
            if ( !installPath.isEmpty() && QFile::exists( installPath ) ) {
                return QDir::toNativeSeparators( QDir::cleanPath( installPath ) );
            }
        }
    }
    
    // user scope
    {
        const QSettings settings( "HKEY_CURRENT_USER\\Software\\PyQt4", QSettings::NativeFormat );
        const QStringList versions = settings.childGroups();
        
        foreach ( const QString& version, versions ) {
            const QString installPath = settings.value( QString( "%1/InstallPath/." ).arg( version ) ).toString();
            
            if ( !installPath.isEmpty() && QFile::exists( installPath ) ) {
                return QDir::toNativeSeparators( QDir::cleanPath( installPath ) );
            }
        }
    }
#endif
    
    return QString::null;
}
Example #2
0
void LoadHotkeys(QSettings& settings)
{
    settings.beginGroup("Shortcuts");

    // Make sure NOT to use a reference here because it would become invalid once we call beginGroup()
    QStringList groups = settings.childGroups();
    for (auto group : groups)
    {
        settings.beginGroup(group);

        QStringList hotkeys = settings.childGroups();
        for (auto hotkey : hotkeys)
        {
            settings.beginGroup(hotkey);

            // RegisterHotkey assigns default keybindings, so use old values as default parameters
            Hotkey& hk = hotkey_groups[group][hotkey];
            hk.keyseq = QKeySequence::fromString(settings.value("KeySeq", hk.keyseq.toString()).toString());
            hk.context = (Qt::ShortcutContext)settings.value("Context", hk.context).toInt();
            if (hk.shortcut)
                hk.shortcut->setKey(hk.keyseq);

            settings.endGroup();
        }

        settings.endGroup();
    }

    settings.endGroup();
}
			QString FirefoxProfileSelectPage::GetProfileDirectory (const QString& profileName) const
			{
				QString profilesFile = field ("ProfileFile").toString ();
				QSettings settings (profilesFile, QSettings::IniFormat);
				QString profilePath;
				Q_FOREACH (const QString& groupName, settings.childGroups ())
				{
					// Call settings.endGroup() on scope exit no matter what.
					boost::shared_ptr<void> guard (static_cast<void*> (0), 
							boost::bind (&QSettings::endGroup, &settings));
					settings.beginGroup (groupName);
					if (settings.value ("Name").toString () == profileName)
					{	
						profilePath = settings.value ("Path").toString ();
						break;
					}		
				}
				if (profilePath.isEmpty ())
					return QString ();
				
				QFileInfo file (profilesFile);
				profilePath = file.absolutePath ().append ("/").append (profilePath);
				
				return profilePath; 
			}
Example #4
0
/**
  * Load any values that are available from persistent storage. Note: this
 * clears all currently values stored
  */
void AbstractAlgorithmInputHistory::load() {
  m_lastInput.clear();
  QSettings settings;
  settings.beginGroup(m_algorithmsGroup);
  //  QStringList algorithms = settings.childGroups();
  QListIterator<QString> algNames(settings.childGroups());

  // Each property is a key of the algorithm group
  while (algNames.hasNext()) {
    QHash<QString, QString> algorithmProperties;
    QString group = algNames.next();
    settings.beginGroup(group);
    QListIterator<QString> properties(settings.childKeys());
    while (properties.hasNext()) {
      QString propName = properties.next();
      QString value = settings.value(propName).toString();
      if (!value.isEmpty())
        algorithmProperties.insert(propName, value);
    }
    m_lastInput.insert(group, algorithmProperties);
    settings.endGroup();
  }

  // The previous dir
  m_previousDirectory = settings.value(m_dirKey).toString();

  settings.endGroup();
}
void AbstractAlgorithmInputHistory::readSettings(const QSettings &storage) {
  // unfortunately QSettings does not allow const when using beginGroup and
  // endGroup
  m_lastInput.clear();
  const_cast<QSettings &>(storage).beginGroup(m_algorithmsGroup);
  //  QStringList algorithms = settings.childGroups();
  QListIterator<QString> algNames(storage.childGroups());

  // Each property is a key of the algorithm group
  while (algNames.hasNext()) {
    QHash<QString, QString> algorithmProperties;
    QString group = algNames.next();
    const_cast<QSettings &>(storage).beginGroup(group);
    QListIterator<QString> properties(storage.childKeys());
    while (properties.hasNext()) {
      QString propName = properties.next();
      QString value = storage.value(propName).toString();
      if (!value.isEmpty())
        algorithmProperties.insert(propName, value);
    }
    m_lastInput.insert(group, algorithmProperties);
    const_cast<QSettings &>(storage).endGroup();
  }

  // The previous dir
  m_previousDirectory = storage.value(m_dirKey).toString();

  const_cast<QSettings &>(storage).endGroup();
}
Example #6
0
void QtDcmPreferences::readSettings()
{
    if ( !d->iniFile.exists() )
        this->setDefaultIniFile();
    //Instantiate a QSettings object from the ini file.
    QSettings prefs ( d->iniFile.fileName(), QSettings::IniFormat );
    //Load local settings
    prefs.beginGroup ( "LocalSettings" );
    d->aetitle = prefs.value ( "AETitle" ).toString();
    d->port = prefs.value ( "Port" ).toString();
    d->hostname = prefs.value ( "Hostname" ).toString();
    prefs.endGroup();

    prefs.beginGroup ( "Converter" );
    d->useDcm2nii = prefs.value ( "UseDcm2nii" ).toBool();
    d->dcm2niiPath = prefs.value ( "Dcm2nii" ).toString();
    prefs.endGroup();

    //For each server load corresponding settings
    prefs.beginGroup ( "Servers" );
    for ( int i = 0; i < prefs.childGroups().size(); i++ )
    {
        d->servers.append ( new QtDcmServer );
        d->servers.at ( i )->setAetitle ( prefs.value ( "Server" + QString::number ( i + 1 ) + "/AETitle" ).toString() );
        d->servers.at ( i )->setServer ( prefs.value ( "Server" + QString::number ( i + 1 ) + "/Hostname" ).toString() );
        d->servers.at ( i )->setPort ( prefs.value ( "Server" + QString::number ( i + 1 ) + "/Port" ).toString() );
        d->servers.at ( i )->setName ( prefs.value ( "Server" + QString::number ( i + 1 ) + "/Name" ).toString() );
    }
    prefs.endGroup();

    emit preferencesUpdated();
}
Example #7
0
void msvcProbe(Settings *settings, QList<Profile> &profiles)
{
    qbsInfo() << Tr::tr("Detecting MSVC toolchains...");

    // 1) Installed SDKs preferred over standalone Visual studio
    QVector<WinSDK> winSDKs;
    WinSDK defaultWinSDK;

    const QSettings sdkRegistry(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE") + wow6432Key()
                                + QLatin1String("\\Microsoft\\Microsoft SDKs\\Windows"),
                                QSettings::NativeFormat);
    const QString defaultSdkPath = sdkRegistry.value(QLatin1String("CurrentInstallFolder")).toString();
    if (!defaultSdkPath.isEmpty()) {
        foreach (const QString &sdkKey, sdkRegistry.childGroups()) {
            WinSDK sdk;
            sdk.version = sdkKey;
            sdk.installPath = sdkRegistry.value(sdkKey + QLatin1String("/InstallationFolder")).toString();
            sdk.isDefault = (sdk.installPath == defaultSdkPath);
            if (sdk.installPath.isEmpty())
                continue;
            if (sdk.installPath.endsWith(QLatin1Char('\\')))
                sdk.installPath.chop(1);
            findSupportedArchitectures(&sdk, QLatin1String("/bin"));
            if (sdk.isDefault)
                defaultWinSDK = sdk;
            winSDKs += sdk;
        }
    }
void DVRServerRepository::loadServers()
{
    Q_ASSERT(m_servers.isEmpty());

    QSettings settings;
    settings.beginGroup(QLatin1String("servers"));
    QStringList groups = settings.childGroups();

    DVRServerSettingsReader settingsReader;
    foreach (QString group, groups)
    {
        bool ok = false;
        int id = (int)group.toUInt(&ok);
        if (!ok)
        {
            qWarning("Ignoring invalid server ID from configuration");
            continue;
        }

        DVRServer *server = settingsReader.readServer(id);
        if (!server)
        {
            qWarning("Ignoring invalid server from configuration");
            continue;
        }

        server->setParent(this);
        connect(server, SIGNAL(serverRemoved(DVRServer*)), this, SLOT(onServerRemoved(DVRServer*)));
        connect(server, SIGNAL(statusAlertMessageChanged(QString)), this, SIGNAL(serverAlertsChanged()));

        m_servers.append(server);
        m_maxServerId = qMax(m_maxServerId, id);
    }
Example #9
0
void MainWindow::reconfigure() {
    QSettings settings;
    try{
        ChaosMetadataServiceClient::getInstance()->clearServerList();
        settings.beginGroup(PREFERENCE_NETWORK_GROUP_NAME);

        const QString current_setting = settings.value("active_configuration").toString();
        if(settings.childGroups().contains(current_setting)) {
            settings.beginGroup(current_setting);

            int mds_address_size = settings.beginReadArray("mds_address");
            for (int i = 0; i < mds_address_size; ++i) {
                settings.setArrayIndex(i);
                ChaosMetadataServiceClient::getInstance()->addServerAddress(settings.value("address").toString().toStdString());
            }
            settings.endArray();
            settings.endGroup();
            //check if monitoring is started
            if(mds_address_size &&
                    !ChaosMetadataServiceClient::getInstance()->monitoringIsStarted()) {
                //try to start it
                on_actionEnable_Monitoring_triggered();
            }
            ChaosMetadataServiceClient::getInstance()->reconfigureMonitor();
        } else {
            //mds are not configured so we need to configure it
            on_actionPreferences_triggered();
        }
    }catch(...) {

    }
}
Example #10
0
void Widget::loadSetting()
{
    QSettings setting;
    setting.beginGroup("GroupData");
    for(int i = 0;i<setting.childGroups().count();i++){
        _GroupIpList.insert(i+1,setting.value(QString("%1/IpAdd").arg(i+1)).toString());
//        qDebug()<<"loadsetting:"<<i+1<<setting.value(QString("%1/IpAdd").arg(i+1)).toString();
    }
    setting.endGroup();
//foreach(QString str,_GroupIpList){
//qDebug()<<"QMapList:"<<str<<__LINE__;
//}
//    QMap<int, QString>::const_iterator i;
//    for( i=_GroupIpList.constBegin(); i!=_GroupIpList.constEnd(); ++i){
//        int num = i.key();
//        if("192.168.1.100" = i.value())
//            qDebug() << num <<"        " << i.value();
//    }

    setting.beginGroup("AppData/Operate");
    _DlyGlobalTime = setting.value("DelayTime",300).toInt();
    _flagAppStartFirst = setting.value("FirstStart",true).toBool();
    setting.endGroup();
//    emit sendConnectSocket(QMap<int,QString>);
}
Example #11
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),system_tray(NULL),preBtnPut(NULL),_flagCloseWin(false),TimerGlbDly(NULL),_flagAppStartFirst(false),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    defaultSetting();
    set_ui();

    connect(ui->btnSetting,&QToolButton::clicked,[=]{
        FormSetting *settingform = setupSettingForm();
        if(settingform)
            settingform->isHidden()?settingform->show():settingform->activateWindow();
    });

    //default timer to show current time
    QTimer *time = new QTimer(this);
    time->start(1000);
    connect(time,&QTimer::timeout,[=]{
        ui->states_group_timeSet->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
    });

    if(_flagAppStartFirst){//程序第一次启动时弹出设置对话框
        setupSettingForm();
    }else{
        //NOTE:检测是否有分组记录,否也应弹出
        QSettings setting;
        setting.beginGroup("GroupData");
        if(!setting.childGroups().count())
            setupSettingForm();
        setting.endGroup();
        //end
    }
}
QStringList QgsOWSConnection::connectionList( const QString & theService )
{
  QSettings settings;
  //settings.beginGroup( "/Qgis/connections-wms" );
  settings.beginGroup( "/Qgis/connections-" + theService.toLower() );
  return settings.childGroups();
}
Example #13
0
QList<QPair<QUuid,QString> >
UserListItem::loadItems()
{
  QList<QPair<QUuid,QString> > result;

  QSettings settings;
  settings.beginGroup(KNOWN_USERS_GROUP);
  for (const QString& str_uuid : settings.childGroups())
    {
      QUuid uuid(str_uuid);
      if (uuid.isNull())
        continue;

      settings.beginGroup(str_uuid);
      QString name = settings.value(USER_NAME).toString().trimmed();
      settings.endGroup();

      if (name.isEmpty())
        continue;

      result.append(QPair<QUuid,QString>(uuid, name));
    }

  return result;
}
Example #14
0
editSimulators::editSimulators(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::editSimulators)
{

    edited = false;

    ui->setupUi(this);

    ui->buttonBox->setFocusPolicy(Qt::NoFocus);

    connect(ui->addEnv, SIGNAL(clicked()), this, SLOT(addEnvVar()));

    // load existing simulators:
    QSettings settings;

    settings.beginGroup("simulators");
    QStringList sims = settings.childGroups();
    for (int i = 0; i < sims.size(); ++i) {
        this->ui->comboBox->addItem(sims[i]);
        if (i == 0) selectSimulator(sims[0]);
    }
    settings.endGroup();

    ((QHBoxLayout *) ui->scrollAreaWidgetContents->layout())->removeWidget(ui->addEnv);
    ((QHBoxLayout *) ui->scrollAreaWidgetContents->layout())->addWidget(ui->addEnv);

    // connect up comboBox
    connect(ui->comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(selectSimulator(QString)));
    // connect up buttons
    connect(this->ui->findFile, SIGNAL(clicked()), this, SLOT(getScript()));
    connect(this->ui->addSim, SIGNAL(clicked()), this, SLOT(getNewSimName()));

    // accept
    connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(applyChanges()));

    // cancel
    connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(cancelChanges()));

    //close
    connect(ui->buttonBox_2->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));

    // change path
    connect(ui->scriptLineEdit, SIGNAL(editingFinished()), this, SLOT(changeScript()));

    // change if we save large connections as binary data
    bool writeBinary = settings.value("fileOptions/saveBinaryConnections", "error").toBool();
    ui->save_as_binary->setChecked(writeBinary);
    connect(ui->save_as_binary, SIGNAL(toggled(bool)), this, SLOT(saveAsBinaryToggled(bool)));

    // change level of detail box
    int lod = settings.value("glOptions/detail", 5).toInt();
    ui->openGLDetailSpinBox->setValue(lod);
    connect(ui->openGLDetailSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setGLDetailLevel(int)));

    // TESTING:
    //connect(ui->test, SIGNAL(clicked()), this, SLOT(testFunc()));

    redrawEnvVars();
}
Example #15
0
	void ColorThemeEngine::FillQML (QSettings& settings)
	{
		QMLColors_.clear ();

		for (const auto& group : settings.childGroups ())
		{
			settings.beginGroup (group);
			auto& hash = QMLColors_ [group];
			for (const auto& key : settings.childKeys ())
				hash [key] = ParseColor (settings.value (key));
			settings.endGroup ();
		}

		auto fixup = [this, &settings] (const QString& section,
				const QString& name, const QString& fallback) -> void
		{
			auto& sec = QMLColors_ [section];
			if (sec.contains (name))
				return;

			qWarning () << Q_FUNC_INFO
					<< settings.fileName ()
					<< "lacks"
					<< (section + "_" + name)
					<< "; falling back to"
					<< fallback;
			sec [name] = sec [fallback];
		};

		fixup ("ToolButton", "HoveredTopColor", "SelectedTopColor");
		fixup ("ToolButton", "HoveredBottomColor", "SelectedBottomColor");
	}
void QgsPasteTransformations::restoreTransfers( const QString& sourceLayerName,
    const QString& destinationLayerName )
{
  QgsDebugMsg( "entered." );
  QSettings settings;
  QString baseKey = "/Qgis/paste-transformations";             // TODO: promote to static member

  settings.beginGroup( baseKey );
  QStringList sourceLayers = settings.childGroups();

  for ( QStringList::Iterator it  = sourceLayers.begin();
        it != sourceLayers.end();
        ++it )
  {
    QgsDebugMsg( QString( "testing source '%1' with '%2'." ).arg(( *it ) ).arg( sourceLayerName ) );
    if (( sourceLayerName == ( *it ) ) )
    {
      // Go through destination layers defined for this source layer.
      settings.beginGroup( *it );
      QStringList destinationLayers = settings.childGroups();
      for ( QStringList::Iterator it2  = destinationLayers.begin();
            it2 != destinationLayers.end();
            ++it2 )
      {
        QgsDebugMsg( QString( "testing destination '%1' with '%2'." ).arg(( *it2 ) ).arg( destinationLayerName ) );
        if (( destinationLayerName == ( *it2 ) ) )
        {
          QgsDebugMsg( "going through transfers." );
          // Go through Transfers for this source/destination layer pair.
          settings.beginGroup( *it2 );
          QStringList transfers = settings.childKeys();
          for ( QStringList::Iterator it3  = transfers.begin();
                it3 != transfers.end();
                ++it3 )
          {
            QgsDebugMsg( QString( "setting transfer for %1." ).arg(( *it3 ) ) );
            QString destinationField = settings.value( *it3 ).toString();
            addTransfer(( *it3 ), destinationField );
          }
          settings.endGroup();
        }
      }
      settings.endGroup();
    }
  }
  settings.endGroup();
}
Example #17
0
// load this luaconfig from QSettings data
void LuaConfig::fromSettings(QSettings &mySettings)
{
    LuaTriggerBase* atrigger;
    QStringList     childGroups;
    QString         childGroup;
    QString         className;

    // first get description and stuff from ini
    _description    = mySettings.value(INI_KEY_DESC, "").toString();
    _enableScript   = mySettings.value(INI_KEY_ENABLED, false).toBool();
    _lastTriggered  = mySettings.value(INI_KEY_LAST_TRIGGERED, QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0))).toDateTime();

    _constraint     = mySettings.value(INI_KEY_CONSTRAINT_ENABLED, false).toBool();
    _constraintFrom = mySettings.value(INI_KEY_CONSTRAINT_FROM, QTime()).toTime();
    _constraintTo   = mySettings.value(INI_KEY_CONSTRAINT_TO, QTime()).toTime();


    // then fetch all groups of ini file
    childGroups = mySettings.childGroups();

    // for all groups of ini file do ...
    foreach (childGroup, childGroups)
    {
        // open current group
        mySettings.beginGroup(childGroup);

        // is it a trigger?
        if (childGroup.startsWith(INI_KEY_TRIGGER))
        {
            className = mySettings.value(INI_KEY_CLASSNAME).toString();
            if(className == "")
            {
                std::cerr << "[Lua] LuaConfig::fromSettings() : empty trigger classname found in : [" << childGroup.toStdString() << "]" << std::endl;
                continue;
            }

            if (     className == LUA_TRIGGER_TIMER_INTERVAL) { atrigger = new LuaTriggerTimerInterval(); }
            else if (className == LUA_TRIGGER_STARTUP)        { atrigger = new LuaTriggerStartup(); }
            else if (className == LUA_TRIGGER_SHUTDOWN)       { atrigger = new LuaTriggerShutdown(); }
            else if (className == LUA_TRIGGER_ONCE)           { atrigger = new LuaTriggerOnce(); }
            else if (className == LUA_TRIGGER_EVENT)          { atrigger = new LuaTriggerEvent(); }
            else
            {
                std::cerr << "[Lua] LuaConfig::fromSettings() : unknown trigger class : '" << className.toStdString() << "' found in [" << childGroup.toStdString() << "]" << std::endl;
                atrigger = 0;
            }

            // if a trigger has been created, tell him to load his parms
            // from mySettings now and add him to our trigger list
            if (atrigger != 0)
            {
                std::cerr << "[Lua] LuaConfig::fromSettings() : trigger : '" << className.toStdString() << "' added." << std::endl;
                atrigger->fromSettings(mySettings);
                addTrigger(atrigger);
            }
        }
        // close current group
        mySettings.endGroup();
    }
bool HistoryTableModel::insertRows(int row, int count,
                                   const QModelIndex & parent)
{
    TRACE

    int max = count;
    int i = 0;
    QStringList newRow = QStringList();
    if (!HistoryProxy::instance()) {
        qWarning() << QString("[HistoryTableModel] No connection to %1")
                      .arg(HistoryProxy::staticInterfaceName());
        return false; //abort
    }
    QSettings *cache = HistoryProxy::instance()->cache();

    cache->beginGroup("CallHistory");
    QStringList events = cache->childGroups();

    if (events.size() == 0) {
        qWarning() << QString("[HistoryTableModel] Empty call history log!");
        cache->endGroup();
        return true;
    }

    // Special case to just load all data from cache
    if (max < 0)
        max = events.size();

    beginInsertRows(parent, row, row + max - 1);
    foreach (QString key, events) {

        // Stop before end of cache if we hit count
        if (i > max) break;

        cache->beginGroup(key);

        uint start = cache->value("Start").toUInt(); // Call start time
        uint end   = cache->value("End").toUInt();   // Call end time

        // add the column data to a new row
        newRow.clear();
        newRow << cache->value("LineID").toString(); // Phone Number
        newRow << cache->value("Type").toString();   // Call direction type
        newRow << toOfonoString(start);              // Call start time
        newRow << toOfonoString(end);                // Call end time

#ifdef WANT_DEBUG
        qDebug() << QString("[HistoryTableModel] Appending row: %1")
                           .arg(newRow.join("\t"));
#endif
        // add the row data to the vector
        m_data.append(newRow);
        cache->endGroup();
        i++;
    }
    cache->endGroup();
    endInsertRows();
    return true;
}
Example #19
0
CloudDef::CloudDef(QSettings& settings, QObject* parent) :
  PropSet(settings, parent)
{
  foreach (const QString& group, settings.childGroups()) {
    settings.beginGroup(group);
    _words << new PropSet(settings, this);
    settings.endGroup();
  }
}
/*!
	\overload
	\brief Load format data from a QSettings object
	\param s QSettings object from which data will be fetched
	\param ignoreNewIds whether unknown format identifiers should be ignored
	
	The QSettings object is assumed to be initialized properly and to
	point to a correct location.
	
	\note Previous content is not discarded
*/
void QFormatScheme::load(QSettings& s, bool ignoreNewIds)
{
	QString version = s.value("version").toString();
	
	if ( version < QFORMAT_VERSION )
	{
		qWarning("Format encoding version mismatch : [found]%s != [expected]%s",
				qPrintable(version),
				QFORMAT_VERSION);
		
		return;
	}
	
	s.beginGroup("data");
	
	QStringList l = s.childGroups();
	
	foreach ( QString id, l )
	{
		if ( ignoreNewIds && !m_formatKeys.contains(id) )
			continue;
		
		s.beginGroup(id);
		
		QFormat fmt;
		QStringList fields = s.childKeys();
		
		foreach ( QString field, fields )
		{
			QString value = s.value(field).toString();
			
			if ( field == "bold" )
				fmt.weight = bool_cast(value) ? QFont::Bold : QFont::Normal;
			else if ( field == "italic" )
				fmt.italic = bool_cast(value);
			else if ( field == "overline" )
				fmt.overline = bool_cast(value);
			else if ( field == "underline" )
				fmt.underline = bool_cast(value);
			else if ( field == "strikeout" )
				fmt.strikeout = bool_cast(value);
			else if ( field == "waveUnderline" )
				fmt.waveUnderline = bool_cast(value);
			else if ( field == "color" || field == "foreground" )
				fmt.foreground = QColor(value);
			else if ( field == "background" )
				fmt.background = QColor(value);
			else if ( field == "linescolor" )
				fmt.linescolor = QColor(value);
			
		}
		
		setFormat(id, fmt);
		s.endGroup();
	}
void HistoryTableModel::appendRows(QStringList keys)
{
    TRACE

    int max = 0;
    int i = 0;
    QStringList newRow = QStringList();

    if (!HistoryProxy::instance()) {
        qWarning() << QString("[HistoryTableModel] No connection to %1")
                      .arg(HistoryProxy::staticInterfaceName());
        return;
    }

    QSettings *cache = HistoryProxy::instance()->cache();

    cache->beginGroup("CallHistory");
    QStringList events = cache->childGroups();

    if (events.size() == 0) {
        qWarning() << QString("[HistoryTableModel] Empty call history log!");
        cache->endGroup();
        return;
    }

    // Special case to just load all data from cache
    max = keys.size();

    beginInsertRows(QModelIndex(), rowCount(), rowCount() + max - 1);
    foreach (QString key, keys) {

        //if (!cache->contains(key)) continue;  // Skip items not in cache

        cache->beginGroup(key);

        uint start = cache->value("Start").toUInt(); // Call start time
        uint end   = cache->value("End").toUInt();   // Call end time

        // add the column data to a new row
        newRow.clear();
        newRow << cache->value("LineID").toString(); // Phone Number
        newRow << cache->value("Type").toString();   // Call direction type
        newRow << toOfonoString(start);              // Call start time
        newRow << toOfonoString(end);                // Call end time

#ifdef WANT_DEBUG
        qDebug() << QString("[HistoryTableModel] Appending row: %1")
                           .arg(newRow.join("\t"));
#endif
        // add the row data to the vector
        m_data.append(newRow);
        cache->endGroup();
        i++;
    }
Example #22
0
void Widget::defaultSetting()
{ //test...2014-08-23
//    QSettings setting(QStandardPaths::writableLocation(QStandardPaths::DataLocation)+"/data/config.ini",QSettings::IniFormat);
    QSettings setting;
    setting.beginGroup("GroupData");
    for(int i = 0;i<setting.childGroups().count();i++){//TODO:test area.
        QString strip = setting.value(QString("%1/IpAdd").arg(setting.childGroups().at(i)),i>9?QString("192.168.1.1%1").arg(i):QString("192.168.1.10%1").arg(i)).toString();
        ui->combGroup->addItem(QString::number(i+1));
//        ui->combGroup->setItemText(i,strip);
        ui->combGroup->setItemData(i,strip);
    }
    setting.endGroup();

    for(int i=0;i<ui->combGroup->count();i++){
        _BarreStatus.insert(ui->combGroup->itemText(i).toInt(),
                            QPair<QPair<sendHead,sendHead>,bool>
                            (QPair<sendHead,sendHead>(sendHead(),sendHead()),true));
    }

    loadSetting();
}
Example #23
0
/*!
	\overload
	\brief Load format data from a QSettings object
	\param s QSettings object from which data will be fetched
	\param ignoreNewIds whether unknown format identifiers should be ignored
	
	The QSettings object is assumed to be initialized properly and to
	point to a correct location.
	
	\note Previous content is not discarded
*/
void QFormatScheme::load(QSettings& s, bool ignoreNewIds)
{
	if (s.childKeys().isEmpty() && s.childGroups().isEmpty()) return;

	QString version = s.value("version").toString();

	if ( version < QFORMAT_VERSION )
	{
		qWarning("Format encoding version mismatch : [found]%s != [expected]%s",
				qPrintable(version),
				QFORMAT_VERSION);
		
		return;
	}
	
	s.beginGroup("data");
	
	QStringList l = s.childGroups();
	
	foreach ( QString id, l )
	{
		if ( ignoreNewIds && !m_formatKeys.contains(id) )
			continue;
		
		s.beginGroup(id);
		
		QFormat fmt;
		QStringList fields = s.childKeys();
		
		foreach ( QString field, fields )
		{
			QString value = s.value(field).toString();
			setFormatOption(fmt, field, value);
			
		}
		fmt.setPriority(fmt.priority); //update priority if other values changed

		setFormat(id, fmt);
		s.endGroup();
	}
Example #24
0
void Storage::readGroups2Map(QVariantMap& target, const QString &file)
{
    target.clear();
    QSettings* limits = new QSettings (file, QSettings::IniFormat, this);
    QStringList groups = limits->childGroups();
    if (groups.count()) {
        foreach (const QString& group, groups) {
            QVariantMap variantMap;
            limits->beginGroup(group);
            QStringList keylist = limits->allKeys();
            foreach (const QString& key, keylist) {
                variantMap.insert(key, limits->value(key));
            }
Example #25
0
QSettings* getCampTeamFile(QString & campaignName, QString & teamName)
{
    QSettings* teamfile = new QSettings(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
    teamfile->setIniCodec("UTF-8");
    // if entry not found check if there is written without _
    // if then is found rename it to use _
    QString spaceCampName = campaignName;
    spaceCampName = spaceCampName.replace(QString("_"),QString(" "));
    if (!teamfile->childGroups().contains("Campaign " + campaignName) &&
            teamfile->childGroups().contains("Campaign " + spaceCampName)){
        teamfile->beginGroup("Campaign " + spaceCampName);
        QStringList keys = teamfile->childKeys();
        teamfile->endGroup();
        for (int i=0;i<keys.size();i++) {
            QVariant value = teamfile->value("Campaign " + spaceCampName + "/" + keys[i]);
            teamfile->setValue("Campaign " + campaignName + "/" + keys[i], value);
        }
        teamfile->remove("Campaign " + spaceCampName);
    }

    return teamfile;
}
Example #26
0
    void LogManager::doStartup()
    {
        QMutexLocker locker(&instance()->mObjectGuard);

        // Override
        QString default_value = QLatin1String("false");
        QString value = InitialisationHelper::setting(QLatin1String("DefaultInitOverride"),
                                                      default_value);
        if (value != default_value)
        {
            static_logger()->debug("DefaultInitOverride is set. Aborting default initialisation");
            return;
        }

        // Configuration using setting Configuration
        value = InitialisationHelper::setting(QLatin1String("Configuration"));
        if (QFile::exists(value))
        {
            static_logger()->debug("Default initialisation configures from file '%1' specified by Configure", value);
            PropertyConfigurator::configure(value);
            return;
        }

        // Configuration using setting
        if (QCoreApplication::instance())
        {
            const QLatin1String log4qt_group("Log4Qt");
            const QLatin1String properties_group("Properties");
            QSettings s;
            s.beginGroup(log4qt_group);
            if (s.childGroups().contains(properties_group))
            {
                const QString group(QLatin1String("Log4Qt/Properties"));
                static_logger()->debug("Default initialisation configures from setting '%1/%2'", log4qt_group, properties_group);
                s.beginGroup(properties_group);
                PropertyConfigurator::configure(s);
                return;
            }
        }

        // Configuration using default file
        const QString default_file(QLatin1String("log4qt.properties"));
        if (QFile::exists(default_file))
        {
            static_logger()->debug("Default initialisation configures from default file '%1'", default_file);
            PropertyConfigurator::configure(default_file);
            return;
        }

        static_logger()->debug("Default initialisation leaves package unconfigured");
    }
QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::WindowFlags fl )
    : QDialog( parent, fl )
{
  setupUi( this );

  QSettings settings;
  restoreGeometry( settings.value( "/Windows/NewSpatiaLiteLayer/geometry" ).toByteArray() );

  mAddAttributeButton->setIcon( QgsApplication::getThemeIcon( "/mActionNewAttribute.png" ) );
  mRemoveAttributeButton->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteAttribute.png" ) );
  mTypeBox->addItem( tr( "Text data" ), "text" );
  mTypeBox->addItem( tr( "Whole number" ), "integer" );
  mTypeBox->addItem( tr( "Decimal number" ), "real" );

  mPointRadioButton->setChecked( true );
  // Populate the database list from the stored connections
  settings.beginGroup( "/SpatiaLite/connections" );
  QStringList keys = settings.childGroups();
  QStringList::Iterator it = keys.begin();
  mDatabaseComboBox->clear();
  while ( it != keys.end() )
  {
    // retrieving the SQLite DB name and full path
    QString text = settings.value( *it + "/sqlitepath", "###unknown###" ).toString();
    mDatabaseComboBox->addItem( text );
    ++it;
  }
  settings.endGroup();

  mOkButton = buttonBox->button( QDialogButtonBox::Ok );
  mOkButton->setEnabled( false );

  // Set the SRID box to a default of WGS84
  QgsCoordinateReferenceSystem srs;
  srs.createFromOgcWmsCrs( settings.value( "/Projections/layerDefaultCrs", GEO_EPSG_CRS_AUTHID ).toString() );
  srs.validate();
  mCrsId = srs.authid();
  leSRID->setText( srs.authid() + " - " + srs.description() );

  pbnFindSRID->setEnabled( mDatabaseComboBox->count() );

  connect( mNameEdit, SIGNAL( textChanged( QString ) ), this, SLOT( nameChanged( QString ) ) );
  connect( mAttributeView, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );
  connect( leLayerName, SIGNAL( textChanged( const QString& text ) ), this, SLOT( checkOk() ) );
  connect( checkBoxPrimaryKey, SIGNAL( clicked() ), this, SLOT( checkOk() ) );

  mAddAttributeButton->setEnabled( false );
  mRemoveAttributeButton->setEnabled( false );

}
Example #28
0
void
App::unsetPreference(const std::string &key)
{
    QSettings settings;
    std::string keyrep(getKeyRepr(key));
    QString qkeyrep(keyrep.c_str());
    settings.beginGroup(qkeyrep);
    if ((settings.childGroups().length() != 0) || (settings.childKeys().length() != 0)) {
        settings.setValue("", "");
    } else {
        settings.remove("");
    }
    settings.endGroup();
    settings.sync();
}
Example #29
0
void QgsOpenVectorLayerDialog::populateConnectionList()
{
    QSettings settings;
    settings.beginGroup( "/" + cmbDatabaseTypes->currentText() + "/connections" );
    QStringList keys = settings.childGroups();
    QStringList::Iterator it = keys.begin();
    cmbConnections->clear();
    while ( it != keys.end() )
    {
        cmbConnections->addItem( *it );
        ++it;
    }
    settings.endGroup();
    setConnectionListPosition();
}
QList<ToolChain *> MsvcToolChainFactory::autoDetect()
{
    QList<ToolChain *> results;

    // 1) Installed SDKs preferred over standalone Visual studio
    const QSettings sdkRegistry(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows"),
                                QSettings::NativeFormat);
    const QString defaultSdkPath = sdkRegistry.value(QLatin1String("CurrentInstallFolder")).toString();
    if (!defaultSdkPath.isEmpty()) {
        foreach (const QString &sdkKey, sdkRegistry.childGroups()) {
            const QString name = sdkRegistry.value(sdkKey + QLatin1String("/ProductName")).toString();
            const QString version = sdkRegistry.value(sdkKey + QLatin1String("/ProductVersion")).toString();
            const QString folder = sdkRegistry.value(sdkKey + QLatin1String("/InstallationFolder")).toString();
            if (folder.isEmpty())
                continue;

            QDir dir(folder);
            if (!dir.cd(QLatin1String("bin")))
                continue;
            QFileInfo fi(dir, QLatin1String("SetEnv.cmd"));
            if (!fi.exists())
                continue;

            QList<ToolChain *> tmp;
            tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::x86),
                                         findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::x86, version),
                                         fi.absoluteFilePath(), QLatin1String("/x86"), true));
            // Add all platforms, cross-compiler is automatically selected by SetEnv.cmd if needed
            tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::amd64),
                                         findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::amd64, version),
                                         fi.absoluteFilePath(), QLatin1String("/x64"), true));
            tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::x86_amd64),
                                         findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::x86_amd64, version),
                                         fi.absoluteFilePath(), QLatin1String("/x64"), true));
            tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::ia64),
                                         findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::ia64, version),
                                         fi.absoluteFilePath(), QLatin1String("/ia64"), true));
            tmp.append(new MsvcToolChain(generateDisplayName(name, MsvcToolChain::WindowsSDK, MsvcToolChain::x86_ia64),
                                         findAbiOfMsvc(MsvcToolChain::WindowsSDK, MsvcToolChain::x86_ia64, version),
                                         fi.absoluteFilePath(), QLatin1String("/ia64"), true));
            // Make sure the default is front.
            if (folder == defaultSdkPath)
                results = tmp + results;
            else
                results += tmp;
        } // foreach
    }