Exemplo n.º 1
0
void FontDocument::fontCharacters(QString *chars,
                                  Data::Containers::FontParameters *parameters)
{
  QStringList charList(this->mContainer->keys());
  *chars = charList.join("");
  parameters->family = this->usedFont().family();
  parameters->size = this->usedFont().pixelSize();
  parameters->style = this->usedStyle();
  parameters->monospaced = this->monospaced();
  parameters->antiAliasing = this->antialiasing();
  parameters->foreground = this->foreground();
  parameters->background = this->background();
  parameters->ascent = this->ascent();
  parameters->descent = this->descent();
  parameters->multiplicityHeight = this->multiplicityHeight();
  parameters->multiplicityWidth = this->multiplicityWidth();
}
Exemplo n.º 2
0
void KTouchStatistics::updateCurrentLevelTab() {
	// level info
	levelLabel2->setText( QString("%1").arg(m_currLevelStats.m_levelNum+1) );
    // general stats group
    elapsedTimeLCDLevel->display(static_cast<int>(m_currLevelStats.m_elapsedTime));
    totalCharsLCDLevel->display(static_cast<int>(m_currLevelStats.m_totalChars) );
    wrongCharsLCDLevel->display(static_cast<int>(m_currLevelStats.m_totalChars-m_currLevelStats.m_correctChars) );
    wordsLCDLevel->display(static_cast<int>(m_currLevelStats.m_words) );
    // typing rate group
	if (m_currLevelStats.m_elapsedTime == 0) {
		charSpeedLCDLevel->display(0);
		wordSpeedLCDLevel->display(0);
	}
	else {
		charSpeedLCDLevel->display(static_cast<int>(m_currLevelStats.m_correctChars/m_currLevelStats.m_elapsedTime*60.0) );
		wordSpeedLCDLevel->display(static_cast<int>(m_currLevelStats.m_words/m_currLevelStats.m_elapsedTime*60.0) );
	}
    // accuracy
    correctnessBarLevel->setProgress(static_cast<int>(
		(100.0*m_currLevelStats.m_correctChars)/m_currLevelStats.m_totalChars) );
	// create sorted list of missed characters
	std::list<KTouchCharStats> charList( m_currLevelStats.m_charStats.begin(), m_currLevelStats.m_charStats.end());
	charList.sort(higher_miss_hit_ratio);
	
	std::list<KTouchCharStats>::const_iterator it=charList.begin();
    unsigned int i=0;
    for (; i<8 && it!=charList.end(); ++i, ++it) {
        if (it->missHitRatio()==0)
            break;  // stop listing keys when their hit-miss-ration is zero
        switch (i) {
          case 0 :  charLabel1Level->setText( it->m_char ); charProgress1->setEnabled(true);
                    charProgress1Level->setProgress( it->missHitRatio() ); break;
          case 1 :  charLabel2Level->setText( it->m_char ); charProgress2->setEnabled(true);
                    charProgress2Level->setProgress( it->missHitRatio() ); break;
          case 2 :  charLabel3Level->setText( it->m_char ); charProgress3->setEnabled(true);
                    charProgress3Level->setProgress( it->missHitRatio() ); break;
          case 3 :  charLabel4Level->setText( it->m_char ); charProgress4->setEnabled(true);
                    charProgress4Level->setProgress( it->missHitRatio() ); break;
          case 4 :  charLabel5Level->setText( it->m_char ); charProgress5->setEnabled(true);
                    charProgress5Level->setProgress( it->missHitRatio() ); break;
          case 5 :  charLabel6Level->setText( it->m_char ); charProgress6->setEnabled(true);
                    charProgress6Level->setProgress( it->missHitRatio() ); break;
          case 6 :  charLabel7Level->setText( it->m_char ); charProgress7->setEnabled(true);
                    charProgress7Level->setProgress( it->missHitRatio() ); break;
          case 7 :  charLabel8Level->setText( it->m_char ); charProgress8->setEnabled(true);
                    charProgress8Level->setProgress( it->missHitRatio() ); break;
        }
    }
	// set remaining char labels and progress bars to zero
    for(; i<8; ++i) {
        switch (i) {
          case 0 :  charLabel1Level->setText(" "); charProgress1Level->setProgress(0); charProgress1Level->setEnabled(false); break;
          case 1 :  charLabel2Level->setText(" "); charProgress2Level->setProgress(0); charProgress2Level->setEnabled(false); break;
          case 2 :  charLabel3Level->setText(" "); charProgress3Level->setProgress(0); charProgress3Level->setEnabled(false); break;
          case 3 :  charLabel4Level->setText(" "); charProgress4Level->setProgress(0); charProgress4Level->setEnabled(false); break;
          case 4 :  charLabel5Level->setText(" "); charProgress5Level->setProgress(0); charProgress5Level->setEnabled(false); break;
          case 5 :  charLabel6Level->setText(" "); charProgress6Level->setProgress(0); charProgress6Level->setEnabled(false); break;
          case 6 :  charLabel7Level->setText(" "); charProgress7Level->setProgress(0); charProgress7Level->setEnabled(false); break;
          case 7 :  charLabel8Level->setText(" "); charProgress8Level->setProgress(0); charProgress8Level->setEnabled(false); break;
        }
    }
}
Exemplo n.º 3
0
void KTouchStatistics::updateCurrentSessionTab() {
	// session/level/info
	QString levelnums;
    int last_level = -2;
    int levels_count = 0;
	std::set<unsigned int>::iterator last_it = m_currSessionStats.m_levelNums.end();
	--last_it;
	for (std::set<unsigned int>::iterator it = m_currSessionStats.m_levelNums.begin();
		it != m_currSessionStats.m_levelNums.end(); ++it)
	{
		// do we have a level number that is not a subsequent level of the
		// previous?
		
		if ((static_cast<unsigned int>(last_level + 1) != *it) ||
            (it == last_it))
		{
			if (it != m_currSessionStats.m_levelNums.begin()) {
				if (levels_count > 1)	levelnums += "...";
				else					levelnums += ",";
			}
			levels_count = 0;
			levelnums += QString("%1").arg(*it+1);
			
		}
		else {
			++levels_count;  // increase level count
		}
		last_level = *it;
	}
	levelLabel1->setText(levelnums);
    // general stats group
    elapsedTimeLCD->display(static_cast<int>(m_currSessionStats.m_elapsedTime));
    totalCharsLCD->display(static_cast<int>(m_currSessionStats.m_totalChars) );
    wrongCharsLCD->display(static_cast<int>(m_currSessionStats.m_totalChars-m_currSessionStats.m_correctChars) );
    wordsLCD->display(static_cast<int>(m_currSessionStats.m_words) );
    // typing rate group
	if (m_currSessionStats.m_elapsedTime == 0) {
		charSpeedLCD->display(0);
		wordSpeedLCD->display(0);
	}
	else {
		charSpeedLCD->display(static_cast<int>(m_currSessionStats.m_correctChars/m_currSessionStats.m_elapsedTime*60.0) );
		wordSpeedLCD->display(static_cast<int>(m_currSessionStats.m_words/m_currSessionStats.m_elapsedTime*60.0) );
	}
    // accuracy
    correctnessBar->setProgress(static_cast<int>(
		(100.0*m_currSessionStats.m_correctChars)/m_currSessionStats.m_totalChars) );
	// create sorted list of missed characters
	std::list<KTouchCharStats> charList( m_currSessionStats.m_charStats.begin(), m_currSessionStats.m_charStats.end());
	charList.sort(higher_miss_hit_ratio);
	
	std::list<KTouchCharStats>::const_iterator it=charList.begin();
    unsigned int i=0;
    for (; i<8 && it!=charList.end(); ++i, ++it) {
        if (it->missHitRatio()==0)
            break;  // stop listing keys when their hit-miss-ration is zero
        switch (i) {
          case 0 :  charLabel1->setText( it->m_char ); charProgress1->setEnabled(true);
                    charProgress1->setProgress( it->missHitRatio() ); break;
          case 1 :  charLabel2->setText( it->m_char ); charProgress2->setEnabled(true);
                    charProgress2->setProgress( it->missHitRatio() ); break;
          case 2 :  charLabel3->setText( it->m_char ); charProgress3->setEnabled(true);
                    charProgress3->setProgress( it->missHitRatio() ); break;
          case 3 :  charLabel4->setText( it->m_char ); charProgress4->setEnabled(true);
                    charProgress4->setProgress( it->missHitRatio() ); break;
          case 4 :  charLabel5->setText( it->m_char ); charProgress5->setEnabled(true);
                    charProgress5->setProgress( it->missHitRatio() ); break;
          case 5 :  charLabel6->setText( it->m_char ); charProgress6->setEnabled(true);
                    charProgress6->setProgress( it->missHitRatio() ); break;
          case 6 :  charLabel7->setText( it->m_char ); charProgress7->setEnabled(true);
                    charProgress7->setProgress( it->missHitRatio() ); break;
          case 7 :  charLabel8->setText( it->m_char ); charProgress8->setEnabled(true);
                    charProgress8->setProgress( it->missHitRatio() ); break;
        }
    }
	// set remaining char labels and progress bars to zero
    for(; i<8; ++i) {
        switch (i) {
          case 0 :  charLabel1->setText(" "); charProgress1->setProgress(0); charProgress1->setEnabled(false); break;
          case 1 :  charLabel2->setText(" "); charProgress2->setProgress(0); charProgress2->setEnabled(false); break;
          case 2 :  charLabel3->setText(" "); charProgress3->setProgress(0); charProgress3->setEnabled(false); break;
          case 3 :  charLabel4->setText(" "); charProgress4->setProgress(0); charProgress4->setEnabled(false); break;
          case 4 :  charLabel5->setText(" "); charProgress5->setProgress(0); charProgress5->setEnabled(false); break;
          case 5 :  charLabel6->setText(" "); charProgress6->setProgress(0); charProgress6->setEnabled(false); break;
          case 6 :  charLabel7->setText(" "); charProgress7->setProgress(0); charProgress7->setEnabled(false); break;
          case 7 :  charLabel8->setText(" "); charProgress8->setProgress(0); charProgress8->setEnabled(false); break;
        }
    }
}