summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp26
-rw-r--r--core/pim/addressbook/abtable.h2
-rw-r--r--core/pim/addressbook/addressbook.cpp12
-rw-r--r--core/pim/addressbook/addressbook.h3
-rw-r--r--core/pim/addressbook/addressbook.pro6
-rw-r--r--core/pim/addressbook/picker.cpp234
-rw-r--r--core/pim/addressbook/picker.h65
7 files changed, 344 insertions, 4 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 17277b4..759cb48 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -150,6 +150,7 @@ AbTable::~AbTable()
150 150
151void AbTable::init() 151void AbTable::init()
152{ 152{
153 showChar = '\0';
153 setNumRows( 0 ); 154 setNumRows( 0 );
154 setNumCols( 2 ); 155 setNumCols( 2 );
155 156
@@ -452,12 +453,13 @@ void AbTable::addEntry( const Contact &newCnt )
452} 453}
453 454
454void AbTable::resizeRows( int size ) { 455void AbTable::resizeRows( int size ) {
455 456/*
456 if (numRows()) { 457 if (numRows()) {
457 for (int i = 0; i < numRows(); i++) { 458 for (int i = 0; i < numRows(); i++) {
458 setRowHeight( i, size ); 459 setRowHeight( i, size );
459 } 460 }
460 } 461 }*/
462 updateVisible();
461} 463}
462 464
463void AbTable::updateJournal( const Contact &cnt, 465void AbTable::updateJournal( const Contact &cnt,
@@ -1008,6 +1010,13 @@ void AbTable::setShowCategory( const QString &c )
1008 updateVisible(); 1010 updateVisible();
1009} 1011}
1010 1012
1013void AbTable::setShowByLetter( char c )
1014{
1015 showChar = tolower(c);
1016 qDebug( "AbTable::setShowByLetter %c", showChar);
1017 updateVisible();
1018}
1019
1011QString AbTable::showCategory() const 1020QString AbTable::showCategory() const
1012{ 1021{
1013 return showCat; 1022 return showCat;
@@ -1032,6 +1041,8 @@ void AbTable::updateVisible()
1032 bool hide; 1041 bool hide;
1033 AbTableItem *ati; 1042 AbTableItem *ati;
1034 Contact *cnt; 1043 Contact *cnt;
1044 QString fileAsName;
1045 QString tmpStr;
1035 visible = 0; 1046 visible = 0;
1036 1047
1037 setPaintingEnabled( FALSE ); 1048 setPaintingEnabled( FALSE );
@@ -1043,6 +1054,7 @@ void AbTable::updateVisible()
1043 ati = static_cast<AbTableItem*>( item(row, 0) ); 1054 ati = static_cast<AbTableItem*>( item(row, 0) );
1044 cnt = &contactList[ati]; 1055 cnt = &contactList[ati];
1045 cats = cnt->categories(); 1056 cats = cnt->categories();
1057 fileAsName = cnt->fileAs();
1046 hide = false; 1058 hide = false;
1047 if ( !showCat.isEmpty() ) { 1059 if ( !showCat.isEmpty() ) {
1048 if ( showCat == tr( "Unfiled" ) ) { 1060 if ( showCat == tr( "Unfiled" ) ) {
@@ -1062,6 +1074,16 @@ void AbTable::updateVisible()
1062 } 1074 }
1063 } 1075 }
1064 } 1076 }
1077 if ( showChar != '\0' ) {
1078 tmpStr = fileAsName.left(1);
1079 tmpStr = tmpStr.lower();
1080 qDebug( "updateVisible ");
1081 qDebug( tmpStr );
1082 qDebug( "updateVisible2 %c", showChar );
1083 if ( tmpStr != QString(QChar(showChar)) ) {
1084 hide = true;
1085 }
1086 }
1065 if ( hide ) { 1087 if ( hide ) {
1066 if ( currentRow() == row ) 1088 if ( currentRow() == row )
1067 setCurrentCell( -1, 0 ); 1089 setCurrentCell( -1, 0 );
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 53635ee..d5ff279 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -84,6 +84,7 @@ public:
84 void setChoiceSelection(int index, const QStringList& list); 84 void setChoiceSelection(int index, const QStringList& list);
85 QStringList choiceSelection(int index) const; 85 QStringList choiceSelection(int index) const;
86 void setShowCategory( const QString &c ); 86 void setShowCategory( const QString &c );
87 void setShowByLetter( char c );
87 QString showCategory() const; 88 QString showCategory() const;
88 QStringList categories(); 89 QStringList categories();
89 void resizeRows( int size ); 90 void resizeRows( int size );
@@ -130,6 +131,7 @@ private:
130 void updateVisible(); 131 void updateVisible();
131 int lastSortCol; 132 int lastSortCol;
132 bool asc; 133 bool asc;
134 char showChar;
133 QMap<AbTableItem*, Contact> contactList; 135 QMap<AbTableItem*, Contact> contactList;
134 const QValueList<int> *intFields; 136 const QValueList<int> *intFields;
135 int currFindRow; 137 int currFindRow;
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 360aa7e..e502cf6 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -63,6 +63,7 @@
63 63
64#include <qdatetime.h> 64#include <qdatetime.h>
65 65
66#include "picker.h"
66static QString addressbookOldXMLFilename() 67static QString addressbookOldXMLFilename()
67{ 68{
68 QString filename = QPEApplication::documentDir() + "addressbook.xml"; 69 QString filename = QPEApplication::documentDir() + "addressbook.xml";
@@ -98,6 +99,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
98 99
99 setToolBarsMovable( FALSE ); 100 setToolBarsMovable( FALSE );
100 101
102 QBoxLayout *vb = new QVBoxLayout( this, 0, 0 );
101 // Create Toolbars 103 // Create Toolbars
102 104
103 QPEToolBar *bar = new QPEToolBar( this ); 105 QPEToolBar *bar = new QPEToolBar( this );
@@ -189,6 +191,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
189 } 191 }
190 192
191 abList = new AbTable( &orderedFields, this, "table" ); 193 abList = new AbTable( &orderedFields, this, "table" );
194 vb->insertWidget(0,abList);
192 abList->setHScrollBarMode( QScrollView::AlwaysOff ); 195 abList->setHScrollBarMode( QScrollView::AlwaysOff );
193 connect( abList, SIGNAL( empty( bool ) ), 196 connect( abList, SIGNAL( empty( bool ) ),
194 this, SLOT( listIsEmpty( bool ) ) ); 197 this, SLOT( listIsEmpty( bool ) ) );
@@ -205,6 +208,9 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
205 QFile::remove(addressbookOldXMLFilename()); 208 QFile::remove(addressbookOldXMLFilename());
206 } 209 }
207 210
211 pLabel = new LetterPicker( abList );
212 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
213 vb->insertWidget(1,pLabel);
208 catMenu = new QPopupMenu( this ); 214 catMenu = new QPopupMenu( this );
209 catMenu->setCheckable( TRUE ); 215 catMenu->setCheckable( TRUE );
210 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 216 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
@@ -884,6 +890,12 @@ void AddressbookWindow::slotSetCategory( int c )
884 } 890 }
885} 891}
886 892
893void AddressbookWindow::slotSetLetter( char c ) {
894
895 abList->setShowByLetter( c );
896
897}
898
887void AddressbookWindow::populateCategories() 899void AddressbookWindow::populateCategories()
888{ 900{
889 catMenu->clear(); 901 catMenu->clear();
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index e2a7100..31c4660 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -31,6 +31,7 @@ class QToolButton;
31class QDialog; 31class QDialog;
32class Ir; 32class Ir;
33class QAction; 33class QAction;
34class LetterPicker;
34 35
35class AddressbookWindow: public QMainWindow 36class AddressbookWindow: public QMainWindow
36{ 37{
@@ -69,6 +70,7 @@ private slots:
69 void beamDone( Ir * ); 70 void beamDone( Ir * );
70 void slotFind(); 71 void slotFind();
71 void slotSetCategory( int ); 72 void slotSetCategory( int );
73 void slotSetLetter( char );
72 void slotUpdateToolbar(); 74 void slotUpdateToolbar();
73 void slotSetFont(int); 75 void slotSetFont(int);
74private: 76private:
@@ -85,6 +87,7 @@ private:
85 enum Panes { paneList=0, paneView, paneEdit }; 87 enum Panes { paneList=0, paneView, paneEdit };
86 ContactEditor *abEditor; 88 ContactEditor *abEditor;
87 AbLabel *mView; 89 AbLabel *mView;
90 LetterPicker *pLabel;
88 AbTable *abList; 91 AbTable *abList;
89 92
90 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, 93 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro
index 53cf030..0d65c74 100644
--- a/core/pim/addressbook/addressbook.pro
+++ b/core/pim/addressbook/addressbook.pro
@@ -5,13 +5,15 @@ HEADERS = addressbook.h \
5 contacteditor.h \ 5 contacteditor.h \
6 ablabel.h \ 6 ablabel.h \
7 abtable.h \ 7 abtable.h \
8 addresssettings.h 8 addresssettings.h \
9 picker.h
9 SOURCES= main.cpp \ 10 SOURCES= main.cpp \
10 addressbook.cpp \ 11 addressbook.cpp \
11 contacteditor.cpp \ 12 contacteditor.cpp \
12 ablabel.cpp \ 13 ablabel.cpp \
13 abtable.cpp \ 14 abtable.cpp \
14 addresssettings.cpp 15 addresssettings.cpp \
16 picker.cpp
15 INTERFACES= addresssettingsbase.ui 17 INTERFACES= addresssettingsbase.ui
16 18
17 TARGET = addressbook 19 TARGET = addressbook
diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp
new file mode 100644
index 0000000..06dcc7d
--- a/dev/null
+++ b/core/pim/addressbook/picker.cpp
@@ -0,0 +1,234 @@
1#include "picker.h"
2
3#include <qfont.h>
4#include <qstring.h>
5#include <qtimer.h>
6#include <qlayout.h>
7
8char PickerLabel::lastLetter = '\0';
9
10PickerLabel::PickerLabel( QWidget *parent, const char *name )
11 : QLabel ( parent, name )
12{
13 currentLetter = 0;
14 //lastLetter = 0;
15
16 letter1 = '\0';
17 letter2 = '\0';
18 letter3 = '\0';
19
20 setFont( QFont( "smallsmooth", 9 ) );
21 setTextFormat( Qt::RichText );
22
23}
24
25PickerLabel::~PickerLabel()
26{
27
28}
29
30void PickerLabel::setLetters( char ch1, char ch2, char ch3 )
31{
32 QString tmpStr;
33
34 if (ch1 != '\0')
35 letter1 = ch1;
36 else
37 letter1 = ' ';
38
39 if (ch2 != '\0')
40 letter2 = ch2;
41 else
42 letter2 = ' ';
43
44 if (ch3 != '\0')
45 letter3 = ch3;
46 else
47 letter3 = ' ';
48
49 tmpStr = "<qt>";
50 tmpStr += letter1;
51 tmpStr += letter2;
52 tmpStr += letter3;
53 tmpStr += "</qt>";
54
55 setText(tmpStr);
56
57 currentLetter = 0;
58
59}
60
61void PickerLabel::clearLetter()
62{
63
64 QString tmpStr;
65
66 tmpStr = "<qt>";
67 tmpStr += letter1;
68 tmpStr += letter2;
69 tmpStr += letter3;
70 tmpStr += "</qt>";
71
72 setText(tmpStr);
73
74 currentLetter = 0;
75
76}
77
78void PickerLabel::mouseReleaseEvent( QMouseEvent *e )
79{
80 QString tmpStr;
81
82 if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3)
83 QTimer::singleShot( 0, this, SLOT(emitClearSignal()) );
84
85 qDebug( "a" );
86 switch (currentLetter) {
87 case 0:
88 tmpStr = "<qt><font color=\"#7F0000\">";
89 tmpStr += letter1;
90 tmpStr += "</font>";
91 tmpStr += letter2;
92 tmpStr += letter3;
93 tmpStr += "</qt>";
94
95 setText(tmpStr);
96
97 currentLetter++;
98 lastLetter = letter1;
99 emit selectedLetter( letter1 );
100 qDebug( "PickerLabel::mouseReleaseEvent %c", letter1 );
101 break;
102
103 case 1:
104 tmpStr = "<qt>";
105 tmpStr += letter1;
106 tmpStr += "<font color=\"#7F0000\">";
107 tmpStr += letter2;
108 tmpStr += "</font>";
109 tmpStr += letter3;
110 tmpStr += "</qt>";
111
112 setText(tmpStr);
113
114 currentLetter++;
115 lastLetter = letter2;
116 emit selectedLetter( letter2 );
117 qDebug( "PickerLabel::mouseReleaseEvent %c", letter2 );
118 break;
119
120 case 2:
121 tmpStr = "<qt>";
122 tmpStr += letter1;
123 tmpStr += letter2;
124 tmpStr += "<font color=\"#7F0000\">";
125 tmpStr += letter3;
126 tmpStr += "</font></qt>";
127
128 setText(tmpStr);
129
130 currentLetter++;
131 lastLetter = letter3;
132 emit selectedLetter( letter3 );
133 qDebug( "PickerLabel::mouseReleaseEvent %c", letter3 );
134 break;
135
136 default:
137 clearLetter();
138 lastLetter = '\0';
139 emit selectedLetter( '\0' );
140
141
142 }
143}
144
145void PickerLabel::emitClearSignal() {
146 emit clearAll();
147}
148
149LetterPicker::LetterPicker( QWidget *parent, const char *name )
150 : QFrame( parent, name )
151{
152 QHBoxLayout *l = new QHBoxLayout(this);
153
154 lblABC = new PickerLabel( this );
155 l->addWidget( lblABC );
156
157 lblDEF = new PickerLabel( this );
158 l->addWidget( lblDEF );
159
160 lblGHI = new PickerLabel( this );
161 l->addWidget( lblGHI );
162
163 lblJKL = new PickerLabel( this );
164 l->addWidget( lblJKL );
165
166 lblMNO = new PickerLabel( this );
167 l->addWidget( lblMNO );
168
169 lblPQR = new PickerLabel( this );
170 l->addWidget( lblPQR );
171
172 lblSTU = new PickerLabel( this );
173 l->addWidget( lblSTU );
174
175 lblVWX = new PickerLabel( this );
176 l->addWidget( lblVWX );
177
178 lblYZ = new PickerLabel( this );
179 l->addWidget( lblYZ );
180
181 lblABC->setLetters( 'A', 'B', 'C' );
182 lblDEF->setLetters( 'D', 'E', 'F' );
183 lblGHI->setLetters( 'G', 'H', 'I' );
184 lblJKL->setLetters( 'J', 'K', 'L' );
185 lblMNO->setLetters( 'M', 'N', 'O' );
186 lblPQR->setLetters( 'P', 'Q', 'R' );
187 lblSTU->setLetters( 'S', 'T', 'U' );
188 lblVWX->setLetters( 'V', 'W', 'X' );
189 lblYZ->setLetters( 'Y', 'Z', '#' );
190
191 connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
192 connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
193 connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
194 connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
195 connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
196 connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
197 connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
198 connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
199 connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
200 connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear()));
201 connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear()));
202 connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear()));
203 connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear()));
204 connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear()));
205 connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear()));
206 connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear()));
207 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear()));
208 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear()));
209
210}
211
212LetterPicker::~LetterPicker()
213{
214}
215
216void LetterPicker::clear()
217{
218 lblABC->clearLetter();
219 lblDEF->clearLetter();
220 lblGHI->clearLetter();
221 lblJKL->clearLetter();
222 lblMNO->clearLetter();
223 lblPQR->clearLetter();
224 lblSTU->clearLetter();
225 lblVWX->clearLetter();
226 lblYZ->clearLetter();
227}
228
229void LetterPicker::newLetter( char letter )
230{
231 qDebug( "LetterPicker::newLetter %c", letter );
232 emit letterClicked( letter );
233
234}
diff --git a/core/pim/addressbook/picker.h b/core/pim/addressbook/picker.h
new file mode 100644
index 0000000..de5bd9d
--- a/dev/null
+++ b/core/pim/addressbook/picker.h
@@ -0,0 +1,65 @@
1/*
2 * Letter Chooser Widget.
3 *
4 * (c) 2002 Mike Crawford
5 *
6 * This file is FREE SOFTWARE covered under the GUN General Public License.
7 *
8 *
9*/
10#ifndef PICKER_H
11#define PICKER_H
12
13#include <qlabel.h>
14#include <qframe.h>
15#include <qevent.h>
16
17class PickerLabel: public QLabel {
18Q_OBJECT
19 public:
20 PickerLabel( QWidget *parent = 0, const char *name = 0 );
21 ~PickerLabel();
22
23 void setLetters( char ch1, char ch2, char ch3 );
24 void clearLetter();
25
26 signals:
27
28 void selectedLetter( char );
29 void clearAll();
30
31 protected:
32
33 void mouseReleaseEvent( QMouseEvent *e );
34
35 private:
36
37 int currentLetter;
38 static char lastLetter;
39 char letter1, letter2, letter3;
40
41 private slots:
42
43 void emitClearSignal();
44
45};
46class LetterPicker: public QFrame {
47Q_OBJECT
48 public:
49 LetterPicker( QWidget *parent = 0, const char *name = 0 );
50 ~LetterPicker();
51
52 public slots:
53 void clear();
54
55 signals:
56 void letterClicked( char );
57
58 private:
59 PickerLabel *lblABC, *lblDEF, *lblGHI, *lblJKL, *lblMNO, *lblPQR, *lblSTU, *lblVWX, *lblYZ;
60
61 private slots:
62 void newLetter( char letter );
63};
64
65#endif