本文整理汇总了C++中QFileInfoList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfoList::size方法的具体用法?C++ QFileInfoList::size怎么用?C++ QFileInfoList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfoList
的用法示例。
在下文中一共展示了QFileInfoList::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReplaceAppPakInSrc
/**********
*返回值:0成功
*1原包名不存在
*2创建包出错
*3目的包名已经存在
*4替换包名过程出错
*5替换app包名出错
***********/
int PathManager::ReplaceAppPakInSrc(QString &path, QString &oldName, QString &newName)
{
QVector<QString> dirNames;
QDir dir(path);
QFileInfoList filst;
QFileInfoList::iterator curFi;
//初始化
dirNames.clear();
if (dir.exists()){
dirNames << path;
}
else{
return 0;
}
bool isTopDir = true;
//遍历各级文件夹,并将这些文件夹中的文件删除
for (int i = 0; i<dirNames.size(); ++i)
{
dir.setPath(dirNames[i]);
filst = dir.entryInfoList(QDir::Dirs | QDir::Files
| QDir::Readable | QDir::Writable
| QDir::Hidden | QDir::NoDotAndDotDot
, QDir::Name);
if (isTopDir){
isTopDir = false;
for (int i = 0; i < filst.size(); i++)
{
if (filst[i].fileName() == "assets" || filst[i].fileName() == "bin" || filst[i].fileName() == "libs"){
filst.removeAt(i);
i--;
}
}
}
if (filst.size()>0){
curFi = filst.begin();
while (curFi != filst.end())
{
//遇到文件夹,则添加至文件夹列表dirs尾部
if (curFi->isDir()){
dirNames.push_back(curFi->filePath());
}
else if (curFi->isFile()){
if (curFi->absoluteFilePath().toLower().endsWith(".java")){
if (!ReplaceAppPakNameInJava(path, curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
else if (curFi->absoluteFilePath().toLower().endsWith(".xml")){
if (!ReplaceAppPakNameInXml(path, curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
}
curFi++;
}//end of while
}
}
if (!ReplaceAppPakNameInManifest(path, oldName, newName)){
return 5;
}
return 0;
}
示例2: scanRecords
void RecordingsModel::scanRecords(const QString &path)
{
Q_ASSERT(mRecorder);
// Current watching directories
auto currentDirs = mWatcher->directories();
// Is the recursive search enabled
auto recursiveSearch = mRecorder->recursiveSearch();
// Check if directory exists and add or remove it and
// its subdirectories to the wathing list
QDir dir(path);
QStringList paths(path);
if (dir.exists())
{
// Check for subdirectories that should be added
if (recursiveSearch)
{
QDirIterator it(path, QDir::Dirs, QDirIterator::Subdirectories);
while (it.hasNext())
{
paths << it.next();
}
}
mWatcher->addPaths(paths);
}
else
{
// Check for subdirectories that should be removed
for (auto d: currentDirs)
{
if (d.startsWith(path))
{
paths << d;
}
}
mWatcher->removePaths(paths);
}
// Scan for updated and removed records
for (int row = mData.size() - 1; row > -1; --row)
{
auto oldFileInfo = mData[row];
// Process entries only of the changed path
if (oldFileInfo.absolutePath() != path)
{
continue;
}
QFileInfo newFileInfo(oldFileInfo);
newFileInfo.refresh();
if (newFileInfo.exists())
{
if (newFileInfo.lastModified() != oldFileInfo.lastModified())
{
// The record was updated
auto index = this->createIndex(row, 0);
emit this->dataChanged(index, index, { Modified });
}
}
else
{
// The record was removed
this->beginRemoveRows(QModelIndex(), row, row);
mData.removeAt(row);
this->endRemoveRows();
}
}
// Scan for new records
auto flags = recursiveSearch ? QDirIterator::Subdirectories : QDirIterator::NoIteratorFlags;
QDirIterator it(path, RecordingsModel::filters, QDir::Files, flags);
QFileInfoList newRecords;
while (it.hasNext())
{
// Add a new record
QFileInfo fileInfo(it.next());
if (!mData.contains(fileInfo))
{
newRecords << fileInfo;
}
}
if (!newRecords.empty())
{
auto pos = mData.size();
this->beginInsertRows(QModelIndex(), pos, pos + newRecords.size() - 1);
mData.append(newRecords);
this->endInsertRows();
}
}
示例3: copyFile
void SelectFile::copyFile(QString path)
{
QDir dir(path);
QFileInfoList list;
QDir flash_dir("C:/pic/SWWYL");
// 复制结果文件到程序用户选择的输出目录
switch (m_pt) {
case HYFM:
// if(m_first_change) {
// m_first_change = false;
// QMessageBox::warning(0,"PATH",path,QMessageBox::Yes);
QThread::sleep(1);
copyDirectoryFiles(path, m_outPath, true );
copyDirectoryFiles(path, "C:/pic/HYFM/", true );
// }
break;
case SWWYL:
list = dir.entryInfoList();
qDebug() << list.size();
if (list.size() == 30+2){
QDir::setCurrent(root_path+"/yubao/wenyanliu/");
QThread::sleep(1);
copyDirectoryFiles(path, m_outPath, true );
// call qie ge program.
QProcess::execute("./QIEGE.exe");
// copy 0,1,2,3,4,5 pic to flash dir.
QDir::setCurrent(root_path+"/yubao/wenyanliu/");
copyDirectoryFiles("./3d_qiege/", "C:/pic/SWWYL_3d/", true );
// copyDirectoryFiles("./flash/", "C:/pic/SWWYL_2d/", true );
QDir::setCurrent(root_path);
}
break;
case ZCDW:
list = dir.entryInfoList();
qDebug() << list.size();
if (list.size() == 101+2){
QDir::setCurrent(root_path+"/yubao/zcdw/");
QThread::sleep(1);
copyDirectoryFiles(path, m_outPath, true );
copyDirectoryFiles(path, "C:/pic/ZCDW/", true );
QDir::setCurrent(root_path);
}
break;
default:
break;
}
}
示例4: compile
bool Dymola::compile(QFileInfo moPath,QString modelToConsider,QDir storeFolder,QFileInfo logFile,
const QFileInfoList & moDeps, QFileInfoList neededFiles)
{
// Create Dymola script
QString filePath = storeFolder.absoluteFilePath("MOFirstRun.mos");
QFile file(filePath);
if(file.exists())
{
file.remove();
}
file.open(QIODevice::WriteOnly);
QString scriptText;
QString curPath;
// load dependencies and model
QFileInfoList moToLoad;
moToLoad.append(moDeps);
moToLoad.push_back(moPath);
LowTools::removeDuplicates(moToLoad);
for(int i=0;i<moToLoad.size();i++)
{
curPath = QDir::fromNativeSeparators(moToLoad.at(i).absoluteFilePath());
scriptText.append("openModel(\""+curPath+"\",false)\n");
}
QString strFolder = QDir::fromNativeSeparators(storeFolder.absolutePath());
QString logFilePath = QDir::fromNativeSeparators(logFile.absoluteFilePath());
scriptText.append("cd "+strFolder+"\n");
scriptText.append("experimentSetupOutput(textual=true)\n");
scriptText.append("Advanced.StoreProtectedVariables:=true;\n");
//scriptText.append("checkModel(\""+modelToConsider+"\",simulate=true)\n");
scriptText.append("translateModel(\""+modelToConsider+"\")\n");
scriptText.append("compile()\n");
scriptText.append("savelog(\""+logFilePath+"\")\n");
scriptText.append("exit\n");
QTextStream ts( &file );
ts << scriptText;
file.close();
// Copy needed files
LowTools::copyFilesInFolder(neededFiles,storeFolder);
// Run script
QString dymolaPath = MOSettings::value("dymolaExe").toString();
QFileInfo dymolaBin(dymolaPath);
if(!dymolaBin.exists())
{
InfoSender::instance()->send(Info("Dymola executable not found. Please verify path in Settings",ListInfo::ERROR2));
return false;
}
else
{
// delete previous dymosim.exe
QFile dymoFile(storeFolder.absoluteFilePath("dymosim.exe"));
if(dymoFile.exists())
dymoFile.remove();
// delete previous dsin file
QFile dsinFile(storeFolder.absoluteFilePath("dsin.txt"));
if(dsinFile.exists())
dsinFile.remove();
// launch script
QProcess scriptProcess;
QStringList args;
args.push_back(filePath);
//start process
InfoSender::sendCurrentTask("Launching Dymola...");
scriptProcess.start(dymolaPath,args);
bool ok = scriptProcess.waitForFinished(-1);
if(!ok)
{
QString msg("CreateProcess failed");
InfoSender::instance()->debug(msg);
return false;
}
//look if it succeed
bool success = dymoFile.exists();
InfoSender::eraseCurrentTask();
return success;
}
}
示例5: GetEntryLists
static PRL_RESULT GetEntryLists(
const QString & aVmHomeDir,
QList<QPair<QFileInfo, QString> > & dirList,
QList<QPair<QFileInfo, QString> > & fileList)
{
QString VmHomeDir = QFileInfo(aVmHomeDir).absoluteFilePath();
QFileInfo dirInfo;
QFileInfoList entryList;
QDir dir;
QDir startDir(VmHomeDir);
int i, j;
QFileInfo config, config_backup, log, statlog;
config.setFile(VmHomeDir, VMDIR_DEFAULT_VM_CONFIG_FILE);
config_backup.setFile(VmHomeDir, VMDIR_DEFAULT_VM_CONFIG_FILE VMDIR_DEFAULT_VM_BACKUP_SUFFIX);
log.setFile(VmHomeDir, "parallels.log");
statlog.setFile(VmHomeDir, PRL_VMTIMING_LOGFILENAME);
dirInfo.setFile(VmHomeDir);
if (!dirInfo.exists()) {
WRITE_TRACE(DBG_FATAL, "Directory %s does not exist", QSTR2UTF8(VmHomeDir));
return (PRL_ERR_VMDIR_INVALID_PATH);
}
dirList.append(qMakePair(dirInfo, QString(".")));
for (i = 0; i < dirList.size(); ++i) {
/* CDir::absoluteDir() is equal CDir::dir() : return parent directory */
dir.setPath(dirList.at(i).first.absoluteFilePath());
entryList = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::Hidden);
WRITE_TRACE(DBG_DEBUG, "Directory %s", QSTR2UTF8(dirList.at(i).first.absoluteFilePath()));
for (j = 0; j < entryList.size(); ++j) {
const QFileInfo& fileInfo = entryList.at(j);
if (dirInfo == fileInfo) {
WRITE_TRACE(DBG_FATAL, "Infinite recursion in : %s", QSTR2UTF8(dirInfo.absoluteFilePath()));
return (PRL_ERR_FAILURE);
}
if (!fileInfo.absoluteFilePath().startsWith(VmHomeDir)) {
WRITE_TRACE(DBG_FATAL, "Path %s does not starts from VM home dir (%s)",
QSTR2UTF8(fileInfo.absoluteFilePath()),
QSTR2UTF8(VmHomeDir));
return PRL_ERR_FAILURE;
}
;
if (fileInfo.isDir()) {
dirList.append(qMakePair(
fileInfo, startDir.relativeFilePath(fileInfo.absoluteFilePath())));
} else {
/* skip config & config backup */
if (fileInfo.absoluteFilePath() == config.absoluteFilePath())
continue;
if (fileInfo.absoluteFilePath() == config_backup.absoluteFilePath())
continue;
/* skip parallels.log */
if (fileInfo.absoluteFilePath() == log.absoluteFilePath())
continue;
if (fileInfo.absoluteFilePath() == statlog.absoluteFilePath())
/* will save statistic.log to temporary file */
fileList.append(qMakePair(statlog,
QString(PRL_VMTIMING_LOGFILENAME VMDIR_DEFAULT_VM_MIGRATE_SUFFIX)));
else
fileList.append(qMakePair(
fileInfo, startDir.relativeFilePath(fileInfo.absoluteFilePath())));
}
WRITE_TRACE(DBG_DEBUG, "%x\t%s.%s\t%s",
int(fileInfo.permissions()),
QSTR2UTF8(fileInfo.owner()),
QSTR2UTF8(fileInfo.group()),
QSTR2UTF8(fileInfo.absoluteFilePath()));
}
entryList.clear();
}
/* remove VM home directory */
dirList.removeFirst();
return (PRL_ERR_SUCCESS);
}
示例6: disconnect
void CCCITT4Client::UpdateFileList()
{
QListWidgetItem *pListItem;
QDir *pDir;
QFileInfoList list;
int i, j;
bool bFileExists, bItemExists;
/* Disconnect the list event while changing the contents */
disconnect(ui->listWidgetFiles, SIGNAL(itemSelectionChanged()), this, SLOT(OnFilesListSelectionChanged()));
/* Obtain a list of all the tif files in the selected directory */
pDir = new QDir(ui->lineEditPath->text());
list = pDir->entryInfoList(QStringList("*.tif"), QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks, QDir::Time);
/* Remove list elements of which the corresponding file does not exist anymore */
for(i = 0; i < ui->listWidgetFiles->count(); i++)
{
pListItem = ui->listWidgetFiles->item(i);
/* Verify if the file exists */
bFileExists = false;
if(pListItem != NULL)
{
for(j = 0; (j < list.size()) && (bFileExists == false); j++)
{
if(list.at(j).fileName().compare(pListItem->text()) == 0)
{
bFileExists = true;
}
}
}
/* Delete the list element if the file doesn't exists */
if(bFileExists == false)
{
ui->listWidgetFiles->removeItemWidget(pListItem);
delete pListItem;
pListItem = NULL;
i = 0;
}
}
/* Iterate over all the files and add them to the list if they are not contained yet */
for(i = 0; i < list.size(); ++i)
{
bItemExists = false;
for(j = 0; j < ui->listWidgetFiles->count(); j++)
{
if(list.at(i).fileName().compare(ui->listWidgetFiles->item(j)->text()) == 0)
{
bItemExists = true;
}
}
if(bItemExists == false)
{
pListItem = new QListWidgetItem(QIcon(list.at(i).absoluteFilePath()), list.at(i).fileName());
ui->listWidgetFiles->addItem(pListItem);
}
}
/* Alternate the backgroundcolor of the list elements */
for(i = 0; i < ui->listWidgetFiles->count(); i++)
{
if(i & 0x1)
{
ui->listWidgetFiles->item(i)->setBackgroundColor(QColor::fromHsv(0,0,240));
}
else
{
ui->listWidgetFiles->item(i)->setBackgroundColor(QColor::fromHsv(0,0,255));
}
}
delete pDir;
/* reconnnect the list event */
connect(ui->listWidgetFiles, SIGNAL(itemSelectionChanged()), this, SLOT(OnFilesListSelectionChanged()));
}
示例7: main
int main(int argc, char *argv[])
{
QString workDir;
#ifdef Q_OS_MAC
if (QDir(QString()).absolutePath() == "/") {
QString first = argc ? QString::fromLocal8Bit(argv[0]) : QString();
if (!first.isEmpty()) {
QFileInfo info(first);
if (info.exists()) {
QDir result(info.absolutePath() + "/../../..");
workDir = result.absolutePath() + '/';
}
}
}
#endif
QString remove;
int version = 0;
QFileInfoList files;
for (int i = 0; i < argc; ++i) {
if (string("-path") == argv[i] && i + 1 < argc) {
QString path = workDir + QString(argv[i + 1]);
QFileInfo info(path);
files.push_back(info);
if (remove.isEmpty()) remove = info.canonicalPath() + "/";
} else if (string("-version") == argv[i] && i + 1 < argc) {
version = QString(argv[i + 1]).toInt();
} else if (string("-dev") == argv[i]) {
DevChannel = true;
}
}
if (files.isEmpty() || remove.isEmpty() || version <= 1016 || version > 999999) { // not for release =)
#ifdef Q_OS_WIN
cout << "Usage: Packer.exe -path {file} -version {version} OR Packer.exe -path {dir} -version {version}\n";
#elif defined Q_OS_MAC
cout << "Usage: Packer.app -path {file} -version {version} OR Packer.app -path {dir} -version {version}\n";
#endif
return -1;
}
bool hasDirs = true;
while (hasDirs) {
hasDirs = false;
for (QFileInfoList::iterator i = files.begin(); i != files.end(); ++i) {
QFileInfo info(*i);
QString fullPath = info.canonicalFilePath();
if (info.isDir()) {
hasDirs = true;
files.erase(i);
QDir d = QDir(info.absoluteFilePath());
QString fullDir = d.canonicalPath();
QStringList entries = d.entryList(QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
files.append(d.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot));
break;
} else if (!info.isReadable()) {
cout << "Can't read: " << info.absoluteFilePath().toUtf8().constData() << "\n";
return -1;
} else if (info.isHidden()) {
hasDirs = true;
files.erase(i);
break;
}
}
}
for (QFileInfoList::iterator i = files.begin(); i != files.end(); ++i) {
QFileInfo info(*i);
if (!info.canonicalFilePath().startsWith(remove)) {
cout << "Can't find '" << remove.toUtf8().constData() << "' in file '" << info.canonicalFilePath().toUtf8().constData() << "' :(\n";
return -1;
}
}
QByteArray result;
{
QBuffer buffer(&result);
buffer.open(QIODevice::WriteOnly);
QDataStream stream(&buffer);
stream.setVersion(QDataStream::Qt_5_1);
stream << quint32(version);
stream << quint32(files.size());
cout << "Found " << files.size() << " file" << (files.size() == 1 ? "" : "s") << "..\n";
for (QFileInfoList::iterator i = files.begin(); i != files.end(); ++i) {
QFileInfo info(*i);
QString fullName = info.canonicalFilePath();
QString name = fullName.mid(remove.length());
cout << name.toUtf8().constData() << " (" << info.size() << ")\n";
QFile f(fullName);
if (!f.open(QIODevice::ReadOnly)) {
cout << "Can't open '" << fullName.toUtf8().constData() << "' for read..\n";
return -1;
}
QByteArray inner = f.readAll();
stream << name << quint32(inner.size()) << inner;
#if defined Q_OS_MAC || defined Q_OS_LINUX
stream << (QFileInfo(fullName).isExecutable() ? true : false);
#endif
//.........这里部分代码省略.........
示例8: get_dir_files
void get_dir_files (QStringList *input_files, QStringList *input_dirs)
{
for (NV_INT32 i = 0 ; i < input_dirs->size () ; i++)
{
QStringList nameFilter;
QString type = input_dirs->at (i).section (':', 0, 0);
if (type == "GSF")
{
nameFilter << "*.d\?\?" << "*.gsf";
}
else if (type == "WLF")
{
nameFilter << "*.wlf" << "*.wtf" << "*.whf";
}
else if (type == "HAWKEYE")
{
nameFilter << "*.bin";
}
else if (type == "HOF")
{
nameFilter << "*.hof";
}
else if (type == "TOF")
{
nameFilter << "*.tof";
}
else if (type == "UNISIPS")
{
nameFilter << "*.u";
}
else if (type == "YXZ")
{
nameFilter << "*.yxz" << "*.txt";
}
else if (type == "HYPACK")
{
nameFilter << "*.raw";
}
else if (type == "IVS XYZ")
{
nameFilter << "*.xyz";
}
else if (type == "LLZ")
{
nameFilter << "*.llz";
}
else if (type == "CZMIL")
{
nameFilter << "*.cxy";
}
else if (type == "DTED")
{
nameFilter << "*.dt1" << "*.dt2";
}
else if (type == "CHRTR")
{
nameFilter << "*.fin" << "*.ch2";
}
else if (type == "BAG")
{
nameFilter << "*.bag";
}
else
{
NV_CHAR atype[128];
strcpy (atype, type.toAscii ());
fprintf (stderr, "\n\nUnknown data type %s on [DIR] = field, ignoring!\n\n", atype);
continue;
}
QString file = input_dirs->at (i).section (':', 1, 1).trimmed ();
QDir dirs;
dirs.cd (file);
dirs.setFilter (QDir::Dirs | QDir::Readable);
// Get all matching files in this directory.
QDir files;
files.setFilter (QDir::Files | QDir::Readable);
files.setNameFilters (nameFilter);
if (files.cd (file))
{
QFileInfoList flist = files.entryInfoList ();
for (NV_INT32 i = 0 ; i < flist.size () ; i++)
{
// Don't load HOF timing lines.
QString tst = flist.at (i).absoluteFilePath ();
if (!nameFilter.contains ("*.hof") || tst.mid (tst.length () - 13, 4) != "_TA_")
{
input_files->append (tst);
}
}
//.........这里部分代码省略.........
示例9: qt_parseEtcLpPrinters
// solaris, not 2.6
void qt_parseEtcLpPrinters(QList<QPrinterDescription> *printers)
{
QDir lp(QLatin1String("/etc/lp/printers"));
QFileInfoList dirs = lp.entryInfoList();
if (dirs.isEmpty())
return;
QString tmp;
for (int i = 0; i < dirs.size(); ++i) {
QFileInfo printer = dirs.at(i);
if (printer.isDir()) {
tmp.sprintf("/etc/lp/printers/%s/configuration",
printer.fileName().toAscii().data());
QFile configuration(tmp);
char *line = new char[1025];
QString remote(QLatin1String("Remote:"));
QString contentType(QLatin1String("Content types:"));
QString printerHost;
bool canPrintPostscript = false;
if (configuration.open(QIODevice::ReadOnly)) {
while (!configuration.atEnd() &&
configuration.readLine(line, 1024) > 0) {
if (QString::fromLatin1(line).startsWith(remote)) {
const char *p = line;
while (*p != ':')
p++;
p++;
while (isspace((uchar) *p))
p++;
printerHost = QString::fromLocal8Bit(p);
printerHost = printerHost.simplified();
} else if (QString::fromLatin1(line).startsWith(contentType)) {
char *p = line;
while (*p != ':')
p++;
p++;
char *e;
while (*p) {
while (isspace((uchar) *p))
p++;
if (*p) {
char s;
e = p;
while (isalnum((uchar) *e))
e++;
s = *e;
*e = '\0';
if (!qstrcmp(p, "postscript") ||
!qstrcmp(p, "any"))
canPrintPostscript = true;
*e = s;
if (s == ',')
e++;
p = e;
}
}
}
}
if (canPrintPostscript)
qt_perhapsAddPrinter(printers, printer.fileName(),
printerHost, QLatin1String(""));
}
delete[] line;
}
}
}
示例10: qt_parseSpoolInterface
// IRIX 6.x
void qt_parseSpoolInterface(QList<QPrinterDescription> *printers)
{
QDir lp(QLatin1String("/usr/spool/lp/interface"));
if (!lp.exists())
return;
QFileInfoList files = lp.entryInfoList();
if(files.isEmpty())
return;
for (int i = 0; i < files.size(); ++i) {
QFileInfo printer = files.at(i);
if (!printer.isFile())
continue;
// parse out some information
QFile configFile(printer.filePath());
if (!configFile.open(QIODevice::ReadOnly))
continue;
QByteArray line;
line.resize(1025);
QString namePrinter;
QString hostName;
QString hostPrinter;
QString printerType;
QString nameKey(QLatin1String("NAME="));
QString typeKey(QLatin1String("TYPE="));
QString hostKey(QLatin1String("HOSTNAME="));
QString hostPrinterKey(QLatin1String("HOSTPRINTER="));
while (!configFile.atEnd() &&
(configFile.readLine(line.data(), 1024)) > 0) {
QString uline = QString::fromLocal8Bit(line);
if (uline.startsWith(typeKey) ) {
printerType = uline.mid(nameKey.length());
printerType = printerType.simplified();
} else if (uline.startsWith(hostKey)) {
hostName = uline.mid(hostKey.length());
hostName = hostName.simplified();
} else if (uline.startsWith(hostPrinterKey)) {
hostPrinter = uline.mid(hostPrinterKey.length());
hostPrinter = hostPrinter.simplified();
} else if (uline.startsWith(nameKey)) {
namePrinter = uline.mid(nameKey.length());
namePrinter = namePrinter.simplified();
}
}
configFile.close();
printerType = printerType.trimmed();
if (printerType.indexOf(QLatin1String("postscript"), 0, Qt::CaseInsensitive) < 0)
continue;
int ii = 0;
while ((ii = namePrinter.indexOf(QLatin1Char('"'), ii)) >= 0)
namePrinter.remove(ii, 1);
if (hostName.isEmpty() || hostPrinter.isEmpty()) {
qt_perhapsAddPrinter(printers, printer.fileName(),
QLatin1String(""), namePrinter);
} else {
QString comment;
comment = namePrinter;
comment += QLatin1String(" (");
comment += hostPrinter;
comment += QLatin1Char(')');
qt_perhapsAddPrinter(printers, printer.fileName(),
hostName, comment);
}
}
}
示例11: init
int init ( )
{
BL_FUNC_DEBUG
/// Inicializa el sistema de traducciones 'gettext'.
setlocale ( LC_ALL, "" );
blBindTextDomain ( "pluginbl_report2ods", g_confpr->value( CONF_DIR_TRADUCCION ).toLatin1().constData() );
PluginBl_Report2ODS *mcont = new PluginBl_Report2ODS;
QMenu *pPluginMenu = NULL;
/// Buscamos ficheros que tengan el nombre de la tabla
QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) );
dir.setFilter ( QDir::Files | QDir::NoSymLinks );
dir.setSorting ( QDir::Size | QDir::Reversed );
/// Hacemos un filtrado de busqueda
QStringList filters;
filters << "inf_*.pys";
dir.setNameFilters ( filters );
QFileInfoList list = dir.entryInfoList();
for ( int i = 0; i < list.size(); ++i ) {
QFileInfo fileInfo = list.at ( i );
QFile file;
file.setFileName ( g_confpr->value( CONF_DIR_OPENREPORTS ) + fileInfo.fileName() );
file.open ( QIODevice::ReadOnly );
QTextStream stream ( &file );
QString buff = stream.readAll();
file.close();
/// Buscamos el titulo
QString titulo = fileInfo.fileName();
QRegExp rx3 ( "title\\s*=\\s*\"(.*)\"" );
rx3.setMinimal ( true );
if ( rx3.indexIn ( buff, 0 ) != -1 ) {
titulo = rx3.cap ( 1 );
} // end if
QString pathtitulo = fileInfo.fileName();
QRegExp rx1 ( "pathtitle\\s*=\\s*\"(.*)\"" );
rx1.setMinimal ( true );
if ( rx1.indexIn ( buff, 0 ) != -1 ) {
pathtitulo = rx1.cap ( 1 );
} else {
pathtitulo = titulo;
} // end if
/// Buscamos el icono
QString icon = ":/Images/template2ods.png";
QRegExp rx4 ( " icon\\s*=\\s*\"(.*)\"" );
rx4.setMinimal ( true );
if ( rx4.indexIn ( buff, 0 ) != -1 ) {
icon = rx4.cap ( 1 );
} // end if
QMenuBar *menubar =g_pluginbl_report2ods->menuBar();
QMenu *menu = NULL;
QStringList path = pathtitulo.split("\\");
if (path.size() > 1) {
QList<QMenu *> allPButtons = menubar->findChildren<QMenu *>();
bool encontrado = false;
for (int j = 0; j < allPButtons.size(); ++j) {
if (allPButtons.at(j)->title() == path[0]) {
encontrado = true;
menu = allPButtons.at(j);
} // end if
} // end for
if (!encontrado) {
//QMenu *pPluginMenu1 = new QMenu ( path[0] , menubar );
//menubar->insertMenu ( pPluginVer->menuAction(), pPluginMenu1 );
/// Miramos si existe un menu Herramientas
menu = g_pluginbl_report2ods->newMenu ( path[0], "", "menuHerramientas" );
} // end if
} else {
if (!pPluginMenu) {
pPluginMenu = g_pluginbl_report2ods->newMenu ( _("Informes &ODS"), "menuInfODS", "menuHerramientas" );
} // end if
menu = pPluginMenu;
} // end if
for (int i = 1; i < path.size()-1; ++i) {
QList<QMenu *> allPButtons = menu->findChildren<QMenu *>();
bool encontrado = false;
for (int j = 0; j < allPButtons.size(); ++j) {
if (allPButtons.at(j)->title() == path[i]) {
encontrado = true;
menu = allPButtons.at(j);
} // end if
} // end for
if (!encontrado) {
//.........这里部分代码省略.........
示例12: dir
///
/// Loads only usable plugins
///
std::vector<LadspaFXInfo*> Effects::getPluginList()
{
if ( m_pluginList.size() != 0 ) {
return m_pluginList;
}
vector<QString> ladspaPathVect = Preferences::get_instance()->getLadspaPath();
INFOLOG( QString( "PATHS: %1" ).arg( ladspaPathVect.size() ) );
for ( vector<QString>::iterator i = ladspaPathVect.begin(); i != ladspaPathVect.end(); i++ ) {
QString sPluginDir = *i;
INFOLOG( "*** [getPluginList] reading directory: " + sPluginDir );
QDir dir( sPluginDir );
if ( !dir.exists() ) {
INFOLOG( "Directory " + sPluginDir + " not found" );
continue;
}
QFileInfoList list = dir.entryInfoList();
for ( int i = 0; i < list.size(); ++i ) {
QString sPluginName = list.at( i ).fileName();
if ( ( sPluginName == "." ) || ( sPluginName == ".." ) ) {
continue;
}
// if the file ends with .so or .dll is a plugin, else...
#ifdef WIN32
int pos = sPluginName.indexOf( ".dll" );
#else
#ifdef Q_OS_MACX
int pos = sPluginName.indexOf( ".dylib" );
#else
int pos = sPluginName.indexOf( ".so" );
#endif
#endif
if ( pos == -1 ) {
continue;
}
//warningLog( "[getPluginList] Loading: " + sPluginName );
QString sAbsPath = QString( "%1/%2" ).arg( sPluginDir ).arg( sPluginName );
QLibrary lib( sAbsPath );
LADSPA_Descriptor_Function desc_func = ( LADSPA_Descriptor_Function )lib.resolve( "ladspa_descriptor" );
if ( desc_func == NULL ) {
ERRORLOG( "Error loading the library. (" + sAbsPath + ")" );
continue;
}
const LADSPA_Descriptor * d;
if ( desc_func ) {
for ( unsigned i = 0; ( d = desc_func ( i ) ) != NULL; i++ ) {
LadspaFXInfo* pFX = new LadspaFXInfo( QString::fromLocal8Bit(d->Name) );
pFX->m_sFilename = sAbsPath;
pFX->m_sLabel = QString::fromLocal8Bit(d->Label);
pFX->m_sID = QString::number(d->UniqueID);
pFX->m_sMaker = QString::fromLocal8Bit(d->Maker);
pFX->m_sCopyright = QString::fromLocal8Bit(d->Copyright);
//INFOLOG( "Loading: " + pFX->m_sLabel );
for ( unsigned j = 0; j < d->PortCount; j++ ) {
LADSPA_PortDescriptor pd = d->PortDescriptors[j];
if ( LADSPA_IS_PORT_INPUT( pd ) && LADSPA_IS_PORT_CONTROL( pd ) ) {
pFX->m_nICPorts++;
} else if ( LADSPA_IS_PORT_INPUT( pd ) && LADSPA_IS_PORT_AUDIO( pd ) ) {
pFX->m_nIAPorts++;
} else if ( LADSPA_IS_PORT_OUTPUT( pd ) && LADSPA_IS_PORT_CONTROL( pd ) ) {
pFX->m_nOCPorts++;
} else if ( LADSPA_IS_PORT_OUTPUT( pd ) && LADSPA_IS_PORT_AUDIO( pd ) ) {
pFX->m_nOAPorts++;
} else {
// string sPortName = d->PortNames[ j ];
QString sPortName;
ERRORLOG( QString( "%1::%2 unknown port type" ).arg( pFX->m_sLabel ).arg( sPortName ) );
}
}
if ( ( pFX->m_nIAPorts == 2 ) && ( pFX->m_nOAPorts == 2 ) ) { // Stereo plugin
m_pluginList.push_back( pFX );
} else if ( ( pFX->m_nIAPorts == 1 ) && ( pFX->m_nOAPorts == 1 ) ) { // Mono plugin
m_pluginList.push_back( pFX );
} else { // not supported plugin
//WARNINGLOG( "Plugin not supported: " + sPluginName );
delete pFX;
}
}
} else {
ERRORLOG( "Error loading: " + sPluginName );
}
}
}
INFOLOG( QString( "Loaded %1 LADSPA plugins" ).arg( m_pluginList.size() ) );
std::sort( m_pluginList.begin(), m_pluginList.end(), LadspaFXInfo::alphabeticOrder );
return m_pluginList;
}
示例13: CopyDir
bool PathManager::CopyDir(const QString &source, const QString &destination, bool isCover)
{
/* 递归实现 */
/*QDir directory(source);
if (!directory.exists()){
return false;
}
QString srcPath = QDir::toNativeSeparators(source);
if (!srcPath.endsWith(QDir::separator())){
srcPath += QDir::separator();
}
QString dstPath = QDir::toNativeSeparators(destination);
if (!dstPath.endsWith(QDir::separator())){
dstPath += QDir::separator();
}
QStringList fileNames = directory.entryList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden);
for (QStringList::size_type i = 0; i != fileNames.size(); ++i)
{
QString fileName = fileNames.at(i);
QString srcFilePath = srcPath + fileName;
QString dstFilePath = dstPath + fileName;
QFileInfo fileInfo(srcFilePath);
if (fileInfo.isFile() || fileInfo.isSymLink()){
if (isCover){
QFile::setPermissions(dstFilePath, QFile::WriteOwner);
}
if (!QFile::copy(srcFilePath, dstFilePath)){
return false;
}
}
else if (fileInfo.isDir()){
QDir dstDir(dstFilePath);
dstDir.mkpath(dstFilePath);
if (!CopyDir(srcFilePath, dstFilePath, isCover)){
return false;
}
}
}
return true;*/
QVector<QString> dirNames;
QVector<QString> fileNames;
QDir dir(source);
if (!dir.exists()){
return false;
}
dirNames.clear();
dirNames << source;
QFileInfoList filst;
QFileInfoList::iterator curFi;
for (int i = 0; i < dirNames.size(); ++i)
{
dir.setPath(dirNames[i]);
filst = dir.entryInfoList(QDir::Dirs | QDir::Files
| QDir::Readable | QDir::Writable
| QDir::Hidden | QDir::NoDotAndDotDot
, QDir::DirsFirst);
if (filst.size() > 0){
curFi = filst.begin();
while (curFi != filst.end())
{
if (curFi->isDir()){
dirNames.push_back(curFi->filePath());
}
else if (curFi->isFile()){
fileNames.push_back(curFi->absoluteFilePath());
}
curFi++;
}
}
}
for (QVector<QString>::Iterator ite = dirNames.begin(); ite != dirNames.end(); ite++)
{
QDir dirSrc(source);
QDir dirDest(destination);
ite->replace(dirSrc.absolutePath(), dirDest.absolutePath());
QDir dirTmp(*ite);
if (!dirTmp.exists() && !dirTmp.mkpath(*ite)){
return false;
}
}
for (QVector<QString>::Iterator ite = fileNames.begin(); ite != fileNames.end(); ite++)
{
QDir dirSrc(source);
QDir dirDest(destination);
QString srcPath = *ite;
QString tar = ite->replace(dirSrc.absolutePath(), dirDest.absolutePath());
QFile file(tar);
if (file.exists()){
if (isCover){
if (!file.remove()){
return false;
//.........这里部分代码省略.........
示例14: loadMessages
void qippda::loadMessages(const QString &path)
{
QDir dir = path;
if(!dir.cd("History"))
return;
QHash<QString,QString> protocols;
protocols[QLatin1String("icq")] = QLatin1String("ICQ");
protocols[QLatin1String("jabber")] = QLatin1String("Jabber");
protocols[QLatin1String("mra")] = QLatin1String("MRIM");
QStringList filters = QStringList() << QLatin1String("*.qhf") << QLatin1String("*.ahf");
QFileInfoList files = dir.entryInfoList(filters, QDir::Files);
setMaxValue(files.size());
for(int i = 0; i < files.size(); i++)
{
setValue(i + 1);
QString protocol = files[i].fileName().section("_",0,0);
while(!protocol.isEmpty() && protocol.at(protocol.length() - 1).isDigit())
protocol.chop(1);
// Old qip pda has only ICQ support and files are named like 1_myuin_hisuin
if(protocol.isEmpty())
protocol = QLatin1String("ICQ");
else
{
protocol = protocols[protocol.toLower()];
if(protocol.isEmpty())
{
qWarning("Unknown protocol: \"%s\"", qPrintable(files[i].fileName()));
continue;
}
}
setProtocol(protocol);
QString account = files[i].fileName().section("_",1,1);
setAccount(account);
QFile file(files[i].absoluteFilePath());
if(file.open(QFile::ReadOnly))
{
QByteArray bytearray = file.readAll();
const uchar *data = (const uchar *)bytearray.constData();
const uchar *end = data + bytearray.size();
if(memcmp(data, "QHF", 3))
continue;
uchar version = data[3];
data += 44;
QString uin = qipinfium::getString(data, qipinfium::getUInt16(data));
QString name = qipinfium::getString(data, qipinfium::getUInt16(data));
setContact(uin);
// continue;
while(data < end)
{
quint16 type = qipinfium::getUInt16(data);
quint32 index = qipinfium::getUInt32(data);
data += 2;
const uchar *next = data + index;
if(type == 1)
{
Message message;
message.type = 1;
data += 10;
message.time = QDateTime::fromTime_t(qipinfium::getUInt32(data));
message.time.setTimeSpec(Qt::LocalTime);
if(version == 1)
message.time = message.time.toUTC().addDays(2);
else
message.time = message.time.toUTC();
data += 4;
message.in = qipinfium::getUInt8(data) == 0;
data += 4;
int mes_len = version == 3 ? qipinfium::getUInt32(data) : qipinfium::getUInt16(data);
QString text = qipinfium::getString(data, mes_len, version > 1);
message.text = Qt::escape(text).replace("\n", "<br/>");
appendMessage(message);
}
else
data = next;
}
}
}
}
示例15: UpdateList
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tFilepathSelector::UpdateList()
{
m_FilePathList.clear();
m_FriendlyFilepathList.clear();
m_DisplayList.clear();
m_pListWidget->clear();
// First add the NONE option, No need to translate (appears in settings.ini)
m_FilePathList << "None";
m_FriendlyFilepathList << "None";
m_DisplayList << "None";
int currentRow = 0; // setCurrentRow to the currentFile
// Add files from all locations
for (int i = 0; i < m_PathAndDirNameList.size(); ++i)
{
tPathAndDirname pathAndDirname = m_PathAndDirNameList.at(i);
QDir directory(pathAndDirname.Path(), "", m_SortFlags, m_Filters);
directory.setNameFilters(m_NameFilters);
QFileInfoList fileInfoList = directory.entryInfoList();
for (int j = 0; j < fileInfoList.size(); ++j)
{
QFileInfo fileInfo = fileInfoList.at(j);
// Add the real filepath string to our list
m_FilePathList.append(fileInfo.filePath());
// Add the user displayed filepath e.g. "Sonar.sl2 (factory)"
const QString dirname = pathAndDirname.DirName();
QString friendlyFilepath;
if (dirname.isEmpty())
{
friendlyFilepath = fileInfo.fileName();
m_FriendlyFilepathList.append(friendlyFilepath);
}
else
{
friendlyFilepath = QString("%1 (%2)").arg(fileInfo.fileName()).arg(dirname);
m_FriendlyFilepathList.append(friendlyFilepath);
// compare currentFile to path and set currentRow if there is an exact match
if (friendlyFilepath.compare(m_CurrentFile) == 0)
{
currentRow = j + 1;
}
}
if (m_ShowFileSize)
{
QString item = QString("%1 (%2)").arg(friendlyFilepath).arg(FormatSize(fileInfo.size()));
m_DisplayList << item;
}
else
{
m_DisplayList << friendlyFilepath;
}
}
}
m_pListWidget->addItems(m_DisplayList);
if (m_CurrentFile.isEmpty())
{
m_pListWidget->setCurrentRow(0);
}
else
{
m_pListWidget->setCurrentRow(currentRow);
}
}