ChooseCyclistDialog::ChooseCyclistDialog(const QDir &home, bool allowNew) : home(home) { setWindowTitle(tr("Choose an Athlete")); listWidget = new QListWidget(this); listWidget->setSelectionMode(QAbstractItemView::SingleSelection); QStringListIterator i(home.entryList(QDir::Dirs | QDir::NoDotAndDotDot)); while (i.hasNext()) { QString name = i.next(); QListWidgetItem *newone = new QListWidgetItem(name, listWidget); // only allow selection of cyclists which are not already open foreach (MainWindow *x, mainwindows) if (x->cyclist == name) newone->setFlags(newone->flags() & ~Qt::ItemIsEnabled); } if (allowNew) newButton = new QPushButton(tr("&New..."), this); okButton = new QPushButton(tr("&Open"), this); cancelButton = new QPushButton(tr("&Cancel"), this); okButton->setEnabled(false); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); if (allowNew) connect(newButton, SIGNAL(clicked()), this, SLOT(newClicked())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked())); connect(listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(enableOk(QListWidgetItem*))); connect(listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(accept())); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addWidget(okButton); if (allowNew) buttonLayout->addWidget(newButton); buttonLayout->addWidget(cancelButton); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(listWidget); mainLayout->addLayout(buttonLayout); }
/* * Method to generate Symbian specific date based folder structure where the * captured image or video will be saved. */ void S60FileNameGenerator::generateFolder(QDir ¤tDirectory, QDate &date, int &fileNameOffset) { // Folder of format: YYYYMM QString newFolder = date.toString(QLatin1String("yyyyMM")); if (!currentDirectory.cd(newFolder)) { if (!currentDirectory.mkpath(newFolder)) { currentDirectory.mkpath(currentDirectory.path()); return; } if (!currentDirectory.cd(newFolder)) { currentDirectory.mkpath(currentDirectory.path()); return; } } // Now create subfolder of format: YYYYMM[A-Z][0-9] fileNameOffset = 0; char indexChar('A'); int indexInt = 0; QString testFolder; while (true) { testFolder = currentDirectory.path() + QLatin1Char('/') + newFolder + indexChar + QString::number(indexInt); if (currentDirectory.cd(testFolder)) { // Check file count (max 100 files per folder) if (currentDirectory.entryList().count() < 100) { return; } else { // Folder full, check next if (indexInt < 9) { ++indexInt; } else { indexInt = 0; indexChar += 1; } fileNameOffset += 100; continue; } } else { if (currentDirectory.mkpath(testFolder)) { if (currentDirectory.cd(testFolder)) return; } } } }
TB_PokemonBoxes::TB_PokemonBoxes(Team *_team) { m_team = _team; currentPoke = 0; QVBoxLayout * ml = new QVBoxLayout(this); QHBoxLayout *firstline = new QHBoxLayout(); ml->addLayout(firstline); firstline->addWidget(m_details = new TB_PokemonDetail()); firstline->addSpacing(20); firstline->addWidget(new TitledWidget(tr("Change Order"), m_buttons = new TB_PokemonButtons()),0,Qt::AlignVCenter); QVBoxLayout *thirdColumn = new QVBoxLayout(); firstline->addLayout(thirdColumn); QPushButton *bstore, *bwithdraw, /* *bswitch, */ *bdelete, *bboxname, *addbox, *deletebox; thirdColumn->addStretch(100); thirdColumn->addWidget(bstore = new QPushButton(tr("&Store"))); thirdColumn->addWidget(bwithdraw = new QPushButton(tr("&Withdraw"))); //thirdColumn->addWidget(bswitch = new QPushButton(tr("Switc&h"))); thirdColumn->addWidget(bdelete = new QPushButton(tr("Dele&te"))); thirdColumn->addWidget(bboxname = new QPushButton(tr("&Edit Box Name..."))); thirdColumn->addWidget(addbox = new QPushButton(tr("&Add New Box"))); thirdColumn->addWidget(deletebox = new QPushButton(tr("&Delete Current Box"))); thirdColumn->addStretch(100); firstline->addStretch(100); bstore->setFixedWidth(132); QHBoxLayout *secondline = new QHBoxLayout(); ml->addLayout(secondline); secondline->addWidget(m_boxes = new TB_BoxContainer(), 100); QDir directory = QDir(PokemonBox::getBoxPath()); QStringList files = directory.entryList(QStringList() << "*.box", QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name); if (files.size() == 0) { files.push_back("First Box.box"); } foreach (QString file, files) { addBox(file); }
void Project::removeTempDirectory() { mDbAdapter->close(); QDir tempDir = getTempDir(); tempDir.setNameFilters(QStringList("*")); QStringList files = tempDir.entryList(QDir::Files,QDir::Name); for(int i=0; i<files.count(); i++) { QFile f( tempDir.absoluteFilePath( files.at(i) ) ); if( ! f.remove() ) qWarning() << f.errorString() << tempDir.absoluteFilePath( files.at(i) ) ; } tempDir.cdUp(); tempDir.rmdir( tempDirName() ); }
void AndroidSettingsWidget::searchForAnt(const QString &location) { if (!m_androidConfig.antLocation.isEmpty()) return; if (location.isEmpty()) return; QDir parentFolder = QFileInfo(location).absoluteDir(); foreach (const QString &file, parentFolder.entryList()) { if (file.startsWith(QLatin1String("apache-ant"))) { QString ant = parentFolder.absolutePath() + QLatin1Char('/') + file + QLatin1String("/bin/ant.bat"); if (QFileInfo(ant).exists()) { m_androidConfig.antLocation = Utils::FileName::fromString(ant); m_ui->AntLocationLineEdit->setText(ant); } } } }
void MainWindow::LogSystemAppend(QString Input) { //////////////////////////////////////////////////////////////////////////////////////// QDir directory; QString TempString; bool t=false; QDate dateNow; TempString = dateNow.currentDate().toString("yyyy.MM.d"); //////////////////////////////////////////////////////////////////////////////////////// // Логи лежат в /root/.WiFiHostapdAP/logs/сегодняшняя дата/log.txt //////////////////////////////////////////////////////////////////////////////////////// // 1. Идём в папку /root/.WiFiHostapdAP/logs/ //////////////////////////////////////////////////////////////////////////////////////// directory.cd("/root"); if(!directory.cd(".WiFiHostapdAP")) { directory.mkdir(QString("%1").arg(".WiFiHostapdAP")); directory.cd(".WiFiHostapdAP"); } if(!directory.cd("logs")) { directory.mkdir(QString("%1").arg("logs")); directory.cd("logs"); } //////////////////////////////////////////////////////////////////////////////////////// // 2. Смотрим список файлов и если там есть папка с сегодняшней датой, то всё отлично, // если её нет, то создём ей //////////////////////////////////////////////////////////////////////////////////////// QStringList listDir = directory.entryList(QDir::Dirs); foreach (QString subdir, listDir) { if (subdir == "." || subdir == "..") continue; else { if(subdir==TempString) t = true; } } if(!t) directory.mkdir(TempString); ////////////////////////////////////////////////////////////////////////////////////////// //// 3. Открываем файл, чтобы дозаписывать строки ////////////////////////////////////////////////////////////////////////////////////////// QFile LogFileNew(QString("%1%2%3").arg("/root/.WiFiHostapdAP/logs/", TempString, "/log.txt")); LogFileNew.open(QIODevice::Append | QIODevice::Text | QIODevice::Unbuffered); QTextStream LogFileOout(&LogFileNew); ////////////////////////////////////////////////////////////////////////////////////////// //// 4. Формируем лог и записываем в файл ////////////////////////////////////////////////////////////////////////////////////////// QString InputNew = Input.replace("\n",""); LogFileOout << InputNew << "\n"; //// Закрываем файл LogFileNew.close(); }
int TrainingSet::getTrainingSet(cv::vector<cv::Mat> &images, cv::vector<int> &labels, cv::vector<QString> &names){ QStringList directoriesList = getAvailableFaces(); labels.clear(); images.clear(); names.clear(); for(int i=0; i<directoriesList.size(); i++){ QString person = directoriesList.at(i); QDir faceDirectory; faceDirectory.setPath(mainDirectory.path() + "/" + person); QStringList photosList = faceDirectory.entryList(QDir::Files); foreach(QString photo, photosList){ images.push_back(cv::imread(faceDirectory.path().toStdString() + "/" + photo.toStdString(), CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(i); } names.push_back(person); }
static QList<CMakeTool *> autoDetectCMakeTools() { QStringList filters; filters.append(QStringLiteral("cmake")); QList<FileName> suspects; QStringList path = Environment::systemEnvironment().path(); path.removeDuplicates(); QDir dir; dir.setNameFilters(filters); dir.setFilter(QDir::Files | QDir::Executable); foreach (const QString &base, path) { dir.setPath(base); foreach (const QString &entry, dir.entryList()) suspects.append(FileName::fromString(dir.absoluteFilePath(entry))); }
QStringList QDeviceDiscoveryStatic::old_ScanConnectedDevices() { QStringList devices; QDir dir; dir.setFilter(QDir::System); if (m_types & Device_InputMask) { dir.setPath(QString::fromLatin1(QT_EVDEV_DEVICE_PATH)); foreach (const QString &deviceFile, dir.entryList()) { if (-1 == deviceFile.indexOf(QString::fromLatin1(QT_EVDEV_DEVICE_PREFIX))) { continue; } QString absoluteFilePath = dir.absolutePath() + QString::fromLatin1("/") + deviceFile; if (checkDeviceType(absoluteFilePath)) devices << absoluteFilePath; } }
bool VUtils::fileExists(const QDir &p_dir, const QString &p_name, bool p_forceCaseInsensitive) { if (!p_forceCaseInsensitive) { return p_dir.exists(p_name); } QString name = p_name.toLower(); QStringList names = p_dir.entryList(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot); foreach (const QString &str, names) { if (str.toLower() == name) { return true; } } return false; }
void KinotifyWidget::LoadTheme (const QString& themePath) { Theme_.clear (); QFile content (themePath + "/tmp.html"); if (!content.open (QIODevice::ReadOnly)) { qWarning () << Q_FUNC_INFO << "could not open theme file at" << content.fileName () << content.errorString (); return; } Theme_ = content.readAll (); const QPalette& palette = QApplication::palette (); #define REPLACE1(a) { const QColor& c = palette.color (QPalette::a); \ Theme_.replace ("{Color"#a "}", QString ("%1, %2, %3").arg (c.red ()).arg (c.green ()).arg (c.blue ())); } REPLACE1 (Window); REPLACE1 (WindowText); REPLACE1 (Base); REPLACE1 (AlternateBase); REPLACE1 (ToolTipBase); REPLACE1 (ToolTipText); REPLACE1 (Text); REPLACE1 (Button); REPLACE1 (ButtonText); REPLACE1 (BrightText); REPLACE1 (Light); REPLACE1 (Midlight); REPLACE1 (Dark); REPLACE1 (Mid); REPLACE1 (Shadow); REPLACE1 (Link); REPLACE1 (LinkVisited); REPLACE1 (Highlight); REPLACE1 (HighlightedText); #undef REPLACE1 QDir imgDir (themePath + "/img"); Q_FOREACH (QString elem, imgDir.entryList (QStringList ("*.png"))) Theme_.replace (QString ("{%1}").arg (elem.left (elem.size () - 4)), MakeImage (themePath + "/img/" + elem)); }
static std::vector<MSVCArchInfo> findSupportedArchitectures(const MSVC &msvc) { std::vector<MSVCArchInfo> result; auto addResult = [&result](const MSVCArchInfo &ai) { if (QFile::exists(ai.binPath + QLatin1String("/cl.exe"))) result.push_back(ai); }; if (msvc.internalVsVersion.majorVersion() < 15) { static const QStringList knownArchitectures = QStringList() << QStringLiteral("x86") << QStringLiteral("amd64_x86") << QStringLiteral("amd64") << QStringLiteral("x86_amd64") << QStringLiteral("ia64") << QStringLiteral("x86_ia64") << QStringLiteral("x86_arm") << QStringLiteral("amd64_arm"); for (const QString &knownArchitecture : knownArchitectures) { MSVCArchInfo ai; ai.arch = knownArchitecture; ai.binPath = msvc.binPathForArchitecture(knownArchitecture); addResult(ai); } } else { QDir vcInstallDir(msvc.vcInstallPath); const auto hostArchs = vcInstallDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (const QString &hostArch : hostArchs) { QDir subdir = vcInstallDir; if (!subdir.cd(hostArch)) continue; const QString shortHostArch = hostArch.mid(4).toLower(); const auto archs = subdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (const QString &arch : archs) { MSVCArchInfo ai; ai.binPath = subdir.absoluteFilePath(arch); if (shortHostArch == arch) ai.arch = arch; else ai.arch = shortHostArch + QLatin1Char('_') + arch; addResult(ai); } } } return result; }
void COptions::on_buttonBox_accepted() { // Show the Wait Cursor QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); // Write the value to the settings storage, where ever it is... m_settings->setValue("ChartPath", ui->txtChartPath->text()); m_settings->setValue("ActOS",ui->cbxActualizeOnStartup->isChecked()); m_settings->setValue("UID", ui->txtUserName->text()); m_settings->setValue("PW",ui->txtPassword->text()); m_settings->setValue("PDFexe",ui->txtPdfExePath->text()); // Get all subdir's names... QDir* basedir = new QDir(m_settings->value("ChartPath").toString()); QStringList dirlist = basedir->entryList(); // Iterate and parse them... foreach (QString fielddir, dirlist) { QString icao = fielddir.left(4); QString name = fielddir.right(fielddir.length()-7); QString fieldpath = basedir->absolutePath(); fieldpath.append("/"); fieldpath.append(fielddir); // We don't need parent and actual dir, so we sort'em out... if(icao.left(1) != ".") { // Give ICAO and name to the database manager... int FID = mdb->AddField(icao, name, fieldpath); QString cdirname = fieldpath; cdirname.append("/"); QDir* chartdir = new QDir(cdirname); QFileInfoList lDirInfo; lDirInfo = chartdir->entryInfoList(); foreach(QFileInfo chart, lDirInfo) { // Skip directories... if(chart.fileName().left(1) != ".") { QString CPath = cdirname; CPath.append(chart.fileName()); mdb->AddChart(FID, chart.fileName(), CPath, chart.lastModified().date()); } } }
void RemoteMenu::initialize() { int id = 0; if (KickerSettings::showMenuTitles()) { insertTitle(i18n("Network Folders")); } id = insertItem(SmallIcon("wizard"), i18n("Add Network Folder")); connectItem(id, this, SLOT(startWizard())); id = insertItem(SmallIcon("kfm"), i18n("Manage Network Folders")); connectItem(id, this, SLOT(openRemoteDir())); insertSeparator(); m_desktopMap.clear(); QStringList names_found; QStringList dirList = KGlobal::dirs()->resourceDirs("remote_entries"); QStringList::ConstIterator dirpath = dirList.begin(); QStringList::ConstIterator end = dirList.end(); for(; dirpath!=end; ++dirpath) { QDir dir = *dirpath; if (!dir.exists()) continue; QStringList filenames = dir.entryList( QDir::Files | QDir::Readable ); QStringList::ConstIterator name = filenames.begin(); QStringList::ConstIterator endf = filenames.end(); for(; name!=endf; ++name) { if (!names_found.contains(*name)) { names_found.append(*name); QString filename = *dirpath+*name; KDesktopFile desktop(filename); id = insertItem(SmallIcon(desktop.readIcon()), desktop.readName()); m_desktopMap[id] = filename; } } } }
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { sbar = new QStatusBar(); main_win = this; setFixedSize(640,480); this->setWindowTitle(tr("QRhymingDictionary")); line_edit = new QLineEdit; combo_box = new QComboBox; timer = new QTimer; timer->setInterval(0); //mseconds timer->setSingleShot(true); QObject::connect(line_edit,SIGNAL(textChanged(QString)),timer,SLOT(start())); QObject::connect(timer,SIGNAL(timeout()),this,SLOT(insert_rhymes())); QObject::connect(combo_box,SIGNAL(currentIndexChanged(int)),this,SLOT(insert_rhymes())); text_edit = new QTextEdit; text_edit->setReadOnly(true); QGridLayout *grid_layout_main = new QGridLayout; QGridLayout *grid_layout_2nd = new QGridLayout; grid_layout_2nd->addWidget(line_edit,0,0); grid_layout_2nd->addWidget(combo_box,0,1); grid_layout_main->addItem(grid_layout_2nd,0,0); grid_layout_main->addWidget(text_edit,1,0); setLayout(grid_layout_main); QDir dir = QDir::current(); QStringList filter; filter.append("*.sqlite"); QStringList list_of_db_files = dir.entryList(filter,QDir::Files,QDir::Name); int number = 0; QString text; for(QList<QString>::iterator it = list_of_db_files.begin();it < list_of_db_files.end();it++) { text = *it; number = get_words_number(*it); if(text.endsWith(QString(".sqlite"))) { text.chop(7); } text.append(QString(" (%1 words)").arg(number)); combo_box->addItem(text,*it); } }
void WatchMoviesView::updateMoviesList() { if(!OptionsView::instance()) return; mUi->moviesTable->clearContents(); while(mUi->moviesTable->rowCount() != 0) mUi->moviesTable->removeRow(0); QDir directory = QDir(OptionsView::instance()->getMoviesDir()); QStringList files = directory.entryList(QStringList("*.tem"), QDir::Files); MovieFile movieFile; for(int i = 0; i < files.size(); i++) { if(movieFile.loadMovie(OptionsView::instance()->getMoviesDir() + "/" + files[i], false)) { int row = mUi->moviesTable->rowCount(); mUi->moviesTable->insertRow(row); mUi->moviesTable->setRowHeight(row, 16); mUi->moviesTable->setItem(row, 8, new QTableWidgetItem(files[i])); mUi->moviesTable->setItem(row, 7, new QTableWidgetItem(QString::number(movieFile.getTibiaVersion()))); mUi->moviesTable->setItem(row, 6, new QTableWidgetItem(QTime().addMSecs(movieFile.getMovieDuration()).toString("hh:mm:ss"))); mUi->moviesTable->setItem(row, 5, new QTableWidgetItem(QDateTime::fromTime_t(movieFile.getMovieDate()).toString())); mUi->moviesTable->setItem(row, 4, new QTableWidgetItem(QString::number(movieFile.getPlayerLevel()))); mUi->moviesTable->setItem(row, 3, new QTableWidgetItem(movieFile.getPlayerWorld())); mUi->moviesTable->setItem(row, 2, new QTableWidgetItem(movieFile.getPlayerName())); mUi->moviesTable->setItem(row, 1, new QTableWidgetItem(movieFile.getMovieTypeName())); mUi->moviesTable->setItem(row, 0, new QTableWidgetItem(movieFile.getMovieTitle())); } } mUi->moviesTable->sortByColumn(0, Qt::AscendingOrder); mUi->moviesTable->resizeColumnsToContents(); mUi->titleLabelValue->clear(); mUi->typeLabelValue->clear(); mUi->playerLabelValue->clear(); mUi->worldLabelValue->clear(); mUi->dateLabelValue->clear(); mUi->durationLabelValue->clear(); mUi->versionLabelValue->clear(); mUi->descriptionText->clear(); }
// static void SoundSourceProxy::loadPlugins() { /** Scan for and initialize all plugins */ QList<QDir> pluginDirs; QStringList nameFilters; const QString& pluginPath = CmdlineArgs::Instance().getPluginPath(); if (!pluginPath.isEmpty()) { qDebug() << "Adding plugin path from commandline arg:" << pluginPath; pluginDirs.append(QDir(pluginPath)); } #ifdef __LINUX__ QDir libPath(UNIX_LIB_PATH); if (libPath.cd("plugins") && libPath.cd("soundsource")) { pluginDirs.append(libPath.absolutePath()); } pluginDirs.append(QDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/.mixxx/plugins/soundsource/")); #elif __WINDOWS__ pluginDirs.append(QDir(QCoreApplication::applicationDirPath() + "/plugins/soundsource/")); #elif __APPLE__ QString bundlePluginDir = QCoreApplication::applicationDirPath(); //blah/Mixxx.app/Contents/MacOS bundlePluginDir.remove("MacOS"); //blah/Mixxx.app/Contents/PlugIns/soundsource //bundlePluginDir.append("PlugIns/soundsource"); //Our SCons bundle target doesn't handle plugin subdirectories :( bundlePluginDir.append("PlugIns/"); pluginDirs.append(QDir(bundlePluginDir)); // Do we ever put stuff here? I think this was meant to be // ~/Library/Application Support/Mixxx/Plugins rryan 04/2012 pluginDirs.append(QDir("/Library/Application Support/Mixxx/Plugins/soundsource/")); pluginDirs.append(QDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/Library/Application Support/Mixxx/Plugins/soundsource/")); nameFilters << "libsoundsource*"; #endif QDir dir; foreach(dir, pluginDirs) { QStringList files = dir.entryList(nameFilters, QDir::Files | QDir::NoDotAndDotDot); QString file; foreach (file, files) { getPlugin(dir.filePath(file)); }
void Appearance::resetValues() { *config = MusEGlobal::config; // init with global config values styleSheetPath->setText(config->styleSheetFile); updateFonts(); QPalette pal; palette0->setStyleSheet(QString("background-color: ") + config->palette[0].name()); palette1->setStyleSheet(QString("background-color: ") + config->palette[1].name()); palette2->setStyleSheet(QString("background-color: ") + config->palette[2].name()); palette3->setStyleSheet(QString("background-color: ") + config->palette[3].name()); palette4->setStyleSheet(QString("background-color: ") + config->palette[4].name()); palette5->setStyleSheet(QString("background-color: ") + config->palette[5].name()); palette6->setStyleSheet(QString("background-color: ") + config->palette[6].name()); palette7->setStyleSheet(QString("background-color: ") + config->palette[7].name()); palette8->setStyleSheet(QString("background-color: ") + config->palette[8].name()); palette9->setStyleSheet(QString("background-color: ") + config->palette[9].name()); palette10->setStyleSheet(QString("background-color: ") + config->palette[10].name()); palette11->setStyleSheet(QString("background-color: ") + config->palette[11].name()); palette12->setStyleSheet(QString("background-color: ") + config->palette[12].name()); palette13->setStyleSheet(QString("background-color: ") + config->palette[13].name()); palette14->setStyleSheet(QString("background-color: ") + config->palette[14].name()); palette15->setStyleSheet(QString("background-color: ") + config->palette[15].name()); global_bg->takeChildren(); user_bg->takeChildren(); QDir bgdir = MusEGlobal::museGlobalShare + "/wallpapers/"; QStringList filters; filters << "*.jpg" << "*.jpeg" << "*.png" << "*.gif"; bgdir.setNameFilters(filters); backgroundTree->model()->setData(backgroundTree->model()->index(0,0), QVariant(QSize(200,BG_ITEM_HEIGHT)), Qt::SizeHintRole); QStringList bglist = bgdir.entryList(QDir::Files, QDir::Name); foreach (const QString &bgfile, bglist) { QTreeWidgetItem* item = new QTreeWidgetItem(global_bg, 0); item->setData(0, Qt::UserRole, QVariant(MusEGlobal::museGlobalShare + "/wallpapers/" + bgfile)); BgPreviewWidget* bgw = new BgPreviewWidget(MusEGlobal::museGlobalShare + "/wallpapers/" + bgfile, backgroundTree); backgroundTree->setItemWidget(item, 0, bgw); if (config->canvasBgPixmap == MusEGlobal::museGlobalShare + "/wallpapers/" + bgfile) backgroundTree->setCurrentItem(item); }
bool ImageContainerWidget::loadImagesFromFolder(QDir dir) { _images.clear(); // get numbers of images in folder QStringList fileslist = dir.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); unsigned int nrImages = fileslist.size(); for(unsigned int i=0 ; i<nrImages ; i++) { // generate filename QString filename; // check if file exists _images.push_back(cv::imread("filename")); } return true; }
void AndroidSettingsWidget::searchForAnt(const QString &location) { if (!m_androidConfig.antLocation.isEmpty()) return; if (location.isEmpty()) return; QDir parentFolder = QFileInfo(location).absoluteDir(); foreach (const QString &file, parentFolder.entryList()) { if (file.startsWith(QLatin1String("apache-ant"))) { Utils::FileName ant = Utils::FileName::fromString(parentFolder.absolutePath()); ant.appendPath(file).appendPath(QLatin1String("bin")).appendPath(QLatin1String("ant.bat")); if (ant.toFileInfo().exists()) { m_androidConfig.antLocation = ant; m_ui->AntLocationLineEdit->setText(ant.toUserOutput()); } } } }
void HIC::WMain::loadLinkTypes() { QString linktypeDirPath = QCoreApplication::applicationDirPath() + tr("/linktypes/"); QDir linktypeDir = QDir(linktypeDirPath); QStringList nameFilters; nameFilters.append(QString("*.linktype")); QStringList fileList = linktypeDir.entryList(nameFilters); std::vector<std::string> linkTypeFilePaths; for (QStringList::iterator iterator = fileList.begin(); iterator != fileList.end(); iterator++) { linkTypeFilePaths.push_back(iterator->toStdString()); } QDir::setCurrent(linktypeDirPath); _application.loadLinkTypeList(linkTypeFilePaths); QDir::setCurrent(QCoreApplication::applicationDirPath()); }
int main(int argc, char *argv[]) { QDir::setCurrent(QFileInfo(QString(argv[0])).absoluteDir().absolutePath()); qDebug(QFileInfo(QString(argv[0])).absoluteDir().absolutePath().prepend("cd ").toAscii()); //Asking user for language and starting application QApplication a(argc, argv); QTranslator *t = new QTranslator(); QDialog *diag = new QDialog(); diag->setLayout(new QHBoxLayout()); QComboBox *chooser = new QComboBox(diag); QDir *dir = new QDir("Dictionaries"); QStringList langs = dir->entryList(QStringList("[A-Z][A-Z]*.qm"), QDir::Files); QStringList chopped = QStringList(); foreach(QString s, langs){ s.chop(3); chopped.append(s); }
static bool checkForStaticBuild(const QtEnvironment &qt) { if (qt.qtMajorVersion >= 5) return qt.qtConfigItems.contains(QLatin1String("static")); if (qt.frameworkBuild) return false; // there are no Qt4 static frameworks const bool isWin = qt.mkspecName.startsWith(QLatin1String("win")); const QDir libdir(isWin ? qt.binaryPath : qt.libraryPath); const QStringList coreLibFiles = libdir.entryList(QStringList(QLatin1String("*Core*")), QDir::Files); if (coreLibFiles.isEmpty()) throw ErrorInfo(Internal::Tr::tr("Could not determine whether Qt is a static build.")); foreach (const QString &fileName, coreLibFiles) { if (QLibrary::isLibrary(fileName)) return false; } return true; }
void UnitTests::TestID_2() { // OK Test QStringList fileFilter("*.csv"); QDir directory = QDir::current(); directory.cd("students"); QStringList studentList = directory.entryList(fileFilter); QVector<Student> students = LoadStudents(studentList); QCOMPARE(students.size(), 3); // ERROR Test QStringList fileFilter2("*.csv"); QDir directory2 = QDir::current(); directory.cd("major"); QStringList studentList2 = directory2.entryList(fileFilter2); QVector<Student> students2 = LoadStudents(studentList2); QCOMPARE(students2.size(), 0); }
void UnitTests::TestID_1() { // OK Test QStringList fileFilter("*.csv"); QDir directory = QDir::current(); directory.cd("majors"); QStringList majorList = directory.entryList(fileFilter); QVector<Major> majors = LoadMajors(majorList); QCOMPARE(majors.size(), 2); // ERROR Test QStringList fileFilter2("*.csv"); QDir directory2 = QDir::current(); directory2.cd("students"); QStringList majorList2 = directory2.entryList(fileFilter2); QVector<Major> majors2 = LoadMajors(majorList2); QCOMPARE(majors2.size(), 0); }
void PlayerWidget::updateFromFolder() { QDir imageDir = QDir(dirPath); QStringList imageFileExtensions; imageFileExtensions << "*.jpg" << "*.jpeg" << "*.png" << "*.tiff"; imageDir.setNameFilters(imageFileExtensions); imageFiles = imageDir.entryList(QDir::NoDotAndDotDot | QDir::Files); if (imageFiles.size() == 0) { imageLabel->setText(QObject::tr("No frames to play")); } else { positionSlider->setRange(0, imageFiles.size() - 1); setPosition(currentIndex); } }
QString Cleaner::findFile(QDir dir, QString filename) { QStringList dirs; if (QFile::exists(dir.canonicalPath() + "/" + filename)) return QString(dir.canonicalPath() + "/" + filename); else { // file not in this dir, search recursively dirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); for (int i=0; i<dirs.size(); i++) { QString tmp; tmp = findFile(QDir(dir.canonicalPath() + "/" + dirs[i]), filename); if (!(tmp.isNull() || tmp.isEmpty())) { return QString(tmp); } } return(QString()); } }
void RepositoryProfile::clearDirectory ( const QString& path ) { QDir dir ( path ); if ( !dir.exists() ) // nothing to delete return; QStringList files = dir.entryList(); foreach ( const QString &file, files ) { // only remove files QFileInfo fileInfo ( dir, file ); if ( fileInfo.isFile() ) { if ( !dir.remove ( file ) ) qDebug ( "could not remove file: %s", qPrintable ( file ) ); } }
void StyleEngene::init() { #ifdef Q_WS_WIN QString rootPath = QApplication::applicationDirPath() + "/styles/"; #endif #ifdef Q_WS_UNIX QString rootPath = "/usr/share/cutetorrent/styles/"; #endif QDir rootDir = QDir(rootPath); if(rootDir.exists()) { QStringList styleDirs = rootDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); foreach(QString styleDir, styleDirs) { loadStyleInfo(rootPath + styleDir); }
void SearchEngine::init() { #ifdef Q_WS_WIN QString rootPath = StaticHelpers::CombinePathes(QApplication::applicationDirPath(), "searchEngines"); #endif #ifdef Q_OS_UNIX QString rootPath = "/usr/share/cutetorrent/searchEngines/"; #endif QDir rootDir = QDir(rootPath); if (rootDir.exists()) { QStringList engineDirs = rootDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); foreach(QString styleDir, engineDirs) { loadSearchProvider(StaticHelpers::CombinePathes(rootPath, styleDir)); }