void MangaDownloadWidget::startNextDownload(void) {
  if (_downloadQueue.isEmpty()) {
    QString downloadReport = QString::number(_downloadedCount)+"/"+QString::number(_totalCount)+" chapter(s) downloaded successfully.";
    if (_downloadedCount == _totalCount) {
      _messageModel->editMessageSuccess(downloadReport);
    } else {
      _messageModel->editMessageWarning("Only "+downloadReport);
      _messageModel->editMessageWarning("Please check out each issue and retry if necessary.");
    }

    updateChaptersList();

    _totalCount = 0;
    _downloadedCount = 0;

    _selectLineEdit->setEnabled(true);
    _chaptersOnWebView->setEnabled(true);
    _selectAllButton->setEnabled(true);
    _downloadButton->setEnabled(true);
    _updateButton->setEnabled(true);
    _stopButton->setEnabled(false);

    _chaptersProgressBar->setValue(100);
    QTimer::singleShot(1000, _chaptersProgressBar, SLOT(close(void)));
    QTimer::singleShot(1000, _chaptersDownloadedLabel, SLOT(hide(void)));

    _pagesProgressBar->setValue(100);
    QTimer::singleShot(1000, _pagesProgressBar, SLOT(close(void)));
    QTimer::singleShot(1000, _pagesDownloadedLabel, SLOT(hide(void)));

    emit initModelRequested(_selectLineEdit->text());
    emit downloading(false);
    return;
  }
Ejemplo n.º 2
0
double DownloadItem::currentSpeed() const
{
    if (!downloading())
        return -1.0;

    return m_bytesReceived * 1000.0 / m_downloadTime.elapsed();
}
Ejemplo n.º 3
0
int query(int p,int l,int r,int a,int b)
{
	if(a<=l && b>=r) return sum[p];
	int m=(l+r)>>1,x1=0,x2=0;
	downloading(p,l,r,m);
	if(a<=m) x1=query(p<<1,l,m,a,b);
	if(b>m) x2=query((p<<1)+1,m+1,r,a,b);
	return x1+x2;
}
Ejemplo n.º 4
0
void CHttpImageDownloader::updateDataReadProgress(int bytesRead, int totalBytes)
{
    int downloadPercentComplete =0;

    if (bytesRead >1)
    {
        downloadPercentComplete = ((double)bytesRead/totalBytes) * 100;
    }

    emit downloading(downloadPercentComplete);
}
Ejemplo n.º 5
0
	void
	Client::async_download(
		std::string remote_file, 
		std::string local_file, 
		callback_t callback, 
		progress_t progress
	) noexcept
	{
		auto clientImpl = GetImpl(this);
		std::thread downloading([&](){ clientImpl->sync_download(remote_file, local_file, callback, progress); });
		downloading.detach();
	}
Ejemplo n.º 6
0
double DownloadItem::remainingTime() const
{
    if (!downloading())
        return -1.0;

    double timeRemaining = ((double)(bytesTotal() - bytesReceived())) / currentSpeed();

    // When downloading the eta should never be 0
    if (timeRemaining == 0)
        timeRemaining = 1;

    return timeRemaining;
}
Ejemplo n.º 7
0
void modify(int p,int l,int r,int a,int b)
{
	if(a<=l && b>=r)
		if(val[p]!=-1)
		{
			val[p]=!val[p];
			sum[p]=(r-l+1)*val[p];
			return;
		}
	int m=(l+r)>>1;
	downloading(p,l,r,m);
	if(a<=m) modify(p<<1,l,m,a,b);
	if(b>m) modify((p<<1)+1,m+1,r,a,b);
	uploading(p);
}
Ejemplo n.º 8
0
CloudSync::CloudSync()
    : KStatusNotifierItem()
{
    setIconByName("weather-many-clouds");
    setCategory(KStatusNotifierItem::Communications);

    updateTooltip();

    // then, setup our actions
    setupActions();

    contextMenu()->setTitle("CloudSync");

    DirSyncer *syncer = new DirSyncer(Settings::localUrl(), Settings::remoteUrl());
    connect(syncer, SIGNAL(downloading(QString)), this, SLOT(transferring(QString)));
    connect(syncer, SIGNAL(finished(QString)), this, SLOT(finished(QString)));

    syncer->compareDirs();
}
void MangaDownloadWidget::downloadChapters(void) {
  if (_selectLineEdit->text().isEmpty()) {
    _messageModel->editMessageWarning("Warning: no manga name specified.");
    _messageModel->editMessageError("Abort.");
    return;
  }

  _selectLineEdit->setEnabled(false);
  _chaptersOnWebView->setEnabled(false);
  _selectAllButton->setEnabled(false);
  _downloadButton->setEnabled(false);
  _updateButton->setEnabled(false);
  _stopButton->setEnabled(true);
  _chaptersProgressBar->show();
  _chaptersProgressBar->setValue(0);
  _chaptersDownloadedLabel->show();
  _chaptersDownloadedLabel->setText("Chapter");
  _pagesProgressBar->show();
  _pagesProgressBar->setValue(0);
  _pagesDownloadedLabel->show();
  _pagesDownloadedLabel->setText("Page");

  _messageModel->editMessageInformation("Gathering information on chapters to downlaod...");
  QModelIndexList chaptersSelectedIndexes = _chaptersOnWebView->selectionModel()->selectedIndexes();
  for (const QModelIndex& chapterIndex: chaptersSelectedIndexes) {
    _chaptersQueue.enqueue(chapterIndex);
    QString currChapterUrl = _chaptersOnWebModel->data(chapterIndex, Qt::UserRole).toString();
    QString currChapterTitle = _chaptersOnWebModel->data(chapterIndex, Qt::UserRole+1).toString();
    _downloadQueue.enqueue(QPair<QString, QString>(currChapterTitle, currChapterUrl));
  }

  _totalCount = _downloadQueue.size();
  _downloadedCount = 0;

  emit downloading(true);

  startNextDownload();
}
Ejemplo n.º 10
0
bool PROJECT::nearly_runnable() {
    if (runnable(RSC_TYPE_ANY)) return true;
    if (downloading()) return true;
    return false;
}
Ejemplo n.º 11
0
bool PROJECT::potentially_runnable() {
    if (runnable(RSC_TYPE_ANY)) return true;
    if (can_request_work()) return true;
    if (downloading()) return true;
    return false;
}