libkdeedu/keduvocdocument
keduvocmultiplechoice.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 00003 manage multiple choice suggestions for queries 00004 00005 ----------------------------------------------------------------------- 00006 00007 begin : Mon Oct 29 18:09:29 1999 00008 00009 copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de> 00010 00011 (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net> 00012 00013 ----------------------------------------------------------------------- 00014 00015 ***************************************************************************/ 00016 00017 /*************************************************************************** 00018 * * 00019 * This program is free software; you can redistribute it and/or modify * 00020 * it under the terms of the GNU General Public License as published by * 00021 * the Free Software Foundation; either version 2 of the License, or * 00022 * (at your option) any later version. * 00023 * * 00024 ***************************************************************************/ 00025 00026 #include "keduvocmultiplechoice.h" 00027 #include "kdebug.h" 00028 00029 class KEduVocMultipleChoice::KEduVocMultipleChoicePrivate 00030 { 00031 public: 00032 QStringList m_choices; 00033 }; 00034 00035 KEduVocMultipleChoice::KEduVocMultipleChoice() 00036 : d( new KEduVocMultipleChoicePrivate ) 00037 {} 00038 00039 KEduVocMultipleChoice::KEduVocMultipleChoice( const KEduVocMultipleChoice &other ) 00040 : d( new KEduVocMultipleChoicePrivate ) 00041 { 00042 d->m_choices = other.choices(); 00043 } 00044 00045 KEduVocMultipleChoice::KEduVocMultipleChoice( const QStringList &choices ) 00046 : d( new KEduVocMultipleChoicePrivate ) 00047 { 00048 foreach ( const QString &choice, choices ) { 00049 // use appendChoice to check for empty entries 00050 appendChoice(choice); 00051 } 00052 } 00053 00054 KEduVocMultipleChoice::~KEduVocMultipleChoice() 00055 { 00056 delete d; 00057 } 00058 00059 KEduVocMultipleChoice &KEduVocMultipleChoice::operator= ( const KEduVocMultipleChoice &other ) 00060 { 00061 d->m_choices = other.choices(); 00062 return *this; 00063 } 00064 00065 QStringList KEduVocMultipleChoice::choices() const 00066 { 00067 return d->m_choices; 00068 } 00069 00070 bool KEduVocMultipleChoice::isEmpty() const 00071 { 00072 return d->m_choices.isEmpty(); 00073 } 00074 00075 00076 void KEduVocMultipleChoice::clear() 00077 { 00078 d->m_choices.clear(); 00079 } 00080 00081 00082 QString KEduVocMultipleChoice::choice( int index ) const 00083 { 00084 QString choice; 00085 if ( d->m_choices.size() > index ) { 00086 choice = d->m_choices[index]; 00087 } 00088 return choice; 00089 } 00090 00091 unsigned KEduVocMultipleChoice::size() const 00092 { 00093 return d->m_choices.size(); 00094 } 00095 00096 bool KEduVocMultipleChoice::operator== ( const KEduVocMultipleChoice &choice ) const 00097 { 00098 return d->m_choices == choice.choices(); 00099 } 00100 00101 void KEduVocMultipleChoice::appendChoice( const QString &s ) 00102 { 00103 if ( !s.isEmpty() ) { 00104 kDebug() << s; 00105 d->m_choices.append( s ); 00106 } 00107 }
KDE 4.2 API Reference