当前位置: 首页>>代码示例>>C++>>正文


C++ QDir::exists方法代码示例

本文整理汇总了C++中QDir::exists方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::exists方法的具体用法?C++ QDir::exists怎么用?C++ QDir::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDir的用法示例。


在下文中一共展示了QDir::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

/**
FET starts here
*/
int main(int argc, char **argv)
{
	terminateGeneratePointer=NULL;
	
	QCoreApplication qapplication(argc, argv);
	
	//QObject::connect(&qapplication, SIGNAL(lastWindowClosed()), &qapplication, SLOT(quit()));

	srand(unsigned(time(NULL))); //useless, I use randomKnuth(), but just in case I use somewhere rand() by mistake...

	initRandomKnuth();

	OUTPUT_DIR=QDir::homePath()+FILE_SEP+"fet-results";
	
	QStringList _args=QCoreApplication::arguments();

	if(_args.count()==1){
		readSimulationParameters();
	
		QDir dir;
	
		bool t=true;

		//make sure that the output directory exists
		if(!dir.exists(OUTPUT_DIR))
			t=dir.mkpath(OUTPUT_DIR);

		if(!t){
                    /*
			QMessageBox::critical(NULL, FetTranslate::tr("FET critical"), FetTranslate::tr("Cannot create or use %1 directory (where the results should be stored) - you can continue operation, but you might not be able to work with FET."
			 " Maybe you can try to change the output directory from the 'Settings' menu. If this is a bug - please report it.").arg(QDir::toNativeSeparators(OUTPUT_DIR)));
                         */
		}
		
		QString testFileName=OUTPUT_DIR+FILE_SEP+"test_write_permissions_1.tmp";
		QFile test(testFileName);
		bool existedBefore=test.exists();
		bool t_t=test.open(QIODevice::ReadWrite);
		if(!t_t){
                    /*
			QMessageBox::critical(NULL, FetTranslate::tr("FET critical"), FetTranslate::tr("You don't have write permissions in the output directory "
			 "(FET cannot open or create file %1) - you might not be able to work correctly with FET. Maybe you can try to change the output directory from the 'Settings' menu."
			 " If this is a bug - please report it.").arg(testFileName));
                         */
		}
		else{
			test.close();
			if(!existedBefore)
				test.remove();
		}
	}

	students_schedule_ready=0;
	teachers_schedule_ready=0;
	rooms_schedule_ready=0;

	/////////////////////////////////////////////////
	//begin command line
	if(_args.count()>1){
		int randomSeedX=-1;
		int randomSeedY=-1;
		bool randomSeedXSpecified=false;
		bool randomSeedYSpecified=false;
	
		QString outputDirectory="";
	
		INPUT_FILENAME_XML="";
		
		QString filename="";
		
		int secondsLimit=2000000000;
		
		TIMETABLE_HTML_LEVEL=2;
		
		FET_LANGUAGE="en_US";
		
		PRINT_NOT_AVAILABLE_TIME_SLOTS=true;
		
		PRINT_BREAK_TIME_SLOTS=true;
		
		DIVIDE_HTML_TIMETABLES_WITH_TIME_AXIS_BY_DAYS=false;

		PRINT_ACTIVITIES_WITH_SAME_STARTING_TIME=false;
		
		QStringList unrecognizedOptions;
		
                SHOW_WARNING_FOR_STUDENTS_MIN_HOURS_DAILY_WITH_ALLOW_EMPTY_DAYS=true;
		SHOW_WARNING_FOR_NOT_PERFECT_CONSTRAINTS=true;
		
		SHOW_WARNING_FOR_STUDENTS_MIN_HOURS_DAILY_WITH_ALLOW_EMPTY_DAYS=true;
		
		bool showVersion=false;
		
		for(int i=1; i<_args.count(); i++){
			QString s=_args[i];
			
			if(s.left(12)=="--inputfile=")
//.........这里部分代码省略.........
开发者ID:PhilAndrew,项目名称:fet-cli,代码行数:101,代码来源:fet.cpp

示例2: QWidget

Options::Options(QWidget *parent) : QWidget(parent)
{
	ui.setupUi(this);

	SetupPluginList();
	channelsChanged(0);

	ui.sbPaTxDelayValue->setVisible(false);
	ui.sbVoiceRepeatTime->setVisible(false);

	ui.tbSDR->setCurrentIndex(0);
	ui.SwMain->setCurrentIndex(0);

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QString DocumentsLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#else
    QString DocumentsLocation = QDesktopServices::storageLocation(QDesktopServices:: HomeLocation);
#endif

	QDir dir;

	if(dir.exists(DocumentsLocation))
	{
		if(!dir.exists(DocumentsLocation + "/ExpertSDR"))
			dir.mkdir(DocumentsLocation + "/ExpertSDR");
		pathDefaultWaveIQ = DocumentsLocation + "/ExpertSDR/";
	}
	else
	{
		if(dir.mkdir(QDir::homePath() + "/ExpertSDR"))
			pathDefaultWaveIQ = QDir::homePath() + "/ExpertSDR/";
		else
		{
			QMessageBox msgBox;
			msgBox.setText("Choose a directory where wave files will be located.");
			msgBox.exec();
			//
			QString path = QDir::homePath();
			if(path.isEmpty())
			{
				msgBox.setText("Wave file location:\n" + QDir::homePath());
				msgBox.exec();
				pathDefaultWaveIQ = QDir::homePath() + "/";
			}
			else
				pathDefaultWaveIQ = path + "/";
		}
	}
	pathDefaultWaveIQDefault = pathDefaultWaveIQ;
	ui.lbWavePathIQ->setText(pathDefaultWaveIQ);
	pProg0 = new QProcess(this);
	pProg1 = new QProcess(this);
	pProg2 = new QProcess(this);
	pProg3 = new QProcess(this);
	pProg4 = new QProcess(this);

   //prepare to pupulate list in combobox with serial ports
    ui.cbPttPortName->clear();
    ui.cbAddKeyPortName->clear();
    ui.cbKeyPortName->clear();

       QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
       if (ports.size()!=0)
       {
           for (int i = 0; i < ports.size(); i++)
           {
                  ui.cbPttPortName->addItem(ports.at(i).portName.toLocal8Bit().constData(),0);
                  ui.cbAddKeyPortName->addItem(ports.at(i).portName.toLocal8Bit().constData(),0);
                  ui.cbKeyPortName->addItem(ports.at(i).portName.toLocal8Bit().constData(),0);
           }
       }


    #ifdef Q_OS_LINUX
        pPttPort = new QextSerialPort("/dev/ttyS0", QextSerialPort::EventDriven);
        pKeyPort = new QextSerialPort("/dev/ttyS0", QextSerialPort::EventDriven);
        pAddKeyPort = new QextSerialPort("/dev/ttyS0", QextSerialPort::EventDriven);
    #else
       pPttPort = new QextSerialPort("COM1", QextSerialPort::EventDriven);
       pKeyPort = new QextSerialPort("COM1", QextSerialPort::EventDriven);
       pAddKeyPort = new QextSerialPort("COM1", QextSerialPort::EventDriven);
    #endif /*Q_OS_LINUX*/

    connect(pPttPort, SIGNAL(dsrChanged(bool)), this, SLOT(OnPttDsr(bool)));
    connect(pPttPort, SIGNAL(ctsChanged(bool)), this, SLOT(OnPttCts(bool)));
    connect(pKeyPort, SIGNAL(dsrChanged(bool)), this, SLOT(OnKeyDsr(bool)));
    connect(pKeyPort, SIGNAL(ctsChanged(bool)), this, SLOT(OnKeyCts(bool)));
    connect(pAddKeyPort, SIGNAL(dsrChanged(bool)), this, SLOT(OnAddKeyDsr(bool)));
    connect(pAddKeyPort, SIGNAL(ctsChanged(bool)), this, SLOT(OnAddKeyCts(bool)));
	connect(ui.LwOptions, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(ChangePage(QListWidgetItem*, QListWidgetItem*)));
	connect(ui.pbOK, SIGNAL(clicked()), this, SLOT(OnOK()));
	connect(ui.pbCancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
	connect(ui.slTxImRejMag, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChange(int)));
	connect(ui.slTxImRejPhase, SIGNAL(valueChanged(int)), this, SLOT(OnTxPhaseChange(int)));
	connect(ui.slTxImRejMagCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeCw(int)));
	connect(ui.sbTxImRejMagCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeCw(int)));
	connect(ui.slTxImRejPhaseCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxPhaseChangeCw(int)));
	connect(ui.sbTxImRejPhaseCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxPhaseChangeCw(int)));
	connect(ui.slTxImRejMagAmFm, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeAmFm(int)));
	connect(ui.sbTxImRejMagAmFm, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeAmFm(int)));
//.........这里部分代码省略.........
开发者ID:florintanasa,项目名称:OpenExpertSDR_2,代码行数:101,代码来源:Options.cpp

示例3: SaveFile

void MainWindow::SaveFile(const QString& file){
	setStatusTip(UTF8("保存当前进度到:")+file);
	QFile fp(file);
	fp.open(QFile::ReadOnly);
	QTextStream CurrentFile(&fp);
	QString OData;
	QTextStream SaveingFile(&OData);
	SaveingFile.setCodec("UTF-8");

	SaveingFile << StartIndent <<endl;

	SaveingFile <<endl;
	SaveingFile<< "[GLOBAL]" <<endl;
	SaveingFile<<"\tSCREENHEIGHT: "<<singleLine( CurrentSetting->property("screenheight").toString() )<<endl;
	SaveingFile<<"\tSCREENWIDTH: "<<singleLine( CurrentSetting->property("screenwidth").toString() )<<endl;
	SaveingFile<<"\tURL: "<<singleLine( CurrentSetting->property("url").toString() )<<endl;
	SaveingFile<<"\tTEMPLATE: "<<singleLine( CurrentSetting->property("template").toString() )<<endl;
	SaveingFile<<"\tNAMESPACE: "<<singleLine( CurrentSetting->property("namespace").toString() )<<endl;
	SaveingFile<<"\tBGSELECTOR: "<<singleLine( CurrentSetting->property("bgselector").toString() )<<endl;
	SaveingFile<<"\tGENERATEBGIMAGE: "<<singleLine( CurrentSetting->property("generatebgimage").toString() )<<endl;
	SaveingFile<<"\tLASTPNG: "<<singleLine( CurrentSetting->property("lastpng").toString() )<<endl;
	SaveingFile<<"[END]"<<endl;
	SaveingFile <<endl;

	SaveingFile << wm->SessionSave();
	SaveingFile << endl << EndIndent <<endl;

	//读取文件中的其他部分
	QString Line;
	bool switcher = false;
	while( !CurrentFile.atEnd() ){
		Line = CurrentFile.readLine();
		if( !switcher ){ //非 配置or导出 部分
			if(Line.startsWith(StartIndent) || Line.startsWith(AutoGenIndent)){
				switcher = true;
				continue;
			}
			SaveingFile<<Line<<endl;
		}else{ //配置or导出 部分
			switcher = !(Line.startsWith(EndIndent) || Line.startsWith(AutoGenEndIndent));
		}
	}

	fp.close();
	if(!fp.open(QFile::WriteOnly)) throw AlertException(UTF8("保存失败"),UTF8("无法写入文件"));
	CurrentFile.reset();

	CurrentFilePath = file;
	this->setWindowTitle(file+QString(" - cssSprites"));

	qDebug()<<"File Save"<<file;
	CurrentFile<<OData;
	fp.close();

	QDir fsd;
	QString target = fsd.absoluteFilePath(CurrentFilePath);
	target += STUFF_FOLDER;
	if(fsd.currentPath() != target){
		//转移文件
		fsd.setPath(target);
		if( !fsd.exists() ){
			if(! fsd.mkdir(target) ) throw AlertException(UTF8("保存错误"),("目标路径无法写入(请检查权限)\n")+target);
		}
		QStringList stuff = QDir::current().entryList(QDir::Files);
		QString fName;
		foreach(fName,stuff){
			qWarning(QString("Copy File ================\n\t\tfrom %1(%2)\n\t\t to %3").arg(fName).arg(QDir::currentPath()).arg(target+fName).toStdString().data());
			QFile::copy(fName,target+fName);
		}
开发者ID:GongT,项目名称:cssSprites,代码行数:69,代码来源:mainwindow_actions.cpp

示例4: on_Button_OK_clicked

void Advanced_Settings_Window::on_Button_OK_clicked()
{
	// Execute Before Start QEMU
	Settings.setValue( "Run_Before_QEMU", ui.Edit_Before_Start_Command->text() );
	
	// Execute After Stop QEMU
	Settings.setValue( "Run_After_QEMU", ui.Edit_After_Stop_Command->text() );
	
	// Use Shared Folder For All Screenshots
	if( ui.CH_Screenshot_Folder->isChecked() )
	{
		Settings.setValue( "Use_Screenshots_Folder", "yes" );
		
		QDir dir; // For Check on valid
		
		// Screenshots Shared Folder Path
		if( dir.exists(ui.Edit_Screenshot_Folder->text()) )
		{
			Settings.setValue( "Screenshot_Folder_Path", ui.Edit_Screenshot_Folder->text() );
		}
		else
		{
			AQGraphic_Warning( tr("Invalid Value!"), tr("Shared screenshot folder doesn't exist!") );
			return;
		}
	}
	else
	{
		Settings.setValue( "Use_Screenshots_Folder", "no" );
		
		// Screenshots Shared Folder Path
		Settings.setValue( "Screenshot_Folder_Path", ui.Edit_Screenshot_Folder->text() );
	}
	
	// Screenshot save format
	if( ui.RB_Format_PNG->isChecked() ) Settings.setValue( "Screenshot_Save_Format", "PNG" );
	else if( ui.RB_Format_Jpeg->isChecked() ) Settings.setValue( "Screenshot_Save_Format", "JPEG" );
	else Settings.setValue( "Screenshot_Save_Format", "PPM" );
	
	// Jpeg Quality
	Settings.setValue( "Jpeg_Quality", QString::number(ui.HS_Jpeg_Quality->value()) );
	
	// Additional CDROM
	int old_count = Settings.value( "Additional_CDROM_Devices/Count", "0" ).toString().toInt();
	
	if( old_count > ui.CDROM_List->count() )
	{
		// Delete Old Items
		for( int dx = ui.CDROM_List->count()-1; dx < old_count; dx++ )
		{
			Settings.remove( "Additional_CDROM_Devices/Device" + QString::number(dx) );
		}
	}
	
	Settings.setValue( "Additional_CDROM_Devices/Count", QString::number(ui.CDROM_List->count()) );
	
	for( int ix = 0; ix < ui.CDROM_List->count(); ix++ )
	{
		Settings.setValue( "Additional_CDROM_Devices/Device" + QString::number(ix), ui.CDROM_List->item(ix)->text() );
	}
	
	Settings.setValue( "Info/Show_Tab_Info", ui.CH_Show_Tab_Info->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Show_QEMU_Args", ui.CH_Show_QEMU_Args->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Show_Screenshot_in_Save_Mode", ui.CH_Show_Screenshot_in_Save_Mode->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Machine_Details", ui.CH_Machine_Details->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Machine_Name", ui.CH_Machine_Name->isChecked() ? "no" : "no" );
	Settings.setValue( "Info/Emulator_Type", ui.CH_Emulator_Type->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Emulator_Version", ui.CH_Emulator_Version->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Computer_Type", ui.CH_Computer_Type->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Machine_Type", ui.CH_Machine_Type->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Boot_Priority", ui.CH_Boot_Priority->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/CPU_Type", ui.CH_CPU_Type->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Number_of_CPU", ui.CH_Number_of_CPU->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Video_Card", ui.CH_Video_Card->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Keyboard_Layout", ui.CH_Keyboard_Layout->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Memory_Size", ui.CH_Memory_Size->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Use_Sound", ui.CH_Use_Sound->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Fullscreen", ui.CH_Fullscreen->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Snapshot", ui.CH_Snapshot->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Localtime", ui.CH_Localtime->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Show_FDD", ui.CH_Show_FDD->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Show_CD", ui.CH_Show_CD->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Show_HDD", ui.CH_Show_HDD->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Network_Cards", ui.CH_Network_Cards->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Redirections", ui.CH_Redirections->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Serial_Port", ui.CH_Serial_Port->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/Parallel_Port", ui.CH_Parallel_Port->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/USB_Port", ui.CH_USB_Port->isChecked() ? "yes" : "no" );
	
	Settings.setValue( "Info/Win2K_Hack", ui.CH_Win2K_Hack->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/RTC_TD_Hack", ui.CH_RTC_TD_Hack->isChecked() ? "yes" : "no" );
	Settings.setValue( "Info/No_Shutdown",  ui.CH_No_Shutdown->isChecked()? "yes" : "no" );
	Settings.setValue( "Info/No_Reboot", ui.CH_No_Reboot->isChecked() ? "yes" : "no" );
//.........这里部分代码省略.........
开发者ID:loadx,项目名称:aqemu,代码行数:101,代码来源:Advanced_Settings_Window.cpp

示例5: versionUpgrade

// We return the UserSettings here because we have to make changes to the
// configuration and the location of the file may change between releases.
UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) {

/*  Pre-1.7.0:
*
*   Since we didn't store version numbers in the config file prior to 1.7.0,
*   we check to see if the user is upgrading if his config files are in the old location,
*   since we moved them in 1.7.0. This code takes care of moving them.
*/

    QDir oldLocation = QDir(QDir::homePath());
#ifdef __WINDOWS__
    QFileInfo* pre170Config = new QFileInfo(oldLocation.filePath("mixxx.cfg"));
#else
    QFileInfo* pre170Config = new QFileInfo(oldLocation.filePath(".mixxx.cfg"));
#endif

    if (pre170Config->exists()) {

        // Move the files to their new location
        QDir newLocation = QDir(settingsPath);

        if (!newLocation.exists()) {
            qDebug() << "Creating new settings directory" << newLocation.absolutePath();
            newLocation.mkpath(".");
        }

        QString errorText = "Error moving your %1 file %2 to the new location %3: \n";

#ifdef __WINDOWS__
        QString oldFilePath = oldLocation.filePath("mixxxtrack.xml");
#else
        QString oldFilePath = oldLocation.filePath(".mixxxtrack.xml");
#endif

        QString newFilePath = newLocation.filePath("mixxxtrack.xml");
        QFile* oldFile = new QFile(oldFilePath);
        if (oldFile->exists()) {
            if (oldFile->copy(newFilePath)) {
                oldFile->remove();
            }
            else {
                if (oldFile->error()==14) qDebug() << errorText.arg("library", oldFilePath, newFilePath) << "The destination file already exists.";
                else qDebug() << errorText.arg("library", oldFilePath, newFilePath) << "Error #" << oldFile->error();
            }
        }
        delete oldFile;

#ifdef __WINDOWS__
        oldFilePath = oldLocation.filePath("mixxxbpmschemes.xml");
#else
        oldFilePath = oldLocation.filePath(".mixxxbpmscheme.xml");
#endif
        newFilePath = newLocation.filePath("mixxxbpmscheme.xml");
        oldFile = new QFile(oldFilePath);
        if (oldFile->exists()) {
            if (oldFile->copy(newFilePath))
                oldFile->remove();
            else {
                if (oldFile->error()==14) qDebug() << errorText.arg("settings", oldFilePath, newFilePath) << "The destination file already exists.";
                else qDebug() << errorText.arg("settings", oldFilePath, newFilePath) << "Error #" << oldFile->error();
            }
        }
        delete oldFile;
#ifdef __WINDOWS__
        oldFilePath = oldLocation.filePath("MixxxMIDIBindings.xml");
#else
        oldFilePath = oldLocation.filePath(".MixxxMIDIBindings.xml");
#endif
        newFilePath = newLocation.filePath("MixxxMIDIBindings.xml");
        oldFile = new QFile(oldFilePath);
        if (oldFile->exists()) {
            qWarning() << "The MIDI mapping file format has changed in this version of Mixxx. You will need to reconfigure your MIDI controller. See the Wiki for full details on the new format.";
            if (oldFile->copy(newFilePath))
                oldFile->remove();
            else {
                if (oldFile->error()==14) qDebug() << errorText.arg("MIDI mapping", oldFilePath, newFilePath) << "The destination file already exists.";
                else qDebug() << errorText.arg("MIDI mapping", oldFilePath, newFilePath) << "Error #" << oldFile->error();
            }
        }
        // Tidy up
        delete oldFile;
#ifdef __WINDOWS__
        QFile::remove(oldLocation.filePath("MixxxMIDIDevice.xml")); // Obsolete file, so just delete it
#else
        QFile::remove(oldLocation.filePath(".MixxxMIDIDevice.xml")); // Obsolete file, so just delete it
#endif

#ifdef __WINDOWS__
        oldFilePath = oldLocation.filePath("mixxx.cfg");
#else
        oldFilePath = oldLocation.filePath(".mixxx.cfg");
#endif
        newFilePath = newLocation.filePath(SETTINGS_FILE);
        oldFile = new QFile(oldFilePath);
        if (oldFile->copy(newFilePath))
            oldFile->remove();
        else {
                if (oldFile->error()==14) qDebug() << errorText.arg("configuration", oldFilePath, newFilePath) << "The destination file already exists.";
//.........这里部分代码省略.........
开发者ID:badescunicu,项目名称:mixxx,代码行数:101,代码来源:upgrade.cpp

示例6: init

/**
 * Prepares the log file for writting
 */
void DSEventLogger::init()
{
    if (!m_init) {
        /* Initialize the timer */
        m_init = true;
        m_timer.restart();

        /* Get app info */
        QString appN = qApp->applicationName();
        QString appV = qApp->applicationVersion();
        QString ldsV = DriverStation::libDSVersion();
        QString time = GET_DATE_TIME ("MMM dd yyyy - HH:mm:ss AP");

        /* Get dump directoru */
        QString path = QString ("%1/%2/%3/%4/")
                       .arg (logsPath())
                       .arg (GET_DATE_TIME ("yyyy"))
                       .arg (GET_DATE_TIME ("MMMM"))
                       .arg (GET_DATE_TIME ("ddd dd"));

        /* Create logs directory (if necessesary) */
        QDir dir (path);
        if (!dir.exists())
            dir.mkpath (".");

        /* Get dump file path */
        m_currentLog = QString ("%1/%2.log")
                       .arg (path)
                       .arg (GET_DATE_TIME ("HH_mm_ss AP"));

        /* Open dump file */
        m_dump = fopen (m_currentLog.toStdString().c_str(), "w");
        m_dump = !m_dump ? stderr : m_dump;

        /* Get OS information */
        QString sysV;
#if QT_VERSION >= QT_VERSION_CHECK (5, 4, 0)
        sysV = QSysInfo::prettyProductName();
#else
#if defined Q_OS_WIN
        sysV = "Windows";
#elif defined Q_OS_MAC
        sysV = "Mac OSX";
#elif defined Q_OS_LINUX
        sysV = "GNU/Linux";
#else
        sysV = "Unknown";
#endif
#endif

        /* Format app info */
        time.prepend ("Log created on:      ");
        ldsV.prepend ("LibDS version:       ");
        sysV.prepend ("Operating System:    ");
        appN.prepend ("Application name:    ");
        appV.prepend ("Application version: ");

        /* Append app info */
        fprintf (m_dump, "%s\n",   PRINT (time));
        fprintf (m_dump, "%s\n",   PRINT (ldsV));
        fprintf (m_dump, "%s\n",   PRINT (sysV));
        fprintf (m_dump, "%s\n",   PRINT (appN));
        fprintf (m_dump, "%s\n\n", PRINT (appV));

        /* Start the table header */
        fprintf (m_dump, "%s\n", PRINT (REPEAT ("-", 72)));
        fprintf (m_dump, PRINT_FMT, "ELAPSED TIME", "ERROR LEVEL", "MESSAGE");
        fprintf (m_dump, "%s\n", PRINT (REPEAT ("-", 72)));
    }
}
开发者ID:AHerridge,项目名称:LibDS,代码行数:73,代码来源:EventLogger.cpp

示例7: main

int main(int argc, char *argv[]) {
    QDir clamDir;
    QFile dbFile, confFile;

    QApplication app(argc, argv);
    QTranslator myappTranslator;

    QString locale = QLocale::system().name();
    QString defaultLanguage = QString(APP_NAME) + "_" + locale + ".qm";

    // Falls die Sprache manuell gesetzt wurde.
    QSettings clamui_conf(QSettings::NativeFormat, QSettings::UserScope,
                             APP_TITLE, APP_NAME);
    clamui_conf.beginGroup("ClamUI");
    bool languageSet = clamui_conf.value("Language_Manually", false).toBool();
    QString currLanguage = clamui_conf.value(
                     "languageFileName", defaultLanguage).toString();
    bool hideWindow =clamui_conf.value("Hide_Window", false).toBool();
    clamui_conf.endGroup();

    // Systemsprache aus der Umgebungsvariable des Systems lesen.
    // Read the system language from the system environment.
    QTranslator qtTranslator;
    qtTranslator.load("qt_" + QLocale::system().name(),
                      QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app.installTranslator(&qtTranslator);

    if (languageSet == false) {
        // Langauge from system settings
        myappTranslator.load(LANG_PATH
                             + APP_NAME + "_"
                             + locale + ".qm");
        app.installTranslator(&myappTranslator);
      } else {
        // Language manually.
        myappTranslator.load(LANG_PATH + currLanguage);
        app.installTranslator(&myappTranslator);
      }

    /*
     * Check if there is a ClamAV directory.
     * In this directory are the config files stored.
     */
    if (!clamDir.exists(CLAMAV_PATH))
        clamDir.mkdir(CLAMAV_PATH);

    /*
     * The default quarantine folder.
     */
    if (!clamDir.exists(CLAMAV_PATH + "quarantine"))
        clamDir.mkdir(CLAMAV_PATH + "quarantine");

    /*
     * The directory for the virus definition stored.
     */
    if (!clamDir.exists(CLAMAV_VDB_PATH))
        clamDir.mkdir(CLAMAV_VDB_PATH);

    /*
     * Check for an existing SQLite3 database.
     */
    if (!dbFile.exists(APP_CONFIG_PATH + SQLITE_DB_NAME)){

        SQLite_DB sqliteDB;
        sqliteDB.connectDB();
    }

    /*
     * Check for an existing config file.
     *
     * If not run the wizard.
     */
    if (!confFile.exists(APP_CONFIG_PATH + APP_NAME + ".conf")){

        FirstRunWizard startWizard;
        startWizard.show();
        return app.exec();

    }

    /*
     * If exists run clamui.
     */
    if (confFile.exists(APP_CONFIG_PATH + APP_NAME + ".conf")){

        ClamUI startClamUI;
        if (hideWindow){

            startClamUI.hide();
            return app.exec();

        } else {

            startClamUI.show();
            return app.exec();
        }
    }

} // main end
开发者ID:elgolondrino,项目名称:clamui,代码行数:99,代码来源:main.cpp

示例8: rmpath

bool MkPath::rmpath(const QDir &dir
                    #ifdef ULTRACOPIER_PLUGIN_RSYNC
                    ,const bool &toSync
                    #endif
                    )
{
    if(!dir.exists())
        return true;
    bool allHaveWork=true;
    QFileInfoList list = dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst);
    for (int i = 0; i < list.size(); ++i)
    {
        QFileInfo fileInfo(list.at(i));
        if(!fileInfo.isDir())
        {
            #ifdef ULTRACOPIER_PLUGIN_RSYNC
            if(toSync)
            {
                QFile file(fileInfo.absoluteFilePath());
                if(!file.remove())
                {
                    if(toSync)
                    {
                        QFile file(fileInfo.absoluteFilePath());
                        if(!file.remove())
                        {
                            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to remove a file: "+fileInfo.absoluteFilePath()+", due to: "+file.errorString());
                            allHaveWork=false;
                        }
                    }
                    else
                    {
                        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"found a file: "+fileInfo.fileName());
                        allHaveWork=false;
                    }
                }
            }
            else
            {
                ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"found a file: "+fileInfo.fileName());
                allHaveWork=false;
            }
            #else
            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"found a file: "+fileInfo.fileName());
            allHaveWork=false;
            #endif
        }
        else
        {
            //return the fonction for scan the new folder
            if(!rmpath(dir.absolutePath()+'/'+fileInfo.fileName()+'/'))
                allHaveWork=false;
        }
    }
    if(!allHaveWork)
        return false;
    allHaveWork=dir.rmdir(dir.absolutePath());
    if(!allHaveWork)
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to remove the folder: "+dir.absolutePath());
    return allHaveWork;
}
开发者ID:amitamitamitamit,项目名称:Ultracopier,代码行数:61,代码来源:MkPath.cpp

示例9: lastOpenedDir


//.........这里部分代码省略.........
        // lets not restart endlessly
        restarting = false;

        //this is the path within the current directory where GC will look for
        //files to allow USB stick support
        QString localLibraryPath="Library/GoldenCheetah";

        //this is the path that used to be used for all platforms
        //now different platforms will use their own path
        //this path is checked first to make things easier for long-time users
        QString oldLibraryPath=QDir::home().canonicalPath()+"/Library/GoldenCheetah";

        //these are the new platform-dependent library paths
#if defined(Q_OS_MACX)
        QString libraryPath="Library/GoldenCheetah";
#elif defined(Q_OS_WIN)
#if QT_VERSION > 0x050000 // windows and qt5
        QStringList paths=QStandardPaths::standardLocations(QStandardPaths::DataLocation);
        QString libraryPath = paths.at(0); 
#else // windows not qt5
        QString libraryPath=QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/GoldenCheetah";
#endif // qt5
#else // not windows or osx (must be Linux or OpenBSD)
        // Q_OS_LINUX et al
        QString libraryPath=".goldencheetah";
#endif //

        // or did we override in settings?
        QString sh;
        if ((sh=appsettings->value(NULL, GC_HOMEDIR, "").toString()) != QString("")) localLibraryPath = sh;

        // lets try the local library we've worked out...
        QDir home = QDir();
        if(QDir(localLibraryPath).exists() || home.exists(localLibraryPath)) {

            home.cd(localLibraryPath);

        } else {

            // YIKES !! The directory we should be using doesn't exist!
            home = QDir::home();
            if (home.exists(oldLibraryPath)) { // there is an old style path, lets fo there
                home.cd(oldLibraryPath);
            } else {

                if (!home.exists(libraryPath)) {
                    if (!home.mkpath(libraryPath)) {

                        // tell user why we aborted !
                        QMessageBox::critical(NULL, "Exiting", QString("Cannot create library directory (%1)").arg(libraryPath));
                        exit(0);
                    }
                }
                home.cd(libraryPath);
            }
        }

        // set global root directory
        gcroot = home.canonicalPath();
        appsettings->initializeQSettingsGlobal(gcroot);


        // now redirect stderr
#ifndef WIN32
        if (!debug) nostderr(home.canonicalPath());
#else
开发者ID:kopsis,项目名称:GoldenCheetah,代码行数:67,代码来源:main.cpp

示例10: CreateNewSound

QByteArray TTSAcapela::CreateNewSound(QString text, QString voice, bool forceOverwrite)
{
	QEventLoop loop;

	if(!voiceList.contains(voice))
		voice = "claire";

	// Check (and create if needed) output folder
	QDir outputFolder = ttsFolder;
	if(!outputFolder.exists(voice))
		outputFolder.mkdir(voice);
	
	if(!outputFolder.cd(voice))
	{
		LogError(QString("Cant create TTS Folder : %1").arg(ttsFolder.absoluteFilePath(voice)));
		return QByteArray();
	}
	
	// Compute fileName
	QString fileName = QCryptographicHash::hash(text.toAscii(), QCryptographicHash::Md5).toHex().append(".mp3");
	QString filePath = outputFolder.absoluteFilePath(fileName);

	if(!forceOverwrite && QFile::exists(filePath))
		return ttsHTTPUrl.arg(voice, fileName).toAscii();

	// Fetch MP3
	QHttp http("vaas3.acapela-group.com");
	QObject::connect(&http, SIGNAL(done(bool)), &loop, SLOT(quit()));

	QByteArray ContentData;
	ContentData += "client%5Ftext=" + QUrl::toPercentEncoding(text) + "&client%5Fvoice=" + voice + "22k&client%5Frequest%5Ftype=CREATE%5FREQUEST&client%5Fpassword=demo_web&client%5Flogin=asTTS&client%5Fversion=1%2D00&actionscript%5Fversion=3";

	QHttpRequestHeader Header;
	Header.addValue("Host", "vaas3.acapela-group.com");
	Header.addValue("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1");
	Header.addValue("Referer", "http://www.acapela-group.com/Flash/Demo_Web_AS3/demo_web.swf?path=http://vaas3.acapela-group.com/connector/1-20/&lang=FR");
	Header.addValue("Content-type", "application/x-www-form-urlencoded"); 
	Header.addValue("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
	Header.addValue("Accept-Language", "fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3");
	Header.addValue("Accept-Encoding", "gzip,deflate");
	Header.addValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
	Header.addValue("Keep-Alive", "300");
	Header.addValue("Connection", "keep-alive");

	Header.setContentLength(ContentData.length());
	Header.setRequest("POST", "/connector/1-20/textToMP3.php", 1, 1);

	http.request(Header, ContentData);
	loop.exec();
	QByteArray reponse = http.readAll();
	QUrl url("?"+reponse);
	if(url.hasQueryItem("retour_php"))
	{
		//LogDebug(QString("Acapela answer : %1").arg(QString(reponse)));
		QString acapelaFile = url.queryItemValue("retour_php");
		//LogInfo(QString("Downloading MP3 file : %1").arg(QString(acapelaFile)));
		http.get(acapelaFile);
		loop.exec();
		QFile file(filePath);
		if (!file.open(QIODevice::WriteOnly))
		{
			LogError("Cannot open sound file for writing");
			return QByteArray();
		}
		file.write(http.readAll());
		file.close();
		return ttsHTTPUrl.arg(voice, fileName).toAscii();
	}
	LogError("Acapela demo did not return a sound file");
	LogDebug(QString("Acapela answer : %1").arg(QString(reponse)));
	return QByteArray();
}
开发者ID:Laurent207,项目名称:OpenJabNab,代码行数:72,代码来源:tts_acapela.cpp

示例11: getConfigDir

QString Brewtarget::getConfigDir(bool *success)
{
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) // Linux OS or Mac OS.

   QDir dir;
   QFileInfo fileInfo;
   char* xdg_config_home = getenv("XDG_CONFIG_HOME");
   bool tmp;
   QFile::Permissions sevenFiveFive = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner |
                                      QFile::ReadGroup |                     QFile::ExeGroup |
                                      QFile::ReadOther |                     QFile::ExeOther;
   // First, try XDG_CONFIG_HOME.
   // If that variable doesn't exist, create ~/.config
   if (xdg_config_home)
   {
      dir = xdg_config_home;
   }
   else
   {
      // Creating config directory.
      dir = QDir::home();
      if( !dir.exists(".config") )
      {
         logW( QString("Config dir \"%1\" did not exist...").arg(dir.absolutePath() + "/.config") );
         tmp = dir.mkdir(".config");
         logW( QString( tmp ? "...created it." : "...could not create it.") );
         if( !tmp )
         {
            // Failure.
            if( success != 0 )
               *success = false;
            return "";
         }

         // chmod 755 ~/.config
         QFile::setPermissions( dir.absolutePath() + "/.config", sevenFiveFive );
      }

      // CD to config directory.
      if( ! dir.cd(".config") )
      {
         logE( QString("Could not CD to \"%1\".").arg(dir.absolutePath() + "/.config") );
         if( success != 0 )
            *success = false;
         return "";
      }
   }

   // See if brewtarget dir exists.
   if( !dir.exists("brewtarget") )
   {
      logW( QString("\"%1\" does not exist...creating.").arg(dir.absolutePath() + "/brewtarget") );

      // Try to make brewtarget dir.
      if( ! dir.mkdir("brewtarget") )
      {
         logE( QString("Could not create \"%1\"").arg(dir.absolutePath() + "/brewtarget") );
         if( success != 0 )
            *success = false;
         return "";
      }

      // chmod 755 ~/.config/brewtarget
      QFile::setPermissions( dir.absolutePath() + "/brewtarget", sevenFiveFive );
   }

   if( ! dir.cd("brewtarget") )
   {
      logE(QString("Could not CD into \"%1\"").arg(dir.absolutePath() + "/brewtarget"));
      if( success != 0 )
         *success = false;
      return "";
   }

   if( success != 0 )
      *success = true;
   return dir.absolutePath() + "/";

#elif defined(Q_OS_WIN) // Windows OS.

   QDir dir;
   // This is the bin/ directory.
   dir = QDir(qApp->applicationDirPath());
   dir.cdUp();
   // Now we should be in the base directory (i.e. Brewtarget-2.0.0/)

   dir.cd("data");
   if( success != 0 )
      *success = true;
   return dir.absolutePath() + "/";

#else
# error "Unsupported OS"
#endif

}
开发者ID:Mackanzx,项目名称:brewtarget,代码行数:96,代码来源:brewtarget.cpp

示例12: readTheme

void HTMLChatTheme::readTheme(QDir dir) {
    qDebug() << "reading theme from filesystem" << dir;

    isValid_ = false;

    if (!dir.cd("Contents/Resources/")) { //invalid dir
        return; //isValid == false;
    }

    setBaseHref(dir.path() + "/");

    incomingNextMessageTemplate.setContent(readFileContents(dir, "Incoming/Content.html"));

    if (dir.exists("Incoming/NextContent.html")) {
        incomingConsecutiveMessageTemplate.setContent(readFileContents(dir, "Incoming/NextContent.html"));
    }
    else {
        incomingConsecutiveMessageTemplate.setContent(incomingNextMessageTemplate.content());
    }

    // outgoing messages
    if (dir.exists("Outgoing/NextContent.html")) {
        outgoingConsecutiveMessageTemplate.setContent(readFileContents(dir, "Outgoing/NextContent.html"));
    }
    else {
        outgoingConsecutiveMessageTemplate.setContent(incomingConsecutiveMessageTemplate.content());
    }

    if (dir.exists("Outgoing/Content.html")) {
        outgoingNextMessageTemplate.setContent(readFileContents(dir, "Outgoing/Content.html"));
    }
    else {
        outgoingNextMessageTemplate.setContent(incomingNextMessageTemplate.content());
    }

    noOutgoingDir = !dir.exists("Outgoing/buddy_icon.png"); //some themes have empty Outgoing dir
    //we will be using Incoming avatar

    // status/event template
    fileTransferEventTemplate.setContent(readFileContents(dir, "Status.html"));
    systemEventTemplate = HTMLChatTemplate(fileTransferEventTemplate);
    moodEventTemplate = HTMLChatTemplate(fileTransferEventTemplate);
    tuneEventTemplate = HTMLChatTemplate(fileTransferEventTemplate);


    // action
    if (dir.exists("Incoming/Action.html")) {
        incomingEmoteEventTemplate.setContent(readFileContents(dir, "Incoming/Action.html"));
        incomingEmoteEventTemplate.setEmoteTemplate(true);
    }
    else {
        incomingEmoteEventTemplate.setContent(fileTransferEventTemplate.content());
    }

    if (dir.exists("Outgoing/Action.html")) {
        outgoingEmoteEventTemplate.setContent(readFileContents(dir, "Outgoing/Action.html"));
        incomingEmoteEventTemplate.setEmoteTemplate(true);
    }
    else {
        outgoingEmoteEventTemplate.setContent(fileTransferEventTemplate.content());
    }


    headerTemplate_.setContent(readFileContents(dir, "Header.html"));
    footerTemplate_.setContent(readFileContents(dir, "Footer.html"));

    isValid_ = true;

    //read Variants
    variants_.clear();

    if (!dir.cd("Variants/")) {
        qDebug() << "no Variants dir";
        return; //no variants
    }

    QStringList filters;
    filters << "*.css";

    QStringList variantFiles = dir.entryList(filters);
    QString variant;


    foreach(variant, variantFiles) {
        variants_.append(variant.left(variant.size() - 4));
    }
开发者ID:senu,项目名称:psi,代码行数:86,代码来源:htmlchattheme.cpp

示例13: createNewCC

bool DbPlugin::createNewCC (DBIndex *i)
{
  FuturesData fd;
  QStringList l;
  fd.getSymbolList(l);

  QString pl = QObject::tr("Parms");
  QString fsl = QObject::tr("Futures Symbol");
  QString gl = QObject::tr("Gapless");

  PrefDialog *dialog = new PrefDialog(0);
  dialog->setCaption(QObject::tr("New CC"));
  dialog->createPage (pl);
  dialog->setHelpFile(helpFile);

  dialog->addComboItem(fsl, pl, l, 0);
  dialog->addCheckItem(gl, pl, TRUE);

  int rc = dialog->exec();
  if (rc != QDialog::Accepted)
  {
    delete dialog;
    return TRUE;
  }

  QString sym;
  dialog->getCombo(fsl, sym);
  bool f = dialog->getCheck(gl);

  delete dialog;

  QDir dir;
  Config config;
  QString s;
  config.getData(Config::DataPath, s);
  s.append("/CC");
  if (! dir.exists(s))
  {
    if (! dir.mkdir(s, TRUE))
    {
      QMessageBox::information(0,
                               QObject::tr("Qtstalker: Error"),
                               QObject::tr("Could not create ~/.qtstalker/data/CC directory."));
      return TRUE;
    }
  }

  DBIndexItem item;
  QString ts;
  chartIndex->getIndexItem(sym, item);
  item.getSymbol(ts);
  if (ts.length())
  {
    qDebug("DbPlugin::createNewStock: duplicate symbol %s", ts.latin1());
    return TRUE;
  }

  
  s.append("/" + sym);
  if (open(s, i))
  {
    QMessageBox::information(0,
                             QObject::tr("Qtstalker: Error"),
                             QObject::tr("Disk error, cannot create chart"));
    return TRUE;
  }

  type = CC1;
  item.setSymbol(sym);
  s = "CC";
  item.setType(s);
  s = sym + " - " + QObject::tr("Continuous Adjusted");
  item.setTitle(s);
  chartIndex->setIndexItem(indexKey, item);

  s = QString::number(f);
  sym = "Adjustment";
  setData(sym, s);

  return FALSE;
}
开发者ID:botvs,项目名称:FinancialAnalytics,代码行数:81,代码来源:DbPlugin.cpp

示例14: initSettings

//Init settings
void initSettings()
{
    //open file
#ifdef Q_OS_WIN
    QSettings settings("HKEY_CURRENT_USER\\Software\\moonplayer", QSettings::NativeFormat);
#else
    QDir dir = QDir::home();
    if (!dir.cd(".moonplayer"))
    {
        dir.mkdir(".moonplayer");
        dir.cd(".moonplayer");
    }
    if (!dir.exists("plugins"))
        dir.mkdir("plugins");
    if (!dir.exists("skins"))
        dir.mkdir("skins");

    QSettings settings(QDir::homePath() + "/.config/moonplayer.ini", QSettings::IniFormat);
#endif

    //read settings
#ifdef Q_OS_WIN
    if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
        vout = settings.value("Video/out", "direct3d").toString();
    else
        vout = settings.value("Video/out", "directx").toString();
#else
    vout = settings.value("Video/out", "xv").toString();
    path = "/usr/share/moonplayer";
#endif
    framedrop = settings.value("Video/framedrop", true).toBool();
    doubleBuffer = settings.value("Video/double", true).toBool();
    fixLastFrame = settings.value("Video/fixlastframe", false).toBool();
    ffodivxvdpau = settings.value("Video/ffodivxvdpau", true).toBool();
    aout = settings.value("Audio/out", "auto").toString();
    softvol = settings.value("Audio/softvol", false).toBool();
    volume = settings.value("Audio/volume", 10).toInt();
    currentSkin = settings.value("Player/current_skin", 0).toInt();
    autoResize = settings.value("Player/auto_resize", true).toBool();
    enableScreenshot = settings.value("Player/screenshot", true).toBool();
    rememberUnfinished = settings.value("Player/remember_unfinished", true).toBool();
    proxy = settings.value("Net/proxy").toString();
    port = settings.value("Net/port").toInt();
    cacheSize = settings.value("Net/cache_size", 4096).toInt();
    cacheMin = settings.value("Net/cache_min", 50).toInt();
    maxTasks = settings.value("Net/max_tasks", 3).toInt();
    downloadDir = settings.value("Net/download_dir", QDir::homePath()).toString();
    quality = (Quality) settings.value("Plugins/quality", (int) SUPER).toInt();
    autoCombine = settings.value("Plugins/auto_combine", false).toBool();
    autoCloseWindow = settings.value("Plugins/auto_close_window", true).toBool();
    danmakuAlpha = settings.value("Danmaku/alpha", 0.9).toDouble();
    danmakuFont = settings.value("Danmaku/font", "").toString();
    danmakuSize = settings.value("Danmaku/size", 0).toInt();
    durationScrolling = settings.value("Danmaku/dm", 0).toInt();
    durationStill = settings.value("Danmaku/ds", 6).toInt();

    //init proxy
    if (proxy.isEmpty())
        access_manager->setProxy(QNetworkProxy(QNetworkProxy::NoProxy));
    else
        access_manager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxy, port));

    //init skins
    QDir skinDir(path);
    skinDir.cd("skins");
    skinList = skinDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
#ifdef Q_OS_LINUX
    dir.cd("skins");
    skinList.append(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name));
#endif
    if (currentSkin >= skinList.size())
        currentSkin = 0;
}
开发者ID:lipq525,项目名称:moonplayer,代码行数:74,代码来源:settingsdialog.cpp

示例15: imageReader

// Private slot to take care of processing a WMS tile delivered over the network.
void
WMSRequester::processTile(QNetworkReply* reply)
{
    // Check HTTP status code
    QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);

    // Check redirection target
    QVariant redirectionTargetUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    // see CS001432 on how to handle this

    --m_dispatchedRequestCount;

    // no error received?
    if (reply->error() == QNetworkReply::NoError)
    {
        bool fromCache = reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool();

        QImageReader imageReader(reply);
        QImage image = imageReader.read();

        if (image.isNull())
        {
            qDebug() << "Received bad image: " << reply->header(QNetworkRequest::LocationHeader);
        }
        else
        {
            QMutexLocker locker(&m_mutex);

            TileBuildOperation op = m_requestedTiles.take(reply);

            TileAssembly* tileAssembly = op.tile;

            if (tileAssembly)
            {
                bool firstOp = false;
                if (tileAssembly->tileImage.isNull())
                {
                     tileAssembly->tileImage = QImage(tileAssembly->tileWidth, tileAssembly->tileHeight, QImage::Format_RGB888);
                     firstOp = true;
                }

                QPainter painter(&tileAssembly->tileImage);

                // Clear the background to white before the first operation
                if (firstOp)
                {
                    painter.fillRect(QRectF(0.0f, 0.0f, tileAssembly->tileImage.width(), tileAssembly->tileImage.height()), Qt::white);
                }

                painter.setRenderHints(QPainter::SmoothPixmapTransform, true);

                // A hack to work around some drawing problems that left occasional gaps
                // in tiles. There's either a bug in Qt's painter class, or some trouble
                // with roundoff errors. Increasing the rectangle size very slightly
                // eliminates the gaps.
                QRectF r(op.subrect);
                r.setSize(QSizeF(r.width() * 1.0001f, r.height() * 1.0001f));
                painter.drawImage(r, image);
                painter.end();

                tileAssembly->requestCount--;
                if (tileAssembly->requestCount == 0)
                {
                    QString imageName = tileFileName(tileAssembly->tileName, tileAssembly->surfaceName);
                    QFileInfo fileInfo(imageName);
                    QDir tileDir = fileInfo.dir();
                    if (!tileDir.exists())
                    {
                        tileDir.mkpath(tileDir.absolutePath());
                    }

                    bool ok = tileAssembly->tileImage.save(imageName);
                    if (!ok)
                    {
                        qDebug() << "Failed writing to " << imageName;
                    }

                    emit imageCompleted(tileAssembly->tileName, tileAssembly->tileImage.rgbSwapped());
                    delete tileAssembly;
                }
            }
        }
    }
    else
    {
        qDebug() << "Network error: " << reply->errorString();
    }

    reply->deleteLater();

    // If there are queued tiled requests and not too many active WMS server connections,
    // then make some more network requests. Prioritize requests for textures tiles that
    // are currently visible.
    while (m_dispatchedRequestCount < MaxOutstandingNetworkRequests)
    {
        int tileIndex = -1;
        vesta::v_uint64 mostRecent = 0;
        TileBuildOperation op;
        {
//.........这里部分代码省略.........
开发者ID:DrDrake,项目名称:cosmographia,代码行数:101,代码来源:WMSRequester.cpp


注:本文中的QDir::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。