summaryrefslogtreecommitdiff
authorar <ar>2004-02-07 23:52:31 (UTC)
committer ar <ar>2004-02-07 23:52:31 (UTC)
commit6582895befc98131430710191238a93b9dde161c (patch) (unidiff)
treed050483742d0e102e08138bcdd8f170a9558b12d
parent3f261fa6eac46b8d0d4ac8b8bb95b385435004da (diff)
downloadopie-6582895befc98131430710191238a93b9dde161c.zip
opie-6582895befc98131430710191238a93b9dde161c.tar.gz
opie-6582895befc98131430710191238a93b9dde161c.tar.bz2
QPEApplication::showDialog() and QPEAPplication::execDialog() for better big screen handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp5
-rw-r--r--core/apps/textedit/textedit.cpp6
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp3
-rw-r--r--core/pim/addressbook/abeditor.cpp3
-rw-r--r--core/pim/addressbook/addressbook.cpp8
-rw-r--r--core/pim/addressbook/contacteditor.cpp6
-rw-r--r--core/pim/datebook/datebook.cpp27
-rw-r--r--core/pim/datebook/dateentryimpl.cpp10
-rw-r--r--core/pim/datebook2/mainwindow.cpp9
-rw-r--r--core/pim/todo/mainwindow.cpp3
-rw-r--r--core/pim/todo/todoeditor.cpp9
-rw-r--r--core/settings/light-and-power/light.cpp4
12 files changed, 28 insertions, 65 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index a5adc03..ce8fb6b 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,145 +1,146 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
4/* */ 4/* */
5/* ---------------------------------------------------------------------- */ 5/* ---------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21// enhancements added by L.J. Potter <ljp@llornkcor.com> 21// enhancements added by L.J. Potter <ljp@llornkcor.com>
22//#define QT_QWS_OPIE 22//#define QT_QWS_OPIE
23 23
24#include "signal.h" 24#include "signal.h"
25 25
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27 27
28#include <qdir.h> 28#include <qdir.h>
29#include <qevent.h> 29#include <qevent.h>
30#include <qdragobject.h> 30#include <qdragobject.h>
31#include <qobjectlist.h> 31#include <qobjectlist.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <qfontdialog.h> 35#include <qfontdialog.h>
36#include <qglobal.h> 36#include <qglobal.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qmenubar.h> 38#include <qmenubar.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qaction.h> 40#include <qaction.h>
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qfontmetrics.h> 42#include <qfontmetrics.h>
43#include <qcombobox.h> 43#include <qcombobox.h>
44#include <qevent.h> 44#include <qevent.h>
45#include <qtabwidget.h> 45#include <qtabwidget.h>
46#include <qtabbar.h> 46#include <qtabbar.h>
47#include <qpe/config.h>
48#include <qstringlist.h> 47#include <qstringlist.h>
49#include <qpalette.h> 48#include <qpalette.h>
49#include <qpe/config.h>
50#include <qpe/qpeapplication.h>
50 51
51#include <unistd.h> 52#include <unistd.h>
52#include <pwd.h> 53#include <pwd.h>
53#include <sys/types.h> 54#include <sys/types.h>
54//#include <sys/wait.h> 55//#include <sys/wait.h>
55#include <stdio.h> 56#include <stdio.h>
56#include <stdlib.h> 57#include <stdlib.h>
57#include <assert.h> 58#include <assert.h>
58 59
59#include "konsole.h" 60#include "konsole.h"
60#include "keytrans.h" 61#include "keytrans.h"
61#include "commandeditdialog.h" 62#include "commandeditdialog.h"
62 63
63#ifdef QT_QWS_OPIE 64#ifdef QT_QWS_OPIE
64#include <opie/colorpopupmenu.h> 65#include <opie/colorpopupmenu.h>
65#endif 66#endif
66 67
67 #include <qfontdatabase.h>// U.B. 68 #include <qfontdatabase.h>// U.B.
68 #include <qstringlist.h>// U.B. 69 #include <qstringlist.h>// U.B.
69 #include <qvaluelist.h> // U.B. 70 #include <qvaluelist.h> // U.B.
70 71
71class EKNumTabBar : public QTabBar { 72class EKNumTabBar : public QTabBar {
72public: 73public:
73 void numberTabs() 74 void numberTabs()
74 { 75 {
75 // Yes, it really is this messy. QTabWidget needs functions 76 // Yes, it really is this messy. QTabWidget needs functions
76 // that provide acces to tabs in a sequential way. 77 // that provide acces to tabs in a sequential way.
77 int m=INT_MIN; 78 int m=INT_MIN;
78 for (int i=0; i<count(); i++) { 79 for (int i=0; i<count(); i++) {
79 QTab* left=0; 80 QTab* left=0;
80 QListIterator<QTab> it(*tabList()); 81 QListIterator<QTab> it(*tabList());
81 int x=INT_MAX; 82 int x=INT_MAX;
82 for( QTab* t; (t=it.current()); ++it ) { 83 for( QTab* t; (t=it.current()); ++it ) {
83 int tx = t->rect().x(); 84 int tx = t->rect().x();
84 if ( tx<x && tx>m ) { 85 if ( tx<x && tx>m ) {
85 x = tx; 86 x = tx;
86 left = t; 87 left = t;
87 } 88 }
88 } 89 }
89 if ( left ) { 90 if ( left ) {
90 left->setText(QString::number(i+1)); 91 left->setText(QString::number(i+1));
91 m = left->rect().x(); 92 m = left->rect().x();
92 } 93 }
93 } 94 }
94 } 95 }
95}; 96};
96 97
97class EKNumTabWidget : public QTabWidget { 98class EKNumTabWidget : public QTabWidget {
98public: 99public:
99 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 100 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
100 { 101 {
101 } 102 }
102 103
103 void addTab(QWidget* w) 104 void addTab(QWidget* w)
104 { 105 {
105 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 106 QTab* t = new QTab(QString::number(tabBar()->count()+1));
106 QTabWidget::addTab(w,t); 107 QTabWidget::addTab(w,t);
107 } 108 }
108 109
109 void removeTab(QWidget* w) 110 void removeTab(QWidget* w)
110 { 111 {
111 removePage(w); 112 removePage(w);
112 ((EKNumTabBar*)tabBar())->numberTabs(); 113 ((EKNumTabBar*)tabBar())->numberTabs();
113 } 114 }
114}; 115};
115 116
116// This could be configurable or dynamicly generated from the bash history 117// This could be configurable or dynamicly generated from the bash history
117// file of the user 118// file of the user
118static const char *commonCmds[] = 119static const char *commonCmds[] =
119{ 120{
120 "ls ", // I left this here, cause it looks better than the first alpha 121 "ls ", // I left this here, cause it looks better than the first alpha
121 "cardctl eject", 122 "cardctl eject",
122 "cat ", 123 "cat ",
123 "cd ", 124 "cd ",
124 "chmod ", 125 "chmod ",
125 "clear", 126 "clear",
126 "cp ", 127 "cp ",
127 "dc ", 128 "dc ",
128 "df ", 129 "df ",
129 "dmesg", 130 "dmesg",
130 "echo ", 131 "echo ",
131 "env", 132 "env",
132 "find ", 133 "find ",
133 "free", 134 "free",
134 "grep ", 135 "grep ",
135 "ifconfig ", 136 "ifconfig ",
136 "ipkg ", 137 "ipkg ",
137 "mkdir ", 138 "mkdir ",
138 "mv ", 139 "mv ",
139 "nc localhost 7776", 140 "nc localhost 7776",
140 "nc localhost 7777", 141 "nc localhost 7777",
141 "netstat ", 142 "netstat ",
142 "nslookup ", 143 "nslookup ",
143 "ping ", 144 "ping ",
144 "ps aux", 145 "ps aux",
145 "pwd ", 146 "pwd ",
@@ -983,193 +984,193 @@ void Konsole::setColor()
983 cfg.setGroup("Colors"); 984 cfg.setGroup("Colors");
984 int scheme = cfg.readNumEntry("Schema",1); 985 int scheme = cfg.readNumEntry("Schema",1);
985 if(scheme != 1) colorMenuSelected( -scheme); 986 if(scheme != 1) colorMenuSelected( -scheme);
986} 987}
987 988
988void Konsole::scrollMenuSelected(int index) 989void Konsole::scrollMenuSelected(int index)
989{ 990{
990// qDebug( "scrollbar menu %d",index); 991// qDebug( "scrollbar menu %d",index);
991 992
992 TEWidget* te = getTe(); 993 TEWidget* te = getTe();
993 Config cfg("Konsole"); 994 Config cfg("Konsole");
994 cfg.setGroup("ScrollBar"); 995 cfg.setGroup("ScrollBar");
995 int i,j,k; 996 int i,j,k;
996#ifdef QT_QWS_OPIE 997#ifdef QT_QWS_OPIE
997i=-25;j=-26;k=-27; 998i=-25;j=-26;k=-27;
998#else 999#else
999i=-24;j=-25;k=-26; 1000i=-24;j=-25;k=-26;
1000#endif 1001#endif
1001 if(index == i) { 1002 if(index == i) {
1002 1003
1003 te->setScrollbarLocation(0); 1004 te->setScrollbarLocation(0);
1004 cfg.writeEntry("Position",0); 1005 cfg.writeEntry("Position",0);
1005 } else if(index == j) { 1006 } else if(index == j) {
1006 1007
1007 te->setScrollbarLocation(1); 1008 te->setScrollbarLocation(1);
1008 cfg.writeEntry("Position",1); 1009 cfg.writeEntry("Position",1);
1009 } else if(index == k) { 1010 } else if(index == k) {
1010 1011
1011 te->setScrollbarLocation(2); 1012 te->setScrollbarLocation(2);
1012 cfg.writeEntry("Position",2); 1013 cfg.writeEntry("Position",2);
1013 } 1014 }
1014 1015
1015// case -29: { 1016// case -29: {
1016// bool b=cfg.readBoolEntry("HorzScroll",0); 1017// bool b=cfg.readBoolEntry("HorzScroll",0);
1017// cfg.writeEntry("HorzScroll", !b ); 1018// cfg.writeEntry("HorzScroll", !b );
1018// cfg.write(); 1019// cfg.write();
1019// if(cfg.readNumEntry("Position",2) == 0) { 1020// if(cfg.readNumEntry("Position",2) == 0) {
1020// te->setScrollbarLocation(1); 1021// te->setScrollbarLocation(1);
1021// te->setWrapAt(0); 1022// te->setWrapAt(0);
1022// } else { 1023// } else {
1023// te->setScrollbarLocation(0); 1024// te->setScrollbarLocation(0);
1024// te->setWrapAt(120); 1025// te->setWrapAt(120);
1025// } 1026// }
1026// te->setScrollbarLocation( cfg.readNumEntry("Position",2)); 1027// te->setScrollbarLocation( cfg.readNumEntry("Position",2));
1027// } 1028// }
1028// break; 1029// break;
1029} 1030}
1030 1031
1031void Konsole::editCommandListMenuSelected(int iD) 1032void Konsole::editCommandListMenuSelected(int iD)
1032{ 1033{
1033// QString temp; 1034// QString temp;
1034// qDebug( temp.sprintf("edit command list %d",iD)); 1035// qDebug( temp.sprintf("edit command list %d",iD));
1035 TEWidget* te = getTe(); 1036 TEWidget* te = getTe();
1036 Config cfg("Konsole"); 1037 Config cfg("Konsole");
1037 cfg.setGroup("Menubar"); 1038 cfg.setGroup("Menubar");
1038 if( iD == -3) { 1039 if( iD == -3) {
1039 if(!secondToolBar->isHidden()) { 1040 if(!secondToolBar->isHidden()) {
1040 secondToolBar->hide(); 1041 secondToolBar->hide();
1041 configMenu->changeItem( iD,tr( "Show Command List" )); 1042 configMenu->changeItem( iD,tr( "Show Command List" ));
1042 cfg.writeEntry("Hidden","TRUE"); 1043 cfg.writeEntry("Hidden","TRUE");
1043 configMenu->setItemEnabled(-23 ,FALSE); 1044 configMenu->setItemEnabled(-23 ,FALSE);
1044 } else { 1045 } else {
1045 secondToolBar->show(); 1046 secondToolBar->show();
1046 configMenu->changeItem( iD,tr( "Hide Command List" )); 1047 configMenu->changeItem( iD,tr( "Hide Command List" ));
1047 cfg.writeEntry("Hidden","FALSE"); 1048 cfg.writeEntry("Hidden","FALSE");
1048 configMenu->setItemEnabled(-23 ,TRUE); 1049 configMenu->setItemEnabled(-23 ,TRUE);
1049 1050
1050 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { 1051 if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") {
1051 configMenu->setItemChecked(-23,TRUE); 1052 configMenu->setItemChecked(-23,TRUE);
1052 commonCombo->setEditable( TRUE ); 1053 commonCombo->setEditable( TRUE );
1053 } else { 1054 } else {
1054 configMenu->setItemChecked(-23,FALSE); 1055 configMenu->setItemChecked(-23,FALSE);
1055 commonCombo->setEditable( FALSE ); 1056 commonCombo->setEditable( FALSE );
1056 } 1057 }
1057 } 1058 }
1058 } 1059 }
1059 if( iD == -23) { 1060 if( iD == -23) {
1060 cfg.setGroup("Commands"); 1061 cfg.setGroup("Commands");
1061// qDebug("enableCommandEdit"); 1062// qDebug("enableCommandEdit");
1062 if( !configMenu->isItemChecked(iD) ) { 1063 if( !configMenu->isItemChecked(iD) ) {
1063 commonCombo->setEditable( TRUE ); 1064 commonCombo->setEditable( TRUE );
1064 configMenu->setItemChecked(iD,TRUE); 1065 configMenu->setItemChecked(iD,TRUE);
1065 commonCombo->setCurrentItem(0); 1066 commonCombo->setCurrentItem(0);
1066 cfg.writeEntry("EditEnabled","TRUE"); 1067 cfg.writeEntry("EditEnabled","TRUE");
1067 } else { 1068 } else {
1068 commonCombo->setEditable( FALSE ); 1069 commonCombo->setEditable( FALSE );
1069 configMenu->setItemChecked(iD,FALSE); 1070 configMenu->setItemChecked(iD,FALSE);
1070 cfg.writeEntry("EditEnabled","FALSE"); 1071 cfg.writeEntry("EditEnabled","FALSE");
1071 commonCombo->setFocusPolicy(QWidget::NoFocus); 1072 commonCombo->setFocusPolicy(QWidget::NoFocus);
1072 te->setFocus(); 1073 te->setFocus();
1073 } 1074 }
1074 } 1075 }
1075 if(iD == -24) { 1076 if(iD == -24) {
1076 // "edit commands" 1077 // "edit commands"
1077 CommandEditDialog *m = new CommandEditDialog(this); 1078 CommandEditDialog *m = new CommandEditDialog(this);
1078 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 1079 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
1079 m->showMaximized(); 1080 QPEApplication::showDialog( m );
1080 } 1081 }
1081 1082
1082} 1083}
1083 1084
1084// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' 1085// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
1085void Konsole::setDocument( const QString &cmd) { 1086void Konsole::setDocument( const QString &cmd) {
1086 newSession(); 1087 newSession();
1087 TEWidget* te = getTe(); 1088 TEWidget* te = getTe();
1088 if(cmd.find("-e", 0, TRUE) != -1) { 1089 if(cmd.find("-e", 0, TRUE) != -1) {
1089 QString cmd2; 1090 QString cmd2;
1090 cmd2=cmd.right(cmd.length()-3)+" &"; 1091 cmd2=cmd.right(cmd.length()-3)+" &";
1091 system(cmd2.latin1()); 1092 system(cmd2.latin1());
1092 if(startUp <= 1 && nsessions < 2) { 1093 if(startUp <= 1 && nsessions < 2) {
1093 doneSession(getTe()->currentSession, 0); 1094 doneSession(getTe()->currentSession, 0);
1094 exit(0); 1095 exit(0);
1095 } else 1096 } else
1096 doneSession(getTe()->currentSession, 0); 1097 doneSession(getTe()->currentSession, 0);
1097 } else { 1098 } else {
1098 if (te != 0) { 1099 if (te != 0) {
1099 te->emitText(cmd+"\r"); 1100 te->emitText(cmd+"\r");
1100 } 1101 }
1101 } 1102 }
1102 startUp++; 1103 startUp++;
1103} 1104}
1104 1105
1105void Konsole::parseCommandLine() { 1106void Konsole::parseCommandLine() {
1106 QString cmd; 1107 QString cmd;
1107 // newSession(); 1108 // newSession();
1108 for (int i=1;i< qApp->argc();i++) { 1109 for (int i=1;i< qApp->argc();i++) {
1109 if( QString(qApp->argv()[i]) == "-e") { 1110 if( QString(qApp->argv()[i]) == "-e") {
1110 i++; 1111 i++;
1111 for ( int j=i;j< qApp->argc();j++) { 1112 for ( int j=i;j< qApp->argc();j++) {
1112 cmd+=QString(qApp->argv()[j])+" "; 1113 cmd+=QString(qApp->argv()[j])+" ";
1113 } 1114 }
1114 cmd.stripWhiteSpace(); 1115 cmd.stripWhiteSpace();
1115 system(cmd.latin1()); 1116 system(cmd.latin1());
1116 exit(0);//close(); 1117 exit(0);//close();
1117 } // end -e switch 1118 } // end -e switch
1118 } 1119 }
1119 startUp++; 1120 startUp++;
1120} 1121}
1121 1122
1122void Konsole::changeForegroundColor(const QColor &color) { 1123void Konsole::changeForegroundColor(const QColor &color) {
1123 Config cfg("Konsole"); 1124 Config cfg("Konsole");
1124 cfg.setGroup("Colors"); 1125 cfg.setGroup("Colors");
1125 int r, g, b; 1126 int r, g, b;
1126 color.rgb(&r,&g,&b); 1127 color.rgb(&r,&g,&b);
1127 foreground.setRgb(r,g,b); 1128 foreground.setRgb(r,g,b);
1128 1129
1129 cfg.writeEntry("foreground",color.name()); 1130 cfg.writeEntry("foreground",color.name());
1130 qDebug("foreground "+color.name()); 1131 qDebug("foreground "+color.name());
1131 cfg.write(); 1132 cfg.write();
1132 1133
1133qDebug("do other dialog"); 1134qDebug("do other dialog");
1134#ifdef QT_QWS_OPIE 1135#ifdef QT_QWS_OPIE
1135 1136
1136 OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); 1137 OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color");
1137 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, 1138 connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this,
1138 SLOT(changeBackgroundColor(const QColor&))); 1139 SLOT(changeBackgroundColor(const QColor&)));
1139 penColorPopupMenu2->exec(); 1140 penColorPopupMenu2->exec();
1140#endif 1141#endif
1141} 1142}
1142 1143
1143void Konsole::changeBackgroundColor(const QColor &color) { 1144void Konsole::changeBackgroundColor(const QColor &color) {
1144 1145
1145 qDebug("Change background"); 1146 qDebug("Change background");
1146 Config cfg("Konsole"); 1147 Config cfg("Konsole");
1147 cfg.setGroup("Colors"); 1148 cfg.setGroup("Colors");
1148 int r, g, b; 1149 int r, g, b;
1149 color.rgb(&r,&g,&b); 1150 color.rgb(&r,&g,&b);
1150 background.setRgb(r,g,b); 1151 background.setRgb(r,g,b);
1151 cfg.writeEntry("background",color.name()); 1152 cfg.writeEntry("background",color.name());
1152 qDebug("background "+color.name()); 1153 qDebug("background "+color.name());
1153 cfg.write(); 1154 cfg.write();
1154} 1155}
1155 1156
1156void Konsole::doWrap() { 1157void Konsole::doWrap() {
1157int i; 1158int i;
1158#ifdef QT_QWS_OPIE 1159#ifdef QT_QWS_OPIE
1159i=-29; 1160i=-29;
1160#else 1161#else
1161i=-28; 1162i=-28;
1162#endif 1163#endif
1163 1164
1164 Config cfg("Konsole"); 1165 Config cfg("Konsole");
1165 cfg.setGroup("ScrollBar"); 1166 cfg.setGroup("ScrollBar");
1166 TEWidget* te = getTe(); 1167 TEWidget* te = getTe();
1167 if( !cfg.readBoolEntry("HorzScroll",0)) { 1168 if( !cfg.readBoolEntry("HorzScroll",0)) {
1168 te->setWrapAt(0); 1169 te->setWrapAt(0);
1169 configMenu->setItemChecked( i,TRUE); 1170 configMenu->setItemChecked( i,TRUE);
1170 } else { 1171 } else {
1171// te->setWrapAt(90); 1172// te->setWrapAt(90);
1172 te->setWrapAt(120); 1173 te->setWrapAt(120);
1173 configMenu->setItemChecked( i,FALSE); 1174 configMenu->setItemChecked( i,FALSE);
1174 } 1175 }
1175} 1176}
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index be18140..1299fe3 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -849,268 +849,266 @@ bool TextEdit::saveAs() {
849 return false; 849 return false;
850 qDebug("saveAsFile " + currentFileName); 850 qDebug("saveAsFile " + currentFileName);
851 // case of nothing to save... 851 // case of nothing to save...
852// if ( !doc && !currentFileName.isEmpty()) { 852// if ( !doc && !currentFileName.isEmpty()) {
853// //|| !bFromDocView) 853// //|| !bFromDocView)
854// qDebug("no doc"); 854// qDebug("no doc");
855// return true; 855// return true;
856// } 856// }
857// if ( !editor->edited() ) { 857// if ( !editor->edited() ) {
858// delete doc; 858// delete doc;
859// doc = 0; 859// doc = 0;
860// return true; 860// return true;
861// } 861// }
862 862
863 QString rt = editor->text(); 863 QString rt = editor->text();
864 qDebug(currentFileName); 864 qDebug(currentFileName);
865 865
866 if( currentFileName.isEmpty() 866 if( currentFileName.isEmpty()
867 || currentFileName == tr("Unnamed") 867 || currentFileName == tr("Unnamed")
868 || currentFileName == tr("Text Editor")) { 868 || currentFileName == tr("Text Editor")) {
869 qDebug("do silly TT filename thing"); 869 qDebug("do silly TT filename thing");
870// if ( doc && doc->name().isEmpty() ) { 870// if ( doc && doc->name().isEmpty() ) {
871 QString pt = rt.simplifyWhiteSpace(); 871 QString pt = rt.simplifyWhiteSpace();
872 int i = pt.find( ' ' ); 872 int i = pt.find( ' ' );
873 QString docname = pt; 873 QString docname = pt;
874 if ( i > 0 ) 874 if ( i > 0 )
875 docname = pt.left( i ); 875 docname = pt.left( i );
876 // remove "." at the beginning 876 // remove "." at the beginning
877 while( docname.startsWith( "." ) ) 877 while( docname.startsWith( "." ) )
878 docname = docname.mid( 1 ); 878 docname = docname.mid( 1 );
879 docname.replace( QRegExp("/"), "_" ); 879 docname.replace( QRegExp("/"), "_" );
880 // cut the length. filenames longer than that 880 // cut the length. filenames longer than that
881 //don't make sense and something goes wrong when they get too long. 881 //don't make sense and something goes wrong when they get too long.
882 if ( docname.length() > 40 ) 882 if ( docname.length() > 40 )
883 docname = docname.left(40); 883 docname = docname.left(40);
884 if ( docname.isEmpty() ) 884 if ( docname.isEmpty() )
885 docname = tr("Unnamed"); 885 docname = tr("Unnamed");
886 if(doc) doc->setName(docname); 886 if(doc) doc->setName(docname);
887 currentFileName=docname; 887 currentFileName=docname;
888// } 888// }
889// else 889// else
890// qDebug("hmmmmmm"); 890// qDebug("hmmmmmm");
891 } 891 }
892 892
893 893
894 QMap<QString, QStringList> map; 894 QMap<QString, QStringList> map;
895 map.insert(tr("All"), QStringList() ); 895 map.insert(tr("All"), QStringList() );
896 QStringList text; 896 QStringList text;
897 text << "text/*"; 897 text << "text/*";
898 map.insert(tr("Text"), text ); 898 map.insert(tr("Text"), text );
899 text << "*"; 899 text << "*";
900 map.insert(tr("All"), text ); 900 map.insert(tr("All"), text );
901 901
902 QFileInfo cuFi( currentFileName); 902 QFileInfo cuFi( currentFileName);
903 QString filee = cuFi.fileName(); 903 QString filee = cuFi.fileName();
904 QString dire = cuFi.dirPath(); 904 QString dire = cuFi.dirPath();
905 if(dire==".") 905 if(dire==".")
906 dire = QPEApplication::documentDir(); 906 dire = QPEApplication::documentDir();
907 QString str; 907 QString str;
908 if( !featureAutoSave) 908 if( !featureAutoSave)
909 { 909 {
910 str = OFileDialog::getSaveFileName( 2, 910 str = OFileDialog::getSaveFileName( 2,
911 dire, 911 dire,
912 filee, map); 912 filee, map);
913 } 913 }
914 else 914 else
915 str=currentFileName; 915 str=currentFileName;
916 if(!str.isEmpty()) { 916 if(!str.isEmpty()) {
917 QString fileNm=str; 917 QString fileNm=str;
918 918
919 qDebug("saving filename "+fileNm); 919 qDebug("saving filename "+fileNm);
920 QFileInfo fi(fileNm); 920 QFileInfo fi(fileNm);
921 currentFileName=fi.fileName(); 921 currentFileName=fi.fileName();
922 if(doc) 922 if(doc)
923// QString file = doc->file(); 923// QString file = doc->file();
924// doc->removeFiles(); 924// doc->removeFiles();
925 delete doc; 925 delete doc;
926 DocLnk nf; 926 DocLnk nf;
927 nf.setType("text/plain"); 927 nf.setType("text/plain");
928 nf.setFile( fileNm); 928 nf.setFile( fileNm);
929 doc = new DocLnk(nf); 929 doc = new DocLnk(nf);
930// editor->setText(rt); 930// editor->setText(rt);
931 qDebug("Saving file as "+currentFileName); 931 qDebug("Saving file as "+currentFileName);
932 doc->setName( currentFileName); 932 doc->setName( currentFileName);
933 updateCaption( currentFileName); 933 updateCaption( currentFileName);
934 934
935 FileManager fm; 935 FileManager fm;
936 if ( !fm.saveFile( *doc, rt ) ) { 936 if ( !fm.saveFile( *doc, rt ) ) {
937 return false; 937 return false;
938 } 938 }
939 939
940 if( filePerms ) { 940 if( filePerms ) {
941 filePermissions *filePerm; 941 filePermissions *filePerm;
942 filePerm = new filePermissions(this, 942 filePerm = new filePermissions(this,
943 tr("Permissions"),true, 943 tr("Permissions"),true,
944 0,(const QString &)fileNm); 944 0,(const QString &)fileNm);
945 filePerm->showMaximized(); 945 QPEApplication::execDialog( filePerm );
946 filePerm->exec();
947 946
948 if( filePerm) 947 if( filePerm)
949 delete filePerm; 948 delete filePerm;
950 } 949 }
951// } 950// }
952 editor->setEdited( false); 951 editor->setEdited( false);
953 edited1 = false; 952 edited1 = false;
954 edited = false; 953 edited = false;
955 if(caption().left(1)=="*") 954 if(caption().left(1)=="*")
956 setCaption(caption().right(caption().length()-1)); 955 setCaption(caption().right(caption().length()-1));
957 956
958 return true; 957 return true;
959 } 958 }
960 qDebug("returning false"); 959 qDebug("returning false");
961 return false; 960 return false;
962} //end saveAs 961} //end saveAs
963 962
964void TextEdit::clear() { 963void TextEdit::clear() {
965 delete doc; 964 delete doc;
966 doc = 0; 965 doc = 0;
967 editor->clear(); 966 editor->clear();
968} 967}
969 968
970void TextEdit::updateCaption( const QString &name ) { 969void TextEdit::updateCaption( const QString &name ) {
971 970
972 if ( name.isEmpty() ) 971 if ( name.isEmpty() )
973 setCaption( tr("Text Editor") ); 972 setCaption( tr("Text Editor") );
974 else { 973 else {
975 QString s = name; 974 QString s = name;
976 if ( s.isNull() ) 975 if ( s.isNull() )
977 s = doc->name(); 976 s = doc->name();
978 if ( s.isEmpty() ) { 977 if ( s.isEmpty() ) {
979 s = tr( "Unnamed" ); 978 s = tr( "Unnamed" );
980 currentFileName=s; 979 currentFileName=s;
981 } 980 }
982// if(s.left(1) == "/") 981// if(s.left(1) == "/")
983// s = s.right(s.length()-1); 982// s = s.right(s.length()-1);
984 setCaption( tr("%1 - Text Editor").arg( s ) ); 983 setCaption( tr("%1 - Text Editor").arg( s ) );
985 } 984 }
986} 985}
987 986
988void TextEdit::setDocument(const QString& fileref) { 987void TextEdit::setDocument(const QString& fileref) {
989 if(fileref != "Unnamed") { 988 if(fileref != "Unnamed") {
990 currentFileName=fileref; 989 currentFileName=fileref;
991 qDebug("setDocument"); 990 qDebug("setDocument");
992 QFileInfo fi(currentFileName); 991 QFileInfo fi(currentFileName);
993 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); 992 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
994 if( (fi.baseName().left(1)).isEmpty() ) { 993 if( (fi.baseName().left(1)).isEmpty() ) {
995 openDotFile(currentFileName); 994 openDotFile(currentFileName);
996 995
997 } else { 996 } else {
998 qDebug("setDoc open"); 997 qDebug("setDoc open");
999 bFromDocView = true; 998 bFromDocView = true;
1000 openFile(fileref); 999 openFile(fileref);
1001 editor->setEdited(true); 1000 editor->setEdited(true);
1002 edited1=false; 1001 edited1=false;
1003 edited=true; 1002 edited=true;
1004 // fromSetDocument=false; 1003 // fromSetDocument=false;
1005 // doSearchBar(); 1004 // doSearchBar();
1006 } 1005 }
1007 } 1006 }
1008 updateCaption( currentFileName); 1007 updateCaption( currentFileName);
1009} 1008}
1010 1009
1011void TextEdit::changeFont() { 1010void TextEdit::changeFont() {
1012 QDialog *d = new QDialog ( this, "FontDialog", true ); 1011 QDialog *d = new QDialog ( this, "FontDialog", true );
1013 d-> setCaption ( tr( "Choose font" )); 1012 d-> setCaption ( tr( "Choose font" ));
1014 QBoxLayout *lay = new QVBoxLayout ( d ); 1013 QBoxLayout *lay = new QVBoxLayout ( d );
1015 OFontSelector *ofs = new OFontSelector ( true, d ); 1014 OFontSelector *ofs = new OFontSelector ( true, d );
1016 lay-> addWidget ( ofs ); 1015 lay-> addWidget ( ofs );
1017 ofs-> setSelectedFont ( editor-> font ( )); 1016 ofs-> setSelectedFont ( editor-> font ( ));
1018 1017
1019 d-> showMaximized ( ); 1018 if ( QPEApplication::execDialog( d ) == QDialog::Accepted )
1020 if ( d-> exec ( ) == QDialog::Accepted )
1021 editor-> setFont ( ofs-> selectedFont ( )); 1019 editor-> setFont ( ofs-> selectedFont ( ));
1022 delete d; 1020 delete d;
1023 1021
1024} 1022}
1025 1023
1026void TextEdit::editDelete() { 1024void TextEdit::editDelete() {
1027 switch ( QMessageBox::warning(this,tr("Text Editor"), 1025 switch ( QMessageBox::warning(this,tr("Text Editor"),
1028 tr("Do you really want<BR>to <B>delete</B> " 1026 tr("Do you really want<BR>to <B>delete</B> "
1029 "the current file\nfrom the disk?<BR>This is " 1027 "the current file\nfrom the disk?<BR>This is "
1030 "<B>irreversable!</B>"), 1028 "<B>irreversable!</B>"),
1031 tr("Yes"),tr("No"),0,0,1) ) { 1029 tr("Yes"),tr("No"),0,0,1) ) {
1032 case 0: 1030 case 0:
1033 if(doc) { 1031 if(doc) {
1034 doc->removeFiles(); 1032 doc->removeFiles();
1035 clear(); 1033 clear();
1036 setCaption( tr("Text Editor") ); 1034 setCaption( tr("Text Editor") );
1037 } 1035 }
1038 break; 1036 break;
1039 case 1: 1037 case 1:
1040 // exit 1038 // exit
1041 break; 1039 break;
1042 }; 1040 };
1043} 1041}
1044 1042
1045void TextEdit::changeStartConfig( bool b ) { 1043void TextEdit::changeStartConfig( bool b ) {
1046 startWithNew=b; 1044 startWithNew=b;
1047 Config cfg("TextEdit"); 1045 Config cfg("TextEdit");
1048 cfg.setGroup("View"); 1046 cfg.setGroup("View");
1049 cfg.writeEntry("startNew",b); 1047 cfg.writeEntry("startNew",b);
1050 update(); 1048 update();
1051} 1049}
1052 1050
1053void TextEdit::editorChanged() { 1051void TextEdit::editorChanged() {
1054// qDebug("editor changed"); 1052// qDebug("editor changed");
1055 if( /*editor->edited() &&*/ /*edited && */!edited1) { 1053 if( /*editor->edited() &&*/ /*edited && */!edited1) {
1056 setCaption( "*"+caption()); 1054 setCaption( "*"+caption());
1057 edited1=true; 1055 edited1=true;
1058 } 1056 }
1059 edited=true; 1057 edited=true;
1060} 1058}
1061 1059
1062void TextEdit::receive(const QCString&msg, const QByteArray &) { 1060void TextEdit::receive(const QCString&msg, const QByteArray &) {
1063 qDebug("QCop "+msg); 1061 qDebug("QCop "+msg);
1064 if ( msg == "setDocument(QString)" ) { 1062 if ( msg == "setDocument(QString)" ) {
1065 qDebug("bugger all"); 1063 qDebug("bugger all");
1066 1064
1067 } 1065 }
1068 1066
1069} 1067}
1070 1068
1071void TextEdit::doAbout() { 1069void TextEdit::doAbout() {
1072 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 1070 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
1073 "2000 Trolltech AS, and<BR>" 1071 "2000 Trolltech AS, and<BR>"
1074 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 1072 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
1075 "and is licensed under the GPL")); 1073 "and is licensed under the GPL"));
1076} 1074}
1077 1075
1078void TextEdit::doPrompt(bool b) { 1076void TextEdit::doPrompt(bool b) {
1079 promptExit=b; 1077 promptExit=b;
1080 Config cfg("TextEdit"); 1078 Config cfg("TextEdit");
1081 cfg.setGroup ( "View" ); 1079 cfg.setGroup ( "View" );
1082 cfg.writeEntry ( "PromptExit", b); 1080 cfg.writeEntry ( "PromptExit", b);
1083} 1081}
1084 1082
1085void TextEdit::doDesktop(bool b) { 1083void TextEdit::doDesktop(bool b) {
1086 openDesktop=b; 1084 openDesktop=b;
1087 Config cfg("TextEdit"); 1085 Config cfg("TextEdit");
1088 cfg.setGroup ( "View" ); 1086 cfg.setGroup ( "View" );
1089 cfg.writeEntry ( "OpenDesktop", b); 1087 cfg.writeEntry ( "OpenDesktop", b);
1090} 1088}
1091 1089
1092void TextEdit::doFilePerms(bool b) { 1090void TextEdit::doFilePerms(bool b) {
1093 filePerms=b; 1091 filePerms=b;
1094 Config cfg("TextEdit"); 1092 Config cfg("TextEdit");
1095 cfg.setGroup ( "View" ); 1093 cfg.setGroup ( "View" );
1096 cfg.writeEntry ( "FilePermissions", b); 1094 cfg.writeEntry ( "FilePermissions", b);
1097} 1095}
1098 1096
1099void TextEdit::editPasteTimeDate() { 1097void TextEdit::editPasteTimeDate() {
1100#ifndef QT_NO_CLIPBOARD 1098#ifndef QT_NO_CLIPBOARD
1101 QClipboard *cb = QApplication::clipboard(); 1099 QClipboard *cb = QApplication::clipboard();
1102 QDateTime dt = QDateTime::currentDateTime(); 1100 QDateTime dt = QDateTime::currentDateTime();
1103 cb->setText( dt.toString()); 1101 cb->setText( dt.toString());
1104 editor->paste(); 1102 editor->paste();
1105#endif 1103#endif
1106} 1104}
1107 1105
1108int TextEdit::savePrompt() 1106int TextEdit::savePrompt()
1109{ 1107{
1110 switch( QMessageBox::information( 0, (tr("Textedit")), 1108 switch( QMessageBox::information( 0, (tr("Textedit")),
1111 (tr("Textedit detected\n" 1109 (tr("Textedit detected\n"
1112 "you have unsaved changes\n" 1110 "you have unsaved changes\n"
1113 "Go ahead and save?\n")), 1111 "Go ahead and save?\n")),
1114 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 1112 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
1115 { 1113 {
1116 case 0: 1114 case 0:
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 5fb605b..82fd1e1 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -856,194 +856,193 @@ void PlayListWidget::btnPlay(bool b) {
856 d->selectedFiles->unSelect(); 856 d->selectedFiles->unSelect();
857 tabWidget->setCurrentPage(1); 857 tabWidget->setCurrentPage(1);
858 insanityBool=FALSE; 858 insanityBool=FALSE;
859 }// audioView->clearSelection(); 859 }// audioView->clearSelection();
860 break; 860 break;
861 case 2: 861 case 2:
862 { 862 {
863 863
864 addToSelection( videoView->currentItem() ); 864 addToSelection( videoView->currentItem() );
865 mediaPlayerState->setPlaying( b); 865 mediaPlayerState->setPlaying( b);
866 // qApp->processEvents(); 866 // qApp->processEvents();
867 d->selectedFiles->removeSelected( ); 867 d->selectedFiles->removeSelected( );
868 d->selectedFiles->unSelect(); 868 d->selectedFiles->unSelect();
869 tabWidget->setCurrentPage(2); 869 tabWidget->setCurrentPage(2);
870 insanityBool=FALSE; 870 insanityBool=FALSE;
871 }// videoView->clearSelection(); 871 }// videoView->clearSelection();
872 break; 872 break;
873 }; 873 };
874 874
875} 875}
876 876
877void PlayListWidget::deletePlaylist() { 877void PlayListWidget::deletePlaylist() {
878 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 878 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
879 (tr("You really want to delete\nthis playlist?")), 879 (tr("You really want to delete\nthis playlist?")),
880 (tr("Yes")), (tr("No")), 0 )){ 880 (tr("Yes")), (tr("No")), 0 )){
881 case 0: // Yes clicked, 881 case 0: // Yes clicked,
882 QFile().remove(playLists->selectedDocument().file()); 882 QFile().remove(playLists->selectedDocument().file());
883 QFile().remove(playLists->selectedDocument().linkFile()); 883 QFile().remove(playLists->selectedDocument().linkFile());
884 playLists->reread(); 884 playLists->reread();
885 break; 885 break;
886 case 1: // Cancel 886 case 1: // Cancel
887 break; 887 break;
888 }; 888 };
889} 889}
890 890
891void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 891void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
892{ 892{
893 switch (mouse) { 893 switch (mouse) {
894 case 1: 894 case 1:
895 break; 895 break;
896 case 2:{ 896 case 2:{
897 897
898 QPopupMenu m; 898 QPopupMenu m;
899 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 899 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
900 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 900 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
901 m.insertSeparator(); 901 m.insertSeparator();
902 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 902 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
903 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 903 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
904 904
905 m.exec( QCursor::pos() ); 905 m.exec( QCursor::pos() );
906 } 906 }
907 break; 907 break;
908 }; 908 };
909} 909}
910 910
911void PlayListWidget::playSelected() 911void PlayListWidget::playSelected()
912{ 912{
913 btnPlay( true); 913 btnPlay( true);
914// d->selectedFiles->unSelect(); 914// d->selectedFiles->unSelect();
915} 915}
916 916
917void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 917void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
918{ 918{
919 switch (mouse) { 919 switch (mouse) {
920 case 1: 920 case 1:
921 921
922 break; 922 break;
923 case 2:{ 923 case 2:{
924 QPopupMenu m; 924 QPopupMenu m;
925 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 925 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
926 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 926 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
927 // m.insertSeparator(); 927 // m.insertSeparator();
928 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 928 // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
929 m.exec( QCursor::pos() ); 929 m.exec( QCursor::pos() );
930 } 930 }
931 break; 931 break;
932 }; 932 };
933 933
934} 934}
935 935
936void PlayListWidget::listDelete() { 936void PlayListWidget::listDelete() {
937 Config cfg( "OpiePlayer" ); 937 Config cfg( "OpiePlayer" );
938 cfg.setGroup("PlayList"); 938 cfg.setGroup("PlayList");
939 currentPlayList = cfg.readEntry("CurrentPlaylist",""); 939 currentPlayList = cfg.readEntry("CurrentPlaylist","");
940 QString file; 940 QString file;
941 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 941 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
942 switch ( tabWidget->currentPageIndex()) { 942 switch ( tabWidget->currentPageIndex()) {
943 case 0: 943 case 0:
944 break; 944 break;
945 case 1: 945 case 1:
946 { 946 {
947 file = audioView->currentItem()->text(0); 947 file = audioView->currentItem()->text(0);
948 QListIterator<DocLnk> Pdit( files.children() ); 948 QListIterator<DocLnk> Pdit( files.children() );
949 for ( ; Pdit.current(); ++Pdit ) { 949 for ( ; Pdit.current(); ++Pdit ) {
950 if( Pdit.current()->name() == file) { 950 if( Pdit.current()->name() == file) {
951 LnkProperties prop( Pdit.current() ); 951 LnkProperties prop( Pdit.current() );
952 prop.showMaximized(); 952 QPEApplication::execDialog( &prop );
953 prop.exec();
954 } 953 }
955 } 954 }
956 populateAudioView(); 955 populateAudioView();
957 } 956 }
958 break; 957 break;
959 case 2: 958 case 2:
960 { 959 {
961 // file = videoView->selectedItem()->text(0); 960 // file = videoView->selectedItem()->text(0);
962 // for ( int i = 0; i < noOfFiles; i++ ) { 961 // for ( int i = 0; i < noOfFiles; i++ ) {
963 // QString entryName; 962 // QString entryName;
964 // entryName.sprintf( "File%i", i + 1 ); 963 // entryName.sprintf( "File%i", i + 1 );
965 // QString linkFile = cfg.readEntry( entryName ); 964 // QString linkFile = cfg.readEntry( entryName );
966 // AppLnk lnk( AppLnk(linkFile)); 965 // AppLnk lnk( AppLnk(linkFile));
967 // if( lnk.name() == file ) { 966 // if( lnk.name() == file ) {
968 // LnkProperties prop( &lnk); 967 // LnkProperties prop( &lnk);
969 // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 968 // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
970 // prop.showMaximized(); 969 // prop.showMaximized();
971 // prop.exec(); 970 // prop.exec();
972 // } 971 // }
973 // } 972 // }
974 } 973 }
975 break; 974 break;
976 }; 975 };
977} 976}
978 977
979void PlayListWidget::scanForAudio() { 978void PlayListWidget::scanForAudio() {
980 // qDebug("scan for audio"); 979 // qDebug("scan for audio");
981 files.detachChildren(); 980 files.detachChildren();
982 QListIterator<DocLnk> sdit( files.children() ); 981 QListIterator<DocLnk> sdit( files.children() );
983 for ( ; sdit.current(); ++sdit ) { 982 for ( ; sdit.current(); ++sdit ) {
984 delete sdit.current(); 983 delete sdit.current();
985 } 984 }
986 Global::findDocuments( &files, audioMimes); 985 Global::findDocuments( &files, audioMimes);
987 audioScan = true; 986 audioScan = true;
988} 987}
989void PlayListWidget::scanForVideo() { 988void PlayListWidget::scanForVideo() {
990 // qDebug("scan for video"); 989 // qDebug("scan for video");
991 vFiles.detachChildren(); 990 vFiles.detachChildren();
992 QListIterator<DocLnk> sdit( vFiles.children() ); 991 QListIterator<DocLnk> sdit( vFiles.children() );
993 for ( ; sdit.current(); ++sdit ) { 992 for ( ; sdit.current(); ++sdit ) {
994 delete sdit.current(); 993 delete sdit.current();
995 } 994 }
996 Global::findDocuments(&vFiles, "video/*"); 995 Global::findDocuments(&vFiles, "video/*");
997 videoScan = true; 996 videoScan = true;
998} 997}
999 998
1000void PlayListWidget::populateAudioView() { 999void PlayListWidget::populateAudioView() {
1001 1000
1002 audioView->clear(); 1001 audioView->clear();
1003 StorageInfo storageInfo; 1002 StorageInfo storageInfo;
1004 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1003 const QList<FileSystem> &fs = storageInfo.fileSystems();
1005 if(!audioScan) scanForAudio(); 1004 if(!audioScan) scanForAudio();
1006 1005
1007 QListIterator<DocLnk> dit( files.children() ); 1006 QListIterator<DocLnk> dit( files.children() );
1008 QListIterator<FileSystem> it ( fs ); 1007 QListIterator<FileSystem> it ( fs );
1009 1008
1010 QString storage; 1009 QString storage;
1011 for ( ; dit.current(); ++dit ) { 1010 for ( ; dit.current(); ++dit ) {
1012 for( ; it.current(); ++it ){ 1011 for( ; it.current(); ++it ){
1013 const QString name = (*it)->name(); 1012 const QString name = (*it)->name();
1014 const QString path = (*it)->path(); 1013 const QString path = (*it)->path();
1015 if(dit.current()->file().find(path) != -1 ) storage=name; 1014 if(dit.current()->file().find(path) != -1 ) storage=name;
1016 } 1015 }
1017 1016
1018 QListViewItem * newItem; 1017 QListViewItem * newItem;
1019 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1018 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1020 long size; 1019 long size;
1021 if( dit.current()->file().left(4) == "http" ) 1020 if( dit.current()->file().left(4) == "http" )
1022 size=0; 1021 size=0;
1023 else 1022 else
1024 size = QFile( dit.current()->file() ).size(); 1023 size = QFile( dit.current()->file() ).size();
1025 // qDebug(dit.current()->name()); 1024 // qDebug(dit.current()->name());
1026 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1025 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1027 QString::number(size ), storage, dit.current()->file()); 1026 QString::number(size ), storage, dit.current()->file());
1028 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1027 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1029 } 1028 }
1030 } 1029 }
1031 1030
1032} 1031}
1033 1032
1034void PlayListWidget::populateVideoView() { 1033void PlayListWidget::populateVideoView() {
1035 videoView->clear(); 1034 videoView->clear();
1036 StorageInfo storageInfo; 1035 StorageInfo storageInfo;
1037 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1036 const QList<FileSystem> &fs = storageInfo.fileSystems();
1038 1037
1039 if(!videoScan ) scanForVideo(); 1038 if(!videoScan ) scanForVideo();
1040 1039
1041 QListIterator<DocLnk> Vdit( vFiles.children() ); 1040 QListIterator<DocLnk> Vdit( vFiles.children() );
1042 QListIterator<FileSystem> it ( fs ); 1041 QListIterator<FileSystem> it ( fs );
1043 videoView->clear(); 1042 videoView->clear();
1044 QString storage; 1043 QString storage;
1045 for ( ; Vdit.current(); ++Vdit ) { 1044 for ( ; Vdit.current(); ++Vdit ) {
1046 for( ; it.current(); ++it ){ 1045 for( ; it.current(); ++it ){
1047 const QString name = (*it)->name(); 1046 const QString name = (*it)->name();
1048 const QString path = (*it)->path(); 1047 const QString path = (*it)->path();
1049 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1048 if( Vdit.current()->file().find(path) != -1 ) storage=name;
diff --git a/core/pim/addressbook/abeditor.cpp b/core/pim/addressbook/abeditor.cpp
index 91e8722..75e7ede 100644
--- a/core/pim/addressbook/abeditor.cpp
+++ b/core/pim/addressbook/abeditor.cpp
@@ -437,184 +437,183 @@ void AbEditor::saveEntry()
437 break; 437 break;
438 case Qtopia::HomeFax: 438 case Qtopia::HomeFax:
439 ent.setHomeFax( it.current()->text() ); 439 ent.setHomeFax( it.current()->text() );
440 break; 440 break;
441 case Qtopia::HomeMobile: 441 case Qtopia::HomeMobile:
442 ent.setHomeMobile( it.current()->text() ); 442 ent.setHomeMobile( it.current()->text() );
443 break; 443 break;
444 case Qtopia::HomeWebPage: 444 case Qtopia::HomeWebPage:
445 ent.setHomeWebpage( it.current()->text() ); 445 ent.setHomeWebpage( it.current()->text() );
446 break; 446 break;
447 447
448 // business 448 // business
449 case Qtopia::Company: 449 case Qtopia::Company:
450 ent.setCompany( it.current()->text() ); 450 ent.setCompany( it.current()->text() );
451 break; 451 break;
452 case Qtopia::BusinessStreet: 452 case Qtopia::BusinessStreet:
453 ent.setBusinessStreet( it.current()->text() ); 453 ent.setBusinessStreet( it.current()->text() );
454 break; 454 break;
455 case Qtopia::BusinessCity: 455 case Qtopia::BusinessCity:
456 ent.setBusinessCity( it.current()->text() ); 456 ent.setBusinessCity( it.current()->text() );
457 break; 457 break;
458 case Qtopia::BusinessState: 458 case Qtopia::BusinessState:
459 ent.setBusinessState( it.current()->text() ); 459 ent.setBusinessState( it.current()->text() );
460 break; 460 break;
461 case Qtopia::BusinessZip: 461 case Qtopia::BusinessZip:
462 ent.setBusinessZip( it.current()->text() ); 462 ent.setBusinessZip( it.current()->text() );
463 break; 463 break;
464 case Qtopia::BusinessCountry: 464 case Qtopia::BusinessCountry:
465 ent.setBusinessCountry( it.current()->text() ); 465 ent.setBusinessCountry( it.current()->text() );
466 break; 466 break;
467 case Qtopia::BusinessWebPage: 467 case Qtopia::BusinessWebPage:
468 ent.setBusinessWebpage( it.current()->text() ); 468 ent.setBusinessWebpage( it.current()->text() );
469 break; 469 break;
470 case Qtopia::JobTitle: 470 case Qtopia::JobTitle:
471 ent.setJobTitle( it.current()->text() ); 471 ent.setJobTitle( it.current()->text() );
472 break; 472 break;
473 case Qtopia::Department: 473 case Qtopia::Department:
474 ent.setDepartment( it.current()->text() ); 474 ent.setDepartment( it.current()->text() );
475 break; 475 break;
476 case Qtopia::Office: 476 case Qtopia::Office:
477 ent.setOffice( it.current()->text() ); 477 ent.setOffice( it.current()->text() );
478 break; 478 break;
479 case Qtopia::BusinessPhone: 479 case Qtopia::BusinessPhone:
480 ent.setBusinessPhone( it.current()->text() ); 480 ent.setBusinessPhone( it.current()->text() );
481 break; 481 break;
482 case Qtopia::BusinessFax: 482 case Qtopia::BusinessFax:
483 ent.setBusinessFax( it.current()->text() ); 483 ent.setBusinessFax( it.current()->text() );
484 break; 484 break;
485 case Qtopia::BusinessMobile: 485 case Qtopia::BusinessMobile:
486 ent.setBusinessMobile( it.current()->text() ); 486 ent.setBusinessMobile( it.current()->text() );
487 break; 487 break;
488 case Qtopia::BusinessPager: 488 case Qtopia::BusinessPager:
489 ent.setBusinessPager( it.current()->text() ); 489 ent.setBusinessPager( it.current()->text() );
490 break; 490 break;
491 case Qtopia::Profession: 491 case Qtopia::Profession:
492 ent.setProfession( it.current()->text() ); 492 ent.setProfession( it.current()->text() );
493 break; 493 break;
494 case Qtopia::Assistant: 494 case Qtopia::Assistant:
495 ent.setAssistant( it.current()->text() ); 495 ent.setAssistant( it.current()->text() );
496 break; 496 break;
497 case Qtopia::Manager: 497 case Qtopia::Manager:
498 ent.setManager( it.current()->text() ); 498 ent.setManager( it.current()->text() );
499 break; 499 break;
500 500
501 // personal 501 // personal
502 case Qtopia::Spouse: 502 case Qtopia::Spouse:
503 ent.setSpouse( it.current()->text() ); 503 ent.setSpouse( it.current()->text() );
504 break; 504 break;
505 case Qtopia::Children: 505 case Qtopia::Children:
506 ent.setChildren( it.current()->text() ); 506 ent.setChildren( it.current()->text() );
507 break; 507 break;
508 case Qtopia::Birthday: 508 case Qtopia::Birthday:
509 ent.setBirthday( it.current()->text() ); 509 ent.setBirthday( it.current()->text() );
510 break; 510 break;
511 case Qtopia::Anniversary: 511 case Qtopia::Anniversary:
512 ent.setAnniversary( it.current()->text() ); 512 ent.setAnniversary( it.current()->text() );
513 break; 513 break;
514 case Qtopia::Nickname: 514 case Qtopia::Nickname:
515 ent.setNickname( it.current()->text() ); 515 ent.setNickname( it.current()->text() );
516 break; 516 break;
517 default: 517 default:
518 break; 518 break;
519 519
520 } 520 }
521 } 521 }
522 522
523 int gender = genderCombo->currentItem(); 523 int gender = genderCombo->currentItem();
524 ent.setGender( QString::number( gender ) ); 524 ent.setGender( QString::number( gender ) );
525 525
526 QString str = txtNote->text(); 526 QString str = txtNote->text();
527 if ( !str.isNull() ) 527 if ( !str.isNull() )
528 ent.setNotes( str ); 528 ent.setNotes( str );
529} 529}
530 530
531void AbEditor::slotNote() 531void AbEditor::slotNote()
532{ 532{
533 dlgNote->showMaximized(); 533 if ( ! QPEApplication::execDialog( &dlgNote ) ) {
534 if ( !dlgNote->exec() ) {
535 // reset the note... 534 // reset the note...
536 txtNote->setText( ent.notes() ); 535 txtNote->setText( ent.notes() );
537 } 536 }
538} 537}
539 538
540void AbEditor::setNameFocus() 539void AbEditor::setNameFocus()
541{ 540{
542 firstEdit->setFocus(); 541 firstEdit->setFocus();
543} 542}
544 543
545void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 544void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
546 QString &strAll ) 545 QString &strAll )
547{ 546{
548 int where, 547 int where,
549 start; 548 start;
550 if ( txt.isEmpty() ) 549 if ( txt.isEmpty() )
551 return; 550 return;
552 551
553 // find the first 552 // find the first
554 where = txt.find( ',' ); 553 where = txt.find( ',' );
555 if ( where < 0 ) { 554 if ( where < 0 ) {
556 strDefaultEmail = txt; 555 strDefaultEmail = txt;
557 strAll = txt; 556 strAll = txt;
558 } else { 557 } else {
559 strDefaultEmail = txt.left( where ).stripWhiteSpace(); 558 strDefaultEmail = txt.left( where ).stripWhiteSpace();
560 strAll = strDefaultEmail; 559 strAll = strDefaultEmail;
561 while ( where > -1 ) { 560 while ( where > -1 ) {
562 strAll.append(" "); 561 strAll.append(" ");
563 start = where; 562 start = where;
564 where = txt.find( ',', where + 1 ); 563 where = txt.find( ',', where + 1 );
565 if ( where > - 1 ) 564 if ( where > - 1 )
566 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); 565 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
567 else // grab until the end... 566 else // grab until the end...
568 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); 567 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
569 } 568 }
570 } 569 }
571} 570}
572 571
573void parseEmailTo( const QString &strDefaultEmail, 572void parseEmailTo( const QString &strDefaultEmail,
574 const QString &strOtherEmail, QString &strBack ) 573 const QString &strOtherEmail, QString &strBack )
575{ 574{
576 // create a comma dilimeted set of emails... 575 // create a comma dilimeted set of emails...
577 // use the power of short circuiting... 576 // use the power of short circuiting...
578 bool foundDefault = false; 577 bool foundDefault = false;
579 QString strTmp; 578 QString strTmp;
580 int start = 0; 579 int start = 0;
581 int where; 580 int where;
582 // start at the beginng. 581 // start at the beginng.
583 strBack = strDefaultEmail; 582 strBack = strDefaultEmail;
584 where = 0; 583 where = 0;
585 while ( where > -1 ) { 584 while ( where > -1 ) {
586 start = where; 585 start = where;
587 where = strOtherEmail.find( ' ', where + 1 ); 586 where = strOtherEmail.find( ' ', where + 1 );
588 if ( where > 0 ) { 587 if ( where > 0 ) {
589 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); 588 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
590 } else 589 } else
591 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); 590 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
592 if ( foundDefault || strTmp != strDefaultEmail ) { 591 if ( foundDefault || strTmp != strDefaultEmail ) {
593 strBack.append( ", " ); 592 strBack.append( ", " );
594 strBack.append( strTmp ); 593 strBack.append( strTmp );
595 } else 594 } else
596 foundDefault = true; 595 foundDefault = true;
597 } 596 }
598} 597}
599 598
600 599
601static inline bool containsAlphaNum( const QString &str ) 600static inline bool containsAlphaNum( const QString &str )
602{ 601{
603 int i, 602 int i,
604 count = str.length(); 603 count = str.length();
605 for ( i = 0; i < count; i++ ) 604 for ( i = 0; i < count; i++ )
606 if ( !str[i].isSpace() ) 605 if ( !str[i].isSpace() )
607 return TRUE; 606 return TRUE;
608 return FALSE; 607 return FALSE;
609} 608}
610 609
611static inline bool constainsWhiteSpace( const QString &str ) 610static inline bool constainsWhiteSpace( const QString &str )
612{ 611{
613 int i, 612 int i,
614 count = str.length(); 613 count = str.length();
615 for (i = 0; i < count; i++ ) 614 for (i = 0; i < count; i++ )
616 if ( str[i].isSpace() ) 615 if ( str[i].isSpace() )
617 return TRUE; 616 return TRUE;
618 return FALSE; 617 return FALSE;
619} 618}
620 619
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 00cd2a6..1c7ddd4 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -189,194 +189,193 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
189 actionMail = a; 189 actionMail = a;
190 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 190 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
191 a->addTo( edit ); 191 a->addTo( edit );
192 a->addTo( listTools ); 192 a->addTo( listTools );
193 193
194 if ( Ir::supported() ) { 194 if ( Ir::supported() ) {
195 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 195 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
196 0, this, 0 ); 196 0, this, 0 );
197 actionBeam = a; 197 actionBeam = a;
198 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
199 a->addTo( edit ); 199 a->addTo( edit );
200 a->addTo( listTools ); 200 a->addTo( listTools );
201 } 201 }
202 202
203 edit->insertSeparator(); 203 edit->insertSeparator();
204 204
205 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, 205 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null,
206 0, this, 0); 206 0, this, 0);
207 actionPersonal = a; 207 actionPersonal = a;
208 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 208 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
209 a->addTo( edit ); 209 a->addTo( edit );
210 210
211 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, 211 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null,
212 0, this, 0); 212 0, this, 0);
213 actionPersonal = a; 213 actionPersonal = a;
214 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); 214 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) );
215 a->addTo( edit ); 215 a->addTo( edit );
216 216
217 edit->insertSeparator(); 217 edit->insertSeparator();
218 218
219 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), 219 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
220 QString::null, 0, this, 0 , TRUE ); 220 QString::null, 0, this, 0 , TRUE );
221 actionPersonal = a; 221 actionPersonal = a;
222 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 222 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
223 a->addTo( edit ); 223 a->addTo( edit );
224 224
225 225
226#ifdef __DEBUG_RELEASE 226#ifdef __DEBUG_RELEASE
227 // Remove this function for public Release ! This is only 227 // Remove this function for public Release ! This is only
228 // for debug purposes .. 228 // for debug purposes ..
229 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 229 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
230 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 230 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
231 a->addTo( edit ); 231 a->addTo( edit );
232#endif 232#endif
233 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 233 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null,
234 0, this, 0 ); 234 0, this, 0 );
235 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 235 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
236 a->addTo( edit ); 236 a->addTo( edit );
237 237
238 // Create Views 238 // Create Views
239 listContainer = new QWidget( this ); 239 listContainer = new QWidget( this );
240 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 240 QVBoxLayout *vb = new QVBoxLayout( listContainer );
241 241
242 m_abView = new AbView( listContainer, m_config.orderList() ); 242 m_abView = new AbView( listContainer, m_config.orderList() );
243 vb->addWidget( m_abView ); 243 vb->addWidget( m_abView );
244 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 244 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
245 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), 245 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
246 this, SLOT( slotViewSwitched( int ) ) ); 246 this, SLOT( slotViewSwitched( int ) ) );
247 247
248 248
249 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 249 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
250 250
251 // m_abView->load(); // Already done by c'tor . 251 // m_abView->load(); // Already done by c'tor .
252 252
253 // Letter Picker 253 // Letter Picker
254 pLabel = new LetterPicker( listContainer ); 254 pLabel = new LetterPicker( listContainer );
255 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 255 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
256 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); 256 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
257 257
258 vb->addWidget( pLabel ); 258 vb->addWidget( pLabel );
259 259
260 // All Categories into view-menu.. 260 // All Categories into view-menu..
261 populateCategories(); 261 populateCategories();
262 262
263 // Fontsize 263 // Fontsize
264 defaultFont = new QFont( m_abView->font() ); 264 defaultFont = new QFont( m_abView->font() );
265 slotSetFont(m_config.fontSize()); 265 slotSetFont(m_config.fontSize());
266 m_curFontSize = m_config.fontSize(); 266 m_curFontSize = m_config.fontSize();
267 267
268 setCentralWidget(listContainer); 268 setCentralWidget(listContainer);
269 269
270 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 270 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
271 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 271 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
272 connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); 272 connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) );
273 connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), 273 connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ),
274 this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); 274 this, SLOT( appMessage(const QCString &, const QByteArray &) ) );
275 275
276 276
277 isLoading = false; 277 isLoading = false;
278} 278}
279 279
280 280
281void AddressbookWindow::slotConfig() 281void AddressbookWindow::slotConfig()
282{ 282{
283 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 283 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
284 dlg -> setConfig( m_config ); 284 dlg -> setConfig( m_config );
285 dlg -> showMaximized(); 285 if ( QPEApplication::execDialog( dlg ) ) {
286 if ( dlg -> exec() ) {
287 qWarning ("Config Dialog accepted!"); 286 qWarning ("Config Dialog accepted!");
288 m_config = dlg -> getConfig(); 287 m_config = dlg -> getConfig();
289 if ( m_curFontSize != m_config.fontSize() ){ 288 if ( m_curFontSize != m_config.fontSize() ){
290 qWarning("Font was changed!"); 289 qWarning("Font was changed!");
291 m_curFontSize = m_config.fontSize(); 290 m_curFontSize = m_config.fontSize();
292 emit slotSetFont( m_curFontSize ); 291 emit slotSetFont( m_curFontSize );
293 } 292 }
294 m_abView -> setListOrder( m_config.orderList() ); 293 m_abView -> setListOrder( m_config.orderList() );
295 } 294 }
296 295
297 delete dlg; 296 delete dlg;
298} 297}
299 298
300 299
301void AddressbookWindow::slotSetFont( int size ) 300void AddressbookWindow::slotSetFont( int size )
302{ 301{
303 qWarning("void AddressbookWindow::slotSetFont( %d )", size); 302 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
304 303
305 if (size > 2 || size < 0) 304 if (size > 2 || size < 0)
306 size = 1; 305 size = 1;
307 306
308 m_config.setFontSize( size ); 307 m_config.setFontSize( size );
309 308
310 QFont *currentFont; 309 QFont *currentFont;
311 310
312 switch (size) { 311 switch (size) {
313 case 0: 312 case 0:
314 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 313 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
315 currentFont = new QFont (m_abView->font()); 314 currentFont = new QFont (m_abView->font());
316 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 315 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
317 // abList->resizeRows(); 316 // abList->resizeRows();
318 break; 317 break;
319 case 1: 318 case 1:
320 m_abView->setFont( *defaultFont ); 319 m_abView->setFont( *defaultFont );
321 currentFont = new QFont (m_abView->font()); 320 currentFont = new QFont (m_abView->font());
322 // // abList->resizeRows(currentFont->pixelSize() + 7); 321 // // abList->resizeRows(currentFont->pixelSize() + 7);
323 // abList->resizeRows(); 322 // abList->resizeRows();
324 break; 323 break;
325 case 2: 324 case 2:
326 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 325 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
327 currentFont = new QFont (m_abView->font()); 326 currentFont = new QFont (m_abView->font());
328 // //abList->resizeRows(currentFont->pixelSize() + 7); 327 // //abList->resizeRows(currentFont->pixelSize() + 7);
329 // abList->resizeRows(); 328 // abList->resizeRows();
330 break; 329 break;
331 } 330 }
332} 331}
333 332
334 333
335 334
336void AddressbookWindow::importvCard() { 335void AddressbookWindow::importvCard() {
337 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 336 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
338 if(!str.isEmpty() ){ 337 if(!str.isEmpty() ){
339 setDocument((const QString&) str ); 338 setDocument((const QString&) str );
340 } 339 }
341 340
342} 341}
343void AddressbookWindow::exportvCard() 342void AddressbookWindow::exportvCard()
344{ 343{
345 qWarning(" void AddressbookWindow::exportvCard()"); 344 qWarning(" void AddressbookWindow::exportvCard()");
346 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); 345 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this );
347 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ 346 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){
348 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); 347 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 );
349 OContact curCont = m_abView->currentEntry(); 348 OContact curCont = m_abView->currentEntry();
350 if ( !curCont.isEmpty() ){ 349 if ( !curCont.isEmpty() ){
351 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 350 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
352 filename ); 351 filename );
353 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); 352 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true );
354 if ( access ){ 353 if ( access ){
355 access->add( curCont ); 354 access->add( curCont );
356 access->save(); 355 access->save();
357 } 356 }
358 delete access; 357 delete access;
359 }else 358 }else
360 QMessageBox::critical( 0, "Export VCard", 359 QMessageBox::critical( 0, "Export VCard",
361 QString( tr( "You have to select a contact !") ) ); 360 QString( tr( "You have to select a contact !") ) );
362 361
363 }else 362 }else
364 QMessageBox::critical( 0, "Export VCard", 363 QMessageBox::critical( 0, "Export VCard",
365 QString( tr( "You have to set a filename !") ) ); 364 QString( tr( "You have to set a filename !") ) );
366} 365}
367 366
368void AddressbookWindow::setDocument( const QString &filename ) 367void AddressbookWindow::setDocument( const QString &filename )
369{ 368{
370 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); 369 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
371 370
372 if ( filename.find(".vcf") != int(filename.length()) - 4 ){ 371 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
373 372
374 373
375 374
376 switch( QMessageBox::information( this, tr ( "Right file type ?" ), 375 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
377 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), 376 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ),
378 tr( "&Yes" ), tr( "&No" ), QString::null, 377 tr( "&Yes" ), tr( "&No" ), QString::null,
379 0, // Enter == button 0 378 0, // Enter == button 0
380 2 ) ) { // Escape == button 2 379 2 ) ) { // Escape == button 2
381 case 0: 380 case 0:
382 qWarning("YES clicked"); 381 qWarning("YES clicked");
@@ -657,198 +656,195 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
657{ 656{
658 bool needShow = FALSE; 657 bool needShow = FALSE;
659 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); 658 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() );
660 659
661 660
662 if (msg == "editPersonal()") { 661 if (msg == "editPersonal()") {
663 editPersonal(); 662 editPersonal();
664 } else if (msg == "editPersonalAndClose()") { 663 } else if (msg == "editPersonalAndClose()") {
665 editPersonal(); 664 editPersonal();
666 close(); 665 close();
667 } else if ( msg == "addContact(QString,QString)" ) { 666 } else if ( msg == "addContact(QString,QString)" ) {
668 QDataStream stream(data,IO_ReadOnly); 667 QDataStream stream(data,IO_ReadOnly);
669 QString name, email; 668 QString name, email;
670 stream >> name >> email; 669 stream >> name >> email;
671 670
672 OContact cnt; 671 OContact cnt;
673 QString fn, mn, ln; 672 QString fn, mn, ln;
674 parseName( name, &fn, &mn, &ln ); 673 parseName( name, &fn, &mn, &ln );
675 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 674 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
676 cnt.setFirstName( fn ); 675 cnt.setFirstName( fn );
677 cnt.setMiddleName( mn ); 676 cnt.setMiddleName( mn );
678 cnt.setLastName( ln ); 677 cnt.setLastName( ln );
679 cnt.insertEmails( email ); 678 cnt.insertEmails( email );
680 cnt.setDefaultEmail( email ); 679 cnt.setDefaultEmail( email );
681 cnt.setFileAs(); 680 cnt.setFileAs();
682 681
683 m_abView -> addEntry( cnt ); 682 m_abView -> addEntry( cnt );
684 683
685 // :SXm_abView()->init( cnt ); 684 // :SXm_abView()->init( cnt );
686 editEntry( EditEntry ); 685 editEntry( EditEntry );
687 } else if ( msg == "beamBusinessCard()" ) { 686 } else if ( msg == "beamBusinessCard()" ) {
688 QString beamFilename = addressbookPersonalVCardName(); 687 QString beamFilename = addressbookPersonalVCardName();
689 if ( !QFile::exists( beamFilename ) ) 688 if ( !QFile::exists( beamFilename ) )
690 return; // can't beam a non-existent file 689 return; // can't beam a non-existent file
691 690
692 Ir *ir = new Ir( this ); 691 Ir *ir = new Ir( this );
693 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 692 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
694 QString description = "mycard.vcf"; 693 QString description = "mycard.vcf";
695 ir->send( beamFilename, description, "text/x-vCard" ); 694 ir->send( beamFilename, description, "text/x-vCard" );
696 } else if ( msg == "show(int)" ) { 695 } else if ( msg == "show(int)" ) {
697 raise(); 696 raise();
698 QDataStream stream(data,IO_ReadOnly); 697 QDataStream stream(data,IO_ReadOnly);
699 int uid; 698 int uid;
700 stream >> uid; 699 stream >> uid;
701 700
702 qWarning( "Showing uid: %d" , uid ); 701 qWarning( "Showing uid: %d" , uid );
703 702
704 // Deactivate Personal View.. 703 // Deactivate Personal View..
705 if ( actionPersonal->isOn() ){ 704 if ( actionPersonal->isOn() ){
706 actionPersonal->setOn( false ); 705 actionPersonal->setOn( false );
707 slotPersonalView(); 706 slotPersonalView();
708 } 707 }
709 708
710 // Reset category and show as card.. 709 // Reset category and show as card..
711 m_abView -> setShowByCategory( QString::null ); 710 m_abView -> setShowByCategory( QString::null );
712 m_abView -> setCurrentUid( uid ); 711 m_abView -> setCurrentUid( uid );
713 slotViewSwitched ( AbView::CardView ); 712 slotViewSwitched ( AbView::CardView );
714 713
715 needShow = true; 714 needShow = true;
716 715
717 716
718 } else if ( msg == "edit(int)" ) { 717 } else if ( msg == "edit(int)" ) {
719 QDataStream stream(data,IO_ReadOnly); 718 QDataStream stream(data,IO_ReadOnly);
720 int uid; 719 int uid;
721 stream >> uid; 720 stream >> uid;
722 721
723 // Deactivate Personal View.. 722 // Deactivate Personal View..
724 if ( actionPersonal->isOn() ){ 723 if ( actionPersonal->isOn() ){
725 actionPersonal->setOn( false ); 724 actionPersonal->setOn( false );
726 slotPersonalView(); 725 slotPersonalView();
727 } 726 }
728 727
729 // Reset category and edit.. 728 // Reset category and edit..
730 m_abView -> setShowByCategory( QString::null ); 729 m_abView -> setShowByCategory( QString::null );
731 m_abView -> setCurrentUid( uid ); 730 m_abView -> setCurrentUid( uid );
732 slotViewEdit(); 731 slotViewEdit();
733 } 732 }
734 733
735 if (needShow) 734 if (needShow)
736 QPEApplication::setKeepRunning(); 735 QPEApplication::setKeepRunning();
737 736
738} 737}
739 738
740void AddressbookWindow::editEntry( EntryMode entryMode ) 739void AddressbookWindow::editEntry( EntryMode entryMode )
741{ 740{
742 OContact entry; 741 OContact entry;
743 if ( !abEditor ) { 742 if ( !abEditor ) {
744 abEditor = new ContactEditor( entry, this, "editor" ); 743 abEditor = new ContactEditor( entry, this, "editor" );
745 } 744 }
746 if ( entryMode == EditEntry ) 745 if ( entryMode == EditEntry )
747 abEditor->setEntry( m_abView -> currentEntry() ); 746 abEditor->setEntry( m_abView -> currentEntry() );
748 else if ( entryMode == NewEntry ) 747 else if ( entryMode == NewEntry )
749 abEditor->setEntry( entry ); 748 abEditor->setEntry( entry );
750 // other things may change the caption. 749 // other things may change the caption.
751 abEditor->setCaption( tr("Edit Address") ); 750 abEditor->setCaption( tr("Edit Address") );
752 751
753#if defined(Q_WS_QWS) || defined(_WS_QWS_)
754 abEditor->showMaximized();
755#endif
756 // fix the foxus... 752 // fix the foxus...
757 abEditor->setNameFocus(); 753 abEditor->setNameFocus();
758 if ( abEditor->exec() ) { 754 if ( QPEApplication::execDialog( abEditor ) ) {
759 setFocus(); 755 setFocus();
760 if ( entryMode == NewEntry ) { 756 if ( entryMode == NewEntry ) {
761 OContact insertEntry = abEditor->entry(); 757 OContact insertEntry = abEditor->entry();
762 insertEntry.assignUid(); 758 insertEntry.assignUid();
763 m_abView -> addEntry( insertEntry ); 759 m_abView -> addEntry( insertEntry );
764 m_abView -> setCurrentUid( insertEntry.uid() ); 760 m_abView -> setCurrentUid( insertEntry.uid() );
765 } else { 761 } else {
766 OContact replEntry = abEditor->entry(); 762 OContact replEntry = abEditor->entry();
767 763
768 if ( !replEntry.isValidUid() ) 764 if ( !replEntry.isValidUid() )
769 replEntry.assignUid(); 765 replEntry.assignUid();
770 766
771 m_abView -> replaceEntry( replEntry ); 767 m_abView -> replaceEntry( replEntry );
772 } 768 }
773 } 769 }
774 // populateCategories(); 770 // populateCategories();
775 771
776} 772}
777 773
778void AddressbookWindow::editPersonal() 774void AddressbookWindow::editPersonal()
779{ 775{
780 OContact entry; 776 OContact entry;
781 777
782 // Switch to personal view if not selected 778 // Switch to personal view if not selected
783 // but take care of the menu, too 779 // but take care of the menu, too
784 if ( ! actionPersonal->isOn() ){ 780 if ( ! actionPersonal->isOn() ){
785 qWarning("*** ++++"); 781 qWarning("*** ++++");
786 actionPersonal->setOn( true ); 782 actionPersonal->setOn( true );
787 slotPersonalView(); 783 slotPersonalView();
788 } 784 }
789 785
790 if ( !abEditor ) { 786 if ( !abEditor ) {
791 abEditor = new ContactEditor( entry, this, "editor" ); 787 abEditor = new ContactEditor( entry, this, "editor" );
792 } 788 }
793 789
794 abEditor->setCaption(tr("Edit My Personal Details")); 790 abEditor->setCaption(tr("Edit My Personal Details"));
795 abEditor->setPersonalView( true ); 791 abEditor->setPersonalView( true );
796 editEntry( EditEntry ); 792 editEntry( EditEntry );
797 abEditor->setPersonalView( false ); 793 abEditor->setPersonalView( false );
798 794
799} 795}
800 796
801 797
802void AddressbookWindow::slotPersonalView() 798void AddressbookWindow::slotPersonalView()
803{ 799{
804 qWarning("slotPersonalView()"); 800 qWarning("slotPersonalView()");
805 if (!actionPersonal->isOn()) { 801 if (!actionPersonal->isOn()) {
806 // we just turned it off 802 // we just turned it off
807 qWarning("slotPersonalView()-> OFF"); 803 qWarning("slotPersonalView()-> OFF");
808 setCaption( tr("Contacts") ); 804 setCaption( tr("Contacts") );
809 actionNew->setEnabled(TRUE); 805 actionNew->setEnabled(TRUE);
810 actionTrash->setEnabled(TRUE); 806 actionTrash->setEnabled(TRUE);
811 actionFind->setEnabled(TRUE); 807 actionFind->setEnabled(TRUE);
812 actionMail->setEnabled(TRUE); 808 actionMail->setEnabled(TRUE);
813 // slotUpdateToolbar(); 809 // slotUpdateToolbar();
814 810
815 m_abView->showPersonal( false ); 811 m_abView->showPersonal( false );
816 812
817 return; 813 return;
818 } 814 }
819 815
820 qWarning("slotPersonalView()-> ON"); 816 qWarning("slotPersonalView()-> ON");
821 // XXX need to disable some QActions. 817 // XXX need to disable some QActions.
822 actionNew->setEnabled(FALSE); 818 actionNew->setEnabled(FALSE);
823 actionTrash->setEnabled(FALSE); 819 actionTrash->setEnabled(FALSE);
824 actionFind->setEnabled(FALSE); 820 actionFind->setEnabled(FALSE);
825 actionMail->setEnabled(FALSE); 821 actionMail->setEnabled(FALSE);
826 822
827 setCaption( tr("Contacts - My Personal Details") ); 823 setCaption( tr("Contacts - My Personal Details") );
828 824
829 m_abView->showPersonal( true ); 825 m_abView->showPersonal( true );
830 826
831} 827}
832 828
833 829
834void AddressbookWindow::listIsEmpty( bool empty ) 830void AddressbookWindow::listIsEmpty( bool empty )
835{ 831{
836 if ( !empty ) { 832 if ( !empty ) {
837 deleteButton->setEnabled( TRUE ); 833 deleteButton->setEnabled( TRUE );
838 } 834 }
839} 835}
840 836
841void AddressbookWindow::reload() 837void AddressbookWindow::reload()
842{ 838{
843 syncing = FALSE; 839 syncing = FALSE;
844 m_abView->clear(); 840 m_abView->clear();
845 m_abView->reload(); 841 m_abView->reload();
846} 842}
847 843
848void AddressbookWindow::flush() 844void AddressbookWindow::flush()
849{ 845{
850 syncing = TRUE; 846 syncing = TRUE;
851 m_abView->save(); 847 m_abView->save();
852} 848}
853 849
854 850
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 8fbd065..7932781 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -990,209 +990,207 @@ void ContactEditor::slotCmbChooser3Change( int index ) {
990} 990}
991 991
992void ContactEditor::slotCmbChooser4Change( int index ) { 992void ContactEditor::slotCmbChooser4Change( int index ) {
993 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); 993 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
994 994
995 if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){ 995 if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){
996 996
997 txtChooserField4->setText( slChooserValues[index] ); 997 txtChooserField4->setText( slChooserValues[index] );
998 txtChooserField4->setFocus(); 998 txtChooserField4->setFocus();
999 999
1000 } 1000 }
1001} 1001}
1002 1002
1003void ContactEditor::slotAddressTypeChange( int index ) { 1003void ContactEditor::slotAddressTypeChange( int index ) {
1004 1004
1005 1005
1006 if ( !initializing ) 1006 if ( !initializing )
1007 contactfields.setFieldOrder( 4, index ); 1007 contactfields.setFieldOrder( 4, index );
1008 1008
1009 1009
1010 if ( index == 0 ) { 1010 if ( index == 0 ) {
1011 1011
1012 txtAddress->setText( slBusinessAddress[0] ); 1012 txtAddress->setText( slBusinessAddress[0] );
1013 //txtAddress2->setText( (*slBusinessAddress)[1] ); 1013 //txtAddress2->setText( (*slBusinessAddress)[1] );
1014 //txtPOBox->setText( (*slBusinessAddress)[2] ); 1014 //txtPOBox->setText( (*slBusinessAddress)[2] );
1015 txtCity->setText( slBusinessAddress[3] ); 1015 txtCity->setText( slBusinessAddress[3] );
1016 txtState->setText( slBusinessAddress[4] ); 1016 txtState->setText( slBusinessAddress[4] );
1017 txtZip->setText( slBusinessAddress[5] ); 1017 txtZip->setText( slBusinessAddress[5] );
1018 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1018 QLineEdit *txtTmp = cmbCountry->lineEdit();
1019 txtTmp->setText( slBusinessAddress[6] ); 1019 txtTmp->setText( slBusinessAddress[6] );
1020 1020
1021 } else { 1021 } else {
1022 1022
1023 txtAddress->setText( slHomeAddress[0] ); 1023 txtAddress->setText( slHomeAddress[0] );
1024 //txtAddress2->setText( (*slHomeAddress)[1] ); 1024 //txtAddress2->setText( (*slHomeAddress)[1] );
1025 //txtPOBox->setText( (*slHomeAddress)[2] ); 1025 //txtPOBox->setText( (*slHomeAddress)[2] );
1026 txtCity->setText( slHomeAddress[3] ); 1026 txtCity->setText( slHomeAddress[3] );
1027 txtState->setText( slHomeAddress[4] ); 1027 txtState->setText( slHomeAddress[4] );
1028 txtZip->setText( slHomeAddress[5] ); 1028 txtZip->setText( slHomeAddress[5] );
1029 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1029 QLineEdit *txtTmp = cmbCountry->lineEdit();
1030 txtTmp->setText( slHomeAddress[6] ); 1030 txtTmp->setText( slHomeAddress[6] );
1031 1031
1032 } 1032 }
1033 1033
1034} 1034}
1035 1035
1036void ContactEditor::slotFullNameChange( const QString &textChanged ) { 1036void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1037 1037
1038 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() ); 1038 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() );
1039 1039
1040 int index = cmbFileAs->currentItem(); 1040 int index = cmbFileAs->currentItem();
1041 1041
1042 cmbFileAs->clear(); 1042 cmbFileAs->clear();
1043 1043
1044 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); 1044 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) );
1045 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); 1045 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) );
1046 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); 1046 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
1047 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) ); 1047 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) );
1048 if ( ! txtSuffix->text().isEmpty() ) 1048 if ( ! txtSuffix->text().isEmpty() )
1049 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() ); 1049 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() );
1050 1050
1051 cmbFileAs->setCurrentItem( index ); 1051 cmbFileAs->setCurrentItem( index );
1052 1052
1053 1053
1054} 1054}
1055 1055
1056void ContactEditor::slotSuffixChange( const QString& ) { 1056void ContactEditor::slotSuffixChange( const QString& ) {
1057 // Just want to update the FileAs combo if the suffix was changed.. 1057 // Just want to update the FileAs combo if the suffix was changed..
1058 slotFullNameChange( txtFullName->text() ); 1058 slotFullNameChange( txtFullName->text() );
1059} 1059}
1060 1060
1061void ContactEditor::slotOrganizationChange( const QString &textChanged ){ 1061void ContactEditor::slotOrganizationChange( const QString &textChanged ){
1062 qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() ); 1062 qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() );
1063 // Special handling for storing Companies: 1063 // Special handling for storing Companies:
1064 // If no Fullname is given, we store the Company-Name as lastname 1064 // If no Fullname is given, we store the Company-Name as lastname
1065 // to handle it like a person.. 1065 // to handle it like a person..
1066 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) ) 1066 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) )
1067 txtFullName->setText( textChanged ); 1067 txtFullName->setText( textChanged );
1068 1068
1069} 1069}
1070 1070
1071void ContactEditor::accept() { 1071void ContactEditor::accept() {
1072 1072
1073 if ( isEmpty() ) { 1073 if ( isEmpty() ) {
1074 cleanupFields(); 1074 cleanupFields();
1075 reject(); 1075 reject();
1076 } else { 1076 } else {
1077 saveEntry(); 1077 saveEntry();
1078 cleanupFields(); 1078 cleanupFields();
1079 QDialog::accept(); 1079 QDialog::accept();
1080 } 1080 }
1081 1081
1082} 1082}
1083 1083
1084void ContactEditor::slotNote() { 1084void ContactEditor::slotNote() {
1085 1085
1086 dlgNote->showMaximized(); 1086 if ( ! QPEApplication::execDialog( dlgNote ) ) {
1087 if ( !dlgNote->exec() ) {
1088 txtNote->setText( ent.notes() ); 1087 txtNote->setText( ent.notes() );
1089 } 1088 }
1090} 1089}
1091 1090
1092void ContactEditor::slotName() { 1091void ContactEditor::slotName() {
1093 1092
1094 QString tmpName; 1093 QString tmpName;
1095 1094
1096 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1095 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1097 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1096 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1098 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1097 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1099 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1098 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1100 1099
1101 dlgName->showMaximized(); 1100 if ( QPEApplication::execDialog( dlgName ) ) {
1102 if ( dlgName->exec() ) {
1103 if ( txtLastName->text().contains( ' ', TRUE ) ) 1101 if ( txtLastName->text().contains( ' ', TRUE ) )
1104 tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); 1102 tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text();
1105 else 1103 else
1106 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); 1104 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text();
1107 1105
1108 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1106 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1109 slotFullNameChange( txtFullName->text() ); 1107 slotFullNameChange( txtFullName->text() );
1110 } 1108 }
1111 1109
1112} 1110}
1113 1111
1114void ContactEditor::setNameFocus() { 1112void ContactEditor::setNameFocus() {
1115 1113
1116 txtFullName->setFocus(); 1114 txtFullName->setFocus();
1117 1115
1118} 1116}
1119 1117
1120bool ContactEditor::isEmpty() { 1118bool ContactEditor::isEmpty() {
1121 // Test and see if the record should be saved. 1119 // Test and see if the record should be saved.
1122 // More strict than the original qtopia, needs name or fileas to save 1120 // More strict than the original qtopia, needs name or fileas to save
1123 1121
1124 QString t = txtFullName->text(); 1122 QString t = txtFullName->text();
1125 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1123 if ( !t.isEmpty() && containsAlphaNum( t ) )
1126 return false; 1124 return false;
1127 1125
1128 t = cmbFileAs->currentText(); 1126 t = cmbFileAs->currentText();
1129 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1127 if ( !t.isEmpty() && containsAlphaNum( t ) )
1130 return false; 1128 return false;
1131 1129
1132 return true; 1130 return true;
1133 1131
1134} 1132}
1135 1133
1136QString ContactEditor::parseName( const QString fullName, int type ) { 1134QString ContactEditor::parseName( const QString fullName, int type ) {
1137 1135
1138 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1136 QString simplifiedName( fullName.simplifyWhiteSpace() );
1139 QString strFirstName; 1137 QString strFirstName;
1140 QString strMiddleName; 1138 QString strMiddleName;
1141 QString strLastName; 1139 QString strLastName;
1142 QString strTitle; 1140 QString strTitle;
1143 int commapos; 1141 int commapos;
1144 bool haveLastName = false; 1142 bool haveLastName = false;
1145 1143
1146 qWarning("Fullname: %s", simplifiedName.latin1()); 1144 qWarning("Fullname: %s", simplifiedName.latin1());
1147 1145
1148 commapos = simplifiedName.find( ',', 0, TRUE); 1146 commapos = simplifiedName.find( ',', 0, TRUE);
1149 if ( commapos >= 0 ) { 1147 if ( commapos >= 0 ) {
1150 qWarning(" Commapos: %d", commapos ); 1148 qWarning(" Commapos: %d", commapos );
1151 1149
1152 // A comma (",") separates the lastname from one or 1150 // A comma (",") separates the lastname from one or
1153 // many first names. Thus, remove the lastname from the 1151 // many first names. Thus, remove the lastname from the
1154 // String and parse the firstnames. 1152 // String and parse the firstnames.
1155 1153
1156 strLastName = simplifiedName.left( commapos ); 1154 strLastName = simplifiedName.left( commapos );
1157 simplifiedName= simplifiedName.mid( commapos + 1 ); 1155 simplifiedName= simplifiedName.mid( commapos + 1 );
1158 haveLastName = true; 1156 haveLastName = true;
1159 qWarning("Fullname without ',': %s", simplifiedName.latin1()); 1157 qWarning("Fullname without ',': %s", simplifiedName.latin1());
1160 1158
1161 // If we have any lastname, we should now split all first names. 1159 // If we have any lastname, we should now split all first names.
1162 // The first one will be the used as first, the rest as "middle names" 1160 // The first one will be the used as first, the rest as "middle names"
1163 1161
1164 QStringList allFirstNames = QStringList::split(" ", simplifiedName); 1162 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
1165 QStringList::Iterator it = allFirstNames.begin(); 1163 QStringList::Iterator it = allFirstNames.begin();
1166 strFirstName = *it++; 1164 strFirstName = *it++;
1167 QStringList allSecondNames; 1165 QStringList allSecondNames;
1168 for ( ; it != allFirstNames.end(); ++it ) 1166 for ( ; it != allFirstNames.end(); ++it )
1169 allSecondNames.append( *it ); 1167 allSecondNames.append( *it );
1170 1168
1171 strMiddleName = allSecondNames.join(" "); 1169 strMiddleName = allSecondNames.join(" ");
1172 1170
1173 } else { 1171 } else {
1174 1172
1175 // No comma separator used: We use the first word as firstname, the 1173 // No comma separator used: We use the first word as firstname, the
1176 // last as second/lastname and everything in the middle as middlename 1174 // last as second/lastname and everything in the middle as middlename
1177 1175
1178 QStringList allNames = QStringList::split(" ", simplifiedName); 1176 QStringList allNames = QStringList::split(" ", simplifiedName);
1179 QStringList::Iterator it = allNames.begin(); 1177 QStringList::Iterator it = allNames.begin();
1180 strFirstName = *it++; 1178 strFirstName = *it++;
1181 QStringList allSecondNames; 1179 QStringList allSecondNames;
1182 for ( ; it != --allNames.end(); ++it ) 1180 for ( ; it != --allNames.end(); ++it )
1183 allSecondNames.append( *it ); 1181 allSecondNames.append( *it );
1184 1182
1185 strMiddleName = allSecondNames.join(" "); 1183 strMiddleName = allSecondNames.join(" ");
1186 strLastName = *(--allNames.end()); 1184 strLastName = *(--allNames.end());
1187 1185
1188 } 1186 }
1189 1187
1190 if ( strFirstName == strLastName ) 1188 if ( strFirstName == strLastName )
1191 strFirstName = ""; 1189 strFirstName = "";
1192 1190
1193 qWarning(" strFirstName: %s", strFirstName.latin1()); 1191 qWarning(" strFirstName: %s", strFirstName.latin1());
1194 qWarning(" strMiddleName: %s", strMiddleName.latin1()); 1192 qWarning(" strMiddleName: %s", strMiddleName.latin1());
1195 qWarning(" strLastName: %s", strLastName.latin1()); 1193 qWarning(" strLastName: %s", strLastName.latin1());
1196 qWarning(" strTitle: %s", strTitle.latin1()); 1194 qWarning(" strTitle: %s", strTitle.latin1());
1197 1195
1198 switch (type) { 1196 switch (type) {
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 44f1515..706cc08 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -172,417 +172,406 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
172 if(defaultView==WEEKLST) viewWeekLst(); 172 if(defaultView==WEEKLST) viewWeekLst();
173 if(defaultView==MONTH) viewMonth(); 173 if(defaultView==MONTH) viewMonth();
174 174
175 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 175 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
176 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 176 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
177 177
178#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 178#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
179 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 179 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
180#endif 180#endif
181 181
182 // listen on QPE/System 182 // listen on QPE/System
183#if defined(Q_WS_QWS) 183#if defined(Q_WS_QWS)
184#if !defined(QT_NO_COP) 184#if !defined(QT_NO_COP)
185 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 185 QCopChannel *channel = new QCopChannel( "QPE/System", this );
186 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 186 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
187 channel = new QCopChannel( "QPE/Datebook", this ); 187 channel = new QCopChannel( "QPE/Datebook", this );
188 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 188 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
189 qDebug("olle\n"); 189 qDebug("olle\n");
190#endif 190#endif
191#endif 191#endif
192 192
193 qDebug("done t=%d", t.elapsed() ); 193 qDebug("done t=%d", t.elapsed() );
194 194
195 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 195 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
196 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 196 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
197 /* 197 /*
198 * Here is a problem description: 198 * Here is a problem description:
199 * When Weekview is the default view 199 * When Weekview is the default view
200 * a DateBookWeekView get's created 200 * a DateBookWeekView get's created
201 * redraw() get's called. So what? 201 * redraw() get's called. So what?
202 * Remember that we're still in the c'tor 202 * Remember that we're still in the c'tor
203 * and no final layout has happened? Ok 203 * and no final layout has happened? Ok
204 * now all Events get arranged. Their x 204 * now all Events get arranged. Their x
205 * position get's determined by a QHeader 205 * position get's determined by a QHeader
206 * position. But the QHeader isn't layouted or 206 * position. But the QHeader isn't layouted or
207 * at the right position. redraw() is a slot 207 * at the right position. redraw() is a slot
208 * so we'll call it then via a singleShot 208 * so we'll call it then via a singleShot
209 * from view() 209 * from view()
210 */ 210 */
211 if( needEvilHack ){ 211 if( needEvilHack ){
212 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 212 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
213 } 213 }
214} 214}
215 215
216void DateBook::receive( const QCString &msg, const QByteArray &data ) 216void DateBook::receive( const QCString &msg, const QByteArray &data )
217{ 217{
218 QDataStream stream( data, IO_ReadOnly ); 218 QDataStream stream( data, IO_ReadOnly );
219 if ( msg == "timeChange(QString)" ) { 219 if ( msg == "timeChange(QString)" ) {
220 // update active view! 220 // update active view!
221 if ( dayAction->isOn() ) 221 if ( dayAction->isOn() )
222 viewDay(); 222 viewDay();
223 else if ( weekAction->isOn() ) 223 else if ( weekAction->isOn() )
224 viewWeek(); 224 viewWeek();
225 else if ( monthAction->isOn() ) 225 else if ( monthAction->isOn() )
226 viewMonth(); 226 viewMonth();
227 } 227 }
228 else if (msg == "editEvent(int)") { 228 else if (msg == "editEvent(int)") {
229 int uid; 229 int uid;
230 stream >> uid; 230 stream >> uid;
231 Event e=db->eventByUID(uid); 231 Event e=db->eventByUID(uid);
232 editEvent(e); 232 editEvent(e);
233 }else if (msg == "viewDefault(QDate)"){ 233 }else if (msg == "viewDefault(QDate)"){
234 QDate day; 234 QDate day;
235 stream >> day; 235 stream >> day;
236 viewDefault(day); 236 viewDefault(day);
237 } 237 }
238} 238}
239 239
240DateBook::~DateBook() 240DateBook::~DateBook()
241{ 241{
242} 242}
243 243
244void DateBook::slotSettings() 244void DateBook::slotSettings()
245{ 245{
246 DateBookSettings frmSettings( ampm, this ); 246 DateBookSettings frmSettings( ampm, this );
247 frmSettings.setStartTime( startTime ); 247 frmSettings.setStartTime( startTime );
248 frmSettings.setAlarmPreset( aPreset, presetTime ); 248 frmSettings.setAlarmPreset( aPreset, presetTime );
249 frmSettings.setJumpToCurTime( bJumpToCurTime ); 249 frmSettings.setJumpToCurTime( bJumpToCurTime );
250 frmSettings.setRowStyle( rowStyle ); 250 frmSettings.setRowStyle( rowStyle );
251 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 251 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
252 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 252 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
253 253
254 bool found=false; 254 bool found=false;
255 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 255 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
256 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 256 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
257 frmSettings.comboLocation->setCurrentItem(i); 257 frmSettings.comboLocation->setCurrentItem(i);
258 found=true; 258 found=true;
259 break; 259 break;
260 } 260 }
261 } 261 }
262 if(!found) { 262 if(!found) {
263 frmSettings.comboLocation->insertItem(defaultLocation); 263 frmSettings.comboLocation->insertItem(defaultLocation);
264 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 264 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
265 } 265 }
266 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 266 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
267 267
268#if defined (Q_WS_QWS) || defined(_WS_QWS_) 268 if ( QPEApplication::execDialog( &frmSettings ) ) {
269 frmSettings.showMaximized();
270#endif
271
272 if ( frmSettings.exec() ) {
273
274 aPreset = frmSettings.alarmPreset(); 269 aPreset = frmSettings.alarmPreset();
275 presetTime = frmSettings.presetTime(); 270 presetTime = frmSettings.presetTime();
276 startTime = frmSettings.startTime(); 271 startTime = frmSettings.startTime();
277 bJumpToCurTime = frmSettings.jumpToCurTime(); 272 bJumpToCurTime = frmSettings.jumpToCurTime();
278 rowStyle = frmSettings.rowStyle(); 273 rowStyle = frmSettings.rowStyle();
279 defaultView=frmSettings.comboDefaultView->currentItem()+1; 274 defaultView=frmSettings.comboDefaultView->currentItem()+1;
280 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 275 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
281 defaultLocation=frmSettings.comboLocation->currentText(); 276 defaultLocation=frmSettings.comboLocation->currentText();
282 defaultCategories=frmSettings.comboCategory->currentCategories(); 277 defaultCategories=frmSettings.comboCategory->currentCategories();
283 278
284 if ( dayView ) { 279 if ( dayView ) {
285 dayView->setStartViewTime( startTime ); 280 dayView->setStartViewTime( startTime );
286 dayView->setJumpToCurTime( bJumpToCurTime ); 281 dayView->setJumpToCurTime( bJumpToCurTime );
287 dayView->setRowStyle( rowStyle ); 282 dayView->setRowStyle( rowStyle );
288 } 283 }
289 if ( weekView ) { 284 if ( weekView ) {
290 weekView->setStartViewTime( startTime ); 285 weekView->setStartViewTime( startTime );
291 } 286 }
292 saveSettings(); 287 saveSettings();
293 288
294 // make the change obvious 289 // make the change obvious
295 if ( views->visibleWidget() ) { 290 if ( views->visibleWidget() ) {
296 if ( views->visibleWidget() == dayView ) 291 if ( views->visibleWidget() == dayView )
297 dayView->redraw(); 292 dayView->redraw();
298 else if ( views->visibleWidget() == weekView ) 293 else if ( views->visibleWidget() == weekView )
299 weekView->redraw(); 294 weekView->redraw();
300 else if ( views->visibleWidget() == weekLstView ) 295 else if ( views->visibleWidget() == weekLstView )
301 weekLstView->redraw(); 296 weekLstView->redraw();
302 } 297 }
303 } 298 }
304} 299}
305 300
306void DateBook::fileNew() 301void DateBook::fileNew()
307{ 302{
308 slotNewEventFromKey(""); 303 slotNewEventFromKey("");
309} 304}
310 305
311QString DateBook::checkEvent(const Event &e) 306QString DateBook::checkEvent(const Event &e)
312{ 307{
313 /* check if overlaps with itself */ 308 /* check if overlaps with itself */
314 bool checkFailed = FALSE; 309 bool checkFailed = FALSE;
315 310
316 /* check the next 12 repeats. should catch most problems */ 311 /* check the next 12 repeats. should catch most problems */
317 QDate current_date = e.start().date(); 312 QDate current_date = e.start().date();
318 Event previous = e; 313 Event previous = e;
319 for(int i = 0; i < 12; i++) 314 for(int i = 0; i < 12; i++)
320 { 315 {
321 QDateTime next; 316 QDateTime next;
322 if (!nextOccurance(previous, current_date.addDays(1), next)) { 317 if (!nextOccurance(previous, current_date.addDays(1), next)) {
323 break; // no more repeats 318 break; // no more repeats
324 } 319 }
325 if(next < previous.end()) { 320 if(next < previous.end()) {
326 checkFailed = TRUE; 321 checkFailed = TRUE;
327 break; 322 break;
328 } 323 }
329 current_date = next.date(); 324 current_date = next.date();
330 } 325 }
331 326
332 if(checkFailed) 327 if(checkFailed)
333 return tr("Event duration is potentially longer\n" 328 return tr("Event duration is potentially longer\n"
334 "than interval between repeats."); 329 "than interval between repeats.");
335 330
336 return QString::null; 331 return QString::null;
337} 332}
338 333
339QDate DateBook::currentDate() 334QDate DateBook::currentDate()
340{ 335{
341 QDate d = QDate::currentDate(); 336 QDate d = QDate::currentDate();
342 337
343 if ( dayView && views->visibleWidget() == dayView ) { 338 if ( dayView && views->visibleWidget() == dayView ) {
344 d = dayView->date(); 339 d = dayView->date();
345 } else if ( weekView && views->visibleWidget() == weekView ) { 340 } else if ( weekView && views->visibleWidget() == weekView ) {
346 d = weekView->date(); 341 d = weekView->date();
347 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 342 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
348 d = weekLstView->date(); 343 d = weekLstView->date();
349 } else if ( monthView && views->visibleWidget() == monthView ) { 344 } else if ( monthView && views->visibleWidget() == monthView ) {
350 d = monthView->selectedDate(); 345 d = monthView->selectedDate();
351 } 346 }
352 347
353 return d; 348 return d;
354} 349}
355 350
356void DateBook::view(int v, const QDate &d) { 351void DateBook::view(int v, const QDate &d) {
357 if (v==DAY) { 352 if (v==DAY) {
358 initDay(); 353 initDay();
359 dayAction->setOn( TRUE ); 354 dayAction->setOn( TRUE );
360 dayView->setDate( d ); 355 dayView->setDate( d );
361 views->raiseWidget( dayView ); 356 views->raiseWidget( dayView );
362 dayView->redraw(); 357 dayView->redraw();
363 } else if (v==WEEK) { 358 } else if (v==WEEK) {
364 initWeek(); 359 initWeek();
365 weekAction->setOn( TRUE ); 360 weekAction->setOn( TRUE );
366 weekView->setDate( d ); 361 weekView->setDate( d );
367 views->raiseWidget( weekView ); 362 views->raiseWidget( weekView );
368 weekView->redraw(); 363 weekView->redraw();
369 } else if (v==WEEKLST) { 364 } else if (v==WEEKLST) {
370 initWeekLst(); 365 initWeekLst();
371 weekLstAction->setOn( TRUE ); 366 weekLstAction->setOn( TRUE );
372 weekLstView->setDate(d); 367 weekLstView->setDate(d);
373 views->raiseWidget( weekLstView ); 368 views->raiseWidget( weekLstView );
374 weekLstView->redraw(); 369 weekLstView->redraw();
375 } else if (v==MONTH) { 370 } else if (v==MONTH) {
376 initMonth(); 371 initMonth();
377 monthAction->setOn( TRUE ); 372 monthAction->setOn( TRUE );
378 monthView->setDate( d.year(), d.month(), d.day() ); 373 monthView->setDate( d.year(), d.month(), d.day() );
379 views->raiseWidget( monthView ); 374 views->raiseWidget( monthView );
380 monthView->redraw(); 375 monthView->redraw();
381 } 376 }
382} 377}
383 378
384void DateBook::viewDefault(const QDate &d) { 379void DateBook::viewDefault(const QDate &d) {
385 view(defaultView,d); 380 view(defaultView,d);
386} 381}
387 382
388void DateBook::viewDay() { 383void DateBook::viewDay() {
389 view(DAY,currentDate()); 384 view(DAY,currentDate());
390} 385}
391 386
392void DateBook::viewWeek() { 387void DateBook::viewWeek() {
393 view(WEEK,currentDate()); 388 view(WEEK,currentDate());
394} 389}
395 390
396void DateBook::viewWeekLst() { 391void DateBook::viewWeekLst() {
397 view(WEEKLST,currentDate()); 392 view(WEEKLST,currentDate());
398} 393}
399 394
400void DateBook::viewMonth() { 395void DateBook::viewMonth() {
401 view(MONTH,currentDate()); 396 view(MONTH,currentDate());
402} 397}
403 398
404void DateBook::insertEvent( const Event &e ) 399void DateBook::insertEvent( const Event &e )
405{ 400{
406 Event dupEvent=e; 401 Event dupEvent=e;
407 if(!dupEvent.isValidUid() ) // tkcRom seems to be different 402 if(!dupEvent.isValidUid() ) // tkcRom seems to be different
408 dupEvent.assignUid(); 403 dupEvent.assignUid();
409 dupEvent.setLocation(defaultLocation); 404 dupEvent.setLocation(defaultLocation);
410 dupEvent.setCategories(defaultCategories); 405 dupEvent.setCategories(defaultCategories);
411 db->addEvent(dupEvent); 406 db->addEvent(dupEvent);
412 emit newEvent(); 407 emit newEvent();
413} 408}
414 409
415void DateBook::duplicateEvent( const Event &e ) 410void DateBook::duplicateEvent( const Event &e )
416{ 411{
417 qWarning("Hmmm..."); 412 qWarning("Hmmm...");
418 // Alot of code duplication, as this is almost like editEvent(); 413 // Alot of code duplication, as this is almost like editEvent();
419 if (syncing) { 414 if (syncing) {
420 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 415 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
421 return; 416 return;
422 } 417 }
423 418
424 Event dupevent(e);// Make a duplicate. 419 Event dupevent(e);// Make a duplicate.
425 420
426 // workaround added for text input. 421 // workaround added for text input.
427 QDialog editDlg( this, 0, TRUE ); 422 QDialog editDlg( this, 0, TRUE );
428 DateEntry *entry; 423 DateEntry *entry;
429 editDlg.setCaption( tr("Duplicate Event") ); 424 editDlg.setCaption( tr("Duplicate Event") );
430 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 425 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
431 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 426 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
432 sv->setResizePolicy( QScrollView::AutoOneFit ); 427 sv->setResizePolicy( QScrollView::AutoOneFit );
433 // KLUDGE!!! 428 // KLUDGE!!!
434 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 429 sv->setHScrollBarMode( QScrollView::AlwaysOff );
435 vb->addWidget( sv ); 430 vb->addWidget( sv );
436 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 431 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
437 entry->timezone->setEnabled( FALSE ); 432 entry->timezone->setEnabled( FALSE );
438 sv->addChild( entry ); 433 sv->addChild( entry );
439 434
440#if defined(Q_WS_QWS) || defined(_WS_QWS_) 435 while ( QPEApplication::execDialog( &editDlg ) ) {
441 editDlg.showMaximized();
442#endif
443 while (editDlg.exec() ) {
444 Event newEv = entry->event(); 436 Event newEv = entry->event();
445 QString error = checkEvent(newEv); 437 QString error = checkEvent(newEv);
446 if (!error.isNull()) { 438 if (!error.isNull()) {
447 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) 439 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
448 continue; 440 continue;
449 } 441 }
450 /* 442 /*
451 * The problem: 443 * The problem:
452 * DateBookDB does remove repeating events not by uid but by the time 444 * DateBookDB does remove repeating events not by uid but by the time
453 * the recurrence was created 445 * the recurrence was created
454 * so we need to update that time as well 446 * so we need to update that time as well
455 */ 447 */
456 Event::RepeatPattern rp = newEv.repeatPattern(); 448 Event::RepeatPattern rp = newEv.repeatPattern();
457 rp.createTime = ::time( NULL ); 449 rp.createTime = ::time( NULL );
458 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 450 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
459 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 451 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
460 newEv.assignUid(); 452 newEv.assignUid();
461 453
462 db->addEvent(newEv); 454 db->addEvent(newEv);
463 emit newEvent(); 455 emit newEvent();
464 break; 456 break;
465 } 457 }
466} 458}
467 459
468void DateBook::editEvent( const Event &e ) 460void DateBook::editEvent( const Event &e )
469{ 461{
470 if (syncing) { 462 if (syncing) {
471 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 463 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
472 return; 464 return;
473 } 465 }
474 466
475 // workaround added for text input. 467 // workaround added for text input.
476 QDialog editDlg( this, 0, TRUE ); 468 QDialog editDlg( this, 0, TRUE );
477 DateEntry *entry; 469 DateEntry *entry;
478 editDlg.setCaption( tr("Edit Event") ); 470 editDlg.setCaption( tr("Edit Event") );
479 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 471 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
480 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 472 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
481 sv->setResizePolicy( QScrollView::AutoOneFit ); 473 sv->setResizePolicy( QScrollView::AutoOneFit );
482 // KLUDGE!!! 474 // KLUDGE!!!
483 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 475 sv->setHScrollBarMode( QScrollView::AlwaysOff );
484 vb->addWidget( sv ); 476 vb->addWidget( sv );
485 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 477 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
486 entry->timezone->setEnabled( FALSE ); 478 entry->timezone->setEnabled( FALSE );
487 sv->addChild( entry ); 479 sv->addChild( entry );
488 480
489#if defined(Q_WS_QWS) || defined(_WS_QWS_) 481 while ( QPEApplication::execDialog( &editDlg ) ) {
490 editDlg.showMaximized();
491#endif
492 while (editDlg.exec() ) {
493 Event newEv = entry->event(); 482 Event newEv = entry->event();
494 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 483 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
495 break; 484 break;
496 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 485 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
497 QString error = checkEvent(newEv); 486 QString error = checkEvent(newEv);
498 if (!error.isNull()) { 487 if (!error.isNull()) {
499 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; 488 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
500 } 489 }
501 db->editEvent(e, newEv); 490 db->editEvent(e, newEv);
502 emit newEvent(); 491 emit newEvent();
503 break; 492 break;
504 } 493 }
505} 494}
506 495
507void DateBook::removeEvent( const Event &e ) 496void DateBook::removeEvent( const Event &e )
508{ 497{
509 if (syncing) { 498 if (syncing) {
510 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 499 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
511 return; 500 return;
512 } 501 }
513 502
514 QString strName = e.description(); 503 QString strName = e.description();
515 504
516 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 505 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
517 return; 506 return;
518 507
519 db->removeEvent( e ); 508 db->removeEvent( e );
520 if ( views->visibleWidget() == dayView && dayView ) 509 if ( views->visibleWidget() == dayView && dayView )
521 dayView->redraw(); 510 dayView->redraw();
522} 511}
523 512
524void DateBook::addEvent( const Event &e ) 513void DateBook::addEvent( const Event &e )
525{ 514{
526 QDate d = e.start().date(); 515 QDate d = e.start().date();
527 initDay(); 516 initDay();
528 dayView->setDate( d ); 517 dayView->setDate( d );
529} 518}
530 519
531void DateBook::showDay( int year, int month, int day ) 520void DateBook::showDay( int year, int month, int day )
532{ 521{
533 QDate d(year, month, day); 522 QDate d(year, month, day);
534 view(DAY,d); 523 view(DAY,d);
535} 524}
536 525
537void DateBook::initDay() 526void DateBook::initDay()
538{ 527{
539 if ( !dayView ) { 528 if ( !dayView ) {
540 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 529 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
541 views->addWidget( dayView, DAY ); 530 views->addWidget( dayView, DAY );
542 dayView->setJumpToCurTime( bJumpToCurTime ); 531 dayView->setJumpToCurTime( bJumpToCurTime );
543 dayView->setStartViewTime( startTime ); 532 dayView->setStartViewTime( startTime );
544 dayView->setRowStyle( rowStyle ); 533 dayView->setRowStyle( rowStyle );
545 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 534 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
546 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 535 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
547 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 536 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
548 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 537 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
549 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 538 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
550 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); 539 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) );
551 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); 540 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) );
552 } 541 }
553} 542}
554 543
555void DateBook::initWeek() 544void DateBook::initWeek()
556{ 545{
557 if ( !weekView ) { 546 if ( !weekView ) {
558 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 547 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
559 weekView->setStartViewTime( startTime ); 548 weekView->setStartViewTime( startTime );
560 views->addWidget( weekView, WEEK ); 549 views->addWidget( weekView, WEEK );
561 connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 550 connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
562 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 551 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
563 } 552 }
564 553
565 //But also get it right: the year that we display can be different 554 //But also get it right: the year that we display can be different
566 //from the year of the current date. So, first find the year 555 //from the year of the current date. So, first find the year
567 //number of the current week. 556 //number of the current week.
568 int yearNumber, totWeeks; 557 int yearNumber, totWeeks;
569 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 558 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
570 559
571 QDate d = QDate( yearNumber, 12, 31 ); 560 QDate d = QDate( yearNumber, 12, 31 );
572 calcWeek( d, totWeeks, yearNumber, onMonday ); 561 calcWeek( d, totWeeks, yearNumber, onMonday );
573 562
574 while ( totWeeks == 1 ) { 563 while ( totWeeks == 1 ) {
575 d = d.addDays( -1 ); 564 d = d.addDays( -1 );
576 calcWeek( d, totWeeks, yearNumber, onMonday ); 565 calcWeek( d, totWeeks, yearNumber, onMonday );
577 } 566 }
578} 567}
579 568
580void DateBook::initWeekLst() { 569void DateBook::initWeekLst() {
581 if ( !weekLstView ) { 570 if ( !weekLstView ) {
582 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 571 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
583 views->addWidget( weekLstView, WEEKLST ); 572 views->addWidget( weekLstView, WEEKLST );
584 573
585 //weekLstView->setStartViewTime( startTime ); 574 //weekLstView->setStartViewTime( startTime );
586 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 575 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
587 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), 576 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ),
588 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); 577 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) );
@@ -614,391 +603,385 @@ void DateBook::loadSettings()
614 config.setGroup("Main"); 603 config.setGroup("Main");
615 startTime = config.readNumEntry("startviewtime", 8); 604 startTime = config.readNumEntry("startviewtime", 8);
616 aPreset = config.readBoolEntry("alarmpreset"); 605 aPreset = config.readBoolEntry("alarmpreset");
617 presetTime = config.readNumEntry("presettime"); 606 presetTime = config.readNumEntry("presettime");
618 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 607 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
619 rowStyle = config.readNumEntry("rowstyle"); 608 rowStyle = config.readNumEntry("rowstyle");
620 defaultView = config.readNumEntry("defaultview",DAY); 609 defaultView = config.readNumEntry("defaultview",DAY);
621 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 610 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
622 611
623 defaultLocation=config.readEntry("defaultLocation"); 612 defaultLocation=config.readEntry("defaultLocation");
624 QString tmpString=config.readEntry("defaultCategories"); 613 QString tmpString=config.readEntry("defaultCategories");
625 QStringList tmpStringList=QStringList::split(",",tmpString); 614 QStringList tmpStringList=QStringList::split(",",tmpString);
626 defaultCategories.truncate(0); 615 defaultCategories.truncate(0);
627 616
628 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 617 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
629 defaultCategories.resize(defaultCategories.count()+1); 618 defaultCategories.resize(defaultCategories.count()+1);
630 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 619 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
631 } 620 }
632} 621}
633 622
634void DateBook::saveSettings() 623void DateBook::saveSettings()
635{ 624{
636 Config config( "qpe" ); 625 Config config( "qpe" );
637 Config configDB( "DateBook" ); 626 Config configDB( "DateBook" );
638 configDB.setGroup( "Main" ); 627 configDB.setGroup( "Main" );
639 configDB.writeEntry("startviewtime",startTime); 628 configDB.writeEntry("startviewtime",startTime);
640 configDB.writeEntry("alarmpreset",aPreset); 629 configDB.writeEntry("alarmpreset",aPreset);
641 configDB.writeEntry("presettime",presetTime); 630 configDB.writeEntry("presettime",presetTime);
642 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 631 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
643 configDB.writeEntry("rowstyle", rowStyle); 632 configDB.writeEntry("rowstyle", rowStyle);
644 configDB.writeEntry("defaultview",defaultView); 633 configDB.writeEntry("defaultview",defaultView);
645 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 634 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
646 635
647 configDB.writeEntry("defaultLocation",defaultLocation); 636 configDB.writeEntry("defaultLocation",defaultLocation);
648 QStringList tmpStringList; 637 QStringList tmpStringList;
649 for( uint i=0; i<defaultCategories.count(); i++) { 638 for( uint i=0; i<defaultCategories.count(); i++) {
650 tmpStringList << QString::number(defaultCategories[i]); 639 tmpStringList << QString::number(defaultCategories[i]);
651 } 640 }
652 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 641 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
653} 642}
654 643
655void DateBook::appMessage(const QCString& msg, const QByteArray& data) 644void DateBook::appMessage(const QCString& msg, const QByteArray& data)
656{ 645{
657 bool needShow = FALSE; 646 bool needShow = FALSE;
658 if ( msg == "alarm(QDateTime,int)" ) { 647 if ( msg == "alarm(QDateTime,int)" ) {
659 QDataStream ds(data,IO_ReadOnly); 648 QDataStream ds(data,IO_ReadOnly);
660 QDateTime when; int warn; 649 QDateTime when; int warn;
661 ds >> when >> warn; 650 ds >> when >> warn;
662 651
663 // check to make it's okay to continue, 652 // check to make it's okay to continue,
664 // this is the case that the time was set ahead, and 653 // this is the case that the time was set ahead, and
665 // we are forced given a stale alarm... 654 // we are forced given a stale alarm...
666 QDateTime current = QDateTime::currentDateTime(); 655 QDateTime current = QDateTime::currentDateTime();
667 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 656 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
668 return; 657 return;
669 658
670 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 659 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
671 if ( list.count() > 0 ) { 660 if ( list.count() > 0 ) {
672 QString msg; 661 QString msg;
673 bool bSound = FALSE; 662 bool bSound = FALSE;
674 int stopTimer = 0; 663 int stopTimer = 0;
675 bool found = FALSE; 664 bool found = FALSE;
676 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 665 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
677 if ( (*it).event().hasAlarm() ) { 666 if ( (*it).event().hasAlarm() ) {
678 found = TRUE; 667 found = TRUE;
679 msg += "<CENTER><B>" + (*it).description() + "</B>" 668 msg += "<CENTER><B>" + (*it).description() + "</B>"
680 + "<BR>" + (*it).location() + "<BR>" 669 + "<BR>" + (*it).location() + "<BR>"
681 + TimeString::dateString((*it).event().start(),ampm) 670 + TimeString::dateString((*it).event().start(),ampm)
682 + (warn 671 + (warn
683 ? tr(" (in " + QString::number(warn) 672 ? tr(" (in " + QString::number(warn)
684 + tr(" minutes)")) 673 + tr(" minutes)"))
685 : QString("")) 674 : QString(""))
686 + "<BR>" 675 + "<BR>"
687 + (*it).notes() + "</CENTER>"; 676 + (*it).notes() + "</CENTER>";
688 if ( (*it).event().alarmSound() != Event::Silent ) { 677 if ( (*it).event().alarmSound() != Event::Silent ) {
689 bSound = TRUE; 678 bSound = TRUE;
690 } 679 }
691 } 680 }
692 } 681 }
693 if ( found ) { 682 if ( found ) {
694 if ( bSound ) { 683 if ( bSound ) {
695 Sound::soundAlarm(); 684 Sound::soundAlarm();
696 alarmCounter = 0; 685 alarmCounter = 0;
697 stopTimer = startTimer( 5000 ); 686 stopTimer = startTimer( 5000 );
698 } 687 }
699 QDialog dlg( this, 0, TRUE ); 688 QDialog dlg( this, 0, TRUE );
700 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 689 QVBoxLayout *vb = new QVBoxLayout( &dlg );
701 QScrollView *view = new QScrollView( &dlg, "scrollView"); 690 QScrollView *view = new QScrollView( &dlg, "scrollView");
702 view->setResizePolicy( QScrollView::AutoOneFit ); 691 view->setResizePolicy( QScrollView::AutoOneFit );
703 vb->addWidget( view ); 692 vb->addWidget( view );
704 QLabel *lblMsg = new QLabel( msg, &dlg ); 693 QLabel *lblMsg = new QLabel( msg, &dlg );
705 view->addChild( lblMsg ); 694 view->addChild( lblMsg );
706 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 695 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
707 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 696 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
708 vb->addWidget( cmdOk ); 697 vb->addWidget( cmdOk );
709 698
710#if defined(Q_WS_QWS) || defined(_WS_QWS_) 699 needShow = QPEApplication::execDialog( &dlg );
711 dlg.showMaximized();
712#endif
713 needShow = dlg.exec();
714 700
715 if ( bSound ) 701 if ( bSound )
716 killTimer( stopTimer ); 702 killTimer( stopTimer );
717 } 703 }
718 } 704 }
719 } else if ( msg == "nextView()" ) { 705 } else if ( msg == "nextView()" ) {
720 needShow = true; 706 needShow = true;
721 if ( !qApp-> activeWindow ( )) { 707 if ( !qApp-> activeWindow ( )) {
722 needShow = TRUE; 708 needShow = TRUE;
723 } else { 709 } else {
724 QWidget* cur = views->visibleWidget(); 710 QWidget* cur = views->visibleWidget();
725 if ( cur ) { 711 if ( cur ) {
726 if ( cur == dayView ) 712 if ( cur == dayView )
727 viewWeek(); 713 viewWeek();
728 else if ( cur == weekView ) 714 else if ( cur == weekView )
729 viewWeekLst(); 715 viewWeekLst();
730 else if ( cur == weekLstView ) 716 else if ( cur == weekLstView )
731 viewMonth(); 717 viewMonth();
732 else if ( cur == monthView ) 718 else if ( cur == monthView )
733 viewDay(); 719 viewDay();
734 needShow = TRUE; 720 needShow = TRUE;
735 } 721 }
736 } 722 }
737 } else if (msg == "editEvent(int)") { 723 } else if (msg == "editEvent(int)") {
738 /* simple copy from receive */ 724 /* simple copy from receive */
739 QDataStream stream(data,IO_ReadOnly); 725 QDataStream stream(data,IO_ReadOnly);
740 int uid; 726 int uid;
741 stream >> uid; 727 stream >> uid;
742 Event e=db->eventByUID(uid); 728 Event e=db->eventByUID(uid);
743 editEvent(e); 729 editEvent(e);
744 } else if (msg == "viewDefault(QDate)"){ 730 } else if (msg == "viewDefault(QDate)"){
745 /* simple copy from receive */ 731 /* simple copy from receive */
746 QDataStream stream(data,IO_ReadOnly); 732 QDataStream stream(data,IO_ReadOnly);
747 QDate day; 733 QDate day;
748 stream >> day; 734 stream >> day;
749 viewDefault(day); 735 viewDefault(day);
750 needShow = true; 736 needShow = true;
751 } 737 }
752 738
753 if ( needShow ) { 739 if ( needShow ) {
754#if defined(Q_WS_QWS) || defined(_WS_QWS_) 740#if defined(Q_WS_QWS) || defined(_WS_QWS_)
755 // showMaximized(); 741 // showMaximized();
756#else 742#else
757 // show(); 743 // show();
758#endif 744#endif
759 // raise(); 745 // raise();
760 QPEApplication::setKeepRunning(); 746 QPEApplication::setKeepRunning();
761 // setActiveWindow(); 747 // setActiveWindow();
762 } 748 }
763} 749}
764 750
765void DateBook::reload() 751void DateBook::reload()
766{ 752{
767 db->reload(); 753 db->reload();
768 if ( dayAction->isOn() ) viewDay(); 754 if ( dayAction->isOn() ) viewDay();
769 else if ( weekAction->isOn() ) viewWeek(); 755 else if ( weekAction->isOn() ) viewWeek();
770 else if ( monthAction->isOn() ) viewMonth(); 756 else if ( monthAction->isOn() ) viewMonth();
771 syncing = FALSE; 757 syncing = FALSE;
772} 758}
773 759
774void DateBook::flush() 760void DateBook::flush()
775{ 761{
776 syncing = TRUE; 762 syncing = TRUE;
777 db->save(); 763 db->save();
778} 764}
779 765
780void DateBook::timerEvent( QTimerEvent *e ) 766void DateBook::timerEvent( QTimerEvent *e )
781{ 767{
782 if ( alarmCounter < 10 ) { 768 if ( alarmCounter < 10 ) {
783 alarmCounter++; 769 alarmCounter++;
784 Sound::soundAlarm(); 770 Sound::soundAlarm();
785 } else { 771 } else {
786 killTimer( e->timerId() ); 772 killTimer( e->timerId() );
787 } 773 }
788} 774}
789 775
790void DateBook::changeClock( bool newClock ) 776void DateBook::changeClock( bool newClock )
791{ 777{
792 ampm = newClock; 778 ampm = newClock;
793 // repaint the affected objects... 779 // repaint the affected objects...
794 if (dayView) dayView->redraw(); 780 if (dayView) dayView->redraw();
795 if (weekView) weekView->redraw(); 781 if (weekView) weekView->redraw();
796 if (weekLstView) weekLstView->redraw(); 782 if (weekLstView) weekLstView->redraw();
797} 783}
798 784
799void DateBook::changeWeek( bool m ) 785void DateBook::changeWeek( bool m )
800{ 786{
801 /* no need to redraw, each widget catches. Do need to 787 /* no need to redraw, each widget catches. Do need to
802 store though for widgets we haven't made yet */ 788 store though for widgets we haven't made yet */
803 onMonday = m; 789 onMonday = m;
804} 790}
805 791
806void DateBook::slotToday() 792void DateBook::slotToday()
807{ 793{
808 // we need to view today using default view 794 // we need to view today using default view
809 view(defaultView,QDate::currentDate()); 795 view(defaultView,QDate::currentDate());
810} 796}
811 797
812void DateBook::closeEvent( QCloseEvent *e ) 798void DateBook::closeEvent( QCloseEvent *e )
813{ 799{
814 if(syncing) { 800 if(syncing) {
815 /* no need to save, did that at flush */ 801 /* no need to save, did that at flush */
816 e->accept(); 802 e->accept();
817 return; 803 return;
818 } 804 }
819 805
820 // save settings will generate it's own error messages, no 806 // save settings will generate it's own error messages, no
821 // need to do checking ourselves. 807 // need to do checking ourselves.
822 saveSettings(); 808 saveSettings();
823 if ( db->save() ) { 809 if ( db->save() ) {
824 e->accept(); 810 e->accept();
825 } else { 811 } else {
826 if ( QMessageBox::critical( this, tr( "Out of space" ), 812 if ( QMessageBox::critical( this, tr( "Out of space" ),
827 tr("Calendar was unable to save\n" 813 tr("Calendar was unable to save\n"
828 "your changes.\n" 814 "your changes.\n"
829 "Free up some space and try again.\n" 815 "Free up some space and try again.\n"
830 "\nQuit anyway?"), 816 "\nQuit anyway?"),
831 QMessageBox::Yes|QMessageBox::Escape, 817 QMessageBox::Yes|QMessageBox::Escape,
832 QMessageBox::No|QMessageBox::Default ) 818 QMessageBox::No|QMessageBox::Default )
833 != QMessageBox::No ) 819 != QMessageBox::No )
834 e->accept(); 820 e->accept();
835 else 821 else
836 e->ignore(); 822 e->ignore();
837 } 823 }
838} 824}
839 825
840// Entering directly from the "keyboard" 826// Entering directly from the "keyboard"
841void DateBook::slotNewEventFromKey( const QString &str ) 827void DateBook::slotNewEventFromKey( const QString &str )
842{ 828{
843 if (syncing) { 829 if (syncing) {
844 QMessageBox::warning( this, tr("Calendar"), 830 QMessageBox::warning( this, tr("Calendar"),
845 tr( "Can not edit data, currently syncing") ); 831 tr( "Can not edit data, currently syncing") );
846 return; 832 return;
847 } 833 }
848 834
849 // We get to here from a key pressed in the Day View 835 // We get to here from a key pressed in the Day View
850 // So we can assume some things. We want the string 836 // So we can assume some things. We want the string
851 // passed in to be part of the description. 837 // passed in to be part of the description.
852 QDateTime start, end; 838 QDateTime start, end;
853 if ( views->visibleWidget() == dayView ) { 839 if ( views->visibleWidget() == dayView ) {
854 dayView->selectedDates( start, end ); 840 dayView->selectedDates( start, end );
855 } else if ( views->visibleWidget() == monthView ) { 841 } else if ( views->visibleWidget() == monthView ) {
856 QDate d = monthView->selectedDate(); 842 QDate d = monthView->selectedDate();
857 start = end = d; 843 start = end = d;
858 start.setTime( QTime( 10, 0 ) ); 844 start.setTime( QTime( 10, 0 ) );
859 end.setTime( QTime( 12, 0 ) ); 845 end.setTime( QTime( 12, 0 ) );
860 } else if ( views->visibleWidget() == weekView ) { 846 } else if ( views->visibleWidget() == weekView ) {
861 QDate d = weekView->date(); 847 QDate d = weekView->date();
862 start = end = d; 848 start = end = d;
863 start.setTime( QTime( 10, 0 ) ); 849 start.setTime( QTime( 10, 0 ) );
864 end.setTime( QTime( 12, 0 ) ); 850 end.setTime( QTime( 12, 0 ) );
865 } else if ( views->visibleWidget() == weekLstView ) { 851 } else if ( views->visibleWidget() == weekLstView ) {
866 QDate d = weekLstView->date(); 852 QDate d = weekLstView->date();
867 start = end = d; 853 start = end = d;
868 start.setTime( QTime( 10, 0 ) ); 854 start.setTime( QTime( 10, 0 ) );
869 end.setTime( QTime( 12, 0 ) ); 855 end.setTime( QTime( 12, 0 ) );
870 } 856 }
871 slotNewEntry(start, end, str); 857 slotNewEntry(start, end, str);
872} 858}
873void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 859void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
874 // argh! This really needs to be encapsulated in a class 860 // argh! This really needs to be encapsulated in a class
875 // or function. 861 // or function.
876 QDialog newDlg( this, 0, TRUE ); 862 QDialog newDlg( this, 0, TRUE );
877 newDlg.setCaption( DateEntryBase::tr("New Event") ); 863 newDlg.setCaption( DateEntryBase::tr("New Event") );
878 DateEntry *e; 864 DateEntry *e;
879 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 865 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
880 QScrollView *sv = new QScrollView( &newDlg ); 866 QScrollView *sv = new QScrollView( &newDlg );
881 sv->setResizePolicy( QScrollView::AutoOneFit ); 867 sv->setResizePolicy( QScrollView::AutoOneFit );
882 sv->setFrameStyle( QFrame::NoFrame ); 868 sv->setFrameStyle( QFrame::NoFrame );
883 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 869 sv->setHScrollBarMode( QScrollView::AlwaysOff );
884 vb->addWidget( sv ); 870 vb->addWidget( sv );
885 871
886 Event ev; 872 Event ev;
887 ev.setDescription( str ); 873 ev.setDescription( str );
888 // When the new gui comes in, change this... 874 // When the new gui comes in, change this...
889 if(location==0) { 875 if(location==0) {
890 if(defaultLocation.isEmpty()) { 876 if(defaultLocation.isEmpty()) {
891 ev.setLocation(tr("(Unknown)")); 877 ev.setLocation(tr("(Unknown)"));
892 } else { 878 } else {
893 ev.setLocation( defaultLocation ); 879 ev.setLocation( defaultLocation );
894 } 880 }
895 } else { 881 } else {
896 ev.setLocation(location); 882 ev.setLocation(location);
897 } 883 }
898 ev.setCategories(defaultCategories); 884 ev.setCategories(defaultCategories);
899 ev.setStart( start ); 885 ev.setStart( start );
900 ev.setEnd( end ); 886 ev.setEnd( end );
901 887
902 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 888 e = new DateEntry( onMonday, ev, ampm, &newDlg );
903 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 889 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
904 sv->addChild( e ); 890 sv->addChild( e );
905#if defined(Q_WS_QWS) || defined(_WS_QWS_) 891 while ( QPEApplication::execDialog( &newDlg ) ) {
906 newDlg.showMaximized();
907#endif
908 while (newDlg.exec()) {
909 ev = e->event(); 892 ev = e->event();
910 ev.assignUid(); 893 ev.assignUid();
911 QString error = checkEvent( ev ); 894 QString error = checkEvent( ev );
912 if ( !error.isNull() ) { 895 if ( !error.isNull() ) {
913 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 896 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
914 continue; 897 continue;
915 } 898 }
916 db->addEvent( ev ); 899 db->addEvent( ev );
917 emit newEvent(); 900 emit newEvent();
918 break; 901 break;
919 } 902 }
920} 903}
921 904
922void DateBook::setDocument( const QString &filename ) 905void DateBook::setDocument( const QString &filename )
923{ 906{
924 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 907 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
925 908
926 QValueList<Event> tl = Event::readVCalendar( filename ); 909 QValueList<Event> tl = Event::readVCalendar( filename );
927 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 910 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
928 db->addEvent( *it ); 911 db->addEvent( *it );
929 } 912 }
930} 913}
931 914
932static const char * beamfile = "/tmp/obex/event.vcs"; 915static const char * beamfile = "/tmp/obex/event.vcs";
933 916
934void DateBook::beamEvent( const Event &e ) 917void DateBook::beamEvent( const Event &e )
935{ 918{
936 qDebug("trying to beamn"); 919 qDebug("trying to beamn");
937 unlink( beamfile ); // delete if exists 920 unlink( beamfile ); // delete if exists
938 mkdir("/tmp/obex/", 0755); 921 mkdir("/tmp/obex/", 0755);
939 Event::writeVCalendar( beamfile, e ); 922 Event::writeVCalendar( beamfile, e );
940 Ir *ir = new Ir( this ); 923 Ir *ir = new Ir( this );
941 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 924 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
942 QString description = e.description(); 925 QString description = e.description();
943 ir->send( beamfile, description, "text/x-vCalendar" ); 926 ir->send( beamfile, description, "text/x-vCalendar" );
944} 927}
945 928
946void DateBook::beamDone( Ir *ir ) 929void DateBook::beamDone( Ir *ir )
947{ 930{
948 delete ir; 931 delete ir;
949 unlink( beamfile ); 932 unlink( beamfile );
950} 933}
951 934
952void DateBook::slotFind() 935void DateBook::slotFind()
953{ 936{
954 // move it to the day view... 937 // move it to the day view...
955 viewDay(); 938 viewDay();
956 FindDialog frmFind( "Calendar", this ); // no tr needed 939 FindDialog frmFind( "Calendar", this ); // no tr needed
957 frmFind.setUseDate( true ); 940 frmFind.setUseDate( true );
958 frmFind.setDate( currentDate() ); 941 frmFind.setDate( currentDate() );
959 QObject::connect( &frmFind, 942 QObject::connect( &frmFind,
960 SIGNAL(signalFindClicked(const QString&, const QDate&, 943 SIGNAL(signalFindClicked(const QString&, const QDate&,
961 bool, bool, int)), 944 bool, bool, int)),
962 this, 945 this,
963 SLOT(slotDoFind(const QString&, const QDate&, 946 SLOT(slotDoFind(const QString&, const QDate&,
964 bool, bool, int)) ); 947 bool, bool, int)) );
965 QObject::connect( this, 948 QObject::connect( this,
966 SIGNAL(signalNotFound()), 949 SIGNAL(signalNotFound()),
967 &frmFind, 950 &frmFind,
968 SLOT(slotNotFound()) ); 951 SLOT(slotNotFound()) );
969 QObject::connect( this, 952 QObject::connect( this,
970 SIGNAL(signalWrapAround()), 953 SIGNAL(signalWrapAround()),
971 &frmFind, 954 &frmFind,
972 SLOT(slotWrapAround()) ); 955 SLOT(slotWrapAround()) );
973 frmFind.move(0,0); 956 frmFind.move(0,0);
974 frmFind.exec(); 957 frmFind.exec();
975 inSearch = false; 958 inSearch = false;
976} 959}
977 960
978bool catComp( QArray<int> cats, int category ) 961bool catComp( QArray<int> cats, int category )
979{ 962{
980 bool returnMe; 963 bool returnMe;
981 int i, 964 int i,
982 count; 965 count;
983 966
984 count = int(cats.count()); 967 count = int(cats.count());
985 returnMe = false; 968 returnMe = false;
986 if ( (category == -1 && count == 0) || category == -2 ) 969 if ( (category == -1 && count == 0) || category == -2 )
987 returnMe = true; 970 returnMe = true;
988 else { 971 else {
989 for ( i = 0; i < count; i++ ) { 972 for ( i = 0; i < count; i++ ) {
990 if ( category == cats[i] ) { 973 if ( category == cats[i] ) {
991 returnMe = true; 974 returnMe = true;
992 break; 975 break;
993 } 976 }
994 } 977 }
995 } 978 }
996 return returnMe; 979 return returnMe;
997} 980}
998 981
999 982
1000void DateBook::slotDoFind( const QString& txt, const QDate &dt, 983void DateBook::slotDoFind( const QString& txt, const QDate &dt,
1001 bool caseSensitive, bool /*backwards*/, 984 bool caseSensitive, bool /*backwards*/,
1002 int category ) 985 int category )
1003{ 986{
1004 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 987 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index d9e5225..856837c 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -156,342 +156,336 @@ void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
156 156
157void DateEntry::updateTimeEdit(bool s, bool e) { 157void DateEntry::updateTimeEdit(bool s, bool e) {
158 158
159 // Comboboxes 159 // Comboboxes
160 QString strStart, strEnd; 160 QString strStart, strEnd;
161 int shour, ehour; 161 int shour, ehour;
162 if ( ampm ) { 162 if ( ampm ) {
163 shour = startTime.hour(); 163 shour = startTime.hour();
164 ehour = endTime.hour(); 164 ehour = endTime.hour();
165 if ( shour >= 12 ) { 165 if ( shour >= 12 ) {
166 if ( shour > 12 ) 166 if ( shour > 12 )
167 shour -= 12; 167 shour -= 12;
168 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 168 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
169 } else { 169 } else {
170 if ( shour == 0 ) 170 if ( shour == 0 )
171 shour = 12; 171 shour = 12;
172 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 172 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
173 } 173 }
174 if ( ehour == 24 && endTime.minute() == 0 ) { 174 if ( ehour == 24 && endTime.minute() == 0 ) {
175 strEnd = "11:59 PM"; // or "midnight" 175 strEnd = "11:59 PM"; // or "midnight"
176 } else if ( ehour >= 12 ) { 176 } else if ( ehour >= 12 ) {
177 if ( ehour > 12 ) 177 if ( ehour > 12 )
178 ehour -= 12; 178 ehour -= 12;
179 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 179 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
180 } else { 180 } else {
181 if ( ehour == 0 ) 181 if ( ehour == 0 )
182 ehour = 12; 182 ehour = 12;
183 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 183 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
184 } 184 }
185 } else { 185 } else {
186 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 186 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
187 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 187 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
188 } 188 }
189 189
190 if (s) comboStart->setText(strStart); 190 if (s) comboStart->setText(strStart);
191 if (e) comboEnd->setText(strEnd); 191 if (e) comboEnd->setText(strEnd);
192} 192}
193 193
194void DateEntry::init() 194void DateEntry::init()
195{ 195{
196 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 196 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
197 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 197 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
198 198
199 initCombos(); 199 initCombos();
200 QPopupMenu *m1 = new QPopupMenu( this ); 200 QPopupMenu *m1 = new QPopupMenu( this );
201 startPicker = new DateBookMonth( m1, 0, TRUE ); 201 startPicker = new DateBookMonth( m1, 0, TRUE );
202 m1->insertItem( startPicker ); 202 m1->insertItem( startPicker );
203 buttonStart->setPopup( m1 ); 203 buttonStart->setPopup( m1 );
204 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 204 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
205 this, SLOT( startDateChanged( int, int, int ) ) ); 205 this, SLOT( startDateChanged( int, int, int ) ) );
206 206
207 //Let start button change both start and end dates 207 //Let start button change both start and end dates
208 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 208 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
209 this, SLOT( endDateChanged( int, int, int ) ) ); 209 this, SLOT( endDateChanged( int, int, int ) ) );
210 connect( qApp, SIGNAL( clockChanged( bool ) ), 210 connect( qApp, SIGNAL( clockChanged( bool ) ),
211 this, SLOT( slotChangeClock( bool ) ) ); 211 this, SLOT( slotChangeClock( bool ) ) );
212 connect( qApp, SIGNAL(weekChanged(bool)), 212 connect( qApp, SIGNAL(weekChanged(bool)),
213 this, SLOT(slotChangeStartOfWeek(bool)) ); 213 this, SLOT(slotChangeStartOfWeek(bool)) );
214 214
215 connect( editNote, SIGNAL(clicked()), 215 connect( editNote, SIGNAL(clicked()),
216 this, SLOT(slotEditNote()) ); 216 this, SLOT(slotEditNote()) );
217 217
218 QPopupMenu *m2 = new QPopupMenu( this ); 218 QPopupMenu *m2 = new QPopupMenu( this );
219 endPicker = new DateBookMonth( m2, 0, TRUE ); 219 endPicker = new DateBookMonth( m2, 0, TRUE );
220 m2->insertItem( endPicker ); 220 m2->insertItem( endPicker );
221 buttonEnd->setPopup( m2 ); 221 buttonEnd->setPopup( m2 );
222 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), 222 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ),
223 this, SLOT( endDateChanged( int, int, int ) ) ); 223 this, SLOT( endDateChanged( int, int, int ) ) );
224 224
225 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), 225 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ),
226 this, SLOT( startTimePicked(const QTime &) )); 226 this, SLOT( startTimePicked(const QTime &) ));
227 // install eventFilters 227 // install eventFilters
228 comboEnd->installEventFilter( this ); 228 comboEnd->installEventFilter( this );
229 comboStart->installEventFilter( this ); 229 comboStart->installEventFilter( this );
230} 230}
231 231
232/* 232/*
233 * Destroys the object and frees any allocated resources 233 * Destroys the object and frees any allocated resources
234 */ 234 */
235DateEntry::~DateEntry() 235DateEntry::~DateEntry()
236{ 236{
237 // no need to delete child widgets, Qt does it all for us 237 // no need to delete child widgets, Qt does it all for us
238 //cout << "Del: " << comboStart->currentText() << endl; 238 //cout << "Del: " << comboStart->currentText() << endl;
239} 239}
240 240
241/* 241/*
242 * public slot 242 * public slot
243 */ 243 */
244 244
245void DateEntry::slotEditNote() { 245void DateEntry::slotEditNote() {
246 QString s; 246 QString s;
247 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 247 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
248// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 248// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
249 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 249 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
250 this,0,TRUE); 250 this,0,TRUE);
251 251
252#if defined(Q_WS_QWS) || defined(_WS_QWS_) 252 if ( QPEApplication::execDialog( &noteDlg ) ) {
253 noteDlg.showMaximized();
254#endif
255 if (noteDlg.exec() ) {
256 noteStr=noteDlg.note->text(); 253 noteStr=noteDlg.note->text();
257 } 254 }
258 255
259} 256}
260 257
261void DateEntry::endDateChanged( int y, int m, int d ) 258void DateEntry::endDateChanged( int y, int m, int d )
262{ 259{
263 endDate.setYMD( y, m, d ); 260 endDate.setYMD( y, m, d );
264 if ( endDate < startDate ) { 261 if ( endDate < startDate ) {
265 endDate = startDate; 262 endDate = startDate;
266 } 263 }
267 264
268 buttonEnd->setText( TimeString::shortDate( endDate ) ); 265 buttonEnd->setText( TimeString::shortDate( endDate ) );
269 266
270 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 267 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
271} 268}
272 269
273static QTime parseTime( const QString& s, bool ampm ) 270static QTime parseTime( const QString& s, bool ampm )
274{ 271{
275 QTime tmpTime; 272 QTime tmpTime;
276 QStringList l = QStringList::split( ':', s ); 273 QStringList l = QStringList::split( ':', s );
277 int hour = l[0].toInt(); 274 int hour = l[0].toInt();
278 if ( ampm ) { 275 if ( ampm ) {
279 int i=0; 276 int i=0;
280 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 277 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
281 i++; 278 i++;
282 QString digits = l[1].left(i); 279 QString digits = l[1].left(i);
283 if ( l[1].contains( "PM", FALSE ) ) { 280 if ( l[1].contains( "PM", FALSE ) ) {
284 if ( hour != 12 ) 281 if ( hour != 12 )
285 hour += 12; 282 hour += 12;
286 } else { 283 } else {
287 if ( hour == 12 ) 284 if ( hour == 12 )
288 hour = 0; 285 hour = 0;
289 } 286 }
290 l[1] = digits; 287 l[1] = digits;
291 } 288 }
292 int minute = l[1].toInt(); 289 int minute = l[1].toInt();
293 if ( minute > 59 ) 290 if ( minute > 59 )
294 minute = 59; 291 minute = 59;
295 else if ( minute < 0 ) 292 else if ( minute < 0 )
296 minute = 0; 293 minute = 0;
297 if ( hour > 23 ) { 294 if ( hour > 23 ) {
298 hour = 23; 295 hour = 23;
299 minute = 59; 296 minute = 59;
300 } else if ( hour < 0 ) 297 } else if ( hour < 0 )
301 hour = 0; 298 hour = 0;
302 tmpTime.setHMS( hour, minute, 0 ); 299 tmpTime.setHMS( hour, minute, 0 );
303 return tmpTime; 300 return tmpTime;
304} 301}
305 302
306/* 303/*
307 * public slot 304 * public slot
308 */ 305 */
309void DateEntry::endTimeChanged( const QString &s ) 306void DateEntry::endTimeChanged( const QString &s )
310{ 307{
311 endTimeChanged( parseTime(s,ampm) ); 308 endTimeChanged( parseTime(s,ampm) );
312} 309}
313 310
314void DateEntry::endTimeChanged( const QTime &t ) { 311void DateEntry::endTimeChanged( const QTime &t ) {
315 if ( endDate > startDate || t >= startTime ) { 312 if ( endDate > startDate || t >= startTime ) {
316 endTime = t; 313 endTime = t;
317 } else { 314 } else {
318 endTime = startTime; 315 endTime = startTime;
319 //comboEnd->setCurrentItem( comboStart->currentItem() ); 316 //comboEnd->setCurrentItem( comboStart->currentItem() );
320 } 317 }
321 timePickerStart->setHour(endTime.hour()); 318 timePickerStart->setHour(endTime.hour());
322 timePickerStart->setMinute(endTime.minute()); 319 timePickerStart->setMinute(endTime.minute());
323} 320}
324 321
325/* 322/*
326 * public slot 323 * public slot
327 */ 324 */
328void DateEntry::startDateChanged( int y, int m, int d ) 325void DateEntry::startDateChanged( int y, int m, int d )
329{ 326{
330 QDate prev = startDate; 327 QDate prev = startDate;
331 startDate.setYMD( y, m, d ); 328 startDate.setYMD( y, m, d );
332 if ( rp.type == Event::Weekly && 329 if ( rp.type == Event::Weekly &&
333 startDate.dayOfWeek() != prev.dayOfWeek() ) { 330 startDate.dayOfWeek() != prev.dayOfWeek() ) {
334 // if we change the start of a weekly repeating event 331 // if we change the start of a weekly repeating event
335 // set the repeating day appropriately 332 // set the repeating day appropriately
336 char mask = 1 << (prev.dayOfWeek()-1); 333 char mask = 1 << (prev.dayOfWeek()-1);
337 rp.days &= (~mask); 334 rp.days &= (~mask);
338 rp.days |= 1 << (startDate.dayOfWeek()-1); 335 rp.days |= 1 << (startDate.dayOfWeek()-1);
339 } 336 }
340 337
341 buttonStart->setText( TimeString::shortDate( startDate ) ); 338 buttonStart->setText( TimeString::shortDate( startDate ) );
342 339
343 // our pickers must be reset... 340 // our pickers must be reset...
344 startPicker->setDate( y, m, d ); 341 startPicker->setDate( y, m, d );
345 endPicker->setDate( y, m, d ); 342 endPicker->setDate( y, m, d );
346} 343}
347 344
348/* 345/*
349 * public slot 346 * public slot
350 */ 347 */
351void DateEntry::startTimeEdited( const QString &s ) 348void DateEntry::startTimeEdited( const QString &s )
352{ 349{
353 startTimeChanged(parseTime(s,ampm)); 350 startTimeChanged(parseTime(s,ampm));
354 updateTimeEdit(false,true); 351 updateTimeEdit(false,true);
355 timePickerStart->setHour(startTime.hour()); 352 timePickerStart->setHour(startTime.hour());
356 timePickerStart->setMinute(startTime.minute()); 353 timePickerStart->setMinute(startTime.minute());
357} 354}
358 355
359void DateEntry::startTimeChanged( const QTime &t ) 356void DateEntry::startTimeChanged( const QTime &t )
360{ 357{
361 int duration=startTime.secsTo(endTime); 358 int duration=startTime.secsTo(endTime);
362 startTime = t; 359 startTime = t;
363 endTime=t.addSecs(duration); 360 endTime=t.addSecs(duration);
364} 361}
365void DateEntry::startTimePicked( const QTime &t ) { 362void DateEntry::startTimePicked( const QTime &t ) {
366 if(m_showStart ){ 363 if(m_showStart ){
367 startTimeChanged(t); 364 startTimeChanged(t);
368 updateTimeEdit(true,true); 365 updateTimeEdit(true,true);
369 }else{ 366 }else{
370 endTimeChanged(t); 367 endTimeChanged(t);
371 updateTimeEdit(false, true ); 368 updateTimeEdit(false, true );
372 } 369 }
373} 370}
374 371
375/* 372/*
376 * public slot 373 * public slot
377 */ 374 */
378void DateEntry::typeChanged( const QString &s ) 375void DateEntry::typeChanged( const QString &s )
379{ 376{
380 bool b = s != "All Day"; 377 bool b = s != "All Day";
381 buttonStart->setEnabled( b ); 378 buttonStart->setEnabled( b );
382 comboStart->setEnabled( b ); 379 comboStart->setEnabled( b );
383 comboEnd->setEnabled( b ); 380 comboEnd->setEnabled( b );
384} 381}
385 382
386void DateEntry::slotRepeat() 383void DateEntry::slotRepeat()
387{ 384{
388 // Work around for compiler Bug.. 385 // Work around for compiler Bug..
389 RepeatEntry *e; 386 RepeatEntry *e;
390 387
391 // it is better in my opinion to just grab this from the mother, 388 // it is better in my opinion to just grab this from the mother,
392 // since, this dialog doesn't need to keep track of it... 389 // since, this dialog doesn't need to keep track of it...
393 if ( rp.type != Event::NoRepeat ) 390 if ( rp.type != Event::NoRepeat )
394 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); 391 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
395 else 392 else
396 e = new RepeatEntry( startWeekOnMonday, startDate, this ); 393 e = new RepeatEntry( startWeekOnMonday, startDate, this );
397 394
398#if defined(Q_WS_QWS) || defined(_WS_QWS_) 395 if ( QPEApplication::execDialog( e ) ) {
399 e->showMaximized();
400#endif
401 if ( e->exec() ) {
402 rp = e->repeatPattern(); 396 rp = e->repeatPattern();
403 setRepeatLabel(); 397 setRepeatLabel();
404 } 398 }
405 // deleting sounds like a nice idea... 399 // deleting sounds like a nice idea...
406 delete e; 400 delete e;
407} 401}
408 402
409void DateEntry::slotChangeStartOfWeek( bool onMonday ) 403void DateEntry::slotChangeStartOfWeek( bool onMonday )
410{ 404{
411 startWeekOnMonday = onMonday; 405 startWeekOnMonday = onMonday;
412} 406}
413 407
414Event DateEntry::event() 408Event DateEntry::event()
415{ 409{
416 Event ev; 410 Event ev;
417 Event::SoundTypeChoice st; 411 Event::SoundTypeChoice st;
418 ev.setDescription( comboDescription->currentText() ); 412 ev.setDescription( comboDescription->currentText() );
419 ev.setLocation( comboLocation->currentText() ); 413 ev.setLocation( comboLocation->currentText() );
420 ev.setCategories( comboCategory->currentCategories() ); 414 ev.setCategories( comboCategory->currentCategories() );
421 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); 415 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
422 if ( startDate > endDate ) { 416 if ( startDate > endDate ) {
423 QDate tmp = endDate; 417 QDate tmp = endDate;
424 endDate = startDate; 418 endDate = startDate;
425 startDate = tmp; 419 startDate = tmp;
426 } 420 }
427 421
428 // This is now done in the changed slots 422 // This is now done in the changed slots
429 // startTime = parseTime( comboStart->text(), ampm ); 423 // startTime = parseTime( comboStart->text(), ampm );
430 //endTime = parseTime( comboEnd->text(), ampm ); 424 //endTime = parseTime( comboEnd->text(), ampm );
431 425
432 if ( startTime > endTime && endDate == startDate ) { 426 if ( startTime > endTime && endDate == startDate ) {
433 QTime tmp = endTime; 427 QTime tmp = endTime;
434 endTime = startTime; 428 endTime = startTime;
435 startTime = tmp; 429 startTime = tmp;
436 } 430 }
437 // don't set the time if theres no need too 431 // don't set the time if theres no need too
438 if ( ev.type() == Event::AllDay ) { 432 if ( ev.type() == Event::AllDay ) {
439 startTime.setHMS( 0, 0, 0 ); 433 startTime.setHMS( 0, 0, 0 );
440 endTime.setHMS( 23, 59, 59 ); 434 endTime.setHMS( 23, 59, 59 );
441 } 435 }
442 436
443 // adjust start and end times based on timezone 437 // adjust start and end times based on timezone
444 QDateTime start( startDate, startTime ); 438 QDateTime start( startDate, startTime );
445 QDateTime end( endDate, endTime ); 439 QDateTime end( endDate, endTime );
446 time_t start_utc, end_utc; 440 time_t start_utc, end_utc;
447 441
448// qDebug( "tz: %s", timezone->currentZone().latin1() ); 442// qDebug( "tz: %s", timezone->currentZone().latin1() );
449 443
450 // get real timezone 444 // get real timezone
451 QString realTZ; 445 QString realTZ;
452 realTZ = QString::fromLocal8Bit( getenv("TZ") ); 446 realTZ = QString::fromLocal8Bit( getenv("TZ") );
453 447
454 // set timezone 448 // set timezone
455 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) 449 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 )
456 qWarning( "There was a problem setting the timezone." ); 450 qWarning( "There was a problem setting the timezone." );
457 451
458 // convert to UTC based on selected TZ (calling tzset internally) 452 // convert to UTC based on selected TZ (calling tzset internally)
459 start_utc = TimeConversion::toUTC( start ); 453 start_utc = TimeConversion::toUTC( start );
460 end_utc = TimeConversion::toUTC( end ); 454 end_utc = TimeConversion::toUTC( end );
461 455
462 // done playing around... put it all back 456 // done playing around... put it all back
463 unsetenv( "TZ" ); 457 unsetenv( "TZ" );
464 if ( !realTZ.isNull() ) 458 if ( !realTZ.isNull() )
465 if ( setenv( "TZ", realTZ, true ) != 0 ) 459 if ( setenv( "TZ", realTZ, true ) != 0 )
466 qWarning( "There was a problem setting the timezone." ); 460 qWarning( "There was a problem setting the timezone." );
467 461
468 // convert UTC to local time (calling tzset internally) 462 // convert UTC to local time (calling tzset internally)
469 ev.setStart( TimeConversion::fromUTC( start_utc ) ); 463 ev.setStart( TimeConversion::fromUTC( start_utc ) );
470 ev.setEnd( TimeConversion::fromUTC( end_utc ) ); 464 ev.setEnd( TimeConversion::fromUTC( end_utc ) );
471 465
472 // we only have one type of sound at the moment... LOUD!!! 466 // we only have one type of sound at the moment... LOUD!!!
473 if ( comboSound->currentItem() != 0 ) 467 if ( comboSound->currentItem() != 0 )
474 st = Event::Loud; 468 st = Event::Loud;
475 else 469 else
476 st = Event::Silent; 470 st = Event::Silent;
477 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); 471 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st );
478 if ( rp.type != Event::NoRepeat ) 472 if ( rp.type != Event::NoRepeat )
479 ev.setRepeat( TRUE, rp ); 473 ev.setRepeat( TRUE, rp );
480 ev.setNotes( noteStr ); 474 ev.setNotes( noteStr );
481 475
482 //cout << "Start: " << comboStart->currentText() << endl; 476 //cout << "Start: " << comboStart->currentText() << endl;
483 477
484 return ev; 478 return ev;
485} 479}
486 480
487void DateEntry::setRepeatLabel() 481void DateEntry::setRepeatLabel()
488{ 482{
489 483
490 switch( rp.type ) { 484 switch( rp.type ) {
491 case Event::Daily: 485 case Event::Daily:
492 cmdRepeat->setText( tr("Daily...") ); 486 cmdRepeat->setText( tr("Daily...") );
493 break; 487 break;
494 case Event::Weekly: 488 case Event::Weekly:
495 cmdRepeat->setText( tr("Weekly...") ); 489 cmdRepeat->setText( tr("Weekly...") );
496 break; 490 break;
497 case Event::MonthlyDay: 491 case Event::MonthlyDay:
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp
index be30415..7ff2204 100644
--- a/core/pim/datebook2/mainwindow.cpp
+++ b/core/pim/datebook2/mainwindow.cpp
@@ -136,170 +136,167 @@ void MainWindow::initUI() {
136 a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); 136 a = new QAction( tr("Configure Locations"), QString::null, 0, 0 );
137 a->addTo( m_popSetting ); 137 a->addTo( m_popSetting );
138 connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); 138 connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) );
139 139
140 a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); 140 a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 );
141 a->addTo( m_popSetting ); 141 a->addTo( m_popSetting );
142 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); 142 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) );
143 143
144 a = new QAction( tr("Configure Templates"), QString::null, 0, 0 ); 144 a = new QAction( tr("Configure Templates"), QString::null, 0, 0 );
145 a->addTo( m_popSetting ); 145 a->addTo( m_popSetting );
146 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) ); 146 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) );
147 147
148 connect( qApp, SIGNAL(clockChanged(bool) ), 148 connect( qApp, SIGNAL(clockChanged(bool) ),
149 this, SLOT(slotClockChanged(bool) ) ); 149 this, SLOT(slotClockChanged(bool) ) );
150 connect( qApp, SIGNAL(weekChanged(bool) ), 150 connect( qApp, SIGNAL(weekChanged(bool) ),
151 this, SLOT(slotWeekChanged(bool) ) ); 151 this, SLOT(slotWeekChanged(bool) ) );
152 152
153 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), 153 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ),
154 this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); 154 this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) );
155} 155}
156void MainWindow::initConfig() { 156void MainWindow::initConfig() {
157 157
158} 158}
159void MainWindow::initView() { 159void MainWindow::initView() {
160 160
161} 161}
162void MainWindow::initManagers() { 162void MainWindow::initManagers() {
163 m_manager = new BookManager; 163 m_manager = new BookManager;
164 164
165 m_tempMan.load(); 165 m_tempMan.load();
166 m_locMan.load(); 166 m_locMan.load();
167 m_descMan.load(); 167 m_descMan.load();
168 168
169 setTemplateMenu(); 169 setTemplateMenu();
170} 170}
171void MainWindow::raiseCurrentView() { 171void MainWindow::raiseCurrentView() {
172 172
173} 173}
174/* 174/*
175 * populate the view 175 * populate the view
176 */ 176 */
177void MainWindow::populate() { 177void MainWindow::populate() {
178 if (!manager()->isLoaded() ) 178 if (!manager()->isLoaded() )
179 manager()->load(); 179 manager()->load();
180} 180}
181void MainWindow::slotGoToNow() { 181void MainWindow::slotGoToNow() {
182 182
183} 183}
184View* MainWindow::currentView() { 184View* MainWindow::currentView() {
185 185
186} 186}
187void MainWindow::slotFind() { 187void MainWindow::slotFind() {
188 188
189} 189}
190void MainWindow::slotConfigure() { 190void MainWindow::slotConfigure() {
191 191
192} 192}
193void MainWindow::slotClockChanged( bool ) { 193void MainWindow::slotClockChanged( bool ) {
194 194
195} 195}
196void MainWindow::slotWeekChanged(bool ) { 196void MainWindow::slotWeekChanged(bool ) {
197 197
198} 198}
199void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { 199void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) {
200 200
201} 201}
202void MainWindow::slotReceive( const QCString&, const QByteArray& ) { 202void MainWindow::slotReceive( const QCString&, const QByteArray& ) {
203 203
204} 204}
205BookManager* MainWindow::manager() { 205BookManager* MainWindow::manager() {
206 return m_manager; 206 return m_manager;
207} 207}
208TemplateManager MainWindow::templateManager() { 208TemplateManager MainWindow::templateManager() {
209 return m_tempMan; 209 return m_tempMan;
210} 210}
211LocationManager MainWindow::locationManager() { 211LocationManager MainWindow::locationManager() {
212 return m_locMan; 212 return m_locMan;
213} 213}
214DescriptionManager MainWindow::descriptionManager() { 214DescriptionManager MainWindow::descriptionManager() {
215 return m_descMan; 215 return m_descMan;
216} 216}
217void MainWindow::setLocationManager( const LocationManager& loc) { 217void MainWindow::setLocationManager( const LocationManager& loc) {
218 m_locMan = loc; 218 m_locMan = loc;
219} 219}
220void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { 220void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) {
221 m_descMan = dsc; 221 m_descMan = dsc;
222} 222}
223Show* MainWindow::eventShow() { 223Show* MainWindow::eventShow() {
224 return m_show; 224 return m_show;
225} 225}
226void MainWindow::slotAction( QAction* act ) { 226void MainWindow::slotAction( QAction* act ) {
227 227
228} 228}
229void MainWindow::slotConfigureLocs() { 229void MainWindow::slotConfigureLocs() {
230 LocationManagerDialog dlg( locationManager() ); 230 LocationManagerDialog dlg( locationManager() );
231 dlg.setCaption( tr("Configure Locations") ); 231 dlg.setCaption( tr("Configure Locations") );
232 dlg.showMaximized(); 232 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
233 if (dlg.exec() == QDialog::Accepted ) {
234 setLocationManager( dlg.manager() ); 233 setLocationManager( dlg.manager() );
235 } 234 }
236} 235}
237void MainWindow::slotConfigureDesc() { 236void MainWindow::slotConfigureDesc() {
238 DescriptionManagerDialog dlg( descriptionManager() ); 237 DescriptionManagerDialog dlg( descriptionManager() );
239 dlg.setCaption( tr("Configure Descriptions") ); 238 dlg.setCaption( tr("Configure Descriptions") );
240 dlg.showMaximized(); 239 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
241 if (dlg.exec() == QDialog::Accepted ) {
242 setDescriptionManager( dlg.manager() ); 240 setDescriptionManager( dlg.manager() );
243 } 241 }
244} 242}
245void MainWindow::slotConfigureTemp() { 243void MainWindow::slotConfigureTemp() {
246 TemplateDialog dlg( templateManager(), editor() ); 244 TemplateDialog dlg( templateManager(), editor() );
247 dlg.setCaption( tr("Configure Templates") ); 245 dlg.setCaption( tr("Configure Templates") );
248 dlg.showMaximized(); 246 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
249 if ( dlg.exec() == QDialog::Accepted ) {
250 m_tempMan = dlg.manager(); 247 m_tempMan = dlg.manager();
251 setTemplateMenu(); 248 setTemplateMenu();
252 } 249 }
253} 250}
254void MainWindow::hideShow() { 251void MainWindow::hideShow() {
255 252
256} 253}
257void MainWindow::viewPopup(int ) { 254void MainWindow::viewPopup(int ) {
258 255
259} 256}
260void MainWindow::viewAdd(const QDate& ) { 257void MainWindow::viewAdd(const QDate& ) {
261 258
262} 259}
263void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { 260void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) {
264 261
265} 262}
266bool MainWindow::viewAP()const{ 263bool MainWindow::viewAP()const{
267} 264}
268bool MainWindow::viewStartMonday()const { 265bool MainWindow::viewStartMonday()const {
269 266
270} 267}
271void MainWindow::setTemplateMenu() { 268void MainWindow::setTemplateMenu() {
272 m_popTemplate->clear(); 269 m_popTemplate->clear();
273 270
274 QStringList list = templateManager().names(); 271 QStringList list = templateManager().names();
275 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 272 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
276 m_popTemplate->insertItem( (*it) ); 273 m_popTemplate->insertItem( (*it) );
277 } 274 }
278} 275}
279/* 276/*
280 * get the name of the item with the id id 277 * get the name of the item with the id id
281 * then ask for an OEvent from the manager 278 * then ask for an OEvent from the manager
282 */ 279 */
283void MainWindow::slotNewFromTemplate(int id ) { 280void MainWindow::slotNewFromTemplate(int id ) {
284 QString name = m_popTemplate->text( id ); 281 QString name = m_popTemplate->text( id );
285 282
286 OEvent ev = templateManager().value( name ); 283 OEvent ev = templateManager().value( name );
287 284
288 if ( editor()->edit( ev ) ) { 285 if ( editor()->edit( ev ) ) {
289 ev = editor()->event(); 286 ev = editor()->event();
290 ev.setUid( -1 ); 287 ev.setUid( -1 );
291 manager()->add( ev ); 288 manager()->add( ev );
292 289
293 /* 290 /*
294 * no we'll find out if the current view 291 * no we'll find out if the current view
295 * should show the new event 292 * should show the new event
296 * and then we will ask it to refresh 293 * and then we will ask it to refresh
297 * FIXME for now we'll call a refresh 294 * FIXME for now we'll call a refresh
298 */ 295 */
299 currentView()->reschedule(); 296 currentView()->reschedule();
300 raiseCurrentView(); 297 raiseCurrentView();
301 } 298 }
302} 299}
303Editor* MainWindow::editor() { 300Editor* MainWindow::editor() {
304 return m_edit; 301 return m_edit;
305} 302}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index d06a405..fc189bd 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -935,111 +935,110 @@ void MainWindow::slotReturnFromView() {
935namespace { 935namespace {
936 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, 936 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls,
937 const OPimNotifyManager::Alarms& newAls ) { 937 const OPimNotifyManager::Alarms& newAls ) {
938 OPimNotifyManager::Alarms nonMatching; 938 OPimNotifyManager::Alarms nonMatching;
939 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); 939 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin();
940 OPimNotifyManager::Alarms::ConstIterator newIt; 940 OPimNotifyManager::Alarms::ConstIterator newIt;
941 for ( ; oldIt != oldAls.end(); ++oldIt ) { 941 for ( ; oldIt != oldAls.end(); ++oldIt ) {
942 bool found = false; 942 bool found = false;
943 QDateTime oldDt = (*oldIt).dateTime(); 943 QDateTime oldDt = (*oldIt).dateTime();
944 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { 944 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) {
945 if ( oldDt == (*newIt).dateTime() ) { 945 if ( oldDt == (*newIt).dateTime() ) {
946 found = true; 946 found = true;
947 break; 947 break;
948 } 948 }
949 } 949 }
950 if (!found) 950 if (!found)
951 nonMatching.append( (*oldIt) ); 951 nonMatching.append( (*oldIt) );
952 } 952 }
953 return nonMatching; 953 return nonMatching;
954 } 954 }
955 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 955 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
956 OPimNotifyManager::Alarms::ConstIterator it; 956 OPimNotifyManager::Alarms::ConstIterator it;
957 for ( it = als.begin(); it != als.end(); ++it ) { 957 for ( it = als.begin(); it != als.end(); ++it ) {
958 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() ); 958 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() );
959 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 959 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
960 } 960 }
961 961
962 } 962 }
963 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 963 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
964 OPimNotifyManager::Alarms::ConstIterator it; 964 OPimNotifyManager::Alarms::ConstIterator it;
965 for ( it = als.begin(); it != als.end(); ++it ) { 965 for ( it = als.begin(); it != als.end(); ++it ) {
966 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); 966 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() );
967 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 967 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
968 } 968 }
969 } 969 }
970} 970}
971 971
972void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) { 972void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) {
973 /* 973 /*
974 * if oldTodo is not empty and has notifiers we need to find the deleted ones 974 * if oldTodo is not empty and has notifiers we need to find the deleted ones
975 */ 975 */
976 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { 976 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
977 OPimNotifyManager::Alarms removed; 977 OPimNotifyManager::Alarms removed;
978 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); 978 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
979 if (!newTodo.hasNotifiers() ) 979 if (!newTodo.hasNotifiers() )
980 removed = oldAls; 980 removed = oldAls;
981 else 981 else
982 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); 982 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
983 983
984 removeAlarms( removed, oldTodo.uid() ); 984 removeAlarms( removed, oldTodo.uid() );
985 } 985 }
986 if ( newTodo.hasNotifiers() ) { 986 if ( newTodo.hasNotifiers() ) {
987 OPimNotifyManager::Alarms added; 987 OPimNotifyManager::Alarms added;
988 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) 988 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
989 added = newTodo.notifiers().alarms(); 989 added = newTodo.notifiers().alarms();
990 else 990 else
991 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); 991 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
992 992
993 addAlarms( added, newTodo.uid() ); 993 addAlarms( added, newTodo.uid() );
994 } 994 }
995} 995}
996/* we might have not loaded the db */ 996/* we might have not loaded the db */
997void MainWindow::doAlarm( const QDateTime& dt, int uid ) { 997void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
998 m_todoMgr.load(); 998 m_todoMgr.load();
999 999
1000 OTodo todo = m_todoMgr.event( uid ); 1000 OTodo todo = m_todoMgr.event( uid );
1001 if (!todo.hasNotifiers() ) return; 1001 if (!todo.hasNotifiers() ) return;
1002 1002
1003 /* 1003 /*
1004 * let's find the right alarm and find out if silent 1004 * let's find the right alarm and find out if silent
1005 * then show a richtext widget 1005 * then show a richtext widget
1006 */ 1006 */
1007 bool loud = false; 1007 bool loud = false;
1008 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 1008 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
1009 OPimNotifyManager::Alarms::Iterator it; 1009 OPimNotifyManager::Alarms::Iterator it;
1010 for ( it = als.begin(); it != als.end(); ++it ) { 1010 for ( it = als.begin(); it != als.end(); ++it ) {
1011 if ( (*it).dateTime() == dt ) { 1011 if ( (*it).dateTime() == dt ) {
1012 loud = ( (*it).sound() == OPimAlarm::Loud ); 1012 loud = ( (*it).sound() == OPimAlarm::Loud );
1013 break; 1013 break;
1014 } 1014 }
1015 } 1015 }
1016 if (loud) 1016 if (loud)
1017 startAlarm(); 1017 startAlarm();
1018 1018
1019 QDialog dlg(this, 0, TRUE ); 1019 QDialog dlg(this, 0, TRUE );
1020 QVBoxLayout* lay = new QVBoxLayout( &dlg ); 1020 QVBoxLayout* lay = new QVBoxLayout( &dlg );
1021 QTextView* view = new QTextView( &dlg ); 1021 QTextView* view = new QTextView( &dlg );
1022 lay->addWidget( view ); 1022 lay->addWidget( view );
1023 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); 1023 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg );
1024 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); 1024 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) );
1025 lay->addWidget( btnOk ); 1025 lay->addWidget( btnOk );
1026 1026
1027 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); 1027 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) );
1028 text += todo.toRichText(); 1028 text += todo.toRichText();
1029 view->setText( text ); 1029 view->setText( text );
1030 1030
1031 dlg.showMaximized(); 1031 bool needToStay = QPEApplication::execDialog( &dlg );
1032 bool needToStay = dlg.exec();
1033 1032
1034 if (loud) 1033 if (loud)
1035 killAlarm(); 1034 killAlarm();
1036 1035
1037 if (needToStay) { 1036 if (needToStay) {
1038// showMaximized(); 1037// showMaximized();
1039// raise(); 1038// raise();
1040 QPEApplication::setKeepRunning(); 1039 QPEApplication::setKeepRunning();
1041// setActiveWindow(); 1040// setActiveWindow();
1042 } 1041 }
1043 1042
1044} 1043}
1045 1044
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp
index c204325..78aedd6 100644
--- a/core/pim/todo/todoeditor.cpp
+++ b/core/pim/todo/todoeditor.cpp
@@ -1,63 +1,62 @@
1 1
2#include <qpe/qpeapplication.h>
3
2#include "otaskeditor.h" 4#include "otaskeditor.h"
3#include "todoeditor.h" 5#include "todoeditor.h"
4 6
5using namespace Todo; 7using namespace Todo;
6 8
7Editor::Editor() { 9Editor::Editor() {
8 m_accepted = false; 10 m_accepted = false;
9 m_self = 0l; 11 m_self = 0l;
10} 12}
11Editor::~Editor() { 13Editor::~Editor() {
12 delete m_self; 14 delete m_self;
13 m_self = 0; 15 m_self = 0;
14} 16}
15OTodo Editor::newTodo( int cur, 17OTodo Editor::newTodo( int cur,
16 QWidget*) { 18 QWidget*) {
17 19
18 OTaskEditor *e = self(); 20 OTaskEditor *e = self();
19 e->setCaption( QObject::tr("Enter Task") ); 21 e->setCaption( QObject::tr("Enter Task") );
20 e->init( cur ); 22 e->init( cur );
21 23
24 int ret = QPEApplication::execDialog( e );
22 25
23 e->showMaximized();
24
25 int ret = e->exec();
26 if ( QDialog::Accepted == ret ) { 26 if ( QDialog::Accepted == ret ) {
27 m_accepted = true; 27 m_accepted = true;
28 }else 28 }else
29 m_accepted = false; 29 m_accepted = false;
30 30
31 OTodo ev = e->todo(); 31 OTodo ev = e->todo();
32 qWarning("Todo uid"); 32 qWarning("Todo uid");
33 qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); 33 qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() );
34 ev.setUid(1); 34 ev.setUid(1);
35 35
36 return ev; 36 return ev;
37} 37}
38OTodo Editor::edit( QWidget *, 38OTodo Editor::edit( QWidget *,
39 const OTodo& todo ) { 39 const OTodo& todo ) {
40 OTaskEditor *e = self(); 40 OTaskEditor *e = self();
41 e->init( todo ); 41 e->init( todo );
42 e->setCaption( QObject::tr( "Edit Task" ) ); 42 e->setCaption( QObject::tr( "Edit Task" ) );
43 43
44 e->showMaximized(); 44 int ret = QPEApplication::execDialog( e );
45 int ret = e->exec();
46 45
47 OTodo ev = e->todo(); 46 OTodo ev = e->todo();
48 if ( ret == QDialog::Accepted ) 47 if ( ret == QDialog::Accepted )
49 m_accepted = true; 48 m_accepted = true;
50 else 49 else
51 m_accepted = false; 50 m_accepted = false;
52 51
53 return ev; 52 return ev;
54} 53}
55bool Editor::accepted()const { 54bool Editor::accepted()const {
56 return m_accepted; 55 return m_accepted;
57} 56}
58OTaskEditor* Editor::self() { 57OTaskEditor* Editor::self() {
59 if (!m_self ) 58 if (!m_self )
60 m_self = new OTaskEditor(0); 59 m_self = new OTaskEditor(0);
61 60
62 return m_self; 61 return m_self;
63} 62}
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index d6d09a1..b21215b 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -1,301 +1,301 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "light.h" 29#include "light.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/power.h> 32#include <qpe/power.h>
33#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 33#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
34#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
35#endif 35#endif
36#include <qpe/qpeapplication.h>
36 37
37#include <qlabel.h> 38#include <qlabel.h>
38#include <qcheckbox.h> 39#include <qcheckbox.h>
39#include <qtabwidget.h> 40#include <qtabwidget.h>
40#include <qslider.h> 41#include <qslider.h>
41#include <qspinbox.h> 42#include <qspinbox.h>
42#include <qpushbutton.h> 43#include <qpushbutton.h>
43#include <qgroupbox.h> 44#include <qgroupbox.h>
44#include <qcombobox.h> 45#include <qcombobox.h>
45 46
46#include <opie/odevice.h> 47#include <opie/odevice.h>
47 48
48#include "sensor.h" 49#include "sensor.h"
49 50
50using namespace Opie; 51using namespace Opie;
51 52
52LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
53 : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) 54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
54{ 55{
55 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); 56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
56 m_cres = ODevice::inst ( )-> displayContrastResolution ( ); 57 m_cres = ODevice::inst ( )-> displayContrastResolution ( );
57 58
58 // check whether to show the light sensor stuff 59 // check whether to show the light sensor stuff
59 60
60 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 61 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
61 auto_brightness-> hide ( ); 62 auto_brightness-> hide ( );
62 CalibrateLightSensor-> hide ( ); 63 CalibrateLightSensor-> hide ( );
63 auto_brightness_ac-> hide ( ); 64 auto_brightness_ac-> hide ( );
64 CalibrateLightSensor_ac-> hide ( ); 65 CalibrateLightSensor_ac-> hide ( );
65 } 66 }
66 67
67 // check whether to show the contrast stuff 68 // check whether to show the contrast stuff
68 69
69 if (m_cres) { 70 if (m_cres) {
70 GroupLight->setTitle(tr("Backlight && Contrast")); 71 GroupLight->setTitle(tr("Backlight && Contrast"));
71 GroupLight_ac->setTitle(GroupLight->title()); 72 GroupLight_ac->setTitle(GroupLight->title());
72 } else { 73 } else {
73 contrast->hide(); 74 contrast->hide();
74 contrast_ac->hide(); 75 contrast_ac->hide();
75 } 76 }
76 77
77 // check whether to show the cpu frequency stuff 78 // check whether to show the cpu frequency stuff
78 79
79 QStrList freq = ODevice::inst()->allowedCpuFrequencies(); 80 QStrList freq = ODevice::inst()->allowedCpuFrequencies();
80 if ( freq.count() ) { 81 if ( freq.count() ) {
81 frequency->insertStrList( freq ); 82 frequency->insertStrList( freq );
82 frequency_ac->insertStrList( freq ); 83 frequency_ac->insertStrList( freq );
83 } else { 84 } else {
84 frequencyLabel->hide(); 85 frequencyLabel->hide();
85 frequency->hide(); 86 frequency->hide();
86 frequencyLabel_ac->hide(); 87 frequencyLabel_ac->hide();
87 frequency_ac->hide(); 88 frequency_ac->hide();
88 } 89 }
89 90
90 // check whether to show the hinge action stuff 91 // check whether to show the hinge action stuff
91 92
92 if ( !ODevice::inst()->hasHingeSensor() ) { 93 if ( !ODevice::inst()->hasHingeSensor() ) {
93 closeHingeLabel->hide(); 94 closeHingeLabel->hide();
94 closeHingeAction->hide(); 95 closeHingeAction->hide();
95 closeHingeLabel_ac->hide(); 96 closeHingeLabel_ac->hide();
96 closeHingeAction_ac->hide(); 97 closeHingeAction_ac->hide();
97 } 98 }
98 99
99 Config config ( "apm" ); 100 Config config ( "apm" );
100 config. setGroup ( "Battery" ); 101 config. setGroup ( "Battery" );
101 102
102 // battery spinboxes 103 // battery spinboxes
103 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 104 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
104 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 105 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
105 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 106 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
106 107
107 // battery check and slider 108 // battery check and slider
108 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 109 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
109 110
110 // CPU frequency 111 // CPU frequency
111 frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); 112 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
112 113
113 // hinge action 114 // hinge action
114 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 115 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
115 116
116 int bright = config. readNumEntry ( "Brightness", 127 ); 117 int bright = config. readNumEntry ( "Brightness", 127 );
117 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 118 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
118 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 119 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
119 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 120 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
120 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 121 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
121 brightness-> setValue ( bright ); 122 brightness-> setValue ( bright );
122 123
123 if (m_cres) { 124 if (m_cres) {
124 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); 125 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
125 contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); 126 contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
126 contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); 127 contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
127 contrast-> setValue ( contr ); 128 contrast-> setValue ( contr );
128 } 129 }
129 130
130 // light sensor 131 // light sensor
131 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 132 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
132 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 133 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
133 134
134 config. setGroup ( "AC" ); 135 config. setGroup ( "AC" );
135 136
136 // ac spinboxes 137 // ac spinboxes
137 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); 138 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
138 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 139 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
139 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 140 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
140 141
141 // ac check and slider 142 // ac check and slider
142 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 143 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
143 144
144 // CPU frequency 145 // CPU frequency
145 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); 146 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
146 147
147 // hinge action 148 // hinge action
148 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 149 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
149 150
150 bright = config. readNumEntry ( "Brightness", 255 ); 151 bright = config. readNumEntry ( "Brightness", 255 );
151 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 152 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
152 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 153 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
153 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 154 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
154 brightness_ac-> setValue ( bright ); 155 brightness_ac-> setValue ( bright );
155 156
156 if (m_cres) { 157 if (m_cres) {
157 contr = config. readNumEntry ( "Contrast", 127); 158 contr = config. readNumEntry ( "Contrast", 127);
158 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); 159 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
159 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); 160 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
160 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); 161 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
161 contrast_ac-> setValue ( contr ); 162 contrast_ac-> setValue ( contr );
162 } 163 }
163 164
164 // light sensor 165 // light sensor
165 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 166 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
166 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 167 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
167 168
168 // warnings 169 // warnings
169 config. setGroup ( "Warnings" ); 170 config. setGroup ( "Warnings" );
170 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 171 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
171 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 172 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
172 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 173 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
173 174
174 m_resettimer = new QTimer ( this ); 175 m_resettimer = new QTimer ( this );
175 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); 176 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( )));
176 177
177 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 178 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
178 tabs-> setCurrentPage ( 0 ); 179 tabs-> setCurrentPage ( 0 );
179 } 180 }
180 else { 181 else {
181 tabs-> setCurrentPage ( 1 ); 182 tabs-> setCurrentPage ( 1 );
182 } 183 }
183 184
184 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 185 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
185 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 186 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
186 if (m_cres) { 187 if (m_cres) {
187 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 188 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
188 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 189 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
189 } 190 }
190 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 191 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
191 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 192 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
192 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 193 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
193 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 194 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
194} 195}
195 196
196LightSettings::~LightSettings ( ) 197LightSettings::~LightSettings ( )
197{ 198{
198} 199}
199 200
200void LightSettings::calibrateSensor ( ) 201void LightSettings::calibrateSensor ( )
201{ 202{
202 Sensor *s = new Sensor ( m_sensordata, this ); 203 Sensor *s = new Sensor ( m_sensordata, this );
203 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 204 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
204 s-> showMaximized ( ); 205 QPEApplication::execDialog( s );
205 s-> exec ( );
206 delete s; 206 delete s;
207} 207}
208 208
209void LightSettings::calibrateSensorAC ( ) 209void LightSettings::calibrateSensorAC ( )
210{ 210{
211 Sensor *s = new Sensor ( m_sensordata_ac, this ); 211 Sensor *s = new Sensor ( m_sensordata_ac, this );
212 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 212 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
213 s-> showMaximized ( ); 213 s-> showMaximized ( );
214 s-> exec ( ); 214 s-> exec ( );
215 delete s; 215 delete s;
216} 216}
217 217
218void LightSettings::setBacklight ( int bright ) 218void LightSettings::setBacklight ( int bright )
219{ 219{
220 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 220 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
221 e << bright; 221 e << bright;
222 222
223 if ( bright != -1 ) { 223 if ( bright != -1 ) {
224 m_resettimer-> stop ( ); 224 m_resettimer-> stop ( );
225 m_resettimer-> start ( 4000, true ); 225 m_resettimer-> start ( 4000, true );
226 } 226 }
227} 227}
228 228
229void LightSettings::setContrast ( int contr ) 229void LightSettings::setContrast ( int contr )
230{ 230{
231 if (contr == -1) contr = m_oldcontrast; 231 if (contr == -1) contr = m_oldcontrast;
232 ODevice::inst ( )-> setDisplayContrast(contr); 232 ODevice::inst ( )-> setDisplayContrast(contr);
233} 233}
234 234
235void LightSettings::setFrequency ( int index ) 235void LightSettings::setFrequency ( int index )
236{ 236{
237 qWarning("LightSettings::setFrequency(%d)", index); 237 qWarning("LightSettings::setFrequency(%d)", index);
238 ODevice::inst ( )-> setCurrentCpuFrequency(index); 238 ODevice::inst ( )-> setCurrentCpuFrequency(index);
239} 239}
240 240
241void LightSettings::resetBacklight ( ) 241void LightSettings::resetBacklight ( )
242{ 242{
243 setBacklight ( -1 ); 243 setBacklight ( -1 );
244 setContrast ( -1 ); 244 setContrast ( -1 );
245} 245}
246 246
247void LightSettings::setCloseHingeAction ( int index ) 247void LightSettings::setCloseHingeAction ( int index )
248{ 248{
249 qWarning("LightSettings::setCloseHingeStatus(%d)", index); 249 qWarning("LightSettings::setCloseHingeStatus(%d)", index);
250} 250}
251 251
252void LightSettings::accept ( ) 252void LightSettings::accept ( )
253{ 253{
254 Config config ( "apm" ); 254 Config config ( "apm" );
255 255
256 // bat 256 // bat
257 config. setGroup ( "Battery" ); 257 config. setGroup ( "Battery" );
258 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 258 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
259 config. writeEntry ( "Dim", interval_dim-> value ( )); 259 config. writeEntry ( "Dim", interval_dim-> value ( ));
260 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 260 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
261 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 261 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
262 config. writeEntry ( "Brightness", brightness-> value () ); 262 config. writeEntry ( "Brightness", brightness-> value () );
263 if (m_cres) 263 if (m_cres)
264 config. writeEntry ( "Contrast", contrast-> value () ); 264 config. writeEntry ( "Contrast", contrast-> value () );
265 config. writeEntry ( "Freq", frequency->currentItem() ); 265 config. writeEntry ( "Freq", frequency->currentItem() );
266 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); 266 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() );
267 267
268 // ac 268 // ac
269 config. setGroup ( "AC" ); 269 config. setGroup ( "AC" );
270 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 270 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
271 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 271 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
272 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 272 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
273 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 273 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
274 config. writeEntry ( "Brightness", brightness_ac-> value () ); 274 config. writeEntry ( "Brightness", brightness_ac-> value () );
275 if (m_cres) 275 if (m_cres)
276 config. writeEntry ( "Contrast", contrast_ac-> value () ); 276 config. writeEntry ( "Contrast", contrast_ac-> value () );
277 config. writeEntry ( "Freq", frequency_ac->currentItem() ); 277 config. writeEntry ( "Freq", frequency_ac->currentItem() );
278 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); 278 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() );
279 279
280 // only make light sensor stuff appear if the unit has a sensor 280 // only make light sensor stuff appear if the unit has a sensor
281 if ( ODevice::inst ( )-> hasLightSensor ( )) { 281 if ( ODevice::inst ( )-> hasLightSensor ( )) {
282 config. setGroup ( "Battery" ); 282 config. setGroup ( "Battery" );
283 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 283 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
284 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 284 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
285 config. setGroup ( "AC" ); 285 config. setGroup ( "AC" );
286 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); 286 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
287 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 287 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
288 } 288 }
289 289
290 // advanced 290 // advanced
291 config. setGroup ( "Warnings" ); 291 config. setGroup ( "Warnings" );
292 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 292 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
293 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 293 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
294 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 294 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
295 config. write ( ); 295 config. write ( );
296 296
297 // notify the launcher 297 // notify the launcher
298 { 298 {
299 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 299 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
300 } 300 }
301 { 301 {