当前位置: 首页>>代码示例>>C++>>正文


C++ QFileInfo::created方法代码示例

本文整理汇总了C++中QFileInfo::created方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo::created方法的具体用法?C++ QFileInfo::created怎么用?C++ QFileInfo::created使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFileInfo的用法示例。


在下文中一共展示了QFileInfo::created方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createFromFile

void Note::createFromFile( QFile &file ) {
    if ( file.open( QIODevice::ReadOnly ) )
    {
        QTextStream in( &file );
        in.setCodec("UTF-8");

        // qDebug() << file.size() << in.readAll();
        QString noteText = in.readAll();
        file.close();

        QFileInfo fileInfo;
        fileInfo.setFile( file );

        // create a nicer name by removing ".txt"
        // TODO: make sure name is ownNote conform
        QString name = fileInfo.fileName();
        name.chop( 4 );

        this->name = name;
        this->fileName = fileInfo.fileName();
        this->noteText = noteText;
        this->fileCreated = fileInfo.created();
        this->fileLastModified = fileInfo.lastModified();
        this->store();
    }

}
开发者ID:Amadeus666,项目名称:QOwnNotes,代码行数:27,代码来源:note.cpp

示例2: promptUser

static KUrl promptUser (QWidget *parent, const KUrl& url, const QString& suggestedName)
{
    KUrl destUrl;
    int result = KIO::R_OVERWRITE;
    const QString fileName ((suggestedName.isEmpty() ? url.fileName() : suggestedName));

    do {
        // convert filename to URL using fromPath to avoid trouble with ':' in filenames (#184202)
        destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent);

        if (destUrl.isLocalFile()) {
            QFileInfo finfo (destUrl.toLocalFile());
            if (finfo.exists()) {
                QDateTime now = QDateTime::currentDateTime();
                KIO::RenameDialog dlg (parent, i18n("Overwrite File?"), url, destUrl,
                                       KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP),
                                       -1, finfo.size(),
                                       now.toTime_t(), finfo.created().toTime_t(),
                                       now.toTime_t(), finfo.lastModified().toTime_t());
                result = dlg.exec();
            }
        }
    } while (result == KIO::R_CANCEL && destUrl.isValid());

    return destUrl;
}
开发者ID:vasi,项目名称:kdelibs,代码行数:26,代码来源:kwebpage.cpp

示例3: convertDateString

QString DkUtils::convertDateString(const QString& date, const QFileInfo& file) {

	// convert date
	QString dateConverted;
	QStringList dateSplit = date.split(QRegExp("[/: \t]"));

	if (dateSplit.size() >= 3) {

		QDate dateV = QDate(dateSplit[0].toInt(), dateSplit[1].toInt(), dateSplit[2].toInt());
		dateConverted = dateV.toString(Qt::SystemLocaleShortDate);

		if (dateSplit.size() >= 6) {
			QTime time = QTime(dateSplit[3].toInt(), dateSplit[4].toInt(), dateSplit[5].toInt());
			dateConverted += " " + time.toString(Qt::SystemLocaleShortDate);
		}
	}
	else if (file.exists()) {
		QDateTime dateCreated = file.created();
		dateConverted += dateCreated.toString(Qt::SystemLocaleShortDate);
	}
	else
		dateConverted = "unknown date";

	return dateConverted;
}
开发者ID:SamKeightley,项目名称:nomacs,代码行数:25,代码来源:DkUtils.cpp

示例4: createFromFile

void Note::createFromFile(QFile &file) {
    if (file.open(QIODevice::ReadOnly)) {
        QTextStream in(&file);
        in.setCodec("UTF-8");

        // qDebug() << file.size() << in.readAll();
        QString noteText = in.readAll();
        file.close();

        QFileInfo fileInfo;
        fileInfo.setFile(file);

        // create a nicer name by removing the extension
        // TODO(pbek): make sure name is ownCloud Notes conform
        QString name = fileInfo.fileName();

        int lastPoint = name.lastIndexOf(".");
        name = name.left(lastPoint);

        this->name = name;
        this->fileName = fileInfo.fileName();
        this->noteText = noteText;
        this->fileCreated = fileInfo.created();
        this->fileLastModified = fileInfo.lastModified();
        this->store();
    }
}
开发者ID:guija,项目名称:QOwnNotes,代码行数:27,代码来源:note.cpp

示例5: addFileNode

  tlp::node addFileNode(const QFileInfo &infos, tlp::Graph *g) {
    tlp::node n = g->addNode();
    _absolutePaths->setNodeValue(n,tlp::QStringToTlpString(infos.absoluteFilePath()));
    _baseNames->setNodeValue(n,tlp::QStringToTlpString(infos.baseName()));
    _createdDates->setNodeValue(n,tlp::QStringToTlpString(infos.created().toString()));
    _fileNames->setNodeValue(n,tlp::QStringToTlpString(infos.fileName()));
    _isDir->setNodeValue(n,infos.isDir());
    _isExecutable->setNodeValue(n,infos.isExecutable());
    _isReadable->setNodeValue(n,infos.isReadable());
    _isSymlink->setNodeValue(n,infos.isSymLink());
    _isWritable->setNodeValue(n,infos.isWritable());
    _lastModifiedDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastModified().toString()));
    _lastReadDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastRead().toString()));
    _owners->setNodeValue(n,tlp::QStringToTlpString(infos.owner()));
    _permissions->setNodeValue(n,(int)(infos.permissions()));
    _suffixes->setNodeValue(n,tlp::QStringToTlpString(infos.suffix()));
    _sizes->setNodeValue(n,infos.size());

    if (_useIcons) {
      std::string extension = infos.suffix().toStdString();

      if (infos.isDir()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FolderO);
        tlp::ColorProperty *viewColor = graph->getProperty<tlp::ColorProperty>("viewColor");
        viewColor->setNodeValue(n, dirColor);
      }
      else if (std::find(commonTextFilesExt.begin(), commonTextFilesExt.end(), extension) != commonTextFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileTextO);
      }
      else if (std::find(commonArchiveFilesExt.begin(), commonArchiveFilesExt.end(), extension) != commonArchiveFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileArchiveO);
      }
      else if (std::find(commonAudioFilesExt.begin(), commonAudioFilesExt.end(), extension) != commonAudioFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileAudioO);
      }
      else if (std::find(commonImageFilesExt.begin(), commonImageFilesExt.end(), extension) != commonImageFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileImageO);
      }
      else if (std::find(commonVideoFilesExt.begin(), commonVideoFilesExt.end(), extension) != commonVideoFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileVideoO);
      }
      else if (std::find(commonDevFilesExt.begin(), commonDevFilesExt.end(), extension) != commonDevFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileCodeO);
      }
      else if (extension == "pdf") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePdfO);
      }
      else if (extension == "doc" || extension == "docx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileWordO);
      }
      else if (extension == "xls" || extension == "xlsx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileExcelO);
      }
      else if (extension == "ppt" || extension == "pptx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePowerpointO);
      }
    }

    return n;
  }
开发者ID:mneumann,项目名称:tulip,代码行数:60,代码来源:FileSystem.cpp

示例6: fillList

void AdminDatabase::fillList()
{
	m_listView->clear();
	const QFileInfoList *files = m_dumpDir->entryInfoList("*.sql");
	
	if ( files )
	{
		QFileInfoListIterator it( *files );
		QFileInfo * fi = 0;
		while( (fi=it.current()) != 0 )
		{
			++it;
			KListViewItem *item = new KListViewItem(m_listView);
			
			item->setText(0, fi->baseName().section('.', 0,0) );
			
			QFile tmp(fi->absFilePath());
			tmp.open(IO_ReadOnly);
			QTextStream stream( &tmp );
			item->setText(1, stream.readLine().section("--",1,1));
			tmp.close();
			item->setText(2, fi->created().toString(Qt::ISODate));
		}
		
	}
}
开发者ID:BackupTheBerlios,项目名称:kludoteca-svn,代码行数:26,代码来源:admindatabase.cpp

示例7: ListFilesInDirectoryTest

QMultiMap<QString,FileAttributes> ListFilesInDirectoryTest(QDir dir, bool Hash)
{
    extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
    qt_ntfs_permission_lookup++; // turn checking on
    QMultiMap<QString, FileAttributes> fileAttHashTable; //making hash table to store file attributes
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Name);
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i)
    {
       QFileInfo fileInfo = list.at(i);
       if (fileInfo.isFile())
       {
           FileAttributes tempFileAttributes;
           QDateTime date = fileInfo.lastModified();
           QString lastModified = date.toString();

            tempFileAttributes.absoluteFilePath = fileInfo.absoluteFilePath();
            tempFileAttributes.fileName = fileInfo.fileName();
            tempFileAttributes.filePath= fileInfo.path();
            if (Hash) tempFileAttributes.md5Hash = GetFileMd5hash(fileInfo.absoluteFilePath());
            tempFileAttributes.lastModified  = fileInfo.lastModified();
            tempFileAttributes.lastRead = fileInfo.lastRead();
            tempFileAttributes.created = fileInfo.created();
            tempFileAttributes.isHidden =  fileInfo.isHidden();
            tempFileAttributes.size = fileInfo.size();
            tempFileAttributes.owner = fileInfo.owner();
            fileAttHashTable.insert(fileInfo.absoluteFilePath(),tempFileAttributes);
       }

    }
return fileAttHashTable;
}
开发者ID:szkrawcz,项目名称:aInf,代码行数:33,代码来源:dirgrinder.cpp

示例8: info

QDateTime
Wallpaper::fileTimeStamp (
        const QString &filePath)
{
    QFileInfo info (filePath);
    
    return info.created ();
}
开发者ID:deztructor,项目名称:meegotouch-controlpanelapplets,代码行数:8,代码来源:wallpaperutils_stub.cpp

示例9: DelSDPicFile

void XMLMoveThread::DelSDPicFile()
{
    //qDebug()<<tr("删除图片开始");
    QDir dir;
    if(!dir.exists("/SDHC"))
    {
        LogMsg("lane", tr("未检测到SD卡,不执行SD卡文件清理操作"));
        //qDebug()<<tr("未检测到SD卡,不执行SD卡文件清理操作");
        return;
    }
    QString dirName = "/SDHC/PicFile";
    if(!dir.exists(dirName))
    {
        LogMsg("lane", tr("SD中不存在图片备份,不执行SD卡文件清理操作"));
        //qDebug()<<tr("SD中不存在图片备份,不执行SD卡文件清理操作");
        return;
    }
    QDate curDate = QDateTime::currentDateTime().addDays(-getLaneInfo()->getPicSaveDay()).date();
    QString tmpFileName = curDate.toString("MMdd");
    dir.setPath(dirName);
    QFileInfoList dirList = dir.entryInfoList(QDir::Dirs,QDir::Time);
    QFileInfo dirInfo;
    int count = dirList.count();
    for(int i = count - 1;i > 0;i--)
    {
        //qDebug()<<tr("SD卡图片文件夹数量:%1").arg(count);
        //保留一个文件夹
        //        if(count <= 3)
        //        {
        //            qDebug()<<tr("保留一个文件夹");
        //            return;
        //        }
        dirInfo = dirList.at(i);
        if(!dirInfo.fileName().startsWith(".") && dirInfo.created().date() <= curDate)
            //if(dirInfo.fileName() == tmpFileName)
        {
            tmpFileName = dirInfo.fileName();
            //qDebug()<<tr("确定要删除文件目录:%1").arg(tmpFileName);
            dir.setPath(dirName + "/" + tmpFileName);
            QFileInfoList fileList = dir.entryInfoList(QDir::Files,QDir::Time);
            for(int i = 0;i < fileList.count();i++)
            {
                if(!dir.exists("/SDHC"))
                {
                    LogMsg("lane", tr("文件清理过程中检测不到SD卡"));
                    //qDebug()<<tr("文件清理过程中检测不到SD卡");
                    return;
                }
                QFile::remove(fileList.at(i).filePath());
            }
            dir.rmdir(dirInfo.filePath());
            //count --;
        }
    }
}
开发者ID:eilin1208,项目名称:QT_Test,代码行数:55,代码来源:xmlmovethread.cpp

示例10: expire

/*!
    Cleans the cache so that its size is under the maximum cache size.
    Returns the current size of the cache.

    When the current size of the cache is greater than the maximumCacheSize()
    older cache files are removed until the total size is less then 90% of
    maximumCacheSize() starting with the oldest ones first using the file
    creation date to determine how old a cache file is.

    Subclasses can reimplement this function to change the order that cache
    files are removed taking into account information in the application
    knows about that QNetworkDiskCache does not, for example the number of times
    a cache is accessed.

    Note: cacheSize() calls expire if the current cache size is unknown.

    \sa maximumCacheSize(), fileMetaData()
 */
qint64 QNetworkDiskCache::expire()
{
    Q_D(QNetworkDiskCache);
    if (d->currentCacheSize >= 0 && d->currentCacheSize < maximumCacheSize())
        return d->currentCacheSize;

    if (cacheDirectory().isEmpty()) {
        qWarning() << "QNetworkDiskCache::expire() The cache directory is not set";
        return 0;
    }

    // close file handle to prevent "in use" error when QFile::remove() is called
    d->lastItem.reset();

    QDir::Filters filters = QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot;
    QDirIterator it(cacheDirectory(), filters, QDirIterator::Subdirectories);

    QMultiMap<QDateTime, QString> cacheItems;
    qint64 totalSize = 0;
    while (it.hasNext()) {
        QString path = it.next();
        QFileInfo info = it.fileInfo();
        QString fileName = info.fileName();
        if (fileName.endsWith(CACHE_POSTFIX)) {
            cacheItems.insert(info.created(), path);
            totalSize += info.size();
        }
    }

    int removedFiles = 0;
    qint64 goal = (maximumCacheSize() * 9) / 10;
    QMultiMap<QDateTime, QString>::const_iterator i = cacheItems.constBegin();
    while (i != cacheItems.constEnd()) {
        if (totalSize < goal)
            break;
        QString name = i.value();
        QFile file(name);
        qint64 size = file.size();
        file.remove();
        totalSize -= size;
        ++removedFiles;
        ++i;
    }
#if defined(QNETWORKDISKCACHE_DEBUG)
    if (removedFiles > 0) {
        qDebug() << "QNetworkDiskCache::expire()"
                << "Removed:" << removedFiles
                << "Kept:" << cacheItems.count() - removedFiles;
    }
#endif
    return totalSize;
}
开发者ID:FlavioFalcao,项目名称:qt5,代码行数:70,代码来源:qnetworkdiskcache.cpp

示例11: loadExtensions

/*!
    \internal
    Loads the information from /etc/mime.types from all installpaths, and the root directory
*/
void QMimeType::loadExtensions()
{
    QStringList paths;
    paths << QLatin1String("/") << Qtopia::installPaths();
    const int CheckIntervalSeconds = 60 * 10;

    const QString etcMimeTypesConst = QLatin1String("etc/mime.types");

    QFileInfo fi;
    foreach(QString path, paths)
    {
        QString file = QDir::cleanPath(path+etcMimeTypesConst);
        if(!loadedTimes()->contains(path) || loadedTimes()->value(path).secsTo(QDateTime::currentDateTime()) > CheckIntervalSeconds)
        {
            fi.setFile(file);
            if(fi.exists() && fi.created() > loadedTimes()->value(path))
            {
                loadExtensions(file);
                loadedTimes()->insert(path, fi.created());
            }
        }
    }
开发者ID:Camelek,项目名称:qtmoko,代码行数:26,代码来源:qmimetype.cpp

示例12: info

TEST(codegen, DISABLED_reference)
{
  soft::Reference reference;
  QFileInfo info ("/tmp/thermo-edited.dat");
  reference.uri = "file://" + info.absoluteFilePath().toStdString();
  reference.created = info.created().toString("dd-mm-yyyy").toStdString();
  reference.owner = info.owner().toStdString();
  reference.lastModified = info.lastModified().toString("dd-mm-yyyy").toStdString();
  reference.sha1 = toStdBlob(sha1(info.absoluteFilePath()));

  soft::Storage storage("mongo2", "mongodb://localhost", "db=codegentest;coll=reference");
  storage.save(&reference);
}
开发者ID:NanoSim,项目名称:Porto,代码行数:13,代码来源:codegen-test.cpp

示例13: getPreviousFile

QFileInfo ImageFrame::getPreviousFile(QString file){
  int increment = 0;
  ProcessControl * pc = imageDisplay->getProcess();
  QFileInfo fi = QFileInfo(file);
  if(pc){
    increment = pc->getOptions()->output_period;
  }else{
    if(suggestedIncrement.contains(fi.path())){
      // There is already an increment for this directory, use that
      increment = suggestedIncrement.value(fi.path());
    }else{
      increment = discoverIncrement(fi);
      suggestedIncrement.insert(fi.path(),increment);
    }
  }  
  file = OutputWatcher::incrementFilename(file,-increment);
  QFileInfo ret = QFileInfo(file);
  if(ret.exists() && ret.created() <= fi.created()){
    return ret;
  }
  return QFileInfo();
}
开发者ID:FXIhub,项目名称:hawk,代码行数:22,代码来源:imageframe.cpp

示例14: getDate

QDateTime VideoItem::getDate()
{
    QDateTime result;

    result = _videoData->pictureDate();
    if (!result.isValid()) {
        QFileInfo info;

        info.setFile(_fileName);

        result = info.created();
    }

    return result;
}
开发者ID:cachirulop,项目名称:PhotoViewer,代码行数:15,代码来源:videoitem.cpp

示例15: addFileToZip

bool QMinizip::addFileToZip(QString filepath, QString newname)
{
    QFile file = { filepath };

    if (!file.exists())
        return false;

    if (!file.open(QIODevice::ReadOnly))
        return false;

    QFileInfo fileInfo = QFileInfo(file);

    QByteArray data = file.readAll();
    QDateTime created = fileInfo.created();

    return addDataToZip(&data, newname, created);
}
开发者ID:Manromen,项目名称:QMinizip,代码行数:17,代码来源:QMinizip.cpp


注:本文中的QFileInfo::created方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。