author | tux_mike <tux_mike> | 2002-04-17 20:46:18 (UTC) |
---|---|---|
committer | tux_mike <tux_mike> | 2002-04-17 20:46:18 (UTC) |
commit | 7b19e1d98d5acf01102ac057ec077fc036c034c6 (patch) (unidiff) | |
tree | a5ec8752ba8cbf9c5c037f1ec3552be544cc8b3f /core/pim/addressbook | |
parent | 106073977316103f057930daf45f3a083114d48d (diff) | |
download | opie-7b19e1d98d5acf01102ac057ec077fc036c034c6.zip opie-7b19e1d98d5acf01102ac057ec077fc036c034c6.tar.gz opie-7b19e1d98d5acf01102ac057ec077fc036c034c6.tar.bz2 |
Added a Letter Picker
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 86 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 27 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 1 | ||||
-rw-r--r-- | core/pim/addressbook/picker.cpp | 7 |
4 files changed, 98 insertions, 23 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 759cb48..124ff6c 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1010,13 +1010,12 @@ void AbTable::setShowCategory( const QString &c ) | |||
1010 | updateVisible(); | 1010 | updateVisible(); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | void AbTable::setShowByLetter( char c ) | 1013 | void AbTable::setShowByLetter( char c ) |
1014 | { | 1014 | { |
1015 | showChar = tolower(c); | 1015 | showChar = tolower(c); |
1016 | qDebug( "AbTable::setShowByLetter %c", showChar); | ||
1017 | updateVisible(); | 1016 | updateVisible(); |
1018 | } | 1017 | } |
1019 | 1018 | ||
1020 | QString AbTable::showCategory() const | 1019 | QString AbTable::showCategory() const |
1021 | { | 1020 | { |
1022 | return showCat; | 1021 | return showCat; |
@@ -1074,18 +1073,95 @@ void AbTable::updateVisible() | |||
1074 | } | 1073 | } |
1075 | } | 1074 | } |
1076 | } | 1075 | } |
1077 | if ( showChar != '\0' ) { | 1076 | if ( showChar != '\0' ) { |
1078 | tmpStr = fileAsName.left(1); | 1077 | tmpStr = fileAsName.left(1); |
1079 | tmpStr = tmpStr.lower(); | 1078 | tmpStr = tmpStr.lower(); |
1080 | qDebug( "updateVisible "); | 1079 | if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { |
1081 | qDebug( tmpStr ); | ||
1082 | qDebug( "updateVisible2 %c", showChar ); | ||
1083 | if ( tmpStr != QString(QChar(showChar)) ) { | ||
1084 | hide = true; | 1080 | hide = true; |
1085 | } | 1081 | } |
1082 | if ( showChar == '#' ) { | ||
1083 | if (tmpStr == "a") | ||
1084 | hide = true; | ||
1085 | |||
1086 | if (tmpStr == "b") | ||
1087 | hide = true; | ||
1088 | |||
1089 | if (tmpStr == "c") | ||
1090 | hide = true; | ||
1091 | |||
1092 | if (tmpStr == "d") | ||
1093 | hide = true; | ||
1094 | |||
1095 | if (tmpStr == "e") | ||
1096 | hide = true; | ||
1097 | |||
1098 | if (tmpStr == "f") | ||
1099 | hide = true; | ||
1100 | |||
1101 | if (tmpStr == "g") | ||
1102 | hide = true; | ||
1103 | |||
1104 | if (tmpStr == "h") | ||
1105 | hide = true; | ||
1106 | |||
1107 | if (tmpStr == "i") | ||
1108 | hide = true; | ||
1109 | |||
1110 | if (tmpStr == "j") | ||
1111 | hide = true; | ||
1112 | |||
1113 | if (tmpStr == "k") | ||
1114 | hide = true; | ||
1115 | |||
1116 | if (tmpStr == "l") | ||
1117 | hide = true; | ||
1118 | |||
1119 | if (tmpStr == "m") | ||
1120 | hide = true; | ||
1121 | |||
1122 | if (tmpStr == "n") | ||
1123 | hide = true; | ||
1124 | |||
1125 | if (tmpStr == "o") | ||
1126 | hide = true; | ||
1127 | |||
1128 | if (tmpStr == "p") | ||
1129 | hide = true; | ||
1130 | |||
1131 | if (tmpStr == "q") | ||
1132 | hide = true; | ||
1133 | |||
1134 | if (tmpStr == "r") | ||
1135 | hide = true; | ||
1136 | |||
1137 | if (tmpStr == "s") | ||
1138 | hide = true; | ||
1139 | |||
1140 | if (tmpStr == "t") | ||
1141 | hide = true; | ||
1142 | |||
1143 | if (tmpStr == "u") | ||
1144 | hide = true; | ||
1145 | |||
1146 | if (tmpStr == "v") | ||
1147 | hide = true; | ||
1148 | |||
1149 | if (tmpStr == "w") | ||
1150 | hide = true; | ||
1151 | |||
1152 | if (tmpStr == "x") | ||
1153 | hide = true; | ||
1154 | |||
1155 | if (tmpStr == "y") | ||
1156 | hide = true; | ||
1157 | |||
1158 | if (tmpStr == "z") | ||
1159 | hide = true; | ||
1160 | } | ||
1161 | |||
1086 | } | 1162 | } |
1087 | if ( hide ) { | 1163 | if ( hide ) { |
1088 | if ( currentRow() == row ) | 1164 | if ( currentRow() == row ) |
1089 | setCurrentCell( -1, 0 ); | 1165 | setCurrentCell( -1, 0 ); |
1090 | if ( rowHeight(row) > 0 ) | 1166 | if ( rowHeight(row) > 0 ) |
1091 | hideRow( row ); | 1167 | hideRow( row ); |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index e502cf6..beb953a 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -96,13 +96,12 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
96 | 96 | ||
97 | setCaption( tr("Contacts") ); | 97 | setCaption( tr("Contacts") ); |
98 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 98 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
99 | 99 | ||
100 | setToolBarsMovable( FALSE ); | 100 | setToolBarsMovable( FALSE ); |
101 | 101 | ||
102 | QBoxLayout *vb = new QVBoxLayout( this, 0, 0 ); | ||
103 | // Create Toolbars | 102 | // Create Toolbars |
104 | 103 | ||
105 | QPEToolBar *bar = new QPEToolBar( this ); | 104 | QPEToolBar *bar = new QPEToolBar( this ); |
106 | bar->setHorizontalStretchable( TRUE ); | 105 | bar->setHorizontalStretchable( TRUE ); |
107 | 106 | ||
108 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 107 | QPEMenuBar *mbList = new QPEMenuBar( bar ); |
@@ -187,14 +186,18 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
187 | tr("There is not enough space to create\n" | 186 | tr("There is not enough space to create\n" |
188 | "neccessary startup files.\n" | 187 | "neccessary startup files.\n" |
189 | "\nFree up some space before\nentering data!") | 188 | "\nFree up some space before\nentering data!") |
190 | ); | 189 | ); |
191 | } | 190 | } |
192 | 191 | ||
193 | abList = new AbTable( &orderedFields, this, "table" ); | 192 | listContainer = new QWidget( this ); |
194 | vb->insertWidget(0,abList); | 193 | |
194 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | ||
195 | |||
196 | abList = new AbTable( &orderedFields, listContainer, "table" ); | ||
197 | vb->addWidget(abList); | ||
195 | abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 198 | abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
196 | connect( abList, SIGNAL( empty( bool ) ), | 199 | connect( abList, SIGNAL( empty( bool ) ), |
197 | this, SLOT( listIsEmpty( bool ) ) ); | 200 | this, SLOT( listIsEmpty( bool ) ) ); |
198 | connect( abList, SIGNAL( details() ), | 201 | connect( abList, SIGNAL( details() ), |
199 | this, SLOT( slotListView() ) ); | 202 | this, SLOT( slotListView() ) ); |
200 | connect( abList, SIGNAL(currentChanged(int,int)), | 203 | connect( abList, SIGNAL(currentChanged(int,int)), |
@@ -205,22 +208,22 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
205 | abList->load( addressbookXMLFilename() ); | 208 | abList->load( addressbookXMLFilename() ); |
206 | if ( QFile::exists(addressbookOldXMLFilename()) ) { | 209 | if ( QFile::exists(addressbookOldXMLFilename()) ) { |
207 | abList->load( addressbookOldXMLFilename() ); | 210 | abList->load( addressbookOldXMLFilename() ); |
208 | QFile::remove(addressbookOldXMLFilename()); | 211 | QFile::remove(addressbookOldXMLFilename()); |
209 | } | 212 | } |
210 | 213 | ||
211 | pLabel = new LetterPicker( abList ); | 214 | pLabel = new LetterPicker( listContainer ); |
212 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 215 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
213 | vb->insertWidget(1,pLabel); | 216 | vb->addWidget(pLabel); |
214 | catMenu = new QPopupMenu( this ); | 217 | catMenu = new QPopupMenu( this ); |
215 | catMenu->setCheckable( TRUE ); | 218 | catMenu->setCheckable( TRUE ); |
216 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 219 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
217 | populateCategories(); | 220 | populateCategories(); |
218 | 221 | ||
219 | mbList->insertItem( tr("View"), catMenu ); | 222 | mbList->insertItem( tr("View"), catMenu ); |
220 | setCentralWidget( abList ); | 223 | setCentralWidget( listContainer ); |
221 | 224 | ||
222 | fontMenu = new QPopupMenu(this); | 225 | fontMenu = new QPopupMenu(this); |
223 | fontMenu->setCheckable( true ); | 226 | fontMenu->setCheckable( true ); |
224 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); | 227 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); |
225 | 228 | ||
226 | fontMenu->insertItem(tr( "Small" ), 0); | 229 | fontMenu->insertItem(tr( "Small" ), 0); |
@@ -229,13 +232,13 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
229 | 232 | ||
230 | defaultFont = new QFont( abList->font() ); | 233 | defaultFont = new QFont( abList->font() ); |
231 | 234 | ||
232 | slotSetFont(startFontSize); | 235 | slotSetFont(startFontSize); |
233 | 236 | ||
234 | mbList->insertItem( tr("Font"), fontMenu); | 237 | mbList->insertItem( tr("Font"), fontMenu); |
235 | setCentralWidget(abList); | 238 | setCentralWidget(listContainer); |
236 | 239 | ||
237 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 240 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
238 | } | 241 | } |
239 | void AddressbookWindow::slotSetFont( int size ) { | 242 | void AddressbookWindow::slotSetFont( int size ) { |
240 | 243 | ||
241 | if (size > 2 || size < 0) | 244 | if (size > 2 || size < 0) |
@@ -291,13 +294,13 @@ void AddressbookWindow::setDocument( const QString &filename ) | |||
291 | } | 294 | } |
292 | 295 | ||
293 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 296 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
294 | { | 297 | { |
295 | QMainWindow::resizeEvent( e ); | 298 | QMainWindow::resizeEvent( e ); |
296 | 299 | ||
297 | if ( centralWidget() == abList ) | 300 | if ( centralWidget() == listContainer ) |
298 | showList(); | 301 | showList(); |
299 | else if ( centralWidget() == mView ) | 302 | else if ( centralWidget() == mView ) |
300 | showView(); | 303 | showView(); |
301 | } | 304 | } |
302 | 305 | ||
303 | AddressbookWindow::~AddressbookWindow() | 306 | AddressbookWindow::~AddressbookWindow() |
@@ -313,22 +316,22 @@ void AddressbookWindow::slotUpdateToolbar() | |||
313 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 316 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
314 | } | 317 | } |
315 | 318 | ||
316 | void AddressbookWindow::showList() | 319 | void AddressbookWindow::showList() |
317 | { | 320 | { |
318 | if ( mView ) mView->hide(); | 321 | if ( mView ) mView->hide(); |
319 | setCentralWidget( abList ); | 322 | setCentralWidget( listContainer ); |
320 | abList->show(); | 323 | listContainer->show(); |
321 | // update our focues... (or use a stack widget!); | 324 | // update our focues... (or use a stack widget!); |
322 | abList->setFocus(); | 325 | abList->setFocus(); |
323 | } | 326 | } |
324 | 327 | ||
325 | void AddressbookWindow::showView() | 328 | void AddressbookWindow::showView() |
326 | { | 329 | { |
327 | if ( abList->numRows() > 0 ) { | 330 | if ( abList->numRows() > 0 ) { |
328 | abList->hide(); | 331 | listContainer->hide(); |
329 | setCentralWidget( abView() ); | 332 | setCentralWidget( abView() ); |
330 | mView->show(); | 333 | mView->show(); |
331 | mView->setFocus(); | 334 | mView->setFocus(); |
332 | } | 335 | } |
333 | } | 336 | } |
334 | 337 | ||
@@ -598,13 +601,13 @@ void AddressbookWindow::slotPersonalView() | |||
598 | Contact me; | 601 | Contact me; |
599 | if (QFile::exists(filename)) | 602 | if (QFile::exists(filename)) |
600 | me = Contact::readVCard( filename )[0]; | 603 | me = Contact::readVCard( filename )[0]; |
601 | 604 | ||
602 | abView()->init( me ); | 605 | abView()->init( me ); |
603 | abView()->sync(); | 606 | abView()->sync(); |
604 | abList->hide(); | 607 | listContainer->hide(); |
605 | setCentralWidget( abView() ); | 608 | setCentralWidget( abView() ); |
606 | mView->show(); | 609 | mView->show(); |
607 | mView->setFocus(); | 610 | mView->setFocus(); |
608 | } | 611 | } |
609 | 612 | ||
610 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 613 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 31c4660..8e8c883 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -86,12 +86,13 @@ private: | |||
86 | QStringList slOrderedFields; | 86 | QStringList slOrderedFields; |
87 | enum Panes { paneList=0, paneView, paneEdit }; | 87 | enum Panes { paneList=0, paneView, paneEdit }; |
88 | ContactEditor *abEditor; | 88 | ContactEditor *abEditor; |
89 | AbLabel *mView; | 89 | AbLabel *mView; |
90 | LetterPicker *pLabel; | 90 | LetterPicker *pLabel; |
91 | AbTable *abList; | 91 | AbTable *abList; |
92 | QWidget *listContainer; | ||
92 | 93 | ||
93 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, | 94 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, |
94 | *actionPersonal, *actionMail; | 95 | *actionPersonal, *actionMail; |
95 | 96 | ||
96 | bool bAbEditFirstTime; | 97 | bool bAbEditFirstTime; |
97 | int viewMargin; | 98 | int viewMargin; |
diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp index 06dcc7d..a165451 100644 --- a/core/pim/addressbook/picker.cpp +++ b/core/pim/addressbook/picker.cpp | |||
@@ -76,16 +76,15 @@ void PickerLabel::clearLetter() | |||
76 | } | 76 | } |
77 | 77 | ||
78 | void PickerLabel::mouseReleaseEvent( QMouseEvent *e ) | 78 | void PickerLabel::mouseReleaseEvent( QMouseEvent *e ) |
79 | { | 79 | { |
80 | QString tmpStr; | 80 | QString tmpStr; |
81 | 81 | ||
82 | if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3) | 82 | if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3 && lastLetter != '\0') |
83 | QTimer::singleShot( 0, this, SLOT(emitClearSignal()) ); | 83 | QTimer::singleShot( 0, this, SLOT(emitClearSignal()) ); |
84 | 84 | ||
85 | qDebug( "a" ); | ||
86 | switch (currentLetter) { | 85 | switch (currentLetter) { |
87 | case 0: | 86 | case 0: |
88 | tmpStr = "<qt><font color=\"#7F0000\">"; | 87 | tmpStr = "<qt><font color=\"#7F0000\">"; |
89 | tmpStr += letter1; | 88 | tmpStr += letter1; |
90 | tmpStr += "</font>"; | 89 | tmpStr += "</font>"; |
91 | tmpStr += letter2; | 90 | tmpStr += letter2; |
@@ -94,13 +93,12 @@ void PickerLabel::mouseReleaseEvent( QMouseEvent *e ) | |||
94 | 93 | ||
95 | setText(tmpStr); | 94 | setText(tmpStr); |
96 | 95 | ||
97 | currentLetter++; | 96 | currentLetter++; |
98 | lastLetter = letter1; | 97 | lastLetter = letter1; |
99 | emit selectedLetter( letter1 ); | 98 | emit selectedLetter( letter1 ); |
100 | qDebug( "PickerLabel::mouseReleaseEvent %c", letter1 ); | ||
101 | break; | 99 | break; |
102 | 100 | ||
103 | case 1: | 101 | case 1: |
104 | tmpStr = "<qt>"; | 102 | tmpStr = "<qt>"; |
105 | tmpStr += letter1; | 103 | tmpStr += letter1; |
106 | tmpStr += "<font color=\"#7F0000\">"; | 104 | tmpStr += "<font color=\"#7F0000\">"; |
@@ -111,13 +109,12 @@ void PickerLabel::mouseReleaseEvent( QMouseEvent *e ) | |||
111 | 109 | ||
112 | setText(tmpStr); | 110 | setText(tmpStr); |
113 | 111 | ||
114 | currentLetter++; | 112 | currentLetter++; |
115 | lastLetter = letter2; | 113 | lastLetter = letter2; |
116 | emit selectedLetter( letter2 ); | 114 | emit selectedLetter( letter2 ); |
117 | qDebug( "PickerLabel::mouseReleaseEvent %c", letter2 ); | ||
118 | break; | 115 | break; |
119 | 116 | ||
120 | case 2: | 117 | case 2: |
121 | tmpStr = "<qt>"; | 118 | tmpStr = "<qt>"; |
122 | tmpStr += letter1; | 119 | tmpStr += letter1; |
123 | tmpStr += letter2; | 120 | tmpStr += letter2; |
@@ -127,13 +124,12 @@ void PickerLabel::mouseReleaseEvent( QMouseEvent *e ) | |||
127 | 124 | ||
128 | setText(tmpStr); | 125 | setText(tmpStr); |
129 | 126 | ||
130 | currentLetter++; | 127 | currentLetter++; |
131 | lastLetter = letter3; | 128 | lastLetter = letter3; |
132 | emit selectedLetter( letter3 ); | 129 | emit selectedLetter( letter3 ); |
133 | qDebug( "PickerLabel::mouseReleaseEvent %c", letter3 ); | ||
134 | break; | 130 | break; |
135 | 131 | ||
136 | default: | 132 | default: |
137 | clearLetter(); | 133 | clearLetter(); |
138 | lastLetter = '\0'; | 134 | lastLetter = '\0'; |
139 | emit selectedLetter( '\0' ); | 135 | emit selectedLetter( '\0' ); |
@@ -225,10 +221,9 @@ void LetterPicker::clear() | |||
225 | lblVWX->clearLetter(); | 221 | lblVWX->clearLetter(); |
226 | lblYZ->clearLetter(); | 222 | lblYZ->clearLetter(); |
227 | } | 223 | } |
228 | 224 | ||
229 | void LetterPicker::newLetter( char letter ) | 225 | void LetterPicker::newLetter( char letter ) |
230 | { | 226 | { |
231 | qDebug( "LetterPicker::newLetter %c", letter ); | ||
232 | emit letterClicked( letter ); | 227 | emit letterClicked( letter ); |
233 | 228 | ||
234 | } | 229 | } |