本文整理汇总了C++中QFileInfoList::length方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfoList::length方法的具体用法?C++ QFileInfoList::length怎么用?C++ QFileInfoList::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfoList
的用法示例。
在下文中一共展示了QFileInfoList::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadNewDir
void ImageProvider::loadNewDir(int inc) {
if (isLoading)
return;
QString curr = io->getCurrentDir(), sDir = curr;
curr = sDir.remove(sDir.length() - 1, 1); // Delete last slash
sDir = sDir.remove(sDir.lastIndexOf('/'), 100); // Delete all before last slash
QFileInfoList entr = QDir(sDir).entryInfoList({"*"}, QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
int ind = 0;
for (int i = 0; i < entr.size(); i++) {
if (curr == entr[i].absoluteFilePath()) {
ind = i;
}
}
ind += inc;
ind = ind < 0 ? 0 : ind;
ind = ind > entr.length() - 1 ? entr.length() - 1 : ind;
sDir = entr[ind].absoluteFilePath();
io->setCurrentDir(sDir + '/');
loadDir();
}
示例2: updateFavItems
void UserWidget::updateFavItems(){
ClearScrollArea(ui->scroll_fav);
QFileInfoList items;
QDir homedir = QDir( QDir::homePath()+"/Desktop");
QDir favdir = QDir( QDir::homePath()+"/.lumina/favorites");
if(!favdir.exists()){ favdir.mkpath( QDir::homePath()+"/.lumina/favorites"); }
if(ui->tool_fav_apps->isChecked()){
items = homedir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
items << favdir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
}else if(ui->tool_fav_dirs->isChecked()){
items = homedir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
items << favdir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
}else{
//Files
items = homedir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
items << favdir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
for(int i=0; i<items.length(); i++){
if(items[i].suffix()=="desktop"){ items.removeAt(i); i--; }
}
}
for(int i=0; i<items.length(); i++){
UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), items[i].absoluteFilePath(), ui->tool_fav_dirs->isChecked());
ui->scroll_fav->widget()->layout()->addWidget(it);
connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) );
connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) );
}
static_cast<QBoxLayout*>(ui->scroll_fav->widget()->layout())->addStretch();
}
示例3: DirControl
/**
* Constructeur, Charge la liste des controleurs disponibles et les propose dans l'IHM
* @brief f_ChoixControleur::f_ChoixControleur
* @param Config : Le fichier de config à éditer
* @param parent : widget parent
*/
f_ChoixControleur::f_ChoixControleur(QSettings* Config, QWidget *parent) :
QDialog (parent),
Config (Config),
ui (new Ui::f_ChoixControleur)
{
//Mise en place de l'IHM
this->ui->setupUi(this);
//Scan du dossier contenant les controleurs
QDir DirControl("./Controleurs");
QFileInfoList ListeDir (DirControl.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot));
//Listing de son contenu
for(register int i = 0; i < ListeDir.length(); i++)
{
//Si c'est un dossier
if(ListeDir[i].isDir())
{
//On va regarder ce q'il y a dedans
QDir RepertoireCourant("./Controleurs/" + ListeDir[i].completeBaseName());
QFileInfoList ListeFichier (RepertoireCourant.entryInfoList());
for(register int i = 0; i < ListeFichier.length(); i++)
{
//Si c'est un fichier et que son extension est .ini
if(ListeFichier[i].isFile() && ListeFichier[i].suffix() == "ini")
{
//On lit ce fichier et on récupere son nom
QSettings Config(ListeFichier[i].filePath(), QSettings::IniFormat);
this->ui->CB_Controleur->addItem(Config.value("Nom").toString());
}
}
}
}
//On charge la config courante si jamais il s'agit d'une édition de plan existant
QString ConfigCourante (this->Config->value("IDENTIFICATION/Board", "").toString());
if(!ConfigCourante.isEmpty())
{
this->ui->CB_Controleur->setCurrentText(ConfigCourante);
}
ConfigCourante = this->Config->value("IDENTIFICATION/Nom", "").toString();
if(!ConfigCourante.isEmpty())
{
this->ui->LE_NomProjet->setText(ConfigCourante);
}
//Chargement de la photo
this->ui->LB_Controleur->setPixmap(QPixmap("./Controleurs/" + this->ui->CB_Controleur->currentText() + "/photo.png"));
}
示例4: watcherNotification
void SystemFlagWatcher::watcherNotification(){
//qDebug() << "Watcher found change";
QDir dir(FLAGDIR);
if(!dir.exists()){ return; } //flag directory does not exist yet - do nothing
QDateTime oldCDT = CDT.addSecs(-1); //Always backup one second to make sure we get concurrently set flags
CDT = QDateTime::currentDateTime(); //Update the last time flags were checked
QFileInfoList flags = dir.entryInfoList( QDir::Files | QDir::NoDotAndDotDot, QDir::Time);
for(int i=0; i<flags.length(); i++){
if(oldCDT < flags[i].lastModified()){
QString contents = quickRead(flags[i].absoluteFilePath());
SystemFlags::SYSMESSAGE msg;
if(contents==MWORKING){ msg = SystemFlags::Working; }
else if(contents==MERROR){ msg = SystemFlags::Error; }
else if(contents==MSUCCESS){ msg = SystemFlags::Success; }
else if(contents==MUPDATE){ msg = SystemFlags::UpdateAvailable; }
else if(contents==MUPDATING){ msg = SystemFlags::Updating; }
else{ continue; } //invalid message - skip this flag
//New flag - check which one and emit the proper signal
if(flags[i].fileName().startsWith(NETWORKRESTARTED) ){
emit FlagChanged(SystemFlags::NetRestart, msg);
}else if(flags[i].fileName().startsWith(PKGUPDATEAVAILABLE) ){
emit FlagChanged(SystemFlags::PkgUpdate, msg);
}else if(flags[i].fileName().startsWith(SYSUPDATEAVAILABLE) ){
emit FlagChanged(SystemFlags::SysUpdate, msg);
}else if(flags[i].fileName().startsWith(WARDENUPDATEAVAILABLE) ){
emit FlagChanged(SystemFlags::WardenUpdate, msg);
}
}
}
if(chktime->isActive()){ chktime->stop(); }
chktime->start(); //restart the default timer
}
示例5: countFiles
int FileModel::countFiles()
{
QDir files("/home/user/MyDocs/exnote/");
QFileInfoList fileList = files.entryInfoList(QDir::Files, QDir::Time);
return fileList.length();
}
示例6: read_formula
void Enhancededitorwindow::read_formula()
{
_names_list.clear();
ui->cb_AtomFormula->clear();
QString contents;
QFile formula_file(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/user.fml");
if (formula_file.open(QIODevice::ReadOnly | QIODevice::Text))
{
while(!formula_file.atEnd())
{
contents = formula_file.readLine(0).constData();
ui->cb_AtomFormula->addItem(QIcon(":/images/icons/formel.png"), contents.trimmed());
}
}
formula_file.close();
QDir dictDir = QDir(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox");
QStringList filterList;
filterList.append("*.dict");
filterList.append("*.pdict");
QFileInfoList fileList = dictDir.entryInfoList(filterList);
for(int i = 0; i < fileList.length(); i++)
_names_list.append(fileList.at(i).baseName());
if(ui->cb_AtomFormula->count() != 0)
ui->cb_AtomFormula->setCurrentIndex(0);
}
示例7: removeOldFiles
void RollingFileAppender::removeOldFiles()
{
if (m_logFilesLimit <= 1)
return;
QFileInfo fileInfo(fileName());
QDir logDirectory(fileInfo.absoluteDir());
logDirectory.setFilter(QDir::Files);
logDirectory.setNameFilters(QStringList() << fileInfo.fileName() + "*");
QFileInfoList logFiles = logDirectory.entryInfoList();
QMap<QDateTime, QString> fileDates;
for (int i = 0; i < logFiles.length(); ++i)
{
QString name = logFiles[i].fileName();
QString suffix = name.mid(name.indexOf(fileInfo.fileName()) + fileInfo.fileName().length());
QDateTime fileDateTime = QDateTime::fromString(suffix, datePatternString());
if (fileDateTime.isValid())
fileDates.insert(fileDateTime, logFiles[i].absoluteFilePath());
}
QList<QString> fileDateNames = fileDates.values();
for (int i = 0; i < fileDateNames.length() - m_logFilesLimit + 1; ++i)
QFile::remove(fileDateNames[i]);
}
示例8: AddDirToPlaylist
void PlayerWidget::AddDirToPlaylist(){
QFileDialog dlg(0, Qt::Dialog | Qt::WindowStaysOnTopHint );
dlg.setFileMode(QFileDialog::Directory);
dlg.setOption(QFileDialog::ShowDirsOnly, true);
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.setWindowTitle(tr("Select Multimedia Directory"));
dlg.setWindowIcon( LXDG::findIcon("folder-open","") );
dlg.setDirectory(QDir::homePath()); //start in the home directory
//ensure it is centered on the current screen
QPoint center = QApplication::desktop()->screenGeometry(this).center();
dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) );
dlg.show();
while( dlg.isVisible() ){
QApplication::processEvents();
}
if(dlg.result() != QDialog::Accepted){ return; } //cancelled
QStringList sel = dlg.selectedFiles();
if(sel.isEmpty()){ return; } //cancelled
QString dirpath = sel.first(); //QFileDialog::getExistingDirectory(0, tr("Select a Multimedia Directory"), QDir::homePath() );
if(dirpath.isEmpty()){ return; } //cancelled
QDir dir(dirpath);
QFileInfoList files = dir.entryInfoList(LXDG::findAVFileExtensions(), QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
if(files.isEmpty()){ return; } //nothing in this directory
QList<QMediaContent> urls;
for(int i=0; i<files.length(); i++){
urls << QMediaContent(QUrl::fromLocalFile(files[i].absoluteFilePath()) );
}
PLAYLIST->addMedia(urls);
playlistChanged();
}
示例9: updateContents
void DesktopViewPlugin::updateContents(){
list->clear();
QDir dir(QDir::homePath()+"/Desktop");
QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Type | QDir::DirsFirst);
for(int i=0; i<files.length(); i++){
QListWidgetItem *it = new QListWidgetItem;
it->setWhatsThis(files[i].absoluteFilePath());
if(files[i].isDir()){
it->setIcon( LXDG::findIcon("folder","") );
it->setText( files[i].fileName() );
}else if(files[i].suffix() == "desktop" ){
bool ok = false;
XDGDesktop desk = LXDG::loadDesktopFile(files[i].absoluteFilePath(), ok);
if(ok){
it->setIcon( LXDG::findIcon(desk.icon,"") );
it->setText( desk.name );
}else{
//Revert back to a standard file handling
it->setIcon( LXDG::findMimeIcon(files[i].suffix()) );
it->setText( files[i].fileName() );
}
}else{
it->setIcon( LXDG::findMimeIcon(files[i].suffix()) );
it->setText( files[i].fileName() );
}
list->addItem(it);
}
}
示例10: updateMenu
void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){
menu->clear();
//re-create the menu (since it is hidden from view)
for(int i=0; i<files.length(); i++){
qDebug() << "New Menu Item:" << files[i].fileName();
if(trim){ totals.removeAll(files[i]); }
menu->addAction( newAction( files[i].canonicalFilePath(), files[i].fileName(), "") );
}
}
示例11: desktopChanged
void LDeskBarPlugin::desktopChanged(){
if(!desktopPath.isEmpty()){
QDir dir(desktopPath);
totals = dir.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
//Update all the special menus (trimming the totals list as we go)
updateMenu(dirM, dir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) );
updateMenu(audioM, dir.entryInfoList( audioFilter, QDir::Files, QDir::Name) );
updateMenu(videoM, dir.entryInfoList( videoFilter, QDir::Files, QDir::Name) );
updateMenu(pictureM, dir.entryInfoList( pictureFilter, QDir::Files, QDir::Name) );
//Now update the launchers
QFileInfoList exe = dir.entryInfoList( QStringList() << "*.desktop", QDir::Files, QDir::Name );
// - Get a complete list of apps (in alphabetical order)
QList<XDGDesktop> exeList;
for(int i=0; i<exe.length(); i++){
totals.removeAll(exe[i]); //Remove this item from the totals
bool ok = false;
XDGDesktop df = LXDG::loadDesktopFile(exe[i].canonicalFilePath(), ok);
if(ok){
if( LXDG::checkValidity(df) && !df.isHidden ){ exeList << df; }
}
}
exeList = LXDG::sortDesktopNames(exeList);
// - Now re-create the menu with the apps
appM->clear();
for(int i=0; i<exeList.length(); i++){
appM->addAction( newAction(exeList[i].filePath, exeList[i].name, LXDG::findIcon(exeList[i].icon, ":/images/default-application.png")) );
}
//Now update the other menu with everything else that is left
updateMenu(otherM, totals, false);
//Now update the file menu as appropriate
fileM->clear();
if(!audioM->isEmpty()){ fileM->addMenu(audioM); }
if(!pictureM->isEmpty()){ fileM->addMenu(pictureM); }
if(!videoM->isEmpty()){ fileM->addMenu(videoM); }
if(!otherM->isEmpty()){ fileM->addMenu(otherM); }
//Check for a single submenu, and skip the main if need be
if(fileM->actions().length()==1){
if(!audioM->isEmpty()){ fileB->setMenu(audioM); }
else if(!pictureM->isEmpty()){ fileB->setMenu(pictureM); }
else if(!videoM->isEmpty()){ fileB->setMenu(videoM); }
else if(!otherM->isEmpty()){ fileB->setMenu(otherM); }
}else{
fileB->setMenu(fileM);
}
}
//Setup the visibility of the buttons
appB->setVisible( !appM->isEmpty() );
dirB->setVisible( !dirM->isEmpty() );
fileB->setVisible( !fileM->isEmpty() );
//Clear the totals list (since no longer in use)
totals.clear();
}
示例12: deleteFolder
bool CloneThread::deleteFolder(const QString &folder)
{
QDir folderDir(folder);
if (!folderDir.exists())
{
return true;
}
QFileInfoList files = folderDir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
for (int i=0; i<files.length(); ++i)
{
QString filePath = files.at(i).absoluteFilePath();
if (files.at(i).isDir())
{
if (!deleteFolder(filePath))
{
return false;
}
}
else
{
qDebug() << "Deleting:" << filePath;
if (!QFile::remove(filePath))
{
mError = tr("Impossible to remove file: %1").arg(QDir::toNativeSeparators(filePath));
qCritical() << "Error:" << mError;
return false;
}
}
}
qDebug() << "Deleting folder:" << folder;
if (!QDir().rmdir(folder))
{
mError = tr("Impossible to remove folder: %1").arg(QDir::toNativeSeparators(folder));
qCritical() << "Error:" << mError;
return false;
}
return !mTerminated;
}
示例13: ExternalDevicePaths
// ==== ExternalDevicePaths() ====
QStringList LOS::ExternalDevicePaths(){
//Returns: QStringList[<type>::::<filesystem>::::<path>]
//Note: <type> = [USB, HDRIVE, DVD, SDCARD, UNKNOWN]
QStringList devs = LUtils::getCmdOutput("mount");
//Now check the output
for(int i=0; i<devs.length(); i++){
if(devs[i].startsWith("/dev/")){
devs[i].replace("\t"," ");
QString type = devs[i].section(" on ",0,0);
type.remove("/dev/");
//Determine the type of hardware device based on the dev node
if(type.startsWith("da")){ type = "USB"; }
else if(type.startsWith("ada")){ type = "HDRIVE"; }
else if(type.startsWith("mmsd")){ type = "SDCARD"; }
else if(type.startsWith("cd")||type.startsWith("acd")){ type="DVD"; }
else{ type = "UNKNOWN"; }
//Now put the device in the proper output format
devs[i] = type+"::::"+devs[i].section("(",1,1).section(",",0,0)+"::::"+devs[i].section(" on ",1,50).section("(",0,0).simplified();
}else{
//invalid device - remove it from the list
devs.removeAt(i);
i--;
}
}
//Also add info about anything in the "/media" directory
QDir media("/media");
QFileInfoList list = media.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Type | QDir::Name);
//qDebug() << "Media files found:" << list.length();
for(int i=0; i<list.length(); i++){
//qDebug() << "Found media entry:" << list[i].fileName();
if(list[i].isDir()){
devs << "UNKNOWN::::::::/media/"+list[i].fileName();
}else if(list[i].fileName().endsWith(".desktop")){
QString type = list[i].fileName().section(".desktop",0,-2);
//Determine the type of hardware device based on the dev node
if(type.startsWith("da")){ type = "USB"; }
else if(type.startsWith("ada")){ type = "HDRIVE"; }
else if(type.startsWith("mmsd")){ type = "SDCARD"; }
else if(type.startsWith("cd")||type.startsWith("acd")){ type="DVD"; }
else{ type = "UNKNOWN"; }
devs << type+"::::::::/media/"+list[i].fileName();
}
}
return devs;
}
示例14: watcherDirChange
// ===============
// PRIVATE SLOTS
// ===============
void TrayUI::watcherDirChange(){
bool check = false;
if(lastDirCheck.isNull()){
//First time this has had a ping - always run it once
check = true;
}else{
//Check that it is a relevant flag that was updated
QDir procdir(UPDATE_PROC_DIR);
QFileInfoList flags = procdir.entryInfoList(QStringList() << UPDATE_PROC_FLAG_FILE_FILTER, QDir::Files, QDir::Time);
for(int i=0; i<flags.length(); i++){
if(lastDirCheck < flags[i].lastModified()){
check=true;
break;
}
}
}
if(check){ QTimer::singleShot(0,this, SLOT(checkForUpdates()) ); }
lastDirCheck = QDateTime::currentDateTime();
}
示例15: checkSystem
void SysStatus::checkSystem(bool checkjails){
complete = QFile::exists("/tmp/.rebootRequired");
if(!complete){
//Get all the possible flag files and only take the most recent (latest flag - they overwrite each other)
QStringList upinfo = pcbsd::Utils::runShellCommand("syscache needsreboot isupdating");
if(upinfo.length() < 2 || upinfo.join("").contains("[ERROR]") ){
//Fallback method in case syscache is not working for some reason
QDir procdir(UPDATE_PROC_DIR);
QFileInfoList files = procdir.entryInfoList(QStringList() << UPDATE_PROC_FLAG_FILE_FILTER, QDir::Files, QDir::Time);
QStringList tmp; for(int i=0; i<files.length(); i++){ tmp << files[i].absoluteFilePath(); }
QString flag;
if(!files.isEmpty()){ flag = pcbsd::Utils::readTextFile(files.first().absoluteFilePath()).simplified().toLower(); }
//qDebug() << "No syscache running - use flags:" << tmp << flag;
complete = (UPDATE_PROC_FINISHED == flag );
updating = (UPDATE_PROC_WORKING == flag );
}else{
//Use the syscache info
complete = (upinfo[0]=="true");
updating = (upinfo[1]=="true");
}
if(!updating && !complete){
//Run syscache to probe for updates that are available
QString cmd = "syscache hasmajorupdates hassecurityupdates haspcbsdupdates \"pkg #system hasupdates\" \"jail list\"";
QStringList info = pcbsd::Utils::runShellCommand(cmd);
if(info.length() < 5){ return; } //no info from syscache
sys = (info[0] == "true");
sec = (info[1] == "true") || (info[2] == "true"); //combine security updates with pcbsd patches for notifications
pkg = (info[3] == "true");
//Now look for jail updates
if(checkjails && !info[4].simplified().isEmpty() ){
QStringList jls = info[4].split(", ");
cmd = "syscache";
for(int i=0; i<jls.length(); i++){
cmd.append(" \"pkg "+jls[i]+" hasupdates\"");
}
QStringList jinfo = pcbsd::Utils::runShellCommand(cmd);
jail = jinfo.contains("true");
}
}
}
}