void bamCore::readCurrent(){ emit setProgressBar(0); #ifdef DEBUG qDebug() << "\nRead Current:"; #endif QStringList lines; QString text, line; QFile file(myInput.currentFile); if(file.exists()){ if(file.open(QIODevice::ReadOnly)){ QTextStream in(&file); while(!in.atEnd()){ /*Here the reading of the file starts line by line. Every line will be append with a linebreak flag before it is going to be added to a string, which contains the whole file. Lines which contain "#" will be ignored.*/ line=in.readLine().append("\n"); if(!line.contains("#")){ text.append(line); } } file.close(); lines = text.split("\n"); QVector<QStringList> values; //Array of QStringlists of size of the number of lines for(int i=0; i<lines.size()-1; i++){ if(lines.at(i).size()>0){ values.push_back(lines.at(i).split(QRegExp( "[ \\t]+"), QString::SkipEmptyParts)); } } for(int i=0; i<values.size(); i++){ emit setProgressBar(i/values.size()); if(!i){ myInput.currentTime.push_back(values.at(i).at(0).toDouble()); myInput.currentCount.push_back(values.at(i).at(1).toDouble()); myInput.currentCountdiff.push_back(values.at(i).at(1).toDouble()); } else{ myInput.currentTime.push_back(values.at(i).at(0).toDouble()); myInput.currentCountdiff.push_back(values.at(i).at(1).toDouble()-values.at(i-1).at(1).toDouble()); myInput.currentCount.push_back(values.at(i).at(1).toDouble()); } #ifdef DEBUG qDebug() << values.at(i).at(0).toDouble() << values.at(i).at(1).toDouble(); #endif } } } emit CurrentFinished(); }
void eZapSetup::updateProgressBar(void) { int blocksPercentUsed = 0; char progressText[100]; if (!eSystemInfo::getInstance()->isOpenEmbedded()) { blocksPercentUsed = getFsFullPerc("/var"); sprintf(progressText, _("/var used %d%%"), blocksPercentUsed); setProgressLabel((eString)progressText, 0); setProgressBar(blocksPercentUsed, 0); } }
void WMediaPlayer::addProgressBar(WTemplate *t, BarControlId id, const char *bindId, const std::string& styleClass, const std::string& valueStyleClass) { WProgressBar *progressBar = new WProgressBar(); progressBar->setStyleClass(styleClass); progressBar->setValueStyleClass(valueStyleClass); progressBar->setInline(false); t->bindWidget(bindId, progressBar); setProgressBar(id, progressBar); }
ProgressDialog::ProgressDialog(QWidget * parent, QString textStr) : QDialog(parent,Qt::Popup | Qt::Dialog) { setupUi(this); textLbl->setText(textStr); setProgressBar(0); connect(cancelBtn,SIGNAL(clicked()),this,SIGNAL(cancel()), Qt::UniqueConnection); connect(hideBtn,SIGNAL(clicked()),this,SIGNAL(hideDialog()), Qt::UniqueConnection); QFile fileSpecific(":/res/ui_styles.qss"); QFile fileCommons(":/res/ui_styles_generic.qss"); fileSpecific.open(QFile::ReadOnly); fileCommons.open(QFile::ReadOnly); QString styles = QLatin1String(fileSpecific.readAll() + fileCommons.readAll()); setStyleSheet(styles); hideBtn->hide(); }
void D2BlockApplication::on_updateComplete() { emit setProgressBar(100); LaunchLaunchTarget(); exit(); }
void DownloadInfoBox::setProgressInformation(qint64 bytesRead, qint64 totalBytes) { QString displayprogress = ""; setProgressBar(bytesRead,totalBytes); if (bytesRead == totalBytes) { //displayprogress.append(QString("100%")); progressinfo->setText(displayprogress); return; } //qreal ratio = bytesRead/totalBytes; //qint8 percentage = (qint8)ratio*100; //displayprogress.prepend(QString("%1").arg(percentage)); //displayprogress.append(QString("% - ")); //get bytes loaded and total bytes => display % and x MB of y MB if (bytesRead < 1000) { displayprogress.append(QString("%1").arg(bytesRead)); displayprogress.append(QString(" bytes")); } else if (bytesRead < 1000000) { displayprogress.append(QString("%1").arg(bytesRead/1000)); displayprogress.append(QString(" KB")); } else if (bytesRead < 1000000000) { double temp = bytesRead / 1000000.0; displayprogress.append(QString::number(temp,'g',2)); displayprogress.append(QString(" MB")); } else { double temp = bytesRead / 1000000000.0; displayprogress.append(QString::number(temp,'g',2)); displayprogress.append(QString(" GB")); } displayprogress.append(QString(" of ")); if (totalBytes < 1000) { displayprogress.append(QString("%1").arg(totalBytes)); displayprogress.append(QString(" bytes")); } else if (totalBytes < 1000000) { displayprogress.append(QString("%1").arg(totalBytes/1000)); displayprogress.append(QString(" KB")); } else if (totalBytes < 1000000000) { double temp = totalBytes / 1000000.0; displayprogress.append(QString::number(temp,'g',2)); displayprogress.append(QString(" MB")); } else { double temp = totalBytes / 1000000000.0; displayprogress.append(QString::number(temp,'g',2)); displayprogress.append(QString(" GB")); } // Speed displayprogress.append(QString(" (Speed ")); int elapsed = time.elapsed()/1000; if (elapsed == 0) elapsed = 1; double speed = bytesRead/elapsed; if (speed < 1000) { displayprogress.append(QString("%1").arg((int)speed)); displayprogress.append(QString(" bytes/s")); } else if (speed < 1000000) { displayprogress.append(QString("%1").arg((int)(speed/1000))); displayprogress.append(QString(" KB/s")); } else { displayprogress.append(QString("%1").arg((int)(speed/1000000))); displayprogress.append(QString(" MB/s")); } //calculate time remaining. use t=time.elapsed. then z=total bytes - loaded bytes. speed=bytes loaded / t.time remaining = z/speed displayprogress.append(QString(") Time remaining ")); int remainingBytes = (int)(totalBytes-bytesRead); int timeRemaining = remainingBytes / speed; if (timeRemaining < 60) { displayprogress.append(QString("%1").arg(timeRemaining)); displayprogress.append(QString(" s")); } else if (timeRemaining < 3600) { int timeRemainingMin = timeRemaining / 60; displayprogress.append(QString("%1").arg(timeRemainingMin)); displayprogress.append(QString(" min ")); timeRemaining = timeRemaining % 60; if (timeRemaining != 0) { displayprogress.append(QString("%1").arg(timeRemaining)); displayprogress.append(QString(" s")); } } else { int timeRemainingHours = timeRemaining / 3600; displayprogress.append(QString("%1").arg(timeRemainingHours)); displayprogress.append(QString(" h ")); timeRemaining = timeRemaining % 3600; if (timeRemaining != 0) { displayprogress.append(QString("%1").arg(timeRemaining)); displayprogress.append(QString(" min")); } } progressinfo->setText(displayprogress); }