From: Peter Hedlund Date: Wed, 13 Jul 2005 04:07:18 +0000 (+0000) Subject: Change function names from getMyProperty() to myProperty() per Qt/KDE standards. X-Git-Tag: v3.80.2~237^2~27 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=b94b210bb91e4806f2f547bb1faecf5ef0055dba;p=libqmvoc.git Change function names from getMyProperty() to myProperty() per Qt/KDE standards. CCMAIL:martin-pfeiffer-bensheim@web.de svn path=/branches/work/kwordquiz/src/leitnersystemview.cpp; revision=434159 --- diff --git a/kwordquiz/keduvocexpression.cpp b/kwordquiz/keduvocexpression.cpp index daa3e29..a46a65e 100644 --- a/kwordquiz/keduvocexpression.cpp +++ b/kwordquiz/keduvocexpression.cpp @@ -402,7 +402,7 @@ void KEduVocExpression::removeTranslation (int idx) return; if (idx <= numTranslations()) - translations.erase (translations.begin() + idx-1); + translations.remove(translations.at(idx-1)); if (idx < (int)remarks.size() ) remarks.erase (remarks.begin() + idx); diff --git a/kwordquiz/keduvocexpression.h b/kwordquiz/keduvocexpression.h index 8158ac2..3f120ac 100644 --- a/kwordquiz/keduvocexpression.h +++ b/kwordquiz/keduvocexpression.h @@ -47,6 +47,8 @@ #define KV_LEV7_GRADE 7 #define KV_LEV7_TEXT I18N_NOOP("Level 7") +#include + #include #include using namespace std; @@ -437,7 +439,7 @@ class KEduVocExpression // all these vectors must be deleted in removeTranslation() vector exprtypes; - vector translations; + /*vector*/ QStringList translations; vector remarks; vector usageLabels; vector paraphrases; diff --git a/kwordquiz/leitnerbox.cpp b/kwordquiz/leitnerbox.cpp index aab7fff..a96d7c4 100644 --- a/kwordquiz/leitnerbox.cpp +++ b/kwordquiz/leitnerbox.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: leitnerbox // -// Description: +// Description: // // // Author: Martin Pfeiffer , (C) 2005 @@ -20,7 +20,7 @@ LeitnerBox::~LeitnerBox() { } -int LeitnerBox::getVocabCount() +int LeitnerBox::vocabCount() { return m_vocabCount; } @@ -30,17 +30,17 @@ void LeitnerBox::setVocabCount( int count ) m_vocabCount = count; } -const QString& LeitnerBox::getBoxName() const +const QString& LeitnerBox::boxName() const { return m_name; } -LeitnerBox* LeitnerBox::getCorrectWordBox() +LeitnerBox* LeitnerBox::correctWordBox() { return m_correctWordBox; } -LeitnerBox* LeitnerBox::getWrongWordBox() +LeitnerBox* LeitnerBox::wrongWordBox() { return m_wrongWordBox; } @@ -62,7 +62,7 @@ void LeitnerBox::setWrongWordBox( LeitnerBox* wrongWordBox ) bool LeitnerBox::operator ==( const LeitnerBox& a ) const { - if( a.getBoxName() == getBoxName() ) + if( a.boxName() == boxName() ) return true; else return false; diff --git a/kwordquiz/leitnerbox.h b/kwordquiz/leitnerbox.h index bf20d6a..d8a48ef 100644 --- a/kwordquiz/leitnerbox.h +++ b/kwordquiz/leitnerbox.h @@ -1,7 +1,7 @@ // // C++ Interface: leitnerbox // -// Description: +// Description: // // // Author: Martin Pfeiffer , (C) 2005 @@ -29,19 +29,19 @@ public: void setBoxName( const QString& ); //sets the boxes name void setVocabCount( int count ); - int getVocabCount(); - - LeitnerBox* getCorrectWordBox(); - LeitnerBox* getWrongWordBox(); - const QString& getBoxName() const; - + int vocabCount(); + + LeitnerBox* correctWordBox(); + LeitnerBox* wrongWordBox(); + const QString& boxName() const; + bool operator == ( const LeitnerBox& a ) const; private: QString m_name; int m_vocabCount; - + LeitnerBox* m_wrongWordBox; LeitnerBox* m_correctWordBox; }; diff --git a/kwordquiz/leitnersystem.cpp b/kwordquiz/leitnersystem.cpp index 2df19ad..65661dd 100644 --- a/kwordquiz/leitnersystem.cpp +++ b/kwordquiz/leitnersystem.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: leitnersystem // -// Description: +// Description: // // // Author: Martin Pfeiffer , (C) 2005 @@ -32,12 +32,12 @@ LeitnerSystem::~LeitnerSystem() QStringList LeitnerSystem::getBoxNameList() { QStringList boxNameList; - QValueList::iterator it; + QValueList::iterator it; for(it = m_boxes.begin(); it != m_boxes.end(); ++it) { - boxNameList.append((*it).getBoxName()); + boxNameList.append((*it).boxName()); } return boxNameList; @@ -48,68 +48,68 @@ int LeitnerSystem::getNumberOfBoxes() return m_boxes.count(); } -LeitnerBox* LeitnerSystem::getBoxWithNumber( int number ) +LeitnerBox* LeitnerSystem::boxWithNumber( int number ) { return &m_boxes[ number ]; } -LeitnerBox* LeitnerSystem::getBoxWithName( const QString& name ) +LeitnerBox* LeitnerSystem::boxWithName( const QString& name ) { QValueList::iterator it; for(it = m_boxes.begin(); it != m_boxes.end(); ++it) { - if((*it).getBoxName() == name) + if((*it).boxName() == name) return &(*it); } return 0; } -QString& LeitnerSystem::getSystemName() +QString& LeitnerSystem::systemName() { return m_systemName; } -const QString& LeitnerSystem::getNextBox( QString& previousBox ) +const QString& LeitnerSystem::nextBox( QString& previousBox ) { for( int i = 0; i < m_boxes.count(); i++ ) { - if( m_boxes[i].getVocabCount() > 0 ) - return getBox( i ); + if( m_boxes[i].vocabCount() > 0 ) + return box( i ); } - + return QString::null; } -const QString& LeitnerSystem::getCorrectBox( int box ) +const QString& LeitnerSystem::correctBox( int box ) { - return m_boxes[ box ].getCorrectWordBox()->getBoxName(); + return m_boxes[ box ].correctWordBox()->boxName(); } -const QString& LeitnerSystem::getWrongBox( int box ) +const QString& LeitnerSystem::wrongBox( int box ) { - return m_boxes[ box ].getWrongWordBox()->getBoxName(); + return m_boxes[ box ].wrongWordBox()->boxName(); } -const QString& LeitnerSystem::getCorrectBox( QString& box ) +const QString& LeitnerSystem::correctBox( QString& box ) { - return getBoxWithName( box )->getCorrectWordBox()->getBoxName(); + return boxWithName( box )->correctWordBox()->boxName(); } -const QString& LeitnerSystem::getWrongBox( QString& box ) +const QString& LeitnerSystem::wrongBox( QString& box ) { - return getBoxWithName( box )->getWrongWordBox()->getBoxName(); + return boxWithName( box )->wrongWordBox()->boxName(); } -int LeitnerSystem::getWrongBoxNumber( int box ) +int LeitnerSystem::wrongBoxNumber( int box ) { - return getNumber( m_boxes[ box ].getWrongWordBox() ); + return number( m_boxes[ box ].wrongWordBox() ); } -int LeitnerSystem::getCorrectBoxNumber( int box ) +int LeitnerSystem::correctBoxNumber( int box ) { - return getNumber( m_boxes[ box ].getCorrectWordBox() ); + return number( m_boxes[ box ].correctWordBox() ); } void LeitnerSystem::deleteBox( int box ) @@ -121,10 +121,10 @@ void LeitnerSystem::deleteBox( LeitnerBox* box ) { for( int i = 0; i < m_boxes.count(); i++ ) { - if( m_boxes[i].getCorrectWordBox() == box ) + if( m_boxes[i].correctWordBox() == box ) m_boxes[i].setCorrectWordBox( 0 ); - if( m_boxes[i].getWrongWordBox() == box ) + if( m_boxes[i].wrongWordBox() == box ) m_boxes[i].setWrongWordBox( 0 ); } @@ -135,12 +135,12 @@ bool LeitnerSystem::insertBox( const QString& name, int correctWordBox, int wron { if( getBoxNameList().contains( name ) != 0 ) return false; - + LeitnerBox tmpBox; tmpBox.setBoxName( name ); - tmpBox.setCorrectWordBox( getBoxWithNumber( correctWordBox ) ); - tmpBox.setWrongWordBox( getBoxWithNumber( wrongWordBox ) ); - + tmpBox.setCorrectWordBox( boxWithNumber( correctWordBox ) ); + tmpBox.setWrongWordBox( boxWithNumber( wrongWordBox ) ); + m_boxes.append( tmpBox ); return true; } @@ -150,7 +150,7 @@ void LeitnerSystem::setSystemName( const QString& name ) m_systemName = name; } -int LeitnerSystem::getNumber( LeitnerBox* box ) +int LeitnerSystem::number( LeitnerBox* box ) { if( box == 0 ) return -1; @@ -160,10 +160,10 @@ int LeitnerSystem::getNumber( LeitnerBox* box ) bool LeitnerSystem::setBoxName( int box, const QString& name ) { - if( getBoxWithName( name ) == 0 || getBoxWithName( name ) == getBoxWithNumber( box ) ) + if( boxWithName( name ) == 0 || boxWithName( name ) == boxWithNumber( box ) ) { - getBoxWithNumber( box )->setBoxName( name ); - + boxWithNumber( box )->setBoxName( name ); + return true; } else @@ -172,10 +172,10 @@ bool LeitnerSystem::setBoxName( int box, const QString& name ) bool LeitnerSystem::setBoxName( LeitnerBox* box, const QString& name ) { - if( getBoxWithName( name ) == 0 || getBoxWithName( name ) == box ) + if( boxWithName( name ) == 0 || boxWithName( name ) == box ) { box->setBoxName( name ); - + return true; } else @@ -186,48 +186,48 @@ bool LeitnerSystem::insertBox( const QString& name ) { if( getBoxNameList().contains( name ) != 0 ) return false; - + LeitnerBox tmpBox; tmpBox.setBoxName( name ); - + m_boxes.append( tmpBox ); return true; } void LeitnerSystem::setCorrectBox( const QString& box, const QString& correctWordBox ) { - getBoxWithName( box )->setCorrectWordBox( getBoxWithName( correctWordBox ) ); + boxWithName( box )->setCorrectWordBox( boxWithName( correctWordBox ) ); } void LeitnerSystem::setWrongBox( const QString& box, const QString& wrongWordBox ) { - getBoxWithName( box )->setWrongWordBox( getBoxWithName( wrongWordBox ) ); + boxWithName( box )->setWrongWordBox( boxWithName( wrongWordBox ) ); } -const QString& LeitnerSystem::getBox( int i ) +const QString& LeitnerSystem::box( int i ) { - return getBoxWithNumber( i )->getBoxName(); + return boxWithNumber( i )->boxName(); } void LeitnerSystem::setBoxVocabCount( QString& box, int vocabCount ) { - getBoxWithName( box )->setVocabCount( vocabCount ); + boxWithName( box )->setVocabCount( vocabCount ); } -int LeitnerSystem::getBoxVocabCount( QString& box ) +int LeitnerSystem::boxVocabCount( QString& box ) { - return getBoxWithName( box )->getVocabCount(); + return boxWithName( box )->vocabCount(); } void LeitnerSystem::incrementBoxVocabCount( QString& box ) { - int tmp = getBoxWithName( box )->getVocabCount(); - getBoxWithName( box )->setVocabCount( tmp++ ); + int tmp = boxWithName( box )->vocabCount(); + boxWithName( box )->setVocabCount( tmp++ ); } void LeitnerSystem::decrementBoxVocabCount( QString& box ) { - int tmp = getBoxWithName( box )->getVocabCount(); - getBoxWithName( box )->setVocabCount( tmp-- ); + int tmp = boxWithName( box )->vocabCount(); + boxWithName( box )->setVocabCount( tmp-- ); } diff --git a/kwordquiz/leitnersystem.h b/kwordquiz/leitnersystem.h index e53586e..6e9be52 100644 --- a/kwordquiz/leitnersystem.h +++ b/kwordquiz/leitnersystem.h @@ -1,7 +1,7 @@ // // C++ Interface: leitnersystem // -// Description: +// Description: // // // Author: Martin Pfeiffer , (C) 2005 @@ -33,32 +33,32 @@ public: int getNumberOfBoxes(); //returns the number of boxes in the system QStringList getBoxNameList(); //returns a list with the boxes names - QString& getSystemName(); //returns the systems name + QString& systemName(); //returns the systems name void setSystemName( const QString& name ); //sets the systems name - LeitnerBox* getBoxWithNumber( int number ); //returns box by number - LeitnerBox* getBoxWithName( const QString& name );//returns box by name - int getNumber( LeitnerBox* box ); - const QString& getBox( int i ); - - const QString& getNextBox( QString& previousBox ); //returns the next box for the next question - - const QString& getCorrectBox( int box ); //returns the correct word box of "int box" - const QString& getWrongBox( int box ); //returns the wrong word box of "int box" - const QString& getCorrectBox( QString& box ); - const QString& getWrongBox( QString& box ); - - int getWrongBoxNumber( int box ); - int getCorrectBoxNumber( int box ); + LeitnerBox* boxWithNumber( int number ); //returns box by number + LeitnerBox* boxWithName( const QString& name );//returns box by name + int number( LeitnerBox* box ); + const QString& box( int i ); + + const QString& nextBox( QString& previousBox ); //returns the next box for the next question + + const QString& correctBox( int box ); //returns the correct word box of "int box" + const QString& wrongBox( int box ); //returns the wrong word box of "int box" + const QString& correctBox( QString& box ); + const QString& wrongBox( QString& box ); + + int wrongBoxNumber( int box ); + int correctBoxNumber( int box ); void setCorrectBox( const QString& box, const QString& correctWordBox ); void setWrongBox( const QString& box, const QString& wrongWordBox ); bool setBoxName( int box, const QString& name ); bool setBoxName( LeitnerBox* box, const QString& name ); - + void setBoxVocabCount( QString& box, int vocabCount ); - int getBoxVocabCount( QString& box ); + int boxVocabCount( QString& box ); void incrementBoxVocabCount( QString& box ); void decrementBoxVocabCount( QString& box ); diff --git a/kwordquiz/leitnersystemview.cpp b/kwordquiz/leitnersystemview.cpp index a7ddaf2..f802ba7 100644 --- a/kwordquiz/leitnersystemview.cpp +++ b/kwordquiz/leitnersystemview.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: leitnersystemview // -// Description: +// Description: // // // Author: Martin Pfeiffer , (C) 2005 @@ -46,7 +46,7 @@ void LeitnerSystemView::drawSystem(QPainter* p) } else { //for each box 74 = 64(pixmap) + 10(distance between two boxes) - //p->drawPixmap(12 + i * 74, m_imageY, KGlobal::iconLoader()->loadIcon("leitnerbox", KIcon::Panel)); + //p->drawPixmap(12 + i * 74, m_imageY, KGlobal::iconLoader()->loadIcon("leitnerbox", KIcon::Panel)); p->drawRect(12 + i * 64 + i*10, m_imageY,64,64); } } @@ -58,23 +58,23 @@ void LeitnerSystemView::drawConnections(QPainter* p) //width = width of the rect for the arc int dist, width = 0; int numberOfBoxes = m_leitnerSystem->getNumberOfBoxes(); - + p->setPen( QPen(green, 2) ); - //paint the connections for the correct word boxes, above the boxes + //paint the connections for the correct word boxes, above the boxes for(int i = 0; i < numberOfBoxes; i++) { - if( m_leitnerSystem->getCorrectBoxNumber( i ) != -1 ) + if( m_leitnerSystem->correctBoxNumber( i ) != -1 ) { - dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i; - + dist = m_leitnerSystem->correctBoxNumber( i ) - i; + if(dist <= 0) { // (dist*(-1) -1)*64 == for each box in between take 64 // dist*(-1)*10 == the gaps in between - // 2*22; 2*21 == the distances of the endings on the picture - width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; - + // 2*22; 2*21 == the distances of the endings on the picture + width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; + p->drawArc( 12 + (dist+i)*74 + 21, m_imageY-(width/3), width, /*(height()/2 - 12-32) *2*/ width/3*2, 0, 180*16); } else @@ -82,23 +82,23 @@ void LeitnerSystemView::drawConnections(QPainter* p) width = (dist-1)*64 + dist*10 + 2*21; p->drawArc(12 + i*74 + 21+22 ,m_imageY-(width/3) , width, /*(height()/2 - 12-32) *2*/width/3*2, 0, 180*16); } - } + } } - + //paint the connections for the wrong word boxes, below the boxes p->setPen(QPen(red, 2)); for(int i = 0; i < numberOfBoxes; i++) { - if( m_leitnerSystem->getWrongBoxNumber( i ) != -1 ) + if( m_leitnerSystem->wrongBoxNumber( i ) != -1 ) { - dist = m_leitnerSystem->getWrongBoxNumber( i ) - i; - + dist = m_leitnerSystem->wrongBoxNumber( i ) - i; + if(dist <= 0) { - width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; + width = (dist*(-1) -1)*64 + dist*(-1)*10 + 2*22 + 2*21; p->drawArc(12+ (dist+i)*74 + 21 ,m_imageY+64-width/3 , width, width/3*2 , 180*16, 180*16); - } + } else { width = (dist-1)*64 + dist*10 + 2*21; @@ -111,7 +111,7 @@ void LeitnerSystemView::drawConnections(QPainter* p) void LeitnerSystemView::setSystem(LeitnerSystem* leitnersystem) { m_leitnerSystem = leitnersystem; - + //calculate the new sizes calculateSize(); updateContents(); @@ -125,10 +125,10 @@ void LeitnerSystemView::highlightBox(int box) void LeitnerSystemView::drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph) { - p->eraseRect(0,0,width(),height()); - + p->eraseRect(0,0,width(),height()); + drawSystem( p ); - + drawConnections( p ); } @@ -137,28 +137,28 @@ void LeitnerSystemView::calculateSize() //margin = 12 //distance between boxes = 10 //boxes = 64*64 - + int numberOfBoxes = m_leitnerSystem->getNumberOfBoxes(); QString x; int height, dist, tmpMaxC, tmpMaxW; tmpMaxC = 0; - tmpMaxW = 0; + tmpMaxW = 0; height = 0; for(int i = 0; i < numberOfBoxes; i++) { - if( m_leitnerSystem->getCorrectBoxNumber( i ) != -1 ) - { - dist = m_leitnerSystem->getCorrectBoxNumber( i ) - i; - + if( m_leitnerSystem->correctBoxNumber( i ) != -1 ) + { + dist = m_leitnerSystem->correctBoxNumber( i ) - i; + if( abs(dist) >= abs(tmpMaxC) ) tmpMaxC = dist; } - - if( m_leitnerSystem->getWrongBoxNumber( i ) != -1 ) + + if( m_leitnerSystem->wrongBoxNumber( i ) != -1 ) { - dist = m_leitnerSystem->getWrongBoxNumber( i ) - i; - + dist = m_leitnerSystem->wrongBoxNumber( i ) - i; + if( abs(dist) >= abs(tmpMaxW) ) tmpMaxW = dist; } @@ -168,7 +168,7 @@ void LeitnerSystemView::calculateSize() height += (( abs(tmpMaxC) -1)*64 + abs(tmpMaxC)*10 + 2*22 + 2*21)/3; else height += ((tmpMaxC-1)*64 + tmpMaxC*10 + 2*21)/3; - + if( tmpMaxW <= 0 ) height += (( abs(tmpMaxW) -1)*64 + abs(tmpMaxW)*10 + 2*22 + 2*21)/3; else @@ -187,13 +187,13 @@ void LeitnerSystemView::mousePressEvent(QMouseEvent* e) if( e->y() > m_imageY && e->y() < m_imageY + 64 && e->x() < contentsWidth() ) { int d = (e->x()-12)/74; - + if((e->x()-12-74*d) <= 64) { //signal for prefLeitner to set the comboboxes to the clicked box emit boxClicked( d ); m_highlightedBox = d; - + updateContents(); } } diff --git a/kwordquiz/prefleitner.cpp b/kwordquiz/prefleitner.cpp index de264ab..bb44fb0 100644 --- a/kwordquiz/prefleitner.cpp +++ b/kwordquiz/prefleitner.cpp @@ -31,13 +31,13 @@ PrefLeitner::PrefLeitner(QWidget * parent, const char* name, WFlags f, LeitnerSy m_leitnerSystemView = new LeitnerSystemView( this, 0 ); PrefLeitnerBaseLayout->addWidget( m_leitnerSystemView, 1, 0 ); PrefLeitnerBaseLayout->setOrigin( QGridLayout::BottomLeft ); - + connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), this, SLOT( slotBoxClicked( int ) ) ); //insert the list of box' names in the comboboxes cmbWrong->insertStringList( m_selectedSystem->getBoxNameList() ); cmbCorrect->insertStringList( m_selectedSystem->getBoxNameList() ); - + //show leitnersystem m_leitnerSystemView->setSystem( m_selectedSystem ); } @@ -51,9 +51,9 @@ void PrefLeitner::slotCorrectWord( const QString& newBox ) { if( m_selectedBox == 0 ) return; - + //when the correct word box was changed in the combobox - m_selectedBox->setCorrectWordBox( m_selectedSystem->getBoxWithName( newBox ) ); + m_selectedBox->setCorrectWordBox( m_selectedSystem->boxWithName( newBox ) ); refreshSystemView(); } @@ -61,9 +61,9 @@ void PrefLeitner::slotWrongWord( const QString& newBox ) { if( m_selectedBox == 0 ) return; - + //when the wrong word box was changed in the combobox - m_selectedBox->setWrongWordBox( m_selectedSystem->getBoxWithName( newBox ) ); + m_selectedBox->setWrongWordBox( m_selectedSystem->boxWithName( newBox ) ); refreshSystemView(); } @@ -80,7 +80,7 @@ void PrefLeitner::newSystem() { cmbCorrect->insertStringList( m_selectedSystem->getBoxNameList() ); cmbWrong->insertStringList( m_selectedSystem->getBoxNameList() ); - + refreshSystemView(); } @@ -91,11 +91,11 @@ void PrefLeitner::refreshSystemView() void PrefLeitner::slotBoxClicked( int box ) { - m_selectedBox = m_selectedSystem->getBoxWithNumber( box ); - - cmbCorrect->setCurrentItem( m_selectedSystem->getCorrectBoxNumber( box ) ); - cmbWrong->setCurrentItem( m_selectedSystem->getWrongBoxNumber( box ) ); - lndBoxName->setText( m_selectedBox->getBoxName() ); + m_selectedBox = m_selectedSystem->boxWithNumber( box ); + + cmbCorrect->setCurrentItem( m_selectedSystem->correctBoxNumber( box ) ); + cmbWrong->setCurrentItem( m_selectedSystem->wrongBoxNumber( box ) ); + lndBoxName->setText( m_selectedBox->boxName() ); } void PrefLeitner::slotAddBox()