コード例 #1
0
void TestSettingsWidget::backup()
{
    SettingsWidget *    settingsWidget = new SettingsWidget();
    Ui::SettingsWidget *ui             = settingsWidget->_ui;

    VISUAL_INIT(settingsWidget);

    // Switch to Backup tab.
    ui->settingsToolbox->setCurrentIndex(1);
    VISUAL_WAIT;

    // Toggle some options.
    ui->preservePathsCheckBox->setChecked(false);
    ui->skipNoDumpCheckBox->setChecked(true);
    ui->simulationCheckBox->setChecked(true);
    VISUAL_WAIT;

    // Check saved settings.  These are ready due to not using setText().
    TSettings settings;

    QVERIFY(settings.value("tarsnap/preserve_pathnames", "").toBool() == false);
    QVERIFY(settings.value("app/skip_nodump", "").toBool() == true);
    QVERIFY(settings.value("tarsnap/dry_run", "").toBool() == true);

    delete settingsWidget;
}
コード例 #2
0
ファイル: jobstabwidget.cpp プロジェクト: Tarsnap/tarsnap-gui
void JobsTabWidget::loadSettings()
{
    TSettings settings;

    if(settings.value("app/default_jobs_dismissed", false).toBool())
    {
        _ui->defaultJobs->hide();
        _ui->addJobButton->show();
    }
    else
    {
        _ui->defaultJobs->show();
        _ui->addJobButton->hide();
    }
}
コード例 #3
0
void TMapCentering::configure(TSettings &settings, const QString &section)
{
	settings.beginGroup(section);
	_zoomMax = settings.getValue("maxautozoom", 18).toInt();
	_elasticityStartZoom = settings.getValue("elasticitystartzoom", 12).toInt();
	_elasticitySpeed = settings.getValue("elasticityspeed", 10).toInt();
	_elasticityTopBorder = settings.getValue("elasticitytopborder", 130).toInt();
	_elasticityBottomBorder = settings.getValue("elasticitybottomborder", 80).toInt();
	_elasticityRightBorder = settings.getValue("elasticityrightborder", 80).toInt();
	_elasticityLeftBorder = settings.getValue("elasticityleftborder", 80).toInt();
	settings.endGroup();
}
コード例 #4
0
ファイル: jobstabwidget.cpp プロジェクト: Tarsnap/tarsnap-gui
void JobsTabWidget::addDefaultJobs()
{
    TSettings settings;
    for(const QString &path : DEFAULT_JOBS)
    {
        QDir dir(QDir::home());
        if(dir.cd(path))
        {
            JobPtr job(new Job());
            job->setName(dir.dirName());
            QList<QUrl> urls;
            urls << QUrl::fromUserInput(dir.canonicalPath());
            job->setUrls(urls);
            job->save();
            _ui->jobDetailsWidget->jobAdded(job);
        }
    }
    settings.setValue("app/default_jobs_dismissed", true);
    _ui->defaultJobs->hide();
    _ui->addJobButton->show();
}
コード例 #5
0
void TTraceRecorder::configure(TSettings &settings, const QString &section)
{
	settings.beginGroup(section);

	_dir = settings.getValue("recorddir", "/media/card/NeronGPS/traces/records").toString();
	_tmpDir = settings.getValue("tempdir", "/media/card/NeronGPS/traces/temp").toString();

	bool record = settings.getValue("autorecord", "true").toBool();

	settings.endGroup();

	QDir::current().mkpath(_dir);
	QDir::current().mkpath(_tmpDir);

	if(record) {
		QMessageBox dialog(QMessageBox::Question, "Auto-recording enabled", "Start recording?", QMessageBox::Yes | QMessageBox::No);
		if(dialog.exec() == QMessageBox::Yes) {
			slotRecord(true);
		}
	}
}
コード例 #6
0
ファイル: keyboard.cpp プロジェクト: idaohang/NeronGPS
QStringList TKeyboard::getKeyboards(TSettings &settings, const QString &section)
{
	QStringList keyboards;

	settings.beginGroup(section);

	if(!settings.contains("keyboard1")) {
		keyboards += settings.getValue("keyboard1", "a b c d e  f g h i j  k l m n o  p q r s t  u v w x y  z SPACE <- CAPS ALT").toString();
		keyboards += settings.getValue("keyboard2", "1 2 3 4 5  6 7 8 9 0  ( ) [ ] {  } + - = _  / % * ! @  $ SPACE <- CAPS ALT").toString();
	} else {
		int i = 1;
		QString num = QString::number(i);

		while(settings.contains("keyboard" + num)) {
			keyboards += settings.getValue("keyboard" + num, "").toString();
			i++;
			num = QString::number(i);
		}
	}

	settings.endGroup();

	int i;
	for(i = 0; i < keyboards.size(); i ++) {
		keyboards[i] = prepareLayoutString(keyboards[i]);
	}

	return keyboards;
}
コード例 #7
0
void TestSettingsWidget::application()
{
    SettingsWidget *    settingsWidget = new SettingsWidget();
    Ui::SettingsWidget *ui             = settingsWidget->_ui;

    VISUAL_INIT(settingsWidget);

    // Switch to Application tab.
    ui->settingsToolbox->setCurrentIndex(2);
    VISUAL_WAIT;

    // Toggle some options.
    ui->notificationsCheckBox->setChecked(false);
    VISUAL_WAIT;

    // Check saved settings.  These are ready due to not using setText().
    TSettings settings;

    QVERIFY(settings.value("app/notifications", "").toBool() == false);

    delete settingsWidget;
}
コード例 #8
0
void TTileServerDirect::configure(TSettings &settings, const QString &server, const QString &cache)
{
	QStringList serverNames;
	QString defaultServer;
	bool empty;

	settings.beginGroup(server);
	empty = !settings.contains("httpservers");
	settings.endGroup();

	if(empty) {
		defaultServer = TTileHttpName::initDefault(settings);
	}

	settings.beginGroup(server);
	serverNames = settings.getValue("httpservers", defaultServer).toStringList();
	_online = settings.getValue("startonline", true).toBool();
	settings.endGroup();

	_http.configure(settings, serverNames);
	_container.configure(settings, cache);
}
コード例 #9
0
ファイル: jobstabwidget.cpp プロジェクト: Tarsnap/tarsnap-gui
JobsTabWidget::JobsTabWidget(QWidget *parent)
    : QWidget(parent), _ui(new Ui::JobsTabWidget)
{
    // Ui initialization
    _ui->setupUi(this);
    _ui->jobListWidget->setAttribute(Qt::WA_MacShowFocusRect, false);
    _ui->jobDetailsWidget->hide();
    _ui->jobsFilterFrame->hide();

    // "Default jobs" handling
    connect(_ui->sureButton, &QPushButton::clicked, this,
            &JobsTabWidget::addDefaultJobs);
    connect(_ui->dismissButton, &QPushButton::clicked, [&]() {
        TSettings settings;
        settings.setValue("app/default_jobs_dismissed", true);
        _ui->defaultJobs->hide();
        _ui->addJobButton->show();
    });

    // Messages between widgets on this tab
    connect(_ui->addJobButton, &QToolButton::clicked, this,
            &JobsTabWidget::addJobClicked);
    connect(_ui->actionAddJob, &QAction::triggered, this,
            &JobsTabWidget::addJobClicked);

    // Connections from the JobDetailsWidget
    connect(_ui->jobDetailsWidget, &JobWidget::collapse, this,
            &JobsTabWidget::hideJobDetails);
    connect(_ui->jobDetailsWidget, &JobWidget::jobAdded, this,
            &JobsTabWidget::displayJobDetails);
    connect(_ui->jobDetailsWidget, &JobWidget::enableSave, _ui->addJobButton,
            &QToolButton::setEnabled);

    // Connections from the JobDetailsWidget that get forwarded on
    connect(_ui->jobDetailsWidget, &JobWidget::jobAdded, this,
            &JobsTabWidget::jobAdded);
    connect(_ui->jobDetailsWidget, &JobWidget::inspectJobArchive, this,
            &JobsTabWidget::displayInspectArchive);
    connect(_ui->jobDetailsWidget, &JobWidget::restoreJobArchive, this,
            &JobsTabWidget::restoreArchive);
    connect(_ui->jobDetailsWidget, &JobWidget::deleteJobArchives, this,
            &JobsTabWidget::deleteArchives);
    connect(_ui->jobDetailsWidget, &JobWidget::backupJob, this,
            &JobsTabWidget::backupJob);
    connect(_ui->jobDetailsWidget, &JobWidget::findMatchingArchives, this,
            &JobsTabWidget::findMatchingArchives);

    // Connections to the JobDetailsWidget
    connect(this, &JobsTabWidget::matchingArchives, _ui->jobDetailsWidget,
            &JobWidget::updateMatchingArchives);

    // Connections from the JobListWidget
    connect(_ui->jobListWidget, &JobListWidget::displayJobDetails, this,
            &JobsTabWidget::displayJobDetails);
    connect(_ui->jobListWidget, &JobListWidget::backupJob, this,
            &JobsTabWidget::backupJob);
    connect(_ui->jobListWidget, &JobListWidget::restoreArchive, this,
            &JobsTabWidget::restoreArchive);
    connect(_ui->jobListWidget, &JobListWidget::deleteJob, this,
            &JobsTabWidget::deleteJob);
    connect(_ui->jobListWidget, &JobListWidget::customContextMenuRequested,
            this, &JobsTabWidget::showJobsListMenu);

    // Connections to the JobListWidget
    connect(this, &JobsTabWidget::backupSelectedItems, _ui->jobListWidget,
            &JobListWidget::backupSelectedItems);
    connect(this, &JobsTabWidget::deleteSelectedItem, _ui->jobListWidget,
            &JobListWidget::deleteSelectedItem);
    connect(this, &JobsTabWidget::restoreSelectedItem, _ui->jobListWidget,
            &JobListWidget::restoreSelectedItem);
    connect(this, &JobsTabWidget::inspectSelectedItem, _ui->jobListWidget,
            &JobListWidget::inspectSelectedItem);

    // Jobs filter
    _ui->jobsFilterButton->setDefaultAction(_ui->actionFilterJobs);
    connect(_ui->actionFilterJobs, &QAction::triggered, [&]() {
        _ui->jobsFilterFrame->setVisible(!_ui->jobsFilterFrame->isVisible());
        if(_ui->jobsFilter->isVisible())
            _ui->jobsFilter->setFocus();
        else
            _ui->jobsFilter->clearEditText();
    });
    connect(_ui->jobsFilter, &QComboBox::editTextChanged, _ui->jobListWidget,
            &JobListWidget::setFilter);
    connect(_ui->jobsFilter, static_cast<void (QComboBox::*)(int)>(
                                 &QComboBox::currentIndexChanged),
            this, [&]() { _ui->jobListWidget->setFocus(); });

    // Update filter results
    connect(_ui->jobListWidget, &JobListWidget::countChanged, this,
            [&](int total, int visible) {
                _ui->jobsCountLabel->setText(
                    tr("Jobs (%1/%2)").arg(visible).arg(total));
            });

    // Right-click context menu
    _ui->jobListWidget->addAction(_ui->actionJobBackup);
    _ui->jobListWidget->addAction(_ui->actionJobDelete);
    _ui->jobListWidget->addAction(_ui->actionJobInspect);
    _ui->jobListWidget->addAction(_ui->actionJobRestore);
    _ui->jobListWidget->addAction(_ui->actionFilterJobs);
    _ui->jobListWidget->addAction(_ui->actionJobBackup);
    _ui->jobListWidget->addAction(_ui->actionAddJob);

    // Connections to the JobListWidget
    connect(this, &JobsTabWidget::jobList, _ui->jobListWidget,
            &JobListWidget::setJobs);
    connect(this, &JobsTabWidget::jobAdded, _ui->jobListWidget,
            &JobListWidget::addJob);
    connect(this, &JobsTabWidget::jobInspectByRef, _ui->jobListWidget,
            &JobListWidget::inspectJobByRef);

    connect(_ui->actionJobBackup, &QAction::triggered, _ui->jobListWidget,
            &JobListWidget::backupSelectedItems);
    connect(_ui->actionJobDelete, &QAction::triggered, _ui->jobListWidget,
            &JobListWidget::deleteSelectedItem);
    connect(_ui->actionJobRestore, &QAction::triggered, _ui->jobListWidget,
            &JobListWidget::restoreSelectedItem);
    connect(_ui->actionJobInspect, &QAction::triggered, _ui->jobListWidget,
            &JobListWidget::inspectSelectedItem);

    //  addJobButton
    QMenu *addJobMenu = new QMenu(_ui->addJobButton);
    addJobMenu->addAction(_ui->actionBackupAllJobs);
    connect(_ui->actionBackupAllJobs, &QAction::triggered, _ui->jobListWidget,
            &JobListWidget::backupAllJobs);
    _ui->addJobButton->setMenu(addJobMenu);

    loadSettings();
    updateUi();
}
コード例 #10
0
int main(int argc, char ** argv) {
	TStopwatch comulativeWatch;
	comulativeWatch.Start(true);
	readInputs(argc,argv);
	cout<<"Currrent Subversion Revision: "<<SVN_REV<<endl;
	cout << "starting main loop.." << endl;
	RunListOK = ReadRunList();
	if(!RunListOK)exit(-1);
	TSystem* sys = gSystem;
	std::string currentDir = sys->pwd();
	for (unsigned int i = 0; i < RunParameters.size(); i++) {
		cout << RunParameters[i].getRunNumber();
		if (i+1 < RunParameters.size()) cout << ", ";
	}
	cout << " will be analysed.." << endl;

	if (!RunListOK) return 0;

	/**Start with Analyising, read RunParameteres of the Run and start analysis with that parameters
	 */
	for (unsigned int i = 0; i < RunParameters.size(); i++) {
		TStopwatch runWatch;
		runWatch.Start(true);
		RunParameters[i].Print();
		bool DO_ALIGNMENT = RunParameters[i].doAlignment();
		bool DO_ALIGNMENTANALYSIS = RunParameters[i].doAlignmentAnalysis();
		bool DO_TRANSPARENT_ANALYSIS = RunParameters[i].doTransparentAnalysis();

		time_t rawtime;
		tm *timestamp;
		time (&rawtime);
		timestamp = gmtime(&rawtime);

		ostringstream logfilename;
		logfilename << "analyse_log_" << RunParameters[i].getRunNumber() << "_" << timestamp->tm_year << "-" << timestamp->tm_mon << "-" << timestamp->tm_mday << "." << timestamp->tm_hour << "." << timestamp->tm_min << "." << timestamp->tm_sec << ".log";
		//
		//		FILE *log;
		//		log = freopen(logfilename.str().c_str(), "w", stdout);


		TSettings *settings = 0;
		cout<<"settings"<<endl;
		settings = new TSettings((TRunInfo*)&RunParameters[i]);

		TResults *currentResults =new TResults(settings);
		currentResults->Print();


		TRawEventSaver *eventSaver;
		eventSaver = new TRawEventSaver(settings);
		eventSaver->saveEvents(RunParameters[i].getEvents());
		delete eventSaver;

		//Calculate Pedestal
		sys->cd(currentDir.c_str());
		TPedestalCalculation* pedestalCalculation;
		pedestalCalculation = new TPedestalCalculation(settings);
		pedestalCalculation->calculateSlidingPedestals(RunParameters[i].getEvents());
		delete pedestalCalculation;

		if(RunParameters[i].doPedestalAnalysis()){
			sys->cd(currentDir.c_str());
			TAnalysisOfPedestal *analysisOfPedestal;
			analysisOfPedestal = new TAnalysisOfPedestal(settings);
			analysisOfPedestal->setResults(currentResults);
			analysisOfPedestal->doAnalysis(RunParameters[i].getEvents());
			delete analysisOfPedestal;
		}

		THTMLGenerator *htmlGen = new THTMLGenerator(settings);
		htmlGen->setFileGeneratingPath(settings->getAbsoluteOuputPath(true));
		htmlGen->setMainPath("./");
		htmlGen->setSubdirPath("");
		htmlGen->setFileName("overview.html");
		htmlGen->addSection("Pedestal","<a href=\"./pedestalAnalysis/pedestal.html\">PEDESTAL</a>");
		htmlGen->addSection("Clustering","<a href=\"./clustering/clustering.html\">CLUSTERING</a>");
		htmlGen->addSection("Selection","<a href=\"./selections/selection.html\">SELECTION</a>");
		htmlGen->addSection("Alignment","<a href=\"./alignment/alignment.html\">ALIGNMENT</a>");
		htmlGen->addSection("Landau","<a href=\"./selectionAnalysis/landaus.html\">LANDAU-DISTRIBUTIONS</a>");
		htmlGen->generateHTMLFile();
		delete htmlGen;

		sys->cd(currentDir.c_str());
		TClustering* clustering;
		clustering=new TClustering(settings);//int seedDetSigma=10,int hitDetSigma=7,int seedDiaSigma=5, int hitDiaSigma=3);
		clustering->ClusterEvents(RunParameters[i].getEvents());
		delete clustering;

		if(RunParameters[i].doClusterAnalysis()){
			sys->cd(currentDir.c_str());
			TAnalysisOfClustering* analysisClustering;
			analysisClustering = new TAnalysisOfClustering(settings);
			analysisClustering->setResults(currentResults);
			analysisClustering->doAnalysis(RunParameters[i].getEvents());
			delete analysisClustering;
		}

		sys->cd(currentDir.c_str());
		TSelectionClass* selectionClass = new TSelectionClass(settings);
		selectionClass->SetResults(currentResults);
		selectionClass->MakeSelection(RunParameters[i].getEvents());
		delete selectionClass;

		if(RunParameters[i].doSelectionAnalysis()){
			sys->cd(currentDir.c_str());
			TAnalysisOfSelection *analysisSelection=new TAnalysisOfSelection(settings);
			analysisSelection->doAnalysis(RunParameters[i].getEvents());
			delete analysisSelection;
		}

		if (DO_ALIGNMENT){
			sys->cd(currentDir.c_str());
			TAlignment *alignment = new TAlignment(settings);
			//			alignment->setSettings(settings);
			//alignment->PrintEvents(1511,1501);
			alignment->Align(RunParameters[i].getEvents());
			delete alignment;
		}

		if(DO_ALIGNMENTANALYSIS){
			sys->cd(currentDir.c_str());
			TAnalysisOfAlignment *anaAlignment;
			anaAlignment=new TAnalysisOfAlignment(settings);
			anaAlignment->doAnalysis(RunParameters[i].getEvents());
			delete anaAlignment;
		}

		if (DO_TRANSPARENT_ANALYSIS) {
			TTransparentAnalysis *transpAna;
			transpAna = new TTransparentAnalysis(settings);
			transpAna->setResults(currentResults);
			transpAna->analyze(RunParameters[i].getEvents(),RunParameters.at(i).getStartEvent());
			delete transpAna;
		}

		if (settings && settings->doTransparentAlignmnet()){
			sys->cd(currentDir.c_str());
			TAlignment *alignment = new TAlignment(settings,TSettings::transparentMode);
			alignment->createTransparentEventVectors(RunParameters[i].getEvents());
			//			alignment->setSettings(settings);
			//alignment->PrintEvents(1511,1501);
			alignment->Align(RunParameters[i].getEvents(),0,TAlignment::diaAlignment);
			delete alignment;

			TTransparentAnalysis *transpAna;
			transpAna = new TTransparentAnalysis(settings,TSettings::transparentMode);
			transpAna->setResults(currentResults);
			transpAna->analyze(RunParameters[i].getEvents(),RunParameters.at(i).getStartEvent());
			delete transpAna;
		}
		cout<<"PRINT RESULTS"<<endl;
		currentResults->Print();
		cout<<"SAVE RESULTS"<<endl;
//		currentResults->saveResults(settings->getResultsRootFilePath());
		TFile* file = new TFile (settings->getResultsRootFilePath().c_str(),"RECREATE");
		file->Print();
		file->ls();
		file->SetName("fileName");
		file->cd();
		cout<<"KEYS: "<<file->GetNkeys()<<endl;
		file->GetListOfKeys()->Print();
		cout<<"Write"<<endl;

		currentResults->Write("test");
		cout<<"CLOSE FILE"<<endl;
		file->Close();
//		if (currentResults){
//			cout<<"DELETE RESULTS"<<endl;
//			delete currentResults;
//			cout<<"#"<<endl;;
//		}
		cout<<"saved results..."<<endl;


		runWatch.Stop();
		cout<<"needed Time for Run "<<RunParameters[i].getRunNumber()<<":"<<endl;
		runWatch.Print();
   
        cout<<"needed Time for Run "<<RunParameters[i].getRunNumber()<<":\n\t"<<flush;
        runWatch.Print();
        if (settings!=NULL){
            cout<<"delete Settings..."<<endl;
            delete settings;
            cout<<"DONE_SETTINGS"<<endl;
                                                           
        }
        cout<<"DONE with Analysis of Run "<< RunParameters[i].getRunNumber();
        cout<<": "<<i+1<<"/"<<RunParameters.size()<<endl;
   }
   cout<<"DONE with Analysis of all "<<RunParameters.size()<<" Runs from RunList.ini"<<endl;
   cout<<"total time for all analysis:\n\t"<<flush;

	cout<<"time for all analysis:"<<endl;
	comulativeWatch.Print();
	cout<<"DONE_ALL"<<endl;

	return 0;
}
コード例 #11
0
void TestSettingsWidget::account()
{
    SettingsWidget *    settingsWidget = new SettingsWidget();
    Ui::SettingsWidget *ui             = settingsWidget->_ui;
    QSignalSpy          sig_status(settingsWidget,
                          SIGNAL(newStatusMessage(QString, QString)));

    TarsnapAccountDialog *tarsnapAccount = &settingsWidget->_tarsnapAccount;

    VISUAL_INIT(settingsWidget);

    // Send stats info.
    settingsWidget->overallStatsChanged(5, 4, 3, 2, 1);
    QCOMPARE(ui->accountArchivesCountLabel->text(), QString("1"));
    QCOMPARE(ui->accountTotalSizeLabel->text(), QString("5 B"));
    QCOMPARE(ui->accountActualSizeLabel->text(), QString("2 B"));
    QCOMPARE(ui->accountStorageSavedLabel->text(), QString("3 B"));
    VISUAL_WAIT;

    // Trigger an error message that we have to click away.
    QMetaObject::invokeMethod(ui->updateAccountButton, "clicked",
                              Qt::QueuedConnection);
    QMetaObject::invokeMethod(&tarsnapAccount->_popup, "close",
                              Qt::QueuedConnection);
    VISUAL_WAIT;

    // Set username, machine name, key.
    ui->accountUserLineEdit->setText("edited-user");
    ui->accountMachineLineEdit->setText("edited-mn");
    ui->accountMachineKeyLineEdit->setText("edited-mk");
    VISUAL_WAIT;

    // Nuke button, reject dialog.
    QMetaObject::invokeMethod(ui->nukeArchivesButton, "clicked",
                              Qt::QueuedConnection);
    QMetaObject::invokeMethod(&settingsWidget->_nukeConfirmationDialog._inputDialog,
                              "reject", Qt::QueuedConnection);
    QTest::qWait(200);
    QVERIFY(sig_status.takeFirst().at(0).toString()
            == QString("Nuke confirmation requested."));
    QVERIFY(sig_status.takeFirst().at(0).toString()
            == QString("Nuke cancelled."));
    VISUAL_WAIT;

    // It would be nice to test the nuke button with invalid confirmation text,
    // but QInputDialog::setTextValue() is not a slot and ::invokeMethod()
    // only works on slots.

    // Call commitSettings() manually because setText() doesn't trigger
    // editingFinished(), which is what's attached to the signal.
    settingsWidget->commitSettings();

    // Check saved settings
    TSettings settings;

    QVERIFY(settings.value("tarsnap/user", "") == QString("edited-user"));
    QVERIFY(settings.value("tarsnap/machine", "") == QString("edited-mn"));
    QVERIFY(settings.value("tarsnap/key", "") == QString("edited-mk"));

    delete settingsWidget;
}