⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yconfigure.cpp

📁 世界时间转换程序
💻 CPP
字号:
/****************************************************************************** $Id: yconfigure.cpp     edited 2005-12-18 $**** Copyright (C) 2005 Wya AS.  All rights reserved.**** ** program may be used, distributed and modified without limitation.******************************************************************************/#include <QFile>#include <QTextStream>#include <QMessageBox>#include <QDir>#include "ydefine.h"#include "yconfigure.h"#ifdef WIN_CONFIGURATIONconst QString  FILE_WORLDTIMER= "/worldtimer.ini";const QString  FILE_STOPWATCH="/stopwatch.log";#endif#ifdef LINUX_CONFIGURATIONconst QString FILE_WORLDTIMER= "/worldtimer.cnf";const QString FILE_STOPWATCH = "/stopwatch.log";#endif/////////////////////////////////////////////////////////////////////////////////get parameter for traceviewYConfigure::YConfigure(QObject * parent ,const QString &fileName)    :QObject(parent){	paraFileName=  CONFIGURATION_DIR +FILE_WORLDTIMER;//get default file name	if(!QFile::exists(paraFileName)) {     setDefaultValue(); }   else {   loadCnf();  } }//////////////////////////////////////////////////////////////////////////////get the parameter from a file bool YConfigure::loadCnf(){    bool isFileOk=false;     QString str;  yDebug(" file conf "+paraFileName);  QFile file(paraFileName);         yDebug(" configure file Name is exited");          	if ( !file.open( ( QIODevice::ReadOnly ) ) )	     return isFileOk;        QTextStream ts( &file );		//get the chinatimeoffset		str=ts.readLine();		if(str.contains("$CHINA:"))		{			m_ChinaTimeOffset=str.remove("$CHINA:");					}		else		{            m_ChinaTimeOffset="0";		}		//get europe time		str=ts.readLine();		if(str.contains("$EUROPE:"))		{			m_EuropeTimeOffset=str.remove("$EUROPE:");					}		else		{            m_EuropeTimeOffset="0";           		}		//get usa time        str=ts.readLine();		if(str.contains("$USA:"))		{			m_UsaTimeOffset=str.remove("$USA:");		}		else		{            m_UsaTimeOffset="0";		}		 str=ts.readLine();		if(str.contains("$LOGFILE:"))		{			m_StopWatchLogFile=str.remove("$LOGFILE:");		}		else		{            m_StopWatchLogFile=CONFIGURATION_DIR +FILE_STOPWATCH;		}					file.close();   return isFileOk=true;}////////////////////////////////////////////////////////////////////////////// when sortie we save the parameter to the filevoid YConfigure::saveConf(){   QFile file(paraFileName);     if ( !file.open( ( QIODevice::WriteOnly ) )  )       {	     yDebug("can't save parameter to the file"+paraFileName);	            //  setCaption( QString( "Chart -- %1" ).arg( m_filename ) );            QMessageBox::critical( 0, QString("Could not write to %1").arg(paraFileName),				   "Please check file Acess right" );	    	    return;	           }     	               yDebug("Start save parameter to file "+ paraFileName);              QTextStream ts( &file );	  //do something		  QString str =getChinaTimeOffset();		  ts <<"$CHINA:"<<str<<"\n";		  str=getEuropeTimeOffset();		  ts <<"$EUROPE:"<<str<<"\n";		  str=getUsaTimeOffset();		  ts <<"$USA:"<< str<<"\n";		  str=getStopWatchLogFile();	      ts <<"$LOGFILE:"<< str<<"\n";          file.close();}//////////////////////////////////////////////////////////////////////////////save the parameter of traceviewYConfigure::~YConfigure(){  yDebug(" Start deconstruction YConfigure");  }//////////////////////////////////////////////////////////////////////////////set the default value void YConfigure::setDefaultValue(){ #if CHINA_TIME      	 m_ChinaTimeOffset="0";//CHINA     m_EuropeTimeOffset="7";//europe     m_UsaTimeOffset="-16";//Usa#endif#if EURO_TIME     m_ChinaTimeOffset="-7";//CHINA     m_EuropeTimeOffset="0";//europe     m_UsaTimeOffset="-9";//Usa#endif	 m_StopWatchLogFile=CONFIGURATION_DIR +FILE_STOPWATCH;}/////////////////////////////////////////////////////////////////////////////convert the value int to stringvoid YConfigure::setChinaTimeOffset(int i){	QString str = QString::number(i);	setChinaTimeOffset(str);}void YConfigure::setEuropeTimeOffset(int i) {	QString str = QString::number(i);	setEuropeTimeOffset(str);}void YConfigure::setUsaTimeOffset(int i){	QString str = QString::number(i);	setUsaTimeOffset( str );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -