summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp86
-rw-r--r--core/pim/addressbook/addressbook.cpp27
-rw-r--r--core/pim/addressbook/addressbook.h1
-rw-r--r--core/pim/addressbook/picker.cpp7
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
@@ -824,301 +824,377 @@ void AbTable::journalFreeRemove( int row )
824void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) 824void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
825{ 825{
826 // Region of the rect we should draw 826 // Region of the rect we should draw
827 QRegion reg( QRect( cx, cy, cw, ch ) ); 827 QRegion reg( QRect( cx, cy, cw, ch ) );
828 // Subtract the table from it 828 // Subtract the table from it
829 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); 829 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
830 // And draw the rectangles (transformed as needed) 830 // And draw the rectangles (transformed as needed)
831 QArray<QRect> r = reg.rects(); 831 QArray<QRect> r = reg.rects();
832 for (unsigned int i=0; i<r.count(); i++) 832 for (unsigned int i=0; i<r.count(); i++)
833 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); 833 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
834} 834}
835#endif 835#endif
836#endif 836#endif
837 837
838 838
839// int AbTable::rowHeight( int ) const 839// int AbTable::rowHeight( int ) const
840// { 840// {
841// return 18; 841// return 18;
842// } 842// }
843 843
844// int AbTable::rowPos( int row ) const 844// int AbTable::rowPos( int row ) const
845// { 845// {
846// return 18*row; 846// return 18*row;
847// } 847// }
848 848
849// int AbTable::rowAt( int pos ) const 849// int AbTable::rowAt( int pos ) const
850// { 850// {
851// return QMIN( pos/18, numRows()-1 ); 851// return QMIN( pos/18, numRows()-1 );
852// } 852// }
853 853
854void AbTable::slotDoFind( const QString &findString, bool caseSensitive, 854void AbTable::slotDoFind( const QString &findString, bool caseSensitive,
855 bool backwards, int category ) 855 bool backwards, int category )
856{ 856{
857 if ( currFindRow < -1 ) 857 if ( currFindRow < -1 )
858 currFindRow = currentRow() - 1; 858 currFindRow = currentRow() - 1;
859 clearSelection( TRUE ); 859 clearSelection( TRUE );
860 int rows, 860 int rows,
861 row; 861 row;
862 AbTableItem *ati; 862 AbTableItem *ati;
863 QRegExp r( findString ); 863 QRegExp r( findString );
864 r.setCaseSensitive( caseSensitive ); 864 r.setCaseSensitive( caseSensitive );
865 rows = numRows(); 865 rows = numRows();
866 static bool wrapAround = true; 866 static bool wrapAround = true;
867 867
868 if ( !backwards ) { 868 if ( !backwards ) {
869 for ( row = currFindRow + 1; row < rows; row++ ) { 869 for ( row = currFindRow + 1; row < rows; row++ ) {
870 ati = static_cast<AbTableItem*>( item(row, 0) ); 870 ati = static_cast<AbTableItem*>( item(row, 0) );
871 if ( contactCompare( contactList[ati], r, category ) ) 871 if ( contactCompare( contactList[ati], r, category ) )
872 break; 872 break;
873 873
874 } 874 }
875 } else { 875 } else {
876 for ( row = currFindRow - 1; row > -1; row-- ) { 876 for ( row = currFindRow - 1; row > -1; row-- ) {
877 ati = static_cast<AbTableItem*>( item(row, 0) ); 877 ati = static_cast<AbTableItem*>( item(row, 0) );
878 if ( contactCompare( contactList[ati], r, category ) ) 878 if ( contactCompare( contactList[ati], r, category ) )
879 break; 879 break;
880 } 880 }
881 } 881 }
882 if ( row >= rows || row < 0 ) { 882 if ( row >= rows || row < 0 ) {
883 if ( row < 0 ) 883 if ( row < 0 )
884 currFindRow = rows; 884 currFindRow = rows;
885 else 885 else
886 currFindRow = -1; 886 currFindRow = -1;
887 887
888 if ( wrapAround ) 888 if ( wrapAround )
889 emit signalWrapAround(); 889 emit signalWrapAround();
890 else 890 else
891 emit signalNotFound(); 891 emit signalNotFound();
892 892
893 wrapAround = !wrapAround; 893 wrapAround = !wrapAround;
894 } else { 894 } else {
895 currFindRow = row; 895 currFindRow = row;
896 QTableSelection foundSelection; 896 QTableSelection foundSelection;
897 foundSelection.init( currFindRow, 0 ); 897 foundSelection.init( currFindRow, 0 );
898 foundSelection.expandTo( currFindRow, numCols() - 1 ); 898 foundSelection.expandTo( currFindRow, numCols() - 1 );
899 addSelection( foundSelection ); 899 addSelection( foundSelection );
900 setCurrentCell( currFindRow, numCols() - 1 ); 900 setCurrentCell( currFindRow, numCols() - 1 );
901 wrapAround = true; 901 wrapAround = true;
902 } 902 }
903} 903}
904 904
905static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ) 905static bool contactCompare( const Contact &cnt, const QRegExp &r, int category )
906{ 906{
907 bool returnMe; 907 bool returnMe;
908 QArray<int> cats; 908 QArray<int> cats;
909 cats = cnt.categories(); 909 cats = cnt.categories();
910 910
911 returnMe = false; 911 returnMe = false;
912 if ( (category == -1 && cats.count() == 0) || category == -2 ) 912 if ( (category == -1 && cats.count() == 0) || category == -2 )
913 returnMe = cnt.match( r ); 913 returnMe = cnt.match( r );
914 else { 914 else {
915 int i; 915 int i;
916 for ( i = 0; i < int(cats.count()); i++ ) { 916 for ( i = 0; i < int(cats.count()); i++ ) {
917 if ( cats[i] == category ) { 917 if ( cats[i] == category ) {
918 returnMe = cnt.match( r ); 918 returnMe = cnt.match( r );
919 break; 919 break;
920 } 920 }
921 } 921 }
922 } 922 }
923 return returnMe; 923 return returnMe;
924} 924}
925 925
926void AbTable::fitColumns() 926void AbTable::fitColumns()
927{ 927{
928 int contentsWidth = visibleWidth(); 928 int contentsWidth = visibleWidth();
929 int n = numCols(); 929 int n = numCols();
930 int pw = n == 3 ? columnWidth(2) : 0; 930 int pw = n == 3 ? columnWidth(2) : 0;
931 setColumnWidth( 0, contentsWidth - contentsWidth / 2 ); 931 setColumnWidth( 0, contentsWidth - contentsWidth / 2 );
932 setColumnWidth( 1, contentsWidth / 2 - pw ); 932 setColumnWidth( 1, contentsWidth / 2 - pw );
933} 933}
934 934
935void AbTable::show() 935void AbTable::show()
936{ 936{
937 fitColumns(); 937 fitColumns();
938 QTable::show(); 938 QTable::show();
939} 939}
940 940
941void AbTable::setChoiceNames( const QStringList& list) 941void AbTable::setChoiceNames( const QStringList& list)
942{ 942{
943 choicenames = list; 943 choicenames = list;
944 if ( choicenames.isEmpty() ) { 944 if ( choicenames.isEmpty() ) {
945 // hide pick column 945 // hide pick column
946 setNumCols( 2 ); 946 setNumCols( 2 );
947 } else { 947 } else {
948 // show pick column 948 // show pick column
949 setNumCols( 3 ); 949 setNumCols( 3 );
950 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 950 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
951 horizontalHeader()->setLabel( 2, tr( "Pick" )); 951 horizontalHeader()->setLabel( 2, tr( "Pick" ));
952 } 952 }
953 fitColumns(); 953 fitColumns();
954} 954}
955 955
956void AbTable::itemClicked(int,int col) 956void AbTable::itemClicked(int,int col)
957{ 957{
958 if ( col == 2 ) { 958 if ( col == 2 ) {
959 return; 959 return;
960 } else { 960 } else {
961 emit details(); 961 emit details();
962 } 962 }
963} 963}
964 964
965QStringList AbTable::choiceNames() const 965QStringList AbTable::choiceNames() const
966{ 966{
967 return choicenames; 967 return choicenames;
968} 968}
969 969
970void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) 970void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/)
971{ 971{
972 /* ###### 972 /* ######
973 973
974 QString selname = choicenames.at(index); 974 QString selname = choicenames.at(index);
975 for (each row) { 975 for (each row) {
976 Contact *c = contactForRow(row); 976 Contact *c = contactForRow(row);
977 if ( list.contains(c->email) ) { 977 if ( list.contains(c->email) ) {
978 list.remove(c->email); 978 list.remove(c->email);
979 setText(row, 2, selname); 979 setText(row, 2, selname);
980 } 980 }
981 } 981 }
982 for (remaining list items) { 982 for (remaining list items) {
983 Contact *c = new contact(item); 983 Contact *c = new contact(item);
984 setText(newrow, 2, selname); 984 setText(newrow, 2, selname);
985 } 985 }
986 986
987 */ 987 */
988} 988}
989 989
990QStringList AbTable::choiceSelection(int /*index*/) const 990QStringList AbTable::choiceSelection(int /*index*/) const
991{ 991{
992 QStringList r; 992 QStringList r;
993 /* ###### 993 /* ######
994 994
995 QString selname = choicenames.at(index); 995 QString selname = choicenames.at(index);
996 for (each row) { 996 for (each row) {
997 Contact *c = contactForRow(row); 997 Contact *c = contactForRow(row);
998 if ( text(row,2) == selname ) { 998 if ( text(row,2) == selname ) {
999 r.append(c->email); 999 r.append(c->email);
1000 } 1000 }
1001 } 1001 }
1002 1002
1003 */ 1003 */
1004 return r; 1004 return r;
1005} 1005}
1006 1006
1007void AbTable::setShowCategory( const QString &c ) 1007void AbTable::setShowCategory( const QString &c )
1008{ 1008{
1009 showCat = c; 1009 showCat = c;
1010 updateVisible(); 1010 updateVisible();
1011} 1011}
1012 1012
1013void AbTable::setShowByLetter( char c ) 1013void 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
1020QString AbTable::showCategory() const 1019QString AbTable::showCategory() const
1021{ 1020{
1022 return showCat; 1021 return showCat;
1023} 1022}
1024 1023
1025 1024
1026QStringList AbTable::categories() 1025QStringList AbTable::categories()
1027{ 1026{
1028 mCat.load( categoryFileName() ); 1027 mCat.load( categoryFileName() );
1029 QStringList categoryList = mCat.labels( "Contacts" ); 1028 QStringList categoryList = mCat.labels( "Contacts" );
1030 return categoryList; 1029 return categoryList;
1031} 1030}
1032 1031
1033void AbTable::updateVisible() 1032void AbTable::updateVisible()
1034{ 1033{
1035 int visible, 1034 int visible,
1036 totalRows, 1035 totalRows,
1037 id, 1036 id,
1038 totalCats, 1037 totalCats,
1039 it, 1038 it,
1040 row; 1039 row;
1041 bool hide; 1040 bool hide;
1042 AbTableItem *ati; 1041 AbTableItem *ati;
1043 Contact *cnt; 1042 Contact *cnt;
1044 QString fileAsName; 1043 QString fileAsName;
1045 QString tmpStr; 1044 QString tmpStr;
1046 visible = 0; 1045 visible = 0;
1047 1046
1048 setPaintingEnabled( FALSE ); 1047 setPaintingEnabled( FALSE );
1049 1048
1050 totalRows = numRows(); 1049 totalRows = numRows();
1051 id = mCat.id( "Contacts", showCat ); 1050 id = mCat.id( "Contacts", showCat );
1052 QArray<int> cats; 1051 QArray<int> cats;
1053 for ( row = 0; row < totalRows; row++ ) { 1052 for ( row = 0; row < totalRows; row++ ) {
1054 ati = static_cast<AbTableItem*>( item(row, 0) ); 1053 ati = static_cast<AbTableItem*>( item(row, 0) );
1055 cnt = &contactList[ati]; 1054 cnt = &contactList[ati];
1056 cats = cnt->categories(); 1055 cats = cnt->categories();
1057 fileAsName = cnt->fileAs(); 1056 fileAsName = cnt->fileAs();
1058 hide = false; 1057 hide = false;
1059 if ( !showCat.isEmpty() ) { 1058 if ( !showCat.isEmpty() ) {
1060 if ( showCat == tr( "Unfiled" ) ) { 1059 if ( showCat == tr( "Unfiled" ) ) {
1061 if ( cats.count() > 0 ) 1060 if ( cats.count() > 0 )
1062 hide = true; 1061 hide = true;
1063 } else { 1062 } else {
1064 // do some comparing 1063 // do some comparing
1065 if ( !hide ) { 1064 if ( !hide ) {
1066 hide = true; 1065 hide = true;
1067 totalCats = int(cats.count()); 1066 totalCats = int(cats.count());
1068 for ( it = 0; it < totalCats; it++ ) { 1067 for ( it = 0; it < totalCats; it++ ) {
1069 if ( cats[it] == id ) { 1068 if ( cats[it] == id ) {
1070 hide = false; 1069 hide = false;
1071 break; 1070 break;
1072 } 1071 }
1073 } 1072 }
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 );
1092 } else { 1168 } else {
1093 if ( rowHeight(row) == 0 ) { 1169 if ( rowHeight(row) == 0 ) {
1094 showRow( row ); 1170 showRow( row );
1095 adjustRow( row ); 1171 adjustRow( row );
1096 } 1172 }
1097 visible++; 1173 visible++;
1098 } 1174 }
1099 } 1175 }
1100 if ( !visible ) 1176 if ( !visible )
1101 setCurrentCell( -1, 0 ); 1177 setCurrentCell( -1, 0 );
1102 1178
1103 setPaintingEnabled( TRUE ); 1179 setPaintingEnabled( TRUE );
1104} 1180}
1105 1181
1106 1182
1107void AbTable::setPaintingEnabled( bool e ) 1183void AbTable::setPaintingEnabled( bool e )
1108{ 1184{
1109 if ( e != enablePainting ) { 1185 if ( e != enablePainting ) {
1110 if ( !enablePainting ) { 1186 if ( !enablePainting ) {
1111 enablePainting = true; 1187 enablePainting = true;
1112 rowHeightChanged( 0 ); 1188 rowHeightChanged( 0 );
1113 viewport()->update(); 1189 viewport()->update();
1114 } else { 1190 } else {
1115 enablePainting = false; 1191 enablePainting = false;
1116 } 1192 }
1117 } 1193 }
1118} 1194}
1119 1195
1120void AbTable::rowHeightChanged( int row ) 1196void AbTable::rowHeightChanged( int row )
1121{ 1197{
1122 if ( enablePainting ) 1198 if ( enablePainting )
1123 QTable::rowHeightChanged( row ); 1199 QTable::rowHeightChanged( row );
1124} 1200}
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
@@ -1,796 +1,799 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
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 20
21#define QTOPIA_INTERNAL_FD 21#define QTOPIA_INTERNAL_FD
22 22
23#include "contacteditor.h" 23#include "contacteditor.h"
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abtable.h" 25#include "abtable.h"
26#include "addresssettings.h" 26#include "addresssettings.h"
27#include "addressbook.h" 27#include "addressbook.h"
28 28
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/config.h> 30#include <qpe/config.h>
31#include <qpe/contact.h> 31#include <qpe/contact.h>
32 32
33#ifndef MAKE_FOR_SHARP_ROM 33#ifndef MAKE_FOR_SHARP_ROM
34#include <qpe/finddialog.h> 34#include <qpe/finddialog.h>
35#endif 35#endif
36 36
37#include <qpe/global.h> 37#include <qpe/global.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39#include <qpe/ir.h> 39#include <qpe/ir.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
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#include "picker.h"
67static QString addressbookOldXMLFilename() 67static QString addressbookOldXMLFilename()
68{ 68{
69 QString filename = QPEApplication::documentDir() + "addressbook.xml"; 69 QString filename = QPEApplication::documentDir() + "addressbook.xml";
70 return filename; 70 return filename;
71} 71}
72 72
73static QString addressbookXMLFilename() 73static QString addressbookXMLFilename()
74{ 74{
75 QString filename = Global::applicationFileName("addressbook", 75 QString filename = Global::applicationFileName("addressbook",
76 "addressbook.xml"); 76 "addressbook.xml");
77 return filename; 77 return filename;
78} 78}
79 79
80static QString addressbookPersonalVCardName() 80static QString addressbookPersonalVCardName()
81{ 81{
82 QString filename = Global::applicationFileName("addressbook", 82 QString filename = Global::applicationFileName("addressbook",
83 "businesscard.vcf"); 83 "businesscard.vcf");
84 return filename; 84 return filename;
85} 85}
86 86
87 87
88AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 88AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
89 WFlags f ) 89 WFlags f )
90 : QMainWindow( parent, name, f ), 90 : QMainWindow( parent, name, f ),
91 abEditor(0), 91 abEditor(0),
92 bAbEditFirstTime(TRUE), 92 bAbEditFirstTime(TRUE),
93 syncing(FALSE) 93 syncing(FALSE)
94{ 94{
95 initFields(); 95 initFields();
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 );
109 mbList->setMargin( 0 ); 108 mbList->setMargin( 0 );
110 109
111 QPopupMenu *edit = new QPopupMenu( this ); 110 QPopupMenu *edit = new QPopupMenu( this );
112 mbList->insertItem( tr( "Contact" ), edit ); 111 mbList->insertItem( tr( "Contact" ), edit );
113 112
114 listTools = new QPEToolBar( this, "list operations" ); 113 listTools = new QPEToolBar( this, "list operations" );
115 114
116 115
117 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 116 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
118 0, this, 0 ); 117 0, this, 0 );
119 actionNew = a; 118 actionNew = a;
120 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 119 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
121 a->addTo( edit ); 120 a->addTo( edit );
122 a->addTo( listTools ); 121 a->addTo( listTools );
123 122
124 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 123 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
125 0, this, 0 ); 124 0, this, 0 );
126 actionEdit = a; 125 actionEdit = a;
127 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
128 a->addTo( edit ); 127 a->addTo( edit );
129 a->addTo( listTools ); 128 a->addTo( listTools );
130 129
131 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 130 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
132 0, this, 0 ); 131 0, this, 0 );
133 actionTrash = a; 132 actionTrash = a;
134 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
135 a->addTo( edit ); 134 a->addTo( edit );
136 a->addTo( listTools ); 135 a->addTo( listTools );
137 136
138#ifndef MAKE_FOR_SHARP_ROM 137#ifndef MAKE_FOR_SHARP_ROM
139 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 138 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
140 QString::null, 0, this, 0 ); 139 QString::null, 0, this, 0 );
141 actionFind = a; 140 actionFind = a;
142 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 141 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
143 a->addTo( edit ); 142 a->addTo( edit );
144 a->addTo( listTools ); 143 a->addTo( listTools );
145#endif 144#endif
146 145
147 146
148 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 147 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
149 QString::null, 0, this, 0 ); 148 QString::null, 0, this, 0 );
150 //a->setEnabled( FALSE ); we got support for it now :) zecke 149 //a->setEnabled( FALSE ); we got support for it now :) zecke
151 actionMail = a; 150 actionMail = a;
152 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 151 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
153 a->addTo( edit ); 152 a->addTo( edit );
154 a->addTo( listTools ); 153 a->addTo( listTools );
155 154
156 155
157 156
158 if ( Ir::supported() ) { 157 if ( Ir::supported() ) {
159 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 158 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
160 0, this, 0 ); 159 0, this, 0 );
161 actionBeam = a; 160 actionBeam = a;
162 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 161 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
163 a->addTo( edit ); 162 a->addTo( edit );
164 a->addTo( listTools ); 163 a->addTo( listTools );
165 } 164 }
166 165
167 edit->insertSeparator(); 166 edit->insertSeparator();
168 167
169 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 168 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
170 actionPersonal = a; 169 actionPersonal = a;
171 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 170 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
172 a->addTo( edit ); 171 a->addTo( edit );
173 172
174 173
175 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 174 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
176 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 175 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
177 a->addTo( edit ); 176 a->addTo( edit );
178 177
179 // Create Views 178 // Create Views
180 179
181 // This is safe to call without checking to see if it exists... 180 // This is safe to call without checking to see if it exists...
182 // not to mention it also does the necessary stuff for the 181 // not to mention it also does the necessary stuff for the
183 // journaling... 182 // journaling...
184 QString str = addressbookXMLFilename(); 183 QString str = addressbookXMLFilename();
185 if ( str.isNull() ) { 184 if ( str.isNull() ) {
186 QMessageBox::warning( this, tr("Out of Space"), 185 QMessageBox::warning( this, tr("Out of Space"),
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)),
201 this, SLOT(slotUpdateToolbar()) ); 204 this, SLOT(slotUpdateToolbar()) );
202 205
203 mView = 0; 206 mView = 0;
204 207
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);
227 fontMenu->insertItem(tr( "Normal" ), 1); 230 fontMenu->insertItem(tr( "Normal" ), 1);
228 fontMenu->insertItem(tr( "Large" ), 2); 231 fontMenu->insertItem(tr( "Large" ), 2);
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}
239void AddressbookWindow::slotSetFont( int size ) { 242void AddressbookWindow::slotSetFont( int size ) {
240 243
241 if (size > 2 || size < 0) 244 if (size > 2 || size < 0)
242 size = 1; 245 size = 1;
243 246
244 startFontSize = size; 247 startFontSize = size;
245 248
246 QFont *currentFont; 249 QFont *currentFont;
247 250
248 switch (size) { 251 switch (size) {
249 case 0: 252 case 0:
250 fontMenu->setItemChecked(0, true); 253 fontMenu->setItemChecked(0, true);
251 fontMenu->setItemChecked(1, false); 254 fontMenu->setItemChecked(1, false);
252 fontMenu->setItemChecked(2, false); 255 fontMenu->setItemChecked(2, false);
253 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 256 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
254 currentFont = new QFont (abList->font()); 257 currentFont = new QFont (abList->font());
255 abList->resizeRows(currentFont->pixelSize() + 7); 258 abList->resizeRows(currentFont->pixelSize() + 7);
256 break; 259 break;
257 case 1: 260 case 1:
258 fontMenu->setItemChecked(0, false); 261 fontMenu->setItemChecked(0, false);
259 fontMenu->setItemChecked(1, true); 262 fontMenu->setItemChecked(1, true);
260 fontMenu->setItemChecked(2, false); 263 fontMenu->setItemChecked(2, false);
261 abList->setFont( *defaultFont ); 264 abList->setFont( *defaultFont );
262 currentFont = new QFont (abList->font()); 265 currentFont = new QFont (abList->font());
263 abList->resizeRows(currentFont->pixelSize() + 7); 266 abList->resizeRows(currentFont->pixelSize() + 7);
264 break; 267 break;
265 case 2: 268 case 2:
266 fontMenu->setItemChecked(0, false); 269 fontMenu->setItemChecked(0, false);
267 fontMenu->setItemChecked(1, false); 270 fontMenu->setItemChecked(1, false);
268 fontMenu->setItemChecked(2, true); 271 fontMenu->setItemChecked(2, true);
269 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 272 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
270 currentFont = new QFont (abList->font()); 273 currentFont = new QFont (abList->font());
271 abList->resizeRows(currentFont->pixelSize() + 7); 274 abList->resizeRows(currentFont->pixelSize() + 7);
272 break; 275 break;
273 } 276 }
274} 277}
275 278
276 279
277void AddressbookWindow::setDocument( const QString &filename ) 280void AddressbookWindow::setDocument( const QString &filename )
278{ 281{
279 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; 282 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
280 283
281 QValueList<Contact> cl = Contact::readVCard( filename ); 284 QValueList<Contact> cl = Contact::readVCard( filename );
282 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 285 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
283 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 286 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
284 // .arg( (*it).fullName() ); 287 // .arg( (*it).fullName() );
285 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 288 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
286 // QMessageBox::Ok ) { 289 // QMessageBox::Ok ) {
287 abList->addEntry( *it ); 290 abList->addEntry( *it );
288 // } 291 // }
289 } 292 }
290 293
291} 294}
292 295
293void AddressbookWindow::resizeEvent( QResizeEvent *e ) 296void 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
303AddressbookWindow::~AddressbookWindow() 306AddressbookWindow::~AddressbookWindow()
304{ 307{
305 Config cfg("AddressBook"); 308 Config cfg("AddressBook");
306 cfg.setGroup("Font"); 309 cfg.setGroup("Font");
307 cfg.writeEntry("fontSize", startFontSize); 310 cfg.writeEntry("fontSize", startFontSize);
308} 311}
309 312
310void AddressbookWindow::slotUpdateToolbar() 313void AddressbookWindow::slotUpdateToolbar()
311{ 314{
312 Contact ce = abList->currentEntry(); 315 Contact ce = abList->currentEntry();
313 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 316 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
314} 317}
315 318
316void AddressbookWindow::showList() 319void 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
325void AddressbookWindow::showView() 328void 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
335void AddressbookWindow::slotListNew() 338void AddressbookWindow::slotListNew()
336{ 339{
337 Contact cnt; 340 Contact cnt;
338 if( !syncing ) { 341 if( !syncing ) {
339 if ( abEditor ) 342 if ( abEditor )
340 abEditor->setEntry( cnt ); 343 abEditor->setEntry( cnt );
341 abView()->init( cnt ); 344 abView()->init( cnt );
342 editEntry( NewEntry ); 345 editEntry( NewEntry );
343 } else { 346 } else {
344 QMessageBox::warning(this, tr("Contacts"), 347 QMessageBox::warning(this, tr("Contacts"),
345 tr("Can not edit data, currently syncing")); 348 tr("Can not edit data, currently syncing"));
346 } 349 }
347} 350}
348 351
349void AddressbookWindow::slotListView() 352void AddressbookWindow::slotListView()
350{ 353{
351 abView()->init( abList->currentEntry() ); 354 abView()->init( abList->currentEntry() );
352 mView->sync(); 355 mView->sync();
353 showView(); 356 showView();
354} 357}
355 358
356void AddressbookWindow::slotListDelete() 359void AddressbookWindow::slotListDelete()
357{ 360{
358 if(!syncing) { 361 if(!syncing) {
359 Contact tmpEntry = abList->currentEntry(); 362 Contact tmpEntry = abList->currentEntry();
360 363
361 // get a name, do the best we can... 364 // get a name, do the best we can...
362 QString strName = tmpEntry.fullName(); 365 QString strName = tmpEntry.fullName();
363 if ( strName.isEmpty() ) { 366 if ( strName.isEmpty() ) {
364 strName = tmpEntry.company(); 367 strName = tmpEntry.company();
365 if ( strName.isEmpty() ) 368 if ( strName.isEmpty() )
366 strName = "No Name"; 369 strName = "No Name";
367 } 370 }
368 371
369 372
370 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 373 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
371 strName ) ) { 374 strName ) ) {
372 abList->deleteCurrentEntry(); 375 abList->deleteCurrentEntry();
373 showList(); 376 showList();
374 } 377 }
375 } else { 378 } else {
376 QMessageBox::warning( this, tr("Contacts"), 379 QMessageBox::warning( this, tr("Contacts"),
377 tr("Can not edit data, currently syncing") ); 380 tr("Can not edit data, currently syncing") );
378 } 381 }
379} 382}
380 383
381void AddressbookWindow::slotViewBack() 384void AddressbookWindow::slotViewBack()
382{ 385{
383 showList(); 386 showList();
384} 387}
385 388
386void AddressbookWindow::slotViewEdit() 389void AddressbookWindow::slotViewEdit()
387{ 390{
388 if(!syncing) { 391 if(!syncing) {
389 if (actionPersonal->isOn()) { 392 if (actionPersonal->isOn()) {
390 editPersonal(); 393 editPersonal();
391 } else { 394 } else {
392 if ( !bAbEditFirstTime ) 395 if ( !bAbEditFirstTime )
393 abEditor->setEntry( abList->currentEntry() ); 396 abEditor->setEntry( abList->currentEntry() );
394 editEntry( EditEntry ); 397 editEntry( EditEntry );
395 } 398 }
396 } else { 399 } else {
397 QMessageBox::warning( this, tr("Contacts"), 400 QMessageBox::warning( this, tr("Contacts"),
398 tr("Can not edit data, currently syncing") ); 401 tr("Can not edit data, currently syncing") );
399 } 402 }
400} 403}
401 404
402 405
403 406
404void AddressbookWindow::writeMail() 407void AddressbookWindow::writeMail()
405{ 408{
406 Contact c = abList->currentEntry(); 409 Contact c = abList->currentEntry();
407 QString name = c.fileAs(); 410 QString name = c.fileAs();
408 QString email = c.defaultEmail(); 411 QString email = c.defaultEmail();
409 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 412 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
410 e << name << email; 413 e << name << email;
411} 414}
412 415
413 416
414 417
415 418
416static const char * beamfile = "/tmp/obex/contact.vcf"; 419static const char * beamfile = "/tmp/obex/contact.vcf";
417 420
418void AddressbookWindow::slotBeam() 421void AddressbookWindow::slotBeam()
419{ 422{
420 QString filename; 423 QString filename;
421 Contact c; 424 Contact c;
422 if ( actionPersonal->isOn() ) { 425 if ( actionPersonal->isOn() ) {
423 filename = addressbookPersonalVCardName(); 426 filename = addressbookPersonalVCardName();
424 if (!QFile::exists(filename)) 427 if (!QFile::exists(filename))
425 return; // can't beam a non-existent file 428 return; // can't beam a non-existent file
426 c = Contact::readVCard( filename )[0]; 429 c = Contact::readVCard( filename )[0];
427 } else { 430 } else {
428 unlink( beamfile ); // delete if exists 431 unlink( beamfile ); // delete if exists
429 c = abList->currentEntry(); 432 c = abList->currentEntry();
430 mkdir("/tmp/obex/", 0755); 433 mkdir("/tmp/obex/", 0755);
431 Contact::writeVCard( beamfile, c ); 434 Contact::writeVCard( beamfile, c );
432 filename = beamfile; 435 filename = beamfile;
433 } 436 }
434 Ir *ir = new Ir( this ); 437 Ir *ir = new Ir( this );
435 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 438 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
436 QString description = c.fullName(); 439 QString description = c.fullName();
437 ir->send( filename, description, "text/x-vCard" ); 440 ir->send( filename, description, "text/x-vCard" );
438} 441}
439 442
440void AddressbookWindow::beamDone( Ir *ir ) 443void AddressbookWindow::beamDone( Ir *ir )
441{ 444{
442 delete ir; 445 delete ir;
443 unlink( beamfile ); 446 unlink( beamfile );
444} 447}
445 448
446 449
447static void parseName( const QString& name, QString *first, QString *middle, 450static void parseName( const QString& name, QString *first, QString *middle,
448 QString * last ) 451 QString * last )
449{ 452{
450 453
451 int comma = name.find ( "," ); 454 int comma = name.find ( "," );
452 QString rest; 455 QString rest;
453 if ( comma > 0 ) { 456 if ( comma > 0 ) {
454 *last = name.left( comma ); 457 *last = name.left( comma );
455 comma++; 458 comma++;
456 while ( comma < int(name.length()) && name[comma] == ' ' ) 459 while ( comma < int(name.length()) && name[comma] == ' ' )
457 comma++; 460 comma++;
458 rest = name.mid( comma ); 461 rest = name.mid( comma );
459 } else { 462 } else {
460 int space = name.findRev( ' ' ); 463 int space = name.findRev( ' ' );
461 *last = name.mid( space+1 ); 464 *last = name.mid( space+1 );
462 rest = name.left( space ); 465 rest = name.left( space );
463 } 466 }
464 int space = rest.find( ' ' ); 467 int space = rest.find( ' ' );
465 if ( space <= 0 ) { 468 if ( space <= 0 ) {
466 *first = rest; 469 *first = rest;
467 } else { 470 } else {
468 *first = rest.left( space ); 471 *first = rest.left( space );
469 *middle = rest.mid( space+1 ); 472 *middle = rest.mid( space+1 );
470 } 473 }
471 474
472} 475}
473 476
474 477
475void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 478void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
476{ 479{
477 if (msg == "editPersonal()") { 480 if (msg == "editPersonal()") {
478 editPersonal(); 481 editPersonal();
479 } else if (msg == "editPersonalAndClose()") { 482 } else if (msg == "editPersonalAndClose()") {
480 editPersonal(); 483 editPersonal();
481 close(); 484 close();
482 } else if ( msg == "addContact(QString,QString)" ) { 485 } else if ( msg == "addContact(QString,QString)" ) {
483 QDataStream stream(data,IO_ReadOnly); 486 QDataStream stream(data,IO_ReadOnly);
484 QString name, email; 487 QString name, email;
485 stream >> name >> email; 488 stream >> name >> email;
486 489
487 Contact cnt; 490 Contact cnt;
488 QString fn, mn, ln; 491 QString fn, mn, ln;
489 parseName( name, &fn, &mn, &ln ); 492 parseName( name, &fn, &mn, &ln );
490 //qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 493 //qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
491 cnt.setFirstName( fn ); 494 cnt.setFirstName( fn );
492 cnt.setMiddleName( mn ); 495 cnt.setMiddleName( mn );
493 cnt.setLastName( ln ); 496 cnt.setLastName( ln );
494 cnt.setEmails( email ); 497 cnt.setEmails( email );
495 cnt.setDefaultEmail( email ); 498 cnt.setDefaultEmail( email );
496 cnt.setFileAs(); 499 cnt.setFileAs();
497 500
498 if ( bAbEditFirstTime ) { 501 if ( bAbEditFirstTime ) {
499 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, 502 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields,
500 this, "editor" ); 503 this, "editor" );
501 bAbEditFirstTime = FALSE; 504 bAbEditFirstTime = FALSE;
502 } else { 505 } else {
503 abEditor->setEntry( cnt ); 506 abEditor->setEntry( cnt );
504 } 507 }
505 abView()->init( cnt ); 508 abView()->init( cnt );
506 editEntry( NewEntry ); 509 editEntry( NewEntry );
507 510
508 511
509 512
510 } 513 }
511#if 0 514#if 0
512 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { 515 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
513 QDataStream stream(data,IO_ReadOnly); 516 QDataStream stream(data,IO_ReadOnly);
514 QCString ch,m; 517 QCString ch,m;
515 QStringList types; 518 QStringList types;
516 stream >> ch >> m >> types; 519 stream >> ch >> m >> types;
517 AddressPicker picker(abList,this,0,TRUE); 520 AddressPicker picker(abList,this,0,TRUE);
518 picker.showMaximized(); 521 picker.showMaximized();
519 picker.setChoiceNames(types); 522 picker.setChoiceNames(types);
520 int i=0; 523 int i=0;
521 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 524 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
522 QStringList sel; 525 QStringList sel;
523 stream >> sel; 526 stream >> sel;
524 picker.setSelection(i++,sel); 527 picker.setSelection(i++,sel);
525 } 528 }
526 picker.showMaximized(); 529 picker.showMaximized();
527 picker.exec(); 530 picker.exec();
528 531
529 // ###### note: contacts may have been added - save here! 532 // ###### note: contacts may have been added - save here!
530 533
531 setCentralWidget(abList); 534 setCentralWidget(abList);
532 QCopEnvelope e(ch,m); 535 QCopEnvelope e(ch,m);
533 i=0; 536 i=0;
534 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 537 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
535 QStringList sel = picker.selection(i++); 538 QStringList sel = picker.selection(i++);
536 e << sel; 539 e << sel;
537 } 540 }
538 } 541 }
539#endif 542#endif
540 543
541} 544}
542 545
543void AddressbookWindow::editPersonal() 546void AddressbookWindow::editPersonal()
544{ 547{
545 QString filename = addressbookPersonalVCardName(); 548 QString filename = addressbookPersonalVCardName();
546 Contact me; 549 Contact me;
547 if (QFile::exists(filename)) 550 if (QFile::exists(filename))
548 me = Contact::readVCard( filename )[0]; 551 me = Contact::readVCard( filename )[0];
549 if (bAbEditFirstTime) { 552 if (bAbEditFirstTime) {
550 abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, 553 abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields,
551 this, "editor" ); 554 this, "editor" );
552 // don't create a new editor every time 555 // don't create a new editor every time
553 bAbEditFirstTime = FALSE; 556 bAbEditFirstTime = FALSE;
554 } else 557 } else
555 abEditor->setEntry( me ); 558 abEditor->setEntry( me );
556 559
557 abEditor->setCaption(tr("Edit My Personal Details")); 560 abEditor->setCaption(tr("Edit My Personal Details"));
558 abEditor->showMaximized(); 561 abEditor->showMaximized();
559 562
560 // fix the foxus... 563 // fix the foxus...
561 abEditor->setNameFocus(); 564 abEditor->setNameFocus();
562 if ( abEditor->exec() ) { 565 if ( abEditor->exec() ) {
563 setFocus(); 566 setFocus();
564 Contact new_personal = abEditor->entry(); 567 Contact new_personal = abEditor->entry();
565 QString fname = addressbookPersonalVCardName(); 568 QString fname = addressbookPersonalVCardName();
566 Contact::writeVCard( fname, new_personal ); 569 Contact::writeVCard( fname, new_personal );
567 abView()->init(new_personal); 570 abView()->init(new_personal);
568 abView()->sync(); 571 abView()->sync();
569 } 572 }
570 abEditor->setCaption( tr("Edit Address") ); 573 abEditor->setCaption( tr("Edit Address") );
571} 574}
572 575
573void AddressbookWindow::slotPersonalView() 576void AddressbookWindow::slotPersonalView()
574{ 577{
575 if (!actionPersonal->isOn()) { 578 if (!actionPersonal->isOn()) {
576 // we just turned it off 579 // we just turned it off
577 setCaption( tr("Contacts") ); 580 setCaption( tr("Contacts") );
578 actionNew->setEnabled(TRUE); 581 actionNew->setEnabled(TRUE);
579 actionTrash->setEnabled(TRUE); 582 actionTrash->setEnabled(TRUE);
580#ifndef MAKE_FOR_SHARP_ROM 583#ifndef MAKE_FOR_SHARP_ROM
581 actionFind->setEnabled(TRUE); 584 actionFind->setEnabled(TRUE);
582#endif 585#endif
583 slotUpdateToolbar(); // maybe some of the above could be moved there 586 slotUpdateToolbar(); // maybe some of the above could be moved there
584 showList(); 587 showList();
585 return; 588 return;
586 } 589 }
587 590
588 // XXX need to disable some QActions. 591 // XXX need to disable some QActions.
589 actionNew->setEnabled(FALSE); 592 actionNew->setEnabled(FALSE);
590 actionTrash->setEnabled(FALSE); 593 actionTrash->setEnabled(FALSE);
591#ifndef MAKE_FOR_SHARP_ROM 594#ifndef MAKE_FOR_SHARP_ROM
592 actionFind->setEnabled(FALSE); 595 actionFind->setEnabled(FALSE);
593#endif 596#endif
594 actionMail->setEnabled(FALSE); 597 actionMail->setEnabled(FALSE);
595 598
596 setCaption( tr("Contacts - My Personal Details") ); 599 setCaption( tr("Contacts - My Personal Details") );
597 QString filename = addressbookPersonalVCardName(); 600 QString filename = addressbookPersonalVCardName();
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
610void AddressbookWindow::editEntry( EntryMode entryMode ) 613void AddressbookWindow::editEntry( EntryMode entryMode )
611{ 614{
612 Contact entry; 615 Contact entry;
613 if ( bAbEditFirstTime ) { 616 if ( bAbEditFirstTime ) {
614 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, 617 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields,
615 this, "editor" ); 618 this, "editor" );
616 bAbEditFirstTime = FALSE; 619 bAbEditFirstTime = FALSE;
617 if ( entryMode == EditEntry ) 620 if ( entryMode == EditEntry )
618 abEditor->setEntry( abList->currentEntry() ); 621 abEditor->setEntry( abList->currentEntry() );
619 } 622 }
620 // other things may chane the caption. 623 // other things may chane the caption.
621 abEditor->setCaption( tr("Edit Address") ); 624 abEditor->setCaption( tr("Edit Address") );
622 625
623#if defined(Q_WS_QWS) || defined(_WS_QWS_) 626#if defined(Q_WS_QWS) || defined(_WS_QWS_)
624 abEditor->showMaximized(); 627 abEditor->showMaximized();
625#endif 628#endif
626 // fix the foxus... 629 // fix the foxus...
627 abEditor->setNameFocus(); 630 abEditor->setNameFocus();
628 if ( abEditor->exec() ) { 631 if ( abEditor->exec() ) {
629 setFocus(); 632 setFocus();
630 if ( entryMode == NewEntry ) { 633 if ( entryMode == NewEntry ) {
631 Contact insertEntry = abEditor->entry(); 634 Contact insertEntry = abEditor->entry();
632 insertEntry.assignUid(); 635 insertEntry.assignUid();
633 abList->addEntry( insertEntry ); 636 abList->addEntry( insertEntry );
634 } else { 637 } else {
635 Contact replaceEntry = abEditor->entry(); 638 Contact replaceEntry = abEditor->entry();
636 if ( !replaceEntry.isValidUid() ) 639 if ( !replaceEntry.isValidUid() )
637 replaceEntry.assignUid(); 640 replaceEntry.assignUid();
638 abList->replaceCurrentEntry( replaceEntry ); 641 abList->replaceCurrentEntry( replaceEntry );
639 } 642 }
640 } 643 }
641 populateCategories(); 644 populateCategories();
642 showList(); 645 showList();
643} 646}
644 647
645void AddressbookWindow::listIsEmpty( bool empty ) 648void AddressbookWindow::listIsEmpty( bool empty )
646{ 649{
647 if ( !empty ) { 650 if ( !empty ) {
648 deleteButton->setEnabled( TRUE ); 651 deleteButton->setEnabled( TRUE );
649 } 652 }
650} 653}
651 654
652void AddressbookWindow::reload() 655void AddressbookWindow::reload()
653{ 656{
654 syncing = FALSE; 657 syncing = FALSE;
655 abList->clear(); 658 abList->clear();
656 abList->load( addressbookXMLFilename() ); 659 abList->load( addressbookXMLFilename() );
657} 660}
658 661
659void AddressbookWindow::flush() 662void AddressbookWindow::flush()
660{ 663{
661 syncing = TRUE; 664 syncing = TRUE;
662 abList->save( addressbookXMLFilename() ); 665 abList->save( addressbookXMLFilename() );
663} 666}
664 667
665 668
666void AddressbookWindow::closeEvent( QCloseEvent *e ) 669void AddressbookWindow::closeEvent( QCloseEvent *e )
667{ 670{
668 if ( centralWidget() == mView ) { 671 if ( centralWidget() == mView ) {
669 if (actionPersonal->isOn()) { 672 if (actionPersonal->isOn()) {
670 // pretend we clicked it off 673 // pretend we clicked it off
671 actionPersonal->setOn(FALSE); 674 actionPersonal->setOn(FALSE);
672 slotPersonalView(); 675 slotPersonalView();
673 } else { 676 } else {
674 showList(); 677 showList();
675 } 678 }
676 e->ignore(); 679 e->ignore();
677 return; 680 return;
678 } 681 }
679 682
680 if(syncing) { 683 if(syncing) {
681 /* shouldn't we save, I hear you say? well its already been set 684 /* shouldn't we save, I hear you say? well its already been set
682 so that an edit can not occur during a sync, and we flushed 685 so that an edit can not occur during a sync, and we flushed
683 at the start of the sync, so there is no need to save 686 at the start of the sync, so there is no need to save
684 Saving however itself would cause problems. */ 687 Saving however itself would cause problems. */
685 e->accept(); 688 e->accept();
686 return; 689 return;
687 } 690 }
688//################## shouldn't always save 691//################## shouldn't always save
689 if ( save() ) 692 if ( save() )
690 e->accept(); 693 e->accept();
691 else 694 else
692 e->ignore(); 695 e->ignore();
693} 696}
694 697
695/* 698/*
696 Returns TRUE if it is OK to exit 699 Returns TRUE if it is OK to exit
697 */ 700 */
698 701
699bool AddressbookWindow::save() 702bool AddressbookWindow::save()
700{ 703{
701 QString str = addressbookXMLFilename(); 704 QString str = addressbookXMLFilename();
702 if ( str.isNull() ) { 705 if ( str.isNull() ) {
703 if ( QMessageBox::critical( 0, tr("Out of space"), 706 if ( QMessageBox::critical( 0, tr("Out of space"),
704 tr("Unable to save information.\n" 707 tr("Unable to save information.\n"
705 "Free up some space\n" 708 "Free up some space\n"
706 "and try again.\n" 709 "and try again.\n"
707 "\nQuit anyway?"), 710 "\nQuit anyway?"),
708 QMessageBox::Yes|QMessageBox::Escape, 711 QMessageBox::Yes|QMessageBox::Escape,
709 QMessageBox::No|QMessageBox::Default ) 712 QMessageBox::No|QMessageBox::Default )
710 != QMessageBox::No ) 713 != QMessageBox::No )
711 return TRUE; 714 return TRUE;
712 else 715 else
713 return FALSE; 716 return FALSE;
714 } else { 717 } else {
715 if ( !abList->save( str ) ) { 718 if ( !abList->save( str ) ) {
716 if ( QMessageBox::critical( 0, tr( "Out of space" ), 719 if ( QMessageBox::critical( 0, tr( "Out of space" ),
717 tr("Unable to save information.\n" 720 tr("Unable to save information.\n"
718 "Free up some space\n" 721 "Free up some space\n"
719 "and try again.\n" 722 "and try again.\n"
720 "\nQuit anyway?"), 723 "\nQuit anyway?"),
721 QMessageBox::Yes|QMessageBox::Escape, 724 QMessageBox::Yes|QMessageBox::Escape,
722 QMessageBox::No|QMessageBox::Default ) 725 QMessageBox::No|QMessageBox::Default )
723 != QMessageBox::No ) 726 != QMessageBox::No )
724 return TRUE; 727 return TRUE;
725 else 728 else
726 return FALSE; 729 return FALSE;
727 } 730 }
728 } 731 }
729 return TRUE; 732 return TRUE;
730} 733}
731 734
732void AddressbookWindow::slotSettings() 735void AddressbookWindow::slotSettings()
733{ 736{
734 AddressSettings frmSettings( this ); 737 AddressSettings frmSettings( this );
735#if defined(Q_WS_QWS) || defined(_WS_QWS_) 738#if defined(Q_WS_QWS) || defined(_WS_QWS_)
736 frmSettings.showMaximized(); 739 frmSettings.showMaximized();
737#endif 740#endif
738 741
739 if ( frmSettings.exec() ) { 742 if ( frmSettings.exec() ) {
740 allFields.clear(); 743 allFields.clear();
741 orderedFields.clear(); 744 orderedFields.clear();
742 slOrderedFields.clear(); 745 slOrderedFields.clear();
743 initFields(); 746 initFields();
744 if ( abEditor ) 747 if ( abEditor )
745 abEditor->loadFields(); 748 abEditor->loadFields();
746 abList->refresh(); 749 abList->refresh();
747 } 750 }
748} 751}
749 752
750 753
751void AddressbookWindow::initFields() 754void AddressbookWindow::initFields()
752{ 755{
753 // we really don't need the things from the configuration, anymore 756 // we really don't need the things from the configuration, anymore
754 // only thing that is important are the important categories. So, 757 // only thing that is important are the important categories. So,
755 // Call the contact functions that correspond to these old functions... 758 // Call the contact functions that correspond to these old functions...
756 759
757 QStringList xmlFields = Contact::fields(); 760 QStringList xmlFields = Contact::fields();
758 QStringList visibleFields = Contact::trfields(); 761 QStringList visibleFields = Contact::trfields();
759 xmlFields.remove( "Title" ); 762 xmlFields.remove( "Title" );
760 visibleFields.remove( tr("Name Title") ); 763 visibleFields.remove( tr("Name Title") );
761 visibleFields.remove( tr("Notes") ); 764 visibleFields.remove( tr("Notes") );
762 765
763 int i, 766 int i,
764 version; 767 version;
765 Config cfg( "AddressBook" ); 768 Config cfg( "AddressBook" );
766 QString zn; 769 QString zn;
767 770
768 // ### Write a function to keep this from happening again... 771 // ### Write a function to keep this from happening again...
769 QStringList::ConstIterator it; 772 QStringList::ConstIterator it;
770 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { 773 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
771 allFields.append( i + 3 ); 774 allFields.append( i + 3 );
772 } 775 }
773 776
774 cfg.setGroup( "Version" ); 777 cfg.setGroup( "Version" );
775 version = cfg.readNumEntry( "version" ); 778 version = cfg.readNumEntry( "version" );
776 i = 0; 779 i = 0;
777 startFontSize = 1; 780 startFontSize = 1;
778 781
779 if ( version >= ADDRESSVERSION ) { 782 if ( version >= ADDRESSVERSION ) {
780 783
781 cfg.setGroup( "ImportantCategory" ); 784 cfg.setGroup( "ImportantCategory" );
782 785
783 zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); 786 zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
784 while ( !zn.isNull() ) { 787 while ( !zn.isNull() ) {
785 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { 788 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) {
786 slOrderedFields.clear(); 789 slOrderedFields.clear();
787 break; 790 break;
788 } 791 }
789 slOrderedFields.append( zn ); 792 slOrderedFields.append( zn );
790 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); 793 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
791 } 794 }
792 cfg.setGroup( "Font" ); 795 cfg.setGroup( "Font" );
793 startFontSize = cfg.readNumEntry( "fontSize", 1 ); 796 startFontSize = cfg.readNumEntry( "fontSize", 1 );
794 797
795 798
796 } else { 799 } else {
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
@@ -1,104 +1,105 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
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
25class ContactEditor; 25class ContactEditor;
26class AbLabel; 26class AbLabel;
27class AbTable; 27class AbTable;
28class QPEToolBar; 28class QPEToolBar;
29class QPopupMenu; 29class QPopupMenu;
30class QToolButton; 30class QToolButton;
31class QDialog; 31class QDialog;
32class Ir; 32class Ir;
33class QAction; 33class QAction;
34class LetterPicker; 34class LetterPicker;
35 35
36class AddressbookWindow: public QMainWindow 36class AddressbookWindow: public QMainWindow
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39public: 39public:
40 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 40 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
41 ~AddressbookWindow(); 41 ~AddressbookWindow();
42 42
43protected: 43protected:
44 void resizeEvent( QResizeEvent * e ); 44 void resizeEvent( QResizeEvent * e );
45 void showList(); 45 void showList();
46 void showView(); 46 void showView();
47 enum EntryMode { NewEntry=0, EditEntry }; 47 enum EntryMode { NewEntry=0, EditEntry };
48 void editPersonal(); 48 void editPersonal();
49 void editEntry( EntryMode ); 49 void editEntry( EntryMode );
50 void closeEvent( QCloseEvent *e ); 50 void closeEvent( QCloseEvent *e );
51 bool save(); 51 bool save();
52 52
53public slots: 53public slots:
54 void flush(); 54 void flush();
55 void reload(); 55 void reload();
56 void appMessage(const QCString &, const QByteArray &); 56 void appMessage(const QCString &, const QByteArray &);
57 void setDocument( const QString & ); 57 void setDocument( const QString & );
58 58
59private slots: 59private slots:
60 void slotListNew(); 60 void slotListNew();
61 void slotListView(); 61 void slotListView();
62 void slotListDelete(); 62 void slotListDelete();
63 void slotViewBack(); 63 void slotViewBack();
64 void slotViewEdit(); 64 void slotViewEdit();
65 void slotPersonalView(); 65 void slotPersonalView();
66 void listIsEmpty( bool ); 66 void listIsEmpty( bool );
67 void slotSettings(); 67 void slotSettings();
68 void writeMail(); 68 void writeMail();
69 void slotBeam(); 69 void slotBeam();
70 void beamDone( Ir * ); 70 void beamDone( Ir * );
71 void slotFind(); 71 void slotFind();
72 void slotSetCategory( int ); 72 void slotSetCategory( int );
73 void slotSetLetter( char ); 73 void slotSetLetter( char );
74 void slotUpdateToolbar(); 74 void slotUpdateToolbar();
75 void slotSetFont(int); 75 void slotSetFont(int);
76private: 76private:
77 void initFields();// inititialize our fields... 77 void initFields();// inititialize our fields...
78 AbLabel *abView(); 78 AbLabel *abView();
79 void populateCategories(); 79 void populateCategories();
80 80
81 QPopupMenu *catMenu, *fontMenu; 81 QPopupMenu *catMenu, *fontMenu;
82 QPEToolBar *listTools; 82 QPEToolBar *listTools;
83 QToolButton *deleteButton; 83 QToolButton *deleteButton;
84 QValueList<int> allFields, 84 QValueList<int> allFields,
85 orderedFields; 85 orderedFields;
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;
98 99
99 bool syncing; 100 bool syncing;
100 QFont *defaultFont; 101 QFont *defaultFont;
101 int startFontSize; 102 int startFontSize;
102}; 103};
103 104
104#endif 105#endif
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
@@ -1,234 +1,229 @@
1#include "picker.h" 1#include "picker.h"
2 2
3#include <qfont.h> 3#include <qfont.h>
4#include <qstring.h> 4#include <qstring.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qlayout.h> 6#include <qlayout.h>
7 7
8char PickerLabel::lastLetter = '\0'; 8char PickerLabel::lastLetter = '\0';
9 9
10PickerLabel::PickerLabel( QWidget *parent, const char *name ) 10PickerLabel::PickerLabel( QWidget *parent, const char *name )
11 : QLabel ( parent, name ) 11 : QLabel ( parent, name )
12{ 12{
13 currentLetter = 0; 13 currentLetter = 0;
14 //lastLetter = 0; 14 //lastLetter = 0;
15 15
16 letter1 = '\0'; 16 letter1 = '\0';
17 letter2 = '\0'; 17 letter2 = '\0';
18 letter3 = '\0'; 18 letter3 = '\0';
19 19
20 setFont( QFont( "smallsmooth", 9 ) ); 20 setFont( QFont( "smallsmooth", 9 ) );
21 setTextFormat( Qt::RichText ); 21 setTextFormat( Qt::RichText );
22 22
23} 23}
24 24
25PickerLabel::~PickerLabel() 25PickerLabel::~PickerLabel()
26{ 26{
27 27
28} 28}
29 29
30void PickerLabel::setLetters( char ch1, char ch2, char ch3 ) 30void PickerLabel::setLetters( char ch1, char ch2, char ch3 )
31{ 31{
32 QString tmpStr; 32 QString tmpStr;
33 33
34 if (ch1 != '\0') 34 if (ch1 != '\0')
35 letter1 = ch1; 35 letter1 = ch1;
36 else 36 else
37 letter1 = ' '; 37 letter1 = ' ';
38 38
39 if (ch2 != '\0') 39 if (ch2 != '\0')
40 letter2 = ch2; 40 letter2 = ch2;
41 else 41 else
42 letter2 = ' '; 42 letter2 = ' ';
43 43
44 if (ch3 != '\0') 44 if (ch3 != '\0')
45 letter3 = ch3; 45 letter3 = ch3;
46 else 46 else
47 letter3 = ' '; 47 letter3 = ' ';
48 48
49 tmpStr = "<qt>"; 49 tmpStr = "<qt>";
50 tmpStr += letter1; 50 tmpStr += letter1;
51 tmpStr += letter2; 51 tmpStr += letter2;
52 tmpStr += letter3; 52 tmpStr += letter3;
53 tmpStr += "</qt>"; 53 tmpStr += "</qt>";
54 54
55 setText(tmpStr); 55 setText(tmpStr);
56 56
57 currentLetter = 0; 57 currentLetter = 0;
58 58
59} 59}
60 60
61void PickerLabel::clearLetter() 61void PickerLabel::clearLetter()
62{ 62{
63 63
64 QString tmpStr; 64 QString tmpStr;
65 65
66 tmpStr = "<qt>"; 66 tmpStr = "<qt>";
67 tmpStr += letter1; 67 tmpStr += letter1;
68 tmpStr += letter2; 68 tmpStr += letter2;
69 tmpStr += letter3; 69 tmpStr += letter3;
70 tmpStr += "</qt>"; 70 tmpStr += "</qt>";
71 71
72 setText(tmpStr); 72 setText(tmpStr);
73 73
74 currentLetter = 0; 74 currentLetter = 0;
75 75
76} 76}
77 77
78void PickerLabel::mouseReleaseEvent( QMouseEvent *e ) 78void 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;
92 tmpStr += letter3; 91 tmpStr += letter3;
93 tmpStr += "</qt>"; 92 tmpStr += "</qt>";
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\">";
107 tmpStr += letter2; 105 tmpStr += letter2;
108 tmpStr += "</font>"; 106 tmpStr += "</font>";
109 tmpStr += letter3; 107 tmpStr += letter3;
110 tmpStr += "</qt>"; 108 tmpStr += "</qt>";
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;
124 tmpStr += "<font color=\"#7F0000\">"; 121 tmpStr += "<font color=\"#7F0000\">";
125 tmpStr += letter3; 122 tmpStr += letter3;
126 tmpStr += "</font></qt>"; 123 tmpStr += "</font></qt>";
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' );
140 136
141 137
142 } 138 }
143} 139}
144 140
145void PickerLabel::emitClearSignal() { 141void PickerLabel::emitClearSignal() {
146 emit clearAll(); 142 emit clearAll();
147} 143}
148 144
149LetterPicker::LetterPicker( QWidget *parent, const char *name ) 145LetterPicker::LetterPicker( QWidget *parent, const char *name )
150 : QFrame( parent, name ) 146 : QFrame( parent, name )
151{ 147{
152 QHBoxLayout *l = new QHBoxLayout(this); 148 QHBoxLayout *l = new QHBoxLayout(this);
153 149
154 lblABC = new PickerLabel( this ); 150 lblABC = new PickerLabel( this );
155 l->addWidget( lblABC ); 151 l->addWidget( lblABC );
156 152
157 lblDEF = new PickerLabel( this ); 153 lblDEF = new PickerLabel( this );
158 l->addWidget( lblDEF ); 154 l->addWidget( lblDEF );
159 155
160 lblGHI = new PickerLabel( this ); 156 lblGHI = new PickerLabel( this );
161 l->addWidget( lblGHI ); 157 l->addWidget( lblGHI );
162 158
163 lblJKL = new PickerLabel( this ); 159 lblJKL = new PickerLabel( this );
164 l->addWidget( lblJKL ); 160 l->addWidget( lblJKL );
165 161
166 lblMNO = new PickerLabel( this ); 162 lblMNO = new PickerLabel( this );
167 l->addWidget( lblMNO ); 163 l->addWidget( lblMNO );
168 164
169 lblPQR = new PickerLabel( this ); 165 lblPQR = new PickerLabel( this );
170 l->addWidget( lblPQR ); 166 l->addWidget( lblPQR );
171 167
172 lblSTU = new PickerLabel( this ); 168 lblSTU = new PickerLabel( this );
173 l->addWidget( lblSTU ); 169 l->addWidget( lblSTU );
174 170
175 lblVWX = new PickerLabel( this ); 171 lblVWX = new PickerLabel( this );
176 l->addWidget( lblVWX ); 172 l->addWidget( lblVWX );
177 173
178 lblYZ = new PickerLabel( this ); 174 lblYZ = new PickerLabel( this );
179 l->addWidget( lblYZ ); 175 l->addWidget( lblYZ );
180 176
181 lblABC->setLetters( 'A', 'B', 'C' ); 177 lblABC->setLetters( 'A', 'B', 'C' );
182 lblDEF->setLetters( 'D', 'E', 'F' ); 178 lblDEF->setLetters( 'D', 'E', 'F' );
183 lblGHI->setLetters( 'G', 'H', 'I' ); 179 lblGHI->setLetters( 'G', 'H', 'I' );
184 lblJKL->setLetters( 'J', 'K', 'L' ); 180 lblJKL->setLetters( 'J', 'K', 'L' );
185 lblMNO->setLetters( 'M', 'N', 'O' ); 181 lblMNO->setLetters( 'M', 'N', 'O' );
186 lblPQR->setLetters( 'P', 'Q', 'R' ); 182 lblPQR->setLetters( 'P', 'Q', 'R' );
187 lblSTU->setLetters( 'S', 'T', 'U' ); 183 lblSTU->setLetters( 'S', 'T', 'U' );
188 lblVWX->setLetters( 'V', 'W', 'X' ); 184 lblVWX->setLetters( 'V', 'W', 'X' );
189 lblYZ->setLetters( 'Y', 'Z', '#' ); 185 lblYZ->setLetters( 'Y', 'Z', '#' );
190 186
191 connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 187 connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
192 connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 188 connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
193 connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 189 connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
194 connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 190 connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
195 connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 191 connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
196 connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 192 connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
197 connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 193 connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
198 connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 194 connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
199 connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 195 connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
200 connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear())); 196 connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear()));
201 connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear())); 197 connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear()));
202 connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear())); 198 connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear()));
203 connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear())); 199 connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear()));
204 connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear())); 200 connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear()));
205 connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear())); 201 connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear()));
206 connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear())); 202 connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear()));
207 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear())); 203 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear()));
208 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear())); 204 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear()));
209 205
210} 206}
211 207
212LetterPicker::~LetterPicker() 208LetterPicker::~LetterPicker()
213{ 209{
214} 210}
215 211
216void LetterPicker::clear() 212void LetterPicker::clear()
217{ 213{
218 lblABC->clearLetter(); 214 lblABC->clearLetter();
219 lblDEF->clearLetter(); 215 lblDEF->clearLetter();
220 lblGHI->clearLetter(); 216 lblGHI->clearLetter();
221 lblJKL->clearLetter(); 217 lblJKL->clearLetter();
222 lblMNO->clearLetter(); 218 lblMNO->clearLetter();
223 lblPQR->clearLetter(); 219 lblPQR->clearLetter();
224 lblSTU->clearLetter(); 220 lblSTU->clearLetter();
225 lblVWX->clearLetter(); 221 lblVWX->clearLetter();
226 lblYZ->clearLetter(); 222 lblYZ->clearLetter();
227} 223}
228 224
229void LetterPicker::newLetter( char letter ) 225void LetterPicker::newLetter( char letter )
230{ 226{
231 qDebug( "LetterPicker::newLetter %c", letter );
232 emit letterClicked( letter ); 227 emit letterClicked( letter );
233 228
234} 229}