not allow to duplicate entry

svn path=/branches/kdepim/enterprise/kdepim/; revision=960940
wilder-work
Laurent Montel 17 years ago
parent 9d72baa516
commit 9706e50cc9
  1. 11
      simplestringlisteditor.cpp
  2. 1
      simplestringlisteditor.h

@ -166,6 +166,15 @@ QStringList SimpleStringListEditor::stringList() const {
return result;
}
bool SimpleStringListEditor::containsString( const QString & str ) {
for ( QListBoxItem * item = mListBox->firstItem() ;
item ; item = item->next() ) {
if ( item->text() == str )
return true;
}
return false;
}
void SimpleStringListEditor::setButtonText( ButtonCode button,
const QString & text ) {
switch ( button ) {
@ -207,7 +216,7 @@ void SimpleStringListEditor::slotAdd() {
&ok, this );
// let the user verify the string before adding
emit aboutToAdd( newEntry );
if ( ok && !newEntry.isEmpty() ) {
if ( ok && !newEntry.isEmpty() && !containsString( newEntry )) {
mListBox->insertItem( newEntry );
emit changed();
}

@ -91,6 +91,7 @@ protected slots:
void slotSelectionChanged();
protected:
bool containsString( const QString & str );
QListBox *mListBox;
QPushButton *mAddButton;
QPushButton *mRemoveButton;

Loading…
Cancel
Save