コード例 #1
0
ファイル: downloaditem.cpp プロジェクト: nsx0r/quiterss
void DownloadItem::finished()
{
    updateInfoTimer_.stop();

    QString host = downloadUrl_.host();
    QString fileSize = fileSizeToString(total_);

    if (fileSize == tr("Unknown size")) {
        fileSize = fileSizeToString(received_);
    }
    downloadInfo_->setText(QString("%1 - %2 - %3").arg(fileSize, host, QDateTime::currentDateTime().time().toString()));

    progressFrame_->hide();
    item_->setSizeHint(sizeHint());
    outputFile_.close();

    reply_->deleteLater();

    downloading_ = false;

    if (openAfterFinish_) {
        openFile();
    }

    emit downloadFinished(true);
}
コード例 #2
0
void CCopyMoveDialog::onProgressChanged(int totalPercentage, size_t numFilesProcessed, size_t totalNumFiles, int filePercentage, uint64_t speed)
{
	if (speed > 0)
		_speed = speed;
	ui->_overallProgress->setValue(totalPercentage);
	ui->_fileProgress->setValue(filePercentage);
	ui->_lblOperationName->setText(_labelTemplate.arg(fileSizeToString(_speed)));
	ui->_lblNumFiles->setText(QString("%1/%2").arg(numFilesProcessed).arg(totalNumFiles));
	setWindowTitle(_titleTemplate.arg(totalPercentage).arg(fileSizeToString(_speed)));
}
コード例 #3
0
void UpdateCenterImpl::downloadingUpdate(int updateIndex, int pogress, int totalProgress)
{
	lsvUpdates->topLevelItem(updateIndex)->setText(3, QString("%1%").arg(pogress));
	pgbUpdate->setValue(totalProgress);
	lblUpdateSate->setText(tr("<b>Update state:</b> Downloading %1")
							.arg(lsvUpdates->topLevelItem(updateIndex)->text(0)));
	lblDownloadedSize->setText(tr("%1 (%2)")
								.arg(fileSizeToString(updates->getCurrentDownloaded()))
								.arg(fileSizeToString(updates->getTotalToDownload())));
}
コード例 #4
0
ファイル: downloaditem.cpp プロジェクト: nsx0r/quiterss
void DownloadItem::updateInfo()
{
    int estimatedTime = ((total_ - received_) / 1024) / (curSpeed_ / 1024);
    QString speed = currentSpeedToString(curSpeed_);

    QTime time;
    time = time.addSecs(estimatedTime);
    QString remTime = remaingTimeToString(time);
    remTime_ = time;

    QString curSize = fileSizeToString(received_);
    QString fileSize = fileSizeToString(total_);

    if (fileSize == tr("Unknown size")) {
        downloadInfo_->setText(tr("%2 - unknown size (%3)").arg(curSize, speed));
    } else {
        downloadInfo_->setText(tr("Remaining %1 - %2 of %3 (%4)").arg(remTime, curSize, fileSize, speed));
    }
}
コード例 #5
0
/** Paint a cell of the ViewItem when in TVS_ERROR state
  *
  * \param painter The paint where we draw the item
  * \param cg The color group we can use to draw
  * \param column The index of the column to draw
  * \param width The width of the cell
  * \param align Not yet used
  *
  */
void RainbruRPG::Network::Ftp::TransferVisual::
drawError(QPainter * painter,const QColorGroup & cg, int column, 
	   int width, int align){

  if (isSelected()){
    painter->setPen(Qt::NoPen);
    painter->setBrush(cg.color(QPalette::Highlight));
    painter->drawRect(0, 0, width, height());
  }

  painter->setPen(Qt::red);
  QString s;
  switch(column){
  case 0:
    drawIpPort(painter, width, height());
    break;

  case 1:
    // Filename
    s=absoluteFilename;
    painter->drawText( 0, 0, width, height(), 
		       Qt::AlignLeft|Qt::AlignVCenter, s);
    break;

  case 2:
    // Green or Red arrow
    drawArrow(painter, width, height());
    break;


  case 3:
    // Download rate
    s="Finished";
    painter->drawText( 0, 0, width, height(), 
		       Qt::AlignCenter, s);
    break;
  case 4:
    // File size
    painter->drawText( 0, 0, width, height(), 
		       Qt::AlignRight|Qt::AlignVCenter, fileSizeToString());
    break;
  case 5:
    // Remaining time
    s="Finished";
    painter->drawText( 0, 0, width, height(), 
		       Qt::AlignCenter, s);
    break;

  default:
    s="Error";
    painter->drawText( 0, 0, width, height(), 
		       Qt::AlignLeft|Qt::AlignVCenter, s);
    break;
  }
}
コード例 #6
0
void CMainWindow::calculateOccupiedSpace()
{
	if (!_currentFileList)
		return;

	const FilesystemObjectsStatistics stats = _controller->calculateStatistics(_currentFileList->panelPosition(), _currentFileList->selectedItemsHashes());
	if (stats.empty())
		return;

	QMessageBox::information(this, tr("Occupied space"), tr("Statistics for the selected items(including subitems):\nFiles: %1\nFolders: %2\nOccupied space: %3").
							 arg(stats.files).arg(stats.folders).arg(fileSizeToString(stats.occupiedSpace)));
}
コード例 #7
0
	//--------------------------------------------------------------------------	
	bool BaseFileDialog::updateAlphabeticList()
	{
		if(!mTabAlphabeticList || mTab->getItemSelected() != mTabAlphabeticList)
			return false;

		// Setup columns
		if(mListFiles->getColumnCount() == 0)
		{
			int width = mListFiles->getWidth();
			MyGUI::LanguageManager& lang = MyGUI::LanguageManager::getInstance();
			mListFiles->addColumn(lang.replaceTags("#{FileName}"), 0);
			mListFiles->addColumn(lang.replaceTags("#{FilePath}"), 0);
			mListFiles->addColumn(lang.replaceTags("#{FileSize}"), 0);
			mListFiles->addColumn(lang.replaceTags("#{ArchiveType}"), 0);
			mListFiles->sortByColumn(0);
		}

		// Fill the list
		mListFiles->removeAllItems();

		// Add information about every file matching one of patterns 
		// corresponding the current filter.
		size_t filterIndex = mComboFilters->getIndexSelected();
		if(filterIndex != -1)
		{
			String fileSizeAsStr;
			const Filter& filter = getFilter(filterIndex);
			for(size_t i = 0; i != filter.getNumPatterns(); ++i)
			{
				const String& pattern = filter.getPattern(i);
				FileInfoListPtr pFileInfoList = ResourceGroupManager::getSingleton().findResourceFileInfo(mResourceGroup, pattern, false);
				const FileInfoList& fileInfoList = *pFileInfoList;
				for(size_t j = 0; j != fileInfoList.size(); ++j)
				{
					const FileInfo& fileInfo = fileInfoList[j];
					mListFiles->addItem(fileInfo.basename);
					fileSizeToString(fileInfo.uncompressedSize, &fileSizeAsStr);
					mListFiles->setSubItemNameAt(1, j, fileInfo.path);
					mListFiles->setSubItemNameAt(2, j, fileSizeAsStr);
					mListFiles->setSubItemNameAt(3, j, fileInfo.archive->getType());
				}
			}
		}
		
		return true;
	}
コード例 #8
0
void UpdateCenterImpl::fillUpdates()
{
	for (int n = 0; n < updates->getUpdatesCount(); n++)
	{
		QTreeWidgetItem *item = new QTreeWidgetItem(lsvUpdates);

		item->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
		item->setTextAlignment(2, Qt::AlignRight   | Qt::AlignVCenter);
		item->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);

		item->setText(0, updates->getUpdateItem(n)->getCaption());
		item->setText(1, updates->getUpdateItem(n)->getVersion());
		item->setText(2, fileSizeToString(updates->getUpdateItem(n)->getSize()));
		item->setText(3, "-");
		
		item->setSizeHint(0, QSize(18,18));
		
		item->setCheckState(0, Qt::Checked);
	}
}
コード例 #9
0
DISABLE_COMPILER_WARNINGS
#include <QDateTime>
#include <QInputDialog>
#include <QLineEdit>
RESTORE_COMPILER_WARNINGS

CPromptDialog::CPromptDialog(QWidget *parent, Operation op, HaltReason promptReason,
	const CFileSystemObject& source, const CFileSystemObject& dest, const QString& message) :

		QDialog(parent),
		ui(new Ui::CPromptDialog),
		_response(urNone)
{
	ui->setupUi(this);

	connect(ui->btnCancel,          &QPushButton::clicked, this, &CPromptDialog::onCancelClicked);
	connect(ui->btnCancelDeletion,  &QPushButton::clicked, this, &CPromptDialog::onCancelClicked);
	connect(ui->btnDeleteAnyway,    &QPushButton::clicked, this, &CPromptDialog::onProceedClicked);
	connect(ui->btnDeleteAllAnyway, &QPushButton::clicked, this, &CPromptDialog::onProceedAllClicked);
	connect(ui->btnOverwrite,       &QPushButton::clicked, this, &CPromptDialog::onProceedClicked);
	connect(ui->btnOverwriteAll,    &QPushButton::clicked, this, &CPromptDialog::onProceedAllClicked);
	connect(ui->btnRename,          &QPushButton::clicked, this, &CPromptDialog::onRenameClicked);
	connect(ui->btnSkip,            &QPushButton::clicked, this, &CPromptDialog::onSkipClicked);
	connect(ui->btnSkipAll,         &QPushButton::clicked, this, &CPromptDialog::onSkipAllClicked);
	connect(ui->btnSkipDeletion,    &QPushButton::clicked, this, &CPromptDialog::onSkipClicked);
	connect(ui->btnSkipAllDeletion, &QPushButton::clicked, this, &CPromptDialog::onSkipAllClicked);
	connect(ui->btnRetry,           &QPushButton::clicked, this, &CPromptDialog::onRetryClicked);

	switch (promptReason)
	{
	case hrFileExists:
		ui->lblQuestion->setText("File or folder already exists.");
		break;
	case hrSourceFileIsReadOnly:
		ui->btnOverwrite->setVisible(false);
		ui->btnOverwriteAll->setVisible(false);
		ui->btnRename->setVisible(false);
		ui->lblQuestion->setText("The source file or folder is read-only.");
		break;
	case hrDestFileIsReadOnly:
		ui->lblQuestion->setText("The destination file or folder is read-only.");
		break;
	case hrFailedToMakeItemWritable:
		ui->lblQuestion->setText("Failed to make the file or folder writable.");
		ui->btnOverwrite->setVisible(false);
		ui->btnOverwriteAll->setVisible(false);
		ui->btnRename->setVisible(false);
	case hrFileDoesntExit:
		ui->lblQuestion->setText("The file or folder doesn't exist.");
		ui->btnOverwrite->setVisible(false);
		ui->btnOverwriteAll->setVisible(false);
		ui->btnRename->setVisible(false);
		ui->btnDeleteAllAnyway->setVisible(false);
		ui->btnDeleteAnyway->setVisible(false);
		break;
	case hrCreatingFolderFailed:
		ui->lblQuestion->setText(tr("Failed to create the folder\n%1").arg(source.fullAbsolutePath()));
		ui->btnOverwrite->setVisible(false);
		ui->btnOverwriteAll->setVisible(false);
		ui->btnRename->setVisible(false);
		break;
	case hrFailedToDelete:
		ui->btnOverwrite->setVisible(false);
		ui->btnOverwriteAll->setVisible(false);
		ui->btnDeleteAnyway->setVisible(false);
		ui->btnDeleteAllAnyway->setVisible(false);
		ui->btnRename->setVisible(false);
		ui->lblQuestion->setText(tr("Failed to delete\n%1").arg(source.fullAbsolutePath()));
		break;
	case hrUnknownError:
		ui->lblQuestion->setText("An unknown error occurred. What do you want to do?");
		ui->btnOverwrite->setVisible(false);
		ui->btnOverwriteAll->setVisible(false);
		ui->btnRename->setVisible(false);
		break;
	default:
		ui->lblQuestion->setText("An unknown error occurred. What do you want to do?");
		break;
	}

	if (!message.isEmpty())
		ui->lblQuestion->setText(ui->lblQuestion->text() + "\n\n" + message);

	if (op == operationDelete || promptReason == hrSourceFileIsReadOnly || promptReason == hrFailedToMakeItemWritable)
	{
		ui->stackedWidget->setCurrentIndex(1);

		ui->m_lblItemBeingDeleted->setText(source.fullAbsolutePath());
		ui->lblSize->setText(fileSizeToString(source.size()));
		QDateTime modificationDate;
		modificationDate.setTime_t((uint)source.properties().modificationDate);
		modificationDate = modificationDate.toLocalTime();
		ui->lblModTime->setText(modificationDate.toString("dd.MM.yyyy hh:mm"));
	}
	else
	{
		ui->stackedWidget->setCurrentIndex(0);

		if (source.isValid())
		{
			ui->lblSrcFile->setText(source.fullAbsolutePath());
			ui->lblSourceSize->setText(fileSizeToString(source.size()));
			QDateTime modificationDate;
			modificationDate.setTime_t((uint)source.properties().modificationDate);
			modificationDate = modificationDate.toLocalTime();
			ui->lblSourceModTime->setText(modificationDate.toString("dd.MM.yyyy hh:mm"));
		}
		else
			WidgetUtils::setLayoutVisible(ui->sourceFileInfo, false);

		if (dest.isValid())
		{
			ui->lblDstFile->setText(dest.fullAbsolutePath());
			ui->lblDestSize->setText(fileSizeToString(dest.size()));
			QDateTime modificationDate;
			modificationDate.setTime_t((uint)dest.properties().modificationDate);
			modificationDate = modificationDate.toLocalTime();
			ui->lblDestModTime->setText(modificationDate.toString("dd.MM.yyyy hh:mm"));
		}
		else
			WidgetUtils::setLayoutVisible(ui->destFileInfo, false);
	}

	_srcFileName = source.fullName();
}
コード例 #10
0
QString CFileSystemObject::sizeString() const
{
	return _properties.type == File ? fileSizeToString(_properties.size) : QString();
}
コード例 #11
0
/** Adds a file to the tree widget
  *
  * \param fi A QFileInfo object pointing the file to add
  *
  */
void RainbruRPG::Gui::QuarantineList::addFile(QFileInfo fi){
  LOGI("Addfile called");
  QBrush red(QColor(250,0,0));
  QBrush orange(QColor(0, 0, 240));
  QBrush green(QColor(0,250,0));

  bool fileInTransfer;

  if (fi.isFile()){

    // Is this file is in storedFile list
    QRegExp rexp(fi.fileName());
    
    if (storedFiles.indexOf(rexp)==-1){
      LOGI("The file is NOT being stored");
      LOGCATS("filename=");
      LOGCATS(fi.fileName().toLatin1());
      LOGCAT();

      LOGCATS("storedFiles=");
      LOGCATS(storedFiles.join(";").toLatin1());
      LOGCAT();

      fileInTransfer=false;
    }
    else{
      LOGI("The file is being stored");
      fileInTransfer=true;
      labStillInTransfer->setVisible(true);

    }

    // adding it to the list
    QTreeWidgetItem *it= new QTreeWidgetItem(tree);
    it->setText(0,fi.fileName() );
    it->setText(1,fileSizeToString(fi.size()) );
   
    // Get the mime-type
    FileTypeGuesser ftg;
    std::string stdFn(fi.absoluteFilePath().toLatin1());
    std::string strMime=ftg.getMimeType(stdFn);
    it->setText(2,strMime.c_str() );

    tQuarantineFileStatus status=ftg.getFileStatus(stdFn);
    std::string strStatus;
    switch(status){
      case QFS_ACCEPTED:
	strStatus="Accepted";
	it->setForeground ( 0, green);
	it->setForeground ( 1, green);
	it->setForeground ( 2, green);
	it->setForeground ( 3, green);
	break;
      case QFS_REFUSED:
	strStatus="Refused";
	it->setForeground ( 0, red);
	it->setForeground ( 1, red);
	it->setForeground ( 2, red);
	it->setForeground ( 3, red);
	break;
      case QFS_UNKNOWN:
	strStatus="Unknown";
	it->setForeground ( 0, orange);
	it->setForeground ( 1, orange);
	it->setForeground ( 2, orange);
	it->setForeground ( 3, orange);
	break;
      case QFS_WRONGEXT:
	strStatus="Wrong extension";
	it->setForeground ( 0, orange);
	it->setForeground ( 1, orange);
	it->setForeground ( 2, orange);
	it->setForeground ( 3, orange);
	break;
      case QFS_TESTEDEXT:
	strStatus="Tested but unlisted extension";
	break;
    default:
	strStatus="ERROR";
	it->setForeground ( 0, red);
	it->setForeground ( 1, red);
	it->setForeground ( 2, red);
	it->setForeground ( 3, red);
    }

    it->setText(3,strStatus.c_str() );

    //    if (fileInTransfer){
    //      it->setText(3,"Still in transfer...");
    //    }

    tree->addTopLevelItem( it );
  }
}
コード例 #12
0
/** Paint a cell of the ViewItem when in TVS_INPROGRESS state
  *
  * \param painter The paint where we draw the item
  * \param cg The color group we can use to draw
  * \param column The index of the column to draw
  * \param width The width of the cell
  * \param align Not yet used
  *
  */
void RainbruRPG::Network::Ftp::TransferVisual::
drawInProgress(QPainter * painter,const QColorGroup & cg, int column, 
	   int width, int align){

  // controls
  if (ip.isEmpty()){
    LOGW("IP address is empty");
  }

  if (isSelected()){
    painter->setPen(Qt::NoPen);
    painter->setBrush(cg.color(QPalette::Highlight));
    painter->drawRect(0, 0, width, height());
  }

  QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height()));
  linearGrad.setColorAt(0,    QColor( 34,  80, 184));
  linearGrad.setColorAt(0.25, QColor(150, 189, 231));
  linearGrad.setColorAt(0.50, QColor( 88, 154, 227));
  linearGrad.setColorAt(0.75, QColor(150, 189, 231));
  linearGrad.setColorAt(1,    QColor(127, 205, 255));

  QLinearGradient linearGrad2(QPointF(0, 0), QPointF(0, height()));
  linearGrad2.setColorAt(0,    QColor(163, 163, 163));
  linearGrad2.setColorAt(0.25, QColor(231, 231, 231));
  linearGrad2.setColorAt(0.50, QColor(217, 217, 217));
  linearGrad2.setColorAt(0.75, QColor(244, 244, 244));
  linearGrad2.setColorAt(1,    QColor(248, 248, 248));

  QPen pen(Qt::gray, 1); 

  if (column==6){
    // Progress bar
    int totalW=width-4;
    int leftW=(int)(totalW*percent)/100;
    int rightW=totalW-leftW;

    // Drawing ProgressBar
    painter->setPen(Qt::NoPen);
    painter->setBrush(QBrush(linearGrad));
    painter->drawRect( 2, 2, leftW, height()-4 );
    painter->setBrush(QBrush(linearGrad2));
    painter->drawRect( leftW+2, 2, rightW, height()-4 );

    painter->setPen(pen);
    painter->setBrush(Qt::NoBrush);
    painter->drawRect(0, 0, width-1, height()-1);

    QFont f=painter->font();
    f.setPointSize(f.pointSize()-1);

    painter->setFont(f);
    painter->setPen(Qt::black);

    QString s=QString::number(percent, 'f', 2);
    s+=" %";
    painter->drawText( 0, 0, width, height(), Qt::AlignCenter, s );
  }
  else{

    painter->setPen(Qt::black);
    QString s;
    switch(column){
    case 0:
      drawIpPort(painter, width, height());
      break;
    case 1:
      // Filename
      s=absoluteFilename;
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignLeft|Qt::AlignVCenter, s);
      break;
    case 2:
      // Green or Red arrow
      drawArrow(painter, width, height());
      break;
    case 3:
      // Download rate
      s=QString::number(rate, 'f', 2);
      s+=" kB/s";
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignRight|Qt::AlignVCenter, s);
      break;
    case 4:
      // File size
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignRight|Qt::AlignVCenter, fileSizeToString());
      break;
    case 5:
      // Remaining time
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignRight|Qt::AlignVCenter, remainingTime);
      break;
   }
  }
}
コード例 #13
0
ファイル: ftptransfer.cpp プロジェクト: dreamsxin/rainbrurpg
/** Creates the \c ls command result 
  *
  * It creates it in the packetData string.
  *
  */
void RainbruRPG::Network::Ftp::FtpTransfer::lsResult(){
  LOGI("LIST command result :");
  packetData="";
  unsigned int childs=1;

  QDir dir(currentDirectory );
  dir.setFilter(QDir::Dirs| QDir::Files| QDir::NoSymLinks);
  dir.setSorting(QDir::Name);

  QFileInfoList list = dir.entryInfoList();

  LOGCATS("Sending ");
  LOGCATI(list.size());
  LOGCATS(" files.");
  LOGCAT();

  for (int i = 0; i < list.size(); ++i) {
    QFileInfo fileInfo = list.at(i);

    // ====== User permissions
    // Diretory ?
    if (fileInfo.isDir()){
      packetData+="d";

      QDir dir2(fileInfo.absoluteFilePath());
      childs=dir2.count();

    }
    else{
      packetData+="-";
      childs=1;
    }

    packetData+=filePermissions(fileInfo.isReadable(),fileInfo.isWritable(),
				fileInfo.isExecutable());

    packetData+=filePermissions(fileInfo.permission(QFile::ReadGroup),
				fileInfo.permission(QFile::WriteGroup),
				fileInfo.permission(QFile::ExeGroup));

    packetData+=filePermissions(fileInfo.permission(QFile::ReadOther),
				fileInfo.permission(QFile::WriteOther),
				fileInfo.permission(QFile::ExeOther));

    // Child number
    QString sChild;
    sChild.setNum(childs);
    sChild=sChild.rightJustified(5);
    packetData+=sChild;

    // Owner and group names
    packetData+=' ';
    QString sOwner=fileInfo.owner();
    sOwner=sOwner.leftJustified(9);
    packetData+=sOwner;
    QString sGroup=fileInfo.group();
    sGroup=sGroup.leftJustified(9);
    packetData+=sGroup;

    // File size
    qint64 size=fileInfo.size();

    QString sSize=fileSizeToString(size);
    sSize=sSize.rightJustified(8);
    packetData+=sSize;

    // Last modified time
    packetData+=" ";
    QDateTime dt=fileInfo.lastModified();
    packetData+=dt.toString("yyyy-MM-dd hh:mm");

    // File name and EOL
    packetData+=" ";
    packetData+=fileInfo.fileName();
    packetData+="\n";
  }
  LOGI("PacketData done. LIST result can be sent");
  int i=  packetData.size();
  LOGCATS("PacketData lenght :");
  LOGCATI(i);
  LOGCAT();
}