本文整理汇总了C++中QFileInfoList类的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfoList类的具体用法?C++ QFileInfoList怎么用?C++ QFileInfoList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QFileInfoList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dir
void AntiPiracy::checkValidityAndSetScene(AbstractPane* root, QString urlToBypassHash) {
// Save internally for future use
if (root) { m_normalRoot = root; }
m_urlToBypassHash = urlToBypassHash;
// Check if the unlock key was already entered previously
QSettings settings;
settings.beginGroup("AntiPiracy");
if ((settings.contains("unlockKeyEnteredByUser")) && (this->hashThis(settings.value("unlockKeyEnteredByUser", "").toString()) == m_unlockKeyHash)) {
// User already entered the correct key previously
m_appInstalledFromBBW = true;
}
else {
// The next code will check if the app was downloaded from BBW
QDir dir("/pps/system/installer/appdetails/");
dir.setFilter(QDir::Files | QDir::System | QDir::Hidden | QDir::NoDotAndDotDot | QDir::AllEntries);
QFileInfoList fileInfoList = dir.entryInfoList();
for (int i = 0; i < fileInfoList.size(); i++) {
QString completePath = fileInfoList[i].path() + "/" + fileInfoList[i].fileName() + (fileInfoList[i].isDir() ? "/" : "");
if (this->checkFile(completePath)) { break; };
}
}
if ((m_appInstalledFromBBW) || (m_appInstalledFromBetaZone)) {
// App was either installed from BBW/BetaZone or unlock key was previously entered correctly.
// Set the normal main.qml as Scene
Application::instance()->setScene(root);
this->deleteLater();
}
else {
/*
* Load a custom Page constructed in C++ to make sure it can't be altered
* The Page is only a Label and an ActivityIndicator, but it's mostly used to be the
* scene where the unlock key prompt will be shown
*/
Page *keyPromptPage = new Page(this);
Container *keyPromptContainer = new Container();
keyPromptContainer->setLayout(new DockLayout());
Label *label = new Label();
label->setText(tr("Checking validity, please wait..."));
label->setHorizontalAlignment(HorizontalAlignment::Center);
ActivityIndicator *activityIndicator = new ActivityIndicator();
activityIndicator->setHorizontalAlignment(HorizontalAlignment::Center);
activityIndicator->setMinHeight(300);
activityIndicator->setMinWidth(activityIndicator->minHeight());
Container *container = new Container();
container->setHorizontalAlignment(HorizontalAlignment::Center);
container->setVerticalAlignment(VerticalAlignment::Center);
container->add(label);
container->add(activityIndicator);
keyPromptContainer->add(container);
keyPromptPage->setContent(keyPromptContainer);
Application::instance()->setScene(keyPromptPage);
activityIndicator->start();
/*
* Check online for a bypass.
* This can be used while your app is in review period to avoid having the unlock prompt
* shown to a BBW reviewer. To construct the bypass hash, use the function
* printToConsoleHashOfThisKey() and pass the app version you'd like to whitelist
* as a parameter. Use the hash printed to console and put it online.
*/
QUrl url(m_urlToBypassHash);
QNetworkAccessManager *nam = new QNetworkAccessManager(this);
QNetworkReply *reply = nam->get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished()));
}
}
示例2: GetLocalDiskList
QList<DiskInfo> GetLocalDiskList(quint64 minSizeInGb,
const QString &type,
const QString &table){
QList<DiskInfo> disklist;
QFileInfoList devlist = QDir::drives();
for (int i = 0; i < devlist.size(); ++i)
{
QString devname = QDir::toNativeSeparators(devlist.at(i).path().toUpper()).remove("\\");
if (GetDriveType(LPWSTR(devname.utf16())) == DRIVE_FIXED)
{
ULARGE_INTEGER FreeAv,TotalBytes,FreeBytes;
if (!GetDiskFreeSpaceEx(LPWSTR(devname.utf16()),&FreeAv,&TotalBytes,&FreeBytes)) {
continue;
}
if ((FreeBytes.QuadPart/(1024*1024*1024)) < minSizeInGb) {
qDebug()<<"Skip Disk"<<devname<<"Space not enough"<<FreeBytes.QuadPart/(1024*1024*1024);
continue;
}
PARTITION_INFORMATION_EX piex;
Xapi::GetPartitionEx (devname, &piex);
QString format = "Unknow";
PartitonStyle style;
switch (piex.PartitionStyle) {
case PARTITION_STYLE_MBR:
style = MBRPartition;
if (!table.toUpper ().contains ("MBR")) {
qDebug()<<"Skip Disk"<<devname<<"MBR";
continue;
}
switch (piex.Mbr.PartitionType) {
case PARTITION_FAT32:
case PARTITION_FAT_16:
format = "FAT";
break;
case 0x4A:
case PARTITION_IFS:
format = "NTFS";
break;
default:
break;
}
if (!type.toUpper ().contains (format.toUpper ())) {
qDebug()<<"Skip Disk"<<devname<<format<<"Not a NTFS Disk";
continue;
}
break;
case PARTITION_STYLE_GPT:
style = GPTPartition;
if (!table.toUpper ().contains ("GPT")) {
qDebug()<<"Skip Disk"<<devname<<"GPT";
continue;
}
GUID PARTITION_BASIC_DATA_GUID;
PARTITION_BASIC_DATA_GUID.Data1 = 0xEBD0A0A2L;
PARTITION_BASIC_DATA_GUID.Data2 = 0xB9E5;
PARTITION_BASIC_DATA_GUID.Data3 = 0x4433;
PARTITION_BASIC_DATA_GUID.Data4[0] = 0x87;
PARTITION_BASIC_DATA_GUID.Data4[1] = 0xC0;
PARTITION_BASIC_DATA_GUID.Data4[2] = 0x68;
PARTITION_BASIC_DATA_GUID.Data4[3] = 0xB6;
PARTITION_BASIC_DATA_GUID.Data4[4] = 0xB7;
PARTITION_BASIC_DATA_GUID.Data4[5] = 0x26;
PARTITION_BASIC_DATA_GUID.Data4[6] = 0x99;
PARTITION_BASIC_DATA_GUID.Data4[7] = 0xC7;
if (PARTITION_BASIC_DATA_GUID != piex.Gpt.PartitionType) {
qDebug()<<"Skip Disk"<<devname<<"Not a NTFS Disk";
continue;
}
break;
case PARTITION_STYLE_RAW:
style = RAWPartition;
if (!table.toUpper ().contains ("RAW")) {
continue;
}
break;
default:
style = UnknowPartition;
qDebug()<<"Disk Type"<<devname<<"Unknow";
continue;
}
DiskInfo diskinfo;
diskinfo.Name = devname;
diskinfo.Style = style;
diskinfo.FreeSpace = FreeBytes.QuadPart/(1024*1024*1024);
QString result = Xapi::SynExec( "cmd", QString("/C \"chcp 437 & %1\\manage-bde -status %2\" ").arg(Xapi::SystemDirtory()).arg(devname));
QStringList list = result.split("\r").filter("BitLocker Version");
diskinfo.Encrypt = list.size() ? !list.first().contains("None") : false;
qDebug()<<devname<<"System Type"<<diskinfo.Encrypt;
disklist.push_back(diskinfo);
}
}
//.........这里部分代码省略.........
示例3: 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);
}
}
}
示例4: HootException
void TileOpDriver::apply(QString in, vector<Envelope> envelopes, double buffer,
QString out)
{
// create a job
pp::Job job;
job.setVerbose(Log::getInstance().getLevel() <= Log::Debug);
// set the name
job.setName("TileOpDriver");
// be nice and don't start the reduce tasks until most of the map tasks are done.
job.getConfiguration().setDouble("mapred.reduce.slowstart.completed.maps", 0.98);
// set the input/output
pp::Hdfs fs;
job.setInput(fs.getAbsolutePath(in.toStdString()));
job.setOutput(fs.getAbsolutePath(out.toStdString()));
if (_op == 0)
{
throw HootException("You must specify an operation.");
}
stringstream ss;
ObjectOutputStream oos(ss);
oos.writeObject(*_op);
oos.flush();
LOG_INFO("oos size: " << ss.str().size());
job.getConfiguration().setBytes(TileOpReducer::opKey(), ss.str());
job.getConfiguration().set(TileOpMapper::envelopesKey(), _toString(envelopes));
job.getConfiguration().set(TileOpMapper::replacementsKey(),
fs.getAbsolutePath(in.toStdString()));
job.getConfiguration().setDouble(TileOpMapper::maxWaySizeKey(), buffer);
job.getConfiguration().setDouble(TileOpMapper::bufferKey(), buffer);
// read the max ids from in and write them to the configuration
MapStats stats;
stats.readDir(in);
stats.write(job.getConfiguration());
// setup the mapper and reducer classes.
job.setMapperClass(TileOpMapper::className());
job.setReducerClass(TileOpReducer::className());
job.setInputFormatClass(PbfInputFormat::className());
job.setRecordReaderClass(PbfRecordReader::className());
job.setRecordWriterClass(PbfRecordWriter::className());
// Adds all libraries in this directory to the job.
job.addLibraryDirs(conf().getList("hoot.hadoop.libpath",
"${HOOT_HOME}/lib/;${HOOT_HOME}/local/lib/;${HADOOP_HOME}/c++/Linux-amd64-64/lib/;"
"${HOOT_HOME}/pretty-pipes/lib/"));
LOG_INFO("Hoot home: " << conf().getString("foo", "${HOOT_HOME}"));
const std::vector<std::string>& dirs = job.getLibraryDirs();
for (size_t i = 0; i < dirs.size(); i++)
{
LOG_INFO("lib dir: " << dirs[i]);
}
job.addFile(ConfPath::search("hoot.json").toStdString());
// if GDAL isn't installed on all nodes, then we'll need to copy over the projection info.
QString gdalData = QString(getenv("GDAL_DATA"));
if (gdalData != "")
{
QDir gdalDir(gdalData);
if (gdalDir.exists() == false)
{
LOG_WARN("Could not find GDAL_DIR: " << gdalData);
}
else
{
QStringList filters;
filters << "*.csv";
QFileInfoList fil = gdalDir.entryInfoList(filters, QDir::Files);
for (int i = 0; i < fil.size(); i++)
{
LOG_INFO("Adding GDAL_DATA file: " << fil[i].absoluteFilePath());
job.addFile(fil[i].absoluteFilePath().toStdString());
}
}
}
// This library will be used to provide mapper/reducer classes and anything else referenced
// by the factory.
job.addPlugin(getenv("HOOT_HOME") + string("/lib/libHootHadoop.so.1"));
// serialize all the configuration settings.
job.getConfiguration().set(settingsConfKey().toStdString(),
conf().toString().toUtf8().constData());
_addDefaultJobSettings(job);
QStringList fileDeps = conf().getList(fileDepsKey(), QStringList());
for (int i = 0; i < fileDeps.size(); i++)
{
job.addFile(fileDeps[i].toStdString());
//.........这里部分代码省略.........
示例5: processQdocconfFile
//.........这里部分代码省略.........
The tree gets built as the source files are parsed, and then the
documentation output is generated by traversing the tree.
*/
Tree *tree = new Tree;
tree->setVersion(config.getString(CONFIG_VERSION));
/*
By default, the only output format is HTML.
*/
QSet<QString> outputFormats = config.getOutputFormats();
Location outputFormatsLocation = config.lastLocation();
/*
Read some XML indexes containing definitions from other documentation sets.
*/
QStringList indexFiles = config.getStringList(CONFIG_INDEXES);
dependModules += config.getStringList(CONFIG_DEPENDS);
if (dependModules.size() > 0) {
if (indexDirs.size() > 0) {
for (int i = 0; i < indexDirs.size(); i++) {
if (indexDirs[i].startsWith("..")) {
const QString prefix(QDir(dir).relativeFilePath(prevCurrentDir));
if (!prefix.isEmpty())
indexDirs[i].prepend(prefix + QLatin1Char('/'));
}
}
/*
Add all subdirectories of the indexdirs as dependModules when an asterisk is used in
the 'depends' list.
*/
if (dependModules.contains("*")) {
dependModules.removeOne("*");
for (int i = 0; i < indexDirs.size(); i++) {
QDir scanDir = QDir(indexDirs[i]);
scanDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
QFileInfoList dirList = scanDir.entryInfoList();
for (int j = 0; j < dirList.size(); j++) {
if (dirList[j].fileName().toLower() != config.getString(CONFIG_PROJECT).toLower())
dependModules.append(dirList[j].fileName());
}
}
}
for (int i = 0; i < dependModules.size(); i++) {
QString indexToAdd;
QList<QFileInfo> foundIndices;
for (int j = 0; j < indexDirs.size(); j++) {
QString fileToLookFor = indexDirs[j] + QLatin1Char('/') + dependModules[i] +
QLatin1Char('/') + dependModules[i] + QLatin1String(".index");
if (QFile::exists(fileToLookFor)) {
QFileInfo tempFileInfo(fileToLookFor);
if (!foundIndices.contains(tempFileInfo))
foundIndices.append(tempFileInfo);
}
}
qSort(foundIndices.begin(), foundIndices.end(), creationTimeBefore);
if (foundIndices.size() > 1) {
/*
QDoc should always use the last entry in the multimap when there are
multiple index files for a module, since the last modified file has the
highest UNIX timestamp.
*/
qDebug() << "Multiple indices found for dependency:" << dependModules[i] << "\nFound:";
for (int k = 0; k < foundIndices.size(); k++)
qDebug() << foundIndices[k].absoluteFilePath();
qDebug() << "Using" << foundIndices[foundIndices.size() - 1].absoluteFilePath()
<< "as index for" << dependModules[i];
indexToAdd = foundIndices[foundIndices.size() - 1].absoluteFilePath();
}
else if (foundIndices.size() == 1) {
indexToAdd = foundIndices[0].absoluteFilePath();
}
else {
qDebug() << "No indices for" << dependModules[i] <<
"could be found in the specified index directories.";
}
if (!indexToAdd.isEmpty() && !indexFiles.contains(indexToAdd))
indexFiles << indexToAdd;
}
}
else {
qDebug() << "Dependant modules specified, but no index directories or install directory were set."
<< "There will probably be errors for missing links.";
}
}
tree->readIndexes(indexFiles);
QSet<QString> excludedDirs;
QSet<QString> excludedFiles;
QStringList headerList;
QStringList sourceList;
QStringList excludedDirsList;
QStringList excludedFilesList;
excludedDirsList = config.getCanonicalRelativePathList(CONFIG_EXCLUDEDIRS);
foreach (const QString &excludeDir, excludedDirsList) {
QString p = QDir::fromNativeSeparators(excludeDir);
excludedDirs.insert(p);
}
示例6: soInfo
QString
AudioPluginOSCGUI::getGUIFilePath(QString identifier)
{
QString type, soName, label;
PluginIdentifier::parseIdentifier(identifier, type, soName, label);
RG_DEBUG << "AudioPluginOSCGUI::getGUIFilePath(" << identifier << ")";
QFileInfo soInfo(soName);
if (soInfo.isRelative()) {
//!!!
RG_DEBUG << "AudioPluginOSCGUI::AudioPluginOSCGUI: Unable to deal with relative .so path \"" << soName << "\" in identifier \"" << identifier << "\" yet";
throw Exception("Can't deal with relative .soname");
}
QDir dir(soInfo.dir());
QString fileBase(soInfo.completeBaseName());
if (!dir.cd(fileBase)) {
RG_DEBUG << "AudioPluginOSCGUI::AudioPluginOSCGUI: No GUI subdir for plugin .so " << soName;
throw Exception("No GUI subdir available");
}
QFileInfoList list = dir.entryInfoList();
// in order of preference:
const char *suffixes[] = { "_rg", "_kde", "_qt", "_gtk2", "_gtk", "_x11", "_gui"
};
int nsuffixes = int(sizeof(suffixes) / sizeof(suffixes[0]));
for (int k = 0; k <= nsuffixes; ++k) {
for (int fuzzy = 0; fuzzy <= 1; ++fuzzy) {
QFileInfoList::iterator info;
for (info = list.begin(); info != list.end(); ++info) { //### JAS Check for errors
RG_DEBUG << "Looking at " << info->fileName() << " in path "
<< info->filePath() << " for suffix " << (k == nsuffixes ? "(none)" : suffixes[k]) << ", fuzzy " << fuzzy << endl;
if (!(info->isFile() || info->isSymLink())
|| !info->isExecutable()) {
RG_DEBUG << "(not executable)";
continue;
}
if (fuzzy) {
if (info->fileName().left(fileBase.length()) != fileBase)
continue;
RG_DEBUG << "(is file base)";
} else {
if (info->fileName().left(label.length()) != label)
continue;
RG_DEBUG << "(is label)";
}
if (k == nsuffixes || info->fileName().toLower().endsWith(suffixes[k])) {
RG_DEBUG << "(ends with suffix " << (k == nsuffixes ? "(none)" : suffixes[k]) << " or out of suffixes)";
return info->filePath();
}
RG_DEBUG << "(doesn't end with suffix " << (k == nsuffixes ? "(none)" : suffixes[k]) << ")";
}
}
}
return QString();
}
示例7: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
if (a.arguments().size() < 3) {
qCritical() << "this application requires more arguments!";
return -1;
}
const QString trainDirName = a.arguments().at(1);
const QString testDirName = a.arguments().at(2);
const QString outputName = a.arguments().at(3);
const QString extractorName = a.arguments().at(4);
const QStringList extractorArgs = a.arguments().mid(5);
ExtractorInterface *extractor =
ExtractorFactory::getExtractor(extractorName, extractorArgs);
if (extractor == NULL) {
qCritical() << "failed to initialise extractor" << extractorName;
return -2;
}
QDir trainDir(trainDirName);
QStringList subdirs = QStringList() << "wood" << "straw" << "salt" << "linen";
QList<quint8> labels = QList<quint8>() << 32 << 96 << 160 << 224;
QVector<LabelledData> trainData;
#ifdef HAS_ELAPSED_TIMER
QElapsedTimer extractionTimer;
#else
QTime extractionTimer;
#endif
int threadCount = 1;
#ifdef _OPENMP
#pragma omp parallel
{
#pragma omp single
{
threadCount = omp_get_num_threads();
}
}
#endif
qDebug() << "using" << threadCount << "threads.";
extractionTimer.start();
unsigned int imagesCount = 0;
for (int j = 0; j < subdirs.size(); j++) {
trainDir.cd(subdirs.at(j));
const QFileInfoList fileList = trainDir.entryInfoList(QStringList() << "*.png");
#ifdef HAS_ELAPSED_TIMER
QElapsedTimer extractorTimer;
#else
QTime extractorTimer;
#endif
extractorTimer.start();
for (int i = 0; i < fileList.size(); i++) {
imagesCount++;
const QString filename = fileList.at(i).filePath();
const QImage image(filename);
if (image.format() != QImage::Format_Indexed8) {
qCritical("Image is not greyscale!");
return -1;
}
extractor->preprocess(image);
if (extractor->extracts()) {
unsigned int count = trainData.size();
trainData.resize(trainData.size() + image.width() * image.height());
LabelledData *trainDataPtr = trainData.data();
#pragma omp parallel for
for (int x = 0; x < image.width(); x++) {
for (int y = 0; y < image.height(); y++) {
const QVector<nnreal> res = extractor->extract(image, x, y);
Q_ASSERT(res.size() == extractor->size());
LabelledData li(res, labels.at(j));
const unsigned int idx = count + x * image.height() + y;
trainDataPtr[idx] = li;
}
}
}
const QVector<QVector<nnreal> > ppFeatures = extractor->postprocess(image);
const int ppCount = ppFeatures.size();
if (ppCount > 0) {
const int count = trainData.size();
trainData.resize(trainData.size() + ppFeatures.size());
LabelledData *trainDataPtr = trainData.data();
#pragma omp parallel for
for (int k = 0; k < ppCount; k++) {
Q_ASSERT(ppFeatures.at(k).size() == extractor->size());
LabelledData ld(ppFeatures.at(k), labels.at(j));
trainDataPtr[count + k] = ld;
}
}
qDebug() << fileList.at(i).filePath() << extractorTimer.restart();
}
trainDir.cdUp();
}
const int msecs = extractionTimer.elapsed();
qDebug() << "trainSize:" << trainData.size() << "extraction of "
<< imagesCount << "images took" << msecs << "msecs, average"
<< float(msecs) / imagesCount << "msecs per image";
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
} else if (option == "printdialog") {
type = PrinterType;
printdlg = true;
}
else if (option == "grab")
type = GrabType;
else if (option == "i")
interactive = true;
else if (option == "v")
verboseMode = true;
else if (option == "commands") {
displayCommands();
return 0;
} else if (option == "w") {
Q_ASSERT_X(i + 1 < argc, "main", "-w must be followed by a value");
width = atoi(argv[++i]);
} else if (option == "h") {
Q_ASSERT_X(i + 1 < argc, "main", "-h must be followed by a value");
height = atoi(argv[++i]);
} else if (option == "scalefactor") {
Q_ASSERT_X(i + 1 < argc, "main", "-scalefactor must be followed by a value");
scalefactor = atof(argv[++i]);
} else if (option == "cmp") {
show_cmp = true;
} else if (option == "bg-white") {
checkers_background = false;
}
} else {
#if defined (Q_WS_WIN)
QString input = QString::fromLocal8Bit(argv[i]);
if (input.indexOf('*') >= 0) {
QFileInfo info(input);
QDir dir = info.dir();
QFileInfoList infos = dir.entryInfoList(QStringList(info.fileName()));
for (int ii=0; ii<infos.size(); ++ii)
files.append(infos.at(ii).absoluteFilePath());
} else {
files.append(input);
}
#else
files.append(QString(argv[i]));
#endif
}
}
scaledWidth = width * scalefactor;
scaledHeight = height * scalefactor;
PaintCommands pcmd(QStringList(), 800, 800);
pcmd.setVerboseMode(verboseMode);
pcmd.setType(type);
pcmd.setCheckersBackground(checkers_background);
QWidget *activeWidget = 0;
if (interactive) {
runInteractive();
if (!files.isEmpty())
interactive_widget->load(files.at(0));
} else if (files.isEmpty()) {
printHelp();
return 0;
} else {
for (int j=0; j<files.size(); ++j) {
const QString &fileName = files.at(j);
QStringList content;
示例9: QProcess
QList<QString> MainWindow::getLangugagelist() {
QProcess *lprocess = new QProcess(this);
QSettings settings(QSettings::IniFormat, QSettings::UserScope,
Organization, ProjectName);
QString ocrCmd;
if (settings.contains("OCR/program"))
ocrCmd = settings.value("OCR/program").toString();
// TODO(zdenop): check for missing setting or empty string
if (!settings.value("OCR/sys_prefix").toBool()) {
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("TESSDATA_PREFIX", settings.value("OCR/prefix").toString());
lprocess->setProcessEnvironment(env);
}
QStringList arguments;
arguments << "a" << "b" << "-l" << "_ICQ_";
lprocess->start(ocrCmd, arguments);
lprocess->waitForFinished(-1);
QString s = QString::fromLocal8Bit(lprocess->
readAllStandardError().constData());
QStringList lines;
QString line, langFile;
lines = s.split("\n");
for (int i = 0; i < lines.size(); ++i) {
line = lines.at(i);
if (line.contains("_ICQ_")) {
// tesseract 3.01
// Error opening data file /usr/local/share/tessdata/_ICQ_.traineddata
langFile = line.replace("Error opening data file ", "");
// tesseract 3.00 ;-)
// Error openning data file /usr/local/share/tessdata/_ICQ_.traineddata
langFile = langFile.replace("Error openning data file ", "");
// tesseract 2.04 ;-)
// Unable to load unicharset file /usr/share/tessdata/_ICQ_.unicharset
langFile = langFile.replace("Unable to load unicharset file ", "");
}
}
if (langFile == "")
ui->tb_Log->appendHtml("<font color=red><b>" +
tr("Unexpexted error: tesseract did not produced expected information!")
+ "</b></font>");
QFileInfo fi(langFile);
QString tessdataPath = fi.absolutePath();
QString extention = fi.suffix();
QDir dir(tessdataPath);
if (!dir.exists()) {
QMessageBox msgBox;
msgBox.setText(tr("Cannot find the tessdata directory '%1'!\n").arg(tessdataPath) +
tr("Please check your configuration or tesseract instalation"));
msgBox.exec();
}
QString filter = "*." + extention;
QStringList filters;
filters << filter.trimmed();
dir.setNameFilters(filters);
QList<QString> languages;
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
languages.append(QString("%1").arg(fileInfo.baseName()));
}
qSort(languages);
return languages;
}
示例10: parseDirectory
void parseDirectory(QString dir)
{
QDir themeDir(dir);
cout << "Searching directory: " << qPrintable(themeDir.path()) << endl;
themeDir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
themeDir.setSorting(QDir::DirsFirst);
QDomDocument doc;
QFileInfoList themeFiles = themeDir.entryInfoList();
QFileInfoList::const_iterator it;
for (it = themeFiles.begin(); it != themeFiles.end(); ++it)
{
if ((*it).isDir())
{
parseDirectory((*it).filePath());
continue;
}
if ((*it).suffix() != "xml")
continue;
cout << " Found: " << qPrintable((*it).filePath()) << endl;
QFile fin((*it).absoluteFilePath());
if (!fin.open(QIODevice::ReadOnly))
{
cerr << "Can't open " << qPrintable((*it).absoluteFilePath()) << endl;
continue;
}
QString errorMsg;
int errorLine = 0;
int errorColumn = 0;
if (!doc.setContent(&fin, false, &errorMsg, &errorLine, &errorColumn))
{
cerr << "Error parsing: " << qPrintable((*it).absoluteFilePath()) << endl;
cerr << "at line: " << errorLine << " column: "
<< errorColumn << endl;
cerr << qPrintable(errorMsg) << endl;
fin.close();
continue;
}
fin.close();
stringCount = 0;
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while (!n.isNull())
{
QDomElement e = n.toElement();
if (!e.isNull())
{
parseElement(e);
}
n = n.nextSibling();
}
cout << " Contains " << stringCount << " total strings" << endl;
}
}
示例11: copyFolder
void FileManager::copyFolder(QString scrPath, QString dstPath)
{
QFileInfoList fList;
fList.clear();
getFolderFiles(scrPath, fList);
if(fList.size() == 0)
{
//QMessageBox::warning(this, tr("Error"), tr("文件夹是空的:").arg(scrPath), 0, 0);
qDebug() << tr("文件夹是空的:").arg(srcfileName);
return;
}
if(srcfileName.compare(destinationPath) == 0) return;
bool stopped = false;
int curIndex = 0;
while( !stopped )
{
if( curIndex == fList.size() )
{
stopped = true;
continue;
}
QFileInfo curFileInfo = fList.at(curIndex);
QString srcFileName = curFileInfo.filePath();
QFile src(srcFileName);
QFileInfo srcTmp(srcfileName);
QString srcTripname = srcFileName.remove(srcfileName);
QString dstFileName = srcTripname.insert(0, dstPath+srcTmp.fileName());
QFile dst(dstFileName);
QFileInfo tmp(dstFileName);
qDebug() << tmp.path();
QDir d(tmp.path());
if(!d.exists())
d.mkpath(d.absolutePath());
//now copy
if(!src.open(QFile::ReadOnly) || !dst.open(QFile::WriteOnly)) continue;
fileSize = src.bytesAvailable();
qint64 BUFF_SIZE = 61440;
char* buffer = new char[BUFF_SIZE];
//int oldPercent = 0;
while( !src.atEnd() )
{
dst.write(buffer, src.read(buffer, BUFF_SIZE));
//dst.flush();
}
src.close();
dst.close();
delete[] buffer;
buffer = NULL;
curIndex++;
int percent = (curIndex*100) / fList.size();//((curIndex + 1) * 100) / fileSize;
//if (oldPercent != percent)
{
emit verificationProgressSignal(percent);
//oldPercent = percent;
}
}
fList.clear();
}
示例12: directory
int QgsComposerPictureWidget::addDirectoryToPreview( const QString& path )
{
//go through all files of a directory
QDir directory( path );
if ( !directory.exists() || !directory.isReadable() )
{
return 1; //error
}
QFileInfoList fileList = directory.entryInfoList( QDir::Files );
QFileInfoList::const_iterator fileIt = fileList.constBegin();
QProgressDialog progress( "Adding Icons...", "Abort", 0, fileList.size() - 1, this );
//cancel button does not seem to work properly with modal dialog
//progress.setWindowModality(Qt::WindowModal);
int counter = 0;
for ( ; fileIt != fileList.constEnd(); ++fileIt )
{
progress.setLabelText( tr( "Creating icon for file %1" ).arg( fileIt->fileName() ) );
progress.setValue( counter );
QCoreApplication::processEvents();
if ( progress.wasCanceled() )
{
break;
}
QString filePath = fileIt->absoluteFilePath();
//test if file is svg or pixel format
bool fileIsPixel = false;
bool fileIsSvg = testSvgFile( filePath );
if ( !fileIsSvg )
{
fileIsPixel = testImageFile( filePath );
}
//exclude files that are not svg or image
if ( !fileIsSvg && !fileIsPixel )
{
++counter; continue;
}
QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget );
listItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
if ( fileIsSvg )
{
QIcon icon( filePath );
listItem->setIcon( icon );
}
else if ( fileIsPixel ) //for pixel formats: create icon from scaled pixmap
{
QPixmap iconPixmap( filePath );
if ( iconPixmap.isNull() )
{
++counter; continue; //unknown file format or other problem
}
//set pixmap hardcoded to 30/30, same as icon size for mPreviewListWidget
QPixmap scaledPixmap( iconPixmap.scaled( QSize( 30, 30 ), Qt::KeepAspectRatio ) );
QIcon icon( scaledPixmap );
listItem->setIcon( icon );
}
else
{
++counter; continue;
}
listItem->setText( "" );
//store the absolute icon file path as user data
listItem->setData( Qt::UserRole, fileIt->absoluteFilePath() );
++counter;
}
return 0;
}
示例13: QStringList
Wad::Wad( QDir dir )
{
ok = false;
QFileInfoList tmds = dir.entryInfoList( QStringList() << "*.tmd" << "tmd.*", QDir::Files );
if( tmds.isEmpty() )
{
Err( "TMD not found" );
return;
}
tmdData = ReadFile( tmds.at( 0 ).absoluteFilePath() );
if( tmdData.isEmpty() )
return;
QFileInfoList tiks = dir.entryInfoList( QStringList() << "*.tik" << "cetk", QDir::Files );
if( tiks.isEmpty() )
{
Err( "Ticket not found" );
return;
}
tikData = ReadFile( tiks.at( 0 ).absoluteFilePath() );
if( tikData.isEmpty() )
return;
Tmd t( tmdData );
Ticket ticket( tikData );
//make sure to only add the tmd & ticket without all the cert mumbo jumbo
tmdData = t.Data();
tikData = ticket.Data();
t = Tmd( tmdData );
ticket = Ticket( tikData );
quint16 cnt = t.Count();
bool tmdChanged = false;
for( quint16 i = 0; i < cnt; i++ )
{
QByteArray appD = ReadFile( dir.absoluteFilePath( t.Cid( i ) + ".app" ) );
if( appD.isEmpty() )
{
Err( t.Cid( i ) + ".app not found" );
return;
}
if( (quint32)appD.size() != t.Size( i ) )
{
t.SetSize( i, appD.size() );
tmdChanged = true;
}
QByteArray realHash = GetSha1( appD );
if( t.Hash( i ) != realHash )
{
t.SetHash( i, realHash );
tmdChanged = true;
}
AesSetKey( ticket.DecryptedKey() );
appD = PaddedByteArray( appD, 0x40 );
QByteArray encData = AesEncrypt( t.Index( i ), appD );
partsEnc << encData;
}
//if something in the tmd changed, fakesign it
if( tmdChanged )
{
if( !t.FakeSign() )
{
Err( "Error signing the wad" );
return;
}
else
{
tmdData = t.Data();
}
}
QFileInfoList certs = dir.entryInfoList( QStringList() << "*.cert", QDir::Files );
if( !certs.isEmpty() )
{
certData = ReadFile( certs.at( 0 ).absoluteFilePath() );
}
ok = true;
}
示例14: slotSaveSettings
void ImageImporter::slotImport()
{
//first save all
slotSaveSettings();
//then init the regular expression
QRegExp re(m_txtSourceFilename->text(), !m_chkIgnoreCase->isChecked());
//first find all possible files
//listdir is used as a stack containing the directories to parse
QStringList lstDirs = m_cmbSourceFolder->currentText();
//the list of files found in the directories
QFileInfoList lstFiles;
lstFiles.setAutoDelete(true);
DlgImageImporterStatus* dlgStatus = new DlgImageImporterStatus(this, "StatusDialog");
dlgStatus->enableImageArchive(m_groupArchive->isChecked());
dlgStatus->show();
dlgStatus->appendStatusMessage(i18n("Starting..."));
dlgStatus->setCurrentMode( DlgImageImporterStatus::ModeImport,
i18n("Scanning for available Images..."));
//now go thru all folders and collect all files that match the file regexp...
while (!lstDirs.isEmpty()) {
QDir d( lstDirs.front() );
lstDirs.pop_front();
dlgStatus->addFolder();
d.setMatchAllDirs(true);
const QFileInfoList* list = d.entryInfoList();
if (list) {
QFileInfoListIterator it( *list );
QFileInfo* fi;
for ( ; ( fi = it.current() ) != 0; ++it )
{
if ( fi->fileName() == "." || fi->fileName() == ".." ) {
continue;
} else if ( fi->isDir() && m_chkSrcIncludeSubfolders->isChecked()) {
lstDirs.append(fi->absFilePath());
} else if( fi->isFile() ) {
dlgStatus->addFile();
if (re.exactMatch(fi->fileName())) {
dlgStatus->addMatch();
//save a copy of all FileInfos
lstFiles.append(new QFileInfo(*fi));
}
}
// we return here and break all importing!
if (dlgStatus->wasCanceled()) {
return;
}
}
}
// we return here and break all importing!
if (dlgStatus->wasCanceled()) {
return;
}
}
//archive the images, if requested ...
if (m_groupArchive->isChecked())
{
dlgStatus->setCurrentMode(DlgImageImporterStatus::ModeArchive,
i18n("Archiving found images..."));
importFiles(&lstFiles,
m_txtArchiveBaseFolder->text(),
m_txtArchiveSubfolders->text(),
m_txtArchiveFilename->text(),
m_chkArchiveLowercase->isChecked(),
false,
dlgStatus);
if (dlgStatus->wasCanceled()) {
//either canceled by user or error
return;
}
} else {
dlgStatus->appendStatusMessage(i18n("Archiving found images... skipped"));
}
QString msg = i18n("Moving found images...");
if (!m_chkSrcRemoveFilesFromSrc->isChecked()) {
msg = i18n("Copying found images...");
}
dlgStatus->setCurrentMode(DlgImageImporterStatus::ModeDestination, msg);
// ... then copy/ move the images to their destinaion
importFiles(&lstFiles, m_cmbDestBasefolder->currentText(), m_txtDestSubfolders->text(),
m_txtDestFilename->text(), m_chkDestLowercase->isChecked(),
m_chkSrcRemoveFilesFromSrc->isChecked(), dlgStatus);
if (dlgStatus->wasCanceled()) {
//.........这里部分代码省略.........
示例15: if
void LDesktop::checkResolution(){
//Compare the current screen resolution with the last one used/saved and adjust config values *only*
//NOTE: This is only run the first time this desktop is created (before loading all the interface) - not on each desktop change
int oldWidth = settings->value(DPREFIX+"screen/lastWidth",-1).toInt();
int oldHeight = settings->value(DPREFIX+"screen/lastHeight",-1).toInt();
QRect scrn = LSession::handle()->screenGeom(desktopnumber);
if(scrn.isNull()){ return; }
issyncing = true;
settings->setValue(DPREFIX+"screen/lastWidth",scrn.width());
settings->setValue(DPREFIX+"screen/lastHeight",scrn.height());
if(oldWidth<1 || oldHeight<1 || scrn.width()<1 || scrn.height()<1){
//nothing to do - something invalid
}else if(scrn.width()==oldWidth && scrn.height()==oldHeight){
//nothing to do - same as before
}else{
//Calculate the scale factor between the old/new sizes in each dimension
// and forward that on to all the interface elements
double xscale = scrn.width()/((double) oldWidth);
double yscale = scrn.height()/((double) oldHeight);
if(DEBUG){
qDebug() << "Screen Resolution Changed:" << desktopnumber;
qDebug() << " - Old:" << QString::number(oldWidth)+"x"+QString::number(oldHeight);
qDebug() << " - New:" << QString::number(scrn.width())+"x"+QString::number(scrn.height());
qDebug() << " - Scale Factors:" << xscale << yscale;
}
//Update any panels in the config file
for(int i=0; i<4; i++){
QString PPREFIX = "panel"+QString::number(desktopnumber)+"."+QString::number(i)+"/";
int ht = settings->value(PPREFIX+"height",-1).toInt();
if(ht<1){ continue; } //no panel height defined
QString loc = settings->value(PPREFIX+"location","top").toString().toLower();
if(loc=="top" || loc=="bottom"){
settings->setValue(PPREFIX+"height", (int) ht*yscale); //vertical dimension
}else{
settings->setValue(PPREFIX+"height", (int) ht*xscale); //horizontal dimension
}
}
//Update any desktop plugins
QStringList plugs = settings->value(DPREFIX+"pluginlist").toStringList();
QFileInfoList files = LSession::handle()->DesktopFiles();
for(int i=0; i<files.length(); i++){
plugs << "applauncher::"+files[i].absoluteFilePath()+"---"+DPREFIX;
}
//QString pspath = QDir::homePath()+"/.lumina/desktop-plugins/%1.conf";
QSettings *DP = LSession::handle()->DesktopPluginSettings();
QStringList keys = DP->allKeys();
for(int i=0; i<plugs.length(); i++){
QStringList filter = keys.filter(plugs[i]);
for(int j=0; j<filter.length(); j++){
//Has existing settings - need to adjust it
if(filter[j].endsWith("location/height")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
if(filter[j].endsWith("location/width")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*xscale) ); }
if(filter[j].endsWith("location/x")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*xscale) ); }
if(filter[j].endsWith("location/y")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
if(filter[j].endsWith("IconSize")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
if(filter[j].endsWith("iconsize")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
}
}
DP->sync(); //make sure it gets saved to disk right away
}
issyncing = false;
}