void ProfileManager::setProfiles(const QList<Profile*>& profiles) { QList<Profile*> currentProfiles = this->profiles; QList<Profile*>::const_iterator it; for (it = currentProfiles.begin() ; it != currentProfiles.end() ; it++) { Profile* profile = *it; if (!profiles.contains(profile)) { if (getCurrentProfile() == profile) { setCurrentProfile(NULL); } removeProfile(profile); delete profile; } } for (it = profiles.begin() ; it != profiles.end() ; it++) { Profile* profile = *it; if (!currentProfiles.contains(profile)) { addProfile(profile); } } }
/*! \fn OptionsDialog::loadProfiles() */ void OptionsDialog::loadProfiles() { QStringList profiles = getSetting("profiles").toStringList(); profilesList->clear(); profilesList->addItems(profiles); setCurrentProfile(); profileSelectionChanged(); }
bool ProfileManager::removeProfile(Profile* profile) { profiles.removeOne(profile); if (getCurrentProfile() == profile) { if (profiles.size() == 0) { setCurrentProfile(NULL); } else { setCurrentProfile(profiles[0]); } } emit profileRemoved(profile); return true; }
CulistGui::CulistGui(QWidget *parent) : QMainWindow(parent), ui(new Ui::CulistGui), _tcpConnection(0), _tcpServerConnection(0), _actAsProxyServer(false), _dataToSendCurIdx(0), _currentSendAttempt(0), _dataSending(false) { ui->setupUi(this); PERSISTENCE_INIT("heinitz-it","CULIST"); PERSISTENT("WindowPosition", this, "geometry") PERSISTENT("ClientModeServerHost", ui->eClientModeSrvAddr, "text"); PERSISTENT("ClientModeServerPort", ui->eClientModeSrvPort, "text"); PERSISTENT("ServerModeServerHost", ui->eServerModeSrvPort, "text"); on_actionClear_All_triggered(); ui->actionStop_Listening->setEnabled(false); ui->actionDisconnect->setEnabled(false); ui->actionSave_Project->setEnabled(false); ui->actionSave_Project_As->setEnabled(false); /*ui->lvProfileRecords->setModel(&_profileRecords); _profileRecords.setColumnCount(1); _profileRecords.setHorizontalHeaderLabels(QStringList()<<tr("Include/Exclude Record Names")); */ ASTMFactory::instance().init(); ui->cbCurrentProfile->addItems( ASTMFactory::instance().profiles() ); setCurrentProfile( "ASTM_E1394_E97" ); _sendDataTimer = new QTimer(this); _sendDataTimer->setSingleShot(true); _sendDataTimer->setInterval(3000);//TODO configurable connect( _sendDataTimer, SIGNAL(timeout()), this, SLOT(processSendDataTimeout()) ); ui->trvEditProfile->setModel( &_profileFields ); createToolBars(); _winTitleBase = "CULIST. Version:"CULIST_VERSION"; Copyright 2013, Valentin Heinitz"; this->setWindowTitle(_winTitleBase); }
EnvironmentSelectionWidget::EnvironmentSelectionWidget( QWidget *parent ) : QWidget( parent ), d( new EnvironmentSelectionWidgetPrivate( this ) ) { // Taken from kdelibs/kdeui/dialogs/kconfigdialogmanager.cpp (no idea whether this is documented) // Commits d44186bce4670d2985fb6aba8dba59bbd2c4c77a and 8edc1932ecc62370d9a31836dfa9b2bd0175a293 // introduced a regression in kdelibs to fix problems running some apps against Qt4.8. Unfortunately // this fix breaks exactly our use-case, which is to store the text-value in kconfig instead of // the index even though the combobox is editable. Since that change the special combobox-code in // kconfigdialogmanager.cpp is run before check a user-property and hence our user-property is // ignored. Setting this special kcfg_property to the name of our user-property again overrides // the hardcoded combobox-behaviour - until the next one breaks things in kdelibs :| setProperty("kcfg_property", QByteArray("currentProfile")); setLayout( new QHBoxLayout( this ) ); layout()->addWidget( d->comboBox ); layout()->setMargin( 0 ); setCurrentProfile( QString() ); // select the default profile connect(d->comboBox, &QComboBox::currentTextChanged, this, &EnvironmentSelectionWidget::currentProfileChanged); }
void EnvironmentSelectionWidget::reconfigure() { QString selectedProfile = currentProfile(); d->model->reload(); setCurrentProfile( d->model->reloadSelectedItem( selectedProfile ) ); }
void OptionsDetailed::loadCustomProfileButtonClicked() { const QString profile = qobject_cast<QAction*>(QObject::sender())->text().replace("&",""); setCurrentProfile( profile ); }
void ProfileManager::eventLoopStarted() { QSettings settings; for (int i = 0 ; true ; i++) { if (!settings.contains(QString("profile%1/name").arg(i))) { break; } Profile* profile = new Profile(settings.value(QString("profile%1/name").arg(i)).toString()); GameInfo::VersionMode ver; QString verStr = settings.value(QString("profile%1/version").arg(i)).toString(); if (verStr == "gta3") ver = GameInfo::GTAIII; else if (verStr == "gtavc") ver = GameInfo::GTAVC; else ver = GameInfo::GTASA; GameInfo info(ver, File(settings.value(QString("profile%1/root").arg(i)).toString().toLocal8Bit().constData())); profile->setGameInfo(info); for (int j = 0 ; true ; j++) { if (!settings.contains(QString("profile%1/resource%2").arg(i).arg(j))) { break; } QString resource = settings.value(QString("profile%1/resource%2").arg(i).arg(j)).toString(); profile->addResource(File(resource.toLocal8Bit().constData())); } for (int j = 0 ; true ; j++) { if (!settings.contains(QString("profile%1/search_resource%2").arg(i).arg(j))) { break; } QString resource = settings.value(QString("profile%1/search_resource%2").arg(i).arg(j)).toString(); profile->addSearchResource(File(resource.toLocal8Bit().constData())); } for (int j = 0 ; true ; j++) { if (!settings.contains(QString("profile%1/dat_file%2").arg(i).arg(j))) { break; } QString datFile = settings.value(QString("profile%1/dat_file%2").arg(i).arg(j)).toString(); profile->addDATFile(File(datFile.toLocal8Bit().constData())); } addProfile(profile); } int currentProfileIdx = settings.value("main/current_profile", -1).toInt(); if (currentProfileIdx != -1) { setCurrentProfile(getProfile(currentProfileIdx)); } else { setCurrentProfile(NULL); } emit profilesLoaded(); }