Пример #1
0
void CMainWindow::DeletePathFile(QString strFilePath)
{
    QString strPath = strFilePath;
    qDebug()<<strPath;
    QDir dir(strPath);
    if (!dir.exists())
        return ;
    dir.setFilter(QDir::Dirs|QDir::Files);
    dir.setSorting(QDir::DirsFirst);
    QFileInfoList list = dir.entryInfoList();
    int i=0;
    QString fileName;
    do{
        QFileInfo fileInfo = list.at(i);
        if((fileInfo.fileName()==".")|(fileInfo.fileName()==".."))
        {
            i++;
            continue;
        }
        bool bisDir=fileInfo.isDir();
        if(bisDir)
        {
            qDebug()<<(QString("%1 %2 %3").arg(fileInfo.size(), 10).arg(fileInfo.fileName(),10).arg(fileInfo.path()))<<fileInfo.absoluteFilePath();
            DeletePathFile(fileInfo.filePath());
            dir.rmdir(fileInfo.filePath());
        }else{
            fileName = fileInfo.fileName();
            dir.remove(fileInfo.fileName());
            qDebug()<<(QString("%1 %2 %3").arg(fileInfo.size(), 10).arg(fileInfo.fileName(),10).arg(fileInfo.path()))<<fileInfo.absoluteFilePath();
        }
        i++;
    }while(i<list.size());
}
Пример #2
0
			void ThirdStep::initializePage ()
			{
				TotalSize_ = 0;
				QString path = field ("RootPath").toString ();

				QFileInfo pathInfo (path);
				if (pathInfo.isDir ())
				{
					QDirIterator it (path,
							QDirIterator::Subdirectories);
					while (it.hasNext ())
					{
						it.next ();
						QFileInfo info = it.fileInfo ();
						if (info.isFile () && info.isReadable ())
							TotalSize_ += info.size ();
					}
				}
				else if (pathInfo.isFile () &&
						pathInfo.isReadable ())
					TotalSize_ += pathInfo.size ();

				quint64 max = std::log (static_cast<long double> (TotalSize_ / 102400)) * 80;

				quint32 pieceSize = 32 * 1024;
				int shouldIndex = 0;
				for (; TotalSize_ / pieceSize >= max; pieceSize *= 2, ++shouldIndex) ;

				if (shouldIndex > PieceSize_->count () - 1)
					shouldIndex = PieceSize_->count () - 1;

				PieceSize_->setCurrentIndex (shouldIndex);

				on_PieceSize__currentIndexChanged ();
			}
Пример #3
0
QString IconCache::getIconPath(const QString& site)
{

	QString cachedName = site;
	if (site.contains("http"))
		cachedName = QUrl(site).host();

	qDebug() << cachedName;

	//cachedName = cachedName.replace("http:", "").replace("https:", "").replace("/", "");
	QFileInfo info;
	info.setFile(cachePath, cachedName + ".png");

	if (info.exists())
		return info.size() > 0 ? info.absoluteFilePath() : QString();
	info.setFile(cachePath, cachedName + ".ico");
	if (info.exists())
		return info.size() > 0 ? info.absoluteFilePath() : QString();

	if (!site.startsWith("http"))
		return "";


	// Call the main thread to grab the icon in the background
	emit findIcon(QUrl("http://" + QUrl(site).host() + "/favicon.ico"));

	return "";
}
Пример #4
0
//-----------------------------------------------------------
void CrashHandler::carregarRelatorio(const QString &arquivo)
{
 ifstream entrada;
 QFileInfo fi;
 char *buf=NULL;
 CaixaMensagem caixa;

 //Abre o arquivo .crash
 fi.setFile(arquivo);
 entrada.open(arquivo);

 titulo_lbl->setText(trUtf8("pgModeler crash file analysis"));
 criar_btn->setVisible(false);
 msg_lbl->clear();

 //Caso o arquivo  não foi aberto com sucesso, exibe um erro
 if(!entrada.is_open())
  caixa.show(trUtf8("Error"), Excecao::obterMensagemErro(ERR_PARSERS_ARQDIRNAOCARREGADO).arg(arquivo), CaixaMensagem::ICONE_ERRO);
 else
 {
  QByteArray buf_descomp;
  QString buf_aux, str_aux;
  int i, idx;
  QTextEdit *txt_widgets[]={ acoes_txt, modelo_txt , stack_txt};

  //Exibe informações do arquivo
  msg_lbl->setText(trUtf8("File: %1\nSize: %2 bytes\n\n").arg(arquivo).arg(fi.size()));

  //Cria um buffer no tamanho total do arquivo
  buf=new char[fi.size()];
  //Le todos os bytes do arquivo
  entrada.read(buf, fi.size());
  entrada.close();

  //Descompacta o buffer lido
  buf_descomp.append(buf, fi.size());
  buf_descomp=qUncompress(buf_descomp);

  //Desaloca o buffer original
  delete[](buf);
  buf=NULL;

  //Obtém o buffer descompactado
  buf_aux=QString(buf_descomp.data());
  i=idx=0;

  //Varre todo o buffer separando jogando cada parte do buffer em sua respectiva seção
  while(i < buf_aux.size() && idx <= 2)
  {
   if(buf_aux.at(i).ascii()!=CHR_DELIMITADOR)
    str_aux.append(buf_aux.at(i));
   else
   {
    txt_widgets[idx++]->setPlainText(QString::fromUtf8(str_aux));
    str_aux.clear();
   }
   i++;
  }
 }
}
Пример #5
0
void CrashHandler::loadReport(const QString &filename)
{
	QFile input;
	QFileInfo fi;
	char *buf=nullptr;
	Messagebox msgbox;

	fi.setFile(filename);
	input.setFileName(filename);
	input.open(QFile::ReadOnly);

	title_lbl->setText(trUtf8("pgModeler crash file analysis"));
	create_btn->setVisible(false);
	msg_lbl->clear();

	//Raises an error if the file could not be opened
	if(!input.isOpen())
		msgbox.show(trUtf8("Error"), Exception::getErrorMessage(ERR_FILE_DIR_NOT_ACCESSED).arg(filename), Messagebox::ERROR_ICON);
	else
	{
		QByteArray uncomp_buf;
		QString buf_aux, str_aux;
		int i, idx;
		QTextEdit *txt_widgets[]={ actions_txt, model_txt , stack_txt};

		msg_lbl->setText(trUtf8("File: %1\nSize: %2 bytes\n\n").arg(filename).arg(fi.size()));

		//Creates a text buffer
		buf=new char[fi.size()];

		//Reads the file storing it on the buffer
		input.read(buf, fi.size());
		input.close();

		//Uncompress the buffer
		uncomp_buf.append(buf, fi.size());
		uncomp_buf=qUncompress(uncomp_buf);

		delete[](buf);
		buf=nullptr;

		buf_aux=QString(uncomp_buf.data());
		i=idx=0;

		//Showing the sections of the uncompressed buffer on the respective widgets
		while(i < buf_aux.size() && idx <= 2)
		{
			if(buf_aux.at(i).toLatin1()!=CHR_DELIMITER)
				str_aux.append(buf_aux.at(i));
			else
			{
				txt_widgets[idx++]->setPlainText(Utf8String::create(str_aux));
				str_aux.clear();
			}
			i++;
		}
	}
}
Пример #6
0
/*!
 \brief 先清理temp_project中的文件,然后将保存的文件保存在temp_project目录中,然后再将目标目录清理干净,最后将temp_project目录中的文件copy到目标目录中

 \fn CMainWindow::on_actionSave_triggered
*/
void CMainWindow::on_actionSave_triggered()
{
    emit signal_ClearDebug();
    emit signal_ShowMessageDebug(0,QString("开始保存... %1").arg(QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss.zzz")));
    ///< 清理掉temp_project目录中的文件
    QDir tempDir("temp_project");
    if (tempDir.exists())
    {
        qDebug()<<__func__<<__LINE__<<"有";
        DeletePathFile(QDir::currentPath()+"/temp_project");
    }else
    {
        qDebug()<<__func__<<__LINE__<<"无";
        tempDir.mkdir(QDir::currentPath()+"/temp_project");
    }
//    qDebug()<<__func__<<__LINE__<<__FILE__<<m_pTreeWidget->topLevelItemCount();

    ///< 生成配置文件,生成在temp目录中
    for (int nTreeItemCount = 0; nTreeItemCount < m_pTreeWidget->topLevelItemCount(); ++nTreeItemCount)
    {
        if (m_pTreeWidget->topLevelItem(nTreeItemCount)->type() == CGI_SCADA_DLL_I::TreeItemType_Undefined)
        {
            continue;
        }else
        {
            ((CGI_SCADA_DLL_I*)m_pTreeWidget->topLevelItem(nTreeItemCount))->SaveAction();
        }
    }

    DeletePathFile(m_strProjectPath);///< 清理掉目标目录中的文件

    /// 将temp_project目录中的文件复制到目标目录
    if (!tempDir.exists())
        return ;
    tempDir.setFilter(QDir::Dirs|QDir::Files);
    tempDir.setSorting(QDir::DirsFirst);
    QFileInfoList list = tempDir.entryInfoList();
    int i=0;
    do{
        QFileInfo fileInfo = list.at(i);
        if((fileInfo.fileName()==".")|(fileInfo.fileName()==".."))
        {
            i++;
            continue;
        }
        bool bisDir=fileInfo.isDir();
        if(bisDir)
        {
            qDebug()<<(QString("%1 %2 %3").arg(fileInfo.size(), 10).arg(fileInfo.fileName(),10).arg(fileInfo.path()))<<fileInfo.absoluteFilePath();
        }else{
            qDebug()<<(QString("%1 %2 %3").arg(fileInfo.size(), 10).arg(fileInfo.fileName(),10).arg(fileInfo.path()))<<fileInfo.absoluteFilePath()<<fileInfo.baseName();
            QFile::copy(fileInfo.absoluteFilePath(),QString("%1/%2").arg(m_strProjectPath).arg(fileInfo.fileName()));
        }
        i++;
    }while(i<list.size());
    emit signal_ShowMessageDebug(0,QString("保存完毕"));
}
Пример #7
0
int ModelRestorationForm::exec(void)
{
	QStringList file_list=this->getTemporaryModels(), tmp_info;
	QFileInfo info;
	QTableWidgetItem *item=nullptr;
	QFile input;
	QString buffer, filename;
	QRegExp regexp=QRegExp("(\\<database)( )+(name)(=)(\")");
	int start=-1, end=-1, col=0;


	while(!file_list.isEmpty())
	{
		info.setFile(GlobalAttributes::TEMPORARY_DIR, file_list.front());
		filename=GlobalAttributes::TEMPORARY_DIR + GlobalAttributes::DIR_SEPARATOR + file_list.front();

		input.setFileName(filename);
		input.open(QFile::ReadOnly);
		buffer.append(input.readAll());
		input.close();

		start=regexp.indexIn(buffer) + regexp.matchedLength();
		end=buffer.indexOf("\"", start);

		tmp_info.append(buffer.mid(start, end - start));
		tmp_info.append(info.fileName());
		tmp_info.append(info.lastModified().toString(QString("yyyy-MM-dd hh:mm:ss")));

		if(info.size() < 1024)
			tmp_info.append(QString("%1 bytes").arg(info.size()));
		else
			tmp_info.append(QString("%1 KB").arg(info.size()/1024));

		tmp_files_tbw->insertRow(tmp_files_tbw->rowCount());

		for(col=0; col < tmp_info.size(); col++)
		{
			item=new QTableWidgetItem;
			item->setText(tmp_info.at(col));
			item->setData(Qt::UserRole, filename);
			item->setSelected(true);
			tmp_files_tbw->setItem(tmp_files_tbw->rowCount()-1, col, item);
		}

		file_list.pop_front();
		buffer.clear();
		tmp_info.clear();
		start=end=-1;
	}

	tmp_files_tbw->resizeColumnsToContents();
	tmp_files_tbw->resizeRowsToContents();

	return(QDialog::exec());
}
Пример #8
0
void CStart::FindFile()
{
    qDebug()<<QDir::currentPath()+"../project";
    QString strPath = QDir::currentPath().remove("cgi-bin")+"project";
    qDebug()<<strPath;
    QDir dir(strPath);
    if (!dir.exists())
        return ;
    dir.setFilter(QDir::Dirs|QDir::Files);
    dir.setSorting(QDir::DirsFirst);
    QFileInfoList list = dir.entryInfoList();
    int i=0;
    QString fileName;
    do{
        QFileInfo fileInfo = list.at(i);
        if((fileInfo.fileName()==".")|(fileInfo.fileName()==".."))
        {
            i++;
            continue;
        }
        bool bisDir=fileInfo.isDir();
        if(bisDir)
        {
            qDebug()<<(QString("%1 %2 %3").arg(fileInfo.size(), 10).arg(fileInfo.fileName(),10).arg(fileInfo.path()))<<fileInfo.absoluteFilePath();
//            FindFile(fileInfo.filePath());
        }else{
            fileName = fileInfo.fileName();
            if (fileName.left(3) == "Com")
            {
                m_ComFileList.append(fileInfo.absoluteFilePath());
            }else if (fileName.left(3) == "Net")
            {
                m_NetFileList.append(fileInfo.absoluteFilePath());
            }else if (fileName.left(3) == "Can")
            {
                m_CANFileList.append(fileInfo.absoluteFilePath());
            }else if (fileName == "Information_.xml")
            {
                InitMonitorIP(fileInfo.absoluteFilePath());
            }
            qDebug()<<(QString("%1 %2 %3").arg(fileInfo.size(), 10).arg(fileInfo.fileName(),10).arg(fileInfo.path()))<<fileInfo.absoluteFilePath();
        }
        i++;
    }while(i<list.size());

    qDebug()<<"m_ComFileList"<<m_ComFileList;
    qDebug()<<"m_NetFileList"<<m_NetFileList;
    qDebug()<<"m_CANFileList"<<m_CANFileList;
}
Пример #9
0
bool ScImageCacheFile::update(const QFileInfo & info)
{
	bool changed = false;
	if (info.lastModified() != m_modified)
	{
		m_modified = info.lastModified();
		changed = true;
	}
	if (info.size() != m_size)
	{
		m_size = info.size();
		changed = true;
	}
	return changed;
}
Пример #10
0
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;
}
Пример #11
0
/** \fn     ImageUtils::LoadFileData(QFileInfo &, DataMap *)
 *  \brief  Loads the information from the fileInfo into the dataMap object
 *  \param  fileInfo Holds the information about the file
 *  \param  data Holds the loaded information about a file
 *  \return void
 */
void ImageUtils::LoadFileData(QFileInfo &fileInfo,
                              ImageMetadata *data)
{
    data->m_fileName	= fileInfo.absoluteFilePath();
    data->m_name        = fileInfo.fileName();
    data->m_path        = fileInfo.path();
    data->m_modTime     = fileInfo.lastModified().toTime_t();
    data->m_size        = fileInfo.size();
    data->m_isHidden    = fileInfo.isHidden();
    data->m_extension   = fileInfo.completeSuffix().toLower();

    // Set defaults, the data will be loaded later
    data->SetAngle(0);
    data->m_date = MAX_UTCTIME;

    if (m_imageFileExt.contains(data->m_extension))
    {
        data->m_type = kImageFile;
    }
    else if (m_videoFileExt.contains(data->m_extension))
    {
        data->m_type = kVideoFile;
    }
    else
    {
        data->m_type = kUnknown;
    }
}
Пример #12
0
QList<QStandardItem *> MainWindow::createrowinputtable(QFileInfo fileinfo)
{
    QList<QStandardItem *>listitems;
    qint64 fs;
    QString strfs;
    for(int col=0 ; col < inputmodel->columnCount() ; col++)
    {
        QStandardItem *item = new QStandardItem();
        switch(col)
        {
           case 0:item->setText(fileinfo.fileName());
                   // add logs,constellations,signals,prns
                  item->setFlags(item->flags() ^ Qt::ItemIsEditable);
                   addChildrentofile(item);
                   break;

          case 1:  fs = fileinfo.size();
                  strfs = convertintokbmbgb(fs);
                  item->setText(strfs);
                  item->setFlags(item->flags() ^ Qt::ItemIsEditable);
                  break;

          case 2: item->setFlags(item->flags() ^ Qt::ItemIsEditable); //initialize nof ascii logs
                  break;

          case 3:  item->setFlags(item->flags() ^ Qt::ItemIsEditable);// initialize no of binary logs
                    break;

          case 4: item->setFlags(item->flags() ^ Qt::ItemIsEditable);//initialize no of unkonwn logs
                  break;
        }
        listitems.append(item);
    }
    return listitems;
}
Пример #13
0
QVariant FileFilterModel::data(const QModelIndex &index, int role) const
{
    if(!index.isValid() || !this->_dir.isReadable())
        return QVariant();

    if(role == Qt::DisplayRole)
    {
        QFileInfo fi = this->_files[index.row()];

        switch(index.column())
        {
            case 0:
                return fi.fileName();

            case 1:
                return QString("%1KB").arg(static_cast<qreal>(fi.size()) / 1024.0);

            default:
                break;
        }
    }
    else if(role == Qt::DecorationRole && index.column() == 0)
        return this->_icofile;

    return QVariant();
}
Пример #14
0
  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;
  }
Пример #15
0
/* private slots */
qint64 ShredThread::getDirSize(QString &dir)
{
    uint _size = 0;
    QDir::Filters flags =
            QDir::AllEntries |
            QDir::NoDotAndDotDot |
            QDir::Hidden |
            QDir::System |
            QDir::AllDirs;
    QDir d;
    d.setPath(dir);
    QList<QFileInfo> entry = d.entryInfoList(flags);
    if ( !entry.isEmpty() ) {
        QList<QFileInfo>::const_iterator i;
        for ( i=entry.constBegin(); i<entry.constEnd(); i++ ) {
            QFileInfo item = *i;
            if ( !item.exists() ) continue;
            QString path = item.canonicalFilePath();
            if ( path==d.absoluteFilePath(dir)
                 || item.isSymLink() )
                continue;
            if ( item.isDir() ) {
                _size += getDirSize(path);
            } else {
                _size += item.size();
            };
        };
    };
    return _size;
}
Пример #16
0
TEST(codegen, DISABLED_file)
{
  soft::File file;
  QFileInfo info ("/tmp/thermo-edited.dat");
  QFile data(info.absoluteFilePath());
  if (!data.open(QIODevice::ReadOnly)) {
    FAIL();
  }
  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::Storage storage("mongo2", "mongodb://localhost", "db=codegentest;coll=filetest");
  storage.save(&file);

  soft::File filecopy(file.id());
  storage.load(&filecopy);

  ASSERT_TRUE(filecopy.filename == file.filename);
  ASSERT_TRUE(filecopy.suffix == file.suffix);
  QTextStream(stdout) << filecopy.data.size() << " -> " << file.data.size() << endl;
  ASSERT_TRUE(filecopy.data.size() == file.data.size());
  QFile dataCopy(info.absoluteFilePath() + ".copy");
  if (!dataCopy.open(QIODevice::WriteOnly |QIODevice::Truncate)) {
    FAIL();
  }

  dataCopy.write((const char*)filecopy.data.data(), (quint64)filecopy.data.size());
}
Пример #17
0
fileIsSameDialog::fileIsSameDialog(QWidget *parent,QFileInfo fileInfo,QString firstRenamingRule,QString otherRenamingRule) :
	QDialog(parent),
	ui(new Ui::fileIsSameDialog)
{
	ui->setupUi(this);
	action=FileExists_Cancel;
	oldName=fileInfo.fileName();
	destinationInfo=fileInfo;
	ui->lineEditNewName->setText(oldName);
	ui->lineEditNewName->setPlaceholderText(oldName);
	ui->label_content_size->setText(QString::number(fileInfo.size()));
	ui->label_content_modified->setText(fileInfo.lastModified().toString());
	ui->label_content_file_name->setText(fileInfo.fileName());
	updateRenameButton();
	QDateTime maxTime(QDate(ULTRACOPIER_PLUGIN_MINIMALYEAR,1,1));
	if(maxTime<fileInfo.lastModified())
	{
		ui->label_modified->setVisible(true);
		ui->label_content_modified->setVisible(true);
		ui->label_content_modified->setText(fileInfo.lastModified().toString());
	}
	else
	{
		ui->label_modified->setVisible(false);
		ui->label_content_modified->setVisible(false);
	}
	this->firstRenamingRule=firstRenamingRule;
	this->otherRenamingRule=otherRenamingRule;
}
Пример #18
0
/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;

    // Assume files are the same if path is the same
    if (d->fileEntry.filePath() == fileinfo.d_ptr->fileEntry.filePath())
        return true;

    Qt::CaseSensitivity sensitive;
    if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) {
        if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine
            return false;

        sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    } else {
        if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
            return false;
        sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    }

    if (fileinfo.size() != size()) //if the size isn't the same...
        return false;

   // Fallback to expensive canonical path computation
   return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
}
Пример #19
0
void FormRestauracaoModelo::exec(void)
{
 QStringList lista_arqs=this->obterModelosTemporarios();
 QFileInfo info;
 QListWidgetItem *item=NULL;

 //Caso haja arquivos na pasta tmp
 while(!lista_arqs.isEmpty())
 {
  //Obtém as informações do arquivo
  info.setFile(AtributosGlobais::DIR_TEMPORARIO, lista_arqs.front());

  //Cria um item da lista no formato [NOME] - [DATA CRIAÇÃO] - [TAMANHO]
  item=new QListWidgetItem;
  item->setText(info.fileName() +
                QString(" - ") +
                trUtf8("Modified: %1").arg(info.lastModified().toString(tr("yyyy-MM-dd hh:mm:ss"))) +
                QString(" - ") +
                QString("%1 bytes").arg(info.size()));
  //Armazena o caminho completo para o arquivo como dado o item
  item->setData(Qt::UserRole, QVariant::fromValue<QString>(AtributosGlobais::DIR_TEMPORARIO +
                                                           AtributosGlobais::SEP_DIRETORIO + lista_arqs.front()));
  arqs_tmps_lst->addItem(item);
  item->setSelected(true);
  lista_arqs.pop_front();
 }

 QDialog::exec();
}
Пример #20
0
void FileStorageWatcherThread::getCurrentCacheSize()
{
    mDebug() << "FileStorageWatcher: Creating cache size";
    quint64 dataSize = 0;
    QString basePath = m_dataDirectory + "/maps";
    QDirIterator it( basePath,
                     QDir::Files | QDir::Writable,
                     QDirIterator::Subdirectories );
    
    int basePathDepth = basePath.split("/").size();
    while( it.hasNext() && !m_willQuit ) {
        it.next();
        QFileInfo file = it.fileInfo();
        // We try to be very careful and just delete images
        // FIXME, when vectortiling I suppose also vector tiles will have
        // to be deleted
        QString suffix = file.suffix().toLower();
        QStringList path = file.path().split("/");

        // planet/theme/tilelevel should be deeper than 4
        if ( ( path.size() > basePathDepth + 3 ) &&
             ( path[basePathDepth + 2].toInt() >= maxBaseTileLevel ) &&
               ( ( suffix == "jpg"
                || suffix == "png"
                || suffix == "gif"
                || suffix == "svg" ) ) ) {
            dataSize += file.size();
            m_filesCache.insert(file.lastModified(), file.absoluteFilePath());
        }
    }
    m_currentCacheSize = dataSize;
}
Пример #21
0
void scanDirectory(FileInfoList &fileEntries, const QString &name, const QString &strDir)
{
   QDir dir(strDir);
   if (!dir.exists()) return;

   QFileInfoList *newEntries = (QFileInfoList *) dir.entryInfoList();

   if (!newEntries) return; // Directory not accessible ??

   for(QFileInfo *qFileInfo = newEntries->first();
       qFileInfo;
       qFileInfo = newEntries->next())
   {
       if (qFileInfo->isFile())
       {
          FileInfo *fileInfo = readEntry( strDir + "/" + qFileInfo->fileName());
          if (fileInfo)
          {
             fileInfo->name = name + "/" + qFileInfo->fileName();
             fileInfo->size = (qFileInfo->size() + 1023) / 1024;
             fileEntries.append(fileInfo);
          }
       }
   }
}
Пример #22
0
void ImageTab::RefreshContent()
{
    QWebSettings::clearMemoryCaches();

    const QString path = m_Resource.GetFullPath();

    const QFileInfo fileInfo = QFileInfo(path);
    m_RefreshedTimestamp = fileInfo.lastModified().toMSecsSinceEpoch();

    const double ffsize = fileInfo.size() / 1024.0;
    const QString fsize = QLocale().toString(ffsize, 'f', 2);

    const QImage img(path);
    const QUrl imgUrl = QUrl::fromLocalFile(path);

    QString colors_shades = img.isGrayscale() ? tr("shades") : tr ("colors");
    QString colorsInfo = ""; 
    if (img.depth() == 32) {
        colorsInfo = QString(" %1bpp").arg(img.bitPlaneCount());
    }
    else if (img.depth() > 0) {
        colorsInfo = QString(" %1bpp (%2 %3)").arg(img.bitPlaneCount()).arg(img.colorCount()).arg(colors_shades);
    }

    const QString html = IMAGE_HTML_BASE.arg(imgUrl.toString()).arg(img.width()).arg(img.height()).arg(fsize)
            .arg(img.isGrayscale() ? tr("Grayscale") : tr("Color")).arg(colorsInfo);
    m_WebView.setHtml(html, imgUrl);
}
Пример #23
0
MyFileSystemNodeItem::MyFileSystemNodeItem (const QFileInfo & info, QObject * parent)
    : QObject (parent)
    , m_size  (info.size ())
    , m_info  (info)
{
    MyFileSystemNodeItem::s_instances.insert (m_info.filePath (), this);
    if (m_info.isDir ()) {
        const QFileInfoList list (QDir (m_info.filePath ()).entryInfoList (filter, sort));
#ifdef USE_ITERATOR
        QListIterator<QFileInfo> it (list);
        while (it.hasNext ()) {
            m_size += (new MyFileSystemNodeItem (it.next (), this))->getSize ();
        }
#else
#   ifdef USE_FOREACH
        foreach (QFileInfo entry, list) {
            m_size += (new MyFileSystemNodeItem (entry, this))->getSize ();
        }

#   else
        const int nb = list.count ();
        for (int idx = 0; idx < nb; idx++) {
            m_size += (new MyFileSystemNodeItem (list.at (idx), this))->getSize ();
        }
#   endif
#endif
    }
}
Пример #24
0
void ModelRestorationForm::exec(void)
{
	QStringList file_list=this->getTemporaryModels();
	QFileInfo info;
	QListWidgetItem *item=NULL;

	while(!file_list.isEmpty())
	{
		info.setFile(GlobalAttributes::TEMPORARY_DIR, file_list.front());

		//Creates an item on the list in the format: [NAME] - [CREATION DATE] - [SIZE]
		item=new QListWidgetItem;
		item->setText(info.fileName() +
									QString(" - ") +
									trUtf8("Modified: %1").arg(info.lastModified().toString(tr("yyyy-MM-dd hh:mm:ss"))) +
									QString(" - ") +
									QString("%1 bytes").arg(info.size()));

		//Stores the path to the file
		item->setData(Qt::UserRole, QVariant::fromValue<QString>(GlobalAttributes::TEMPORARY_DIR +
																														 GlobalAttributes::DIR_SEPARATOR + file_list.front()));
		tmp_files_lst->addItem(item);
		item->setSelected(true);
		file_list.pop_front();
	}

	QDialog::exec();
}
Пример #25
0
void DataSelector::scanFolderForLogs(QString path) {
    QString filter = QString(("*" + LOG_EXTENSION).data());
    QDir dir(path, filter);
    QFileInfoList list = dir.entryInfoList();
    std::cout << "Found " << list.size() << " log files." << std::endl;

    if (list.size() == 0) {
        return;
    }

    logPathLabel->setText(path); // notify the user of the new log

    std::vector<std::string> files;
    for (int i = 0; i < list.size(); i++) {
        QFileInfo fileInfo = list.at(i);
        std::string path = fileInfo.absoluteFilePath().toStdString();

        if (fileInfo.size() != 0) {
            files.push_back(path);
        }
        else
        {
            std::cout << "Invalid log file: " << path << std::endl;
        }
    }

    emit signalNewDataSet(files);
}
Пример #26
0
/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;
    if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
        return false;
    if (fileinfo.size() == size()) { //if the size isn't the same...
        QString file1 = canonicalFilePath(),
                file2 = fileinfo.canonicalFilePath();
        if (file1.length() == file2.length()) {
            if (!fileinfo.d_ptr->fileEngine->caseSensitive()) {
                for (int i = 0; i < file1.length(); i++) {
                    if (file1.at(i).toLower() != file2.at(i).toLower())
                        return false;
                }
                return true;
            }
            return (file1 == file2);
        }
    }
    return false;
}
Пример #27
0
void ImageTab::ImageFileModified()
{
    const QFileInfo fileInfo = QFileInfo( m_Resource.GetFullPath() );

    const qint64 lastModified = fileInfo.lastModified().toMSecsSinceEpoch();
    if ( lastModified == m_RefreshedTimestamp )
    {
        return;
    }

    // It's best to wait a bit before triggering the actual page refresh,
    // in case the file has not been completely written to disk. The image tab will take
    // a bit to become up-to-date with the file on disk, but it's just an informational tab
    // and instant reaction to file changes is not critical.
    // - If the file is empty, then the file-modified signal was received
    //   exactly when the editor application truncated the file, but before
    //   writing any data to it, so we'll be extra patient.
    // - If the file is larger than 512k (unlikely for images in an ebook, but possible),
    //   it might get even larger than that, and the editor application
    //   might take a long time (ms-wise) to write it, so we'll be extra patient again.
    // The values below are mostly guesswork derived from how things go on my machine;
    // they may not work just as well on slower (disk/cpu) systems.

    const int delay = 500 + ( fileInfo.size() == 0 ? 750 : 0); // + ( fileInfo.size() > 512 * 1024 ? 500 : 0 );

    if ( QDateTime::currentMSecsSinceEpoch() - lastModified < delay )
    {
        QTimer::singleShot( delay, this, SLOT( ImageFileModified() ) );
    }
    else
    {
        QTimer::singleShot( 0, this, SLOT( RefreshContent() ) );
    }
}
Пример #28
0
QVariant ImageList::data(const QModelIndex &index, int role) const
{
    Image *img = at(index.row());
    QFileInfo fi = QFileInfo(img->getPath());

    if (role == Qt::DisplayRole) {
        switch (index.column()) {
        case 0:
            return fi.baseName();
        case 1:
            return fi.suffix().toLower();
        case 2:
            return QString("%1 kB").arg(fi.size() / 1024.0, 0, 'f', 2);
        case 3:
            if (img->isLoaded()) return img->getSourceMat().channels();
        case 4:
            if (img->isLoaded()) return img->getSourceMat().cols;
        case 5:
            if (img->isLoaded()) return img->getSourceMat().rows;
        }
    }
    else if (role ==Qt::TextAlignmentRole) {
        switch (index.column()) {
        case 4:
            return Qt::AlignRight;
        default:
            return Qt::AlignLeft;
        }
    }

    return QVariant();
}
Пример #29
0
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;
}
Пример #30
0
QString FtpFileSystem::listDir(){
    QString fullPath = appendPath(mBaseDir, mCurDir);
    QDir dir(fullPath);
    if (!(dir.exists()))
        return NULL;

    dir.setSorting(QDir::Size | QDir::Reversed);
    QString buffer;
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i) {
        QFileInfo fileInfo = list.at(i);
        if (fileInfo.fileName()=="." || fileInfo.fileName() == "..")
            continue;
         QString dirLabel = fileInfo.isDir()?"d":"-";
         bool writable = isWritable(fileInfo.fileName());
         bool readable =  isReadable(fileInfo.fileName());
         QString sfileSize = fileInfo.isDir()?"512":QString::number(fileInfo.size());
         QDateTime dt = fileInfo.lastModified();
         QString lastModified = formatDate(dt);
//         qDebug() << fileInfo.fileName();
         buffer = buffer % QString("%1%5%6-r--r-- 1 root root %2 %3 %4\r\n").arg(dirLabel).arg(sfileSize).arg(lastModified).arg(fileInfo.fileName())
                .arg(readable?"r":"-").arg(writable?"w":"-");
    }
    return buffer;
}