本文整理汇总了C++中qfileinfolist::iterator类的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkChanges
void Watcher::checkChanges(const QString& path) { // Getting name of appeared file
delete dir;
dir = new QDir(path);
listOfFiles = dir->entryInfoList();
qDebug() << "Изменения в каталоге";
qDebug() << listOfFiles.length() << oldLength << "\n";
if (listOfFiles.length() > oldLength) {
QFileInfoList::iterator i;
QFileInfoList::iterator j;
for (j = oldListOfFiles.begin(); j != oldListOfFiles.end(); ++j)
{
for (i = listOfFiles.begin(); i != listOfFiles.end(); ++i)
{
if (i->fileName().compare(j->fileName()) == 0)
{
listOfFiles.erase(i);
break;
}
}
}
qDebug() << listOfFiles.first().fileName();
dialog = new Dialog(listOfFiles.first(), this);
dialog->show();
setLabel(listOfFiles.first().fileName()); // Showing bubble notification in tray
}
oldListOfFiles = dir->entryInfoList();
oldLength = oldListOfFiles.length();
}
示例2: QString
QString LeScienze500::getDvdPath()
{
#ifdef Q_WS_X11
QString path = "/media/LESCIENZE" ;
QString path_1 = path + "/DVD1" ;
QString path_2 = path + "/DVD2" ;
if ( QFile().exists( path_1 ) || QFile().exists( path_2 ) )
return path ;
else
return QString() ;
#endif
#ifdef Q_WS_WIN
QFileInfoList dev_list ;
dev_list = QDir::drives() ;
for ( QFileInfoList::iterator itr = dev_list.begin() ; itr < dev_list.end() ; itr++ )
{
QString path = itr->absolutePath() ;
QString path_1 = path + "/DVD1" ;
QString path_2 = path + "/DVD2" ;
if ( QFile().exists( path_1 ) || QFile().exists( path_2 ) )
{
return path ;
}
}
return QString() ;
#endif
}
示例3: updateGotCurrent
void Application::updateGotCurrent() {
if (!updateReply || updateThread) return;
cSetLastUpdateCheck(unixtime());
QRegularExpressionMatch m = QRegularExpression(qsl("^\\s*(\\d+)\\s*:\\s*([\\x21-\\x7f]+)\\s*$")).match(QString::fromUtf8(updateReply->readAll()));
if (m.hasMatch()) {
int32 currentVersion = m.captured(1).toInt();
if (currentVersion > AppVersion) {
updateThread = new QThread();
connect(updateThread, SIGNAL(finished()), updateThread, SLOT(deleteLater()));
updateDownloader = new PsUpdateDownloader(updateThread, m.captured(2));
updateThread->start();
}
}
if (updateReply) updateReply->deleteLater();
updateReply = 0;
if (!updateThread) {
QDir updates(cWorkingDir() + "tupdates");
if (updates.exists()) {
QFileInfoList list = updates.entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) {
if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) {
QFile(i->absoluteFilePath()).remove();
}
}
}
emit updateLatest();
}
startUpdateCheck(true);
App::writeConfig();
}
示例4: removeDir
bool VideoMetadataImp::removeDir(const QString &dirName)
{
QDir d(dirName);
QFileInfoList contents = d.entryInfoList();
if (!contents.size())
{
return d.rmdir(dirName);
}
for (QFileInfoList::iterator p = contents.begin(); p != contents.end(); ++p)
{
if (p->fileName() == "." ||
p->fileName() == "..")
{
continue;
}
if (p->isDir())
{
QString fileName = p->fileName();
if (!removeDir(fileName))
return false;
}
else
{
if (!QFile(p->fileName()).remove())
return false;
}
}
return d.rmdir(dirName);
}
示例5: removeFileWithDir
/*递归删除文件夹内容
**
**dir :文件夹的名字,绝对路径和相对路径均可
**
**返回值 :成功后返回true;否则返回false
*/
bool removeFileWithDir(const QString &dirName)
{
static QVector<QString> dirNames;
QDir dir;
QFileInfoList filst;
QFileInfoList::iterator curFi;
//初始化
dirNames.clear();
if(dir.exists()){
dirNames<<dirName;
}
else{
return 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(filst.size()>0)
{
curFi=filst.begin();
while(curFi!=filst.end())
{
//遇到文件夹,则添加至文件夹列表dirs尾部
if(curFi->isDir())
{
dirNames.push_back(curFi->filePath());
}
else if(curFi->isFile())
{
//遇到文件,则删除之
if(!dir.remove(curFi->fileName()))
{
//return false;
}
}
curFi++;
}//end of while
}
}
#if 0
//删除文件夹
for(int i=dirNames.size()-1;i>=0;--i)
{
if(!dir.rmdir(dirNames[i]))
{
//return false;
}
}
#endif
return true;
}
示例6: cleanup
void KTNEFMain::cleanup()
{
QDir d( KGlobal::dirs()->localkdedir() + "/share/apps/ktnef/tmp/" );
QFileInfoList list = d.entryInfoList( QDir::Files | QDir::Hidden, QDir::Unsorted );
QFileInfoList::iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
d.remove( it->absoluteFilePath() );
}
}
示例7: initOutput
void PsUpdateDownloader::initOutput() {
QString fileName;
QRegularExpressionMatch m = QRegularExpression(qsl("/([^/\\?]+)(\\?|$)")).match(updateUrl);
if (m.hasMatch()) {
fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
}
if (fileName.isEmpty()) {
fileName = qsl("tupdate-%1").arg(rand());
}
QString dirStr = cWorkingDir() + qsl("tupdates/");
fileName = dirStr + fileName;
QFileInfo file(fileName);
QDir dir(dirStr);
if (dir.exists()) {
QFileInfoList all = dir.entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = all.begin(), e = all.end(); i != e; ++i) {
if (i->absoluteFilePath() != file.absoluteFilePath()) {
QFile::remove(i->absoluteFilePath());
}
}
} else {
dir.mkdir(dir.absolutePath());
}
outputFile.setFileName(fileName);
if (file.exists()) {
uint64 fullSize = file.size();
if (fullSize < INT_MAX) {
int32 goodSize = (int32)fullSize;
if (goodSize % UpdateChunk) {
goodSize = goodSize - (goodSize % UpdateChunk);
if (goodSize) {
if (outputFile.open(QIODevice::ReadOnly)) {
QByteArray goodData = outputFile.readAll().mid(0, goodSize);
outputFile.close();
if (outputFile.open(QIODevice::WriteOnly)) {
outputFile.write(goodData);
outputFile.close();
QMutexLocker lock(&mutex);
already = goodSize;
}
}
}
} else {
QMutexLocker lock(&mutex);
already = goodSize;
}
}
if (!already) {
QFile::remove(fileName);
}
}
}
示例8: appendAllFileNamesForFileType
void MdPlottingCmapsProvider::appendAllFileNamesForFileType(
QStringList &colorMapNames, QStringList &colorMapFiles,
QString colorMapDirectory, QString fileType) {
QDir directory(colorMapDirectory);
QStringList filter(QString("*.%1").arg(fileType));
QFileInfoList info = directory.entryInfoList(filter, QDir::Files);
for (QFileInfoList::iterator it = info.begin(); it != info.end(); ++it) {
colorMapNames.append(it->baseName());
colorMapFiles.append(it->absoluteFilePath());
}
}
示例9: rollbackDocumentsTransition
void UniboardSankoreTransition::rollbackDocumentsTransition(QFileInfoList& fileInfoList)
{
QFileInfoList::iterator fileInfo;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
if (fileInfo->isDir() && fileInfo->fileName().startsWith("Uniboard Document ")){
QString sankoreDocumentName = fileInfo->fileName();
sankoreDocumentName.replace("Uniboard","Sankore");
QString sankoreDocumentDirectoryPath = UBSettings::userDocumentDirectory() + "/" + sankoreDocumentName;
if (QFileInfo(sankoreDocumentDirectoryPath).exists()){
UBFileSystemUtils::deleteDir(sankoreDocumentDirectoryPath);
}
}
}
}
示例10: getAllIncludes
void getAllIncludes(QString path, QFileInfoList h_files, QFileInfoList cpp_files, QStringList& includes)
{
for(QFileInfoList::iterator it = h_files.begin(); it != h_files.end(); it++)
{
QFile file(it->absoluteFilePath());
if(file.open(QFile::ReadOnly))
{
QTextStream textStream(&file);
while(!textStream.atEnd())
{
QString line = textStream.readLine();
if( line.indexOf("#include ") != -1 && line.indexOf("Q") != -1 )
{
addToStringList(includes, line);
}
}
file.close();
}
}
for(QFileInfoList::iterator it = cpp_files.begin(); it != cpp_files.end(); it++)
{
QFile file(it->absoluteFilePath());
if(file.open(QFile::ReadOnly))
{
QTextStream textStream(&file);
while(!textStream.atEnd())
{
QString line = textStream.readLine();
if( line.indexOf("//") == -1 &&
line.indexOf("#include ") != -1 &&
line.indexOf("Q") != -1
)
{
addToStringList(includes, line);
}
}
file.close();
}
}
}
示例11: startUpdateCheck
void Application::startUpdateCheck(bool forceWait) {
updateCheckTimer.stop();
if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return;
int32 updateInSecs = cLastUpdateCheck() + 3600 + (rand() % 3600) - unixtime();
bool sendRequest = (updateInSecs <= 0 || updateInSecs > 7200);
if (!sendRequest && !forceWait) {
QDir updates(cWorkingDir() + "tupdates");
if (updates.exists()) {
QFileInfoList list = updates.entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) {
if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) {
sendRequest = true;
}
}
}
}
if (cManyInstance() && !cDebug()) return; // only main instance is updating
if (sendRequest) {
QNetworkRequest checkVersion(cUpdateURL());
if (updateReply) updateReply->deleteLater();
App::setProxySettings(updateManager);
updateReply = updateManager.get(checkVersion);
connect(updateReply, SIGNAL(finished()), this, SLOT(updateGotCurrent()));
connect(updateReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(updateFailedCurrent(QNetworkReply::NetworkError)));
// updateRequestId = MTP::send(MTPhelp_GetAppUpdate(MTP_string(cApiDeviceModel()), MTP_string(cApiSystemVersion()), MTP_string(cApiAppVersion()), MTP_string(cApiLang())), rpcDone(&Application::onAppUpdate), rpcFail(&Application::onAppUpdateFail);
emit updateChecking();
} else {
updateCheckTimer.start((updateInSecs + 5) * 1000);
}
}
示例12: qDebug
bool LeScienze500::OpenPDF()
{
QFileInfoList drives = QDir::drives() ;
for ( QFileInfoList::iterator it = drives.begin() ; it < drives.end() ; it++ )
{
qDebug() << it->path() ;
}
if ( this->pdf_file.isEmpty() )
return false ;
return this->OpenPDF( this->pdf_file ) ;
}
示例13: processCacheCleaning
void LunarMainWindow::processCacheCleaning()
{
QDir dir("cache/");
QFileInfoList listDir = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
int i = 0;
for(QFileInfoList::iterator it = listDir.begin(); it != listDir.end(); ++it)
{
if(it->lastModified().date() <= m_cacheDuration)
{
qDebug() << it->lastModified().date() << " " << m_cacheDuration << endl;
QFile file("cache/" + it->fileName());
file.remove();
i++;
}
}
qDebug() << "Cleaned " << i << " expired elements from the cache" << endl;
}
示例14: RenamePak
/**********
*返回值:0成功
*1原包名不存在
*2创建包出错
*3目的包名已经存在
*4替换包名过程出错
***********/
int PathManager::RenamePak(QString &path, QString &oldPakName, QString &newPakName)
{
QString oldName = oldPakName;
QString newName = newPakName;
oldName.replace(".", "/");
newName.replace(".", "/");
QString srcDir = path + "/" + oldName;
QString destDir = path + "/" + newName;
QDir dirSrc(srcDir);
QDir dirDest(destDir);
if (!dirSrc.exists()){
return 1;
}
dirSrc.setFilter(QDir::NoDotAndDotDot | QDir::Files);
QFileInfoList allFiles = dirSrc.entryInfoList();
if (allFiles.isEmpty()){
return 1;
}
if (!dirDest.exists() && !dirDest.mkpath(destDir)){
return 2;
}
dirDest.setFilter(QDir::NoDotAndDotDot | QDir::Files);
if (!dirDest.entryInfoList().isEmpty()){
return 3;
}
for (QFileInfoList::iterator ite = allFiles.begin(); ite != allFiles.end(); ite++){
QString tmpName = ite->absoluteFilePath();
tmpName = tmpName.mid(tmpName.lastIndexOf("/") + 1);
if (!dirDest.exists()){
if (dirDest.mkpath(destDir)){
return 4;
}
}
if (!CopyFile(ite->absoluteFilePath(), destDir + "/" + tmpName, true) || !QFile::remove(ite->absoluteFilePath())){
return 4;
}
}
RemoveEmptyDirFromDeepest(srcDir);
return 0;
}
示例15: ReplacePakInDec
int PathManager::ReplacePakInDec(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;
}
//遍历各级文件夹,并将这些文件夹中的文件删除
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 (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(".smali")){
if (!ReplacePakNameInSmali(curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
else if (curFi->absoluteFilePath().toLower().endsWith(".xml")){
if (!ReplacePakNameInXml(path, curFi->absoluteFilePath(), oldName, newName)){
return 1;
}
}
}
curFi++;
}//end of while
}
}
int ret = 0;
ret = RenamePakInDec(path, oldName, newName);
if (ret != 0){
return ret;
}
return 0;
}