本文整理汇总了C++中QFile::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ QFile::setName方法的具体用法?C++ QFile::setName怎么用?C++ QFile::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFile
的用法示例。
在下文中一共展示了QFile::setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XmlDbBackend
void MultipleBackendsTest::xml2xml()
{
DbBackendIface *backend1 = new XmlDbBackend( "database.xml" );
Manager *manager1 = new Manager( backend1 );
manager1->createSchema();
DbBackendIface *backend2 = new XmlDbBackend( "database2.xml", true );
Manager *manager2 = new Manager( backend2 );
manager2->createSchema();
manager1->copyTo( manager2 );
manager2->commit();
delete manager2;
delete manager1;
QFile file;
QByteArray a1, a2;
file.setName( "database.xml" );
CHECK( file.open( IO_ReadOnly ), true );
a1 = file.readAll();
file.close();
file.setName( "database2.xml" );
CHECK( file.open( IO_ReadOnly ), true );
a2 = file.readAll();
file.close();
CHECK( a1, a2 );
}
示例2: 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);
}
示例3: 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"));
}
示例4: creates
void MultipleBackendsTest::creates()
{
DbBackendIface *backend1 = new XmlDbBackend( "databaseA.xml", true );
Manager *m1 = new Manager( backend1 );
DbBackendIface *backend2 = new XmlDbBackend( "databaseB.xml", true );
Manager *m2 = new Manager( backend2 );
ObjectRef<Customer> c1 = Customer::create( m1 );
c1->setCustomerName( "Customer Name" );
ObjectRef<Customer> c2 = Customer::create( m2 );
c2->setCustomerName( "Customer Name" );
CHECK( m1->objects().count(), m2->objects().count() );
CHECK( m1->commit(), true );
CHECK( m2->commit(), true );
QFile file;
QByteArray a1, a2;
file.setName( "databaseA.xml" );
CHECK( file.open( IO_ReadOnly ), true );
a1 = file.readAll();
file.close();
file.setName( "databaseB.xml" );
CHECK( file.open( IO_ReadOnly ), true );
a2 = file.readAll();
file.close();
CHECK( a1, a2 );
delete m1;
delete m2;
}
示例5: insertDirectory
// ---------------------------------------------------------------
int PackageDialog::insertDirectory(const QString& DirName,
QDataStream& Stream)
{
QFile File;
QDir myDir(DirName);
// Put all files of this directory into the package.
QStringList Entries = myDir.entryList("*", QDir::Files, QDir::Name);
QStringList::iterator it;
for(it = Entries.begin(); it != Entries.end(); ++it) {
File.setName(myDir.absFilePath(*it));
Stream << Q_UINT32(CODE_FILE);
if(insertFile(*it, File, Stream) < 0)
return -1;
}
// Put all subdirectories into the package.
Entries = myDir.entryList("*", QDir::Dirs, QDir::Name);
Entries.pop_front(); // delete "." from list
Entries.pop_front(); // delete ".." from list
for(it = Entries.begin(); it != Entries.end(); ++it) {
Stream << Q_UINT32(CODE_DIR) << (*it).latin1();
if(insertDirectory(myDir.absPath()+QDir::separator()+(*it), Stream) < 0)
return -1;
Stream << Q_UINT32(CODE_DIR_END) << Q_UINT32(0);
}
return 0;
}
示例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 {
示例7: QString
/*!
*\~english
* Writes text to log.
*\~russian
* Пишет текст в лог.
*\~
* \param log_name - \~english Full path to logfile \~russian Полный путь к лог файлу \~
* \param test_name - \~english Test name \~russian Имя теста \~
* \param status - \~english OK, ERROR or SKIP \~russian OK, ОШИБКА или ПРОПУЩЕН \~
* \param text - \~english Comment \~russian Комментарий \~
*/
void
aTests::print2log( const QString &log_name,
const QString &test_name,
const QString &status,
const QString &text)
{
QString toWrite = QString("%1::%2::%3::%4\r\n")\
.arg(QDateTime::currentDateTime().toString(Qt::ISODate).replace('T',' '))\
.arg(test_name)\
.arg(status)\
.arg(text);
QFile f;
if(log_name==QString::null)
{
f.open( QIODevice::WriteOnly, stdout );
f.writeBlock((const char*)toWrite,strlen((const char*)toWrite));
}
else
{
f.setName(log_name);
f.open( QIODevice::WriteOnly | QIODevice::Append );
f.writeBlock((const char*)toWrite,strlen((const char*)toWrite));
f.flush();
}
f.close();
// else printf("error write to log\n");
}
示例8: tr
/*!
* \en
* Gets name for new template. Need for OpenOffice v2.
* \_en
* \ru
* Получение имени для нового шаблона. Нужна из-за блокировок в OpenOffice v2.
* \_ru
*/
QString
aReport::getName4NewTemplate()
{
uint count=0;
QFile tmpf;
QString suff = ".odt";
QString fname;
if(type==RT_office_calc) suff = ".ods";
if(type==RT_msoffice_word || type==RT_msoffice_excel) suff = ".xml";
do
{
// tpl->getDir() должно заканчиваться на /
fname = QDir::convertSeparators(QString(tpl->getDir()+".ananas-report%1%2").arg(count).arg(suff));
tmpf.setName(fname);
if(tmpf.exists())
{
if(tmpf.remove()) break;
else ++count;
}
else
{
break;
}
}while(count<100);
aLog::print(aLog::MT_DEBUG, tr("aReport: name for template = %1").arg(fname));
return fname;
}
示例9: stream
Agent::Agent() : QObject(NULL, "agent")
{
kdebugf();
connect(gadu, SIGNAL(userStatusChangeIgnored(UinType)), this, SLOT(userFound(UinType)));
// Main menu entry
agentActionDescription = new ActionDescription(
ActionDescription::TypeMainMenu, "agentAction",
this, SLOT(resultsRequest()),
"Agent", tr("Who has me on list")
);
kadu->insertMenuActionDescription(0, agentActionDescription);
if(config_file.readBoolEntry("Agent", "FirstTime", true))
{
QFile listFile;
listFile.setName(QString(ggPath("spy-unknownslist").ascii()));
if(listFile.open(IO_ReadOnly))
{
if(MessageBox::ask(tr("Agent has founded spy's unknown-users list. Do you want to append this list to agent module?")))
{
QTextStream stream(&listFile);
QString uin_str, date_str, line;
bool ok;
while (!stream.atEnd())
{
UnknownUser user;
bool isAlready = false;
line = stream.readLine();
uin_str = line.section(',', 0, 0);
date_str = line.section(',', 1, 1);
unsigned int uin_int = uin_str.toUInt(&ok, 10);
if(!ok)
kdebugm(KDEBUG_PANIC, "Couldn't cast QString to int");
foreach(UnknownUser user, UnknownsList)
{
if (user.uin == uin_int)
{
isAlready = true;
break;
}
}
if (!isAlready)
{
user.uin = uin_int;
user.date = QDate::fromString(date_str, Qt::ISODate);
user.seq = 0;
UnknownsList.append(user);
}
}
}
listFile.close();
}
示例10: initDaemon
int initDaemon()
{
pid_t pid;
QString s;
QString pidFileName;
QFile pidFile;
// we probably have a nice little race condition here that I am not
// going to worry about right now.
s.sprintf("%s/share/apps/korganizer",KApplication::localkdedir().data());
qd.setPath(s.data());
pidFileName.sprintf("%s/alarmd.pid",s.data());
pidFile.setName(pidFileName.data());
// a lock file already exists, don't start up.
if (pidFile.exists()) {
if(pidFile.open(IO_ReadOnly)) {
pid_t pid;
char pidStr[25];
pidFile.readLine(pidStr, 24);
pidFile.close();
pid = atoi(pidStr);
if (kill(pid, SIGUSR1) < 0) {
// stale lockfile
unlink(pidFileName.data()); // get rid of old lockfile
}
}
}
// if the PID file still exists, a daemon really is running.
// quit silently.
if (pidFile.exists()) {
exit(0);
} else {
// make ourselves a daemon
if ((pid = fork()) < 0)
return(-1); // we had an error forking
else if (pid != 0) {
// make a lock file.
pidFile.open(IO_ReadWrite);
s.sprintf("%d",pid);
pidFile.writeBlock(s.data(), s.length());
pidFile.close();
exit(0); // parent dies silently
}
// child continues
setsid();
if (getenv("$HOME") != NULL)
chdir(getenv("$HOME"));
umask(0);
}
return(0);
}
示例11: writeDesk
bool Desk::writeDesk (void)
{
QFile file;
QString fname;
// remove any old file
fname = _dir + "/maxdesk.ini";
file.setName (fname);
if (file.exists ())
file.remove ();
fname = _dir + "/MaxDesk.ini";
file.setName (fname);
if (file.exists ())
file.remove ();
file.setName (_dir + DESK_FNAME);
if (file.exists ())
file.remove ();
QTextStream stream( &file );
QString line;
if (!file.open (QIODevice::WriteOnly))
return false;
// write header
stream << "[DesktopFile]" << endl;
stream << "File=" << endl;
stream << endl;
stream << "[Folder]" << endl;
stream << "Version=0x00060000" << endl;
stream << endl;
stream << "[Files]" << endl;
// output the file list
foreach (File *f, _files)
f->encodeFile (stream);
_dirty = false; // we are clean again
return true;
}
示例12: insertLibraries
// ---------------------------------------------------------------
int PackageDialog::insertLibraries(QDataStream& Stream)
{
QFile File;
QDir myDir(QucsSettings.QucsHomeDir.absPath() + QDir::separator() + "user_lib");
QStringList Entries = myDir.entryList("*", QDir::Files, QDir::Name);
QStringList::iterator it;
for(it = Entries.begin(); it != Entries.end(); ++it) {
File.setName(myDir.absFilePath(*it));
Stream << Q_UINT32(CODE_LIBRARY);
if(insertFile(*it, File, Stream) < 0)
return -1;
}
return 0;
}
示例13: InMemorySqlDbBackend
void MultipleBackendsTest::sql2xml()
{
QString dbname = "testmultiple";
QSqlDatabase *db = QSqlDatabase::addDatabase( "QPSQL7" );
db->setDatabaseName( dbname );
db->setUserName( "ak213" );
db->setPassword( "ak" );
db->setHostName( "localhost" );
if ( ! db->open() ) {
kdDebug() << "Failed to open database: " << db->lastError().text() << endl;
return;
}
DbBackendIface *backend1 = new InMemorySqlDbBackend( db );
Manager *manager1 = new Manager( backend1 );
DbBackendIface *backend2 = new XmlDbBackend( "database3.xml", true );
Manager *manager2 = new Manager( backend2 );
manager1->copyTo( manager2 );
manager2->commit();
delete manager1;
delete manager2;
QSqlDatabase::removeDatabase( db );
QFile file;
QByteArray a1, a2;
file.setName( "database.xml" );
CHECK( file.open( IO_ReadOnly ), true );
a1 = file.readAll();
file.close();
file.setName( "database3.xml" );
CHECK( file.open( IO_ReadOnly ), true );
a2 = file.readAll();
file.close();
CHECK( a1, a2 );
}
示例14: get_dri_device
static bool get_dri_device()
{
QFile file;
file.setName(INFO_DRI);
if (!file.exists() || !file.open(QIODevice::ReadOnly))
return false;
QTextStream stream(&file);
QString line = stream.readLine();
if (!line.isEmpty()) {
dri_info.module = line.mid(0, line.indexOf(0x20));
// possible formats, for regression testing
// line = " PCI:01:00:0";
// line = " pci:0000:01:00.0"
QRegExp rx = QRegExp("\\b[Pp][Cc][Ii][:]([0-9a-fA-F]+[:])?([0-9a-fA-F]+[:][0-9a-fA-F]+[:.][0-9a-fA-F]+)\\b");
if (rx.indexIn(line)>0) {
dri_info.pci = rx.cap(2);
int end = dri_info.pci.lastIndexOf(':');
int end2 = dri_info.pci.lastIndexOf('.');
if (end2>end) end=end2;
dri_info.pci[end]='.';
QString cmd = QString("lspci -m -v -s ") + dri_info.pci;
QStringList pci_info;
int num;
if (((num = ReadPipe(cmd, pci_info)) ||
(num = ReadPipe("/sbin/"+cmd, pci_info)) ||
(num = ReadPipe("/usr/sbin/"+cmd, pci_info)) ||
(num = ReadPipe("/usr/local/sbin/"+cmd, pci_info))) && num>=7) {
for (int i=2; i<=6; i++) {
line = pci_info[i];
line.remove(QRegExp("[^:]*:[ ]*"));
switch (i){
case 2: dri_info.vendor = line; break;
case 3: dri_info.device = line; break;
case 4: dri_info.subvendor = line; break;
case 6: dri_info.rev = line; break;
}
}
return true;
}
}
}
return false;
}
示例15: 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);
}