From 2fcffbf462226d34bf03ce60fad50152c4eea1ec Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Thu, 30 Apr 2009 13:55:27 +0000 Subject: [PATCH] Merged revisions 960995 via svnmerge from svn+ssh://tmcguire@svn.kde.org/home/kde/branches/kdepim/enterprise4/kdepim ................ r960995 | winterz | 2009-04-29 14:46:14 +0200 (Wed, 29 Apr 2009) | 9 lines Merged revisions 960940 via svnmerge from https://svn.kde.org/home/kde/branches/kdepim/enterprise/kdepim ........ r960940 | mlaurent | 2009-04-29 06:22:31 -0400 (Wed, 29 Apr 2009) | 2 lines not allow to duplicate entry ........ ................ svn path=/trunk/KDE/kdepim/; revision=961647 --- simplestringlisteditor.cpp | 10 +++++++++- simplestringlisteditor.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/simplestringlisteditor.cpp b/simplestringlisteditor.cpp index c4a3a56f0..487d8d8d5 100644 --- a/simplestringlisteditor.cpp +++ b/simplestringlisteditor.cpp @@ -158,6 +158,14 @@ QStringList SimpleStringListEditor::stringList() const { return result; } +bool SimpleStringListEditor::containsString( const QString & str ) { + for ( int i = 0; i < mListBox->count(); i++ ) { + if ( mListBox->item( i )->text() == str ) + return true; + } + return false; +} + void SimpleStringListEditor::setButtonText( ButtonCode button, const QString & text ) { switch ( button ) { @@ -196,7 +204,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->addItem( newEntry ); emit changed(); } diff --git a/simplestringlisteditor.h b/simplestringlisteditor.h index c73253567..917173eb6 100644 --- a/simplestringlisteditor.h +++ b/simplestringlisteditor.h @@ -91,6 +91,7 @@ protected slots: void slotSelectionChanged(); protected: + bool containsString( const QString & str ); QListWidget *mListBox; QPushButton *mAddButton; QPushButton *mRemoveButton;