示例#1
0
void AutogenStep::run(QFutureInterface<bool> &interface)
{
    AutotoolsBuildConfiguration *bc = autotoolsBuildConfiguration();

    // Check whether we need to run autogen.sh
    const QFileInfo configureInfo(bc->buildDirectory() + QLatin1String("/configure"));
    const QFileInfo configureAcInfo(bc->buildDirectory() + QLatin1String("/configure.ac"));
    const QFileInfo makefileAmInfo(bc->buildDirectory() + QLatin1String("/Makefile.am"));

    if (!configureInfo.exists()
        || configureInfo.lastModified() < configureAcInfo.lastModified()
        || configureInfo.lastModified() < makefileAmInfo.lastModified()) {
        m_runAutogen = true;
    }

    if (!m_runAutogen) {
        emit addOutput(tr("Configuration unchanged, skipping autogen step."), BuildStep::MessageOutput);
        interface.reportResult(true);
        return;
    }

    m_runAutogen = false;
    AbstractProcessStep::run(interface);
}
QString ExampleAppPluginActivator::GetQtHelpCollectionFile() const
{
  if (!helpCollectionFile.isEmpty())
  {
    return helpCollectionFile;
  }

  QString collectionFilename = "ExampleAppQtHelpCollection.qhc";

  QFileInfo collectionFileInfo = context->getDataFile(collectionFilename);
  QFileInfo pluginFileInfo = QFileInfo(QUrl(context->getPlugin()->getLocation()).toLocalFile());
  if (!collectionFileInfo.exists() ||
      pluginFileInfo.lastModified() > collectionFileInfo.lastModified())
  {
    // extract the qhc file from the plug-in
    QByteArray content = context->getPlugin()->getResource(collectionFilename);
    if (content.isEmpty())
    {
      BERRY_WARN << "Could not get plug-in resource: " << collectionFilename.toStdString();
    }
    else
    {
      QFile file(collectionFileInfo.absoluteFilePath());
      file.open(QIODevice::WriteOnly);
      file.write(content);
      file.close();
    }
  }

  if (QFile::exists(collectionFileInfo.absoluteFilePath()))
  {
    helpCollectionFile = collectionFileInfo.absoluteFilePath();
  }

  return helpCollectionFile;
}
示例#3
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
//    QDir * _dir=new QDir();
//   // _dir->mkdir("tmp//audio");
//    _dir->mkpath("tmp/audio");

  /**/
    QDir directory(this->getPath());
    qDebug()<<"getIOSFilePath,m    :"<<this->getPath();
    QFileInfoList fileInfoList;
    if (this->hiddenFiles)
    {
        fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
    }
    else
    {
        fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
    }
    QFileInfo fileInfo;
    File file;
    QList<File> *fileList = new QList<File>;
    QFileIconProvider *provider = new QFileIconProvider;
    while (!fileInfoList.isEmpty())
    {
        if (this->procesEvents)
            qApp->processEvents();
        fileInfo = fileInfoList.takeFirst();

        file.fileIcon = provider->icon(fileInfo);
        file.fileName = fileInfo.fileName();
        qDebug()<<"IOSFileName:"<<file.fileName;
        file.fileSize = QString::number(fileInfo.size());
        file.fileDate = fileInfo.lastModified().toString("MMM dd yyyy");
        file.filePath = fileInfo.absoluteFilePath();
        file.filePermissions = "";
        file.fileOwner = fileInfo.owner();
        if (fileInfo.isDir())
            file.fileType = "dir";
        else
            file.fileType = "file";

        fileList->append(file);
    }
    delete provider;
    return fileList;
    return a.exec();
}
示例#4
0
TEST(codegen, DISABLED_collectionWithFileAndReference)
{
  soft::File file;
  soft::Reference reference;

  QFileInfo info ("/tmp/thermo-edited.dat");
  QFile data(info.absoluteFilePath());
  if (!data.open(QIODevice::ReadOnly)) {
    FAIL();
  }
  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()));

  file.filename = info.fileName().toStdString();
  file.suffix = info.suffix().toStdString();
  file.size = info.size();
  auto buffer = data.readAll();
  file.data = toStdBlob(buffer);
  data.close();

  soft::Collection collection;
  collection.setName("thermo");
  collection.setVersion("1.0");
  collection.attachEntity("file1", &file);
  collection.attachEntity("ref", &reference);
  collection.connect("file1", "has-info", "ref");

  soft::Storage storage("mongo2", "mongodb://localhost", "db=codegentest;coll=collectiontest3");
  storage.save(&collection);

  soft::Collection copyCollection(collection.id());
  soft::Reference refCopy;
  copyCollection.attachEntity("myref", &refCopy);
  storage.load(&copyCollection);
  std::string name, version, ns, id;
  copyCollection.findEntity("ref", name, version, ns, id);
  soft::Reference refCopy2(id);
  storage.load(&refCopy2);
  ASSERT_EQ(refCopy.sha1, reference.sha1);
  ASSERT_EQ(refCopy2.sha1, reference.sha1);
  ASSERT_EQ(refCopy.uri, reference.uri);
  ASSERT_EQ(refCopy2.uri, reference.uri);
  ASSERT_EQ(refCopy.created, reference.created);
  ASSERT_EQ(refCopy2.created, reference.created);
}
示例#5
0
/**
 * fast hash created from canonical path of file,
 * stringified timestamp, and stringified size of file.
 */
std::string
FileAnnouncer::fileStatHash(const QFileInfo& fileInfo)
{
  QString str;
  irg::SHA1Hash hash;

  hash.init();
  str = fileInfo.absoluteFilePath();
  hash.update((const unsigned char*)qPrintable(str), str.length());
  str = fileInfo.lastModified().toString("yy.MMM.dd-hh:mm:ss.zzz");
  hash.update((const unsigned char*)qPrintable(str), str.length());
  str.setNum(fileInfo.size());
  hash.update((const unsigned char*)qPrintable(str), str.length());

  return hash.hexString(hash.final());
}
示例#6
0
bool ImgDirSink::fileHandler(const QFileInfo &finfo)
{
	const QString fname = finfo.fileName();
	if (knownImageExtension(fname))
	{
		imgfiles.append(finfo.absoluteFilePath());
		timestamps.insert(finfo.absoluteFilePath(), FileStatus(finfo.lastModified()));
		return true;
	}
	if (fname.endsWith(".nfo", Qt::CaseInsensitive) || fname == "file_id.diz")
	{
		txtfiles.append(finfo.absoluteFilePath());
		return true;
	}
	otherfiles.append(finfo.absoluteFilePath());
	return false;
}
void OpenSavedGameDialog::updateTableWidget(const QString &subdir) {
    if (!savedir) {
        // cannot do anything
        return;
    }

    // go to the given subdirectory
    if (!savedir->cd(subdir)) {
        QMessageBox::critical(this, tr("Error"), tr("Unable to load the save-files!"));
        return;
    }

    // clear our table and current save game
    ui->tableWidget->clearContents();
    m_saveDirectory = QString("");
    m_saveName = QString("");

    // get all the files in the subdirectory and cd back out
    QFileInfoList list = savedir->entryInfoList(QDir::AllDirs, QDir::Time);
    int row = 0;
    for (QFileInfoList::iterator it = list.begin(); it != list.end(); ++it) {
        // grab everything after the first dash
        QFileInfo file = (*it);
        QString name = file.baseName().section("-", 1);

        // we don't care about empty folders or the quick/auto-save folders
        if (name.isEmpty() || name == strQuickSave || name == strAutoSave) {
            continue;
        }

        // add the option to the table
        ui->tableWidget->insertRow(row);
        ui->tableWidget->setItem(row, 0, new QTableWidgetItem(name));
        ui->tableWidget->setItem(row, 1, new QTableWidgetItem(file.lastModified().toString()));
        ui->tableWidget->setItem(row, 2, new QTableWidgetItem(file.canonicalFilePath()));

        // go to the next row
        ++row;
    }

    // show the table if we have any rows
    ui->tableWidget->setEnabled((row > 0));

    // jump back up
    savedir->cdUp();
}
示例#8
0
void VBoxVMLogViewer::save()
{
    /* Prepare "save as" dialog */
    QFileInfo fileInfo (mLogFiles.at(mLogList->currentIndex()).first);
    QDateTime dtInfo = fileInfo.lastModified();
    QString dtString = dtInfo.toString ("yyyy-MM-dd-hh-mm-ss");
    QString defaultFileName = QString ("%1-%2.log")
        .arg (mMachine.GetName()).arg (dtString);
    QString defaultFullName = QDir::toNativeSeparators (
        QDir::home().absolutePath() + "/" + defaultFileName);
    QString newFileName = QFileDialog::getSaveFileName (this,
        tr ("Save VirtualBox Log As"), defaultFullName);

    /* Copy log into the file */
    if (!newFileName.isEmpty())
        QFile::copy(mMachine.QueryLogFilename(mLogList->currentIndex()), newFileName);
}
示例#9
0
void Desk::arrangeBy (int type)
   {
   myPtrList<File> todo;
   int order, steps = 0;

   // fill in the date & field
   File *f;

   /* FIXME: this sorts by the position of the top left of the object, which is
      not the same as the top left of the image */
   foreach (f, _files)
      {
      QFileInfo fi (f->pathname ());

      f->setTime (fi.lastModified ());
      todo.append (f);
      }
示例#10
0
void SpaceChecker::deleteOldFiles()
{
//  QDir videoDir("/sdcard/DCIM/DashCam/Video");
  QDir videoDir;//("/Users/ratmandu/Pictures");
  videoDir.setPath("/Users/ratmandu");
  if (videoDir.count() > 1) {
    // delete oldest file
    videoDir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    videoDir.setSorting(QDir::Time | QDir::Reversed);

    QFileInfoList list = videoDir.entryInfoList();
    for (int i = 0; i < list.size(); i++) {
      QFileInfo fileinfo = list.at(i);
      qDebug() << fileinfo.absoluteFilePath() << fileinfo.size() << fileinfo.lastModified();
    }
  }
}
void LoacalFileServer::display(QString* currentPath)
{
	//QString currentPath = root;
	this->setWindowTitle("LocalFileServer : "+(*currentPath));
	QDir rootDir(*currentPath);
	QList<QTreeWidgetItem *> itemList;
	QStringList tmplist;
	tmplist << "*";
	QFileInfoList list = rootDir.entryInfoList(tmplist);

	for(unsigned int i = 0;i<list.count();i++)
	{
		QFileInfo tmpFileInfo = list.at(i);

		QTreeWidgetItem *item = new QTreeWidgetItem;
		
		if(tmpFileInfo.fileName() == "." || tmpFileInfo.fileName() == "..")
				continue;

		item->setText(0,tmpFileInfo.fileName());
		
		if(tmpFileInfo.isDir())
		{
			item->setText(1,QString(""));
		}
		else
		{
			item->setText(1,QString::number(tmpFileInfo.size()));
		}
		
		item->setText(2,tmpFileInfo.created().toString("MMM dd yyyy"));
		
		item->setText(3,tmpFileInfo.lastModified().toString("MMM dd yyyy"));

		QPixmap pixmap(tmpFileInfo.isDir()?"./dir.png":"./file.png");
		item->setIcon(0,pixmap);
		
		itemList.push_back(item);

		//the path is whether the directory
		isDirectory[tmpFileInfo.fileName()] = tmpFileInfo.isDir();
	}

	fileWidget->addTopLevelItems(itemList);
}
示例#12
0
void commutil::autoload(QString db_type, QString data_dir, QString subdir){
    QDir dir(Config::single()->mp[data_dir]);
    dir.setFilter(QDir::Dirs);
    QFileInfoList list = dir.entryInfoList();
    int total = list.count();
    QDateTime lastdate;
    QFile f(Config::single()->mp[data_dir] +  "/modify.txt");
    if(!f.open(QIODevice::ReadOnly)){
        QLOG_ERROR() << "open:" << Config::single()->mp[data_dir] + "/modify.txt" << " error";
        return;
    }

    QDataStream stream(&f);
    stream >> lastdate;
    f.close();
    //prepare database
    for(int i = 0; i < total; ++i){
      QFileInfo it = list.at(i);
      auto filename = it.fileName();
      if(filename == "." || filename == ".."){
          continue;
      }
      auto date = it.lastModified();
      //may debug
      if(date > lastdate){
        auto patient_name = ImageMatrix::get_patientname((Config::single()->mp[data_dir] + "/" + filename + "/" + Config::single()->mp[subdir]).toStdString());
        //bug in dcmtk lib
        int bug_pos = patient_name.find(":bah:");
        if(bug_pos != -1){
            patient_name = patient_name.substr(0,bug_pos);
        }
        auto patient_id = ImageMatrix::get_patientid((Config::single()->mp[data_dir] + "/" + filename + "/" + Config::single()->mp[subdir]).toStdString());
        DataCon::getinstance(db_type.toStdString()) -> add(patient_id.c_str(), patient_name.c_str(),date.toString(), date.toString());
      }
    }
    //update check time
    lastdate = QDateTime::currentDateTime();
    if(!f.open(QIODevice::WriteOnly)){
        QLOG_ERROR() << "open:" << Config::single()->mp[data_dir] + "/modify.txt" << " error";
        return;
    }
    stream.setDevice(&f);
    stream << lastdate;
    f.close();
}
示例#13
0
QDateTime ItemScanner::creationDateFromFilesystem(const QFileInfo& info)
{
    // creation date is not what it seems on Unix
    QDateTime ctime = info.created();
    QDateTime mtime = info.lastModified();

    if (ctime.isNull())
    {
        return mtime;
    }

    if (mtime.isNull())
    {
        return ctime;
    }

    return qMin(ctime, mtime);
}
示例#14
0
void ListFilesInDirectory(QDir dir, bool Hash)
{
       dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
       dir.setSorting(QDir::Size | QDir::Reversed);
       QFileInfoList list = dir.entryInfoList();
       for (int i = 0; i < list.size(); ++i)
       {
          QFileInfo fileInfo = list.at(i);
          if (fileInfo.isFile())
          {
              QDateTime date = fileInfo.lastModified();
              QString lastModified = date.toString();
              std::cout << qPrintable(QString("%1 lastModified=%2 ").arg(fileInfo.absoluteFilePath()).arg(lastModified)) << std::endl;
              if (Hash) GetFileMd5hash(fileInfo.absoluteFilePath());
          }

       }
}
void FlashcardsDeck::saveResources (QString deckFileName, bool verbose)
{
	if (resourceAbsoluteToDeckPathMap.empty()) return;
	verify (!(mediaDirectoryName.isEmpty() || mediaDirectoryName.isNull()), "Media directory not specified or empty.");

	QDir createMediaIn = QFileInfo (deckFileName).dir();
	verify (createMediaIn.exists(), "Failed to access parent directory of '" + deckFileName + "'.");

	verify (createMediaIn.mkpath (mediaDirectoryName), "Failed to create media subdirectory '" + mediaDirectoryName + "' for deck file '" + deckFileName +"'.");

	for (std::pair <QString, QString> absoluteToRelative : resourceAbsoluteToDeckPathMap.toStdMap())
	{
		QString destination = createMediaIn.absolutePath() + "/" + mediaDirectoryName + "/" + absoluteToRelative.second;

		QFileInfo sourceFile (absoluteToRelative.first), destinationFile (destination);
		if (destinationFile.exists() && sourceFile.lastModified() == destinationFile.lastModified() && sourceFile.size() == destinationFile.size())
		{
			if (verbose)
				qstderr << "File '" << absoluteToRelative.first << "' has same last accessed time as '" << destination << "': skipping." << endl;
			continue;
		}

		//bool copied = QFile::copy (absoluteToRelative.first, destination);

		// Copy preserving timestamps via 'cp'
		bool copied = false;

#ifdef  Q_OS_LINUX
		QProcess process;
		process.start ("cp", QStringList() << sourceFile.absoluteFilePath() << destinationFile.absoluteFilePath() << "--preserve=timestamps");
		verify (process.waitForFinished(), "Failed to wait for 'cp' to finish.");
		copied = process.exitCode() == 0;
#else
#error This platform is not supported. Add more cases or test if the existing code works.
#endif

		verify (copied, "Failed to copy '" + absoluteToRelative.first + "' to '" + destination + "'.");

		if (verbose)
			qstderr << "Copied resource '" + absoluteToRelative.first + "' to '" + destination + "'." << endl;
	}
	if (verbose)
		qstderr << resourceAbsoluteToDeckPathMap.size() << " resources saved." << endl;
}
示例#16
0
void QLocalFs::operationListChildren( QNetworkOperation *op )
{
#ifdef QLOCALFS_DEBUG
    qDebug( "QLocalFs: operationListChildren" );
#endif
    op->setState( StInProgress );

    dir = QDir( url()->path() );
    dir.setNameFilter( url()->nameFilter() );
    dir.setMatchAllDirs( TRUE );
    if ( !dir.isReadable() ) {
	QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
	op->setState( StFailed );
	op->setProtocolDetail( msg );
	op->setErrorCode( (int)ErrListChildren );
	emit finished( op );
	return;
    }

    const QFileInfoList *filist = dir.entryInfoList( QDir::All | QDir::Hidden | QDir::System );
    if ( !filist ) {
	QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
	op->setState( StFailed );
	op->setProtocolDetail( msg );
	op->setErrorCode( (int)ErrListChildren );
	emit finished( op );
	return;
    }

    emit start( op );

    QFileInfoListIterator it( *filist );
    QFileInfo *fi;
    QValueList<QUrlInfo> infos;
    while ( ( fi = it.current() ) != 0 ) {
	++it;
	infos << QUrlInfo( fi->fileName(), convertPermissions(fi), fi->owner(), fi->group(),
			   fi->size(), fi->lastModified(), fi->lastRead(), fi->isDir(), fi->isFile(),
			   fi->isSymLink(), fi->isWritable(), fi->isReadable(), fi->isExecutable() );
    }
    emit newChildren( infos, op );
    op->setState( StDone );
    emit finished( op );
}
示例#17
0
文件: textdoc.cpp 项目: AMDmi3/qucs
// ---------------------------------------------------
int TextDoc::save ()
{
  saveSettings ();

  QFile file (DocName);
  if (!file.open (QIODevice::WriteOnly))
    return -1;
  setLanguage (DocName);

  Q3TextStream stream (&file);
  stream << text ();
  setModified (false);
  slotSetChanged ();
  file.close ();

  QFileInfo Info (DocName);
  lastSaved = Info.lastModified ();
  return 0;
}
void CleanDialog::setFileList(const QString &workingDirectory, const QStringList &l)
{
    d->m_workingDirectory = workingDirectory;
    d->ui.groupBox->setTitle(tr("Repository: %1").
                             arg(QDir::toNativeSeparators(workingDirectory)));
    if (const int oldRowCount = d->m_filesModel->rowCount())
        d->m_filesModel->removeRows(0, oldRowCount);

    QStyle *style = QApplication::style();
    const QIcon folderIcon = style->standardIcon(QStyle::SP_DirIcon);
    const QIcon fileIcon = style->standardIcon(QStyle::SP_FileIcon);
    const QString diffSuffix = QLatin1String(".diff");
    const QString patchSuffix = QLatin1String(".patch");
    const QString proUserSuffix = QLatin1String(".pro.user");
    const QString qmlProUserSuffix = QLatin1String(".qmlproject.user");
    const QChar slash = QLatin1Char('/');
    // Do not initially check patches or 'pro.user' files for deletion.
    foreach(const QString &fileName, l) {
        const QFileInfo fi(workingDirectory + slash + fileName);
        const bool isDir = fi.isDir();
        QStandardItem *nameItem = new QStandardItem(QDir::toNativeSeparators(fileName));
        nameItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
        nameItem->setIcon(isDir ? folderIcon : fileIcon);
        const bool saveFile = !isDir && (fileName.endsWith(diffSuffix)
                                        || fileName.endsWith(patchSuffix)
                                        || fileName.endsWith(proUserSuffix)
                                        || fileName.endsWith(qmlProUserSuffix));
        nameItem->setCheckable(true);
        nameItem->setCheckState(saveFile ? Qt::Unchecked : Qt::Checked);
        nameItem->setData(QVariant(fi.absoluteFilePath()), fileNameRole);
        nameItem->setData(QVariant(isDir), isDirectoryRole);
        // Tooltip with size information
        if (fi.isFile()) {
            const QString lastModified = fi.lastModified().toString(Qt::DefaultLocaleShortDate);
            nameItem->setToolTip(tr("%1 bytes, last modified %2")
                                 .arg(fi.size()).arg(lastModified));
        }
        d->m_filesModel->appendRow(nameItem);
    }

    for (int c = 0; c < d->m_filesModel->columnCount(); c++)
        d->ui.filesTreeView->resizeColumnToContents(c);
}
示例#19
0
QVariant Drive::data(const QModelIndex &index, int role) const {
    QFileInfo file = results_.at(index.row());

    if (role == Qt::DisplayRole) {
        switch (index.column()) {
            case 0: return file.fileName();
                    break;
            case 1: return file.size();
                    break;
            case 2: return file.suffix();
                    break;
            case 3: return file.lastModified();
                    break;
        }
    } else {
        return QVariant();
    }
    return QVariant();
}
示例#20
0
void Q3LocalFs::operationListChildren( Q3NetworkOperation *op )
{
#ifdef QLOCALFS_DEBUG
    qDebug( "Q3LocalFs: operationListChildren" );
#endif
    op->setState( StInProgress );

    dir = QDir( url()->path() );
    dir.setNameFilter( url()->nameFilter() );
    dir.setMatchAllDirs( true );
    if ( !dir.isReadable() ) {
	QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
	op->setState( StFailed );
	op->setProtocolDetail( msg );
	op->setErrorCode( (int)ErrListChildren );
	emit finished( op );
	return;
    }

    QFileInfoList filist = dir.entryInfoList(QDir::All | QDir::Hidden | QDir::System);
    if ( filist.isEmpty() ) {
	QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
	op->setState( StFailed );
	op->setProtocolDetail( msg );
	op->setErrorCode( (int)ErrListChildren );
	emit finished( op );
	return;
    }

    emit start( op );

    Q3ValueList<QUrlInfo> infos;
    for (int i = 0; i < filist.size(); ++i) {
        QFileInfo fi = filist.at(i);
	infos << QUrlInfo( fi.fileName(), convertPermissions(&fi), fi.owner(), fi.group(),
			   fi.size(), fi.lastModified(), fi.lastRead(), fi.isDir(), fi.isFile(),
			   fi.isSymLink(), fi.isWritable(), fi.isReadable(), fi.isExecutable() );
    }
    emit newChildren( infos, op );
    op->setState( StDone );
    emit finished( op );
}
示例#21
0
void TeaLeafReader::parse(bool forceConfiguration)
{
    const QString cbpFile = findCbpFile(QDir(m_parameters.workDirectory.toString()));
    const QFileInfo cbpFileFi = cbpFile.isEmpty() ? QFileInfo() : QFileInfo(cbpFile);
    if (!cbpFileFi.exists() || forceConfiguration) {
        // Initial create:
        startCMake(toArguments(m_parameters.configuration, m_parameters.expander));
        return;
    }

    const bool mustUpdate = m_cmakeFiles.isEmpty()
            || anyOf(m_cmakeFiles, [&cbpFileFi](const FileName &f) {
                   return f.toFileInfo().lastModified() > cbpFileFi.lastModified();
               });
    if (mustUpdate) {
        startCMake(QStringList());
    } else {
        extractData();
        emit dataAvailable();
    }
}
void ImageSyncApp::extractFileNames( const QFileInfoList & allFiles, QTableWidget * filesView )
{
   filesView->setRowCount( allFiles.size() );
   filesView->setColumnCount( 2 );
   filesView->verticalHeader()->hide();
   QHeaderView * horizontalHeader = filesView->horizontalHeader();
   horizontalHeader->setResizeMode( 0, QHeaderView::Stretch );
   horizontalHeader->setResizeMode( 1, QHeaderView::Custom );
   QStringList headerLabels;
   headerLabels << "Name" << "Date";
   filesView->setHorizontalHeaderLabels( headerLabels );

   int rowCounter = 0;
   for( QFileInfoList::const_iterator it = allFiles.begin(); it != allFiles.end(); ++it ) {
      QFileInfo fileInfo = *it;
      filesView->setItem( rowCounter, 0, new QTableWidgetItem( fileInfo.fileName() ) );
      filesView->setItem( rowCounter, 1, new QTableWidgetItem( fileInfo.lastModified().toString() ) );
      filesView->resizeRowToContents( rowCounter );
      rowCounter++;
   }
}
示例#23
0
QList<File> *Computer::getFileList()
{
    QDir directory(this->getPath());
    QFileInfoList fileInfoList;
    if (this->hiddenFiles)
    {
        fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
    }
    else
    {
        fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
    }
    QFileInfo fileInfo;
    File file;
    QList<File> *fileList = new QList<File>;
    QFileIconProvider *provider = new QFileIconProvider;
    while (!fileInfoList.isEmpty())
    {
        if (this->procesEvents)
            qApp->processEvents();
        fileInfo = fileInfoList.takeFirst();

        file.fileIcon = provider->icon(fileInfo);
        file.fileName = fileInfo.fileName();
        file.fileSize = QString::number(fileInfo.size());
        file.fileDate = fileInfo.lastModified().toString("MMM dd yyyy");
        file.filePath = fileInfo.absoluteFilePath();
        file.filePermissions = "";
        file.fileOwner = fileInfo.owner();
        if (fileInfo.isDir())
            file.fileType = "dir";
        else
            file.fileType = "file";

        fileList->append(file);
    }
    delete provider;
    return fileList;
}
示例#24
0
void processModelFiles()
{
	QString workingModelDirPath = QString(workingAssetsDir) + "Models\\";
	QDir workingModelDir (workingModelDirPath);
	if(workingModelDir.exists())
	{
		QStringList modelFileFilters;
		modelFileFilters << "*.obj";

		workingModelDir.setFilter(QDir::Files | QDir::NoSymLinks);
		workingModelDir.setNameFilters(modelFileFilters);
		QFileInfoList workingModelFiles = workingModelDir.entryInfoList();
		for(int i = 0; i < workingModelFiles.size(); i++)
		{
			QFileInfo workingModelObj = workingModelFiles.at(i);
			QFileInfo workingModelBin (workingModelObj.path() + "\\" + workingModelObj.baseName() + ".bin");
			QFileInfo outModelBin (QString(outAssetsDir) + "Models\\" + workingModelBin.fileName());
			
			bool needsUpdate = (!workingModelBin.exists() || !outModelBin.exists() || (workingModelBin.lastModified() < workingModelObj.lastModified()));
			if(needsUpdate)
			{
				QString command("call \"" + QString(objToBinDir) + "ObjToBinaryWriter.exe\" ");
				command += "\"" + QDir::toNativeSeparators(workingModelObj.absoluteFilePath()) + "\" \"" + QDir::toNativeSeparators(workingModelBin.absoluteFilePath()) + "\"";
				int result = system(command.toLocal8Bit().constData());
				if(result != 0)
				{
					qDebug("ERROR CONVERTING MODEL OBJ, RESULT: " + result);
				}
				QString copyCommand("echo f|xcopy /y \"" + QDir::toNativeSeparators(workingModelBin.absoluteFilePath()) + "\" \"" + QString(outAssetsDir) + "Models\\" + workingModelBin.fileName() + "\"");
				int result2 = system(copyCommand.toLocal8Bit().constData());
			}

		}
	}
	else
	{
		qDebug("No working Model folder.");
	}
}
示例#25
0
////////////////////////////////////////////////////////////////////////////////
//
// GeneralTab
//
////////////////////////////////////////////////////////////////////////////////
GeneralTab::GeneralTab(const QFileInfo& fileInfo, QWidget* parent)
{
  auto fileNameLabel = new QLabel(tr("File Name:"));
  auto fileNameEdit  = new QLineEdit(fileInfo.fileName());

  auto pathLabel = new QLabel(tr("Path:"));
  auto pathValueLabel = new QLabel(fileInfo.absoluteFilePath());
  pathValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);

  auto sizeLabel = new QLabel(tr("Size:"));
  auto size = fileInfo.size() / 1024;
  auto sizeValueLabel = new QLabel(tr("%1 K").arg(size));
  sizeValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);

  auto lastReadLabel = new QLabel(tr("Last Read:"));
  auto lastReadValueLabel = new QLabel(fileInfo.lastRead().toString());
  lastReadValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);

  auto lastModLabel = new QLabel(tr("Last Modified:"));
  auto lastModValueLabel = new QLabel(fileInfo.lastModified().toString());
  lastModValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);

  auto layout = new QVBoxLayout;
  layout->addWidget(fileNameLabel);
  layout->addWidget(fileNameEdit);
  layout->addWidget(pathLabel);
  layout->addWidget(pathValueLabel);
  layout->addWidget(sizeLabel);
  layout->addWidget(sizeValueLabel);
  layout->addWidget(lastReadLabel);
  layout->addWidget(lastReadValueLabel);
  layout->addWidget(lastModLabel);
  layout->addWidget(lastModValueLabel);

  layout->addStretch(1);

  this->setLayout(layout);
}
示例#26
0
void
FileSystemItem::addChild(const boost::shared_ptr<SequenceParsing::SequenceFromFiles>& sequence,
              const QFileInfo& info)
{
    QMutexLocker l(&_imp->childrenMutex);
    ///Does the child exist already ?
    QString filename = sequence ? sequence->generateUserFriendlySequencePattern().c_str() : info.fileName();
    
    bool found = false;
    for (int j = 0; j < (int)_imp->children.size(); ++j) {
        if (_imp->children[j]->fileName() == filename) {
            found = true;
            break;
        }
    }
    
    if (!found) {
        
        bool isDir = sequence ? false : info.isDir();
        qint64 size;
        if (sequence) {
            size = sequence->getEstimatedTotalSize();
        } else {
            size = isDir ? 0 : info.size();
        }
        
        
        ///Create the child
        boost::shared_ptr<FileSystemItem> child( new FileSystemItem(isDir,
                                                                    filename,
                                                                    sequence,
                                                                    info.lastModified(),
                                                                    size,
                                                                    this) );
        _imp->children.push_back(child);
        
    }
}
示例#27
0
FileTreeItem::FileTreeItem(const QFileInfo & fileInfo,const FileTreeItem * parentItem,
                           bool scan_subdirs,bool encripted) {
    m_path = (parentItem->rootItem?"":parentItem->archivePath()) + fileInfo.fileName();
    if (fileInfo.isDir()) m_path += "/";
    m_perms = permissions(fileInfo);
    m_user = fileInfo.owner();
    m_group = fileInfo.group();
    m_link_to = fileInfo.symLinkTarget();
    m_file_size = fileInfo.size();
    m_date = fileInfo.lastModified();
    m_parentItem = (FileTreeItem *)parentItem;
    m_encripted = encripted;
    rootItem = false;
    if (is_dir()) {
        if (scan_subdirs) {
            QDirIterator di(fileInfo.filePath(),QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot);
            while (di.hasNext()) {
                di.next();
                appendChild(new FileTreeItem(QFileInfo(di.filePath()),this,true,encripted));
            }
        }
    }
}
void ViewTableListWidget::addViewName(QString str)
{
    qDebug()<<tr("信号发射成功")<<str;
    QDir rootdir("view//");
    rootdir.setFilter(rootdir.filter()|QDir::NoDotAndDotDot);
    QStringList strings;
    strings<<str;
     QFileInfo tempinfo = *(rootdir.entryInfoList(strings).begin());
     qDebug()<<tempinfo.absolutePath();
    this->insertRow(rowCount());
    int temprow = rowCount()-1;
    QTableWidgetItem * item = new QTableWidgetItem(QIcon("images/historicalcurve.jpg"),tempinfo.fileName());
    item->setToolTip(item->text());
    this->setItem(temprow,0,item);
    this->setItem(temprow,1,new QTableWidgetItem(tempinfo.suffix()));
    item = new QTableWidgetItem("0");
    item->setTextAlignment(Qt::AlignCenter);
    this->setItem(temprow,2,item);
    item = new QTableWidgetItem(tempinfo.lastModified().toString("yyyy-MM-dd hh:mm"));
    item->setTextAlignment(Qt::AlignCenter);
    this->setItem(temprow,3,item);
    modifyViewTable();
}
示例#29
0
static void addChildToItem(FileSystemItem* parent,const boost::shared_ptr<SequenceParsing::SequenceFromFiles>& sequence,
                           const QFileInfo& info)
{
    ///Does the child exist already ?
    QString filename = sequence ? sequence->generateUserFriendlySequencePattern().c_str() : info.fileName();
    
    bool found = false;
    for (int j = 0; j < parent->childCount(); ++j) {
        if (parent->childAt(j)->fileName() == filename) {
            found = true;
            break;
        }
    }
    
    if (!found) {
        
        bool isDir = sequence ? false : info.isDir();
        qint64 size;
        if (sequence) {
            size = sequence->getEstimatedTotalSize();
        } else {
            size = isDir ? 0 : info.size();
        }

        
        ///Create the child
        boost::shared_ptr<FileSystemItem> child( new FileSystemItem(isDir,
                                                                    filename,
                                                                    sequence,
                                                                    info.lastModified(),
                                                                    size,
                                                                    parent) );
        parent->addChild(child);
        
    }

}
示例#30
-1
void ConfigureStep::run(QFutureInterface<bool>& interface)
{
    BuildConfiguration *bc = buildConfiguration();

    //Check whether we need to run configure
    const QString projectDir(bc->target()->project()->projectDirectory().toString());
    const QFileInfo configureInfo(projectDir + QLatin1String("/configure"));
    const QFileInfo configStatusInfo(bc->buildDirectory().toString() + QLatin1String("/config.status"));

    if (!configStatusInfo.exists()
        || configStatusInfo.lastModified() < configureInfo.lastModified()) {
        m_runConfigure = true;
    }

    if (!m_runConfigure) {
        emit addOutput(tr("Configuration unchanged, skipping configure step."), BuildStep::MessageOutput);
        interface.reportResult(true);
        emit finished();
        return;
    }

    m_runConfigure = false;
    AbstractProcessStep::run(interface);
}