author | zautrix <zautrix> | 2005-01-27 14:15:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-27 14:15:50 (UTC) |
commit | cd1b9287f2bcd59652ef66186d00dcf5ff8a2a46 (patch) (unidiff) | |
tree | 99db53425edb1c68cd880e8221805e0f84ae9a75 /kaddressbook | |
parent | 32ad6c6cc658d952c9dfa1fcf5857662bcf01c22 (diff) | |
download | kdepimpi-cd1b9287f2bcd59652ef66186d00dcf5ff8a2a46.zip kdepimpi-cd1b9287f2bcd59652ef66186d00dcf5ff8a2a46.tar.gz kdepimpi-cd1b9287f2bcd59652ef66186d00dcf5ff8a2a46.tar.bz2 |
jump 1
-rw-r--r-- | kaddressbook/jumpbuttonbar.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/kaddressbook/jumpbuttonbar.cpp b/kaddressbook/jumpbuttonbar.cpp index 184d516..b12d9e7 100644 --- a/kaddressbook/jumpbuttonbar.cpp +++ b/kaddressbook/jumpbuttonbar.cpp | |||
@@ -94,18 +94,21 @@ QSizePolicy JumpButtonBar::sizePolicy() const | |||
94 | return QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum); | 94 | return QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum); |
95 | #endif //KAB_EMBEDDED | 95 | #endif //KAB_EMBEDDED |
96 | } | 96 | } |
97 | 97 | ||
98 | void JumpButtonBar::letterClicked() | 98 | void JumpButtonBar::letterClicked() |
99 | { | 99 | { |
100 | JumpButton *button = (JumpButton*)sender(); | 100 | JumpButton *button = (JumpButton*)sender(); |
101 | QString character = button->character(); | 101 | QString character = button->character(); |
102 | if ( character.length() == 2 ) | ||
103 | character = character.left(1) +"-"+character.right(1); | ||
102 | if ( !character.isNull() ) | 104 | if ( !character.isNull() ) |
103 | emit jumpToLetter( character ); | 105 | emit jumpToLetter( character ); |
106 | //qDebug("emit *%s* ",character.latin1()); | ||
104 | } | 107 | } |
105 | 108 | ||
106 | void JumpButtonBar::recreateButtons() | 109 | void JumpButtonBar::recreateButtons() |
107 | { | 110 | { |
108 | // the easiest way to remove all buttons ;) | 111 | // the easiest way to remove all buttons ;) |
109 | //mButtons.setAutoDelete( true ); | 112 | //mButtons.setAutoDelete( true ); |
110 | //mButtons.clear(); | 113 | //mButtons.clear(); |
111 | //mButtons.setAutoDelete( false ); | 114 | //mButtons.setAutoDelete( false ); |
@@ -117,16 +120,17 @@ void JumpButtonBar::recreateButtons() | |||
117 | KABC::AddressBook::Iterator it; | 120 | KABC::AddressBook::Iterator it; |
118 | KABC::Field *field = mCore->currentSearchField(); | 121 | KABC::Field *field = mCore->currentSearchField(); |
119 | if ( field ) { | 122 | if ( field ) { |
120 | setEnabled( true ); | 123 | setEnabled( true ); |
121 | } else { | 124 | } else { |
122 | setEnabled( false ); | 125 | setEnabled( false ); |
123 | return; | 126 | return; |
124 | } | 127 | } |
128 | mCharacters.append( "*"); | ||
125 | for ( it = ab->begin(); it != ab->end(); ++it ) { | 129 | for ( it = ab->begin(); it != ab->end(); ++it ) { |
126 | if ( !field->value( *it ).isEmpty() ) | 130 | if ( !field->value( *it ).isEmpty() ) |
127 | character = field->value( *it )[ 0 ].lower(); | 131 | character = field->value( *it )[ 0 ].lower(); |
128 | if ( character != "!" ) | 132 | if ( character != "!" ) |
129 | if ( !character.isEmpty() && !mCharacters.contains( character ) ) | 133 | if ( !character.isEmpty() && !mCharacters.contains( character ) ) |
130 | mCharacters.append( character ); | 134 | mCharacters.append( character ); |
131 | } | 135 | } |
132 | if ( mCharacters.count() == 0 ) { | 136 | if ( mCharacters.count() == 0 ) { |
@@ -153,22 +157,25 @@ void JumpButtonBar::recreateButtons() | |||
153 | maxHei = (QApplication::desktop()->height()-120)/(mCharacters.count()-skipcount); | 157 | maxHei = (QApplication::desktop()->height()-120)/(mCharacters.count()-skipcount); |
154 | 158 | ||
155 | } | 159 | } |
156 | maxRows = 28; | 160 | maxRows = 28; |
157 | bool skipcurrent = false; | 161 | bool skipcurrent = false; |
158 | bool state = isUpdatesEnabled(); | 162 | bool state = isUpdatesEnabled(); |
159 | setUpdatesEnabled( false ); | 163 | setUpdatesEnabled( false ); |
160 | //qDebug("cc %d ",mCharacters.count() ); | 164 | //qDebug("cc %d ",mCharacters.count() ); |
161 | JumpButton *button; | 165 | JumpButton *button = 0; |
162 | int row = 0, col = 0; | 166 | int row = 0, col = 0; |
163 | JumpButton* cur = mButtons.first(); | 167 | JumpButton* cur = mButtons.first(); |
164 | for ( uint i = 0; i < mCharacters.count(); ++i ) { | 168 | for ( uint i = 0; i < mCharacters.count(); ++i ) { |
165 | if ( skipcount > 0 && skipcurrent ) { | 169 | if ( skipcount > 0 && skipcurrent ) { |
166 | --skipcount; | 170 | --skipcount; |
171 | if ( button ) { | ||
172 | button->setCharacter( button->character() + mCharacters[ i ]); | ||
173 | } | ||
167 | } else { | 174 | } else { |
168 | if ( cur ) { | 175 | if ( cur ) { |
169 | button = cur ; | 176 | button = cur ; |
170 | cur = mButtons.next(); | 177 | cur = mButtons.next(); |
171 | button->setCharacter(mCharacters[ i ]); | 178 | button->setCharacter(mCharacters[ i ]); |
172 | } else { | 179 | } else { |
173 | button = new JumpButton( mCharacters[ i ].upper(), this, mCharacters[ i ] ); | 180 | button = new JumpButton( mCharacters[ i ].upper(), this, mCharacters[ i ] ); |
174 | button->setFixedWidth( fixwid ); | 181 | button->setFixedWidth( fixwid ); |
@@ -180,18 +187,18 @@ void JumpButtonBar::recreateButtons() | |||
180 | button->show(); | 187 | button->show(); |
181 | 188 | ||
182 | if ( col == maxRows ) { | 189 | if ( col == maxRows ) { |
183 | row = 0; | 190 | row = 0; |
184 | col++; | 191 | col++; |
185 | } else | 192 | } else |
186 | row++; | 193 | row++; |
187 | } | 194 | } |
188 | 195 | if ( i > 0 ) | |
189 | skipcurrent = !skipcurrent; | 196 | skipcurrent = !skipcurrent; |
190 | } | 197 | } |
191 | while ( cur ) { | 198 | while ( cur ) { |
192 | cur->hide(); | 199 | cur->hide(); |
193 | cur = mButtons.next(); | 200 | cur = mButtons.next(); |
194 | } | 201 | } |
195 | 202 | ||
196 | mButtonLayout->activate(); | 203 | mButtonLayout->activate(); |
197 | setUpdatesEnabled( state ); | 204 | setUpdatesEnabled( state ); |