Ejemplo n.º 1
0
	void SceneModeler::calculateClasses(){
		setProgressText("calculate classes");
		
		this->means = new vector<double>;
		double min = 0;
		double max = 0;
		
		for(unsigned int i = 0; i < this->sceneLimits->size();i++){
			int next = (i != this->sceneLimits->size()-1) ? (*this->sceneLimits)[i+1]-1 : Ub(this->m_ptrData->getTrace());
			
			this->means->push_back(_double(this->m_ptrData->getMeanSlice((*this->sceneLimits)[i],next)));
			min = ((*this->means)[i] < min || min == 0) ? (*this->means)[i] : min;
			max = ((*this->means)[i] > max) ? (*this->means)[i] : max;
			setProgressValue(26 + (int)( (double)( 10.0 / this->sceneLimits->size()) * i));
		}
		this->numClasses = (int) floor((max - min) / _double(this->m_ptrData->getStandardDeviation()));
		double step = ((double)max - (double)min) / this->numClasses;
		
		this->classes = new vector< vector<int> >(this->numClasses);
		
		for(unsigned int i = 0; i < this->means->size();i++){
			if((*this->means)[i] != max){
				(*this->classes)[(int) floor(((*this->means)[i] - (double)min) / step)].push_back(i);
			}
			else{
				(*this->classes)[(int) floor(((*this->means)[i] - (double)min) / step)-1].push_back(i);
			}
			setProgressValue(36 + (int)( (double) ( 15.0 / this->means->size()) * i));
		}
	}
Ejemplo n.º 2
0
void StatGetterThread::onStart()
{
    setLabel("Retrieving files count..");
    emit showLabel();
    emit setProgressRange(0, 0);
    emit setProgressValue(0);
    emit showProgressBar();

    FillPreAnalysisTree();
    const size_t totalValue = preAnalysisTree_.size();

    setLabel("Calculating statistics..");
    emit setProgressRange(0, totalValue);
    emit setProgressValue(0);

    FillStatTreeByPath();
    GetSubdirsCount();

    emit setProgressValue(totalValue);

    emit hideLabel();
    emit hideProgressBar();

    emit finished();
}
Ejemplo n.º 3
0
/******************************************************************************
* Performs the actual analysis. This method is executed in a worker thread.
******************************************************************************/
void CreateBondsModifier::BondsEngine::perform()
{
	setProgressText(tr("Generating bonds"));

	// Determine maximum cutoff.
	FloatType maxCutoff = _uniformCutoff;
	if(_particleTypes) {
		OVITO_ASSERT(_particleTypes->size() == _positions->size());
		for(const auto& innerList : _pairCutoffs)
			for(const auto& cutoff : innerList)
				if(cutoff > maxCutoff) maxCutoff = cutoff;
	}

	// Prepare the neighbor list.
	CutoffNeighborFinder neighborFinder;
	if(!neighborFinder.prepare(maxCutoff, _positions.data(), _simCell, this))
		return;

	// Generate (half) bonds.
	size_t particleCount = _positions->size();
	setProgressRange(particleCount);
	if(!_particleTypes) {
		for(size_t particleIndex = 0; particleIndex < particleCount; particleIndex++) {
			for(CutoffNeighborFinder::Query neighborQuery(neighborFinder, particleIndex); !neighborQuery.atEnd(); neighborQuery.next()) {
				_bonds->push_back({ neighborQuery.unwrappedPbcShift(), (unsigned int)particleIndex, (unsigned int)neighborQuery.current() });
			}
			// Update progress indicator.
			if((particleIndex % 4096) == 0) {
				setProgressValue(particleIndex);
				if(isCanceled())
					return;
			}
		}
	}
	else {
		for(size_t particleIndex = 0; particleIndex < particleCount; particleIndex++) {
			for(CutoffNeighborFinder::Query neighborQuery(neighborFinder, particleIndex); !neighborQuery.atEnd(); neighborQuery.next()) {
				int type1 = _particleTypes->getInt(particleIndex);
				int type2 = _particleTypes->getInt(neighborQuery.current());
				if(type1 >= 0 && type1 < (int)_pairCutoffs.size() && type2 >= 0 && type2 < (int)_pairCutoffs[type1].size()) {
					if(neighborQuery.distanceSquared() <= _pairCutoffs[type1][type2])
						_bonds->push_back({ neighborQuery.unwrappedPbcShift(), (unsigned int)particleIndex, (unsigned int)neighborQuery.current() });
				}
			}
			// Update progress indicator.
			if((particleIndex % 4096) == 0) {
				setProgressValue(particleIndex);
				if(isCanceled())
					return;
			}
		}
	}
	setProgressValue(particleCount);
}
Ejemplo n.º 4
0
void CoreConnection::updateProgress(int value, int max)
{
    if (max != _progressMaximum) {
        _progressMaximum = max;
        emit progressRangeChanged(_progressMinimum, _progressMaximum);
    }
    setProgressValue(value);
}
Ejemplo n.º 5
0
void ProgressLoggerGui::setProgress(int value, int max)
{
    // set maximum first to avoid setting a value outside of the max range.
    // If the current value is outside of the valid range QProgressBar
    // calls reset() internally.
    setProgressMax(max);
    setProgressValue(value);
}
Ejemplo n.º 6
0
bool wmpBootStrap::start()
{

    ASSERT( m_core );
    
    #define TEST_OR_RETURN( function ) if( function != S_OK ) \
                                         return false
    CComPtr<IWMPMediaCollection> mediaCollection;

    TEST_OR_RETURN( m_core->get_mediaCollection( &mediaCollection ) );

    CComPtr<IWMPPlaylist> allMediaPlaylist;
    
    TEST_OR_RETURN( mediaCollection->getAll( &allMediaPlaylist ) );

    long mediaCount;
    
    TEST_OR_RETURN( allMediaPlaylist->get_count( &mediaCount ) );

    CComPtr<IWMPMedia> currentMedia;
        
    setProgressRange( mediaCount );

    for ( long mediaIndex = 0; mediaIndex < mediaCount; mediaIndex++ )
    {
        //Update progress bar
        setProgressValue( mediaIndex + 1 );

        while( m_paused){
            WaitForSingleObject( m_pauseStateChanged, INFINITE );
            if(m_cancel) return false;
        }

        TEST_OR_CONTINUE( allMediaPlaylist->get_item( mediaIndex, &currentMedia ) );
        
        //Get media type
        _bstr_t mediaTypeValue;
        _bstr_t mediaTypeAttrib = _T( "MediaType" );
        TEST_OR_CONTINUE( currentMedia->getItemInfo( mediaTypeAttrib.GetBSTR() , &mediaTypeValue.GetBSTR() ) );

        //Skip any media that is not audio
        std::wstring mediaTypeValueString = mediaTypeValue;
        if( mediaTypeValueString != L"audio" )
            continue;
            
        readAttributes( currentMedia );

    }
    
    completed();


    #undef TEST_OR_RETURN

    return true;
}
/*!
    Displays or updates a progress bar hosted in a taskbar button of the main application window
    to show the specific percentage completed of the full operation.

    \a value value from 0 to 1 that indicates the proportion of the operation that has been completed at the time the method is called.
 */
bool IntegratedMainWindow::setProgressValue(float value)
{
    // windef.h does this
#if defined(Q_CC_MSVC) && defined(max)
#error "Please define NOMINMAX in your project settings to avoid a compiler error."
#endif

    // Despite takig a ULONGLONG, a regular signed 32-bit integer is the maximum "maximum" value for the progress bar
    const int max = std::numeric_limits<int>::max();
    return setProgressValue(value * max, max);
}
Ejemplo n.º 8
0
void FileParser::openFile(const QString &fileName)
{
  intoData = false;
  intoRule = false;
  wordRule.clear();

  KeyCode.clear();
  Length.clear();
  Pinyin.clear();
  PinyinLength.clear();
  Prompt.clear();
  ConstructPhrase.clear();
  InvalidChar.clear();

  keymap.clear();
  wordList.clear();
  //validKey.clear(); //FIXME: May be qt4.8.3 BUG

  if (fileName.isEmpty())
    return;
  QFile file(fileName);
  if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    return;
  
  QTextStream in(&file);
  in.setCodec("UTF-8");
  QString line;
  emit setProgressRange(0, file.size() - 1);
  while (!in.atEnd()) {
    line = in.readLine();
    if (line.isEmpty())
      continue;

    processLine(line);
    if (keymap.size() % 400 == 1)
        emit setProgressValue(file.pos());
  }
  file.close();
  saveWordList();
  emit setProgressValue(file.size());
}
Ejemplo n.º 9
0
void QFStatusBar::addLabel()
{
	//QList<QLabel*> lst = findChildren<QLabel*>();
	//int ix = lst.count();
	QBoxLayout *ly = qobject_cast<QBoxLayout*>(layout());
	QF_ASSERT_EX(ly, "bad layout");
	//ly->setMargin(0);
	QLabel *lbl = new QLabel(QString());//::number(labels.count()));
	lbl->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
	ly->insertWidget(labels.count(), lbl);
	labels << lbl;
	setProgressValue(-1);
}
Ejemplo n.º 10
0
void BootStrap::setProgressRange( int maxValue )
{
    if( maxValue == 0 )
    {
        // no tracks to bootstrap so just set progress bar to 100%
        setProgressRange( 1 );
        setProgressValue( 1 );
        return;
    }

    if( m_hwndProgressBar )
        SendMessage( m_hwndProgressBar, PBM_SETRANGE, 0, MAKELPARAM( 0, maxValue ) );

    m_progressRange = maxValue;
}
Ejemplo n.º 11
0
	SSMProcess* SceneModeler::compute(){
		setProgressText("starting computation");
		setProgressMax(100);
		setProgressValue(1);
		this->captureSceneLimits();
		this->calculateClasses();
		this->computeIndexSequence();
		for(int i = Lb(*this->transitionDataStates); i <= Ub(*this->transitionDataStates); i++){
			(*this->transitionDataStates)[i] += 1;
		}
		
		intvector rv(Lb(*this->transitionDataStates) , Ub(*this->transitionDataStates) );
		for(int i = Lb(rv) ; i <= Ub(rv) ; i++){
			rv[i] = (*this->transitionDataStates)[i];
		}
		setProgressText("creating model");
		return modelFromIndexSequence(rv);
	}
Ejemplo n.º 12
0
void StatGetterThread::FillStatTreeByPath()
{
    int counter = 0;

    for (auto pair : preAnalysisTree_)
    {
        auto groupName = pair.first;
        auto groupStats = pair.second;

        const size_t elementsCount(GetTotalGroupFilesCount(groupStats));
        const size_t groupSize(GetTotalGroupFilesSize(groupStats));
        GroupStats stats = {elementsCount, groupSize};

        statTree_.insert(std::make_pair(groupName, stats));

        ++counter;
        emit setProgressValue(counter);
    }
}
Ejemplo n.º 13
0
//! called twice
void InstallerForm::downloadDaemon()
{
    show();

    manager = new QNetworkAccessManager(this);

    file.setFileName(downloadPath);
    file.open(QIODevice::WriteOnly);

    request = new QNetworkRequest(QUrl(daemonUrl));
    request->setRawHeader("User-Agent", "Kfilebox");

    reply = manager->get(*request);

    connect(reply, SIGNAL(finished()), SLOT(downloadFinished()));
    connect(reply, SIGNAL(readyRead()), SLOT(downloadReadyRead()));

    connect(reply,SIGNAL(downloadProgress(qint64,qint64)), SLOT(setProgressValue(qint64,qint64)));
    connect(reply,SIGNAL(error(QNetworkReply::NetworkError)), SLOT(displayError(QNetworkReply::NetworkError)));

}
Ejemplo n.º 14
0
	void SceneModeler::captureSceneLimits(){
		this->sceneLimits = new vector<int>;
		this->sceneLimits->push_back(0);
		vector<real> vk;
		
		rvector trace = m_ptrData->getTrace();
		SetLb(trace,0);
		
		setProgressText("caputre scenelimits");
		for(int i = 0;i <= Ub(trace);i++){
			
			vk.push_back(this->m_ptrData->getVariationCoefficientSlice(this->sceneLimits->back(),i));
			int last = this->sceneLimits->back();
			if( (i-last) >= 1 ){
				if(((i-last+1) * abs(vk[i] - vk[i-1])) > this->threshold){
					this->sceneLimits->push_back(i);
					vk[i] = this->m_ptrData->getVariationCoefficientSlice(this->sceneLimits->back(),i);
				}
			}
			setProgressValue( 1+ (int)( (double) (25.0 / Ub(trace) )) * i );
		}
	}
Ejemplo n.º 15
0
void Win32TaskbarManager::notifyError() {
	setProgressState(Common::TaskbarManager::kTaskbarError);
	setProgressValue(1, 1);
}
Ejemplo n.º 16
0
void BootStrap::dialogEventLoop()
{
    log( "Starting dialogEventLoop" );

    m_hwndDialog = CreateDialogW( m_module,
                                  MAKEINTRESOURCEW( IDD_PROGRESSFORM ),
                                  m_hwndParent,
                                  (DLGPROC)BootStrap::DialogProc );

    m_hwndMap[ m_hwndDialog ] = this;

    // FIXME: error never used
    DWORD error = GetLastError();

    m_hwndProgressBar = GetDlgItem( m_hwndDialog, IDC_PROGRESS1 );

    HWND hwndLabel = GetDlgItem( m_hwndDialog, IDC_LABEL );

    // EJ: Just out of interest, why do you read the string into a member at construct time and then
    // access the member here, instead of just calling a function that reads it straight here?
    //set the label from the registry key
    SetWindowTextW( hwndLabel, (LPCWSTR)m_strProgressLabel.c_str() );

    //set the window title from the registry key
    SetWindowTextW( m_hwndDialog, (LPCWSTR)m_strProgressTitle.c_str() );

    //Set Dialog Position to Parent position
    if( m_hwndParent )
    {
        RECT parentPos;
        GetWindowRect( m_hwndParent, &parentPos );

        RECT dialogPos;
        GetWindowRect( m_hwndDialog, &dialogPos );

        SetWindowPos( m_hwndDialog, m_hwndParent,
            ( ( parentPos.left + parentPos.right ) / 2 ) - ( ( dialogPos.right - dialogPos.left ) / 2 ),
            ( ( parentPos.top + parentPos.bottom ) / 2 ) - ( ( dialogPos.top - dialogPos.bottom ) / 2 ),
            NULL, NULL, SWP_NOSIZE || SWP_ASYNCWINDOWPOS );
    }

    setProgressRange( m_progressRange );
    setProgressValue( m_progressValue );

    ShowWindow( m_hwndDialog, SW_SHOWNORMAL );

    log( "Dialog shown, setting event to signalled" );

    SetEvent( m_progressDialogShown );
    
    MSG message;
    BOOL messageVal;
    m_dialogThreadEnd = false;
    while( messageVal = GetMessage( &message, NULL, 0, 0 ) && !m_dialogThreadEnd && !m_cancel )
    {
        if( messageVal < 0 )
        {
            // FIXME: what about localisation here? And why are we using T-strings?
            std::basic_stringstream<TCHAR, std::char_traits<TCHAR>, std::allocator<TCHAR> > errorTxt;
            errorTxt << _T( "Event loop error " ) << GetLastError();
            MessageBox( NULL, errorTxt.str().c_str(), _T( "Error..." ), MB_OK | MB_ICONEXCLAMATION );
        }
        else
        {
            TranslateMessage( &message );
            DispatchMessage( &message );
        }
    }

    std::ostringstream os;
    os << "Dialog loop exited\nmessageVal: " << messageVal << ", m_dialogThreadEnd: " << m_dialogThreadEnd << ", m_cancel: " << m_cancel;
    log( os.str() );
    
    if( m_cancel )
    {
        closeWindow();
    }
}
Ejemplo n.º 17
0
	void SceneModeler::computeIndexSequence(){
		setProgressText("compute index sequence");
		rvector rawData(m_ptrData->getTrace());
		int menge = 0;
		for(unsigned int i = 0;i < this->classes->size(); i++){
			if((*this->classes)[i].size() != 0){ menge += 1; }
		}
		
		this->classTraces = new vector< Trace* >;
		this->classData = new vector< vector <double>* >(menge);
		
		this->transitionDataClasses = new vector< int >(Ub(this->m_ptrData->getTrace())+1);
		this->numStates = new int[this->numClasses];
		this->classMap = new int[this->numClasses];
		unsigned int count = 0;
		
		/*creating vectors containing:
			-a map that compensates the empty classes(this->classMap)
			-the specific class for each datapoint(this->transitionDataClasses)*/
		
		for(unsigned int i = 0;i < this->classes->size(); i++){
			
			if((*this->classes)[i].size() != 0){
				this->classMap[i] = i-count;
				(*this->classData)[this->classMap[i]] = new vector<double>;
				
				for(unsigned int n = 0; n < (*this->classes)[i].size(); n++){
					int ende = ((unsigned int) (*this->classes)[i][n] != this->sceneLimits->size()-1) ? ((int) (*this->sceneLimits)[((int) (*this->classes)[i][n])+1]) -1 : Ub(this->m_ptrData->getTrace());;
					for(int x = (*this->sceneLimits)[(*this->classes)[i][n]]; x <= ende; x++){
						(*this->classData)[this->classMap[i]]->push_back(_double(rawData[x]));
						(*this->transitionDataClasses)[x] = i;
					}
				}
				
				double max = 0;
				double min = 0;
				
				for(unsigned int n = 0; n < (*this->classData)[this->classMap[i]]->size();n++){
					min = (n == 0 || min > (*(*this->classData)[this->classMap[i]])[n]) ? (*(*this->classData)[this->classMap[i]])[n] : min;
					max = (max < (*(*this->classData)[this->classMap[i]])[n]) ? (*(*this->classData)[this->classMap[i]])[n] : max;
				}
				
				rvector dump(0,(*this->classData)[this->classMap[i]]->size()-1);
				for(unsigned int n=0;n< (*this->classData)[this->classMap[i]]->size();n++){
					dump[n] = (*(*this->classData)[this->classMap[i]])[n];
				}
				this->classTraces->push_back(new Trace(dump));
				
				if( _double(this->classTraces->back()->getStandardDeviation()) == 0 ){
					this->numStates[i] = 1;
				}
				else{
					this->numStates[i] = (int) floor((max - min) /	_double(this->classTraces->back()->getStandardDeviation()));
				}
					
				
			}
			else{
				this->numStates[i] = 0;
				this->classMap[i] = -1;
				count++;
			}
			setProgressValue(41+ (int)( (double) (20.0 / this->classes->size()) * i));
		}
		
		/*creating vector containing empty states*/
		this->strippedStates = new vector< vector <int>* >(this->classes->size());
		
		for(unsigned int i=0; i < this->classes->size();i++){
			(*this->strippedStates)[i] = new vector<int>;
			
			if(this->classMap[i] != -1){
				intvector intvec(0,Ub((*this->classTraces)[this->classMap[i]]->getTrace()));
				
				for(int c=0;c <= Ub(intvec);c++){
					intvec[c] = this->getStateFromTrace((*(*this->classTraces)[this->classMap[i]]),(*this->classTraces)[this->classMap[i]]->getTrace()[c]);
				}
				
				rmatrix* tmp = new rmatrix(AbstractDiscreteSSMPModeler::computeTransition(intvec));
				
				for(int n=0;n < this->numStates[i];n++){
					real sum=0;
					for(int x=0;x < this->numStates[i];x++){
						sum += (*tmp)[cxsc::Row(n)][x];
					}
					if(((int) cxsc::_double(sum)) != 1){ (*this->strippedStates)[this->classMap[i]]->push_back(n); }
				}
				
				delete tmp;
			}
			setProgressValue(61 + (int)( (double) (20.0 / this->classes->size()) * i));
		}
		
		/*creating intvector containing states for each datapoint*/
		this->transitionDataStates = new intvector(0,Ub(m_ptrData->getTrace()));
		
		for(int i=0; i <= Ub(m_ptrData->getTrace());i++){
			int stateBuff=0;
			for(int n=0;n < (*this->transitionDataClasses)[i];n++){
				stateBuff += this->numStates[n]-(*this->strippedStates)[n]->size();
			}
			
			(*this->transitionDataStates)[i] = (stateBuff+ this->getStateFromTrace( ((*(*this->classTraces)[this->classMap[(*this->transitionDataClasses)[i]]])) , m_ptrData->getTrace()[i] ) );
			setProgressValue(81 + (int)( (double) ( 15.0 / Ub( m_ptrData->getTrace() )) * i));
		}
	}
Ejemplo n.º 18
0
void ExcelControl::run(){
    if(m_tableView == NULL || m_tableModel == NULL){
        return;
    }

    int rowCount = m_tableModel->rowCount();
    int colCount = m_tableModel->columnCount();
    qDebug() << rowCount << colCount;

    Document xlsx;
    //单元格格式
    Format cellFormat;
    //颜色
    QColor originColor = cellFormat.patternBackgroundColor();
    //水平居中
    cellFormat.setHorizontalAlignment(Format::AlignHCenter);
    //垂直居中
    cellFormat.setVerticalAlignment(Format::AlignVCenter);
    //边框
    cellFormat.setBorderStyle(Format::BorderThin);
    //设置字体
    cellFormat.setFont(QFont("微软雅黑"));
    cellFormat.setFontSize(9);

    //添加标题
    cellFormat.setPatternBackgroundColor(QColor(0, 176, 200));
    for(int i = 0;i < colCount;i++){
        //获取标题单元格值
        QString headerValue = m_tableModel->headerData(i, Qt::Horizontal).toString();
        //字体加粗
        cellFormat.setFontBold(true);
        //给单元格设值并合并单元格
        xlsx.write(1, i + 1, headerValue, cellFormat);
    }
    //字体不加粗
    cellFormat.setFontBold(false);
    //循环添加单元格内容
    for(int i = 0;i < rowCount;i++){
        for(int j = 0;j < colCount;j++){
            QStandardItem *cellItem = m_tableModel->item(i, j);
            if(cellItem != NULL){
                //获取单元格值
                QString cellValue = cellItem->text();
                //获取单元格背景色
                QColor cellBgColor = cellItem->background().color();
                //给单元格设值并合并单元格
                int rowSpan = m_tableView->rowSpan(i, j);
                int colSpan = m_tableView->columnSpan(i, j);
                cellFormat.setPatternBackgroundColor(cellBgColor);
                xlsx.write(i + 2, j + 1, cellValue, cellFormat);
                xlsx.mergeCells(CellRange(i + 2, j + 1, i + rowSpan + 1, j + colSpan), cellFormat);
            }else{
                //设置空值
                int rowSpan = m_tableView->rowSpan(i, j);
                int colSpan = m_tableView->columnSpan(i, j);
                if(rowSpan == 1 && colSpan == 1){
                    cellFormat.setPatternBackgroundColor(originColor);
                    xlsx.write(i + 2, j + 1, "", cellFormat);
                }
            }
            emit setProgressValue(i * colCount + j + 1, rowCount * colCount);
        }
    }
    //保存excel
    if(m_path.isEmpty()){
        xlsx.save();
    }else{
        xlsx.saveAs(m_path);
    }

    //初始化
    m_tableView = NULL;
    m_tableModel = NULL;

    //发送处理完成的信号
    emit execute(true);

    qDebug() << "excel done";
}
/*!
    Displays or updates a progress bar hosted in a taskbar button of the main application window
    to show the specific percentage completed of the full operation.

    \a value an application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.
    \a max an application-defined value that specifies the value \a value will have when the operation is complete.
 */
bool IntegratedMainWindow::setProgressValue(int value, int max)
{
    return setProgressValue(value, 0, max);
}
Ejemplo n.º 20
0
void Logger::set_next_line() {
	QMutexLocker locker(&mutex);
	virgin_line = true;
	if (line_message.startsWith(PROGRESS_ON)) progress_on = true;
	if (line_message.startsWith(PROGRESS_OFF)) progress_on = false;
	if (line_message.startsWith(PROGRESS_HEADER)) {
		if (progress_on) {
			if (line_message.startsWith(PROGRESS_MINIMUM)) {
				int v = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2).toInt();
				process_start.start();
				emit setProgressMinimum(v);
			}
			if (line_message.startsWith(PROGRESS_MAXIMUM)) {
				int v = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2).toInt();
				emit setProgressMaximum(v);
			}
			if (line_message.startsWith(PROGRESS_VALUE)) {
				int v = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2).toInt();
				emit setProgressValue(v);
			}
			if (line_message == PROGRESS_DONE) {
				emit setProgressMinimum(0);
				emit setProgressMaximum(1);
				emit resetProgress();
				emit setProgressStatus("Done.",1000);
				setTextColor(Qt::lightGray);
				append(line_time.toString("hh:mm:ss")+": ");
				moveCursor(QTextCursor::End);
				setTextColor(Qt::black);
				float sec = (float)process_start.elapsed()/1000;
				int min = sec / 60;
				QString start_string = last_progress_status;
				if (start_string == "") start_string = "Processing time";
				if (min>0) {
					sec = sec - min*60;
					insertPlainText(tr("%1: %2 min %3 s").arg(start_string).arg(min).arg(sec));
				} else insertPlainText(tr("%1: %2 s").arg(start_string).arg(sec));
				emit set_variable(Application_variable(tr("%1").arg(last_progress_status), QString::number((float)process_start.elapsed()/1000)));
				repaint();

			}
			if (line_message.startsWith(PROGRESS_STATUS)) {
				process_start.start();
				last_progress_status = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2);
				emit setProgressStatus(last_progress_status,0);
			}
		}
	} else {
		setTextColor(Qt::lightGray);
		append(line_time.toString("hh:mm:ss")+": ");
		moveCursor(QTextCursor::End);
		if (line_message.startsWith(LOG_ERROR)) {
			setTextColor(QColor(168,0,0));
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_ERROR).size()));
			line_message = tr("%1 %2").arg("ERROR: ").arg(line_message);
		} else if (line_message.startsWith(LOG_WARNING)) {
			setTextColor(Qt::blue);
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_WARNING).size()));
			line_message = tr("%1 %2").arg("WARNING: ").arg(line_message);
		} else if (line_message.startsWith(LOG_GREEN)) {
			setTextColor(QColor(0,168,0));
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_GREEN).size()));
		} else if (line_message.startsWith(LOG_BLUE)) {
			setTextColor(Qt::blue);
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_BLUE).size()));
		} else if (line_message.startsWith(LOG_RED)) {
			setTextColor(Qt::red);
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_RED).size()));
		} else	setTextColor(Qt::black);
		insertPlainText(line_message);
//		repaint();
	}
	//#ifdef Q_WS_WIN
	//QEventLoop el(this);
	//el.processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers );	
	//#endif //Q_WS_WIN
	line_message.clear();
}
Ejemplo n.º 21
0
void WindowsTaskBar::setProgress(int percents)
{
	int progress = qBound(0, percents, 100);
	setProgressValue(window()->winId(), progress);
}