本文整理汇总了C++中QDir::entryList方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::entryList方法的具体用法?C++ QDir::entryList怎么用?C++ QDir::entryList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::entryList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: i
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);
}
示例2: QVBoxLayout
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);
}
示例3: removeTempDirectory
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() );
}
示例4: searchForAnt
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);
}
}
}
}
示例5: LogSystemAppend
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();
}
示例6: getTrainingSet
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);
}
示例7: autoDetectCMakeTools
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)));
}
示例8: old_ScanConnectedDevices
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;
}
}
示例9: fileExists
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;
}
示例10: LoadTheme
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));
}
示例11: vcInstallDir
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;
}
示例12: on_buttonBox_accepted
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());
}
}
}
示例13: QWidget
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);
}
}
示例14: updateMoviesList
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();
}
示例15: loadPlugins
// 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));
}