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


C++ QFile::name方法代码示例

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


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

示例1: checkHeader

bool BinaryFormat::checkHeader(QDataStream &stream) const
{
    Q_UINT32 magic, version;

    stream >> magic >> version;

    QFile *file = dynamic_cast< QFile * >(stream.device());

    if(!file)
    {
        kdError() << i18n("Not a file?") << endl;
        return false;
    }

    if(magic != 0x2e93e)
    {
        kdError() << i18n("File '%1' is not binary format.").arg(file->name()) << endl;
        return false;
    }

    if(version != BINARY_FORMAT_VERSION)
    {
        kdError() << i18n("File '%1' is the wrong version.").arg(file->name()) << endl;
        return false;
    }

    return true;
}
开发者ID:serghei,项目名称:kde3-kdelibs,代码行数:28,代码来源:binaryformat.cpp

示例2: tr

void
aBackup::cleanupTmpFiles(const QString& tmpDirName, QStringList *files)
{
	QFile file;
	QDir dir;
	file.setName(QDir::convertSeparators(tmpDirName+"/content.xml"));
	aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name()));
	file.remove();
	file.setName(QDir::convertSeparators(tmpDirName+"/busines-schema.cfg"));
	aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name()));
	file.remove();
	file.setName(QDir::convertSeparators(tmpDirName+"/META-INF/manifest.xml"));
	aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name()));
	file.remove();
	for(uint i=0; i<files->count(); i++)
	{
			file.setName(QDir::convertSeparators(tmpDirName + "/templates/"+ (*files)[i]));
			aLog::print(aLog::Debug, tr("aBackup delete file %1").arg(file.name()));
			file.remove();
	}
	aLog::print(aLog::Debug, tr("aBackup delete directory %1").arg(tmpDirName + "/META-INF"));
	dir.rmdir(QDir::convertSeparators(tmpDirName + "/META-INF"));
	aLog::print(aLog::Debug, tr("aBackup delete directory %1").arg(tmpDirName + "/templates"));
	dir.rmdir(QDir::convertSeparators(tmpDirName + "/templates"));
	aLog::print(aLog::Debug, tr("aBackup delete directory %1").arg(tmpDirName));
	dir.rmdir(QDir::convertSeparators(tmpDirName));
	aLog::print(aLog::Info, tr("aBackup cleanup temporary files"));

}
开发者ID:heiheshang,项目名称:ananas-labs-qt4,代码行数:29,代码来源:adataexchange.cpp

示例3: setFile

void QFileInfo::setFile( const QFile &file )
{
    fn	= file.name();
    slashify( fn );
    delete fic;
    fic = 0;
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:7,代码来源:qfileinfo.cpp

示例4: parseFile

bool KlustersXmlReader::parseFile(const QFile& file,fileType type){
 this->type = type;
  
 // Init libxml
 xmlInitParser();

 // Load XML document
 doc = xmlParseFile(file.name());
 if(doc == NULL) return false;
 
 // Create xpath evaluation context
 xpathContex = xmlXPathNewContext(doc);
 if(xpathContex== NULL){
  xmlFreeDoc(doc);
  return false;   
 }

 //Read the document version
 xmlNodePtr rootElement = xmlDocGetRootElement(doc);
 xmlChar* versionTag = xmlCharStrdup(VERSION);
 if(rootElement != NULL){
  xmlChar* sVersion = xmlGetProp(rootElement,versionTag);
  if(sVersion != NULL) readVersion = QString((char*)sVersion);
  xmlFree(sVersion);
 }
 xmlFree(versionTag);

 return true;
}
开发者ID:caffeine-xx,项目名称:klusters,代码行数:29,代码来源:klustersxmlreader.cpp

示例5: resetPage

//=====================================
// XAccessX reset and switch to Intro
//-------------------------------------
void XAccessX::resetPage (int reload) {
	// ...
	// this function is called if the xaccess dialog is finished or canceled
	// AccessX is an X11 extension which need a seperate configuration file
	// which is outside of the normal configuration create via ISaX. Therefore
	// we don`t need to serialize any data here
	// ---
	if (reload == PAGE_RELOAD) {
	if (mEnable -> isChecked()) {
		QFile* mHandle = new QFile (
			"/usr/X11R6/lib/X11/xkb/X0-config.keyboard"
		);
		if (! mHandle -> open(IO_WriteOnly)) {
		log (L_ERROR,
			"XAccessX::open failed on: %s -> %s\n",
			mHandle->name().ascii(),strerror(errno)
		);
		}
		QString* speed = new QString();
		speed -> sprintf ( 
			"%d",mLCD -> intValue()
		);
		QDict<char> data;
		data.insert ("MouseKeysMaxSpeed=" , 
			speed->ascii()
		);
		data.insert ("MouseKeysDelay="    , "40");
		data.insert ("MouseKeysInterval=" , "10" );
		data.insert ("MouseKeysTimeToMax=", "1000" );
		data.insert ("MouseKeysCurve="    , "0"  );
		data.insert ("Controls+=","MouseKeysAccel");
		#if 0
		data.insert ("Controls+=",
			"MouseKeysAccel + AccessxKeys"
		);
		data.insert ("Feedback+=",
			"SlowKeysPress + SlowKeysAccept + StickyKeys + LatchToLock"
		);
		#endif
		QDictIterator<char> it (data);
		for (; it.current(); ++it) {
			QString line;
			line.sprintf ("%s %s\n",
				it.currentKey().ascii(),it.current()
			);
			mHandle -> writeBlock (
				line.ascii(),line.length()
			);
		}
		mHandle -> close();
	}
	}
	if (reload == PAGE_RELOAD) {
		slotApply();
	}
	mStatus -> clear();
	slotIntro (mIndex);
	XTemplate::resetPage ();
	mStack -> raiseWidget (Intro);
}
开发者ID:BackupTheBerlios,项目名称:sax-svn,代码行数:63,代码来源:accessxhandler.cpp

示例6: kMailOpenComposer

//// Send the def file as body of the message.
//int KLMailClient::kMailOpenComposer(const QString& arg0,const QString& arg1, const QString& arg2,const QString& arg3,const QString& arg4,int arg5, const KURL& arg6) {
//  int result = 0;
//
//   QString attfn = QString(arg6.path().utf8());
//   QFile attfile;
//    attfile.setName(attfn);
//    if (attfile.open(IO_ReadOnly) == false)
//    	cout << "Could not open file: " << attfile.name();
//  QByteArray data, replyData;
//  QCString replyType;
//  QDataStream arg( data, IO_WriteOnly );
//  arg << arg0; // to
//  arg << arg1;  // cc
//  arg << arg2; // bcc
//  arg << arg3; //subject
//  arg << arg4; //body
//  arg << arg5; // hidden=0
//  arg << attfile.readAll(); // KURL messageFile
//  cout << "In kMailOpenComposer version 1: arg6=" << arg6.path().utf8() << endl;
//  cout << "In kMailOpenComposer version 1: data=" << data << endl;
//  if (kapp->dcopClient()->call("kmail","KMailIface","openComposer(QString,QString,QString,QString,QString,int,KURL)", data, replyType, replyData ) ) {
//    if ( replyType == "int" ) {
//      QDataStream _reply_stream( replyData, IO_ReadOnly );
//      _reply_stream >> result;
//    } else {
//      kdDebug() << "kMailOpenComposer() call failed." << endl;
//    }
//  } else {
//    kdDebug() << "kMailOpenComposer() call failed." << endl;
//  }
//  return result;
//}
// Create an email and add the def file as an attachment.
int KLMailClient::kMailOpenComposer( const QString& arg0, const QString& arg1, const QString& arg2, const QString& arg3,
                                     const QString& arg4, int arg5, const QString& arg6, const QCString& arg7, const QCString& arg8,
                                     const QCString& arg9, const QCString& arg10, const QCString& arg11, const QString& arg12, const QCString& arg13 ) {

    int result = 0;
    QString attfn = QString(arg8);
    QFile attfile;
    attfile.setName(attfn);
    if (attfile.open(IO_ReadOnly) == false)
    	cout << "Could not open file: " << attfile.name();
    QByteArray data, replyData;
    QCString replyType;
    QDataStream arg( data, IO_WriteOnly );
    arg << arg0; //to
    arg << arg1; // cc
    arg << arg2; // from (bcc)
    arg << arg3; //subject
    arg << arg4; //body
    arg << arg5; // hidden=0
    arg << arg6; // attachName
    arg << arg7; // "7bit" (attachCte)
    arg << attfile.readAll(); //attachment (attachData)
    arg << arg9; // "text" (attachType)
    arg << arg10; // "calendar" (attachSubType)
    arg << arg11; // "method" (attachParamAttr)
    arg << arg12; // "publish" (attachParamValue)
    arg << arg13; // "attachment" (attachContDisp)
    if ( kapp->dcopClient()->call("kmail","KMailIface","openComposer(QString,QString,QString,QString,QString,int,QString,QCString,QCString,QCString,QCString,QCString,QString,QCString)", data, replyType, replyData ) ) {
        if ( replyType == "int" ) {
            QDataStream _reply_stream( replyData, IO_ReadOnly );
            _reply_stream >> result;
        } else {
开发者ID:paulmadore,项目名称:G-Keymap,代码行数:66,代码来源:klmailclient.cpp

示例7: fi

bool
DspMakefileGenerator::openOutput(QFile &file) const
{
    QString outdir;
    if(!file.name().isEmpty()) {
	if(QDir::isRelativePath(file.name()))
	    file.setName(Option::output_dir + file.name()); //pwd when qmake was run
	QFileInfo fi(file);
	if(fi.isDir())
	    outdir = file.name() + QDir::separator();
    }
    if(!outdir.isEmpty() || file.name().isEmpty())
	file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION"));
    if(QDir::isRelativePath(file.name())) {
	QString ofile;
	ofile = file.name();
	int slashfind = ofile.findRev('\\');
	if (slashfind == -1) {
	    ofile = ofile.replace(QRegExp("-"), "_");
	} else {
	    int hypenfind = ofile.find('-', slashfind);
	    while (hypenfind != -1 && slashfind < hypenfind) {
		ofile = ofile.replace(hypenfind, 1, "_");
		hypenfind = ofile.find('-', hypenfind + 1);
	    }
	}
	file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile));
    }
    return Win32MakefileGenerator::openOutput(file);
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:30,代码来源:msvc_dsp.cpp

示例8: fi

bool
ProjectGenerator::openOutput(QFile &file) const
{
    QString outdir;
    if(!file.name().isEmpty()) {
	QFileInfo fi(file);
	if(fi.isDir())
	    outdir = fi.dirPath() + QDir::separator();
    }
    if(!outdir.isEmpty() || file.name().isEmpty()) {
	QString dir = QDir::currentDirPath();
	int s = dir.findRev('/');
	if(s != -1)
	    dir = dir.right(dir.length() - (s + 1));
	file.setName(outdir + dir + ".pro");
    }
    return MakefileGenerator::openOutput(file);
}
开发者ID:opieproject,项目名称:opie,代码行数:18,代码来源:projectgenerator.cpp

示例9: slashify

QFileInfo::QFileInfo( const QFile &file )
{
    fn	  = file.name();
    slashify( fn );
    fic	  = 0;
    cache = TRUE;
#if defined(Q_OS_UNIX)
    symLink = FALSE;
#endif
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:10,代码来源:qfileinfo.cpp

示例10: qfile

Sound * qGo::retrieveSound(const char * filename, SearchPath& sp)
{
  	QFile qfile(filename);
  	QFile * foundFile = sp.findFile(qfile);
	QString msg(filename);
  	if (! foundFile) 
	{
    		QString msg(filename);
    		msg.append(" not found");
    		qDebug(msg);
    		return (Sound *) NULL;
  	}
	else 
	{
		msg.append(" found : " + foundFile->name());
		qDebug(msg);
    		return SoundFactory::newSound(foundFile->name());
  	}
}
开发者ID:alserkli,项目名称:q4Go,代码行数:19,代码来源:qgo.cpp

示例11: loadTemplateFile

bool TrendPw::loadTemplateFile( )
{
  ConfigRC conf_rc; 

  QFile f ( QString::fromStdString(conf_rc.getVisPredefPwPath( ) + "/trendpw.xml") );
  
  if ( !f.open( QIODevice::ReadOnly ) ) {
qDebug("Cant load file!!! %s %s", f.name().ascii(), __PRETTY_FUNCTION__ );
    return false;
  }
  
  if ( !pw_xml_template.setContent( &f ) ) {
qDebug("SET CONTENT FAILED!!! %s %s", f.name().ascii(), __PRETTY_FUNCTION__ );  
    f.close();  
    return false;
  }
  
  f.close();
  
  return true;
}
开发者ID:obrpasha,项目名称:votlis_krizh_gaz_nas,代码行数:21,代码来源:predefpws.cpp

示例12: open_file

static int open_file(QFile & fp, BooL & ro)
{
  QString filename = fp.name();
  
  while (! fp.open(QIODevice::ReadOnly)) {
    if (QMessageBox::critical(0, "Uml",
			      filename + "\ncannot be opened for read, retry ?\n",
			      "yes", "no", 0, 0, 0) != 0)
      return -1;
  }
  
  QFileInfo fi(fp);
  
  ro = !fi.isWritable();
  
  return fi.size();
}
开发者ID:SciBoy,项目名称:douml,代码行数:17,代码来源:myio.cpp

示例13: sendFile

/*
 * let's call the one with the filename
 */
void FileTransfer::sendFile( const QFile& file ) {
    sendFile( file.name() );
}
开发者ID:opieproject,项目名称:opie,代码行数:6,代码来源:filetransfer.cpp

示例14: loadSettings

void Setting::loadSettings()
{
	QFile file;

	// set under Linux
	settingHomeDir = QString(getenv("HOME"));
	if (!settingHomeDir)
		// set under Windows
		settingHomeDir = QString(getenv("USERPROFILE"));
	if (!settingHomeDir)
	{
		// however...
		qDebug("HOME and/or USERPROFILE are not set");
		settingHomeDir = QDir::homeDirPath();
		file.setName(settingHomeDir + "/.qgoclientrc");
		if (file.exists())
		{
			// rename, but use it anyway
			QString oldName = ".qgoclientrc";
			QString newName = ".qgoclientrc.bak";
			QDir::home().rename(oldName, newName);
			file.setName(settingHomeDir + "/.qgoclientrc.bak");
		}
		else
			// file may be already renamed
			file.setName(settingHomeDir + "/." + PACKAGE + "rc");
	}
	else
		file.setName(settingHomeDir + "/." + PACKAGE + "rc");

	if (!file.exists() || !file.open(IO_ReadOnly))
	{
		qDebug("Failed loading settings: " + file.name());

		// maybe old file available
		file.setName(QDir::homeDirPath() + "/.qgoclientrc");

		if (!file.exists() || !file.open(IO_ReadOnly))
		{
			qWarning("Failed loading settings: " + file.name());
			return;
		}
	}

	qDebug("Use settings: " + file.name());

	// read file
	QTextStream txt(&file);
	QString s;
	int pos, pos1, pos2;
	while (!txt.eof())
	{
		s = txt.readLine();
		if (s.length() > 2)
		{
			// ' ' is delitmiter between key and txt
			pos = s.find(' ');
			// find first '['
			pos1 = s.find('[');
			// find last ']'
			pos2 = s.findRev(']');
			writeEntry(s.left(pos), s.mid(pos1 + 1, pos2 - pos1 - 1));
		}
	}

	file.close();

	// init fonts and colors
	updateFont(fontStandard, "FONT_MAIN");
	updateFont(fontMarks, "FONT_MARK");
	updateFont(fontComments, "FONT_COMMENT");
	updateFont(fontLists, "FONT_LIST");
	updateFont(fontClocks, "FONT_CLOCK");
	updateFont(fontConsole, "FONT_CONSOLE");
 	s = readEntry("COLOR_BK");
	if (s)
		colorBackground = QColor(s);
	s = readEntry("COLOR_ALT_BK");
	if (s)
		colorAltBackground = QColor(s);
	s=readEntry("CHARSET");
	charset->blackStone = s.constref(0);
	charset->emptyPoint = s.constref(1);
	charset->hBorder = s.constref(2);
	charset->starPoint = s.constref(3);
	charset->vBorder = s.constref(4);
	charset->whiteStone = s.constref(5);  
}
开发者ID:rd8,项目名称:qGo,代码行数:88,代码来源:setting.cpp

示例15: writeClass

// main method for invoking..
void XMLSchemaWriter::writeClass(UMLClassifier *c)
{

    if (!c) {
        kDebug()<<"Cannot write class of NULL classifier!\n";
        return;
    }

    // find an appropriate name for our file
    QString fileName = findFileName(c,".xsd");

    if (fileName.isEmpty()) {
        emit codeGenerated(c, false);
        return;
    }

    // check that we may open that file for writing
    QFile file;
    if ( !openFile(file, fileName) ) {
        emit codeGenerated(c, false);
        return;
    }

    QTextStream XMLschema(&file);

    // set package namespace tag appropriately
    if(!c->getPackage().isEmpty())
        packageNamespaceTag = c->getPackage();

    // START WRITING

    // 0. FIRST THING: open the xml processing instruction. This MUST be
    // the first thing in the file
    XMLschema<<"<?xml version=\"1.0\"?>"<<m_endl;

    // 1. create the header
    QString headerText = getHeadingFile(".xsd");
    if(!headerText.isEmpty()) {
        headerText.replace(QRegExp("%filename%"),fileName);
        headerText.replace(QRegExp("%filepath%"),file.name());
    }
    if(!headerText.isEmpty())
        XMLschema<<headerText<<m_endl;

    // 2. Open schema element node with appropriate namespace decl
    XMLschema<<"<"<<makeSchemaTag("schema");
    // common namespaces we know will be in the file..
    XMLschema<<" targetNamespace=\""<<packageNamespaceURI+packageNamespaceTag<<"\""<<m_endl;
    XMLschema<<" xmlns:"<<schemaNamespaceTag<<"=\""<<schemaNamespaceURI<<"\"";
    XMLschema<<" xmlns:"<<packageNamespaceTag<<"=\""<<packageNamespaceURI+packageNamespaceTag<<"\"";

    XMLschema<<">"<<m_endl; // close opening declaration

    m_indentLevel++;

    // 3? IMPORT statements -- do we need to do anything here? I suppose if
    // our document has more than one package, which is possible, we are missing
    // the correct import statements. Leave that for later at this time.
    /*
    //only import classes in a different package as this class
    UMLPackageList imports;
    findObjectsRelated(c,imports);
    for(UMLPackage *con = imports.first(); con ; con = imports.next())
        if(con->getPackage() != c->getPackage())
                XMLschema<<"import "<<con->getPackage()<<"."<<cleanName(con->getName())<<";"<<m_endl;
    */

    // 4. BODY of the schema.
    // start the writing by sending this classifier, the "root" for this particular
    // schema, to writeClassifier method, which will subsequently call itself on all
    // related classifiers and thus populate the schema.
    writeClassifier(c, XMLschema);

    // 5. What remains is to make the root node declaration
    XMLschema<<m_endl;
    writeElementDecl(getElementName(c), getElementTypeName(c), XMLschema);

    // 6. Finished: now we may close schema decl
    m_indentLevel--;
    XMLschema<<getIndent()<<"</"<<makeSchemaTag("schema")<<">"<<m_endl; // finished.. close schema node

    // bookeeping for code generation
    emit codeGenerated(c, true);

    // tidy up. no dangling open files please..
    file.close();

    // need to clear HERE, NOT in the destructor because we want each
    // schema that we write to have all related classes.
    writtenClassifiers.clear();
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:92,代码来源:xmlschemawriter.cpp


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