author | tux_mike <tux_mike> | 2002-04-17 19:45:48 (UTC) |
---|---|---|
committer | tux_mike <tux_mike> | 2002-04-17 19:45:48 (UTC) |
commit | c2c343110573bd8b4d59fbff577969ff23d5c544 (patch) (unidiff) | |
tree | 79cff133d04fa7df83783482e27557191ee2e199 /core | |
parent | b94bcfb586b838885d7d0503623ea36ee0054464 (diff) | |
download | opie-c2c343110573bd8b4d59fbff577969ff23d5c544.zip opie-c2c343110573bd8b4d59fbff577969ff23d5c544.tar.gz opie-c2c343110573bd8b4d59fbff577969ff23d5c544.tar.bz2 |
Added preliminary version of the Picker
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 26 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 2 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 12 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 3 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.pro | 6 | ||||
-rw-r--r-- | core/pim/addressbook/picker.cpp | 234 | ||||
-rw-r--r-- | core/pim/addressbook/picker.h | 65 |
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 | |||
@@ -129,48 +129,49 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam | |||
129 | // : QTable( 0, 0, parent, name, TRUE ), | 129 | // : QTable( 0, 0, parent, name, TRUE ), |
130 | // #else | 130 | // #else |
131 | : QTable( parent, name ), | 131 | : QTable( parent, name ), |
132 | // #endif | 132 | // #endif |
133 | lastSortCol( -1 ), | 133 | lastSortCol( -1 ), |
134 | asc( TRUE ), | 134 | asc( TRUE ), |
135 | intFields( order ), | 135 | intFields( order ), |
136 | currFindRow( -2 ), | 136 | currFindRow( -2 ), |
137 | mCat( 0 ) | 137 | mCat( 0 ) |
138 | { | 138 | { |
139 | mCat.load( categoryFileName() ); | 139 | mCat.load( categoryFileName() ); |
140 | setSelectionMode( NoSelection ); | 140 | setSelectionMode( NoSelection ); |
141 | init(); | 141 | init(); |
142 | setSorting( TRUE ); | 142 | setSorting( TRUE ); |
143 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 143 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
144 | this, SLOT(itemClicked(int,int)) ); | 144 | this, SLOT(itemClicked(int,int)) ); |
145 | } | 145 | } |
146 | 146 | ||
147 | AbTable::~AbTable() | 147 | AbTable::~AbTable() |
148 | { | 148 | { |
149 | } | 149 | } |
150 | 150 | ||
151 | void AbTable::init() | 151 | void AbTable::init() |
152 | { | 152 | { |
153 | showChar = '\0'; | ||
153 | setNumRows( 0 ); | 154 | setNumRows( 0 ); |
154 | setNumCols( 2 ); | 155 | setNumCols( 2 ); |
155 | 156 | ||
156 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 157 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
157 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 158 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
158 | setLeftMargin( 0 ); | 159 | setLeftMargin( 0 ); |
159 | verticalHeader()->hide(); | 160 | verticalHeader()->hide(); |
160 | } | 161 | } |
161 | 162 | ||
162 | void AbTable::columnClicked( int col ) | 163 | void AbTable::columnClicked( int col ) |
163 | { | 164 | { |
164 | if ( !sorting() ) | 165 | if ( !sorting() ) |
165 | return; | 166 | return; |
166 | 167 | ||
167 | if ( lastSortCol == -1 ) | 168 | if ( lastSortCol == -1 ) |
168 | lastSortCol = col; | 169 | lastSortCol = col; |
169 | 170 | ||
170 | if ( col == lastSortCol ) { | 171 | if ( col == lastSortCol ) { |
171 | asc = !asc; | 172 | asc = !asc; |
172 | } else { | 173 | } else { |
173 | lastSortCol = col; | 174 | lastSortCol = col; |
174 | asc = TRUE; | 175 | asc = TRUE; |
175 | } | 176 | } |
176 | resort(); | 177 | resort(); |
@@ -431,54 +432,55 @@ QString AbTable::findContactContact( const Contact &entry ) | |||
431 | case Qtopia::Children: | 432 | case Qtopia::Children: |
432 | value = entry.children(); | 433 | value = entry.children(); |
433 | break; | 434 | break; |
434 | case Qtopia::Notes: | 435 | case Qtopia::Notes: |
435 | value = entry.notes(); | 436 | value = entry.notes(); |
436 | break; | 437 | break; |
437 | } | 438 | } |
438 | if ( !value.isEmpty() ) | 439 | if ( !value.isEmpty() ) |
439 | break; | 440 | break; |
440 | } | 441 | } |
441 | return value; | 442 | return value; |
442 | } | 443 | } |
443 | 444 | ||
444 | void AbTable::addEntry( const Contact &newCnt ) | 445 | void AbTable::addEntry( const Contact &newCnt ) |
445 | { | 446 | { |
446 | int row = numRows(); | 447 | int row = numRows(); |
447 | setNumRows( row + 1 ); | 448 | setNumRows( row + 1 ); |
448 | updateJournal( newCnt, Contact::ACTION_ADD ); | 449 | updateJournal( newCnt, Contact::ACTION_ADD ); |
449 | insertIntoTable( newCnt, row ); | 450 | insertIntoTable( newCnt, row ); |
450 | setCurrentCell( row, 0 ); | 451 | setCurrentCell( row, 0 ); |
451 | updateVisible(); | 452 | updateVisible(); |
452 | } | 453 | } |
453 | 454 | ||
454 | void AbTable::resizeRows( int size ) { | 455 | void 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 | ||
463 | void AbTable::updateJournal( const Contact &cnt, | 465 | void AbTable::updateJournal( const Contact &cnt, |
464 | Contact::journal_action action, int row ) | 466 | Contact::journal_action action, int row ) |
465 | { | 467 | { |
466 | QFile f( journalFileName() ); | 468 | QFile f( journalFileName() ); |
467 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 469 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
468 | return; | 470 | return; |
469 | QString buf; | 471 | QString buf; |
470 | QCString str; | 472 | QCString str; |
471 | buf = "<Contact "; | 473 | buf = "<Contact "; |
472 | cnt.save( buf ); | 474 | cnt.save( buf ); |
473 | buf += " action=\"" + QString::number( (int)action ) + "\" "; | 475 | buf += " action=\"" + QString::number( (int)action ) + "\" "; |
474 | if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE) | 476 | if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE) |
475 | buf += " actionrow=\"" + QString::number(row) + "\" "; | 477 | buf += " actionrow=\"" + QString::number(row) + "\" "; |
476 | buf += "/>\n"; | 478 | buf += "/>\n"; |
477 | QCString cstr = buf.utf8(); | 479 | QCString cstr = buf.utf8(); |
478 | f.writeBlock( cstr.data(), cstr.length() ); | 480 | f.writeBlock( cstr.data(), cstr.length() ); |
479 | QCopEnvelope( "QPE/PIM", "addressbookUpdated()" ); | 481 | QCopEnvelope( "QPE/PIM", "addressbookUpdated()" ); |
480 | } | 482 | } |
481 | 483 | ||
482 | bool AbTable::save( const QString &fn ) | 484 | bool AbTable::save( const QString &fn ) |
483 | { | 485 | { |
484 | // QTime t; | 486 | // QTime t; |
@@ -987,102 +989,122 @@ void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | |||
987 | 989 | ||
988 | QStringList AbTable::choiceSelection(int /*index*/) const | 990 | QStringList AbTable::choiceSelection(int /*index*/) const |
989 | { | 991 | { |
990 | QStringList r; | 992 | QStringList r; |
991 | /* ###### | 993 | /* ###### |
992 | 994 | ||
993 | QString selname = choicenames.at(index); | 995 | QString selname = choicenames.at(index); |
994 | for (each row) { | 996 | for (each row) { |
995 | Contact *c = contactForRow(row); | 997 | Contact *c = contactForRow(row); |
996 | if ( text(row,2) == selname ) { | 998 | if ( text(row,2) == selname ) { |
997 | r.append(c->email); | 999 | r.append(c->email); |
998 | } | 1000 | } |
999 | } | 1001 | } |
1000 | 1002 | ||
1001 | */ | 1003 | */ |
1002 | return r; | 1004 | return r; |
1003 | } | 1005 | } |
1004 | 1006 | ||
1005 | void AbTable::setShowCategory( const QString &c ) | 1007 | void AbTable::setShowCategory( const QString &c ) |
1006 | { | 1008 | { |
1007 | showCat = c; | 1009 | showCat = c; |
1008 | updateVisible(); | 1010 | updateVisible(); |
1009 | } | 1011 | } |
1010 | 1012 | ||
1013 | void AbTable::setShowByLetter( char c ) | ||
1014 | { | ||
1015 | showChar = tolower(c); | ||
1016 | qDebug( "AbTable::setShowByLetter %c", showChar); | ||
1017 | updateVisible(); | ||
1018 | } | ||
1019 | |||
1011 | QString AbTable::showCategory() const | 1020 | QString AbTable::showCategory() const |
1012 | { | 1021 | { |
1013 | return showCat; | 1022 | return showCat; |
1014 | } | 1023 | } |
1015 | 1024 | ||
1016 | 1025 | ||
1017 | QStringList AbTable::categories() | 1026 | QStringList AbTable::categories() |
1018 | { | 1027 | { |
1019 | mCat.load( categoryFileName() ); | 1028 | mCat.load( categoryFileName() ); |
1020 | QStringList categoryList = mCat.labels( "Contacts" ); | 1029 | QStringList categoryList = mCat.labels( "Contacts" ); |
1021 | return categoryList; | 1030 | return categoryList; |
1022 | } | 1031 | } |
1023 | 1032 | ||
1024 | void AbTable::updateVisible() | 1033 | void AbTable::updateVisible() |
1025 | { | 1034 | { |
1026 | int visible, | 1035 | int visible, |
1027 | totalRows, | 1036 | totalRows, |
1028 | id, | 1037 | id, |
1029 | totalCats, | 1038 | totalCats, |
1030 | it, | 1039 | it, |
1031 | row; | 1040 | row; |
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 ); |
1038 | 1049 | ||
1039 | totalRows = numRows(); | 1050 | totalRows = numRows(); |
1040 | id = mCat.id( "Contacts", showCat ); | 1051 | id = mCat.id( "Contacts", showCat ); |
1041 | QArray<int> cats; | 1052 | QArray<int> cats; |
1042 | for ( row = 0; row < totalRows; row++ ) { | 1053 | for ( row = 0; row < totalRows; row++ ) { |
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" ) ) { |
1049 | if ( cats.count() > 0 ) | 1061 | if ( cats.count() > 0 ) |
1050 | hide = true; | 1062 | hide = true; |
1051 | } else { | 1063 | } else { |
1052 | // do some comparing | 1064 | // do some comparing |
1053 | if ( !hide ) { | 1065 | if ( !hide ) { |
1054 | hide = true; | 1066 | hide = true; |
1055 | totalCats = int(cats.count()); | 1067 | totalCats = int(cats.count()); |
1056 | for ( it = 0; it < totalCats; it++ ) { | 1068 | for ( it = 0; it < totalCats; it++ ) { |
1057 | if ( cats[it] == id ) { | 1069 | if ( cats[it] == id ) { |
1058 | hide = false; | 1070 | hide = false; |
1059 | break; | 1071 | break; |
1060 | } | 1072 | } |
1061 | } | 1073 | } |
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 ); |
1068 | if ( rowHeight(row) > 0 ) | 1090 | if ( rowHeight(row) > 0 ) |
1069 | hideRow( row ); | 1091 | hideRow( row ); |
1070 | } else { | 1092 | } else { |
1071 | if ( rowHeight(row) == 0 ) { | 1093 | if ( rowHeight(row) == 0 ) { |
1072 | showRow( row ); | 1094 | showRow( row ); |
1073 | adjustRow( row ); | 1095 | adjustRow( row ); |
1074 | } | 1096 | } |
1075 | visible++; | 1097 | visible++; |
1076 | } | 1098 | } |
1077 | } | 1099 | } |
1078 | if ( !visible ) | 1100 | if ( !visible ) |
1079 | setCurrentCell( -1, 0 ); | 1101 | setCurrentCell( -1, 0 ); |
1080 | 1102 | ||
1081 | setPaintingEnabled( TRUE ); | 1103 | setPaintingEnabled( TRUE ); |
1082 | } | 1104 | } |
1083 | 1105 | ||
1084 | 1106 | ||
1085 | void AbTable::setPaintingEnabled( bool e ) | 1107 | void AbTable::setPaintingEnabled( bool e ) |
1086 | { | 1108 | { |
1087 | if ( e != enablePainting ) { | 1109 | if ( e != enablePainting ) { |
1088 | if ( !enablePainting ) { | 1110 | if ( !enablePainting ) { |
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 | |||
@@ -63,79 +63,81 @@ class AbTable : public QTable | |||
63 | public: | 63 | public: |
64 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); | 64 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); |
65 | ~AbTable(); | 65 | ~AbTable(); |
66 | // NEW | 66 | // NEW |
67 | void addEntry( const Contact &newContact ); | 67 | void addEntry( const Contact &newContact ); |
68 | Contact currentEntry(); | 68 | Contact currentEntry(); |
69 | void replaceCurrentEntry( const Contact &newContact ); | 69 | void replaceCurrentEntry( const Contact &newContact ); |
70 | 70 | ||
71 | void init(); | 71 | void init(); |
72 | 72 | ||
73 | void deleteCurrentEntry(); | 73 | void deleteCurrentEntry(); |
74 | void clear(); | 74 | void clear(); |
75 | void clearFindRow() { currFindRow = -2; } | 75 | void clearFindRow() { currFindRow = -2; } |
76 | void loadFields(); | 76 | void loadFields(); |
77 | void refresh(); | 77 | void refresh(); |
78 | bool save( const QString &fn ); | 78 | bool save( const QString &fn ); |
79 | void load( const QString &fn ); | 79 | void load( const QString &fn ); |
80 | 80 | ||
81 | // addresspicker mode | 81 | // addresspicker mode |
82 | void setChoiceNames( const QStringList& list); | 82 | void setChoiceNames( const QStringList& list); |
83 | QStringList choiceNames() const; | 83 | QStringList choiceNames() const; |
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 ); |
90 | 91 | ||
91 | void show(); | 92 | void show(); |
92 | void setPaintingEnabled( bool e ); | 93 | void setPaintingEnabled( bool e ); |
93 | 94 | ||
94 | public slots: | 95 | public slots: |
95 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, | 96 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, |
96 | int category ); | 97 | int category ); |
97 | signals: | 98 | signals: |
98 | void empty( bool ); | 99 | void empty( bool ); |
99 | void details(); | 100 | void details(); |
100 | void signalNotFound(); | 101 | void signalNotFound(); |
101 | void signalWrapAround(); | 102 | void signalWrapAround(); |
102 | 103 | ||
103 | protected: | 104 | protected: |
104 | virtual void keyPressEvent( QKeyEvent *e ); | 105 | virtual void keyPressEvent( QKeyEvent *e ); |
105 | 106 | ||
106 | // int rowHeight( int ) const; | 107 | // int rowHeight( int ) const; |
107 | // int rowPos( int row ) const; | 108 | // int rowPos( int row ) const; |
108 | // virtual int rowAt( int pos ) const; | 109 | // virtual int rowAt( int pos ) const; |
109 | 110 | ||
110 | 111 | ||
111 | protected slots: | 112 | protected slots: |
112 | void moveTo( char ); | 113 | void moveTo( char ); |
113 | virtual void columnClicked( int col ); | 114 | virtual void columnClicked( int col ); |
114 | void itemClicked(int,int col); | 115 | void itemClicked(int,int col); |
115 | void rowHeightChanged( int row ); | 116 | void rowHeightChanged( int row ); |
116 | 117 | ||
117 | private: | 118 | private: |
118 | void loadFile( const QString &strFile, bool journalFile ); | 119 | void loadFile( const QString &strFile, bool journalFile ); |
119 | void fitColumns(); | 120 | void fitColumns(); |
120 | void resort(); | 121 | void resort(); |
121 | void updateJournal( const Contact &contact, Contact::journal_action action, | 122 | void updateJournal( const Contact &contact, Contact::journal_action action, |
122 | int row = -1 ); | 123 | int row = -1 ); |
123 | void insertIntoTable( const Contact &contact, int row ); | 124 | void insertIntoTable( const Contact &contact, int row ); |
124 | void internalAddEntries( QList<Contact> &list ); | 125 | void internalAddEntries( QList<Contact> &list ); |
125 | QString findContactName( const Contact &entry ); | 126 | QString findContactName( const Contact &entry ); |
126 | QString findContactContact( const Contact &entry ); | 127 | QString findContactContact( const Contact &entry ); |
127 | void journalFreeReplace( const Contact &cnt, int row ); | 128 | void journalFreeReplace( const Contact &cnt, int row ); |
128 | void journalFreeRemove( int row ); | 129 | void journalFreeRemove( int row ); |
129 | void realignTable( int ); | 130 | void realignTable( int ); |
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; |
136 | QString showCat; | 138 | QString showCat; |
137 | QStringList choicenames; | 139 | QStringList choicenames; |
138 | bool enablePainting; | 140 | bool enablePainting; |
139 | Categories mCat; | 141 | Categories mCat; |
140 | }; | 142 | }; |
141 | #endif // ABTABLE_H | 143 | #endif // ABTABLE_H |
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 | |||
@@ -42,83 +42,85 @@ | |||
42 | 42 | ||
43 | #include <qaction.h> | 43 | #include <qaction.h> |
44 | #include <qdialog.h> | 44 | #include <qdialog.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qfile.h> | 46 | #include <qfile.h> |
47 | #include <qimage.h> | 47 | #include <qimage.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qpe/qpemenubar.h> | 49 | #include <qpe/qpemenubar.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qpixmap.h> | 51 | #include <qpixmap.h> |
52 | #include <qpopupmenu.h> | 52 | #include <qpopupmenu.h> |
53 | #include <qpe/qpetoolbar.h> | 53 | #include <qpe/qpetoolbar.h> |
54 | #include <qstringlist.h> | 54 | #include <qstringlist.h> |
55 | #include <qtoolbutton.h> | 55 | #include <qtoolbutton.h> |
56 | #include <qwhatsthis.h> | 56 | #include <qwhatsthis.h> |
57 | 57 | ||
58 | #include <stdlib.h> | 58 | #include <stdlib.h> |
59 | #include <sys/stat.h> | 59 | #include <sys/stat.h> |
60 | #include <sys/types.h> | 60 | #include <sys/types.h> |
61 | #include <fcntl.h> | 61 | #include <fcntl.h> |
62 | #include <unistd.h> | 62 | #include <unistd.h> |
63 | 63 | ||
64 | #include <qdatetime.h> | 64 | #include <qdatetime.h> |
65 | 65 | ||
66 | #include "picker.h" | ||
66 | static QString addressbookOldXMLFilename() | 67 | static QString addressbookOldXMLFilename() |
67 | { | 68 | { |
68 | QString filename = QPEApplication::documentDir() + "addressbook.xml"; | 69 | QString filename = QPEApplication::documentDir() + "addressbook.xml"; |
69 | return filename; | 70 | return filename; |
70 | } | 71 | } |
71 | 72 | ||
72 | static QString addressbookXMLFilename() | 73 | static QString addressbookXMLFilename() |
73 | { | 74 | { |
74 | QString filename = Global::applicationFileName("addressbook", | 75 | QString filename = Global::applicationFileName("addressbook", |
75 | "addressbook.xml"); | 76 | "addressbook.xml"); |
76 | return filename; | 77 | return filename; |
77 | } | 78 | } |
78 | 79 | ||
79 | static QString addressbookPersonalVCardName() | 80 | static QString addressbookPersonalVCardName() |
80 | { | 81 | { |
81 | QString filename = Global::applicationFileName("addressbook", | 82 | QString filename = Global::applicationFileName("addressbook", |
82 | "businesscard.vcf"); | 83 | "businesscard.vcf"); |
83 | return filename; | 84 | return filename; |
84 | } | 85 | } |
85 | 86 | ||
86 | 87 | ||
87 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 88 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
88 | WFlags f ) | 89 | WFlags f ) |
89 | : QMainWindow( parent, name, f ), | 90 | : QMainWindow( parent, name, f ), |
90 | abEditor(0), | 91 | abEditor(0), |
91 | bAbEditFirstTime(TRUE), | 92 | bAbEditFirstTime(TRUE), |
92 | syncing(FALSE) | 93 | syncing(FALSE) |
93 | { | 94 | { |
94 | initFields(); | 95 | initFields(); |
95 | 96 | ||
96 | setCaption( tr("Contacts") ); | 97 | setCaption( tr("Contacts") ); |
97 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 98 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
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 ); |
104 | bar->setHorizontalStretchable( TRUE ); | 106 | bar->setHorizontalStretchable( TRUE ); |
105 | 107 | ||
106 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 108 | QPEMenuBar *mbList = new QPEMenuBar( bar ); |
107 | mbList->setMargin( 0 ); | 109 | mbList->setMargin( 0 ); |
108 | 110 | ||
109 | QPopupMenu *edit = new QPopupMenu( this ); | 111 | QPopupMenu *edit = new QPopupMenu( this ); |
110 | mbList->insertItem( tr( "Contact" ), edit ); | 112 | mbList->insertItem( tr( "Contact" ), edit ); |
111 | 113 | ||
112 | listTools = new QPEToolBar( this, "list operations" ); | 114 | listTools = new QPEToolBar( this, "list operations" ); |
113 | 115 | ||
114 | 116 | ||
115 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 117 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
116 | 0, this, 0 ); | 118 | 0, this, 0 ); |
117 | actionNew = a; | 119 | actionNew = a; |
118 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 120 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
119 | a->addTo( edit ); | 121 | a->addTo( edit ); |
120 | a->addTo( listTools ); | 122 | a->addTo( listTools ); |
121 | 123 | ||
122 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 124 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
123 | 0, this, 0 ); | 125 | 0, this, 0 ); |
124 | actionEdit = a; | 126 | actionEdit = a; |
@@ -168,64 +170,68 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
168 | actionPersonal = a; | 170 | actionPersonal = a; |
169 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 171 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
170 | a->addTo( edit ); | 172 | a->addTo( edit ); |
171 | 173 | ||
172 | 174 | ||
173 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | 175 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); |
174 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 176 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
175 | a->addTo( edit ); | 177 | a->addTo( edit ); |
176 | 178 | ||
177 | // Create Views | 179 | // Create Views |
178 | 180 | ||
179 | // This is safe to call without checking to see if it exists... | 181 | // This is safe to call without checking to see if it exists... |
180 | // not to mention it also does the necessary stuff for the | 182 | // not to mention it also does the necessary stuff for the |
181 | // journaling... | 183 | // journaling... |
182 | QString str = addressbookXMLFilename(); | 184 | QString str = addressbookXMLFilename(); |
183 | if ( str.isNull() ) { | 185 | if ( str.isNull() ) { |
184 | QMessageBox::warning( this, tr("Out of Space"), | 186 | QMessageBox::warning( this, tr("Out of Space"), |
185 | tr("There is not enough space to create\n" | 187 | tr("There is not enough space to create\n" |
186 | "neccessary startup files.\n" | 188 | "neccessary startup files.\n" |
187 | "\nFree up some space before\nentering data!") | 189 | "\nFree up some space before\nentering data!") |
188 | ); | 190 | ); |
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 ) ) ); |
195 | connect( abList, SIGNAL( details() ), | 198 | connect( abList, SIGNAL( details() ), |
196 | this, SLOT( slotListView() ) ); | 199 | this, SLOT( slotListView() ) ); |
197 | connect( abList, SIGNAL(currentChanged(int,int)), | 200 | connect( abList, SIGNAL(currentChanged(int,int)), |
198 | this, SLOT(slotUpdateToolbar()) ); | 201 | this, SLOT(slotUpdateToolbar()) ); |
199 | 202 | ||
200 | mView = 0; | 203 | mView = 0; |
201 | 204 | ||
202 | abList->load( addressbookXMLFilename() ); | 205 | abList->load( addressbookXMLFilename() ); |
203 | if ( QFile::exists(addressbookOldXMLFilename()) ) { | 206 | if ( QFile::exists(addressbookOldXMLFilename()) ) { |
204 | abList->load( addressbookOldXMLFilename() ); | 207 | abList->load( addressbookOldXMLFilename() ); |
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)) ); |
211 | populateCategories(); | 217 | populateCategories(); |
212 | 218 | ||
213 | mbList->insertItem( tr("View"), catMenu ); | 219 | mbList->insertItem( tr("View"), catMenu ); |
214 | setCentralWidget( abList ); | 220 | setCentralWidget( abList ); |
215 | 221 | ||
216 | fontMenu = new QPopupMenu(this); | 222 | fontMenu = new QPopupMenu(this); |
217 | fontMenu->setCheckable( true ); | 223 | fontMenu->setCheckable( true ); |
218 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); | 224 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); |
219 | 225 | ||
220 | fontMenu->insertItem(tr( "Small" ), 0); | 226 | fontMenu->insertItem(tr( "Small" ), 0); |
221 | fontMenu->insertItem(tr( "Normal" ), 1); | 227 | fontMenu->insertItem(tr( "Normal" ), 1); |
222 | fontMenu->insertItem(tr( "Large" ), 2); | 228 | fontMenu->insertItem(tr( "Large" ), 2); |
223 | 229 | ||
224 | defaultFont = new QFont( abList->font() ); | 230 | defaultFont = new QFont( abList->font() ); |
225 | 231 | ||
226 | slotSetFont(startFontSize); | 232 | slotSetFont(startFontSize); |
227 | 233 | ||
228 | mbList->insertItem( tr("Font"), fontMenu); | 234 | mbList->insertItem( tr("Font"), fontMenu); |
229 | setCentralWidget(abList); | 235 | setCentralWidget(abList); |
230 | 236 | ||
231 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 237 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
@@ -863,46 +869,52 @@ void AddressbookWindow::slotFind() | |||
863 | 869 | ||
864 | abList->clearFindRow(); | 870 | abList->clearFindRow(); |
865 | #endif | 871 | #endif |
866 | } | 872 | } |
867 | 873 | ||
868 | void AddressbookWindow::slotSetCategory( int c ) | 874 | void AddressbookWindow::slotSetCategory( int c ) |
869 | { | 875 | { |
870 | if ( c <= 0 ) | 876 | if ( c <= 0 ) |
871 | return; | 877 | return; |
872 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 878 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
873 | catMenu->setItemChecked( i, c == (int)i ); | 879 | catMenu->setItemChecked( i, c == (int)i ); |
874 | if ( c == 1 ) { | 880 | if ( c == 1 ) { |
875 | abList->setShowCategory( QString::null ); | 881 | abList->setShowCategory( QString::null ); |
876 | setCaption( tr("Contacts") + " - " + tr ( "All" ) ); | 882 | setCaption( tr("Contacts") + " - " + tr ( "All" ) ); |
877 | } else if ( c == (int)catMenu->count() ) { | 883 | } else if ( c == (int)catMenu->count() ) { |
878 | abList->setShowCategory( tr( "Unfiled" ) ); | 884 | abList->setShowCategory( tr( "Unfiled" ) ); |
879 | setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); | 885 | setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); |
880 | } else { | 886 | } else { |
881 | QString cat = abList->categories()[c - 2]; | 887 | QString cat = abList->categories()[c - 2]; |
882 | abList->setShowCategory( cat ); | 888 | abList->setShowCategory( cat ); |
883 | setCaption( tr("Contacts") + " - " + cat ); | 889 | setCaption( tr("Contacts") + " - " + cat ); |
884 | } | 890 | } |
885 | } | 891 | } |
886 | 892 | ||
893 | void AddressbookWindow::slotSetLetter( char c ) { | ||
894 | |||
895 | abList->setShowByLetter( c ); | ||
896 | |||
897 | } | ||
898 | |||
887 | void AddressbookWindow::populateCategories() | 899 | void AddressbookWindow::populateCategories() |
888 | { | 900 | { |
889 | catMenu->clear(); | 901 | catMenu->clear(); |
890 | 902 | ||
891 | int id, | 903 | int id, |
892 | rememberId; | 904 | rememberId; |
893 | id = 1; | 905 | id = 1; |
894 | catMenu->insertItem( tr( "All" ), id++ ); | 906 | catMenu->insertItem( tr( "All" ), id++ ); |
895 | QStringList categories = abList->categories(); | 907 | QStringList categories = abList->categories(); |
896 | categories.append( tr( "Unfiled" ) ); | 908 | categories.append( tr( "Unfiled" ) ); |
897 | for ( QStringList::Iterator it = categories.begin(); | 909 | for ( QStringList::Iterator it = categories.begin(); |
898 | it != categories.end(); ++it ) { | 910 | it != categories.end(); ++it ) { |
899 | catMenu->insertItem( *it, id ); | 911 | catMenu->insertItem( *it, id ); |
900 | if ( *it == abList->showCategory() ) | 912 | if ( *it == abList->showCategory() ) |
901 | rememberId = id; | 913 | rememberId = id; |
902 | ++id; | 914 | ++id; |
903 | } | 915 | } |
904 | if ( abList->showCategory().isEmpty() ) | 916 | if ( abList->showCategory().isEmpty() ) |
905 | slotSetCategory( 1 ); | 917 | slotSetCategory( 1 ); |
906 | else | 918 | else |
907 | slotSetCategory( rememberId ); | 919 | slotSetCategory( rememberId ); |
908 | } | 920 | } |
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 | |||
@@ -10,92 +10,95 @@ | |||
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef Addressbook_H | 20 | #ifndef Addressbook_H |
21 | #define Addressbook_H | 21 | #define Addressbook_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | 24 | ||
25 | class ContactEditor; | 25 | class ContactEditor; |
26 | class AbLabel; | 26 | class AbLabel; |
27 | class AbTable; | 27 | class AbTable; |
28 | class QPEToolBar; | 28 | class QPEToolBar; |
29 | class QPopupMenu; | 29 | class QPopupMenu; |
30 | class QToolButton; | 30 | class QToolButton; |
31 | class QDialog; | 31 | class QDialog; |
32 | class Ir; | 32 | class Ir; |
33 | class QAction; | 33 | class QAction; |
34 | class LetterPicker; | ||
34 | 35 | ||
35 | class AddressbookWindow: public QMainWindow | 36 | class AddressbookWindow: public QMainWindow |
36 | { | 37 | { |
37 | Q_OBJECT | 38 | Q_OBJECT |
38 | public: | 39 | public: |
39 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 40 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
40 | ~AddressbookWindow(); | 41 | ~AddressbookWindow(); |
41 | 42 | ||
42 | protected: | 43 | protected: |
43 | void resizeEvent( QResizeEvent * e ); | 44 | void resizeEvent( QResizeEvent * e ); |
44 | void showList(); | 45 | void showList(); |
45 | void showView(); | 46 | void showView(); |
46 | enum EntryMode { NewEntry=0, EditEntry }; | 47 | enum EntryMode { NewEntry=0, EditEntry }; |
47 | void editPersonal(); | 48 | void editPersonal(); |
48 | void editEntry( EntryMode ); | 49 | void editEntry( EntryMode ); |
49 | void closeEvent( QCloseEvent *e ); | 50 | void closeEvent( QCloseEvent *e ); |
50 | bool save(); | 51 | bool save(); |
51 | 52 | ||
52 | public slots: | 53 | public slots: |
53 | void flush(); | 54 | void flush(); |
54 | void reload(); | 55 | void reload(); |
55 | void appMessage(const QCString &, const QByteArray &); | 56 | void appMessage(const QCString &, const QByteArray &); |
56 | void setDocument( const QString & ); | 57 | void setDocument( const QString & ); |
57 | 58 | ||
58 | private slots: | 59 | private slots: |
59 | void slotListNew(); | 60 | void slotListNew(); |
60 | void slotListView(); | 61 | void slotListView(); |
61 | void slotListDelete(); | 62 | void slotListDelete(); |
62 | void slotViewBack(); | 63 | void slotViewBack(); |
63 | void slotViewEdit(); | 64 | void slotViewEdit(); |
64 | void slotPersonalView(); | 65 | void slotPersonalView(); |
65 | void listIsEmpty( bool ); | 66 | void listIsEmpty( bool ); |
66 | void slotSettings(); | 67 | void slotSettings(); |
67 | void writeMail(); | 68 | void writeMail(); |
68 | void slotBeam(); | 69 | void slotBeam(); |
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); |
74 | private: | 76 | private: |
75 | void initFields();// inititialize our fields... | 77 | void initFields();// inititialize our fields... |
76 | AbLabel *abView(); | 78 | AbLabel *abView(); |
77 | void populateCategories(); | 79 | void populateCategories(); |
78 | 80 | ||
79 | QPopupMenu *catMenu, *fontMenu; | 81 | QPopupMenu *catMenu, *fontMenu; |
80 | QPEToolBar *listTools; | 82 | QPEToolBar *listTools; |
81 | QToolButton *deleteButton; | 83 | QToolButton *deleteButton; |
82 | QValueList<int> allFields, | 84 | QValueList<int> allFields, |
83 | orderedFields; | 85 | orderedFields; |
84 | QStringList slOrderedFields; | 86 | QStringList slOrderedFields; |
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, |
91 | *actionPersonal, *actionMail; | 94 | *actionPersonal, *actionMail; |
92 | 95 | ||
93 | bool bAbEditFirstTime; | 96 | bool bAbEditFirstTime; |
94 | int viewMargin; | 97 | int viewMargin; |
95 | 98 | ||
96 | bool syncing; | 99 | bool syncing; |
97 | QFont *defaultFont; | 100 | QFont *defaultFont; |
98 | int startFontSize; | 101 | int startFontSize; |
99 | }; | 102 | }; |
100 | 103 | ||
101 | #endif | 104 | #endif |
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 | |||
@@ -1,33 +1,35 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS= addressbook.h \ | 4 | 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 |
18 | INCLUDEPATH += $(OPIEDIR)/include | 20 | INCLUDEPATH += $(OPIEDIR)/include |
19 | DEPENDPATH+= $(OPIEDIR)/include | 21 | DEPENDPATH+= $(OPIEDIR)/include |
20 | LIBS += -lqpe | 22 | LIBS += -lqpe |
21 | 23 | ||
22 | TRANSLATIONS = ../../i18n/pt_BR/addressbook.ts | 24 | TRANSLATIONS = ../../i18n/pt_BR/addressbook.ts |
23 | TRANSLATIONS += ../../i18n/de/addressbook.ts | 25 | TRANSLATIONS += ../../i18n/de/addressbook.ts |
24 | TRANSLATIONS += ../../i18n/en/addressbook.ts | 26 | TRANSLATIONS += ../../i18n/en/addressbook.ts |
25 | TRANSLATIONS += ../../i18n/hu/addressbook.ts | 27 | TRANSLATIONS += ../../i18n/hu/addressbook.ts |
26 | TRANSLATIONS += ../../i18n/sl/addressbook.ts | 28 | TRANSLATIONS += ../../i18n/sl/addressbook.ts |
27 | TRANSLATIONS += ../../i18n/ja/addressbook.ts | 29 | TRANSLATIONS += ../../i18n/ja/addressbook.ts |
28 | TRANSLATIONS += ../../i18n/ko/addressbook.ts | 30 | TRANSLATIONS += ../../i18n/ko/addressbook.ts |
29 | TRANSLATIONS += ../../i18n/pl/addressbook.ts | 31 | TRANSLATIONS += ../../i18n/pl/addressbook.ts |
30 | TRANSLATIONS += ../../i18n/no/addressbook.ts | 32 | TRANSLATIONS += ../../i18n/no/addressbook.ts |
31 | TRANSLATIONS += ../../i18n/zh_CN/addressbook.ts | 33 | TRANSLATIONS += ../../i18n/zh_CN/addressbook.ts |
32 | TRANSLATIONS += ../../i18n/zh_TW/addressbook.ts | 34 | TRANSLATIONS += ../../i18n/zh_TW/addressbook.ts |
33 | TRANSLATIONS += ../../i18n/fr/addressbook.ts | 35 | TRANSLATIONS += ../../i18n/fr/addressbook.ts |
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 | |||
8 | char PickerLabel::lastLetter = '\0'; | ||
9 | |||
10 | PickerLabel::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 | |||
25 | PickerLabel::~PickerLabel() | ||
26 | { | ||
27 | |||
28 | } | ||
29 | |||
30 | void 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 | |||
61 | void 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 | |||
78 | void 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 | |||
145 | void PickerLabel::emitClearSignal() { | ||
146 | emit clearAll(); | ||
147 | } | ||
148 | |||
149 | LetterPicker::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 | |||
212 | LetterPicker::~LetterPicker() | ||
213 | { | ||
214 | } | ||
215 | |||
216 | void 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 | |||
229 | void 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 | |||
17 | class PickerLabel: public QLabel { | ||
18 | Q_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 | }; | ||
46 | class LetterPicker: public QFrame { | ||
47 | Q_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 | ||