76 files changed, 372 insertions, 372 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 7625545..e8072c6 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,253 +1,253 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.cpp | 2 | * cardmon.cpp |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2002 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "cardmon.h" | 19 | #include "cardmon.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/odevice.h> | 22 | #include <opie2/odevice.h> |
23 | #include <opie2/otaskbarapplet.h> | 23 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | 26 | ||
27 | /* QT */ | 27 | /* QT */ |
28 | #include <qcopchannel_qws.h> | 28 | #include <qcopchannel_qws.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qtextstream.h> | 31 | #include <qtextstream.h> |
32 | #include <qsound.h> | 32 | #include <qsound.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | 34 | ||
35 | /* STD */ | 35 | /* STD */ |
36 | #include <stdio.h> | 36 | #include <stdio.h> |
37 | #include <unistd.h> | 37 | #include <unistd.h> |
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include <string.h> | 39 | #include <string.h> |
40 | #include <fcntl.h> | 40 | #include <fcntl.h> |
41 | 41 | ||
42 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 42 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
43 | #include <sys/vfs.h> | 43 | #include <sys/vfs.h> |
44 | #include <mntent.h> | 44 | #include <mntent.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | using namespace Opie; | 47 | using namespace Opie; |
48 | 48 | ||
49 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), | 49 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), |
50 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) | 50 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) |
51 | { | 51 | { |
52 | 52 | ||
53 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 53 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
54 | connect( pcmciaChannel, | 54 | connect( pcmciaChannel, |
55 | SIGNAL( received( const QCString &, const QByteArray & ) ), this, | 55 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
56 | SLOT( cardMessage( const QCString &, const QByteArray & ) ) ); | 56 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
57 | 57 | ||
58 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); | 58 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); |
59 | connect( sdChannel, | 59 | connect( sdChannel, |
60 | SIGNAL( received( const QCString &, const QByteArray & ) ), this, | 60 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
61 | SLOT( cardMessage( const QCString &, const QByteArray & ) ) ); | 61 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
62 | 62 | ||
63 | cardInPcmcia0 = FALSE; | 63 | cardInPcmcia0 = FALSE; |
64 | cardInPcmcia1 = FALSE; | 64 | cardInPcmcia1 = FALSE; |
65 | cardInSd = FALSE; | 65 | cardInSd = FALSE; |
66 | 66 | ||
67 | setFocusPolicy( NoFocus ); | 67 | setFocusPolicy( NoFocus ); |
68 | 68 | ||
69 | setFixedWidth ( AppLnk::smallIconSize() ); | 69 | setFixedWidth ( AppLnk::smallIconSize() ); |
70 | setFixedHeight ( AppLnk::smallIconSize() ); | 70 | setFixedHeight ( AppLnk::smallIconSize() ); |
71 | 71 | ||
72 | getStatusPcmcia( TRUE ); | 72 | getStatusPcmcia( TRUE ); |
73 | getStatusSd( TRUE ); | 73 | getStatusSd( TRUE ); |
74 | repaint( FALSE ); | 74 | repaint( FALSE ); |
75 | popupMenu = 0; | 75 | popupMenu = 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | CardMonitor::~CardMonitor() | 78 | CardMonitor::~CardMonitor() |
79 | { | 79 | { |
80 | if ( popupMenu ) | 80 | if ( popupMenu ) |
81 | { | 81 | { |
82 | delete popupMenu; | 82 | delete popupMenu; |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | void CardMonitor::popUp( QString message, QString icon ) | 86 | void CardMonitor::popUp( QString message, QString icon ) |
87 | { | 87 | { |
88 | if ( !popupMenu ) | 88 | if ( !popupMenu ) |
89 | { | 89 | { |
90 | popupMenu = new QPopupMenu( this ); | 90 | popupMenu = new QPopupMenu( this ); |
91 | } | 91 | } |
92 | 92 | ||
93 | popupMenu->clear(); | 93 | popupMenu->clear(); |
94 | if ( icon.isEmpty() ) | 94 | if ( icon.isEmpty() ) |
95 | { | 95 | { |
96 | popupMenu->insertItem( message, 0 ); | 96 | popupMenu->insertItem( message, 0 ); |
97 | } | 97 | } |
98 | else | 98 | else |
99 | { | 99 | { |
100 | popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), | 100 | popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), |
101 | message, 0 ); | 101 | message, 0 ); |
102 | } | 102 | } |
103 | 103 | ||
104 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 104 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
105 | QSize s = popupMenu->sizeHint(); | 105 | QSize s = popupMenu->sizeHint(); |
106 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 106 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
107 | p.y() - s.height() ), 0 ); | 107 | p.y() - s.height() ), 0 ); |
108 | 108 | ||
109 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 109 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
110 | } | 110 | } |
111 | 111 | ||
112 | void CardMonitor::popupTimeout() | 112 | void CardMonitor::popupTimeout() |
113 | { | 113 | { |
114 | popupMenu->hide(); | 114 | popupMenu->hide(); |
115 | } | 115 | } |
116 | 116 | ||
117 | void CardMonitor::mousePressEvent( QMouseEvent * ) | 117 | void CardMonitor::mousePressEvent( QMouseEvent * ) |
118 | { | 118 | { |
119 | QPopupMenu * menu = new QPopupMenu( this ); | 119 | QPopupMenu * menu = new QPopupMenu( this ); |
120 | QString cmd; | 120 | QString cmd; |
121 | int err = 0; | 121 | int err = 0; |
122 | 122 | ||
123 | if ( cardInSd ) | 123 | if ( cardInSd ) |
124 | { | 124 | { |
125 | menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), | 125 | menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), |
126 | tr( "Eject SD/MMC card" ), 0 ); | 126 | tr( "Eject SD/MMC card" ), 0 ); |
127 | } | 127 | } |
128 | 128 | ||
129 | if ( cardInPcmcia0 ) | 129 | if ( cardInPcmcia0 ) |
130 | { | 130 | { |
131 | menu-> | 131 | menu-> |
132 | insertItem( QIconSet | 132 | insertItem( QIconSet |
133 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ), | 133 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ), |
134 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); | 134 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); |
135 | } | 135 | } |
136 | 136 | ||
137 | if ( cardInPcmcia1 ) | 137 | if ( cardInPcmcia1 ) |
138 | { | 138 | { |
139 | menu-> | 139 | menu-> |
140 | insertItem( QIconSet | 140 | insertItem( QIconSet |
141 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ), | 141 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ), |
142 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | 142 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); |
143 | } | 143 | } |
144 | 144 | ||
145 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 145 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
146 | QSize s = menu->sizeHint(); | 146 | QSize s = menu->sizeHint(); |
147 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 147 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
148 | p.y() - s.height() ), 0 ); | 148 | p.y() - s.height() ), 0 ); |
149 | 149 | ||
150 | if ( opt == 1 ) | 150 | if ( opt == 1 ) |
151 | { | 151 | { |
152 | cmd = "/sbin/cardctl eject 0"; | 152 | cmd = "/sbin/cardctl eject 0"; |
153 | err = system( ( const char * ) cmd ); | 153 | err = system( ( const char * ) cmd ); |
154 | if ( err != 0 ) | 154 | if ( err != 0 ) |
155 | { | 155 | { |
156 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", | 156 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", |
157 | err ); | 157 | err ); |
158 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 158 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | else if ( opt == 0 ) | 161 | else if ( opt == 0 ) |
162 | { | 162 | { |
163 | if ( ODevice::inst() ->system() == System_Familiar ) | 163 | if ( ODevice::inst() ->system() == System_Familiar ) |
164 | { | 164 | { |
165 | cmd = "umount /dev/mmc/part1"; | 165 | cmd = "umount /dev/mmc/part1"; |
166 | } | 166 | } |
167 | else | 167 | else |
168 | { | 168 | { |
169 | cmd = "umount /dev/mmcda1"; | 169 | cmd = "umount /dev/mmcda1"; |
170 | } | 170 | } |
171 | err = system( ( const char * ) cmd ); | 171 | err = system( ( const char * ) cmd ); |
172 | if ( err != 0 ) | 172 | if ( err != 0 ) |
173 | { | 173 | { |
174 | popUp( tr( "SD/MMC card eject failed!" ) ); | 174 | popUp( tr( "SD/MMC card eject failed!" ) ); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | else if ( opt == 2 ) | 177 | else if ( opt == 2 ) |
178 | { | 178 | { |
179 | cmd = "/sbin/cardctl eject 1"; | 179 | cmd = "/sbin/cardctl eject 1"; |
180 | err = system( ( const char * ) cmd ); | 180 | err = system( ( const char * ) cmd ); |
181 | if ( err != 0 ) | 181 | if ( err != 0 ) |
182 | { | 182 | { |
183 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", | 183 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", |
184 | err ); | 184 | err ); |
185 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 185 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | delete menu; | 188 | delete menu; |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) | 192 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) |
193 | { | 193 | { |
194 | if ( msg == "stabChanged()" ) | 194 | if ( msg == "stabChanged()" ) |
195 | { | 195 | { |
196 | // qDebug("Pcmcia: stabchanged"); | 196 | // qDebug("Pcmcia: stabchanged"); |
197 | getStatusPcmcia(); | 197 | getStatusPcmcia(); |
198 | } | 198 | } |
199 | else if ( msg == "mtabChanged()" ) | 199 | else if ( msg == "mtabChanged()" ) |
200 | { | 200 | { |
201 | // qDebug("CARDMONAPPLET: mtabchanged"); | 201 | // qDebug("CARDMONAPPLET: mtabchanged"); |
202 | getStatusSd(); | 202 | getStatusSd(); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | bool CardMonitor::getStatusPcmcia( int showPopUp ) | 206 | bool CardMonitor::getStatusPcmcia( int showPopUp ) |
207 | { | 207 | { |
208 | 208 | ||
209 | bool cardWas0 = cardInPcmcia0;// remember last state | 209 | bool cardWas0 = cardInPcmcia0;// remember last state |
210 | bool cardWas1 = cardInPcmcia1; | 210 | bool cardWas1 = cardInPcmcia1; |
211 | 211 | ||
212 | QString fileName; | 212 | QString fileName; |
213 | 213 | ||
214 | // one of these 3 files should exist | 214 | // one of these 3 files should exist |
215 | if ( QFile::exists( "/var/run/stab" ) ) | 215 | if ( QFile::exists( "/var/run/stab" ) ) |
216 | { | 216 | { |
217 | fileName = "/var/run/stab"; | 217 | fileName = "/var/run/stab"; |
218 | } | 218 | } |
219 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) | 219 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) |
220 | { | 220 | { |
221 | fileName = "/var/state/pcmcia/stab"; | 221 | fileName = "/var/state/pcmcia/stab"; |
222 | } | 222 | } |
223 | else | 223 | else |
224 | { | 224 | { |
225 | fileName = "/var/lib/pcmcia/stab"; | 225 | fileName = "/var/lib/pcmcia/stab"; |
226 | } | 226 | } |
227 | 227 | ||
228 | QFile f( fileName ); | 228 | QFile f( fileName ); |
229 | 229 | ||
230 | if ( f.open( IO_ReadOnly ) ) | 230 | if ( f.open( IO_ReadOnly ) ) |
231 | { | 231 | { |
232 | QStringList list; | 232 | QStringList list; |
233 | QTextStream stream( &f ); | 233 | QTextStream stream( &f ); |
234 | QString streamIn; | 234 | QString streamIn; |
235 | streamIn = stream.read(); | 235 | streamIn = stream.read(); |
236 | list = QStringList::split( "\n", streamIn ); | 236 | list = QStringList::split( "\n", streamIn ); |
237 | for ( QStringList::Iterator line = list.begin(); line != list.end(); | 237 | for ( QStringList::Iterator line = list.begin(); line != list.end(); |
238 | line++ ) | 238 | line++ ) |
239 | { | 239 | { |
240 | if ( ( *line ).startsWith( "Socket 0:" ) ) | 240 | if ( ( *line ).startsWith( "Socket 0:" ) ) |
241 | { | 241 | { |
242 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) | 242 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) |
243 | { | 243 | { |
244 | cardInPcmcia0 = FALSE; | 244 | cardInPcmcia0 = FALSE; |
245 | } | 245 | } |
246 | else if ( !( *line ).startsWith( "Socket 0: empty" ) | 246 | else if ( !( *line ).startsWith( "Socket 0: empty" ) |
247 | && !cardInPcmcia0 ) | 247 | && !cardInPcmcia0 ) |
248 | { | 248 | { |
249 | cardInPcmcia0Name = | 249 | cardInPcmcia0Name = |
250 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | 250 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), |
251 | ( *line ).length() - 9 ); | 251 | ( *line ).length() - 9 ); |
252 | cardInPcmcia0Name.stripWhiteSpace(); | 252 | cardInPcmcia0Name.stripWhiteSpace(); |
253 | cardInPcmcia0 = TRUE; | 253 | cardInPcmcia0 = TRUE; |
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp index 34d151e..4fc8076 100644 --- a/core/applets/clipboardapplet/clipboard.cpp +++ b/core/applets/clipboardapplet/clipboard.cpp | |||
@@ -1,189 +1,189 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "clipboard.h" | 21 | #include "clipboard.h" |
22 | 22 | ||
23 | #include <opie2/otaskbarapplet.h> | 23 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | ||
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qwindowsystem_qws.h> | 29 | #include <qwindowsystem_qws.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qclipboard.h> | 31 | #include <qclipboard.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | //=========================================================================== | 34 | //=========================================================================== |
35 | 35 | ||
36 | 36 | ||
37 | ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) | 37 | ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) |
38 | { | 38 | { |
39 | setFixedWidth ( AppLnk::smallIconSize() ); | 39 | setFixedWidth ( AppLnk::smallIconSize() ); |
40 | setFixedHeight ( AppLnk::smallIconSize() ); | 40 | setFixedHeight ( AppLnk::smallIconSize() ); |
41 | 41 | ||
42 | QImage img = Resource::loadImage( "paste"); | 42 | QImage img = Resource::loadImage( "paste"); |
43 | img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 43 | img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
44 | 44 | ||
45 | m_clipboardPixmap.convertFromImage( img ); | 45 | m_clipboardPixmap.convertFromImage( img ); |
46 | 46 | ||
47 | m_timer = new QTimer ( this ); | 47 | m_timer = new QTimer ( this ); |
48 | 48 | ||
49 | connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); | 49 | connect ( QApplication::clipboard ( ), SIGNAL( dataChanged()), this, SLOT( newData())); |
50 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); | 50 | connect ( m_timer, SIGNAL( timeout()), this, SLOT( newData())); |
51 | connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( ))); | 51 | connect ( qApp, SIGNAL( aboutToQuit()), this, SLOT( shutdown())); |
52 | 52 | ||
53 | m_menu = 0; | 53 | m_menu = 0; |
54 | m_dirty = true; | 54 | m_dirty = true; |
55 | m_lasttext = QString::null; | 55 | m_lasttext = QString::null; |
56 | 56 | ||
57 | m_timer-> start ( 0, true ); | 57 | m_timer-> start ( 0, true ); |
58 | } | 58 | } |
59 | 59 | ||
60 | ClipboardApplet::~ClipboardApplet ( ) | 60 | ClipboardApplet::~ClipboardApplet ( ) |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | int ClipboardApplet::position() | 64 | int ClipboardApplet::position() |
65 | { | 65 | { |
66 | return 6; | 66 | return 6; |
67 | } | 67 | } |
68 | 68 | ||
69 | void ClipboardApplet::shutdown ( ) | 69 | void ClipboardApplet::shutdown ( ) |
70 | { | 70 | { |
71 | // the timer has to be stopped, or Qt/E will hang on quit() | 71 | // the timer has to be stopped, or Qt/E will hang on quit() |
72 | // see launcher/desktop.cpp | 72 | // see launcher/desktop.cpp |
73 | 73 | ||
74 | m_timer-> stop ( ); | 74 | m_timer-> stop ( ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) | 77 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) |
78 | { | 78 | { |
79 | if ( m_dirty ) { | 79 | if ( m_dirty ) { |
80 | delete m_menu; | 80 | delete m_menu; |
81 | 81 | ||
82 | m_menu = new QPopupMenu ( this ); | 82 | m_menu = new QPopupMenu ( this ); |
83 | m_menu-> setCheckable ( true ); | 83 | m_menu-> setCheckable ( true ); |
84 | 84 | ||
85 | if ( m_history. count ( )) { | 85 | if ( m_history. count ( )) { |
86 | for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { | 86 | for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { |
87 | QString str = m_history [i]; | 87 | QString str = m_history [i]; |
88 | 88 | ||
89 | if ( str. length ( ) > 20 ) | 89 | if ( str. length ( ) > 20 ) |
90 | str = str. left ( 20 ) + "..."; | 90 | str = str. left ( 20 ) + "..."; |
91 | 91 | ||
92 | m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); | 92 | m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); |
93 | m_menu-> setItemChecked ( i, false ); | 93 | m_menu-> setItemChecked ( i, false ); |
94 | } | 94 | } |
95 | m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); | 95 | m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); |
96 | m_menu-> insertSeparator ( ); | 96 | m_menu-> insertSeparator ( ); |
97 | } | 97 | } |
98 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); | 98 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); |
99 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); | 99 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); |
100 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); | 100 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); |
101 | 101 | ||
102 | connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); | 102 | connect ( m_menu, SIGNAL( activated(int)), this, SLOT( action(int))); |
103 | 103 | ||
104 | m_dirty = false; | 104 | m_dirty = false; |
105 | } | 105 | } |
106 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 106 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
107 | QSize s = m_menu-> sizeHint ( ); | 107 | QSize s = m_menu-> sizeHint ( ); |
108 | 108 | ||
109 | m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); | 109 | m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); |
110 | } | 110 | } |
111 | 111 | ||
112 | void ClipboardApplet::action(int id) | 112 | void ClipboardApplet::action(int id) |
113 | { | 113 | { |
114 | ushort unicode = 0; | 114 | ushort unicode = 0; |
115 | int scan = 0; | 115 | int scan = 0; |
116 | 116 | ||
117 | switch ( id ) { | 117 | switch ( id ) { |
118 | case 100: | 118 | case 100: |
119 | unicode = 'X' - '@'; | 119 | unicode = 'X' - '@'; |
120 | scan = Key_X; // Cut | 120 | scan = Key_X; // Cut |
121 | break; | 121 | break; |
122 | case 101: | 122 | case 101: |
123 | unicode = 'C' - '@'; | 123 | unicode = 'C' - '@'; |
124 | scan = Key_C; // Copy | 124 | scan = Key_C; // Copy |
125 | break; | 125 | break; |
126 | case 102: | 126 | case 102: |
127 | unicode = 'V' - '@'; | 127 | unicode = 'V' - '@'; |
128 | scan = Key_V; // Paste | 128 | scan = Key_V; // Paste |
129 | break; | 129 | break; |
130 | 130 | ||
131 | default: | 131 | default: |
132 | if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { | 132 | if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { |
133 | QApplication::clipboard ( )-> setText ( m_history [id] ); | 133 | QApplication::clipboard ( )-> setText ( m_history [id] ); |
134 | 134 | ||
135 | for ( uint i = 0; i < m_history. count ( ); i++ ) | 135 | for ( uint i = 0; i < m_history. count ( ); i++ ) |
136 | m_menu-> setItemChecked ( i, i == uint( id )); | 136 | m_menu-> setItemChecked ( i, i == uint( id )); |
137 | 137 | ||
138 | unicode = 'V' - '@'; | 138 | unicode = 'V' - '@'; |
139 | scan = Key_V; | 139 | scan = Key_V; |
140 | } | 140 | } |
141 | break; | 141 | break; |
142 | } | 142 | } |
143 | 143 | ||
144 | if ( scan ) { | 144 | if ( scan ) { |
145 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); | 145 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); |
146 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); | 146 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | void ClipboardApplet::paintEvent ( QPaintEvent* ) | 150 | void ClipboardApplet::paintEvent ( QPaintEvent* ) |
151 | { | 151 | { |
152 | QPainter p ( this ); | 152 | QPainter p ( this ); |
153 | /* center the height but our pixmap is as big as the height ;)*/ | 153 | /* center the height but our pixmap is as big as the height ;)*/ |
154 | p. drawPixmap( 0, 0, | 154 | p. drawPixmap( 0, 0, |
155 | m_clipboardPixmap ); | 155 | m_clipboardPixmap ); |
156 | } | 156 | } |
157 | 157 | ||
158 | void ClipboardApplet::newData ( ) | 158 | void ClipboardApplet::newData ( ) |
159 | { | 159 | { |
160 | static bool excllock = false; | 160 | static bool excllock = false; |
161 | 161 | ||
162 | if ( excllock ) | 162 | if ( excllock ) |
163 | return; | 163 | return; |
164 | else | 164 | else |
165 | excllock = true; | 165 | excllock = true; |
166 | 166 | ||
167 | m_timer-> stop ( ); | 167 | m_timer-> stop ( ); |
168 | 168 | ||
169 | QCString type = "plain"; | 169 | QCString type = "plain"; |
170 | QString txt = QApplication::clipboard ( )-> text ( type ); | 170 | QString txt = QApplication::clipboard ( )-> text ( type ); |
171 | 171 | ||
172 | if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { | 172 | if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { |
173 | m_history. append ( txt ); | 173 | m_history. append ( txt ); |
174 | 174 | ||
175 | if ( m_history. count ( ) > 5 ) | 175 | if ( m_history. count ( ) > 5 ) |
176 | m_history. remove ( m_history. begin ( )); | 176 | m_history. remove ( m_history. begin ( )); |
177 | 177 | ||
178 | m_dirty = true; | 178 | m_dirty = true; |
179 | } | 179 | } |
180 | 180 | ||
181 | m_timer-> start ( 1500, true ); | 181 | m_timer-> start ( 1500, true ); |
182 | 182 | ||
183 | excllock = false; | 183 | excllock = false; |
184 | } | 184 | } |
185 | 185 | ||
186 | Q_EXPORT_INTERFACE() | 186 | Q_EXPORT_INTERFACE() |
187 | { | 187 | { |
188 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ClipboardApplet> ); | 188 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ClipboardApplet> ); |
189 | } | 189 | } |
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp index 9fead03..120a019 100644 --- a/core/applets/clockapplet/clock.cpp +++ b/core/applets/clockapplet/clock.cpp | |||
@@ -1,121 +1,121 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "clock.h" | 21 | #include "clock.h" |
22 | 22 | ||
23 | #include <opie2/otaskbarapplet.h> | 23 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | 27 | ||
28 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) | 28 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) |
29 | { | 29 | { |
30 | // If you want a sunken border around the clock do this: | 30 | // If you want a sunken border around the clock do this: |
31 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 31 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
32 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); | 32 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); |
33 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) ); | 33 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime() ) ); |
34 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 34 | connect( qApp, SIGNAL( clockChanged(bool) ), |
35 | this, SLOT( slotClockChanged( bool ) ) ); | 35 | this, SLOT( slotClockChanged(bool) ) ); |
36 | readConfig(); | 36 | readConfig(); |
37 | timerId = 0; | 37 | timerId = 0; |
38 | timerEvent( 0 ); | 38 | timerEvent( 0 ); |
39 | show(); | 39 | show(); |
40 | } | 40 | } |
41 | 41 | ||
42 | int LauncherClock::position() | 42 | int LauncherClock::position() |
43 | { | 43 | { |
44 | return 10; | 44 | return 10; |
45 | } | 45 | } |
46 | 46 | ||
47 | void LauncherClock::readConfig() { | 47 | void LauncherClock::readConfig() { |
48 | Config config( "qpe" ); | 48 | Config config( "qpe" ); |
49 | config.setGroup( "Time" ); | 49 | config.setGroup( "Time" ); |
50 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); | 50 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); |
51 | config.setGroup( "Date" ); | 51 | config.setGroup( "Date" ); |
52 | format = config.readNumEntry("ClockApplet",0); | 52 | format = config.readNumEntry("ClockApplet",0); |
53 | } | 53 | } |
54 | 54 | ||
55 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) | 55 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) |
56 | { | 56 | { |
57 | QCString setTimeApp; | 57 | QCString setTimeApp; |
58 | setTimeApp="systemtime"; | 58 | setTimeApp="systemtime"; |
59 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); | 59 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | void LauncherClock::timerEvent( QTimerEvent *e ) | 63 | void LauncherClock::timerEvent( QTimerEvent *e ) |
64 | { | 64 | { |
65 | if ( !e || e->timerId() == timerId ) { | 65 | if ( !e || e->timerId() == timerId ) { |
66 | killTimer( timerId ); | 66 | killTimer( timerId ); |
67 | changeTime(); | 67 | changeTime(); |
68 | QTime t = QTime::currentTime(); | 68 | QTime t = QTime::currentTime(); |
69 | int ms = (60 - t.second())*1000 - t.msec(); | 69 | int ms = (60 - t.second())*1000 - t.msec(); |
70 | timerId = startTimer( ms ); | 70 | timerId = startTimer( ms ); |
71 | } else { | 71 | } else { |
72 | QLabel::timerEvent( e ); | 72 | QLabel::timerEvent( e ); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | void LauncherClock::updateTime( void ) | 76 | void LauncherClock::updateTime( void ) |
77 | { | 77 | { |
78 | changeTime(); | 78 | changeTime(); |
79 | } | 79 | } |
80 | 80 | ||
81 | void LauncherClock::changeTime( void ) | 81 | void LauncherClock::changeTime( void ) |
82 | { | 82 | { |
83 | QTime tm = QDateTime::currentDateTime().time(); | 83 | QTime tm = QDateTime::currentDateTime().time(); |
84 | QString s; | 84 | QString s; |
85 | if( ampmFormat ) { | 85 | if( ampmFormat ) { |
86 | int hour = tm.hour(); | 86 | int hour = tm.hour(); |
87 | if (hour == 0) | 87 | if (hour == 0) |
88 | hour = 12; | 88 | hour = 12; |
89 | if (hour > 12) | 89 | if (hour > 12) |
90 | hour -= 12; | 90 | hour -= 12; |
91 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 91 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
92 | (tm.hour() >= 12) ? "PM" : "AM" ); | 92 | (tm.hour() >= 12) ? "PM" : "AM" ); |
93 | } else | 93 | } else |
94 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 94 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
95 | 95 | ||
96 | if (format==1) { | 96 | if (format==1) { |
97 | QDate dm = QDate::currentDate(); | 97 | QDate dm = QDate::currentDate(); |
98 | QString d; | 98 | QString d; |
99 | d.sprintf("%d/%d ", dm.day(), dm.month()); | 99 | d.sprintf("%d/%d ", dm.day(), dm.month()); |
100 | setText( d+s ); | 100 | setText( d+s ); |
101 | } else if (format==2) { | 101 | } else if (format==2) { |
102 | QDate dm = QDate::currentDate(); | 102 | QDate dm = QDate::currentDate(); |
103 | QString d; | 103 | QString d; |
104 | d.sprintf("%d/%d ", dm.month(), dm.day()); | 104 | d.sprintf("%d/%d ", dm.month(), dm.day()); |
105 | setText( d+s ); | 105 | setText( d+s ); |
106 | } else { | 106 | } else { |
107 | setText( s ); | 107 | setText( s ); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | void LauncherClock::slotClockChanged( bool pm ) | 111 | void LauncherClock::slotClockChanged( bool pm ) |
112 | { | 112 | { |
113 | readConfig(); | 113 | readConfig(); |
114 | updateTime(); | 114 | updateTime(); |
115 | } | 115 | } |
116 | 116 | ||
117 | Q_EXPORT_INTERFACE() | 117 | Q_EXPORT_INTERFACE() |
118 | { | 118 | { |
119 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<LauncherClock> ); | 119 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<LauncherClock> ); |
120 | } | 120 | } |
121 | 121 | ||
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index afc0592..dde8050 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -1,292 +1,292 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> | 2 | ** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> |
3 | ** Max Reiss <harlekin@handhelds.org> [trivial stuff] | 3 | ** Max Reiss <harlekin@handhelds.org> [trivial stuff] |
4 | ** Robert Griebl <sandman@handhelds.org> | 4 | ** Robert Griebl <sandman@handhelds.org> |
5 | ** Holger Freyther <zecke@handhelds.org> QCOP Interface | 5 | ** Holger Freyther <zecke@handhelds.org> QCOP Interface |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | **********************************************************************/ | 15 | **********************************************************************/ |
16 | 16 | ||
17 | #include "irda.h" | 17 | #include "irda.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <net/if.h> | 32 | #include <net/if.h> |
33 | #include <netinet/in.h> | 33 | #include <netinet/in.h> |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | #include <sys/socket.h> | 35 | #include <sys/socket.h> |
36 | #include <sys/ioctl.h> | 36 | #include <sys/ioctl.h> |
37 | 37 | ||
38 | //=========================================================================== | 38 | //=========================================================================== |
39 | 39 | ||
40 | IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) | 40 | IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) |
41 | : QWidget ( parent, name ) | 41 | : QWidget ( parent, name ) |
42 | { | 42 | { |
43 | setFixedHeight ( 18 ); | 43 | setFixedHeight ( 18 ); |
44 | setFixedWidth ( 14 ); | 44 | setFixedWidth ( 14 ); |
45 | 45 | ||
46 | m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); | 46 | m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); |
47 | 47 | ||
48 | m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); | 48 | m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); |
49 | m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); | 49 | m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); |
50 | m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); | 50 | m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); |
51 | m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); | 51 | m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); |
52 | 52 | ||
53 | m_irda_active = false; | 53 | m_irda_active = false; |
54 | m_irda_discovery_active = false; | 54 | m_irda_discovery_active = false; |
55 | m_receive_active = false; | 55 | m_receive_active = false; |
56 | m_receive_state_changed = false; | 56 | m_receive_state_changed = false; |
57 | m_popup = 0; | 57 | m_popup = 0; |
58 | m_wasOn = false; | 58 | m_wasOn = false; |
59 | m_wasDiscover = false; | 59 | m_wasDiscover = false; |
60 | 60 | ||
61 | QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); | 61 | QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); |
62 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 62 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
63 | this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) ); | 63 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); |
64 | } | 64 | } |
65 | 65 | ||
66 | int IrdaApplet::position() | 66 | int IrdaApplet::position() |
67 | { | 67 | { |
68 | return 6; | 68 | return 6; |
69 | } | 69 | } |
70 | 70 | ||
71 | void IrdaApplet::show() | 71 | void IrdaApplet::show() |
72 | { | 72 | { |
73 | QWidget::show ( ); | 73 | QWidget::show ( ); |
74 | startTimer ( 2000 ); | 74 | startTimer ( 2000 ); |
75 | } | 75 | } |
76 | 76 | ||
77 | IrdaApplet::~IrdaApplet() | 77 | IrdaApplet::~IrdaApplet() |
78 | { | 78 | { |
79 | if ( m_sockfd >= 0 ) | 79 | if ( m_sockfd >= 0 ) |
80 | ::close ( m_sockfd ); | 80 | ::close ( m_sockfd ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void IrdaApplet::popup ( QString message, QString icon ) | 83 | void IrdaApplet::popup ( QString message, QString icon ) |
84 | { | 84 | { |
85 | if ( !m_popup ) | 85 | if ( !m_popup ) |
86 | m_popup = new QPopupMenu ( this ); | 86 | m_popup = new QPopupMenu ( this ); |
87 | 87 | ||
88 | m_popup-> clear ( ); | 88 | m_popup-> clear ( ); |
89 | 89 | ||
90 | if ( icon. isEmpty ( )) | 90 | if ( icon. isEmpty ( )) |
91 | m_popup-> insertItem ( message, 0 ); | 91 | m_popup-> insertItem ( message, 0 ); |
92 | else | 92 | else |
93 | m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); | 93 | m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); |
94 | 94 | ||
95 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 95 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
96 | QSize s = m_popup-> sizeHint ( ); | 96 | QSize s = m_popup-> sizeHint ( ); |
97 | m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 97 | m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
98 | p. y ( ) - s. height ( ))); | 98 | p. y ( ) - s. height ( ))); |
99 | 99 | ||
100 | QTimer::singleShot ( 2000, this, SLOT( popupTimeout ( ))); | 100 | QTimer::singleShot ( 2000, this, SLOT( popupTimeout())); |
101 | } | 101 | } |
102 | 102 | ||
103 | void IrdaApplet::popupTimeout ( ) | 103 | void IrdaApplet::popupTimeout ( ) |
104 | { | 104 | { |
105 | m_popup-> hide ( ); | 105 | m_popup-> hide ( ); |
106 | } | 106 | } |
107 | 107 | ||
108 | bool IrdaApplet::checkIrdaStatus ( ) | 108 | bool IrdaApplet::checkIrdaStatus ( ) |
109 | { | 109 | { |
110 | struct ifreq ifr; | 110 | struct ifreq ifr; |
111 | strcpy ( ifr. ifr_name, "irda0" ); | 111 | strcpy ( ifr. ifr_name, "irda0" ); |
112 | 112 | ||
113 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) | 113 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) |
114 | return false; | 114 | return false; |
115 | 115 | ||
116 | return ( ifr. ifr_flags & IFF_UP ); | 116 | return ( ifr. ifr_flags & IFF_UP ); |
117 | } | 117 | } |
118 | 118 | ||
119 | bool IrdaApplet::setIrdaStatus ( bool b ) | 119 | bool IrdaApplet::setIrdaStatus ( bool b ) |
120 | { | 120 | { |
121 | struct ifreq ifr; | 121 | struct ifreq ifr; |
122 | strcpy ( ifr. ifr_name, "irda0" ); | 122 | strcpy ( ifr. ifr_name, "irda0" ); |
123 | 123 | ||
124 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) | 124 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) |
125 | return false; | 125 | return false; |
126 | 126 | ||
127 | if ( b ) { | 127 | if ( b ) { |
128 | ifr. ifr_flags |= IFF_UP; | 128 | ifr. ifr_flags |= IFF_UP; |
129 | } | 129 | } |
130 | else { | 130 | else { |
131 | setIrdaDiscoveryStatus ( 0 ); | 131 | setIrdaDiscoveryStatus ( 0 ); |
132 | setIrdaReceiveStatus ( 0 ); | 132 | setIrdaReceiveStatus ( 0 ); |
133 | ifr. ifr_flags &= ~IFF_UP; | 133 | ifr. ifr_flags &= ~IFF_UP; |
134 | } | 134 | } |
135 | 135 | ||
136 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) | 136 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) |
137 | return false; | 137 | return false; |
138 | 138 | ||
139 | return true; | 139 | return true; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) | 142 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) |
143 | { | 143 | { |
144 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 144 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
145 | 145 | ||
146 | QString streamIn = "0"; | 146 | QString streamIn = "0"; |
147 | 147 | ||
148 | if ( discovery. open ( IO_ReadOnly )) { | 148 | if ( discovery. open ( IO_ReadOnly )) { |
149 | QTextStream stream ( &discovery ); | 149 | QTextStream stream ( &discovery ); |
150 | streamIn = stream. read ( ); | 150 | streamIn = stream. read ( ); |
151 | } | 151 | } |
152 | 152 | ||
153 | return streamIn. toInt ( ) > 0; | 153 | return streamIn. toInt ( ) > 0; |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) | 157 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) |
158 | { | 158 | { |
159 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 159 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
160 | 160 | ||
161 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { | 161 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { |
162 | discovery.putch ( d ? '1' : '0' ); | 162 | discovery.putch ( d ? '1' : '0' ); |
163 | return true; | 163 | return true; |
164 | } | 164 | } |
165 | return false; | 165 | return false; |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) | 169 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) |
170 | { | 170 | { |
171 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); | 171 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); |
172 | e << ( d ? 1 : 0 ); | 172 | e << ( d ? 1 : 0 ); |
173 | 173 | ||
174 | m_receive_active = d; | 174 | m_receive_active = d; |
175 | m_receive_state_changed = true; | 175 | m_receive_state_changed = true; |
176 | 176 | ||
177 | return true; | 177 | return true; |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | void IrdaApplet::showDiscovered ( ) | 181 | void IrdaApplet::showDiscovered ( ) |
182 | { | 182 | { |
183 | //static Sound snd_found ( "irdaapplet/irdaon" ); | 183 | //static Sound snd_found ( "irdaapplet/irdaon" ); |
184 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); | 184 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); |
185 | 185 | ||
186 | QFile discovery ( "/proc/net/irda/discovery" ); | 186 | QFile discovery ( "/proc/net/irda/discovery" ); |
187 | 187 | ||
188 | if ( discovery. open ( IO_ReadOnly )) { | 188 | if ( discovery. open ( IO_ReadOnly )) { |
189 | bool qcopsend = false; | 189 | bool qcopsend = false; |
190 | 190 | ||
191 | QString discoveredDevice; | 191 | QString discoveredDevice; |
192 | QString deviceAddr; | 192 | QString deviceAddr; |
193 | 193 | ||
194 | // since it is /proc we _must_ use QTextStream | 194 | // since it is /proc we _must_ use QTextStream |
195 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); | 195 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); |
196 | 196 | ||
197 | QMap <QString, QString>::Iterator it; | 197 | QMap <QString, QString>::Iterator it; |
198 | 198 | ||
199 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 199 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
200 | it. data ( ). prepend ( "+++" ); | 200 | it. data ( ). prepend ( "+++" ); |
201 | 201 | ||
202 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { | 202 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { |
203 | const QString &line = *lit; | 203 | const QString &line = *lit; |
204 | 204 | ||
205 | if ( line. startsWith ( "nickname:" )) { | 205 | if ( line. startsWith ( "nickname:" )) { |
206 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); | 206 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); |
207 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); | 207 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); |
208 | 208 | ||
209 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); | 209 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); |
210 | 210 | ||
211 | if ( !m_devices. contains ( deviceAddr )) { | 211 | if ( !m_devices. contains ( deviceAddr )) { |
212 | popup ( tr( "Found:" ) + " " + discoveredDevice ); | 212 | popup ( tr( "Found:" ) + " " + discoveredDevice ); |
213 | //snd_found. play ( ); | 213 | //snd_found. play ( ); |
214 | qcopsend = true; | 214 | qcopsend = true; |
215 | } | 215 | } |
216 | m_devices. replace ( deviceAddr, discoveredDevice ); | 216 | m_devices. replace ( deviceAddr, discoveredDevice ); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { | 220 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { |
221 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); | 221 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); |
222 | 222 | ||
223 | if ( it. data ( ). left ( 3 ) == "+++" ) { | 223 | if ( it. data ( ). left ( 3 ) == "+++" ) { |
224 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); | 224 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); |
225 | //snd_lost. play ( ); | 225 | //snd_lost. play ( ); |
226 | 226 | ||
227 | QMap <QString, QString>::Iterator tmp = it; | 227 | QMap <QString, QString>::Iterator tmp = it; |
228 | tmp++; | 228 | tmp++; |
229 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator | 229 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator |
230 | it = tmp; | 230 | it = tmp; |
231 | 231 | ||
232 | qcopsend = true; | 232 | qcopsend = true; |
233 | } | 233 | } |
234 | else | 234 | else |
235 | it++; | 235 | it++; |
236 | } | 236 | } |
237 | // XXX if( qcopsend ) { | 237 | // XXX if( qcopsend ) { |
238 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); | 238 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); |
239 | e << ( m_devices. count ( ) > 0 ); | 239 | e << ( m_devices. count ( ) > 0 ); |
240 | // } | 240 | // } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) | 244 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) |
245 | { | 245 | { |
246 | QPopupMenu *menu = new QPopupMenu ( this ); | 246 | QPopupMenu *menu = new QPopupMenu ( this ); |
247 | QString cmd; | 247 | QString cmd; |
248 | 248 | ||
249 | /* Refresh active state */ | 249 | /* Refresh active state */ |
250 | timerEvent ( 0 ); | 250 | timerEvent ( 0 ); |
251 | 251 | ||
252 | //menu->insertItem( tr("More..."), 4 ); | 252 | //menu->insertItem( tr("More..."), 4 ); |
253 | 253 | ||
254 | if ( m_irda_active && !m_devices. isEmpty ( )) { | 254 | if ( m_irda_active && !m_devices. isEmpty ( )) { |
255 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); | 255 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); |
256 | 256 | ||
257 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 257 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
258 | menu-> insertItem ( *it ); | 258 | menu-> insertItem ( *it ); |
259 | 259 | ||
260 | menu-> insertSeparator ( ); | 260 | menu-> insertSeparator ( ); |
261 | } | 261 | } |
262 | 262 | ||
263 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); | 263 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); |
264 | 264 | ||
265 | if ( m_irda_active ) { | 265 | if ( m_irda_active ) { |
266 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); | 266 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); |
267 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); | 267 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 270 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); |
271 | QSize s = menu-> sizeHint ( ); | 271 | QSize s = menu-> sizeHint ( ); |
272 | 272 | ||
273 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); | 273 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); |
274 | 274 | ||
275 | switch ( menu-> exec ( p )) { | 275 | switch ( menu-> exec ( p )) { |
276 | case 0: | 276 | case 0: |
277 | setIrdaStatus ( !m_irda_active ); | 277 | setIrdaStatus ( !m_irda_active ); |
278 | timerEvent ( 0 ); | 278 | timerEvent ( 0 ); |
279 | break; | 279 | break; |
280 | case 1: | 280 | case 1: |
281 | setIrdaDiscoveryStatus ( !m_irda_discovery_active ); | 281 | setIrdaDiscoveryStatus ( !m_irda_discovery_active ); |
282 | timerEvent ( 0 ); | 282 | timerEvent ( 0 ); |
283 | break; | 283 | break; |
284 | case 2: | 284 | case 2: |
285 | setIrdaReceiveStatus ( !m_receive_active ); | 285 | setIrdaReceiveStatus ( !m_receive_active ); |
286 | timerEvent( 0 ); | 286 | timerEvent( 0 ); |
287 | break; | 287 | break; |
288 | } | 288 | } |
289 | 289 | ||
290 | delete menu; | 290 | delete menu; |
291 | } | 291 | } |
292 | 292 | ||
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index b17498d..fc5f093 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp | |||
@@ -1,143 +1,143 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru | 2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "multikey.h" | 15 | #include "multikey.h" |
16 | 16 | ||
17 | /* OPIE */ | 17 | /* OPIE */ |
18 | #include <opie2/otaskbarapplet.h> | 18 | #include <opie2/otaskbarapplet.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | 20 | ||
21 | /* QT */ | 21 | /* QT */ |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | 23 | ||
24 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") | 24 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") |
25 | { | 25 | { |
26 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); | 26 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); |
27 | connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 27 | connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
28 | this, SLOT(message(const QCString &, const QByteArray &))); | 28 | this, SLOT(message(const QCString&,const QByteArray&))); |
29 | 29 | ||
30 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); | 30 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); |
31 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); | 31 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); |
32 | lang = 0; | 32 | lang = 0; |
33 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); | 33 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); |
34 | setText("EN"); | 34 | setText("EN"); |
35 | popupMenu.insertItem("EN", 0); | 35 | popupMenu.insertItem("EN", 0); |
36 | show(); | 36 | show(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void Multikey::mousePressEvent(QMouseEvent *ev) | 39 | void Multikey::mousePressEvent(QMouseEvent *ev) |
40 | { | 40 | { |
41 | if (!sw_maps.count()) | 41 | if (!sw_maps.count()) |
42 | return; | 42 | return; |
43 | 43 | ||
44 | if (ev->button() == RightButton) { | 44 | if (ev->button() == RightButton) { |
45 | 45 | ||
46 | QPoint p = mapToGlobal(QPoint(0, 0)); | 46 | QPoint p = mapToGlobal(QPoint(0, 0)); |
47 | QSize s = popupMenu.sizeHint(); | 47 | QSize s = popupMenu.sizeHint(); |
48 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 48 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
49 | p.y() - s.height()), 0); | 49 | p.y() - s.height()), 0); |
50 | 50 | ||
51 | if (opt == -1) | 51 | if (opt == -1) |
52 | return; | 52 | return; |
53 | lang = opt; | 53 | lang = opt; |
54 | 54 | ||
55 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 55 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
56 | e << sw_maps[lang]; | 56 | e << sw_maps[lang]; |
57 | setText(labels[lang]); | 57 | setText(labels[lang]); |
58 | } | 58 | } |
59 | QWidget::mousePressEvent(ev); | 59 | QWidget::mousePressEvent(ev); |
60 | } | 60 | } |
61 | 61 | ||
62 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) | 62 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) |
63 | { | 63 | { |
64 | if (!sw_maps.count()) | 64 | if (!sw_maps.count()) |
65 | return; | 65 | return; |
66 | 66 | ||
67 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; | 67 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; |
68 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 68 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
69 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); | 69 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); |
70 | e << sw_maps[lang]; | 70 | e << sw_maps[lang]; |
71 | setText(labels[lang]); | 71 | setText(labels[lang]); |
72 | } | 72 | } |
73 | 73 | ||
74 | void Multikey::message(const QCString &message, const QByteArray &data) | 74 | void Multikey::message(const QCString &message, const QByteArray &data) |
75 | { | 75 | { |
76 | if ( message == "setsw(QString,QString)" ) { | 76 | if ( message == "setsw(QString,QString)" ) { |
77 | 77 | ||
78 | QDataStream stream(data, IO_ReadOnly); | 78 | QDataStream stream(data, IO_ReadOnly); |
79 | QString maps, current_map; | 79 | QString maps, current_map; |
80 | stream >> maps >> current_map; | 80 | stream >> maps >> current_map; |
81 | QStringList sw = QStringList::split(QChar('|'), maps); | 81 | QStringList sw = QStringList::split(QChar('|'), maps); |
82 | sw.append(current_map); | 82 | sw.append(current_map); |
83 | 83 | ||
84 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); | 84 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); |
85 | lang = 0; | 85 | lang = 0; |
86 | labels.clear(); | 86 | labels.clear(); |
87 | sw_maps.clear(); | 87 | sw_maps.clear(); |
88 | popupMenu.clear(); | 88 | popupMenu.clear(); |
89 | 89 | ||
90 | for (uint i = 0; i < sw.count(); ++i) { | 90 | for (uint i = 0; i < sw.count(); ++i) { |
91 | QString keymap_map; | 91 | QString keymap_map; |
92 | if (sw[i][0] != '/') { | 92 | if (sw[i][0] != '/') { |
93 | 93 | ||
94 | keymap_map = map_dir.absPath() + "/" + sw[i]; | 94 | keymap_map = map_dir.absPath() + "/" + sw[i]; |
95 | } else { | 95 | } else { |
96 | 96 | ||
97 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) | 97 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) |
98 | && i != sw.count()-1) || !QFile::exists(sw[i])) { | 98 | && i != sw.count()-1) || !QFile::exists(sw[i])) { |
99 | continue; | 99 | continue; |
100 | } | 100 | } |
101 | keymap_map = sw[i]; | 101 | keymap_map = sw[i]; |
102 | } | 102 | } |
103 | 103 | ||
104 | QFile map(keymap_map); | 104 | QFile map(keymap_map); |
105 | if (map.open(IO_ReadOnly)) { | 105 | if (map.open(IO_ReadOnly)) { |
106 | QString line; | 106 | QString line; |
107 | 107 | ||
108 | map.readLine(line, 1024); | 108 | map.readLine(line, 1024); |
109 | while (!map.atEnd()) { | 109 | while (!map.atEnd()) { |
110 | 110 | ||
111 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { | 111 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { |
112 | 112 | ||
113 | if (i != sw.count()-1) { | 113 | if (i != sw.count()-1) { |
114 | if (keymap_map == current_map) { | 114 | if (keymap_map == current_map) { |
115 | lang = i; | 115 | lang = i; |
116 | } | 116 | } |
117 | sw_maps.append(keymap_map); | 117 | sw_maps.append(keymap_map); |
118 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 118 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
119 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); | 119 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); |
120 | } else { | 120 | } else { |
121 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); | 121 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); |
122 | } | 122 | } |
123 | break; | 123 | break; |
124 | } | 124 | } |
125 | map.readLine(line, 1024); | 125 | map.readLine(line, 1024); |
126 | } | 126 | } |
127 | map.close(); | 127 | map.close(); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | setText(current); | 131 | setText(current); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | int Multikey::position() | 135 | int Multikey::position() |
136 | { | 136 | { |
137 | return 10; | 137 | return 10; |
138 | } | 138 | } |
139 | 139 | ||
140 | Q_EXPORT_INTERFACE() | 140 | Q_EXPORT_INTERFACE() |
141 | { | 141 | { |
142 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<Multikey> ); | 142 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<Multikey> ); |
143 | } | 143 | } |
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index dcbf809..0488c36 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -1,244 +1,244 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> | 4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> |
5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> | 5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This library is free software; you can | 8 | _;:, .> :=|. This library is free software; you can |
9 | .> <, > . <= redistribute it and/or modify it under | 9 | .> <, > . <= redistribute it and/or modify it under |
10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%+i> _;_. | 14 | .%+i> _;_. |
15 | .i_,=:_. -<s. This library is distributed in the hope that | 15 | .i_,=:_. -<s. This library is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. . .: details. | 21 | ++= -. . .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-= this library; see the file COPYING.LIB. | 25 | -- :-= this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "rotate.h" | 31 | #include "rotate.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie/odevice.h> | 34 | #include <opie/odevice.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/power.h> | 36 | #include <qpe/power.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | using namespace Opie; | 39 | using namespace Opie; |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | 42 | ||
43 | #include <time.h> | 43 | #include <time.h> |
44 | 44 | ||
45 | RotateApplet::RotateApplet() | 45 | RotateApplet::RotateApplet() |
46 | :QObject( 0, "RotateApplet" ), m_flipped( false ) | 46 | :QObject( 0, "RotateApplet" ), m_flipped( false ) |
47 | { | 47 | { |
48 | 48 | ||
49 | #if !defined(QT_NO_COP) | 49 | #if !defined(QT_NO_COP) |
50 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); | 50 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); |
51 | connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 51 | connect ( rotateChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
52 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 52 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | } | 55 | } |
56 | 56 | ||
57 | RotateApplet::~RotateApplet ( ) | 57 | RotateApplet::~RotateApplet ( ) |
58 | {} | 58 | {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Qcop receive method. | 61 | * Qcop receive method. |
62 | */ | 62 | */ |
63 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) | 63 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) |
64 | { | 64 | { |
65 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); | 65 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); |
66 | 66 | ||
67 | if ( ODevice::inst()->hasHingeSensor() ) | 67 | if ( ODevice::inst()->hasHingeSensor() ) |
68 | { | 68 | { |
69 | struct timespec interval; | 69 | struct timespec interval; |
70 | struct timespec remain; | 70 | struct timespec remain; |
71 | interval.tv_sec = 0; | 71 | interval.tv_sec = 0; |
72 | interval.tv_nsec = 600000; | 72 | interval.tv_nsec = 600000; |
73 | ::nanosleep( &interval, &remain ); | 73 | ::nanosleep( &interval, &remain ); |
74 | OHingeStatus status = ODevice::inst()->readHingeSensor(); | 74 | OHingeStatus status = ODevice::inst()->readHingeSensor(); |
75 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); | 75 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); |
76 | 76 | ||
77 | Config cfg( "apm" ); | 77 | Config cfg( "apm" ); |
78 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); | 78 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); |
79 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); | 79 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); |
80 | 80 | ||
81 | if ( status == CASE_CLOSED ) | 81 | if ( status == CASE_CLOSED ) |
82 | { | 82 | { |
83 | switch ( action ) | 83 | switch ( action ) |
84 | { | 84 | { |
85 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; | 85 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; |
86 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; | 86 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; |
87 | default: /* IGNORE */ break; | 87 | default: /* IGNORE */ break; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | else /* status != CASE_CLOSED */ | 90 | else /* status != CASE_CLOSED */ |
91 | { | 91 | { |
92 | switch ( action ) | 92 | switch ( action ) |
93 | { | 93 | { |
94 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; | 94 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; |
95 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; | 95 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; |
96 | default: /* IGNORE */ break; | 96 | default: /* IGNORE */ break; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); | 99 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); |
100 | } | 100 | } |
101 | 101 | ||
102 | QDataStream stream( data, IO_ReadOnly ); | 102 | QDataStream stream( data, IO_ReadOnly ); |
103 | if ( msg == "flip()" ) | 103 | if ( msg == "flip()" ) |
104 | { | 104 | { |
105 | activated ( ); | 105 | activated ( ); |
106 | } | 106 | } |
107 | else if ( msg == "rotateDefault()") | 107 | else if ( msg == "rotateDefault()") |
108 | { | 108 | { |
109 | rotateDefault(); | 109 | rotateDefault(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | int RotateApplet::position() const | 113 | int RotateApplet::position() const |
114 | { | 114 | { |
115 | return 3; | 115 | return 3; |
116 | } | 116 | } |
117 | 117 | ||
118 | QString RotateApplet::name() const | 118 | QString RotateApplet::name() const |
119 | { | 119 | { |
120 | return tr( "Rotate shortcut" ); | 120 | return tr( "Rotate shortcut" ); |
121 | } | 121 | } |
122 | 122 | ||
123 | QString RotateApplet::text() const | 123 | QString RotateApplet::text() const |
124 | { | 124 | { |
125 | return tr( "Rotate" ); | 125 | return tr( "Rotate" ); |
126 | } | 126 | } |
127 | 127 | ||
128 | /*QString RotateApplet::tr( const char* s ) const | 128 | /*QString RotateApplet::tr( const char* s ) const |
129 | { | 129 | { |
130 | return qApp->translate( "RotateApplet", s, 0 ); | 130 | return qApp->translate( "RotateApplet", s, 0 ); |
131 | } | 131 | } |
132 | 132 | ||
133 | QString RotateApplet::tr( const char* s, const char* p ) const | 133 | QString RotateApplet::tr( const char* s, const char* p ) const |
134 | { | 134 | { |
135 | return qApp->translate( "RotateApplet", s, p ); | 135 | return qApp->translate( "RotateApplet", s, p ); |
136 | } | 136 | } |
137 | */ | 137 | */ |
138 | 138 | ||
139 | QIconSet RotateApplet::icon() const | 139 | QIconSet RotateApplet::icon() const |
140 | { | 140 | { |
141 | QPixmap pix; | 141 | QPixmap pix; |
142 | QImage img = Resource::loadImage( "Rotation" ); | 142 | QImage img = Resource::loadImage( "Rotation" ); |
143 | if ( !img.isNull() ) | 143 | if ( !img.isNull() ) |
144 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); | 144 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); |
145 | return pix; | 145 | return pix; |
146 | } | 146 | } |
147 | 147 | ||
148 | QPopupMenu* RotateApplet::popup(QWidget*) const | 148 | QPopupMenu* RotateApplet::popup(QWidget*) const |
149 | { | 149 | { |
150 | return 0; | 150 | return 0; |
151 | } | 151 | } |
152 | 152 | ||
153 | void RotateApplet::rotateDefault() | 153 | void RotateApplet::rotateDefault() |
154 | { | 154 | { |
155 | int rot = ODevice::inst()->rotation(); | 155 | int rot = ODevice::inst()->rotation(); |
156 | 156 | ||
157 | switch (rot) | 157 | switch (rot) |
158 | { | 158 | { |
159 | case Rot0: rot=0; break; | 159 | case Rot0: rot=0; break; |
160 | case Rot90: rot=90; break; | 160 | case Rot90: rot=90; break; |
161 | case Rot180: rot=180; break; | 161 | case Rot180: rot=180; break; |
162 | case Rot270: rot=270; break; | 162 | case Rot270: rot=270; break; |
163 | default: rot=0; break; | 163 | default: rot=0; break; |
164 | } | 164 | } |
165 | 165 | ||
166 | Config cfg( "qpe" ); | 166 | Config cfg( "qpe" ); |
167 | cfg.setGroup( "Appearance" ); | 167 | cfg.setGroup( "Appearance" ); |
168 | 168 | ||
169 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); | 169 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); |
170 | 170 | ||
171 | if ( !rotateEnabled) return; | 171 | if ( !rotateEnabled) return; |
172 | 172 | ||
173 | // hide inputs methods before rotation | 173 | // hide inputs methods before rotation |
174 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 174 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
175 | 175 | ||
176 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 176 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
177 | env << rot; | 177 | env << rot; |
178 | 178 | ||
179 | m_flipped = false; | 179 | m_flipped = false; |
180 | 180 | ||
181 | } | 181 | } |
182 | void RotateApplet::activated() | 182 | void RotateApplet::activated() |
183 | { | 183 | { |
184 | int defaultRotation = QPEApplication::defaultRotation(); | 184 | int defaultRotation = QPEApplication::defaultRotation(); |
185 | int newRotation = defaultRotation; | 185 | int newRotation = defaultRotation; |
186 | 186 | ||
187 | Config cfg( "qpe" ); | 187 | Config cfg( "qpe" ); |
188 | cfg.setGroup( "Appearance" ); | 188 | cfg.setGroup( "Appearance" ); |
189 | 189 | ||
190 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 190 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
191 | ODirection rot = CW; | 191 | ODirection rot = CW; |
192 | 192 | ||
193 | if (rotDirection == -1) | 193 | if (rotDirection == -1) |
194 | { | 194 | { |
195 | rot = ODevice::inst()->direction(); | 195 | rot = ODevice::inst()->direction(); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | rot = (ODirection) rotDirection; | 199 | rot = (ODirection) rotDirection; |
200 | } | 200 | } |
201 | 201 | ||
202 | // hide inputs methods before rotation | 202 | // hide inputs methods before rotation |
203 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 203 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
204 | 204 | ||
205 | if ( m_flipped ) | 205 | if ( m_flipped ) |
206 | { | 206 | { |
207 | // if flipped, flip back to the original state, | 207 | // if flipped, flip back to the original state, |
208 | // regardless of rotation direction | 208 | // regardless of rotation direction |
209 | newRotation = defaultRotation; | 209 | newRotation = defaultRotation; |
210 | } | 210 | } |
211 | else | 211 | else |
212 | { | 212 | { |
213 | if ( rot == CCW ) | 213 | if ( rot == CCW ) |
214 | { | 214 | { |
215 | newRotation = ( defaultRotation + 90 ) % 360; | 215 | newRotation = ( defaultRotation + 90 ) % 360; |
216 | } | 216 | } |
217 | else if ( rot == CW ) | 217 | else if ( rot == CW ) |
218 | { | 218 | { |
219 | newRotation = ( defaultRotation + 270 ) % 360; | 219 | newRotation = ( defaultRotation + 270 ) % 360; |
220 | } | 220 | } |
221 | else if ( rot == Flip ) | 221 | else if ( rot == Flip ) |
222 | { | 222 | { |
223 | newRotation = ( defaultRotation + 180 ) % 360; | 223 | newRotation = ( defaultRotation + 180 ) % 360; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 227 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
228 | env << newRotation; | 228 | env << newRotation; |
229 | 229 | ||
230 | m_flipped = !m_flipped; | 230 | m_flipped = !m_flipped; |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 234 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
235 | { | 235 | { |
236 | *iface = 0; | 236 | *iface = 0; |
237 | if ( uuid == IID_QUnknown ) | 237 | if ( uuid == IID_QUnknown ) |
238 | *iface = this; | 238 | *iface = this; |
239 | else if ( uuid == IID_MenuApplet ) | 239 | else if ( uuid == IID_MenuApplet ) |
240 | *iface = this; | 240 | *iface = this; |
241 | else | 241 | else |
242 | return QS_FALSE; | 242 | return QS_FALSE; |
243 | 243 | ||
244 | if ( *iface ) | 244 | if ( *iface ) |
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 5d6bce4..20e1c9b 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -110,387 +110,387 @@ static char * snapshot_xpm[] = { | |||
110 | "B c #0A4DA0", | 110 | "B c #0A4DA0", |
111 | "C c #4E5242", | 111 | "C c #4E5242", |
112 | "D c #62362E", | 112 | "D c #62362E", |
113 | "E c #721A1A", | 113 | "E c #721A1A", |
114 | "F c #6E0A0A", | 114 | "F c #6E0A0A", |
115 | "G c #3E0E0E", | 115 | "G c #3E0E0E", |
116 | "H c #6AB85E", | 116 | "H c #6AB85E", |
117 | "I c #7E8ECA", | 117 | "I c #7E8ECA", |
118 | "J c #929CD4", | 118 | "J c #929CD4", |
119 | "K c #9EAECA", | 119 | "K c #9EAECA", |
120 | "L c #9EBEAE", | 120 | "L c #9EBEAE", |
121 | "M c #8EC26A", | 121 | "M c #8EC26A", |
122 | "N c #32A276", | 122 | "N c #32A276", |
123 | "O c #20518C", | 123 | "O c #20518C", |
124 | "P c #46566E", | 124 | "P c #46566E", |
125 | "Q c #614A51", | 125 | "Q c #614A51", |
126 | "R c #AE2A26", | 126 | "R c #AE2A26", |
127 | "S c #C41C1A", | 127 | "S c #C41C1A", |
128 | "T c #CE0A0A", | 128 | "T c #CE0A0A", |
129 | "U c #A60606", | 129 | "U c #A60606", |
130 | "V c #921616", | 130 | "V c #921616", |
131 | "W c #863735", | 131 | "W c #863735", |
132 | "X c #866A66", | 132 | "X c #866A66", |
133 | "Y c #9E9EA2", | 133 | "Y c #9E9EA2", |
134 | "Z c #1E5212", | 134 | "Z c #1E5212", |
135 | "` c #7EC652", | 135 | "` c #7EC652", |
136 | " .c #B2B2F2", | 136 | " .c #B2B2F2", |
137 | "..c #CACAF6", | 137 | "..c #CACAF6", |
138 | "+.c #AECEC6", | 138 | "+.c #AECEC6", |
139 | "@.c #92CE72", | 139 | "@.c #92CE72", |
140 | "#.c #42AA86", | 140 | "#.c #42AA86", |
141 | "$.c #365E96", | 141 | "$.c #365E96", |
142 | "%.c #B82420", | 142 | "%.c #B82420", |
143 | "&.c #E20E0E", | 143 | "&.c #E20E0E", |
144 | "*.c #EF0E0B", | 144 | "*.c #EF0E0B", |
145 | "=.c #566A86", | 145 | "=.c #566A86", |
146 | "-.c #92929A", | 146 | "-.c #92929A", |
147 | ";.c #16260E", | 147 | ";.c #16260E", |
148 | ">.c #2E571A", | 148 | ">.c #2E571A", |
149 | ",.c #7ED64E", | 149 | ",.c #7ED64E", |
150 | "'.c #9ECEB2", | 150 | "'.c #9ECEB2", |
151 | ").c #C6D5EF", | 151 | ").c #C6D5EF", |
152 | "!.c #E2E0FE", | 152 | "!.c #E2E0FE", |
153 | "~.c #A2DE8A", | 153 | "~.c #A2DE8A", |
154 | "{.c #4AAA5B", | 154 | "{.c #4AAA5B", |
155 | "].c #2A6AB2", | 155 | "].c #2A6AB2", |
156 | "^.c #9A7A6E", | 156 | "^.c #9A7A6E", |
157 | "/.c #D25A52", | 157 | "/.c #D25A52", |
158 | "(.c #F62626", | 158 | "(.c #F62626", |
159 | "_.c #FA0206", | 159 | "_.c #FA0206", |
160 | ":.c #DE1E16", | 160 | ":.c #DE1E16", |
161 | "<.c #B63A26", | 161 | "<.c #B63A26", |
162 | "[.c #865A2E", | 162 | "[.c #865A2E", |
163 | "}.c #26568E", | 163 | "}.c #26568E", |
164 | "|.c #435F7D", | 164 | "|.c #435F7D", |
165 | "1.c #7AE246", | 165 | "1.c #7AE246", |
166 | "2.c #96EA6E", | 166 | "2.c #96EA6E", |
167 | "3.c #BEEAAE", | 167 | "3.c #BEEAAE", |
168 | "4.c #D0EADC", | 168 | "4.c #D0EADC", |
169 | "5.c #B6CEFE", | 169 | "5.c #B6CEFE", |
170 | "6.c #9ADE8A", | 170 | "6.c #9ADE8A", |
171 | "7.c #2A609A", | 171 | "7.c #2A609A", |
172 | "8.c #7E623E", | 172 | "8.c #7E623E", |
173 | "9.c #CA7A72", | 173 | "9.c #CA7A72", |
174 | "0.c #F26E6E", | 174 | "0.c #F26E6E", |
175 | "a.c #FE5252", | 175 | "a.c #FE5252", |
176 | "b.c #FA3638", | 176 | "b.c #FA3638", |
177 | "c.c #DA2E28", | 177 | "c.c #DA2E28", |
178 | "d.c #9E3E3A", | 178 | "d.c #9E3E3A", |
179 | "e.c #3E7656", | 179 | "e.c #3E7656", |
180 | "f.c #76CB3A", | 180 | "f.c #76CB3A", |
181 | "g.c #90DE44", | 181 | "g.c #90DE44", |
182 | "h.c #A2EE6A", | 182 | "h.c #A2EE6A", |
183 | "i.c #9EEA9A", | 183 | "i.c #9EEA9A", |
184 | "j.c #92BEDE", | 184 | "j.c #92BEDE", |
185 | "k.c #7ADA7E", | 185 | "k.c #7ADA7E", |
186 | "l.c #5ECE52", | 186 | "l.c #5ECE52", |
187 | "m.c #6A5E52", | 187 | "m.c #6A5E52", |
188 | "n.c #A83238", | 188 | "n.c #A83238", |
189 | "o.c #FA5656", | 189 | "o.c #FA5656", |
190 | "p.c #F29A92", | 190 | "p.c #F29A92", |
191 | "q.c #D29E92", | 191 | "q.c #D29E92", |
192 | "r.c #8A7A62", | 192 | "r.c #8A7A62", |
193 | "s.c #05336B", | 193 | "s.c #05336B", |
194 | "t.c #59C631", | 194 | "t.c #59C631", |
195 | "u.c #8AD23A", | 195 | "u.c #8AD23A", |
196 | "v.c #66E242", | 196 | "v.c #66E242", |
197 | "w.c #1D6FC1", | 197 | "w.c #1D6FC1", |
198 | "x.c #E61212", | 198 | "x.c #E61212", |
199 | "y.c #CA261E", | 199 | "y.c #CA261E", |
200 | "z.c #5A763E", | 200 | "z.c #5A763E", |
201 | "A.c #1E6E9A", | 201 | "A.c #1E6E9A", |
202 | "B.c #023272", | 202 | "B.c #023272", |
203 | "C.c #329696", | 203 | "C.c #329696", |
204 | "D.c #2074B6", | 204 | "D.c #2074B6", |
205 | "E.c #3E4E76", | 205 | "E.c #3E4E76", |
206 | "F.c #5A525E", | 206 | "F.c #5A525E", |
207 | "G.c #425868", | 207 | "G.c #425868", |
208 | "H.c #04448E", | 208 | "H.c #04448E", |
209 | "I.c #28828A", | 209 | "I.c #28828A", |
210 | "J.c #2D8593", | 210 | "J.c #2D8593", |
211 | "K.c #12427A", | 211 | "K.c #12427A", |
212 | "L.c #054696", | 212 | "L.c #054696", |
213 | "M.c #042B5E", | 213 | "M.c #042B5E", |
214 | "N.c #134F95", | 214 | "N.c #134F95", |
215 | "O.c #1E6ABB", | 215 | "O.c #1E6ABB", |
216 | "P.c #1A5E96", | 216 | "P.c #1A5E96", |
217 | "Q.c #022E67", | 217 | "Q.c #022E67", |
218 | "R.c #0C3E7C", | 218 | "R.c #0C3E7C", |
219 | "S.c #023E8A", | 219 | "S.c #023E8A", |
220 | "T.c #021A3E", | 220 | "T.c #021A3E", |
221 | " ", | 221 | " ", |
222 | " ", | 222 | " ", |
223 | " ", | 223 | " ", |
224 | " . + @ # + ", | 224 | " . + @ # + ", |
225 | " $ # % & * * = - # $ ", | 225 | " $ # % & * * = - # $ ", |
226 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", | 226 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", |
227 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", | 227 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", |
228 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", | 228 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", |
229 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", | 229 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", |
230 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", | 230 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", |
231 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", | 231 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", |
232 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", | 232 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", |
233 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", | 233 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", |
234 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", | 234 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", |
235 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", | 235 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", |
236 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", | 236 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", |
237 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", | 237 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", |
238 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", | 238 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", |
239 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", | 239 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", |
240 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", | 240 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", |
241 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", | 241 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", |
242 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", | 242 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", |
243 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", | 243 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", |
244 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", | 244 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", |
245 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", | 245 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", |
246 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", | 246 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", |
247 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", | 247 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", |
248 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", | 248 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", |
249 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", | 249 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", |
250 | " | > e L.d L.H.e M.. ; ] ] ", | 250 | " | > e L.d L.H.e M.. ; ] ] ", |
251 | " > 9 . S.Q.. ; ] ", | 251 | " > 9 . S.Q.. ; ] ", |
252 | " T.; ] "}; | 252 | " T.; ] "}; |
253 | 253 | ||
254 | static const char *SCAP_hostname = "www.handhelds.org"; | 254 | static const char *SCAP_hostname = "www.handhelds.org"; |
255 | static const int SCAP_port = 80; | 255 | static const int SCAP_port = 80; |
256 | 256 | ||
257 | 257 | ||
258 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | 258 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) |
259 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 259 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
260 | { | 260 | { |
261 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 261 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
262 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); | 262 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); |
263 | QHBoxLayout *hbox; | 263 | QHBoxLayout *hbox; |
264 | 264 | ||
265 | hbox = new QHBoxLayout ( vbox ); | 265 | hbox = new QHBoxLayout ( vbox ); |
266 | 266 | ||
267 | QLabel *l = new QLabel ( tr( "Delay" ), this ); | 267 | QLabel *l = new QLabel ( tr( "Delay" ), this ); |
268 | hbox-> addWidget ( l ); | 268 | hbox-> addWidget ( l ); |
269 | 269 | ||
270 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); | 270 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); |
271 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 271 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
272 | delaySpin-> setSuffix ( tr( "sec" )); | 272 | delaySpin-> setSuffix ( tr( "sec" )); |
273 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); | 273 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); |
274 | delaySpin-> setValue ( 1 ); | 274 | delaySpin-> setValue ( 1 ); |
275 | hbox-> addWidget ( delaySpin ); | 275 | hbox-> addWidget ( delaySpin ); |
276 | 276 | ||
277 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); | 277 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); |
278 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); | 278 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); |
279 | vbox->addWidget( saveNamedCheck); | 279 | vbox->addWidget( saveNamedCheck); |
280 | 280 | ||
281 | vbox-> addSpacing ( 3 ); | 281 | vbox-> addSpacing ( 3 ); |
282 | 282 | ||
283 | l = new QLabel ( tr( "Save screenshot as..." ), this ); | 283 | l = new QLabel ( tr( "Save screenshot as..." ), this ); |
284 | vbox-> addWidget ( l, AlignCenter ); | 284 | vbox-> addWidget ( l, AlignCenter ); |
285 | 285 | ||
286 | hbox = new QHBoxLayout ( vbox ); | 286 | hbox = new QHBoxLayout ( vbox ); |
287 | 287 | ||
288 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); | 288 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); |
289 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); | 289 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); |
290 | hbox-> addWidget ( grabItButton ); | 290 | hbox-> addWidget ( grabItButton ); |
291 | 291 | ||
292 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); | 292 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); |
293 | scapButton ->setFocusPolicy( QWidget::TabFocus ); | 293 | scapButton ->setFocusPolicy( QWidget::TabFocus ); |
294 | hbox-> addWidget ( scapButton ); | 294 | hbox-> addWidget ( scapButton ); |
295 | 295 | ||
296 | setFixedSize ( sizeHint ( )); | 296 | setFixedSize ( sizeHint ( )); |
297 | setFocusPolicy ( QWidget::NoFocus ); | 297 | setFocusPolicy ( QWidget::NoFocus ); |
298 | 298 | ||
299 | 299 | ||
300 | grabTimer = new QTimer ( this, "grab timer"); | 300 | grabTimer = new QTimer ( this, "grab timer"); |
301 | 301 | ||
302 | connect ( grabTimer, SIGNAL( timeout ( )), this, SLOT( performGrab ( ))); | 302 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); |
303 | connect ( grabItButton, SIGNAL( clicked ( )), SLOT( slotGrab ( ))); | 303 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); |
304 | connect ( scapButton, SIGNAL( clicked ( )), SLOT( slotScap ( ))); | 304 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); |
305 | } | 305 | } |
306 | 306 | ||
307 | void ScreenshotControl::slotGrab() | 307 | void ScreenshotControl::slotGrab() |
308 | { | 308 | { |
309 | buttonPushed = 1; | 309 | buttonPushed = 1; |
310 | hide(); | 310 | hide(); |
311 | 311 | ||
312 | setFileName = FALSE; | 312 | setFileName = FALSE; |
313 | if ( saveNamedCheck->isChecked()) { | 313 | if ( saveNamedCheck->isChecked()) { |
314 | setFileName = TRUE; | 314 | setFileName = TRUE; |
315 | InputDialog *fileDlg; | 315 | InputDialog *fileDlg; |
316 | 316 | ||
317 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); | 317 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); |
318 | fileDlg->exec(); | 318 | fileDlg->exec(); |
319 | fileDlg->raise(); | 319 | fileDlg->raise(); |
320 | QString fileName, list; | 320 | QString fileName, list; |
321 | if ( fileDlg->result() == 1 ) { | 321 | if ( fileDlg->result() == 1 ) { |
322 | fileName = fileDlg->LineEdit1->text(); | 322 | fileName = fileDlg->LineEdit1->text(); |
323 | 323 | ||
324 | if (fileName.find("/", 0, TRUE) == -1) | 324 | if (fileName.find("/", 0, TRUE) == -1) |
325 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; | 325 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; |
326 | else | 326 | else |
327 | FileNamePath = fileName; | 327 | FileNamePath = fileName; |
328 | 328 | ||
329 | } | 329 | } |
330 | delete fileDlg; | 330 | delete fileDlg; |
331 | } | 331 | } |
332 | 332 | ||
333 | if ( delaySpin->value() ) | 333 | if ( delaySpin->value() ) |
334 | grabTimer->start( delaySpin->value() * 1000, true ); | 334 | grabTimer->start( delaySpin->value() * 1000, true ); |
335 | else | 335 | else |
336 | show(); | 336 | show(); |
337 | } | 337 | } |
338 | 338 | ||
339 | void ScreenshotControl::slotScap() | 339 | void ScreenshotControl::slotScap() |
340 | { | 340 | { |
341 | buttonPushed = 2; | 341 | buttonPushed = 2; |
342 | hide(); | 342 | hide(); |
343 | 343 | ||
344 | if ( delaySpin->value() ) | 344 | if ( delaySpin->value() ) |
345 | grabTimer->start( delaySpin->value() * 1000, true ); | 345 | grabTimer->start( delaySpin->value() * 1000, true ); |
346 | else | 346 | else |
347 | show(); | 347 | show(); |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void ScreenshotControl::savePixmap() | 351 | void ScreenshotControl::savePixmap() |
352 | { | 352 | { |
353 | DocLnk lnk; | 353 | DocLnk lnk; |
354 | QString fileName; | 354 | QString fileName; |
355 | 355 | ||
356 | if ( setFileName) { | 356 | if ( setFileName) { |
357 | fileName = FileNamePath; | 357 | fileName = FileNamePath; |
358 | //not sure why this is needed here, but it forgets fileName | 358 | //not sure why this is needed here, but it forgets fileName |
359 | // if this is below the braces | 359 | // if this is below the braces |
360 | 360 | ||
361 | if (fileName.right(3) != "png") | 361 | if (fileName.right(3) != "png") |
362 | fileName = fileName + ".png"; | 362 | fileName = fileName + ".png"; |
363 | lnk.setFile(fileName); //sets File property | 363 | lnk.setFile(fileName); //sets File property |
364 | qDebug("saving file " + fileName); | 364 | qDebug("saving file " + fileName); |
365 | snapshot.save( fileName, "PNG"); | 365 | snapshot.save( fileName, "PNG"); |
366 | QFileInfo fi( fileName); | 366 | QFileInfo fi( fileName); |
367 | lnk.setName( fi.fileName()); //sets file name | 367 | lnk.setName( fi.fileName()); //sets file name |
368 | 368 | ||
369 | if (!lnk.writeLink()) | 369 | if (!lnk.writeLink()) |
370 | qDebug("Writing doclink did not work"); | 370 | qDebug("Writing doclink did not work"); |
371 | } | 371 | } |
372 | else { | 372 | else { |
373 | 373 | ||
374 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 374 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
375 | fileName.replace(QRegExp("'"), ""); | 375 | fileName.replace(QRegExp("'"), ""); |
376 | fileName.replace(QRegExp(" "), "_"); | 376 | fileName.replace(QRegExp(" "), "_"); |
377 | fileName.replace(QRegExp(":"), "."); | 377 | fileName.replace(QRegExp(":"), "."); |
378 | fileName.replace(QRegExp(","), ""); | 378 | fileName.replace(QRegExp(","), ""); |
379 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 379 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
380 | 380 | ||
381 | if ( !QDir( dirName).exists() ) { | 381 | if ( !QDir( dirName).exists() ) { |
382 | qDebug("making dir " + dirName); | 382 | qDebug("making dir " + dirName); |
383 | QString msg = "mkdir -p " + dirName; | 383 | QString msg = "mkdir -p " + dirName; |
384 | system(msg.latin1()); | 384 | system(msg.latin1()); |
385 | } | 385 | } |
386 | fileName = dirName + fileName; | 386 | fileName = dirName + fileName; |
387 | if (fileName.right(3) != "png") | 387 | if (fileName.right(3) != "png") |
388 | fileName = fileName + ".png"; | 388 | fileName = fileName + ".png"; |
389 | lnk.setFile(fileName); //sets File property | 389 | lnk.setFile(fileName); //sets File property |
390 | qDebug("saving file " + fileName); | 390 | qDebug("saving file " + fileName); |
391 | snapshot.save( fileName, "PNG"); | 391 | snapshot.save( fileName, "PNG"); |
392 | QFileInfo fi( fileName); | 392 | QFileInfo fi( fileName); |
393 | lnk.setName( fi.fileName()); //sets file name | 393 | lnk.setName( fi.fileName()); //sets file name |
394 | 394 | ||
395 | if (!lnk.writeLink()) | 395 | if (!lnk.writeLink()) |
396 | qDebug("Writing doclink did not work"); | 396 | qDebug("Writing doclink did not work"); |
397 | 397 | ||
398 | } | 398 | } |
399 | 399 | ||
400 | QPEApplication::beep(); | 400 | QPEApplication::beep(); |
401 | } | 401 | } |
402 | 402 | ||
403 | void ScreenshotControl::performGrab() | 403 | void ScreenshotControl::performGrab() |
404 | { | 404 | { |
405 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 405 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
406 | 406 | ||
407 | if (buttonPushed == 1) { | 407 | if (buttonPushed == 1) { |
408 | qDebug("grabbing screen"); | 408 | qDebug("grabbing screen"); |
409 | grabTimer->stop(); | 409 | grabTimer->stop(); |
410 | show(); | 410 | show(); |
411 | qApp->processEvents(); | 411 | qApp->processEvents(); |
412 | savePixmap(); | 412 | savePixmap(); |
413 | } else { | 413 | } else { |
414 | grabTimer->stop(); | 414 | grabTimer->stop(); |
415 | 415 | ||
416 | struct sockaddr_in raddr; | 416 | struct sockaddr_in raddr; |
417 | struct hostent *rhost_info; | 417 | struct hostent *rhost_info; |
418 | int sock = -1; | 418 | int sock = -1; |
419 | bool ok = false; | 419 | bool ok = false; |
420 | 420 | ||
421 | QString displayEnv = getenv("QWS_DISPLAY"); | 421 | QString displayEnv = getenv("QWS_DISPLAY"); |
422 | qDebug(displayEnv); | 422 | qDebug(displayEnv); |
423 | 423 | ||
424 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 424 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
425 | 425 | ||
426 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 426 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
427 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 427 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
428 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 428 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
429 | raddr. sin_family = rhost_info-> h_addrtype; | 429 | raddr. sin_family = rhost_info-> h_addrtype; |
430 | raddr. sin_port = htons ( SCAP_port ); | 430 | raddr. sin_port = htons ( SCAP_port ); |
431 | 431 | ||
432 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 432 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
433 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 433 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
434 | 434 | ||
435 | QString header; | 435 | QString header; |
436 | 436 | ||
437 | QPixmap pix; | 437 | QPixmap pix; |
438 | 438 | ||
439 | QString SCAP_model=""; | 439 | QString SCAP_model=""; |
440 | #warning FIXME: model string should be filled with actual device model | 440 | #warning FIXME: model string should be filled with actual device model |
441 | if( snapshot.width() > 320) | 441 | if( snapshot.width() > 320) |
442 | SCAP_model ="Corgi"; | 442 | SCAP_model ="Corgi"; |
443 | 443 | ||
444 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 444 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
445 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 445 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
446 | } else | 446 | } else |
447 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 447 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
448 | 448 | ||
449 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 449 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
450 | 450 | ||
451 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 451 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
452 | "Content-length: %3\n" // 3: content length | 452 | "Content-length: %3\n" // 3: content length |
453 | "Content-Type: image/png\n" | 453 | "Content-Type: image/png\n" |
454 | "Host: %4\n" // 4: scap host | 454 | "Host: %4\n" // 4: scap host |
455 | "\n"; | 455 | "\n"; |
456 | 456 | ||
457 | 457 | ||
458 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 458 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
459 | qDebug(header); | 459 | qDebug(header); |
460 | 460 | ||
461 | if ( !pix.isNull() ) { | 461 | if ( !pix.isNull() ) { |
462 | const char *ascii = header.latin1( ); | 462 | const char *ascii = header.latin1( ); |
463 | uint ascii_len = ::strlen( ascii ); | 463 | uint ascii_len = ::strlen( ascii ); |
464 | ::write ( sock, ascii, ascii_len ); | 464 | ::write ( sock, ascii, ascii_len ); |
465 | ::write ( sock, img.bits(), img.numBytes() ); | 465 | ::write ( sock, img.bits(), img.numBytes() ); |
466 | 466 | ||
467 | ok = true; | 467 | ok = true; |
468 | } | 468 | } |
469 | } | 469 | } |
470 | ::close ( sock ); | 470 | ::close ( sock ); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | if ( ok ) { | 473 | if ( ok ) { |
474 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 474 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
475 | } else { | 475 | } else { |
476 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 476 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
477 | } | 477 | } |
478 | } else { | 478 | } else { |
479 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 479 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | 486 | ||
487 | //=========================================================================== | 487 | //=========================================================================== |
488 | 488 | ||
489 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 489 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
490 | : QWidget( parent, name ) | 490 | : QWidget( parent, name ) |
491 | { | 491 | { |
492 | setFixedWidth( AppLnk::smallIconSize()); | 492 | setFixedWidth( AppLnk::smallIconSize()); |
493 | 493 | ||
494 | QImage img = (const char **)snapshot_xpm; | 494 | QImage img = (const char **)snapshot_xpm; |
495 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 495 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
496 | m_icon.convertFromImage(img); | 496 | m_icon.convertFromImage(img); |
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 563d110..27f6015 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -24,386 +24,386 @@ extern "C" { | |||
24 | 24 | ||
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | 26 | ||
27 | typedef struct _waveheader { | 27 | typedef struct _waveheader { |
28 | u_long main_chunk; /* 'RIFF' */ | 28 | u_long main_chunk; /* 'RIFF' */ |
29 | u_long length; /* filelen */ | 29 | u_long length; /* filelen */ |
30 | u_long chunk_type; /* 'WAVE' */ | 30 | u_long chunk_type; /* 'WAVE' */ |
31 | u_long sub_chunk; /* 'fmt ' */ | 31 | u_long sub_chunk; /* 'fmt ' */ |
32 | u_long sc_len; /* length of sub_chunk, =16 | 32 | u_long sc_len; /* length of sub_chunk, =16 |
33 | (chunckSize) format len */ | 33 | (chunckSize) format len */ |
34 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 34 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
35 | 35 | ||
36 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 36 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
37 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 37 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
38 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 38 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
39 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ | 39 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ |
40 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 40 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
41 | 41 | ||
42 | u_long data_chunk; /* 'data' */ | 42 | u_long data_chunk; /* 'data' */ |
43 | 43 | ||
44 | u_long data_length;/* samplecount */ | 44 | u_long data_length;/* samplecount */ |
45 | } WaveHeader; | 45 | } WaveHeader; |
46 | 46 | ||
47 | #define RIFF 0x46464952 | 47 | #define RIFF 0x46464952 |
48 | #define WAVE 0x45564157 | 48 | #define WAVE 0x45564157 |
49 | #define FMT 0x20746D66 | 49 | #define FMT 0x20746D66 |
50 | #define DATA 0x61746164 | 50 | #define DATA 0x61746164 |
51 | #define PCM_CODE 1 | 51 | #define PCM_CODE 1 |
52 | #define WAVE_MONO 1 | 52 | #define WAVE_MONO 1 |
53 | #define WAVE_STEREO 2 | 53 | #define WAVE_STEREO 2 |
54 | 54 | ||
55 | struct adpcm_state encoder_state; | 55 | struct adpcm_state encoder_state; |
56 | //struct adpcm_state decoder_state; | 56 | //struct adpcm_state decoder_state; |
57 | 57 | ||
58 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) | 58 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) |
59 | #define WAVE_FORMAT_PCM (0x0001) | 59 | #define WAVE_FORMAT_PCM (0x0001) |
60 | 60 | ||
61 | 61 | ||
62 | #include "vmemo.h" | 62 | #include "vmemo.h" |
63 | 63 | ||
64 | #include <opie2/otaskbarapplet.h> | 64 | #include <opie2/otaskbarapplet.h> |
65 | #include <qpe/qpeapplication.h> | 65 | #include <qpe/qpeapplication.h> |
66 | #include <qpe/config.h> | 66 | #include <qpe/config.h> |
67 | 67 | ||
68 | #include <qpainter.h> | 68 | #include <qpainter.h> |
69 | #include <qmessagebox.h> | 69 | #include <qmessagebox.h> |
70 | 70 | ||
71 | int seq = 0; | 71 | int seq = 0; |
72 | 72 | ||
73 | /* XPM */ | 73 | /* XPM */ |
74 | static char * vmemo_xpm[] = { | 74 | static char * vmemo_xpm[] = { |
75 | "16 16 102 2", | 75 | "16 16 102 2", |
76 | " c None", | 76 | " c None", |
77 | ". c #60636A", | 77 | ". c #60636A", |
78 | "+ c #6E6E72", | 78 | "+ c #6E6E72", |
79 | "@ c #68696E", | 79 | "@ c #68696E", |
80 | "# c #4D525C", | 80 | "# c #4D525C", |
81 | "$ c #6B6C70", | 81 | "$ c #6B6C70", |
82 | "% c #E3E3E8", | 82 | "% c #E3E3E8", |
83 | "& c #EEEEF2", | 83 | "& c #EEEEF2", |
84 | "* c #EAEAEF", | 84 | "* c #EAEAEF", |
85 | "= c #CACAD0", | 85 | "= c #CACAD0", |
86 | "- c #474A51", | 86 | "- c #474A51", |
87 | "; c #171819", | 87 | "; c #171819", |
88 | "> c #9B9B9F", | 88 | "> c #9B9B9F", |
89 | ", c #EBEBF0", | 89 | ", c #EBEBF0", |
90 | "' c #F4F4F7", | 90 | "' c #F4F4F7", |
91 | ") c #F1F1F5", | 91 | ") c #F1F1F5", |
92 | "! c #DEDEE4", | 92 | "! c #DEDEE4", |
93 | "~ c #57575C", | 93 | "~ c #57575C", |
94 | "{ c #010101", | 94 | "{ c #010101", |
95 | "] c #A2A2A6", | 95 | "] c #A2A2A6", |
96 | "^ c #747477", | 96 | "^ c #747477", |
97 | "/ c #B5B5B8", | 97 | "/ c #B5B5B8", |
98 | "( c #AEAEB2", | 98 | "( c #AEAEB2", |
99 | "_ c #69696D", | 99 | "_ c #69696D", |
100 | ": c #525256", | 100 | ": c #525256", |
101 | "< c #181C24", | 101 | "< c #181C24", |
102 | "[ c #97979B", | 102 | "[ c #97979B", |
103 | "} c #A7A7AC", | 103 | "} c #A7A7AC", |
104 | "| c #B0B0B4", | 104 | "| c #B0B0B4", |
105 | "1 c #C8C8D1", | 105 | "1 c #C8C8D1", |
106 | "2 c #75757B", | 106 | "2 c #75757B", |
107 | "3 c #46464A", | 107 | "3 c #46464A", |
108 | "4 c #494A4F", | 108 | "4 c #494A4F", |
109 | "5 c #323234", | 109 | "5 c #323234", |
110 | "6 c #909095", | 110 | "6 c #909095", |
111 | "7 c #39393B", | 111 | "7 c #39393B", |
112 | "8 c #757578", | 112 | "8 c #757578", |
113 | "9 c #87878E", | 113 | "9 c #87878E", |
114 | "0 c #222224", | 114 | "0 c #222224", |
115 | "a c #414144", | 115 | "a c #414144", |
116 | "b c #6A6A6E", | 116 | "b c #6A6A6E", |
117 | "c c #020C16", | 117 | "c c #020C16", |
118 | "d c #6B6B6F", | 118 | "d c #6B6B6F", |
119 | "e c #68686D", | 119 | "e c #68686D", |
120 | "f c #5B5B60", | 120 | "f c #5B5B60", |
121 | "g c #8A8A8F", | 121 | "g c #8A8A8F", |
122 | "h c #6B6B6E", | 122 | "h c #6B6B6E", |
123 | "i c #ADADB2", | 123 | "i c #ADADB2", |
124 | "j c #828289", | 124 | "j c #828289", |
125 | "k c #3E3E41", | 125 | "k c #3E3E41", |
126 | "l c #CFCFD7", | 126 | "l c #CFCFD7", |
127 | "m c #4C4C50", | 127 | "m c #4C4C50", |
128 | "n c #000000", | 128 | "n c #000000", |
129 | "o c #66666A", | 129 | "o c #66666A", |
130 | "p c #505054", | 130 | "p c #505054", |
131 | "q c #838388", | 131 | "q c #838388", |
132 | "r c #A1A1A7", | 132 | "r c #A1A1A7", |
133 | "s c #A9A9AE", | 133 | "s c #A9A9AE", |
134 | "t c #A8A8B0", | 134 | "t c #A8A8B0", |
135 | "u c #5E5E63", | 135 | "u c #5E5E63", |
136 | "v c #3A3A3E", | 136 | "v c #3A3A3E", |
137 | "w c #BDBDC6", | 137 | "w c #BDBDC6", |
138 | "x c #59595E", | 138 | "x c #59595E", |
139 | "y c #76767C", | 139 | "y c #76767C", |
140 | "z c #373738", | 140 | "z c #373738", |
141 | "A c #717174", | 141 | "A c #717174", |
142 | "B c #727278", | 142 | "B c #727278", |
143 | "C c #1C1C1E", | 143 | "C c #1C1C1E", |
144 | "D c #3C3C3F", | 144 | "D c #3C3C3F", |
145 | "E c #ADADB6", | 145 | "E c #ADADB6", |
146 | "F c #54555A", | 146 | "F c #54555A", |
147 | "G c #8B8C94", | 147 | "G c #8B8C94", |
148 | "H c #5A5A5F", | 148 | "H c #5A5A5F", |
149 | "I c #BBBBC3", | 149 | "I c #BBBBC3", |
150 | "J c #C4C4CB", | 150 | "J c #C4C4CB", |
151 | "K c #909098", | 151 | "K c #909098", |
152 | "L c #737379", | 152 | "L c #737379", |
153 | "M c #343437", | 153 | "M c #343437", |
154 | "N c #8F8F98", | 154 | "N c #8F8F98", |
155 | "O c #000407", | 155 | "O c #000407", |
156 | "P c #2D3137", | 156 | "P c #2D3137", |
157 | "Q c #B0B1BC", | 157 | "Q c #B0B1BC", |
158 | "R c #3B3C40", | 158 | "R c #3B3C40", |
159 | "S c #6E6E74", | 159 | "S c #6E6E74", |
160 | "T c #95959C", | 160 | "T c #95959C", |
161 | "U c #74747A", | 161 | "U c #74747A", |
162 | "V c #1D1D1E", | 162 | "V c #1D1D1E", |
163 | "W c #91929A", | 163 | "W c #91929A", |
164 | "X c #42444A", | 164 | "X c #42444A", |
165 | "Y c #22282E", | 165 | "Y c #22282E", |
166 | "Z c #B0B2BC", | 166 | "Z c #B0B2BC", |
167 | "` c #898A90", | 167 | "` c #898A90", |
168 | " . c #65656A", | 168 | " . c #65656A", |
169 | ".. c #999AA2", | 169 | ".. c #999AA2", |
170 | "+. c #52535A", | 170 | "+. c #52535A", |
171 | "@. c #151B21", | 171 | "@. c #151B21", |
172 | "#. c #515257", | 172 | "#. c #515257", |
173 | "$. c #B5B5BE", | 173 | "$. c #B5B5BE", |
174 | "%. c #616167", | 174 | "%. c #616167", |
175 | "&. c #1A1D22", | 175 | "&. c #1A1D22", |
176 | "*. c #000713", | 176 | "*. c #000713", |
177 | "=. c #1F1F21", | 177 | "=. c #1F1F21", |
178 | " ", | 178 | " ", |
179 | " . + @ # ", | 179 | " . + @ # ", |
180 | " $ % & * = - ", | 180 | " $ % & * = - ", |
181 | " ; > , ' ) ! ~ ", | 181 | " ; > , ' ) ! ~ ", |
182 | " { ] ^ / ( _ : ", | 182 | " { ] ^ / ( _ : ", |
183 | " < [ } | 1 2 3 ", | 183 | " < [ } | 1 2 3 ", |
184 | " 4 5 6 7 8 9 0 a b c ", | 184 | " 4 5 6 7 8 9 0 a b c ", |
185 | " d e f g h i j 3 k l m n ", | 185 | " d e f g h i j 3 k l m n ", |
186 | " o p q r s t u v w n ", | 186 | " o p q r s t u v w n ", |
187 | " o x y z A B C D E n ", | 187 | " o x y z A B C D E n ", |
188 | " F G H I J K L M N O ", | 188 | " F G H I J K L M N O ", |
189 | " P Q R S T U V W X ", | 189 | " P Q R S T U V W X ", |
190 | " Y Z ` b ...+. ", | 190 | " Y Z ` b ...+. ", |
191 | " @.#.$.%.&. ", | 191 | " @.#.$.%.&. ", |
192 | " *.B =. ", | 192 | " *.B =. ", |
193 | " n n n n n n n n n "}; | 193 | " n n n n n n n n n "}; |
194 | 194 | ||
195 | 195 | ||
196 | VMemo::VMemo( QWidget *parent, const char *_name ) | 196 | VMemo::VMemo( QWidget *parent, const char *_name ) |
197 | : QWidget( parent, _name ) { | 197 | : QWidget( parent, _name ) { |
198 | setFixedHeight( 18 ); | 198 | setFixedHeight( 18 ); |
199 | setFixedWidth( 14 ); | 199 | setFixedWidth( 14 ); |
200 | 200 | ||
201 | t_timer = new QTimer( this ); | 201 | t_timer = new QTimer( this ); |
202 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 202 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
203 | 203 | ||
204 | Config vmCfg("Vmemo"); | 204 | Config vmCfg("Vmemo"); |
205 | vmCfg.setGroup("Defaults"); | 205 | vmCfg.setGroup("Defaults"); |
206 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 206 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
207 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 207 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
208 | 208 | ||
209 | qDebug("toggleKey %d", toggleKey); | 209 | qDebug("toggleKey %d", toggleKey); |
210 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 210 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
211 | systemZaurus=TRUE; | 211 | systemZaurus=TRUE; |
212 | else | 212 | else |
213 | systemZaurus=FALSE; | 213 | systemZaurus=FALSE; |
214 | 214 | ||
215 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 215 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
216 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 216 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
217 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 217 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
218 | 218 | ||
219 | if( toggleKey != -1 ) { | 219 | if( toggleKey != -1 ) { |
220 | // keyRegister(key, channel, message) | 220 | // keyRegister(key, channel, message) |
221 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 221 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
222 | // e << 4096; // Key_Escape | 222 | // e << 4096; // Key_Escape |
223 | // e << Key_F5; //4148 | 223 | // e << Key_F5; //4148 |
224 | e << toggleKey; | 224 | e << toggleKey; |
225 | e << QString("QPE/VMemo"); | 225 | e << QString("QPE/VMemo"); |
226 | e << QString("toggleRecord()"); | 226 | e << QString("toggleRecord()"); |
227 | } | 227 | } |
228 | if(toggleKey == 1) | 228 | if(toggleKey == 1) |
229 | usingIcon=TRUE; | 229 | usingIcon=TRUE; |
230 | else | 230 | else |
231 | usingIcon=FALSE; | 231 | usingIcon=FALSE; |
232 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 232 | if( vmCfg.readNumEntry("hideIcon",0) == 1) |
233 | hide(); | 233 | hide(); |
234 | recording = FALSE; | 234 | recording = FALSE; |
235 | // } | 235 | // } |
236 | } | 236 | } |
237 | 237 | ||
238 | VMemo::~VMemo() { | 238 | VMemo::~VMemo() { |
239 | } | 239 | } |
240 | 240 | ||
241 | int VMemo::position() | 241 | int VMemo::position() |
242 | { | 242 | { |
243 | return 6; | 243 | return 6; |
244 | } | 244 | } |
245 | 245 | ||
246 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 246 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
247 | qDebug("receive"); | 247 | qDebug("receive"); |
248 | QDataStream stream( data, IO_ReadOnly ); | 248 | QDataStream stream( data, IO_ReadOnly ); |
249 | 249 | ||
250 | if (msg == "toggleRecord()") { | 250 | if (msg == "toggleRecord()") { |
251 | if (recording) { | 251 | if (recording) { |
252 | fromToggle = TRUE; | 252 | fromToggle = TRUE; |
253 | stopRecording(); | 253 | stopRecording(); |
254 | } else { | 254 | } else { |
255 | fromToggle = TRUE; | 255 | fromToggle = TRUE; |
256 | startRecording(); | 256 | startRecording(); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | void VMemo::paintEvent( QPaintEvent* ) { | 261 | void VMemo::paintEvent( QPaintEvent* ) { |
262 | QPainter p(this); | 262 | QPainter p(this); |
263 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 263 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
264 | } | 264 | } |
265 | 265 | ||
266 | void VMemo::mousePressEvent( QMouseEvent * me) { | 266 | void VMemo::mousePressEvent( QMouseEvent * me) { |
267 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 267 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
268 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 268 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
269 | 269 | ||
270 | // if (!systemZaurus && me != NULL) | 270 | // if (!systemZaurus && me != NULL) |
271 | // return; | 271 | // return; |
272 | // } | 272 | // } |
273 | 273 | ||
274 | if(!recording) | 274 | if(!recording) |
275 | startRecording(); | 275 | startRecording(); |
276 | else | 276 | else |
277 | stopRecording(); | 277 | stopRecording(); |
278 | } | 278 | } |
279 | 279 | ||
280 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 280 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
281 | } | 281 | } |
282 | 282 | ||
283 | bool VMemo::startRecording() { | 283 | bool VMemo::startRecording() { |
284 | Config config( "Vmemo" ); | 284 | Config config( "Vmemo" ); |
285 | config.setGroup( "System" ); | 285 | config.setGroup( "System" ); |
286 | 286 | ||
287 | useAlerts = config.readBoolEntry("Alert",1); | 287 | useAlerts = config.readBoolEntry("Alert",1); |
288 | if(useAlerts) { | 288 | if(useAlerts) { |
289 | 289 | ||
290 | msgLabel = new QLabel( 0, "alertLabel" ); | 290 | msgLabel = new QLabel( 0, "alertLabel" ); |
291 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 291 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
292 | msgLabel->show(); | 292 | msgLabel->show(); |
293 | } | 293 | } |
294 | 294 | ||
295 | qDebug("Start recording engines"); | 295 | qDebug("Start recording engines"); |
296 | recording = TRUE; | 296 | recording = TRUE; |
297 | 297 | ||
298 | if (openDSP() == -1) { | 298 | if (openDSP() == -1) { |
299 | recording = FALSE; | 299 | recording = FALSE; |
300 | return FALSE; | 300 | return FALSE; |
301 | } | 301 | } |
302 | 302 | ||
303 | config.setGroup("Defaults"); | 303 | config.setGroup("Defaults"); |
304 | 304 | ||
305 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 305 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
306 | date.replace(QRegExp("'"),""); | 306 | date.replace(QRegExp("'"),""); |
307 | date.replace(QRegExp(" "),"_"); | 307 | date.replace(QRegExp(" "),"_"); |
308 | date.replace(QRegExp(":"),"."); | 308 | date.replace(QRegExp(":"),"."); |
309 | date.replace(QRegExp(","),""); | 309 | date.replace(QRegExp(","),""); |
310 | 310 | ||
311 | QString fName; | 311 | QString fName; |
312 | config.setGroup( "System" ); | 312 | config.setGroup( "System" ); |
313 | fName = QPEApplication::documentDir() ; | 313 | fName = QPEApplication::documentDir() ; |
314 | fileName = config.readEntry("RecLocation", fName); | 314 | fileName = config.readEntry("RecLocation", fName); |
315 | 315 | ||
316 | int s; | 316 | int s; |
317 | s=fileName.find(':'); | 317 | s=fileName.find(':'); |
318 | if(s) | 318 | if(s) |
319 | fileName=fileName.right(fileName.length()-s-2); | 319 | fileName=fileName.right(fileName.length()-s-2); |
320 | qDebug("pathname will be "+fileName); | 320 | qDebug("pathname will be "+fileName); |
321 | 321 | ||
322 | if( fileName.left(1).find('/') == -1) | 322 | if( fileName.left(1).find('/') == -1) |
323 | fileName="/"+fileName; | 323 | fileName="/"+fileName; |
324 | if( fileName.right(1).find('/') == -1) | 324 | if( fileName.right(1).find('/') == -1) |
325 | fileName+="/"; | 325 | fileName+="/"; |
326 | fName = "vm_"+ date+ ".wav"; | 326 | fName = "vm_"+ date+ ".wav"; |
327 | 327 | ||
328 | fileName+=fName; | 328 | fileName+=fName; |
329 | qDebug("filename is "+fileName); | 329 | qDebug("filename is "+fileName); |
330 | // open tmp file here | 330 | // open tmp file here |
331 | char *pointer; | 331 | char *pointer; |
332 | pointer=tmpnam(NULL); | 332 | pointer=tmpnam(NULL); |
333 | qDebug("Opening tmp file %s",pointer); | 333 | qDebug("Opening tmp file %s",pointer); |
334 | 334 | ||
335 | if(openWAV(pointer ) == -1) { | 335 | if(openWAV(pointer ) == -1) { |
336 | 336 | ||
337 | QString err("Could not open the temp file\n"); | 337 | QString err("Could not open the temp file\n"); |
338 | err += fileName; | 338 | err += fileName; |
339 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 339 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
340 | ::close(dsp); | 340 | ::close(dsp); |
341 | return FALSE; | 341 | return FALSE; |
342 | } | 342 | } |
343 | if( record() ) { | 343 | if( record() ) { |
344 | 344 | ||
345 | QString cmd; | 345 | QString cmd; |
346 | if( fileName.find(".wav",0,TRUE) == -1) | 346 | if( fileName.find(".wav",0,TRUE) == -1) |
347 | fileName += ".wav"; | 347 | fileName += ".wav"; |
348 | 348 | ||
349 | cmd.sprintf("mv %s "+fileName, pointer); | 349 | cmd.sprintf("mv %s "+fileName, pointer); |
350 | // move tmp file to regular file here | 350 | // move tmp file to regular file here |
351 | 351 | ||
352 | system(cmd.latin1()); | 352 | system(cmd.latin1()); |
353 | 353 | ||
354 | QArray<int> cats(1); | 354 | QArray<int> cats(1); |
355 | cats[0] = config.readNumEntry("Category", 0); | 355 | cats[0] = config.readNumEntry("Category", 0); |
356 | 356 | ||
357 | QString dlName("vm_"); | 357 | QString dlName("vm_"); |
358 | dlName += date; | 358 | dlName += date; |
359 | DocLnk l; | 359 | DocLnk l; |
360 | l.setFile(fileName); | 360 | l.setFile(fileName); |
361 | l.setName(dlName); | 361 | l.setName(dlName); |
362 | l.setType("audio/x-wav"); | 362 | l.setType("audio/x-wav"); |
363 | l.setCategories(cats); | 363 | l.setCategories(cats); |
364 | l.writeLink(); | 364 | l.writeLink(); |
365 | return TRUE; | 365 | return TRUE; |
366 | } else | 366 | } else |
367 | return FALSE; | 367 | return FALSE; |
368 | 368 | ||
369 | } | 369 | } |
370 | 370 | ||
371 | void VMemo::stopRecording() { | 371 | void VMemo::stopRecording() { |
372 | show(); | 372 | show(); |
373 | qDebug("Stopped recording"); | 373 | qDebug("Stopped recording"); |
374 | recording = FALSE; | 374 | recording = FALSE; |
375 | if(useAlerts) { | 375 | if(useAlerts) { |
376 | msgLabel->close(); | 376 | msgLabel->close(); |
377 | msgLabel=0; | 377 | msgLabel=0; |
378 | delete msgLabel; | 378 | delete msgLabel; |
379 | } | 379 | } |
380 | t_timer->stop(); | 380 | t_timer->stop(); |
381 | Config cfg("Vmemo"); | 381 | Config cfg("Vmemo"); |
382 | cfg.setGroup("Defaults"); | 382 | cfg.setGroup("Defaults"); |
383 | if( cfg.readNumEntry("hideIcon",0) == 1 ) | 383 | if( cfg.readNumEntry("hideIcon",0) == 1 ) |
384 | hide(); | 384 | hide(); |
385 | } | 385 | } |
386 | 386 | ||
387 | int VMemo::openDSP() { | 387 | int VMemo::openDSP() { |
388 | Config cfg("Vmemo"); | 388 | Config cfg("Vmemo"); |
389 | cfg.setGroup("Record"); | 389 | cfg.setGroup("Record"); |
390 | 390 | ||
391 | speed = cfg.readNumEntry("SampleRate", 22050); | 391 | speed = cfg.readNumEntry("SampleRate", 22050); |
392 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 392 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
393 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 393 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
394 | format = AFMT_S16_LE; | 394 | format = AFMT_S16_LE; |
395 | resolution = 16; | 395 | resolution = 16; |
396 | } else { | 396 | } else { |
397 | format = AFMT_U8; | 397 | format = AFMT_U8; |
398 | resolution = 8; | 398 | resolution = 8; |
399 | } | 399 | } |
400 | 400 | ||
401 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 401 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
402 | 402 | ||
403 | if(systemZaurus) { | 403 | if(systemZaurus) { |
404 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 404 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
405 | channels=1; //zaurus has one input channel | 405 | channels=1; //zaurus has one input channel |
406 | } else { | 406 | } else { |
407 | dsp = open("/dev/dsp", O_RDONLY); | 407 | dsp = open("/dev/dsp", O_RDONLY); |
408 | } | 408 | } |
409 | 409 | ||
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 8fd88f6..942cebb 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -219,565 +219,565 @@ static const char * alarm_xpm[] = { | |||
219 | " +2&3+$1*44 ", | 219 | " +2&3+$1*44 ", |
220 | " (%_}_+/$:>/4 ", | 220 | " (%_}_+/$:>/4 ", |
221 | " 4%_}3+#;>:*4 ", | 221 | " 4%_}3+#;>:*4 ", |
222 | " 4%_}&+#[1$/4 ", | 222 | " 4%_}&+#[1$/4 ", |
223 | " 4%_,2')[~~>4 ", | 223 | " 4%_,2')[~~>4 ", |
224 | " 4%33'4#@~1>4 ", | 224 | " 4%33'4#@~1>4 ", |
225 | " 4%3344#[:>/4 ", | 225 | " 4%3344#[:>/4 ", |
226 | " 42&_3'4#@>:*44 ", | 226 | " 42&_3'4#@>:*44 ", |
227 | " 42|}}3'4#[;$)$44 ", | 227 | " 42|}}3'4#[;$)$44 ", |
228 | "444{]]2^~~:!!#.@##/ ", | 228 | "444{]]2^~~:!!#.@##/ ", |
229 | "4444-%*:==!!=...../ ", | 229 | "4444-%*:==!!=...../ ", |
230 | " /:[.. ", | 230 | " /:[.. ", |
231 | " /@. ", | 231 | " /@. ", |
232 | " "}; | 232 | " "}; |
233 | 233 | ||
234 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 234 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
235 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 235 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
236 | { | 236 | { |
237 | m_icon = icon; | 237 | m_icon = icon; |
238 | 238 | ||
239 | bool has_wav_alarm = true; | 239 | bool has_wav_alarm = true; |
240 | bool has_bass = true; | 240 | bool has_bass = true; |
241 | bool has_treble = true; | 241 | bool has_treble = true; |
242 | 242 | ||
243 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually | 243 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
244 | case Model_Zaurus_SL5000: | 244 | case Model_Zaurus_SL5000: |
245 | has_wav_alarm = false; //poor guys probably feeling left out... | 245 | has_wav_alarm = false; //poor guys probably feeling left out... |
246 | break; | 246 | break; |
247 | default: | 247 | default: |
248 | break; | 248 | break; |
249 | } | 249 | } |
250 | 250 | ||
251 | if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 251 | if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
252 | has_bass = false; | 252 | has_bass = false; |
253 | has_treble = false; | 253 | has_treble = false; |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 257 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
258 | 258 | ||
259 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 259 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
260 | grid-> setSpacing ( 4 ); | 260 | grid-> setSpacing ( 4 ); |
261 | grid-> setMargin ( 6 ); | 261 | grid-> setMargin ( 6 ); |
262 | 262 | ||
263 | QVBoxLayout *vbox; | 263 | QVBoxLayout *vbox; |
264 | QLabel *l; | 264 | QLabel *l; |
265 | 265 | ||
266 | vbox = new QVBoxLayout ( ); | 266 | vbox = new QVBoxLayout ( ); |
267 | vbox-> setSpacing ( 4 ); | 267 | vbox-> setSpacing ( 4 ); |
268 | grid-> addLayout ( vbox, 1, 0 ); | 268 | grid-> addLayout ( vbox, 1, 0 ); |
269 | 269 | ||
270 | upButton = new QPushButton ( this ); | 270 | upButton = new QPushButton ( this ); |
271 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 271 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
272 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | 272 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); |
273 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 273 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
274 | 274 | ||
275 | vbox-> addWidget ( upButton ); | 275 | vbox-> addWidget ( upButton ); |
276 | 276 | ||
277 | downButton = new QPushButton ( this ); | 277 | downButton = new QPushButton ( this ); |
278 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 278 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
279 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | 279 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); |
280 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 280 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
281 | 281 | ||
282 | vbox-> addWidget ( downButton ); | 282 | vbox-> addWidget ( downButton ); |
283 | 283 | ||
284 | volSlider = new QSlider ( this ); | 284 | volSlider = new QSlider ( this ); |
285 | volSlider-> setRange ( 0, 100 ); | 285 | volSlider-> setRange ( 0, 100 ); |
286 | volSlider-> setTickmarks ( QSlider::Both ); | 286 | volSlider-> setTickmarks ( QSlider::Both ); |
287 | volSlider-> setTickInterval ( 20 ); | 287 | volSlider-> setTickInterval ( 20 ); |
288 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 288 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
289 | 289 | ||
290 | l = new QLabel ( this ); | 290 | l = new QLabel ( this ); |
291 | l-> setPixmap ( QPixmap ( vol_xpm )); | 291 | l-> setPixmap ( QPixmap ( vol_xpm )); |
292 | 292 | ||
293 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 293 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
294 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 294 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
295 | 295 | ||
296 | volLed = new OLedBox ( green, this ); | 296 | volLed = new OLedBox ( green, this ); |
297 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 297 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
298 | volLed-> setFixedSize ( 16, 16 ); | 298 | volLed-> setFixedSize ( 16, 16 ); |
299 | 299 | ||
300 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 300 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
301 | 301 | ||
302 | QVBox *basstrebleBox = new QVBox( this ); | 302 | QVBox *basstrebleBox = new QVBox( this ); |
303 | 303 | ||
304 | trebleSlider = new QSlider ( basstrebleBox ); | 304 | trebleSlider = new QSlider ( basstrebleBox ); |
305 | trebleSlider-> setRange ( 0, 100 ); | 305 | trebleSlider-> setRange ( 0, 100 ); |
306 | trebleSlider-> setTickmarks ( QSlider::Both ); | 306 | trebleSlider-> setTickmarks ( QSlider::Both ); |
307 | trebleSlider-> setTickInterval ( 20 ); | 307 | trebleSlider-> setTickInterval ( 20 ); |
308 | trebleSlider->setMaximumHeight( 40 ); | 308 | trebleSlider->setMaximumHeight( 40 ); |
309 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); | 309 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); |
310 | 310 | ||
311 | bassSlider = new QSlider ( basstrebleBox ); | 311 | bassSlider = new QSlider ( basstrebleBox ); |
312 | bassSlider-> setRange ( 0, 100 ); | 312 | bassSlider-> setRange ( 0, 100 ); |
313 | bassSlider-> setTickmarks ( QSlider::Both ); | 313 | bassSlider-> setTickmarks ( QSlider::Both ); |
314 | bassSlider-> setTickInterval ( 20 ); | 314 | bassSlider-> setTickInterval ( 20 ); |
315 | bassSlider->setMaximumHeight( 40 ); | 315 | bassSlider->setMaximumHeight( 40 ); |
316 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); | 316 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); |
317 | 317 | ||
318 | QLabel *bassLabel = new QLabel ( this ); | 318 | QLabel *bassLabel = new QLabel ( this ); |
319 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); | 319 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); |
320 | 320 | ||
321 | QLabel *trebleLabel = new QLabel( this ); | 321 | QLabel *trebleLabel = new QLabel( this ); |
322 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); | 322 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); |
323 | 323 | ||
324 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); | 324 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); |
325 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); | 325 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); |
326 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); | 326 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); |
327 | 327 | ||
328 | if ( !has_bass ) { | 328 | if ( !has_bass ) { |
329 | bassSlider->hide(); | 329 | bassSlider->hide(); |
330 | bassLabel->hide(); | 330 | bassLabel->hide(); |
331 | } | 331 | } |
332 | 332 | ||
333 | if ( !has_treble ) { | 333 | if ( !has_treble ) { |
334 | trebleSlider->hide(); | 334 | trebleSlider->hide(); |
335 | trebleLabel->hide(); | 335 | trebleLabel->hide(); |
336 | } | 336 | } |
337 | 337 | ||
338 | micSlider = new QSlider ( this ); | 338 | micSlider = new QSlider ( this ); |
339 | micSlider-> setRange ( 0, 100 ); | 339 | micSlider-> setRange ( 0, 100 ); |
340 | micSlider-> setTickmarks ( QSlider::Both ); | 340 | micSlider-> setTickmarks ( QSlider::Both ); |
341 | micSlider-> setTickInterval ( 20 ); | 341 | micSlider-> setTickInterval ( 20 ); |
342 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 342 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
343 | 343 | ||
344 | l = new QLabel ( this ); | 344 | l = new QLabel ( this ); |
345 | l-> setPixmap ( QPixmap ( mic_xpm )); | 345 | l-> setPixmap ( QPixmap ( mic_xpm )); |
346 | 346 | ||
347 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 347 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
348 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 348 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
349 | 349 | ||
350 | micLed = new OLedBox ( red, this ); | 350 | micLed = new OLedBox ( red, this ); |
351 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 351 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
352 | micLed-> setFixedSize ( 16, 16 ); | 352 | micLed-> setFixedSize ( 16, 16 ); |
353 | 353 | ||
354 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 354 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
355 | 355 | ||
356 | alarmSlider = new QSlider ( this ); | 356 | alarmSlider = new QSlider ( this ); |
357 | alarmSlider-> setRange ( 0, 100 ); | 357 | alarmSlider-> setRange ( 0, 100 ); |
358 | alarmSlider-> setTickmarks ( QSlider::Both ); | 358 | alarmSlider-> setTickmarks ( QSlider::Both ); |
359 | alarmSlider-> setTickInterval ( 20 ); | 359 | alarmSlider-> setTickInterval ( 20 ); |
360 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 360 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
361 | 361 | ||
362 | QLabel *alarmLabel = new QLabel ( this ); | 362 | QLabel *alarmLabel = new QLabel ( this ); |
363 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 363 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
364 | 364 | ||
365 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 365 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
366 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 366 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
367 | 367 | ||
368 | alarmLed = new OLedBox ( yellow, this ); | 368 | alarmLed = new OLedBox ( yellow, this ); |
369 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 369 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
370 | alarmLed-> setFixedSize ( 16, 16 ); | 370 | alarmLed-> setFixedSize ( 16, 16 ); |
371 | 371 | ||
372 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 372 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
373 | 373 | ||
374 | if ( !has_wav_alarm ) { | 374 | if ( !has_wav_alarm ) { |
375 | alarmSlider-> hide ( ); | 375 | alarmSlider-> hide ( ); |
376 | alarmLabel-> hide ( ); | 376 | alarmLabel-> hide ( ); |
377 | alarmLed-> hide ( ); | 377 | alarmLed-> hide ( ); |
378 | } | 378 | } |
379 | 379 | ||
380 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); | 380 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
381 | 381 | ||
382 | vbox = new QVBoxLayout ( ); | 382 | vbox = new QVBoxLayout ( ); |
383 | vbox-> setSpacing ( 4 ); | 383 | vbox-> setSpacing ( 4 ); |
384 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); | 384 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
385 | 385 | ||
386 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 386 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
387 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 387 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
388 | 388 | ||
389 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 389 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
390 | 390 | ||
391 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 391 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
392 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 392 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
393 | 393 | ||
394 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 394 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
395 | 395 | ||
396 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 396 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
397 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 397 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
398 | 398 | ||
399 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 399 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
400 | 400 | ||
401 | if ( has_wav_alarm ) { | 401 | if ( has_wav_alarm ) { |
402 | alarmBox-> hide ( ); | 402 | alarmBox-> hide ( ); |
403 | } | 403 | } |
404 | 404 | ||
405 | vbox-> addStretch ( 100 ); | 405 | vbox-> addStretch ( 100 ); |
406 | 406 | ||
407 | setFixedSize ( sizeHint ( )); | 407 | setFixedSize ( sizeHint ( )); |
408 | setFocusPolicy ( QWidget::NoFocus ); | 408 | setFocusPolicy ( QWidget::NoFocus ); |
409 | 409 | ||
410 | rateTimer = new QTimer( this ); | 410 | rateTimer = new QTimer( this ); |
411 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); | 411 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); |
412 | 412 | ||
413 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 413 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
414 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 414 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
415 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 415 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
416 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 416 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
417 | 417 | ||
418 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); | 418 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); |
419 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); | 419 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); |
420 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); | 420 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); |
421 | connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); | 421 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); |
422 | connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); | 422 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); |
423 | 423 | ||
424 | 424 | ||
425 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); | 425 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); |
426 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); | 426 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); |
427 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 427 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
428 | 428 | ||
429 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 429 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
430 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); | 430 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); |
431 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); | 431 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); |
432 | 432 | ||
433 | // initialize variables | 433 | // initialize variables |
434 | 434 | ||
435 | readConfig ( true ); | 435 | readConfig ( true ); |
436 | 436 | ||
437 | // initialize the config file, in case some entries are missing | 437 | // initialize the config file, in case some entries are missing |
438 | 438 | ||
439 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 439 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
440 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | 440 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); |
441 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | 441 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); |
442 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 442 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
443 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 443 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
444 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 444 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
445 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 445 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
446 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 446 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
447 | 447 | ||
448 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 448 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
449 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 449 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
450 | } | 450 | } |
451 | 451 | ||
452 | bool VolumeControl::volMuted ( ) const | 452 | bool VolumeControl::volMuted ( ) const |
453 | { | 453 | { |
454 | return m_vol_muted; | 454 | return m_vol_muted; |
455 | } | 455 | } |
456 | 456 | ||
457 | int VolumeControl::volPercent ( ) const | 457 | int VolumeControl::volPercent ( ) const |
458 | { | 458 | { |
459 | return m_vol_percent; | 459 | return m_vol_percent; |
460 | } | 460 | } |
461 | 461 | ||
462 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 462 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
463 | { | 463 | { |
464 | switch ( e-> key ( )) { | 464 | switch ( e-> key ( )) { |
465 | case Key_Up: | 465 | case Key_Up: |
466 | volSlider-> subtractStep ( ); | 466 | volSlider-> subtractStep ( ); |
467 | break; | 467 | break; |
468 | case Key_Down: | 468 | case Key_Down: |
469 | volSlider-> addStep ( ); | 469 | volSlider-> addStep ( ); |
470 | break; | 470 | break; |
471 | case Key_Space: | 471 | case Key_Space: |
472 | volLed-> toggle ( ); | 472 | volLed-> toggle ( ); |
473 | break; | 473 | break; |
474 | case Key_Escape: | 474 | case Key_Escape: |
475 | hide ( ); | 475 | hide ( ); |
476 | break; | 476 | break; |
477 | } | 477 | } |
478 | } | 478 | } |
479 | 479 | ||
480 | void VolumeControl::buttonChanged ( ) | 480 | void VolumeControl::buttonChanged ( ) |
481 | { | 481 | { |
482 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 482 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
483 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 483 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
484 | // called at all when a button is pressed for a time | 484 | // called at all when a button is pressed for a time |
485 | // shorter than RATE_TIMER_INTERVAL. | 485 | // shorter than RATE_TIMER_INTERVAL. |
486 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 486 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
487 | } | 487 | } |
488 | else | 488 | else |
489 | rateTimer-> stop ( ); | 489 | rateTimer-> stop ( ); |
490 | } | 490 | } |
491 | 491 | ||
492 | void VolumeControl::rateTimerDone ( ) | 492 | void VolumeControl::rateTimerDone ( ) |
493 | { | 493 | { |
494 | if ( upButton-> isDown ( )) | 494 | if ( upButton-> isDown ( )) |
495 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 495 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
496 | else // if ( downButton-> isDown ( )) | 496 | else // if ( downButton-> isDown ( )) |
497 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 497 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void VolumeControl::show ( bool /*showMic*/ ) | 500 | void VolumeControl::show ( bool /*showMic*/ ) |
501 | { | 501 | { |
502 | readConfig ( ); | 502 | readConfig ( ); |
503 | 503 | ||
504 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 504 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
505 | 505 | ||
506 | int w = sizeHint ( ). width ( ); | 506 | int w = sizeHint ( ). width ( ); |
507 | int x = curPos.x ( ) - ( w / 2 ); | 507 | int x = curPos.x ( ) - ( w / 2 ); |
508 | 508 | ||
509 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 509 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
510 | x = QPEApplication::desktop ( )-> width ( ) - w; | 510 | x = QPEApplication::desktop ( )-> width ( ) - w; |
511 | 511 | ||
512 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 512 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |
513 | QFrame::show ( ); | 513 | QFrame::show ( ); |
514 | 514 | ||
515 | } | 515 | } |
516 | 516 | ||
517 | void VolumeControl::readConfig ( bool force ) | 517 | void VolumeControl::readConfig ( bool force ) |
518 | { | 518 | { |
519 | Config cfg ( "qpe" ); | 519 | Config cfg ( "qpe" ); |
520 | cfg. setGroup ( "Volume" ); | 520 | cfg. setGroup ( "Volume" ); |
521 | 521 | ||
522 | int old_vp = m_vol_percent; | 522 | int old_vp = m_vol_percent; |
523 | int old_mp = m_mic_percent; | 523 | int old_mp = m_mic_percent; |
524 | int old_bass = m_bass_percent; | 524 | int old_bass = m_bass_percent; |
525 | int old_treble = m_treble_percent; | 525 | int old_treble = m_treble_percent; |
526 | bool old_vm = m_vol_muted; | 526 | bool old_vm = m_vol_muted; |
527 | bool old_mm = m_mic_muted; | 527 | bool old_mm = m_mic_muted; |
528 | bool old_sk = m_snd_key; | 528 | bool old_sk = m_snd_key; |
529 | bool old_st = m_snd_touch; | 529 | bool old_st = m_snd_touch; |
530 | bool old_sa = m_snd_alarm; | 530 | bool old_sa = m_snd_alarm; |
531 | int old_ap = m_alarm_percent; | 531 | int old_ap = m_alarm_percent; |
532 | 532 | ||
533 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 533 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
534 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 534 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
535 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); | 535 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); |
536 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); | 536 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); |
537 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 537 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
538 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 538 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
539 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 539 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
540 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 540 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
541 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 541 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
542 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 542 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
543 | 543 | ||
544 | if ( force || ( m_vol_percent != old_vp )) | 544 | if ( force || ( m_vol_percent != old_vp )) |
545 | volSlider-> setValue ( 100 - m_vol_percent ); | 545 | volSlider-> setValue ( 100 - m_vol_percent ); |
546 | if ( force || ( m_mic_percent != old_mp )) | 546 | if ( force || ( m_mic_percent != old_mp )) |
547 | micSlider-> setValue ( 100 - m_mic_percent ); | 547 | micSlider-> setValue ( 100 - m_mic_percent ); |
548 | if ( force || ( m_alarm_percent != old_ap )) | 548 | if ( force || ( m_alarm_percent != old_ap )) |
549 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 549 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
550 | if ( force || ( m_bass_percent != old_bass )) | 550 | if ( force || ( m_bass_percent != old_bass )) |
551 | bassSlider-> setValue ( 100 - m_bass_percent ); | 551 | bassSlider-> setValue ( 100 - m_bass_percent ); |
552 | if ( force || ( m_treble_percent != old_treble )) | 552 | if ( force || ( m_treble_percent != old_treble )) |
553 | trebleSlider-> setValue ( 100 - m_treble_percent ); | 553 | trebleSlider-> setValue ( 100 - m_treble_percent ); |
554 | 554 | ||
555 | 555 | ||
556 | if ( force || ( m_vol_muted != old_vm )) | 556 | if ( force || ( m_vol_muted != old_vm )) |
557 | volLed-> setOn ( !m_vol_muted ); | 557 | volLed-> setOn ( !m_vol_muted ); |
558 | if ( force || ( m_mic_muted != old_mm )) | 558 | if ( force || ( m_mic_muted != old_mm )) |
559 | micLed-> setOn ( !m_mic_muted ); | 559 | micLed-> setOn ( !m_mic_muted ); |
560 | if ( force || ( m_snd_alarm != old_sa )) | 560 | if ( force || ( m_snd_alarm != old_sa )) |
561 | alarmLed-> setOn ( m_snd_alarm ); | 561 | alarmLed-> setOn ( m_snd_alarm ); |
562 | 562 | ||
563 | if ( force || ( m_snd_key != old_sk )) | 563 | if ( force || ( m_snd_key != old_sk )) |
564 | keyBox-> setChecked ( m_snd_key ); | 564 | keyBox-> setChecked ( m_snd_key ); |
565 | if ( force || ( m_snd_touch != old_st )) | 565 | if ( force || ( m_snd_touch != old_st )) |
566 | tapBox-> setChecked ( m_snd_touch ); | 566 | tapBox-> setChecked ( m_snd_touch ); |
567 | if ( force || ( m_snd_alarm != old_sa )) | 567 | if ( force || ( m_snd_alarm != old_sa )) |
568 | alarmBox-> setChecked ( m_snd_alarm ); | 568 | alarmBox-> setChecked ( m_snd_alarm ); |
569 | } | 569 | } |
570 | 570 | ||
571 | 571 | ||
572 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) | 572 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) |
573 | { | 573 | { |
574 | int prevVol = m_vol_percent; | 574 | int prevVol = m_vol_percent; |
575 | bool prevMute = m_vol_muted; | 575 | bool prevMute = m_vol_muted; |
576 | 576 | ||
577 | readConfig ( ); | 577 | readConfig ( ); |
578 | 578 | ||
579 | // Handle case where muting it toggled | 579 | // Handle case where muting it toggled |
580 | if ( m_vol_muted != prevMute ) | 580 | if ( m_vol_muted != prevMute ) |
581 | m_icon-> redraw ( true ); | 581 | m_icon-> redraw ( true ); |
582 | else if ( prevVol != m_vol_percent ) // Avoid over repainting | 582 | else if ( prevVol != m_vol_percent ) // Avoid over repainting |
583 | m_icon-> redraw ( false ); | 583 | m_icon-> redraw ( false ); |
584 | } | 584 | } |
585 | 585 | ||
586 | void VolumeControl::micChanged ( bool nowMuted ) | 586 | void VolumeControl::micChanged ( bool nowMuted ) |
587 | { | 587 | { |
588 | if ( !nowMuted ) | 588 | if ( !nowMuted ) |
589 | readConfig ( ); | 589 | readConfig ( ); |
590 | m_mic_muted = nowMuted; | 590 | m_mic_muted = nowMuted; |
591 | } | 591 | } |
592 | 592 | ||
593 | void VolumeControl::screenTapToggled ( bool b ) | 593 | void VolumeControl::screenTapToggled ( bool b ) |
594 | { | 594 | { |
595 | m_snd_touch = b; | 595 | m_snd_touch = b; |
596 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 596 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
597 | } | 597 | } |
598 | 598 | ||
599 | void VolumeControl::keyClickToggled ( bool b ) | 599 | void VolumeControl::keyClickToggled ( bool b ) |
600 | { | 600 | { |
601 | m_snd_key = b; | 601 | m_snd_key = b; |
602 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 602 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
603 | } | 603 | } |
604 | 604 | ||
605 | void VolumeControl::alarmSoundToggled ( bool b ) | 605 | void VolumeControl::alarmSoundToggled ( bool b ) |
606 | { | 606 | { |
607 | m_snd_alarm = b; | 607 | m_snd_alarm = b; |
608 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 608 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
609 | } | 609 | } |
610 | 610 | ||
611 | void VolumeControl::volMuteToggled ( bool b ) | 611 | void VolumeControl::volMuteToggled ( bool b ) |
612 | { | 612 | { |
613 | m_vol_muted = !b; | 613 | m_vol_muted = !b; |
614 | 614 | ||
615 | m_icon-> redraw ( true ); | 615 | m_icon-> redraw ( true ); |
616 | 616 | ||
617 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 617 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
618 | } | 618 | } |
619 | 619 | ||
620 | void VolumeControl::micMuteToggled ( bool b ) | 620 | void VolumeControl::micMuteToggled ( bool b ) |
621 | { | 621 | { |
622 | m_mic_muted = !b; | 622 | m_mic_muted = !b; |
623 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 623 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | ||
627 | void VolumeControl::volMoved ( int percent ) | 627 | void VolumeControl::volMoved ( int percent ) |
628 | { | 628 | { |
629 | m_vol_percent = 100 - percent; | 629 | m_vol_percent = 100 - percent; |
630 | 630 | ||
631 | // clamp volume percent to be between 0 and 100 | 631 | // clamp volume percent to be between 0 and 100 |
632 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 632 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
633 | // repaint just the little volume rectangle | 633 | // repaint just the little volume rectangle |
634 | m_icon-> redraw ( false ); | 634 | m_icon-> redraw ( false ); |
635 | 635 | ||
636 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 636 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
637 | } | 637 | } |
638 | 638 | ||
639 | void VolumeControl::micMoved ( int percent ) | 639 | void VolumeControl::micMoved ( int percent ) |
640 | { | 640 | { |
641 | m_mic_percent = 100 - percent; | 641 | m_mic_percent = 100 - percent; |
642 | 642 | ||
643 | // clamp volume percent to be between 0 and 100 | 643 | // clamp volume percent to be between 0 and 100 |
644 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 644 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
645 | 645 | ||
646 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 646 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
647 | } | 647 | } |
648 | 648 | ||
649 | void VolumeControl::alarmMoved ( int percent ) | 649 | void VolumeControl::alarmMoved ( int percent ) |
650 | { | 650 | { |
651 | m_alarm_percent = 100 - percent; | 651 | m_alarm_percent = 100 - percent; |
652 | 652 | ||
653 | // clamp volume percent to be between 0 and 100 | 653 | // clamp volume percent to be between 0 and 100 |
654 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 654 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
655 | 655 | ||
656 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 656 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void VolumeControl::bassMoved ( int percent ) | 660 | void VolumeControl::bassMoved ( int percent ) |
661 | { | 661 | { |
662 | m_bass_percent = 100 - percent; | 662 | m_bass_percent = 100 - percent; |
663 | 663 | ||
664 | // clamp bass percent to be between 0 and 100 | 664 | // clamp bass percent to be between 0 and 100 |
665 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); | 665 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); |
666 | 666 | ||
667 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | 667 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); |
668 | } | 668 | } |
669 | 669 | ||
670 | 670 | ||
671 | 671 | ||
672 | void VolumeControl::trebleMoved ( int percent ) | 672 | void VolumeControl::trebleMoved ( int percent ) |
673 | { | 673 | { |
674 | m_treble_percent = 100 - percent; | 674 | m_treble_percent = 100 - percent; |
675 | 675 | ||
676 | // clamp treble percent to be between 0 and 100 | 676 | // clamp treble percent to be between 0 and 100 |
677 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); | 677 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); |
678 | 678 | ||
679 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | 679 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); |
680 | } | 680 | } |
681 | 681 | ||
682 | 682 | ||
683 | 683 | ||
684 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 684 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
685 | { | 685 | { |
686 | Config cfg ( "qpe" ); | 686 | Config cfg ( "qpe" ); |
687 | cfg. setGroup ( "Volume" ); | 687 | cfg. setGroup ( "Volume" ); |
688 | cfg. writeEntry ( entry, val ); | 688 | cfg. writeEntry ( entry, val ); |
689 | // cfg. write ( ); | 689 | // cfg. write ( ); |
690 | 690 | ||
691 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 691 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
692 | switch ( upd ) { | 692 | switch ( upd ) { |
693 | case UPD_Vol: { | 693 | case UPD_Vol: { |
694 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 694 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
695 | break; | 695 | break; |
696 | } | 696 | } |
697 | case UPD_Mic: { | 697 | case UPD_Mic: { |
698 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 698 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
699 | break; | 699 | break; |
700 | } | 700 | } |
701 | case UPD_Bass: { | 701 | case UPD_Bass: { |
702 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | 702 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; |
703 | break; | 703 | break; |
704 | } | 704 | } |
705 | case UPD_Treble: { | 705 | case UPD_Treble: { |
706 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | 706 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; |
707 | break; | 707 | break; |
708 | } | 708 | } |
709 | 709 | ||
710 | case UPD_None: | 710 | case UPD_None: |
711 | break; | 711 | break; |
712 | } | 712 | } |
713 | #endif | 713 | #endif |
714 | } | 714 | } |
715 | 715 | ||
716 | //=========================================================================== | 716 | //=========================================================================== |
717 | 717 | ||
718 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 718 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
719 | : QWidget( parent, name ) | 719 | : QWidget( parent, name ) |
720 | { | 720 | { |
721 | setFixedWidth ( AppLnk::smallIconSize() ); | 721 | setFixedWidth ( AppLnk::smallIconSize() ); |
722 | setFixedHeight ( AppLnk::smallIconSize()+4 ); | 722 | setFixedHeight ( AppLnk::smallIconSize()+4 ); |
723 | 723 | ||
724 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); | 724 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); |
725 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); | 725 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); |
726 | 726 | ||
727 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); | 727 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); |
728 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); | 728 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); |
729 | } | 729 | } |
730 | 730 | ||
731 | VolumeApplet::~VolumeApplet() | 731 | VolumeApplet::~VolumeApplet() |
732 | { | 732 | { |
733 | delete m_pixmap; | 733 | delete m_pixmap; |
734 | } | 734 | } |
735 | 735 | ||
736 | int VolumeApplet::position() | 736 | int VolumeApplet::position() |
737 | { | 737 | { |
738 | return 6; | 738 | return 6; |
739 | } | 739 | } |
740 | 740 | ||
741 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 741 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
742 | { | 742 | { |
743 | if ( m_dialog-> isVisible ( )) | 743 | if ( m_dialog-> isVisible ( )) |
744 | m_dialog-> hide ( ); | 744 | m_dialog-> hide ( ); |
745 | else | 745 | else |
746 | m_dialog-> show ( true ); | 746 | m_dialog-> show ( true ); |
747 | } | 747 | } |
748 | 748 | ||
749 | void VolumeApplet::redraw ( bool all ) | 749 | void VolumeApplet::redraw ( bool all ) |
750 | { | 750 | { |
751 | if ( all ) | 751 | if ( all ) |
752 | repaint ( true ); | 752 | repaint ( true ); |
753 | else | 753 | else |
754 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 754 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
755 | } | 755 | } |
756 | 756 | ||
757 | 757 | ||
758 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 758 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
759 | { | 759 | { |
760 | QPainter p ( this ); | 760 | QPainter p ( this ); |
761 | 761 | ||
762 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); | 762 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); |
763 | p. setPen ( darkGray ); | 763 | p. setPen ( darkGray ); |
764 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 764 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
765 | 765 | ||
766 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 766 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
767 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 767 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
768 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 768 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
769 | 769 | ||
770 | if ( m_dialog-> volMuted ( )) { | 770 | if ( m_dialog-> volMuted ( )) { |
771 | p. setPen ( red ); | 771 | p. setPen ( red ); |
772 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 772 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
773 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 773 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
774 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 774 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
775 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 775 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
776 | } | 776 | } |
777 | } | 777 | } |
778 | 778 | ||
779 | 779 | ||
780 | Q_EXPORT_INTERFACE() | 780 | Q_EXPORT_INTERFACE() |
781 | { | 781 | { |
782 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<VolumeApplet> ); | 782 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<VolumeApplet> ); |
783 | } | 783 | } |
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index c0066d8..6587b26 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -1,191 +1,191 @@ | |||
1 | //comandeditdialog.cpp | 1 | //comandeditdialog.cpp |
2 | 2 | ||
3 | #include "commandeditdialog.h" | 3 | #include "commandeditdialog.h" |
4 | #include "playlistselection.h" | 4 | #include "playlistselection.h" |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
7 | #include <qtoolbutton.h> | 7 | #include <qtoolbutton.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qheader.h> | 9 | #include <qheader.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include "smallcommandeditdialogbase.h" | 11 | #include "smallcommandeditdialogbase.h" |
12 | 12 | ||
13 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) | 13 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) |
14 | : CommandEditDialogBase(parent, name, TRUE, fl) | 14 | : CommandEditDialogBase(parent, name, TRUE, fl) |
15 | 15 | ||
16 | { | 16 | { |
17 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); | 17 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); |
18 | m_SuggestedCommandList->header()->hide(); | 18 | m_SuggestedCommandList->header()->hide(); |
19 | m_SuggestedCommandList->setSorting(-1,FALSE); | 19 | m_SuggestedCommandList->setSorting(-1,FALSE); |
20 | m_SuggestedCommandList->clearSelection(); | 20 | m_SuggestedCommandList->clearSelection(); |
21 | m_SuggestedCommandList->setSorting(0,TRUE); | 21 | m_SuggestedCommandList->setSorting(0,TRUE); |
22 | QListViewItem *item; | 22 | QListViewItem *item; |
23 | item = new QListViewItem( m_SuggestedCommandList,"export "); | 23 | item = new QListViewItem( m_SuggestedCommandList,"export "); |
24 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); | 24 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); |
25 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); | 25 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); |
26 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); | 26 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); |
27 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); | 27 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); |
28 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); | 28 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); |
29 | item = new QListViewItem( m_SuggestedCommandList,"chown "); | 29 | item = new QListViewItem( m_SuggestedCommandList,"chown "); |
30 | item = new QListViewItem( m_SuggestedCommandList,"date "); | 30 | item = new QListViewItem( m_SuggestedCommandList,"date "); |
31 | item = new QListViewItem( m_SuggestedCommandList,"dd "); | 31 | item = new QListViewItem( m_SuggestedCommandList,"dd "); |
32 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | 32 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); |
33 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); | 33 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); |
34 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); | 34 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); |
35 | item = new QListViewItem( m_SuggestedCommandList,"kill "); | 35 | item = new QListViewItem( m_SuggestedCommandList,"kill "); |
36 | item = new QListViewItem( m_SuggestedCommandList,"killall "); | 36 | item = new QListViewItem( m_SuggestedCommandList,"killall "); |
37 | item = new QListViewItem( m_SuggestedCommandList,"ln "); | 37 | item = new QListViewItem( m_SuggestedCommandList,"ln "); |
38 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); | 38 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); |
39 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); | 39 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); |
40 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); | 40 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); |
41 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); | 41 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); |
42 | item = new QListViewItem( m_SuggestedCommandList,"mount "); | 42 | item = new QListViewItem( m_SuggestedCommandList,"mount "); |
43 | item = new QListViewItem( m_SuggestedCommandList,"more "); | 43 | item = new QListViewItem( m_SuggestedCommandList,"more "); |
44 | item = new QListViewItem( m_SuggestedCommandList,"sort "); | 44 | item = new QListViewItem( m_SuggestedCommandList,"sort "); |
45 | item = new QListViewItem( m_SuggestedCommandList,"touch "); | 45 | item = new QListViewItem( m_SuggestedCommandList,"touch "); |
46 | item = new QListViewItem( m_SuggestedCommandList,"umount "); | 46 | item = new QListViewItem( m_SuggestedCommandList,"umount "); |
47 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); | 47 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); |
48 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); | 48 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); |
49 | item = new QListViewItem( m_SuggestedCommandList,"route "); | 49 | item = new QListViewItem( m_SuggestedCommandList,"route "); |
50 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); | 50 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); |
51 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); | 51 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); |
52 | m_SuggestedCommandList->sort(); | 52 | m_SuggestedCommandList->sort(); |
53 | 53 | ||
54 | connect( m_SuggestedCommandList, SIGNAL( clicked( QListViewItem * ) ), m_PlayListSelection, SLOT( addToSelection( QListViewItem *) ) ); | 54 | connect( m_SuggestedCommandList, SIGNAL( clicked(QListViewItem*) ), m_PlayListSelection, SLOT( addToSelection(QListViewItem*) ) ); |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | ToolButton1->setTextLabel("new"); | 58 | ToolButton1->setTextLabel("new"); |
59 | ToolButton1->setPixmap(Resource::loadPixmap("new")); | 59 | ToolButton1->setPixmap(Resource::loadPixmap("new")); |
60 | ToolButton1->setAutoRaise(TRUE); | 60 | ToolButton1->setAutoRaise(TRUE); |
61 | ToolButton1->setFocusPolicy(QWidget::NoFocus); | 61 | ToolButton1->setFocusPolicy(QWidget::NoFocus); |
62 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); | 62 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); |
63 | 63 | ||
64 | ToolButton2->setTextLabel("edit"); | 64 | ToolButton2->setTextLabel("edit"); |
65 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); | 65 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); |
66 | ToolButton2->setAutoRaise(TRUE); | 66 | ToolButton2->setAutoRaise(TRUE); |
67 | ToolButton2->setFocusPolicy(QWidget::NoFocus); | 67 | ToolButton2->setFocusPolicy(QWidget::NoFocus); |
68 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); | 68 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); |
69 | 69 | ||
70 | ToolButton3->setTextLabel("delete"); | 70 | ToolButton3->setTextLabel("delete"); |
71 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); | 71 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); |
72 | ToolButton3->setAutoRaise(TRUE); | 72 | ToolButton3->setAutoRaise(TRUE); |
73 | ToolButton3->setFocusPolicy(QWidget::NoFocus); | 73 | ToolButton3->setFocusPolicy(QWidget::NoFocus); |
74 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); | 74 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); |
75 | 75 | ||
76 | ToolButton4->setTextLabel("up"); | 76 | ToolButton4->setTextLabel("up"); |
77 | ToolButton4->setPixmap(Resource::loadPixmap("up")); | 77 | ToolButton4->setPixmap(Resource::loadPixmap("up")); |
78 | ToolButton4->setAutoRaise(TRUE); | 78 | ToolButton4->setAutoRaise(TRUE); |
79 | ToolButton4->setFocusPolicy(QWidget::NoFocus); | 79 | ToolButton4->setFocusPolicy(QWidget::NoFocus); |
80 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); | 80 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); |
81 | 81 | ||
82 | ToolButton5->setTextLabel("down"); | 82 | ToolButton5->setTextLabel("down"); |
83 | ToolButton5->setPixmap(Resource::loadPixmap("down")); | 83 | ToolButton5->setPixmap(Resource::loadPixmap("down")); |
84 | ToolButton5->setAutoRaise(TRUE); | 84 | ToolButton5->setAutoRaise(TRUE); |
85 | ToolButton5->setFocusPolicy(QWidget::NoFocus); | 85 | ToolButton5->setFocusPolicy(QWidget::NoFocus); |
86 | 86 | ||
87 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); | 87 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); |
88 | 88 | ||
89 | 89 | ||
90 | 90 | ||
91 | 91 | ||
92 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); | 92 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); |
93 | if ( current ) | 93 | if ( current ) |
94 | item->moveItem( current ); | 94 | item->moveItem( current ); |
95 | m_SuggestedCommandList->setSelected( item, TRUE ); | 95 | m_SuggestedCommandList->setSelected( item, TRUE ); |
96 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); | 96 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); |
97 | Config cfg( "Konsole" ); | 97 | Config cfg( "Konsole" ); |
98 | cfg.setGroup("Commands"); | 98 | cfg.setGroup("Commands"); |
99 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { | 99 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { |
100 | for (int i = 0; i < 100; i++) { | 100 | for (int i = 0; i < 100; i++) { |
101 | QString tmp; | 101 | QString tmp; |
102 | tmp = cfg.readEntry( QString::number(i),""); | 102 | tmp = cfg.readEntry( QString::number(i),""); |
103 | if (!tmp.isEmpty()) | 103 | if (!tmp.isEmpty()) |
104 | m_PlayListSelection->addStringToSelection(tmp); | 104 | m_PlayListSelection->addStringToSelection(tmp); |
105 | } | 105 | } |
106 | } else { | 106 | } else { |
107 | 107 | ||
108 | m_PlayListSelection->addStringToSelection("ls "); | 108 | m_PlayListSelection->addStringToSelection("ls "); |
109 | m_PlayListSelection->addStringToSelection("cardctl eject"); | 109 | m_PlayListSelection->addStringToSelection("cardctl eject"); |
110 | m_PlayListSelection->addStringToSelection("cat "); | 110 | m_PlayListSelection->addStringToSelection("cat "); |
111 | m_PlayListSelection->addStringToSelection("cd "); | 111 | m_PlayListSelection->addStringToSelection("cd "); |
112 | m_PlayListSelection->addStringToSelection("chmod "); | 112 | m_PlayListSelection->addStringToSelection("chmod "); |
113 | m_PlayListSelection->addStringToSelection("cp "); | 113 | m_PlayListSelection->addStringToSelection("cp "); |
114 | m_PlayListSelection->addStringToSelection("dc "); | 114 | m_PlayListSelection->addStringToSelection("dc "); |
115 | m_PlayListSelection->addStringToSelection("df "); | 115 | m_PlayListSelection->addStringToSelection("df "); |
116 | m_PlayListSelection->addStringToSelection("dmesg"); | 116 | m_PlayListSelection->addStringToSelection("dmesg"); |
117 | m_PlayListSelection->addStringToSelection("echo "); | 117 | m_PlayListSelection->addStringToSelection("echo "); |
118 | m_PlayListSelection->addStringToSelection("env"); | 118 | m_PlayListSelection->addStringToSelection("env"); |
119 | m_PlayListSelection->addStringToSelection("find "); | 119 | m_PlayListSelection->addStringToSelection("find "); |
120 | m_PlayListSelection->addStringToSelection("free"); | 120 | m_PlayListSelection->addStringToSelection("free"); |
121 | m_PlayListSelection->addStringToSelection("grep "); | 121 | m_PlayListSelection->addStringToSelection("grep "); |
122 | m_PlayListSelection->addStringToSelection("ifconfig "); | 122 | m_PlayListSelection->addStringToSelection("ifconfig "); |
123 | m_PlayListSelection->addStringToSelection("ipkg "); | 123 | m_PlayListSelection->addStringToSelection("ipkg "); |
124 | m_PlayListSelection->addStringToSelection("mkdir "); | 124 | m_PlayListSelection->addStringToSelection("mkdir "); |
125 | m_PlayListSelection->addStringToSelection("mv "); | 125 | m_PlayListSelection->addStringToSelection("mv "); |
126 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); | 126 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); |
127 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); | 127 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); |
128 | m_PlayListSelection->addStringToSelection("nslookup "); | 128 | m_PlayListSelection->addStringToSelection("nslookup "); |
129 | m_PlayListSelection->addStringToSelection("ping "); | 129 | m_PlayListSelection->addStringToSelection("ping "); |
130 | m_PlayListSelection->addStringToSelection("ps aux"); | 130 | m_PlayListSelection->addStringToSelection("ps aux"); |
131 | m_PlayListSelection->addStringToSelection("pwd "); | 131 | m_PlayListSelection->addStringToSelection("pwd "); |
132 | m_PlayListSelection->addStringToSelection("rm "); | 132 | m_PlayListSelection->addStringToSelection("rm "); |
133 | m_PlayListSelection->addStringToSelection("rmdir "); | 133 | m_PlayListSelection->addStringToSelection("rmdir "); |
134 | m_PlayListSelection->addStringToSelection("route "); | 134 | m_PlayListSelection->addStringToSelection("route "); |
135 | m_PlayListSelection->addStringToSelection("set "); | 135 | m_PlayListSelection->addStringToSelection("set "); |
136 | m_PlayListSelection->addStringToSelection("traceroute"); | 136 | m_PlayListSelection->addStringToSelection("traceroute"); |
137 | 137 | ||
138 | } | 138 | } |
139 | } | 139 | } |
140 | CommandEditDialog::~CommandEditDialog() | 140 | CommandEditDialog::~CommandEditDialog() |
141 | { | 141 | { |
142 | } | 142 | } |
143 | 143 | ||
144 | void CommandEditDialog::accept() | 144 | void CommandEditDialog::accept() |
145 | { | 145 | { |
146 | int i = 0; | 146 | int i = 0; |
147 | Config *cfg = new Config("Konsole"); | 147 | Config *cfg = new Config("Konsole"); |
148 | cfg->setGroup("Commands"); | 148 | cfg->setGroup("Commands"); |
149 | cfg->clearGroup(); | 149 | cfg->clearGroup(); |
150 | 150 | ||
151 | QListViewItemIterator it( m_PlayListSelection ); | 151 | QListViewItemIterator it( m_PlayListSelection ); |
152 | 152 | ||
153 | for ( ; it.current(); ++it ) { | 153 | for ( ; it.current(); ++it ) { |
154 | // qDebug(it.current()->text(0)); | 154 | // qDebug(it.current()->text(0)); |
155 | cfg->writeEntry(QString::number(i),it.current()->text(0)); | 155 | cfg->writeEntry(QString::number(i),it.current()->text(0)); |
156 | i++; | 156 | i++; |
157 | 157 | ||
158 | } | 158 | } |
159 | cfg->writeEntry("Commands Set","TRUE"); | 159 | cfg->writeEntry("Commands Set","TRUE"); |
160 | // qDebug("CommandEditDialog::accept() - written"); | 160 | // qDebug("CommandEditDialog::accept() - written"); |
161 | delete cfg; | 161 | delete cfg; |
162 | emit commandsEdited(); | 162 | emit commandsEdited(); |
163 | close(); | 163 | close(); |
164 | 164 | ||
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | void CommandEditDialog::showEditDialog() | 171 | void CommandEditDialog::showEditDialog() |
172 | { | 172 | { |
173 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 173 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
174 | d->setCaption("Edit command"); | 174 | d->setCaption("Edit command"); |
175 | d->TextLabel->setText("Edit command:"); | 175 | d->TextLabel->setText("Edit command:"); |
176 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); | 176 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); |
177 | int i = d->exec(); | 177 | int i = d->exec(); |
178 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 178 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
179 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); | 179 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); |
180 | } | 180 | } |
181 | 181 | ||
182 | void CommandEditDialog::showAddDialog() | 182 | void CommandEditDialog::showAddDialog() |
183 | { | 183 | { |
184 | 184 | ||
185 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 185 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
186 | int i = d->exec(); | 186 | int i = d->exec(); |
187 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 187 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
188 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); | 188 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); |
189 | 189 | ||
190 | } | 190 | } |
191 | 191 | ||
diff --git a/core/apps/embeddedkonsole/session.cpp b/core/apps/embeddedkonsole/session.cpp index 043b8db..a94712a 100644 --- a/core/apps/embeddedkonsole/session.cpp +++ b/core/apps/embeddedkonsole/session.cpp | |||
@@ -1,160 +1,160 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* Ported Konsole to Qt/Embedded */ | 3 | /* Ported Konsole to Qt/Embedded */ |
4 | /* */ | 4 | /* */ |
5 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 5 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
6 | /* */ | 6 | /* */ |
7 | /* -------------------------------------------------------------------------- */ | 7 | /* -------------------------------------------------------------------------- */ |
8 | #include "session.h" | 8 | #include "session.h" |
9 | // #include <kdebug.h> | 9 | // #include <kdebug.h> |
10 | 10 | ||
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | 12 | ||
13 | #define HERE fprintf(stderr,"%s(%d): here\n",__FILE__,__LINE__) | 13 | #define HERE fprintf(stderr,"%s(%d): here\n",__FILE__,__LINE__) |
14 | 14 | ||
15 | /*! \class TESession | 15 | /*! \class TESession |
16 | 16 | ||
17 | Sessions are combinations of TEPTy and Emulations. | 17 | Sessions are combinations of TEPTy and Emulations. |
18 | 18 | ||
19 | The stuff in here does not belong to the terminal emulation framework, | 19 | The stuff in here does not belong to the terminal emulation framework, |
20 | but to main.C. It serves it's duty by providing a single reference | 20 | but to main.C. It serves it's duty by providing a single reference |
21 | to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one | 21 | to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one |
22 | of the abilities of the framework - multible sessions. | 22 | of the abilities of the framework - multible sessions. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args) | 25 | TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args) |
26 | { | 26 | { |
27 | te = _te; | 27 | te = _te; |
28 | term = _term; | 28 | term = _term; |
29 | 29 | ||
30 | // sh = new TEPty(); | 30 | // sh = new TEPty(); |
31 | sh = new MyPty(); | 31 | sh = new MyPty(); |
32 | em = new TEmuVt102(te); | 32 | em = new TEmuVt102(te); |
33 | 33 | ||
34 | sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary | 34 | sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary |
35 | QObject::connect( sh,SIGNAL(block_in(const char*,int)), | 35 | QObject::connect( sh,SIGNAL(block_in(const char*,int)), |
36 | em,SLOT(onRcvBlock(const char*,int)) ); | 36 | em,SLOT(onRcvBlock(const char*,int)) ); |
37 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), | 37 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), |
38 | sh,SLOT(setSize(int,int))); | 38 | sh,SLOT(setSize(int,int))); |
39 | 39 | ||
40 | // 'main' should do those connects itself, somehow. | 40 | // 'main' should do those connects itself, somehow. |
41 | // These aren't KTMW's slots, but konsole's.(David) | 41 | // These aren't KTMW's slots, but konsole's.(David) |
42 | 42 | ||
43 | /* | 43 | /* |
44 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), | 44 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), |
45 | main,SLOT(notifySize(int,int))); | 45 | main,SLOT(notifySize(int,int))); |
46 | */ | 46 | */ |
47 | QObject::connect( em,SIGNAL(sndBlock(const char*,int)), | 47 | QObject::connect( em,SIGNAL(sndBlock(const char*,int)), |
48 | sh,SLOT(send_bytes(const char*,int)) ); | 48 | sh,SLOT(send_bytes(const char*,int)) ); |
49 | QObject::connect( em,SIGNAL(changeColumns(int)), | 49 | QObject::connect( em,SIGNAL(changeColumns(int)), |
50 | main,SLOT(changeColumns(int)) ); | 50 | main,SLOT(changeColumns(int)) ); |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | QObject::connect( em,SIGNAL(changeTitle(int, const QString&)), | 54 | QObject::connect( em,SIGNAL(changeTitle(int,const QString&)), |
55 | this,SLOT(changeTitle(int, const QString&)) ); | 55 | this,SLOT(changeTitle(int,const QString&)) ); |
56 | 56 | ||
57 | QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) ); | 57 | QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) ); |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | void TESession::run() | 62 | void TESession::run() |
63 | { | 63 | { |
64 | //kdDebug() << "Running the session!" << pgm << "\n"; | 64 | //kdDebug() << "Running the session!" << pgm << "\n"; |
65 | sh->run(pgm,args,term.data(),FALSE); | 65 | sh->run(pgm,args,term.data(),FALSE); |
66 | } | 66 | } |
67 | 67 | ||
68 | void TESession::kill(int ) // signal) | 68 | void TESession::kill(int ) // signal) |
69 | { | 69 | { |
70 | // sh->kill(signal); | 70 | // sh->kill(signal); |
71 | } | 71 | } |
72 | 72 | ||
73 | TESession::~TESession() | 73 | TESession::~TESession() |
74 | { | 74 | { |
75 | QObject::disconnect( sh, SIGNAL( done( int ) ), | 75 | QObject::disconnect( sh, SIGNAL( done(int) ), |
76 | this, SLOT( done( int ) ) ); | 76 | this, SLOT( done(int) ) ); |
77 | delete em; | 77 | delete em; |
78 | delete sh; | 78 | delete sh; |
79 | } | 79 | } |
80 | 80 | ||
81 | void TESession::setConnect(bool c) | 81 | void TESession::setConnect(bool c) |
82 | { | 82 | { |
83 | em->setConnect(c); | 83 | em->setConnect(c); |
84 | } | 84 | } |
85 | 85 | ||
86 | void TESession::done(int status) | 86 | void TESession::done(int status) |
87 | { | 87 | { |
88 | emit done(te,status); | 88 | emit done(te,status); |
89 | } | 89 | } |
90 | 90 | ||
91 | void TESession::terminate() | 91 | void TESession::terminate() |
92 | { | 92 | { |
93 | delete this; | 93 | delete this; |
94 | } | 94 | } |
95 | 95 | ||
96 | TEmulation* TESession::getEmulation() | 96 | TEmulation* TESession::getEmulation() |
97 | { | 97 | { |
98 | return em; | 98 | return em; |
99 | } | 99 | } |
100 | 100 | ||
101 | // following interfaces might be misplaced /// | 101 | // following interfaces might be misplaced /// |
102 | 102 | ||
103 | int TESession::schemaNo() | 103 | int TESession::schemaNo() |
104 | { | 104 | { |
105 | return schema_no; | 105 | return schema_no; |
106 | } | 106 | } |
107 | 107 | ||
108 | int TESession::keymap() | 108 | int TESession::keymap() |
109 | { | 109 | { |
110 | return keymap_no; | 110 | return keymap_no; |
111 | } | 111 | } |
112 | 112 | ||
113 | int TESession::fontNo() | 113 | int TESession::fontNo() |
114 | { | 114 | { |
115 | return font_no; | 115 | return font_no; |
116 | } | 116 | } |
117 | 117 | ||
118 | const char* TESession::emuName() | 118 | const char* TESession::emuName() |
119 | { | 119 | { |
120 | return term.data(); | 120 | return term.data(); |
121 | } | 121 | } |
122 | 122 | ||
123 | void TESession::setSchemaNo(int sn) | 123 | void TESession::setSchemaNo(int sn) |
124 | { | 124 | { |
125 | schema_no = sn; | 125 | schema_no = sn; |
126 | } | 126 | } |
127 | 127 | ||
128 | void TESession::setKeymapNo(int kn) | 128 | void TESession::setKeymapNo(int kn) |
129 | { | 129 | { |
130 | keymap_no = kn; | 130 | keymap_no = kn; |
131 | em->setKeytrans(kn); | 131 | em->setKeytrans(kn); |
132 | } | 132 | } |
133 | 133 | ||
134 | void TESession::setFontNo(int fn) | 134 | void TESession::setFontNo(int fn) |
135 | { | 135 | { |
136 | font_no = fn; | 136 | font_no = fn; |
137 | } | 137 | } |
138 | 138 | ||
139 | void TESession::changeTitle(int, const QString& title) | 139 | void TESession::changeTitle(int, const QString& title) |
140 | { | 140 | { |
141 | this->title = title; | 141 | this->title = title; |
142 | emit changeTitle(te, title); | 142 | emit changeTitle(te, title); |
143 | } | 143 | } |
144 | 144 | ||
145 | const QString& TESession::Title() | 145 | const QString& TESession::Title() |
146 | { | 146 | { |
147 | return title; | 147 | return title; |
148 | } | 148 | } |
149 | 149 | ||
150 | void TESession::setHistory(bool on) | 150 | void TESession::setHistory(bool on) |
151 | { | 151 | { |
152 | em->setHistory( on ); | 152 | em->setHistory( on ); |
153 | } | 153 | } |
154 | 154 | ||
155 | bool TESession::history() | 155 | bool TESession::history() |
156 | { | 156 | { |
157 | return em->history(); | 157 | return em->history(); |
158 | } | 158 | } |
159 | 159 | ||
160 | // #include "session.moc" | 160 | // #include "session.moc" |
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp index 8fb0161..336d9fb 100644 --- a/core/apps/helpbrowser/helpbrowser.cpp +++ b/core/apps/helpbrowser/helpbrowser.cpp | |||
@@ -1,228 +1,228 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | 22 | ||
23 | #include "helpbrowser.h" | 23 | #include "helpbrowser.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | 27 | ||
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | #include <qfileinfo.h> | 31 | #include <qfileinfo.h> |
32 | #include <qaction.h> | 32 | #include <qaction.h> |
33 | 33 | ||
34 | #include <cctype> | 34 | #include <cctype> |
35 | 35 | ||
36 | #include "magictextbrowser.h" | 36 | #include "magictextbrowser.h" |
37 | 37 | ||
38 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) | 38 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) |
39 | : QMainWindow( parent, name, f ), | 39 | : QMainWindow( parent, name, f ), |
40 | selectedURL() | 40 | selectedURL() |
41 | { | 41 | { |
42 | init( "index.html" ); | 42 | init( "index.html" ); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | void HelpBrowser::init( const QString& _home ) | 47 | void HelpBrowser::init( const QString& _home ) |
48 | { | 48 | { |
49 | setIcon( Resource::loadPixmap( "HelpBrowser" ) ); | 49 | setIcon( Resource::loadPixmap( "HelpBrowser" ) ); |
50 | setBackgroundMode( PaletteButton ); | 50 | setBackgroundMode( PaletteButton ); |
51 | 51 | ||
52 | browser = new MagicTextBrowser( this ); | 52 | browser = new MagicTextBrowser( this ); |
53 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 53 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
54 | connect( browser, SIGNAL( textChanged() ), | 54 | connect( browser, SIGNAL( textChanged() ), |
55 | this, SLOT( textChanged() ) ); | 55 | this, SLOT( textChanged() ) ); |
56 | 56 | ||
57 | setCentralWidget( browser ); | 57 | setCentralWidget( browser ); |
58 | setToolBarsMovable( FALSE ); | 58 | setToolBarsMovable( FALSE ); |
59 | 59 | ||
60 | if ( !_home.isEmpty() ) | 60 | if ( !_home.isEmpty() ) |
61 | browser->setSource( _home ); | 61 | browser->setSource( _home ); |
62 | 62 | ||
63 | QToolBar* toolbar = new QToolBar( this ); | 63 | QToolBar* toolbar = new QToolBar( this ); |
64 | toolbar->setHorizontalStretchable( TRUE ); | 64 | toolbar->setHorizontalStretchable( TRUE ); |
65 | QMenuBar *menu = new QMenuBar( toolbar ); | 65 | QMenuBar *menu = new QMenuBar( toolbar ); |
66 | 66 | ||
67 | toolbar = new QToolBar( this ); | 67 | toolbar = new QToolBar( this ); |
68 | // addToolBar( toolbar, "Toolbar"); | 68 | // addToolBar( toolbar, "Toolbar"); |
69 | 69 | ||
70 | QPopupMenu* go = new QPopupMenu( this ); | 70 | QPopupMenu* go = new QPopupMenu( this ); |
71 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); | 71 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); |
72 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); | 72 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); |
73 | connect( browser, SIGNAL( backwardAvailable( bool ) ), | 73 | connect( browser, SIGNAL( backwardAvailable(bool) ), |
74 | backAction, SLOT( setEnabled( bool ) ) ); | 74 | backAction, SLOT( setEnabled(bool) ) ); |
75 | backAction->addTo( go ); | 75 | backAction->addTo( go ); |
76 | backAction->addTo( toolbar ); | 76 | backAction->addTo( toolbar ); |
77 | backAction->setEnabled( FALSE ); | 77 | backAction->setEnabled( FALSE ); |
78 | 78 | ||
79 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); | 79 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); |
80 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); | 80 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); |
81 | connect( browser, SIGNAL( forwardAvailable( bool ) ), | 81 | connect( browser, SIGNAL( forwardAvailable(bool) ), |
82 | forwardAction, SLOT( setEnabled( bool ) ) ); | 82 | forwardAction, SLOT( setEnabled(bool) ) ); |
83 | forwardAction->addTo( go ); | 83 | forwardAction->addTo( go ); |
84 | forwardAction->addTo( toolbar ); | 84 | forwardAction->addTo( toolbar ); |
85 | forwardAction->setEnabled( FALSE ); | 85 | forwardAction->setEnabled( FALSE ); |
86 | 86 | ||
87 | QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); | 87 | QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); |
88 | connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); | 88 | connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); |
89 | a->addTo( go ); | 89 | a->addTo( go ); |
90 | a->addTo( toolbar ); | 90 | a->addTo( toolbar ); |
91 | 91 | ||
92 | bookm = new QPopupMenu( this ); | 92 | bookm = new QPopupMenu( this ); |
93 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | 93 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); |
94 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); | 94 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); |
95 | bookm->insertSeparator(); | 95 | bookm->insertSeparator(); |
96 | connect( bookm, SIGNAL( activated( int ) ), | 96 | connect( bookm, SIGNAL( activated(int) ), |
97 | this, SLOT( bookmChosen( int ) ) ); | 97 | this, SLOT( bookmChosen(int) ) ); |
98 | 98 | ||
99 | readBookmarks(); | 99 | readBookmarks(); |
100 | 100 | ||
101 | menu->insertItem( tr("Go"), go ); | 101 | menu->insertItem( tr("Go"), go ); |
102 | menu->insertItem( tr( "Bookmarks" ), bookm ); | 102 | menu->insertItem( tr( "Bookmarks" ), bookm ); |
103 | 103 | ||
104 | resize( 240, 300 ); | 104 | resize( 240, 300 ); |
105 | browser->setFocus(); | 105 | browser->setFocus(); |
106 | browser->setFrameStyle( QFrame::NoFrame ); | 106 | browser->setFrameStyle( QFrame::NoFrame ); |
107 | 107 | ||
108 | #if !defined(QT_NO_COP) | 108 | #if !defined(QT_NO_COP) |
109 | QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); | 109 | QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); |
110 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 110 | connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), |
111 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 111 | this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 114 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
115 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 115 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | 118 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) |
119 | { | 119 | { |
120 | qDebug("reached appMessage"); | 120 | qDebug("reached appMessage"); |
121 | if ( msg == "showFile(QString)" ) { | 121 | if ( msg == "showFile(QString)" ) { |
122 | QDataStream ds(data,IO_ReadOnly); | 122 | QDataStream ds(data,IO_ReadOnly); |
123 | QString fn; | 123 | QString fn; |
124 | ds >> fn; | 124 | ds >> fn; |
125 | setDocument( fn ); | 125 | setDocument( fn ); |
126 | 126 | ||
127 | QPEApplication::setKeepRunning(); | 127 | QPEApplication::setKeepRunning(); |
128 | 128 | ||
129 | showMaximized(); | 129 | showMaximized(); |
130 | setActiveWindow(); | 130 | setActiveWindow(); |
131 | raise(); | 131 | raise(); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | void HelpBrowser::setDocument( const QString &doc ) | 135 | void HelpBrowser::setDocument( const QString &doc ) |
136 | { | 136 | { |
137 | if ( !doc.isEmpty() ) | 137 | if ( !doc.isEmpty() ) |
138 | browser->setSource( doc ); | 138 | browser->setSource( doc ); |
139 | raise(); | 139 | raise(); |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | void HelpBrowser::textChanged() | 143 | void HelpBrowser::textChanged() |
144 | { | 144 | { |
145 | if ( browser->documentTitle().isNull() ) | 145 | if ( browser->documentTitle().isNull() ) |
146 | setCaption( tr("Help Browser") ); | 146 | setCaption( tr("Help Browser") ); |
147 | else | 147 | else |
148 | setCaption( browser->documentTitle() ) ; | 148 | setCaption( browser->documentTitle() ) ; |
149 | 149 | ||
150 | selectedURL = caption(); | 150 | selectedURL = caption(); |
151 | } | 151 | } |
152 | 152 | ||
153 | HelpBrowser::~HelpBrowser() | 153 | HelpBrowser::~HelpBrowser() |
154 | { | 154 | { |
155 | QStringList bookmarks; | 155 | QStringList bookmarks; |
156 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); | 156 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); |
157 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 157 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
158 | bookmarks.append( (*it2).name + "=" + (*it2).file ); | 158 | bookmarks.append( (*it2).name + "=" + (*it2).file ); |
159 | 159 | ||
160 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); | 160 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); |
161 | if ( f2.open( IO_WriteOnly ) ) { | 161 | if ( f2.open( IO_WriteOnly ) ) { |
162 | QDataStream s2( &f2 ); | 162 | QDataStream s2( &f2 ); |
163 | s2 << bookmarks; | 163 | s2 << bookmarks; |
164 | f2.close(); | 164 | f2.close(); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | void HelpBrowser::pathSelected( const QString &_path ) | 168 | void HelpBrowser::pathSelected( const QString &_path ) |
169 | { | 169 | { |
170 | browser->setSource( _path ); | 170 | browser->setSource( _path ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void HelpBrowser::readBookmarks() | 173 | void HelpBrowser::readBookmarks() |
174 | { | 174 | { |
175 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); | 175 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); |
176 | if ( QFile::exists( file ) ) { | 176 | if ( QFile::exists( file ) ) { |
177 | QStringList bookmarks; | 177 | QStringList bookmarks; |
178 | QFile f( file ); | 178 | QFile f( file ); |
179 | if ( f.open( IO_ReadOnly ) ) { | 179 | if ( f.open( IO_ReadOnly ) ) { |
180 | QDataStream s( &f ); | 180 | QDataStream s( &f ); |
181 | s >> bookmarks; | 181 | s >> bookmarks; |
182 | f.close(); | 182 | f.close(); |
183 | } | 183 | } |
184 | QStringList::Iterator it = bookmarks.begin(); | 184 | QStringList::Iterator it = bookmarks.begin(); |
185 | for ( ; it != bookmarks.end(); ++it ) { | 185 | for ( ; it != bookmarks.end(); ++it ) { |
186 | Bookmark b; | 186 | Bookmark b; |
187 | QString current = *it; | 187 | QString current = *it; |
188 | int equal = current.find( "=" ); | 188 | int equal = current.find( "=" ); |
189 | if ( equal < 1 || equal == (int)current.length() - 1 ) | 189 | if ( equal < 1 || equal == (int)current.length() - 1 ) |
190 | continue; | 190 | continue; |
191 | b.name = current.left( equal ); | 191 | b.name = current.left( equal ); |
192 | b.file = current.mid( equal + 1 ); | 192 | b.file = current.mid( equal + 1 ); |
193 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 193 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | void HelpBrowser::bookmChosen( int i ) | 198 | void HelpBrowser::bookmChosen( int i ) |
199 | { | 199 | { |
200 | if ( mBookmarks.contains( i ) ) | 200 | if ( mBookmarks.contains( i ) ) |
201 | browser->setSource( mBookmarks[ i ].file ); | 201 | browser->setSource( mBookmarks[ i ].file ); |
202 | } | 202 | } |
203 | 203 | ||
204 | void HelpBrowser::addBookmark() | 204 | void HelpBrowser::addBookmark() |
205 | { | 205 | { |
206 | Bookmark b; | 206 | Bookmark b; |
207 | b.name = browser->documentTitle(); | 207 | b.name = browser->documentTitle(); |
208 | b.file = browser->source(); | 208 | b.file = browser->source(); |
209 | if (b.name.isEmpty() ) { | 209 | if (b.name.isEmpty() ) { |
210 | b.name = b.file.left( b.file.length() - 5 ); // remove .html | 210 | b.name = b.file.left( b.file.length() - 5 ); // remove .html |
211 | } | 211 | } |
212 | QMap<int, Bookmark>::Iterator it; | 212 | QMap<int, Bookmark>::Iterator it; |
213 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) | 213 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) |
214 | if ( (*it).file == b.file ) return; | 214 | if ( (*it).file == b.file ) return; |
215 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 215 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
216 | } | 216 | } |
217 | 217 | ||
218 | void HelpBrowser::removeBookmark() | 218 | void HelpBrowser::removeBookmark() |
219 | { | 219 | { |
220 | QString file = browser->source(); | 220 | QString file = browser->source(); |
221 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); | 221 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); |
222 | for( ; it != mBookmarks.end(); ++it ) | 222 | for( ; it != mBookmarks.end(); ++it ) |
223 | if ( (*it).file == file ) { | 223 | if ( (*it).file == file ) { |
224 | bookm->removeItem( it.key() ); | 224 | bookm->removeItem( it.key() ); |
225 | mBookmarks.remove( it ); | 225 | mBookmarks.remove( it ); |
226 | break; | 226 | break; |
227 | } | 227 | } |
228 | } | 228 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 55725cc..b54da34 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,779 +1,779 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | #include "textedit.h" | 14 | #include "textedit.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | 17 | ||
18 | #include <opie2/ofileselector.h> | 18 | #include <opie2/ofileselector.h> |
19 | #include <opie2/ofiledialog.h> | 19 | #include <opie2/ofiledialog.h> |
20 | #include <opie2/ofontselector.h> | 20 | #include <opie2/ofontselector.h> |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qtoolbar.h> | 26 | #include <qtoolbar.h> |
27 | 27 | ||
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qclipboard.h> | 29 | #include <qclipboard.h> |
30 | #include <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
38 | #include <stdlib.h> //getenv | 38 | #include <stdlib.h> //getenv |
39 | 39 | ||
40 | using Opie::OFileDialog; | 40 | using Opie::OFileDialog; |
41 | using Opie::OFileSelector; | 41 | using Opie::OFileSelector; |
42 | using Opie::OFontSelector; | 42 | using Opie::OFontSelector; |
43 | 43 | ||
44 | #if QT_VERSION < 300 | 44 | #if QT_VERSION < 300 |
45 | 45 | ||
46 | class QpeEditor : public QMultiLineEdit | 46 | class QpeEditor : public QMultiLineEdit |
47 | { | 47 | { |
48 | 48 | ||
49 | public: | 49 | public: |
50 | QpeEditor( QWidget *parent, const char * name = 0 ) | 50 | QpeEditor( QWidget *parent, const char * name = 0 ) |
51 | : QMultiLineEdit( parent, name ) { | 51 | : QMultiLineEdit( parent, name ) { |
52 | clearTableFlags(); | 52 | clearTableFlags(); |
53 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 53 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
54 | } | 54 | } |
55 | 55 | ||
56 | void find( const QString &txt, bool caseSensitive, | 56 | void find( const QString &txt, bool caseSensitive, |
57 | bool backwards ); | 57 | bool backwards ); |
58 | protected: | 58 | protected: |
59 | bool markIt; | 59 | bool markIt; |
60 | int line1, line2, col1, col2; | 60 | int line1, line2, col1, col2; |
61 | void mousePressEvent( QMouseEvent * ); | 61 | void mousePressEvent( QMouseEvent * ); |
62 | void mouseReleaseEvent( QMouseEvent * ); | 62 | void mouseReleaseEvent( QMouseEvent * ); |
63 | 63 | ||
64 | //public slots: | 64 | //public slots: |
65 | /* | 65 | /* |
66 | signals: | 66 | signals: |
67 | void notFound(); | 67 | void notFound(); |
68 | void searchWrapped(); | 68 | void searchWrapped(); |
69 | */ | 69 | */ |
70 | 70 | ||
71 | private: | 71 | private: |
72 | 72 | ||
73 | }; | 73 | }; |
74 | 74 | ||
75 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 75 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
76 | switch(e->button()) { | 76 | switch(e->button()) { |
77 | case RightButton: | 77 | case RightButton: |
78 | { //rediculous workaround for qt popup menu | 78 | { //rediculous workaround for qt popup menu |
79 | //and the hold right click mechanism | 79 | //and the hold right click mechanism |
80 | this->setSelection( line1, col1, line2, col2); | 80 | this->setSelection( line1, col1, line2, col2); |
81 | QMultiLineEdit::mousePressEvent( e ); | 81 | QMultiLineEdit::mousePressEvent( e ); |
82 | markIt = false; | 82 | markIt = false; |
83 | } | 83 | } |
84 | break; | 84 | break; |
85 | default: | 85 | default: |
86 | { | 86 | { |
87 | if(!markIt) { | 87 | if(!markIt) { |
88 | int line, col; | 88 | int line, col; |
89 | this->getCursorPosition(&line, &col); | 89 | this->getCursorPosition(&line, &col); |
90 | line1=line2=line; | 90 | line1=line2=line; |
91 | col1=col2=col; | 91 | col1=col2=col; |
92 | } | 92 | } |
93 | QMultiLineEdit::mousePressEvent( e ); | 93 | QMultiLineEdit::mousePressEvent( e ); |
94 | } | 94 | } |
95 | break; | 95 | break; |
96 | }; | 96 | }; |
97 | } | 97 | } |
98 | 98 | ||
99 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 99 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
100 | if(this->hasMarkedText()) { | 100 | if(this->hasMarkedText()) { |
101 | markIt = true; | 101 | markIt = true; |
102 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 102 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
103 | } else { | 103 | } else { |
104 | markIt = false; | 104 | markIt = false; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 108 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
109 | bool backwards ) | 109 | bool backwards ) |
110 | { | 110 | { |
111 | static bool wrap = false; | 111 | static bool wrap = false; |
112 | int line, col; | 112 | int line, col; |
113 | if ( wrap ) { | 113 | if ( wrap ) { |
114 | if ( !backwards ) | 114 | if ( !backwards ) |
115 | line = col = 0; | 115 | line = col = 0; |
116 | wrap = false; | 116 | wrap = false; |
117 | // emit searchWrapped(); | 117 | // emit searchWrapped(); |
118 | } else { | 118 | } else { |
119 | getCursorPosition( &line, &col ); | 119 | getCursorPosition( &line, &col ); |
120 | } | 120 | } |
121 | //ignore backwards for now.... | 121 | //ignore backwards for now.... |
122 | if ( !backwards ) { | 122 | if ( !backwards ) { |
123 | for ( ; ; ) { | 123 | for ( ; ; ) { |
124 | if ( line >= numLines() ) { | 124 | if ( line >= numLines() ) { |
125 | wrap = true; | 125 | wrap = true; |
126 | //emit notFound(); | 126 | //emit notFound(); |
127 | break; | 127 | break; |
128 | } | 128 | } |
129 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 129 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
130 | if ( findCol >= 0 ) { | 130 | if ( findCol >= 0 ) { |
131 | setCursorPosition( line, findCol, false ); | 131 | setCursorPosition( line, findCol, false ); |
132 | col = findCol + txt.length(); | 132 | col = findCol + txt.length(); |
133 | setCursorPosition( line, col, true ); | 133 | setCursorPosition( line, col, true ); |
134 | 134 | ||
135 | //found = true; | 135 | //found = true; |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | line++; | 138 | line++; |
139 | col = 0; | 139 | col = 0; |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | #else | 145 | #else |
146 | 146 | ||
147 | #error "Must make a QpeEditor that inherits QTextEdit" | 147 | #error "Must make a QpeEditor that inherits QTextEdit" |
148 | 148 | ||
149 | #endif | 149 | #endif |
150 | 150 | ||
151 | 151 | ||
152 | static const int nfontsizes = 6; | 152 | static const int nfontsizes = 6; |
153 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 153 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
154 | 154 | ||
155 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 155 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
156 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 156 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
157 | { | 157 | { |
158 | doc = 0; | 158 | doc = 0; |
159 | edited=false; | 159 | edited=false; |
160 | fromSetDocument=false; | 160 | fromSetDocument=false; |
161 | 161 | ||
162 | setToolBarsMovable( false ); | 162 | setToolBarsMovable( false ); |
163 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 163 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
164 | 164 | ||
165 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 165 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
166 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 166 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
167 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 167 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
168 | 168 | ||
169 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 169 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
170 | 170 | ||
171 | QToolBar *bar = new QToolBar( this ); | 171 | QToolBar *bar = new QToolBar( this ); |
172 | bar->setHorizontalStretchable( true ); | 172 | bar->setHorizontalStretchable( true ); |
173 | menu = bar; | 173 | menu = bar; |
174 | 174 | ||
175 | QMenuBar *mb = new QMenuBar( bar ); | 175 | QMenuBar *mb = new QMenuBar( bar ); |
176 | QPopupMenu *file = new QPopupMenu( this ); | 176 | QPopupMenu *file = new QPopupMenu( this ); |
177 | QPopupMenu *edit = new QPopupMenu( this ); | 177 | QPopupMenu *edit = new QPopupMenu( this ); |
178 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 178 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
179 | 179 | ||
180 | font = new QPopupMenu( this ); | 180 | font = new QPopupMenu( this ); |
181 | 181 | ||
182 | bar = new QToolBar( this ); | 182 | bar = new QToolBar( this ); |
183 | editBar = bar; | 183 | editBar = bar; |
184 | 184 | ||
185 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 185 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
186 | QString::null, 0, this, 0 ); | 186 | QString::null, 0, this, 0 ); |
187 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 187 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
188 | // a->addTo( bar ); | 188 | // a->addTo( bar ); |
189 | a->addTo( file ); | 189 | a->addTo( file ); |
190 | 190 | ||
191 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 191 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
192 | QString::null, 0, this, 0 ); | 192 | QString::null, 0, this, 0 ); |
193 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 193 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
194 | a->addTo( bar ); | 194 | a->addTo( bar ); |
195 | a->addTo( file ); | 195 | a->addTo( file ); |
196 | 196 | ||
197 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , | 197 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
198 | QString::null, 0, this, 0 ); | 198 | QString::null, 0, this, 0 ); |
199 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
200 | file->insertSeparator(); | 200 | file->insertSeparator(); |
201 | a->addTo( bar ); | 201 | a->addTo( bar ); |
202 | a->addTo( file ); | 202 | a->addTo( file ); |
203 | 203 | ||
204 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , | 204 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
205 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
206 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 206 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
207 | a->addTo( file ); | 207 | a->addTo( file ); |
208 | 208 | ||
209 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 209 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
210 | QString::null, 0, this, 0 ); | 210 | QString::null, 0, this, 0 ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 211 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
212 | a->addTo( editBar ); | 212 | a->addTo( editBar ); |
213 | a->addTo( edit ); | 213 | a->addTo( edit ); |
214 | 214 | ||
215 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 215 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
216 | QString::null, 0, this, 0 ); | 216 | QString::null, 0, this, 0 ); |
217 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 217 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
218 | a->addTo( editBar ); | 218 | a->addTo( editBar ); |
219 | a->addTo( edit ); | 219 | a->addTo( edit ); |
220 | 220 | ||
221 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 221 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
222 | QString::null, 0, this, 0 ); | 222 | QString::null, 0, this, 0 ); |
223 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 223 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
224 | a->addTo( editBar ); | 224 | a->addTo( editBar ); |
225 | a->addTo( edit ); | 225 | a->addTo( edit ); |
226 | 226 | ||
227 | 227 | ||
228 | #ifndef QT_NO_CLIPBOARD | 228 | #ifndef QT_NO_CLIPBOARD |
229 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 229 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
230 | QString::null, 0, this, 0 ); | 230 | QString::null, 0, this, 0 ); |
231 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 231 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
232 | a->addTo( edit ); | 232 | a->addTo( edit ); |
233 | #endif | 233 | #endif |
234 | 234 | ||
235 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 235 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
236 | QString::null, 0, this, 0 ); | 236 | QString::null, 0, this, 0 ); |
237 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 237 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
238 | edit->insertSeparator(); | 238 | edit->insertSeparator(); |
239 | a->addTo( edit ); | 239 | a->addTo( edit ); |
240 | 240 | ||
241 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 241 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
242 | QString::null, 0, this, 0 ); | 242 | QString::null, 0, this, 0 ); |
243 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 243 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
244 | a->addTo( bar ); | 244 | a->addTo( bar ); |
245 | a->addTo( edit ); | 245 | a->addTo( edit ); |
246 | 246 | ||
247 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 247 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
248 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 248 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
249 | zin->addTo( font ); | 249 | zin->addTo( font ); |
250 | 250 | ||
251 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 251 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
252 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 252 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
253 | zout->addTo( font ); | 253 | zout->addTo( font ); |
254 | 254 | ||
255 | font->insertSeparator(); | 255 | font->insertSeparator(); |
256 | 256 | ||
257 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 257 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
258 | 258 | ||
259 | font->insertSeparator(); | 259 | font->insertSeparator(); |
260 | font->insertItem(tr("Advanced Features"), advancedMenu); | 260 | font->insertItem(tr("Advanced Features"), advancedMenu); |
261 | 261 | ||
262 | QAction *wa = new QAction( tr("Wrap lines"), | 262 | QAction *wa = new QAction( tr("Wrap lines"), |
263 | QString::null, 0, this, 0 ); | 263 | QString::null, 0, this, 0 ); |
264 | connect( wa, SIGNAL( toggled(bool) ), | 264 | connect( wa, SIGNAL( toggled(bool) ), |
265 | this, SLOT( setWordWrap(bool) ) ); | 265 | this, SLOT( setWordWrap(bool) ) ); |
266 | wa->setToggleAction(true); | 266 | wa->setToggleAction(true); |
267 | wa->addTo( advancedMenu); | 267 | wa->addTo( advancedMenu); |
268 | 268 | ||
269 | nStart = new QAction( tr("Start with new file"), | 269 | nStart = new QAction( tr("Start with new file"), |
270 | QString::null, 0, this, 0 ); | 270 | QString::null, 0, this, 0 ); |
271 | connect( nStart, SIGNAL( toggled(bool) ), | 271 | connect( nStart, SIGNAL( toggled(bool) ), |
272 | this, SLOT( changeStartConfig(bool) ) ); | 272 | this, SLOT( changeStartConfig(bool) ) ); |
273 | nStart->setToggleAction(true); | 273 | nStart->setToggleAction(true); |
274 | nStart->addTo( advancedMenu ); | 274 | nStart->addTo( advancedMenu ); |
275 | nStart->setEnabled(false); | 275 | nStart->setEnabled(false); |
276 | 276 | ||
277 | nAdvanced = new QAction( tr("Prompt on Exit"), | 277 | nAdvanced = new QAction( tr("Prompt on Exit"), |
278 | QString::null, 0, this, 0 ); | 278 | QString::null, 0, this, 0 ); |
279 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 279 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
280 | this, SLOT( doPrompt(bool) ) ); | 280 | this, SLOT( doPrompt(bool) ) ); |
281 | nAdvanced->setToggleAction(true); | 281 | nAdvanced->setToggleAction(true); |
282 | nAdvanced->addTo( advancedMenu ); | 282 | nAdvanced->addTo( advancedMenu ); |
283 | 283 | ||
284 | desktopAction = new QAction( tr("Always open linked file"), | 284 | desktopAction = new QAction( tr("Always open linked file"), |
285 | QString::null, 0, this, 0 ); | 285 | QString::null, 0, this, 0 ); |
286 | connect( desktopAction, SIGNAL( toggled(bool) ), | 286 | connect( desktopAction, SIGNAL( toggled(bool) ), |
287 | this, SLOT( doDesktop(bool) ) ); | 287 | this, SLOT( doDesktop(bool) ) ); |
288 | desktopAction->setToggleAction(true); | 288 | desktopAction->setToggleAction(true); |
289 | desktopAction->addTo( advancedMenu); | 289 | desktopAction->addTo( advancedMenu); |
290 | 290 | ||
291 | filePermAction = new QAction( tr("File Permissions"), | 291 | filePermAction = new QAction( tr("File Permissions"), |
292 | QString::null, 0, this, 0 ); | 292 | QString::null, 0, this, 0 ); |
293 | connect( filePermAction, SIGNAL( toggled(bool) ), | 293 | connect( filePermAction, SIGNAL( toggled(bool) ), |
294 | this, SLOT( doFilePerms(bool) ) ); | 294 | this, SLOT( doFilePerms(bool) ) ); |
295 | filePermAction->setToggleAction(true); | 295 | filePermAction->setToggleAction(true); |
296 | filePermAction->addTo( advancedMenu); | 296 | filePermAction->addTo( advancedMenu); |
297 | 297 | ||
298 | searchBarAction = new QAction( tr("Search Bar Open"), | 298 | searchBarAction = new QAction( tr("Search Bar Open"), |
299 | QString::null, 0, this, 0 ); | 299 | QString::null, 0, this, 0 ); |
300 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 300 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
301 | this, SLOT( setSearchBar(bool) ) ); | 301 | this, SLOT( setSearchBar(bool) ) ); |
302 | searchBarAction->setToggleAction(true); | 302 | searchBarAction->setToggleAction(true); |
303 | searchBarAction->addTo( advancedMenu); | 303 | searchBarAction->addTo( advancedMenu); |
304 | 304 | ||
305 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 305 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
306 | QString::null, 0, this, 0 ); | 306 | QString::null, 0, this, 0 ); |
307 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 307 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
308 | this, SLOT( doTimer(bool) ) ); | 308 | this, SLOT( doTimer(bool) ) ); |
309 | nAutoSave->setToggleAction(true); | 309 | nAutoSave->setToggleAction(true); |
310 | nAutoSave->addTo( advancedMenu); | 310 | nAutoSave->addTo( advancedMenu); |
311 | 311 | ||
312 | 312 | ||
313 | //font->insertSeparator(); | 313 | //font->insertSeparator(); |
314 | 314 | ||
315 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 315 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
316 | 316 | ||
317 | mb->insertItem( tr( "File" ), file ); | 317 | mb->insertItem( tr( "File" ), file ); |
318 | mb->insertItem( tr( "Edit" ), edit ); | 318 | mb->insertItem( tr( "Edit" ), edit ); |
319 | mb->insertItem( tr( "View" ), font ); | 319 | mb->insertItem( tr( "View" ), font ); |
320 | 320 | ||
321 | searchBar = new QToolBar(this); | 321 | searchBar = new QToolBar(this); |
322 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 322 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
323 | 323 | ||
324 | searchBar->setHorizontalStretchable( true ); | 324 | searchBar->setHorizontalStretchable( true ); |
325 | 325 | ||
326 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 326 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
327 | searchBar->setStretchableWidget( searchEdit ); | 327 | searchBar->setStretchableWidget( searchEdit ); |
328 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 328 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), |
329 | this, SLOT( search() ) ); | 329 | this, SLOT( search() ) ); |
330 | 330 | ||
331 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 331 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
332 | QString::null, 0, this, 0 ); | 332 | QString::null, 0, this, 0 ); |
333 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 333 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
334 | a->addTo( searchBar ); | 334 | a->addTo( searchBar ); |
335 | a->addTo( edit ); | 335 | a->addTo( edit ); |
336 | 336 | ||
337 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 337 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
338 | QString::null, 0, this, 0 ); | 338 | QString::null, 0, this, 0 ); |
339 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 339 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
340 | a->addTo( searchBar ); | 340 | a->addTo( searchBar ); |
341 | 341 | ||
342 | edit->insertSeparator(); | 342 | edit->insertSeparator(); |
343 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 343 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
344 | QString::null, 0, this, 0 ); | 344 | QString::null, 0, this, 0 ); |
345 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 345 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
346 | a->addTo( edit ); | 346 | a->addTo( edit ); |
347 | 347 | ||
348 | searchBar->hide(); | 348 | searchBar->hide(); |
349 | 349 | ||
350 | editor = new QpeEditor( this ); | 350 | editor = new QpeEditor( this ); |
351 | setCentralWidget( editor ); | 351 | setCentralWidget( editor ); |
352 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 352 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
353 | connect( editor, SIGNAL( textChanged() ), | 353 | connect( editor, SIGNAL( textChanged() ), |
354 | this, SLOT( editorChanged() ) ); | 354 | this, SLOT( editorChanged() ) ); |
355 | 355 | ||
356 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 356 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
357 | 357 | ||
358 | Config cfg("TextEdit"); | 358 | Config cfg("TextEdit"); |
359 | cfg. setGroup ( "Font" ); | 359 | cfg. setGroup ( "Font" ); |
360 | 360 | ||
361 | QFont defaultFont = editor-> font ( ); | 361 | QFont defaultFont = editor-> font ( ); |
362 | 362 | ||
363 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 363 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
364 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 364 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
365 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 365 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
366 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 366 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
367 | 367 | ||
368 | defaultFont = QFont ( family, size, weight, italic ); | 368 | defaultFont = QFont ( family, size, weight, italic ); |
369 | editor-> setFont ( defaultFont ); | 369 | editor-> setFont ( defaultFont ); |
370 | // updateCaption(); | 370 | // updateCaption(); |
371 | 371 | ||
372 | cfg.setGroup ( "View" ); | 372 | cfg.setGroup ( "View" ); |
373 | 373 | ||
374 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 374 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
375 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 375 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
376 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 376 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
377 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 377 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
378 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 378 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
379 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 379 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
380 | 380 | ||
381 | if(useSearchBar) searchBarAction->setOn(true); | 381 | if(useSearchBar) searchBarAction->setOn(true); |
382 | if(promptExit) nAdvanced->setOn( true ); | 382 | if(promptExit) nAdvanced->setOn( true ); |
383 | if(openDesktop) desktopAction->setOn( true ); | 383 | if(openDesktop) desktopAction->setOn( true ); |
384 | if(filePerms) filePermAction->setOn( true ); | 384 | if(filePerms) filePermAction->setOn( true ); |
385 | if(startWithNew) nStart->setOn( true ); | 385 | if(startWithNew) nStart->setOn( true ); |
386 | if(featureAutoSave) nAutoSave->setOn(true); | 386 | if(featureAutoSave) nAutoSave->setOn(true); |
387 | 387 | ||
388 | // { | 388 | // { |
389 | // doTimer(true); | 389 | // doTimer(true); |
390 | // } | 390 | // } |
391 | 391 | ||
392 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 392 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
393 | wa-> setOn ( wrap ); | 393 | wa-> setOn ( wrap ); |
394 | setWordWrap ( wrap ); | 394 | setWordWrap ( wrap ); |
395 | 395 | ||
396 | ///////////////// | 396 | ///////////////// |
397 | if( qApp->argc() > 1) { | 397 | if( qApp->argc() > 1) { |
398 | currentFileName=qApp->argv()[1]; | 398 | currentFileName=qApp->argv()[1]; |
399 | 399 | ||
400 | QFileInfo fi(currentFileName); | 400 | QFileInfo fi(currentFileName); |
401 | 401 | ||
402 | if(fi.baseName().left(1) == "") { | 402 | if(fi.baseName().left(1) == "") { |
403 | openDotFile(currentFileName); | 403 | openDotFile(currentFileName); |
404 | } else { | 404 | } else { |
405 | openFile(currentFileName); | 405 | openFile(currentFileName); |
406 | } | 406 | } |
407 | } else { | 407 | } else { |
408 | edited1=false; | 408 | edited1=false; |
409 | openDotFile(""); | 409 | openDotFile(""); |
410 | } | 410 | } |
411 | 411 | ||
412 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 412 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
413 | } | 413 | } |
414 | 414 | ||
415 | TextEdit::~TextEdit() { | 415 | TextEdit::~TextEdit() { |
416 | qWarning("textedit d'tor"); | 416 | qWarning("textedit d'tor"); |
417 | delete editor; | 417 | delete editor; |
418 | } | 418 | } |
419 | 419 | ||
420 | void TextEdit::closeEvent(QCloseEvent *) { | 420 | void TextEdit::closeEvent(QCloseEvent *) { |
421 | if( edited1 && promptExit) | 421 | if( edited1 && promptExit) |
422 | { | 422 | { |
423 | switch( savePrompt() ) | 423 | switch( savePrompt() ) |
424 | { | 424 | { |
425 | case 1: | 425 | case 1: |
426 | { | 426 | { |
427 | saveAs(); | 427 | saveAs(); |
428 | qApp->quit(); | 428 | qApp->quit(); |
429 | } | 429 | } |
430 | break; | 430 | break; |
431 | 431 | ||
432 | case 2: | 432 | case 2: |
433 | { | 433 | { |
434 | qApp->quit(); | 434 | qApp->quit(); |
435 | } | 435 | } |
436 | break; | 436 | break; |
437 | 437 | ||
438 | case -1: | 438 | case -1: |
439 | break; | 439 | break; |
440 | }; | 440 | }; |
441 | } | 441 | } |
442 | else | 442 | else |
443 | qApp->quit(); | 443 | qApp->quit(); |
444 | 444 | ||
445 | } | 445 | } |
446 | 446 | ||
447 | void TextEdit::cleanUp() { | 447 | void TextEdit::cleanUp() { |
448 | 448 | ||
449 | Config cfg ( "TextEdit" ); | 449 | Config cfg ( "TextEdit" ); |
450 | cfg. setGroup ( "Font" ); | 450 | cfg. setGroup ( "Font" ); |
451 | QFont f = editor->font(); | 451 | QFont f = editor->font(); |
452 | cfg.writeEntry ( "Family", f. family ( )); | 452 | cfg.writeEntry ( "Family", f. family ( )); |
453 | cfg.writeEntry ( "Size", f. pointSize ( )); | 453 | cfg.writeEntry ( "Size", f. pointSize ( )); |
454 | cfg.writeEntry ( "Weight", f. weight ( )); | 454 | cfg.writeEntry ( "Weight", f. weight ( )); |
455 | cfg.writeEntry ( "Italic", f. italic ( )); | 455 | cfg.writeEntry ( "Italic", f. italic ( )); |
456 | 456 | ||
457 | cfg.setGroup ( "View" ); | 457 | cfg.setGroup ( "View" ); |
458 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 458 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
459 | cfg.writeEntry ( "FileView", viewSelection ); | 459 | cfg.writeEntry ( "FileView", viewSelection ); |
460 | 460 | ||
461 | cfg.writeEntry ( "PromptExit", promptExit ); | 461 | cfg.writeEntry ( "PromptExit", promptExit ); |
462 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 462 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
463 | cfg.writeEntry ( "FilePermissions", filePerms ); | 463 | cfg.writeEntry ( "FilePermissions", filePerms ); |
464 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 464 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
465 | cfg.writeEntry ( "startNew", startWithNew ); | 465 | cfg.writeEntry ( "startNew", startWithNew ); |
466 | 466 | ||
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
470 | void TextEdit::accept() { | 470 | void TextEdit::accept() { |
471 | if( edited1) | 471 | if( edited1) |
472 | saveAs(); | 472 | saveAs(); |
473 | qApp->quit(); | 473 | qApp->quit(); |
474 | } | 474 | } |
475 | 475 | ||
476 | void TextEdit::zoomIn() { | 476 | void TextEdit::zoomIn() { |
477 | setFontSize(editor->font().pointSize()+1,false); | 477 | setFontSize(editor->font().pointSize()+1,false); |
478 | } | 478 | } |
479 | 479 | ||
480 | void TextEdit::zoomOut() { | 480 | void TextEdit::zoomOut() { |
481 | setFontSize(editor->font().pointSize()-1,true); | 481 | setFontSize(editor->font().pointSize()-1,true); |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 485 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
486 | int s=10; | 486 | int s=10; |
487 | for (int i=0; i<nfontsizes; i++) { | 487 | for (int i=0; i<nfontsizes; i++) { |
488 | if ( fontsize[i] == sz ) { | 488 | if ( fontsize[i] == sz ) { |
489 | s = sz; | 489 | s = sz; |
490 | break; | 490 | break; |
491 | } else if ( round_down_not_up ) { | 491 | } else if ( round_down_not_up ) { |
492 | if ( fontsize[i] < sz ) | 492 | if ( fontsize[i] < sz ) |
493 | s = fontsize[i]; | 493 | s = fontsize[i]; |
494 | } else { | 494 | } else { |
495 | if ( fontsize[i] > sz ) { | 495 | if ( fontsize[i] > sz ) { |
496 | s = fontsize[i]; | 496 | s = fontsize[i]; |
497 | break; | 497 | break; |
498 | } | 498 | } |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | QFont f = editor->font(); | 502 | QFont f = editor->font(); |
503 | f.setPointSize(s); | 503 | f.setPointSize(s); |
504 | editor->setFont(f); | 504 | editor->setFont(f); |
505 | 505 | ||
506 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 506 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
507 | zout->setEnabled(s != fontsize[0]); | 507 | zout->setEnabled(s != fontsize[0]); |
508 | } | 508 | } |
509 | 509 | ||
510 | void TextEdit::setBold(bool y) { | 510 | void TextEdit::setBold(bool y) { |
511 | QFont f = editor->font(); | 511 | QFont f = editor->font(); |
512 | f.setBold(y); | 512 | f.setBold(y); |
513 | editor->setFont(f); | 513 | editor->setFont(f); |
514 | } | 514 | } |
515 | 515 | ||
516 | void TextEdit::setItalic(bool y) { | 516 | void TextEdit::setItalic(bool y) { |
517 | QFont f = editor->font(); | 517 | QFont f = editor->font(); |
518 | f.setItalic(y); | 518 | f.setItalic(y); |
519 | editor->setFont(f); | 519 | editor->setFont(f); |
520 | } | 520 | } |
521 | 521 | ||
522 | void TextEdit::setWordWrap(bool y) { | 522 | void TextEdit::setWordWrap(bool y) { |
523 | bool state = editor->edited(); | 523 | bool state = editor->edited(); |
524 | QString captionStr = caption(); | 524 | QString captionStr = caption(); |
525 | bool b1 = edited1; | 525 | bool b1 = edited1; |
526 | bool b2 = edited; | 526 | bool b2 = edited; |
527 | 527 | ||
528 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 528 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
529 | editor->setEdited( state ); | 529 | editor->setEdited( state ); |
530 | edited1=b1; | 530 | edited1=b1; |
531 | edited=b2; | 531 | edited=b2; |
532 | setCaption(captionStr); | 532 | setCaption(captionStr); |
533 | } | 533 | } |
534 | 534 | ||
535 | void TextEdit::setSearchBar(bool b) { | 535 | void TextEdit::setSearchBar(bool b) { |
536 | useSearchBar=b; | 536 | useSearchBar=b; |
537 | Config cfg("TextEdit"); | 537 | Config cfg("TextEdit"); |
538 | cfg.setGroup("View"); | 538 | cfg.setGroup("View"); |
539 | cfg.writeEntry ( "SearchBar", b ); | 539 | cfg.writeEntry ( "SearchBar", b ); |
540 | searchBarAction->setOn(b); | 540 | searchBarAction->setOn(b); |
541 | if(b) | 541 | if(b) |
542 | searchBar->show(); | 542 | searchBar->show(); |
543 | else | 543 | else |
544 | searchBar->hide(); | 544 | searchBar->hide(); |
545 | editor->setFocus(); | 545 | editor->setFocus(); |
546 | } | 546 | } |
547 | 547 | ||
548 | void TextEdit::fileNew() { | 548 | void TextEdit::fileNew() { |
549 | // if( !bFromDocView ) { | 549 | // if( !bFromDocView ) { |
550 | // saveAs(); | 550 | // saveAs(); |
551 | // } | 551 | // } |
552 | newFile(DocLnk()); | 552 | newFile(DocLnk()); |
553 | } | 553 | } |
554 | 554 | ||
555 | void TextEdit::fileOpen() { | 555 | void TextEdit::fileOpen() { |
556 | Config cfg("TextEdit"); | 556 | Config cfg("TextEdit"); |
557 | cfg. setGroup ( "View" ); | 557 | cfg. setGroup ( "View" ); |
558 | QMap<QString, QStringList> map; | 558 | QMap<QString, QStringList> map; |
559 | map.insert(tr("All"), QStringList() ); | 559 | map.insert(tr("All"), QStringList() ); |
560 | QStringList text; | 560 | QStringList text; |
561 | text << "text/*"; | 561 | text << "text/*"; |
562 | map.insert(tr("Text"), text ); | 562 | map.insert(tr("Text"), text ); |
563 | text << "*"; | 563 | text << "*"; |
564 | map.insert(tr("All"), text ); | 564 | map.insert(tr("All"), text ); |
565 | QString str = OFileDialog::getOpenFileName( 2, | 565 | QString str = OFileDialog::getOpenFileName( 2, |
566 | QString::null , | 566 | QString::null , |
567 | QString::null, map); | 567 | QString::null, map); |
568 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 568 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
569 | { | 569 | { |
570 | openFile( str ); | 570 | openFile( str ); |
571 | } | 571 | } |
572 | else | 572 | else |
573 | updateCaption(); | 573 | updateCaption(); |
574 | } | 574 | } |
575 | 575 | ||
576 | void TextEdit::doSearchBar() { | 576 | void TextEdit::doSearchBar() { |
577 | if(!useSearchBar) | 577 | if(!useSearchBar) |
578 | searchBar->hide(); | 578 | searchBar->hide(); |
579 | else | 579 | else |
580 | searchBar->show(); | 580 | searchBar->show(); |
581 | } | 581 | } |
582 | 582 | ||
583 | #if 0 | 583 | #if 0 |
584 | void TextEdit::slotFind() { | 584 | void TextEdit::slotFind() { |
585 | FindDialog frmFind( tr("Text Editor"), this ); | 585 | FindDialog frmFind( tr("Text Editor"), this ); |
586 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 586 | connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)), |
587 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 587 | editor, SLOT(slotDoFind(const QString&,bool,bool))); |
588 | 588 | ||
589 | //case sensitive, backwards, [category] | 589 | //case sensitive, backwards, [category] |
590 | 590 | ||
591 | connect( editor, SIGNAL(notFound()), | 591 | connect( editor, SIGNAL(notFound()), |
592 | &frmFind, SLOT(slotNotFound()) ); | 592 | &frmFind, SLOT(slotNotFound()) ); |
593 | connect( editor, SIGNAL(searchWrapped()), | 593 | connect( editor, SIGNAL(searchWrapped()), |
594 | &frmFind, SLOT(slotWrapAround()) ); | 594 | &frmFind, SLOT(slotWrapAround()) ); |
595 | 595 | ||
596 | frmFind.exec(); | 596 | frmFind.exec(); |
597 | 597 | ||
598 | 598 | ||
599 | } | 599 | } |
600 | #endif | 600 | #endif |
601 | 601 | ||
602 | void TextEdit::fileRevert() { | 602 | void TextEdit::fileRevert() { |
603 | clear(); | 603 | clear(); |
604 | fileOpen(); | 604 | fileOpen(); |
605 | } | 605 | } |
606 | 606 | ||
607 | void TextEdit::editCut() { | 607 | void TextEdit::editCut() { |
608 | #ifndef QT_NO_CLIPBOARD | 608 | #ifndef QT_NO_CLIPBOARD |
609 | editor->cut(); | 609 | editor->cut(); |
610 | #endif | 610 | #endif |
611 | } | 611 | } |
612 | 612 | ||
613 | void TextEdit::editCopy() { | 613 | void TextEdit::editCopy() { |
614 | #ifndef QT_NO_CLIPBOARD | 614 | #ifndef QT_NO_CLIPBOARD |
615 | editor->copy(); | 615 | editor->copy(); |
616 | #endif | 616 | #endif |
617 | } | 617 | } |
618 | 618 | ||
619 | void TextEdit::editPaste() { | 619 | void TextEdit::editPaste() { |
620 | #ifndef QT_NO_CLIPBOARD | 620 | #ifndef QT_NO_CLIPBOARD |
621 | editor->paste(); | 621 | editor->paste(); |
622 | #endif | 622 | #endif |
623 | } | 623 | } |
624 | 624 | ||
625 | void TextEdit::editFind() { | 625 | void TextEdit::editFind() { |
626 | searchBar->show(); | 626 | searchBar->show(); |
627 | searchEdit->setFocus(); | 627 | searchEdit->setFocus(); |
628 | } | 628 | } |
629 | 629 | ||
630 | void TextEdit::findNext() { | 630 | void TextEdit::findNext() { |
631 | editor->find( searchEdit->text(), false, false ); | 631 | editor->find( searchEdit->text(), false, false ); |
632 | 632 | ||
633 | } | 633 | } |
634 | 634 | ||
635 | void TextEdit::findClose() { | 635 | void TextEdit::findClose() { |
636 | searchBar->hide(); | 636 | searchBar->hide(); |
637 | } | 637 | } |
638 | 638 | ||
639 | void TextEdit::search() { | 639 | void TextEdit::search() { |
640 | editor->find( searchEdit->text(), false, false ); | 640 | editor->find( searchEdit->text(), false, false ); |
641 | } | 641 | } |
642 | 642 | ||
643 | void TextEdit::newFile( const DocLnk &f ) { | 643 | void TextEdit::newFile( const DocLnk &f ) { |
644 | DocLnk nf = f; | 644 | DocLnk nf = f; |
645 | nf.setType("text/plain"); | 645 | nf.setType("text/plain"); |
646 | clear(); | 646 | clear(); |
647 | setWState (WState_Reserved1 ); | 647 | setWState (WState_Reserved1 ); |
648 | editor->setFocus(); | 648 | editor->setFocus(); |
649 | doc = new DocLnk(nf); | 649 | doc = new DocLnk(nf); |
650 | currentFileName = "Unnamed"; | 650 | currentFileName = "Unnamed"; |
651 | qDebug("newFile "+currentFileName); | 651 | qDebug("newFile "+currentFileName); |
652 | updateCaption( currentFileName); | 652 | updateCaption( currentFileName); |
653 | // editor->setEdited( false); | 653 | // editor->setEdited( false); |
654 | } | 654 | } |
655 | 655 | ||
656 | void TextEdit::openDotFile( const QString &f ) { | 656 | void TextEdit::openDotFile( const QString &f ) { |
657 | if(!currentFileName.isEmpty()) { | 657 | if(!currentFileName.isEmpty()) { |
658 | currentFileName=f; | 658 | currentFileName=f; |
659 | 659 | ||
660 | qDebug("openFile dotfile " + currentFileName); | 660 | qDebug("openFile dotfile " + currentFileName); |
661 | QString txt; | 661 | QString txt; |
662 | QFile file(f); | 662 | QFile file(f); |
663 | file.open(IO_ReadWrite); | 663 | file.open(IO_ReadWrite); |
664 | QTextStream t(&file); | 664 | QTextStream t(&file); |
665 | while ( !t.atEnd()) { | 665 | while ( !t.atEnd()) { |
666 | txt+=t.readLine()+"\n"; | 666 | txt+=t.readLine()+"\n"; |
667 | } | 667 | } |
668 | editor->setText(txt); | 668 | editor->setText(txt); |
669 | editor->setEdited( false); | 669 | editor->setEdited( false); |
670 | edited1=false; | 670 | edited1=false; |
671 | edited=false; | 671 | edited=false; |
672 | 672 | ||
673 | 673 | ||
674 | } | 674 | } |
675 | updateCaption( currentFileName); | 675 | updateCaption( currentFileName); |
676 | } | 676 | } |
677 | 677 | ||
678 | void TextEdit::openFile( const QString &f ) { | 678 | void TextEdit::openFile( const QString &f ) { |
679 | qDebug("filename is "+ f); | 679 | qDebug("filename is "+ f); |
680 | QString filer; | 680 | QString filer; |
681 | QFileInfo fi( f); | 681 | QFileInfo fi( f); |
682 | // bFromDocView = true; | 682 | // bFromDocView = true; |
683 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 683 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
684 | { | 684 | { |
685 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) | 685 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
686 | { | 686 | { |
687 | case 0: //desktop | 687 | case 0: //desktop |
688 | filer = f; | 688 | filer = f; |
689 | break; | 689 | break; |
690 | case 1: //linked | 690 | case 1: //linked |
691 | DocLnk sf(f); | 691 | DocLnk sf(f); |
692 | filer = sf.file(); | 692 | filer = sf.file(); |
693 | break; | 693 | break; |
694 | }; | 694 | }; |
695 | } | 695 | } |
696 | else if(fi.baseName().left(1) == "") | 696 | else if(fi.baseName().left(1) == "") |
697 | { | 697 | { |
698 | qDebug("opening dotfile"); | 698 | qDebug("opening dotfile"); |
699 | currentFileName=f; | 699 | currentFileName=f; |
700 | openDotFile(currentFileName); | 700 | openDotFile(currentFileName); |
701 | return; | 701 | return; |
702 | } | 702 | } |
703 | /* | 703 | /* |
704 | * The problem is a file where Config(f).isValid() and it does not | 704 | * The problem is a file where Config(f).isValid() and it does not |
705 | * end with .desktop will be treated as desktop file | 705 | * end with .desktop will be treated as desktop file |
706 | */ | 706 | */ |
707 | else if (f.find(".desktop",0,true) != -1 ) | 707 | else if (f.find(".desktop",0,true) != -1 ) |
708 | { | 708 | { |
709 | DocLnk sf(f); | 709 | DocLnk sf(f); |
710 | filer = sf.file(); | 710 | filer = sf.file(); |
711 | if(filer.right(1) == "/") | 711 | if(filer.right(1) == "/") |
712 | filer = f; | 712 | filer = f; |
713 | 713 | ||
714 | } | 714 | } |
715 | else | 715 | else |
716 | filer = f; | 716 | filer = f; |
717 | 717 | ||
718 | DocLnk nf; | 718 | DocLnk nf; |
719 | nf.setType("text/plain"); | 719 | nf.setType("text/plain"); |
720 | nf.setFile(filer); | 720 | nf.setFile(filer); |
721 | currentFileName=filer; | 721 | currentFileName=filer; |
722 | 722 | ||
723 | nf.setName(fi.baseName()); | 723 | nf.setName(fi.baseName()); |
724 | openFile(nf); | 724 | openFile(nf); |
725 | 725 | ||
726 | qDebug("openFile string "+currentFileName); | 726 | qDebug("openFile string "+currentFileName); |
727 | 727 | ||
728 | showEditTools(); | 728 | showEditTools(); |
729 | // Show filename in caption | 729 | // Show filename in caption |
730 | QString name = filer; | 730 | QString name = filer; |
731 | int sep = name.findRev( '/' ); | 731 | int sep = name.findRev( '/' ); |
732 | if ( sep > 0 ) | 732 | if ( sep > 0 ) |
733 | name = name.mid( sep+1 ); | 733 | name = name.mid( sep+1 ); |
734 | updateCaption( name ); | 734 | updateCaption( name ); |
735 | } | 735 | } |
736 | 736 | ||
737 | void TextEdit::openFile( const DocLnk &f ) { | 737 | void TextEdit::openFile( const DocLnk &f ) { |
738 | // clear(); | 738 | // clear(); |
739 | // bFromDocView = true; | 739 | // bFromDocView = true; |
740 | FileManager fm; | 740 | FileManager fm; |
741 | QString txt; | 741 | QString txt; |
742 | currentFileName=f.file(); | 742 | currentFileName=f.file(); |
743 | qDebug("openFile doclnk " + currentFileName); | 743 | qDebug("openFile doclnk " + currentFileName); |
744 | if ( !fm.loadFile( f, txt ) ) { | 744 | if ( !fm.loadFile( f, txt ) ) { |
745 | // ####### could be a new file | 745 | // ####### could be a new file |
746 | qDebug( "Cannot open file" ); | 746 | qDebug( "Cannot open file" ); |
747 | } | 747 | } |
748 | // fileNew(); | 748 | // fileNew(); |
749 | if ( doc ) | 749 | if ( doc ) |
750 | delete doc; | 750 | delete doc; |
751 | doc = new DocLnk(f); | 751 | doc = new DocLnk(f); |
752 | editor->setText(txt); | 752 | editor->setText(txt); |
753 | editor->setEdited( false); | 753 | editor->setEdited( false); |
754 | edited1=false; | 754 | edited1=false; |
755 | edited=false; | 755 | edited=false; |
756 | 756 | ||
757 | doc->setName(currentFileName); | 757 | doc->setName(currentFileName); |
758 | updateCaption(); | 758 | updateCaption(); |
759 | setTimer(); | 759 | setTimer(); |
760 | } | 760 | } |
761 | 761 | ||
762 | void TextEdit::showEditTools() { | 762 | void TextEdit::showEditTools() { |
763 | menu->show(); | 763 | menu->show(); |
764 | editBar->show(); | 764 | editBar->show(); |
765 | if(!useSearchBar) | 765 | if(!useSearchBar) |
766 | searchBar->hide(); | 766 | searchBar->hide(); |
767 | else | 767 | else |
768 | searchBar->show(); | 768 | searchBar->show(); |
769 | setWState (WState_Reserved1 ); | 769 | setWState (WState_Reserved1 ); |
770 | } | 770 | } |
771 | 771 | ||
772 | /*! | 772 | /*! |
773 | unprompted save */ | 773 | unprompted save */ |
774 | bool TextEdit::save() { | 774 | bool TextEdit::save() { |
775 | qDebug("saveAsFile " + currentFileName); | 775 | qDebug("saveAsFile " + currentFileName); |
776 | if(currentFileName.isEmpty()) { | 776 | if(currentFileName.isEmpty()) { |
777 | saveAs(); | 777 | saveAs(); |
778 | return false; | 778 | return false; |
779 | } | 779 | } |
diff --git a/core/launcher/appicons.cpp b/core/launcher/appicons.cpp index c51ee5a..4d48b24 100644 --- a/core/launcher/appicons.cpp +++ b/core/launcher/appicons.cpp | |||
@@ -1,129 +1,131 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | 21 | ||
22 | #include "appicons.h" | 22 | #include "appicons.h" |
23 | 23 | ||
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #ifdef QWS |
25 | #include <qtopia/qcopenvelope_qws.h> | ||
26 | #endif | ||
25 | 27 | ||
26 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
27 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
28 | 30 | ||
29 | 31 | ||
30 | AppIcons::AppIcons( QWidget *parent ) : | 32 | AppIcons::AppIcons( QWidget *parent ) : |
31 | QHBox(parent) | 33 | QHBox(parent) |
32 | { | 34 | { |
33 | buttons.setAutoDelete(TRUE); | 35 | buttons.setAutoDelete(TRUE); |
34 | 36 | ||
35 | #ifndef QT_NO_COP | 37 | #ifndef QT_NO_COP |
36 | QCopChannel* channel = new QCopChannel("Qt/Tray", this); | 38 | QCopChannel* channel = new QCopChannel("Qt/Tray", this); |
37 | connect(channel, SIGNAL(received(const QCString&, const QByteArray&)), | 39 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
38 | this, SLOT(receive(const QCString&, const QByteArray&))); | 40 | this, SLOT(receive(const QCString&,const QByteArray&))); |
39 | #endif | 41 | #endif |
40 | } | 42 | } |
41 | 43 | ||
42 | void AppIcons::setIcon(int id, const QPixmap& pm) | 44 | void AppIcons::setIcon(int id, const QPixmap& pm) |
43 | { | 45 | { |
44 | button(id)->setPixmap(pm); | 46 | button(id)->setPixmap(pm); |
45 | } | 47 | } |
46 | 48 | ||
47 | class FlatButton : public QLabel { | 49 | class FlatButton : public QLabel { |
48 | Q_OBJECT | 50 | Q_OBJECT |
49 | public: | 51 | public: |
50 | FlatButton(QWidget* parent) : QLabel(parent) { } | 52 | FlatButton(QWidget* parent) : QLabel(parent) { } |
51 | 53 | ||
52 | void mouseDoubleClickEvent(QMouseEvent* e) | 54 | void mouseDoubleClickEvent(QMouseEvent* e) |
53 | { | 55 | { |
54 | emit clicked(e->pos(),e->button(),TRUE); | 56 | emit clicked(e->pos(),e->button(),TRUE); |
55 | } | 57 | } |
56 | void mouseReleaseEvent(QMouseEvent* e) | 58 | void mouseReleaseEvent(QMouseEvent* e) |
57 | { | 59 | { |
58 | if ( rect().contains(e->pos()) ) | 60 | if ( rect().contains(e->pos()) ) |
59 | emit clicked(e->pos(),e->button(),FALSE); | 61 | emit clicked(e->pos(),e->button(),FALSE); |
60 | } | 62 | } |
61 | 63 | ||
62 | signals: | 64 | signals: |
63 | void clicked(const QPoint&, int, bool); | 65 | void clicked(const QPoint&, int, bool); |
64 | }; | 66 | }; |
65 | 67 | ||
66 | QLabel* AppIcons::button(int id) | 68 | QLabel* AppIcons::button(int id) |
67 | { | 69 | { |
68 | QLabel* f = buttons.find(id); | 70 | QLabel* f = buttons.find(id); |
69 | if ( !f ) { | 71 | if ( !f ) { |
70 | buttons.insert(id,f=new FlatButton(this)); | 72 | buttons.insert(id,f=new FlatButton(this)); |
71 | connect(f,SIGNAL(clicked(const QPoint&, int, bool)),this,SLOT(clicked(const QPoint&, int, bool))); | 73 | connect(f,SIGNAL(clicked(const QPoint&,int,bool)),this,SLOT(clicked(const QPoint&,int,bool))); |
72 | f->show(); | 74 | f->show(); |
73 | } | 75 | } |
74 | return f; | 76 | return f; |
75 | } | 77 | } |
76 | 78 | ||
77 | int AppIcons::findId(QLabel* b) | 79 | int AppIcons::findId(QLabel* b) |
78 | { | 80 | { |
79 | QIntDictIterator<QLabel> it(buttons); | 81 | QIntDictIterator<QLabel> it(buttons); |
80 | for ( ; ; ++it ) | 82 | for ( ; ; ++it ) |
81 | if ( it.current() == b ) return it.currentKey(); | 83 | if ( it.current() == b ) return it.currentKey(); |
82 | } | 84 | } |
83 | 85 | ||
84 | void AppIcons::clicked(const QPoint& relpos, int button, bool dbl) | 86 | void AppIcons::clicked(const QPoint& relpos, int button, bool dbl) |
85 | { | 87 | { |
86 | #ifndef QT_NO_COP | 88 | #ifndef QT_NO_COP |
87 | QLabel* s = (QLabel*)sender(); | 89 | QLabel* s = (QLabel*)sender(); |
88 | if ( button == RightButton ) { | 90 | if ( button == RightButton ) { |
89 | QCopEnvelope("Qt/Tray","popup(int,QPoint)") | 91 | QCopEnvelope("Qt/Tray","popup(int,QPoint)") |
90 | << findId(s) << s->mapToGlobal(QPoint(0,0)); | 92 | << findId(s) << s->mapToGlobal(QPoint(0,0)); |
91 | } else { | 93 | } else { |
92 | QCopEnvelope("Qt/Tray", | 94 | QCopEnvelope("Qt/Tray", |
93 | dbl ? "doubleClicked(int,QPoint)" : "clicked(int,QPoint)") | 95 | dbl ? "doubleClicked(int,QPoint)" : "clicked(int,QPoint)") |
94 | << findId(s) << relpos; | 96 | << findId(s) << relpos; |
95 | } | 97 | } |
96 | #endif | 98 | #endif |
97 | } | 99 | } |
98 | 100 | ||
99 | void AppIcons::setToolTip(int id, const QString& tip) | 101 | void AppIcons::setToolTip(int id, const QString& tip) |
100 | { | 102 | { |
101 | QToolTip::add(button(id),tip); | 103 | QToolTip::add(button(id),tip); |
102 | } | 104 | } |
103 | 105 | ||
104 | void AppIcons::remove(int id) | 106 | void AppIcons::remove(int id) |
105 | { | 107 | { |
106 | buttons.remove(id); | 108 | buttons.remove(id); |
107 | } | 109 | } |
108 | 110 | ||
109 | void AppIcons::receive( const QCString &msg, const QByteArray &data ) | 111 | void AppIcons::receive( const QCString &msg, const QByteArray &data ) |
110 | { | 112 | { |
111 | QDataStream stream( data, IO_ReadOnly ); | 113 | QDataStream stream( data, IO_ReadOnly ); |
112 | if ( msg == "remove(int)" ) { | 114 | if ( msg == "remove(int)" ) { |
113 | int id; | 115 | int id; |
114 | stream >> id; | 116 | stream >> id; |
115 | remove(id); | 117 | remove(id); |
116 | } else if ( msg == "setIcon(int,QPixmap)" ) { | 118 | } else if ( msg == "setIcon(int,QPixmap)" ) { |
117 | int id; | 119 | int id; |
118 | QPixmap pm; | 120 | QPixmap pm; |
119 | stream >> id >> pm; | 121 | stream >> id >> pm; |
120 | setIcon(id,pm); | 122 | setIcon(id,pm); |
121 | } else if ( msg == "setToolTip(int,QString)" ) { | 123 | } else if ( msg == "setToolTip(int,QString)" ) { |
122 | int id; | 124 | int id; |
123 | QString s; | 125 | QString s; |
124 | stream >> id >> s; | 126 | stream >> id >> s; |
125 | setToolTip(id,s); | 127 | setToolTip(id,s); |
126 | } | 128 | } |
127 | } | 129 | } |
128 | 130 | ||
129 | #include "appicons.moc" | 131 | #include "appicons.moc" |
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp index 7d3c032..08a3cb4 100644 --- a/core/launcher/applauncher.cpp +++ b/core/launcher/applauncher.cpp | |||
@@ -1,286 +1,286 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef QTOPIA_INTERNAL_PRELOADACCESS | 21 | #ifndef QTOPIA_INTERNAL_PRELOADACCESS |
22 | #define QTOPIA_INTERNAL_PRELOADACCESS | 22 | #define QTOPIA_INTERNAL_PRELOADACCESS |
23 | #endif | 23 | #endif |
24 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS | 24 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS |
25 | #define QTOPIA_INTERNAL_FILEOPERATIONS | 25 | #define QTOPIA_INTERNAL_FILEOPERATIONS |
26 | #endif | 26 | #endif |
27 | #ifndef QTOPIA_PROGRAM_MONITOR | 27 | #ifndef QTOPIA_PROGRAM_MONITOR |
28 | #define QTOPIA_PROGRAM_MONITOR | 28 | #define QTOPIA_PROGRAM_MONITOR |
29 | #endif | 29 | #endif |
30 | #include <opie2/oglobal.h> | 30 | #include <opie2/oglobal.h> |
31 | 31 | ||
32 | #ifndef Q_OS_WIN32 | 32 | #ifndef Q_OS_WIN32 |
33 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
34 | #include <sys/wait.h> | 34 | #include <sys/wait.h> |
35 | #include <sys/file.h> | 35 | #include <sys/file.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <sys/time.h> | 37 | #include <sys/time.h> |
38 | #include <sys/resource.h> | 38 | #include <sys/resource.h> |
39 | #include <errno.h> | 39 | #include <errno.h> |
40 | #else | 40 | #else |
41 | #include <process.h> | 41 | #include <process.h> |
42 | #include <windows.h> | 42 | #include <windows.h> |
43 | #include <winbase.h> | 43 | #include <winbase.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include <signal.h> | 46 | #include <signal.h> |
47 | #include <sys/types.h> | 47 | #include <sys/types.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | #include <qtimer.h> | 50 | #include <qtimer.h> |
51 | #include <qwindowsystem_qws.h> | 51 | #include <qwindowsystem_qws.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qfileinfo.h> | 53 | #include <qfileinfo.h> |
54 | 54 | ||
55 | #include <qtopia/qcopenvelope_qws.h> | 55 | #include <qtopia/qcopenvelope_qws.h> |
56 | #include <qtopia/qpeapplication.h> | 56 | #include <qtopia/qpeapplication.h> |
57 | 57 | ||
58 | #include "applauncher.h" | 58 | #include "applauncher.h" |
59 | #include "documentlist.h" | 59 | #include "documentlist.h" |
60 | 60 | ||
61 | const int AppLauncher::RAISE_TIMEOUT_MS = 5000; | 61 | const int AppLauncher::RAISE_TIMEOUT_MS = 5000; |
62 | 62 | ||
63 | //--------------------------------------------------------------------------- | 63 | //--------------------------------------------------------------------------- |
64 | 64 | ||
65 | static AppLauncher* appLauncherPtr; | 65 | static AppLauncher* appLauncherPtr; |
66 | 66 | ||
67 | const int appStopEventID = 1290; | 67 | const int appStopEventID = 1290; |
68 | 68 | ||
69 | class AppStoppedEvent : public QCustomEvent | 69 | class AppStoppedEvent : public QCustomEvent |
70 | { | 70 | { |
71 | public: | 71 | public: |
72 | AppStoppedEvent(int pid, int status) | 72 | AppStoppedEvent(int pid, int status) |
73 | : QCustomEvent( appStopEventID ), mPid(pid), mStatus(status) { } | 73 | : QCustomEvent( appStopEventID ), mPid(pid), mStatus(status) { } |
74 | 74 | ||
75 | int pid() { return mPid; } | 75 | int pid() { return mPid; } |
76 | int status() { return mStatus; } | 76 | int status() { return mStatus; } |
77 | 77 | ||
78 | private: | 78 | private: |
79 | int mPid, mStatus; | 79 | int mPid, mStatus; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | AppLauncher::AppLauncher(QObject *parent, const char *name) | 82 | AppLauncher::AppLauncher(QObject *parent, const char *name) |
83 | : QObject(parent, name), qlPid(0), qlReady(FALSE), | 83 | : QObject(parent, name), qlPid(0), qlReady(FALSE), |
84 | appKillerBox(0) | 84 | appKillerBox(0) |
85 | { | 85 | { |
86 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); | 86 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); |
87 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); | 87 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); |
88 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 88 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
89 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 89 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
90 | this, SLOT(received(const QCString&, const QByteArray&)) ); | 90 | this, SLOT(received(const QCString&,const QByteArray&)) ); |
91 | 91 | ||
92 | channel = new QCopChannel( "QPE/Server", this ); | 92 | channel = new QCopChannel( "QPE/Server", this ); |
93 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 93 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
94 | this, SLOT(received(const QCString&, const QByteArray&)) ); | 94 | this, SLOT(received(const QCString&,const QByteArray&)) ); |
95 | 95 | ||
96 | #ifndef Q_OS_WIN32 | 96 | #ifndef Q_OS_WIN32 |
97 | signal(SIGCHLD, signalHandler); | 97 | signal(SIGCHLD, signalHandler); |
98 | #else | 98 | #else |
99 | runningAppsProc.setAutoDelete( TRUE ); | 99 | runningAppsProc.setAutoDelete( TRUE ); |
100 | #endif | 100 | #endif |
101 | QString tmp = qApp->argv()[0]; | 101 | QString tmp = qApp->argv()[0]; |
102 | int pos = tmp.findRev('/'); | 102 | int pos = tmp.findRev('/'); |
103 | if ( pos > -1 ) | 103 | if ( pos > -1 ) |
104 | tmp = tmp.mid(++pos); | 104 | tmp = tmp.mid(++pos); |
105 | runningApps[::getpid()] = tmp; | 105 | runningApps[::getpid()] = tmp; |
106 | 106 | ||
107 | appLauncherPtr = this; | 107 | appLauncherPtr = this; |
108 | 108 | ||
109 | QTimer::singleShot( 1000, this, SLOT(createQuickLauncher()) ); | 109 | QTimer::singleShot( 1000, this, SLOT(createQuickLauncher()) ); |
110 | } | 110 | } |
111 | 111 | ||
112 | AppLauncher::~AppLauncher() | 112 | AppLauncher::~AppLauncher() |
113 | { | 113 | { |
114 | appLauncherPtr = 0; | 114 | appLauncherPtr = 0; |
115 | #ifndef Q_OS_WIN32 | 115 | #ifndef Q_OS_WIN32 |
116 | signal(SIGCHLD, SIG_DFL); | 116 | signal(SIGCHLD, SIG_DFL); |
117 | #endif | 117 | #endif |
118 | if ( qlPid ) { | 118 | if ( qlPid ) { |
119 | int status; | 119 | int status; |
120 | ::kill( qlPid, SIGTERM ); | 120 | ::kill( qlPid, SIGTERM ); |
121 | waitpid( qlPid, &status, 0 ); | 121 | waitpid( qlPid, &status, 0 ); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | /* We use the QCopChannel of the app as an indicator of when it has been launched | 125 | /* We use the QCopChannel of the app as an indicator of when it has been launched |
126 | so that we can disable the busy indicators */ | 126 | so that we can disable the busy indicators */ |
127 | void AppLauncher::newQcopChannel(const QString& channelName) | 127 | void AppLauncher::newQcopChannel(const QString& channelName) |
128 | { | 128 | { |
129 | // qDebug("channel %s added", channelName.data() ); | 129 | // qDebug("channel %s added", channelName.data() ); |
130 | QString prefix("QPE/Application/"); | 130 | QString prefix("QPE/Application/"); |
131 | if (channelName.startsWith(prefix)) { | 131 | if (channelName.startsWith(prefix)) { |
132 | { | 132 | { |
133 | QCopEnvelope e("QPE/System", "newChannel(QString)"); | 133 | QCopEnvelope e("QPE/System", "newChannel(QString)"); |
134 | e << channelName; | 134 | e << channelName; |
135 | } | 135 | } |
136 | QString appName = channelName.mid(prefix.length()); | 136 | QString appName = channelName.mid(prefix.length()); |
137 | if ( appName != "quicklauncher" ) { | 137 | if ( appName != "quicklauncher" ) { |
138 | emit connected( appName ); | 138 | emit connected( appName ); |
139 | QCopEnvelope e("QPE/System", "notBusy(QString)"); | 139 | QCopEnvelope e("QPE/System", "notBusy(QString)"); |
140 | e << appName; | 140 | e << appName; |
141 | } | 141 | } |
142 | } else if (channelName.startsWith("QPE/QuickLauncher-")) { | 142 | } else if (channelName.startsWith("QPE/QuickLauncher-")) { |
143 | qDebug("Registered %s", channelName.latin1()); | 143 | qDebug("Registered %s", channelName.latin1()); |
144 | int pid = channelName.mid(18).toInt(); | 144 | int pid = channelName.mid(18).toInt(); |
145 | if (pid == qlPid) | 145 | if (pid == qlPid) |
146 | qlReady = TRUE; | 146 | qlReady = TRUE; |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | void AppLauncher::removedQcopChannel(const QString& channelName) | 150 | void AppLauncher::removedQcopChannel(const QString& channelName) |
151 | { | 151 | { |
152 | if (channelName.startsWith("QPE/Application/")) { | 152 | if (channelName.startsWith("QPE/Application/")) { |
153 | QCopEnvelope e("QPE/System", "removedChannel(QString)"); | 153 | QCopEnvelope e("QPE/System", "removedChannel(QString)"); |
154 | e << channelName; | 154 | e << channelName; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void AppLauncher::received(const QCString& msg, const QByteArray& data) | 158 | void AppLauncher::received(const QCString& msg, const QByteArray& data) |
159 | { | 159 | { |
160 | QDataStream stream( data, IO_ReadOnly ); | 160 | QDataStream stream( data, IO_ReadOnly ); |
161 | if ( msg == "execute(QString)" ) { | 161 | if ( msg == "execute(QString)" ) { |
162 | QString t; | 162 | QString t; |
163 | stream >> t; | 163 | stream >> t; |
164 | if ( !executeBuiltin( t, QString::null ) ) | 164 | if ( !executeBuiltin( t, QString::null ) ) |
165 | execute(t, QString::null); | 165 | execute(t, QString::null); |
166 | } else if ( msg == "execute(QString,QString)" ) { | 166 | } else if ( msg == "execute(QString,QString)" ) { |
167 | QString t,d; | 167 | QString t,d; |
168 | stream >> t >> d; | 168 | stream >> t >> d; |
169 | if ( !executeBuiltin( t, d ) ) | 169 | if ( !executeBuiltin( t, d ) ) |
170 | execute( t, d ); | 170 | execute( t, d ); |
171 | } else if ( msg == "processQCop(QString)" ) { // from QPE/Server | 171 | } else if ( msg == "processQCop(QString)" ) { // from QPE/Server |
172 | QString t; | 172 | QString t; |
173 | stream >> t; | 173 | stream >> t; |
174 | if ( !executeBuiltin( t, QString::null ) ) | 174 | if ( !executeBuiltin( t, QString::null ) ) |
175 | execute( t, QString::null, TRUE); | 175 | execute( t, QString::null, TRUE); |
176 | } else if ( msg == "raise(QString)" ) { | 176 | } else if ( msg == "raise(QString)" ) { |
177 | QString appName; | 177 | QString appName; |
178 | stream >> appName; | 178 | stream >> appName; |
179 | 179 | ||
180 | if ( !executeBuiltin( appName, QString::null ) ) { | 180 | if ( !executeBuiltin( appName, QString::null ) ) { |
181 | if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { | 181 | if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { |
182 | //qDebug( "Raising: %s", appName.latin1() ); | 182 | //qDebug( "Raising: %s", appName.latin1() ); |
183 | QCString channel = "QPE/Application/"; | 183 | QCString channel = "QPE/Application/"; |
184 | channel += appName.latin1(); | 184 | channel += appName.latin1(); |
185 | 185 | ||
186 | // Need to lock it to avoid race conditions with QPEApplication::processQCopFile | 186 | // Need to lock it to avoid race conditions with QPEApplication::processQCopFile |
187 | QFile f("/tmp/qcop-msg-" + appName); | 187 | QFile f("/tmp/qcop-msg-" + appName); |
188 | if ( f.open(IO_WriteOnly | IO_Append) ) { | 188 | if ( f.open(IO_WriteOnly | IO_Append) ) { |
189 | #ifndef Q_OS_WIN32 | 189 | #ifndef Q_OS_WIN32 |
190 | flock(f.handle(), LOCK_EX); | 190 | flock(f.handle(), LOCK_EX); |
191 | #endif | 191 | #endif |
192 | QDataStream ds(&f); | 192 | QDataStream ds(&f); |
193 | QByteArray b; | 193 | QByteArray b; |
194 | QDataStream bstream(b, IO_WriteOnly); | 194 | QDataStream bstream(b, IO_WriteOnly); |
195 | ds << channel << QCString("raise()") << b; | 195 | ds << channel << QCString("raise()") << b; |
196 | f.flush(); | 196 | f.flush(); |
197 | #ifndef Q_OS_WIN32 | 197 | #ifndef Q_OS_WIN32 |
198 | flock(f.handle(), LOCK_UN); | 198 | flock(f.handle(), LOCK_UN); |
199 | #endif | 199 | #endif |
200 | f.close(); | 200 | f.close(); |
201 | } | 201 | } |
202 | bool alreadyRunning = isRunning( appName ); | 202 | bool alreadyRunning = isRunning( appName ); |
203 | if ( execute(appName, QString::null) ) { | 203 | if ( execute(appName, QString::null) ) { |
204 | int id = startTimer(RAISE_TIMEOUT_MS + alreadyRunning?2000:0); | 204 | int id = startTimer(RAISE_TIMEOUT_MS + alreadyRunning?2000:0); |
205 | waitingHeartbeat.insert( appName, id ); | 205 | waitingHeartbeat.insert( appName, id ); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } else if ( msg == "sendRunningApps()" ) { | 209 | } else if ( msg == "sendRunningApps()" ) { |
210 | QStringList apps; | 210 | QStringList apps; |
211 | QMap<int,QString>::Iterator it; | 211 | QMap<int,QString>::Iterator it; |
212 | for( it = runningApps.begin(); it != runningApps.end(); ++it ) | 212 | for( it = runningApps.begin(); it != runningApps.end(); ++it ) |
213 | apps.append( *it ); | 213 | apps.append( *it ); |
214 | QCopEnvelope e( "QPE/Desktop", "runningApps(QStringList)" ); | 214 | QCopEnvelope e( "QPE/Desktop", "runningApps(QStringList)" ); |
215 | e << apps; | 215 | e << apps; |
216 | } else if ( msg == "appRaised(QString)" ) { | 216 | } else if ( msg == "appRaised(QString)" ) { |
217 | QString appName; | 217 | QString appName; |
218 | stream >> appName; | 218 | stream >> appName; |
219 | qDebug("Got a heartbeat from %s", appName.latin1()); | 219 | qDebug("Got a heartbeat from %s", appName.latin1()); |
220 | QMap<QString,int>::Iterator it = waitingHeartbeat.find(appName); | 220 | QMap<QString,int>::Iterator it = waitingHeartbeat.find(appName); |
221 | if ( it != waitingHeartbeat.end() ) { | 221 | if ( it != waitingHeartbeat.end() ) { |
222 | killTimer( *it ); | 222 | killTimer( *it ); |
223 | waitingHeartbeat.remove(it); | 223 | waitingHeartbeat.remove(it); |
224 | } | 224 | } |
225 | // Check to make sure we're not waiting on user input... | 225 | // Check to make sure we're not waiting on user input... |
226 | if ( appKillerBox && appName == appKillerName ) { | 226 | if ( appKillerBox && appName == appKillerName ) { |
227 | // If we are, we kill the dialog box, and the code waiting on the result | 227 | // If we are, we kill the dialog box, and the code waiting on the result |
228 | // will clean us up (basically the user said "no"). | 228 | // will clean us up (basically the user said "no"). |
229 | delete appKillerBox; | 229 | delete appKillerBox; |
230 | appKillerBox = 0; | 230 | appKillerBox = 0; |
231 | appKillerName = QString::null; | 231 | appKillerName = QString::null; |
232 | } | 232 | } |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | void AppLauncher::signalHandler(int) | 236 | void AppLauncher::signalHandler(int) |
237 | { | 237 | { |
238 | #ifndef Q_OS_WIN32 | 238 | #ifndef Q_OS_WIN32 |
239 | int status; | 239 | int status; |
240 | pid_t pid = waitpid(-1, &status, WNOHANG); | 240 | pid_t pid = waitpid(-1, &status, WNOHANG); |
241 | /* if (pid == 0 || &status == 0 ) { | 241 | /* if (pid == 0 || &status == 0 ) { |
242 | qDebug("hmm, could not get return value from signal"); | 242 | qDebug("hmm, could not get return value from signal"); |
243 | } | 243 | } |
244 | */ | 244 | */ |
245 | QApplication::postEvent(appLauncherPtr, new AppStoppedEvent(pid, status) ); | 245 | QApplication::postEvent(appLauncherPtr, new AppStoppedEvent(pid, status) ); |
246 | #else | 246 | #else |
247 | qDebug("Unhandled signal see by AppLauncher::signalHandler(int)"); | 247 | qDebug("Unhandled signal see by AppLauncher::signalHandler(int)"); |
248 | #endif | 248 | #endif |
249 | } | 249 | } |
250 | 250 | ||
251 | bool AppLauncher::event(QEvent *e) | 251 | bool AppLauncher::event(QEvent *e) |
252 | { | 252 | { |
253 | if ( e->type() == appStopEventID ) { | 253 | if ( e->type() == appStopEventID ) { |
254 | AppStoppedEvent *ae = (AppStoppedEvent *) e; | 254 | AppStoppedEvent *ae = (AppStoppedEvent *) e; |
255 | sigStopped(ae->pid(), ae->status() ); | 255 | sigStopped(ae->pid(), ae->status() ); |
256 | return TRUE; | 256 | return TRUE; |
257 | } | 257 | } |
258 | 258 | ||
259 | return QObject::event(e); | 259 | return QObject::event(e); |
260 | } | 260 | } |
261 | 261 | ||
262 | void AppLauncher::timerEvent( QTimerEvent *e ) | 262 | void AppLauncher::timerEvent( QTimerEvent *e ) |
263 | { | 263 | { |
264 | int id = e->timerId(); | 264 | int id = e->timerId(); |
265 | QMap<QString,int>::Iterator it; | 265 | QMap<QString,int>::Iterator it; |
266 | for ( it = waitingHeartbeat.begin(); it != waitingHeartbeat.end(); ++it ) { | 266 | for ( it = waitingHeartbeat.begin(); it != waitingHeartbeat.end(); ++it ) { |
267 | if ( *it == id ) { | 267 | if ( *it == id ) { |
268 | if ( appKillerBox ) // we're already dealing with one | 268 | if ( appKillerBox ) // we're already dealing with one |
269 | return; | 269 | return; |
270 | 270 | ||
271 | appKillerName = it.key(); | 271 | appKillerName = it.key(); |
272 | killTimer( id ); | 272 | killTimer( id ); |
273 | waitingHeartbeat.remove( it ); | 273 | waitingHeartbeat.remove( it ); |
274 | 274 | ||
275 | // qDebug("Checking in on %s", appKillerName.latin1()); | 275 | // qDebug("Checking in on %s", appKillerName.latin1()); |
276 | 276 | ||
277 | // We store this incase the application responds while we're | 277 | // We store this incase the application responds while we're |
278 | // waiting for user input so we know not to delete ourselves. | 278 | // waiting for user input so we know not to delete ourselves. |
279 | appKillerBox = new QMessageBox(tr("Application Problem"), | 279 | appKillerBox = new QMessageBox(tr("Application Problem"), |
280 | tr("<p>%1 is not responding.</p>").arg(appKillerName) + | 280 | tr("<p>%1 is not responding.</p>").arg(appKillerName) + |
281 | tr("<p>Would you like to force the application to exit?</p>"), | 281 | tr("<p>Would you like to force the application to exit?</p>"), |
282 | QMessageBox::Warning, QMessageBox::Yes, | 282 | QMessageBox::Warning, QMessageBox::Yes, |
283 | QMessageBox::No | QMessageBox::Default, | 283 | QMessageBox::No | QMessageBox::Default, |
284 | QMessageBox::NoButton); | 284 | QMessageBox::NoButton); |
285 | if (appKillerBox->exec() == QMessageBox::Yes) { | 285 | if (appKillerBox->exec() == QMessageBox::Yes) { |
286 | // qDebug("Killing the app!!! Bwuhahahaha!"); | 286 | // qDebug("Killing the app!!! Bwuhahahaha!"); |
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp index 50ae6c2..4316648 100644 --- a/core/launcher/firstuse.cpp +++ b/core/launcher/firstuse.cpp | |||
@@ -1,353 +1,353 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // I need access to some things you don't normally get access to. | 21 | // I need access to some things you don't normally get access to. |
22 | 22 | ||
23 | #ifndef _MSC_VER | 23 | #ifndef _MSC_VER |
24 | //### revise to allow removal of translators under MSVC | 24 | //### revise to allow removal of translators under MSVC |
25 | #define private public | 25 | #define private public |
26 | #define protected public | 26 | #define protected public |
27 | #endif | 27 | #endif |
28 | #include "firstuse.h" | 28 | #include "firstuse.h" |
29 | #include "inputmethods.h" | 29 | #include "inputmethods.h" |
30 | #include "applauncher.h" | 30 | #include "applauncher.h" |
31 | #include "serverapp.h" | 31 | #include "serverapp.h" |
32 | //#include <qtopia/custom.h> | 32 | //#include <qtopia/custom.h> |
33 | 33 | ||
34 | #include "calibrate.h" | 34 | #include "calibrate.h" |
35 | #include "documentlist.h" | 35 | #include "documentlist.h" |
36 | 36 | ||
37 | #include <qtopia/resource.h> | 37 | #include <qtopia/resource.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 38 | #include <qtopia/qcopenvelope_qws.h> |
39 | #include <qtopia/config.h> | 39 | #include <qtopia/config.h> |
40 | #include <qtopia/fontmanager.h> | 40 | #include <qtopia/fontmanager.h> |
41 | 41 | ||
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qpainter.h> | 43 | #include <qpainter.h> |
44 | #include <qsimplerichtext.h> | 44 | #include <qsimplerichtext.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qtimer.h> | 47 | #include <qtimer.h> |
48 | 48 | ||
49 | #if defined( Q_WS_QWS ) | 49 | #if defined( Q_WS_QWS ) |
50 | #include <qwsdisplay_qws.h> | 50 | #include <qwsdisplay_qws.h> |
51 | #include <qgfx_qws.h> | 51 | #include <qgfx_qws.h> |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | 54 | ||
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <sys/types.h> | 56 | #include <sys/types.h> |
57 | #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) | 57 | #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | 61 | ||
62 | struct { | 62 | struct { |
63 | bool enabled; | 63 | bool enabled; |
64 | const char *app; | 64 | const char *app; |
65 | const char *start; | 65 | const char *start; |
66 | const char *stop; | 66 | const char *stop; |
67 | const char *desc; | 67 | const char *desc; |
68 | } | 68 | } |
69 | settingsTable [] = | 69 | settingsTable [] = |
70 | { | 70 | { |
71 | { FALSE, "language", "raise()", "accept()", // No tr | 71 | { FALSE, "language", "raise()", "accept()", // No tr |
72 | QT_TR_NOOP("Language") }, | 72 | QT_TR_NOOP("Language") }, |
73 | { FALSE, "doctab", "raise()", "accept()", // No tr | 73 | { FALSE, "doctab", "raise()", "accept()", // No tr |
74 | QT_TR_NOOP("DocTab") }, | 74 | QT_TR_NOOP("DocTab") }, |
75 | #ifndef Q_OS_WIN32 | 75 | #ifndef Q_OS_WIN32 |
76 | { FALSE, "systemtime", "raise()", "accept()", // No tr | 76 | { FALSE, "systemtime", "raise()", "accept()", // No tr |
77 | QT_TR_NOOP("Time and Date") }, | 77 | QT_TR_NOOP("Time and Date") }, |
78 | #endif | 78 | #endif |
79 | { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr | 79 | { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr |
80 | QT_TR_NOOP("Personal Information") }, | 80 | QT_TR_NOOP("Personal Information") }, |
81 | { FALSE, 0, 0, 0, 0 } | 81 | { FALSE, 0, 0, 0, 0 } |
82 | }; | 82 | }; |
83 | 83 | ||
84 | 84 | ||
85 | FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : | 85 | FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : |
86 | QDialog( parent, name, TRUE, wf), | 86 | QDialog( parent, name, TRUE, wf), |
87 | transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1), | 87 | transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1), |
88 | waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE) | 88 | waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE) |
89 | { | 89 | { |
90 | ServerApplication::allowRestart = FALSE; | 90 | ServerApplication::allowRestart = FALSE; |
91 | // we force our height beyound the maximum (which we set anyway) | 91 | // we force our height beyound the maximum (which we set anyway) |
92 | QRect desk = qApp->desktop()->geometry(); | 92 | QRect desk = qApp->desktop()->geometry(); |
93 | setGeometry( 0, 0, desk.width(), desk.height() ); | 93 | setGeometry( 0, 0, desk.width(), desk.height() ); |
94 | 94 | ||
95 | connect(qwsServer, SIGNAL(newChannel(const QString&)), | 95 | connect(qwsServer, SIGNAL(newChannel(const QString&)), |
96 | this, SLOT(newQcopChannel(const QString&))); | 96 | this, SLOT(newQcopChannel(const QString&))); |
97 | 97 | ||
98 | // Create a DocumentList so appLauncher has appLnkSet to search | 98 | // Create a DocumentList so appLauncher has appLnkSet to search |
99 | docList = new DocumentList( 0, FALSE ); | 99 | docList = new DocumentList( 0, FALSE ); |
100 | appLauncher = new AppLauncher( this ); | 100 | appLauncher = new AppLauncher( this ); |
101 | connect( appLauncher, SIGNAL(terminated(int, const QString&)), | 101 | connect( appLauncher, SIGNAL(terminated(int,const QString&)), |
102 | this, SLOT(terminated(int, const QString&)) ); | 102 | this, SLOT(terminated(int,const QString&)) ); |
103 | 103 | ||
104 | // more hackery | 104 | // more hackery |
105 | // I will be run as either the main server or as part of the main server | 105 | // I will be run as either the main server or as part of the main server |
106 | QWSServer::setScreenSaverIntervals(0); | 106 | QWSServer::setScreenSaverIntervals(0); |
107 | loadPixmaps(); | 107 | loadPixmaps(); |
108 | 108 | ||
109 | //check if there is a language program | 109 | //check if there is a language program |
110 | #ifndef Q_OS_WIN32 | 110 | #ifndef Q_OS_WIN32 |
111 | QString exeSuffix; | 111 | QString exeSuffix; |
112 | #else | 112 | #else |
113 | QString exeSuffix(".exe"); | 113 | QString exeSuffix(".exe"); |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | for ( int i = 0; settingsTable[i].app; i++ ) { | 116 | for ( int i = 0; settingsTable[i].app; i++ ) { |
117 | QString file = QPEApplication::qpeDir() + "bin/"; | 117 | QString file = QPEApplication::qpeDir() + "bin/"; |
118 | file += settingsTable[i].app; | 118 | file += settingsTable[i].app; |
119 | file += exeSuffix; | 119 | file += exeSuffix; |
120 | if ( QFile::exists(file) ) | 120 | if ( QFile::exists(file) ) |
121 | settingsTable[i].enabled = TRUE; | 121 | settingsTable[i].enabled = TRUE; |
122 | } | 122 | } |
123 | 123 | ||
124 | setFocusPolicy(NoFocus); | 124 | setFocusPolicy(NoFocus); |
125 | 125 | ||
126 | taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader); | 126 | taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader); |
127 | 127 | ||
128 | inputMethods = new InputMethods(taskBar); | 128 | inputMethods = new InputMethods(taskBar); |
129 | connect(inputMethods, SIGNAL(inputToggled(bool)), | 129 | connect(inputMethods, SIGNAL(inputToggled(bool)), |
130 | this, SLOT(calcMaxWindowRect())); | 130 | this, SLOT(calcMaxWindowRect())); |
131 | 131 | ||
132 | back = new QPushButton(tr("<< Back"), taskBar); | 132 | back = new QPushButton(tr("<< Back"), taskBar); |
133 | back->setFocusPolicy(NoFocus); | 133 | back->setFocusPolicy(NoFocus); |
134 | connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) ); | 134 | connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) ); |
135 | 135 | ||
136 | next = new QPushButton(tr("Next >>"), taskBar); | 136 | next = new QPushButton(tr("Next >>"), taskBar); |
137 | next->setFocusPolicy(NoFocus); | 137 | next->setFocusPolicy(NoFocus); |
138 | connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) ); | 138 | connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) ); |
139 | 139 | ||
140 | // need to set the geom to lower corner | 140 | // need to set the geom to lower corner |
141 | QSize sz = inputMethods->sizeHint(); | 141 | QSize sz = inputMethods->sizeHint(); |
142 | int buttonWidth = (width() - sz.width()) / 2; | 142 | int buttonWidth = (width() - sz.width()) / 2; |
143 | int x = 0; | 143 | int x = 0; |
144 | 144 | ||
145 | controlHeight = back->sizeHint().height(); | 145 | controlHeight = back->sizeHint().height(); |
146 | 146 | ||
147 | inputMethods->setGeometry(0,0, sz.width(), controlHeight ); | 147 | inputMethods->setGeometry(0,0, sz.width(), controlHeight ); |
148 | x += sz.width(); | 148 | x += sz.width(); |
149 | 149 | ||
150 | back->setGeometry(x, 0, buttonWidth, controlHeight); | 150 | back->setGeometry(x, 0, buttonWidth, controlHeight); |
151 | x += buttonWidth; | 151 | x += buttonWidth; |
152 | next->setGeometry(x, 0, buttonWidth, controlHeight); | 152 | next->setGeometry(x, 0, buttonWidth, controlHeight); |
153 | 153 | ||
154 | taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight); | 154 | taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight); |
155 | taskBar->hide(); | 155 | taskBar->hide(); |
156 | 156 | ||
157 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 157 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
158 | qDebug("Setting up QCop to QPE/System"); | 158 | qDebug("Setting up QCop to QPE/System"); |
159 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 159 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
160 | connect(sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 160 | connect(sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
161 | this, SLOT(message(const QCString &, const QByteArray &)) ); | 161 | this, SLOT(message(const QCString&,const QByteArray&)) ); |
162 | #endif | 162 | #endif |
163 | calcMaxWindowRect(); | 163 | calcMaxWindowRect(); |
164 | 164 | ||
165 | m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false; | 165 | m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false; |
166 | 166 | ||
167 | if ( m_calHandler) { | 167 | if ( m_calHandler) { |
168 | if ( !QFile::exists("/etc/pointercal") ) { | 168 | if ( !QFile::exists("/etc/pointercal") ) { |
169 | needCalibrate = TRUE; | 169 | needCalibrate = TRUE; |
170 | grabMouse(); | 170 | grabMouse(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | Config config("locale"); | 174 | Config config("locale"); |
175 | config.setGroup( "Language"); | 175 | config.setGroup( "Language"); |
176 | lang = config.readEntry( "Language", "en"); | 176 | lang = config.readEntry( "Language", "en"); |
177 | 177 | ||
178 | defaultFont = font(); | 178 | defaultFont = font(); |
179 | 179 | ||
180 | //###language/font hack; should look it up somewhere | 180 | //###language/font hack; should look it up somewhere |
181 | #ifdef Q_WS_QWS | 181 | #ifdef Q_WS_QWS |
182 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 182 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
183 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 183 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
184 | qApp->setFont( fn, TRUE ); | 184 | qApp->setFont( fn, TRUE ); |
185 | } | 185 | } |
186 | #endif | 186 | #endif |
187 | } | 187 | } |
188 | 188 | ||
189 | FirstUse::~FirstUse() | 189 | FirstUse::~FirstUse() |
190 | { | 190 | { |
191 | delete appLauncher; | 191 | delete appLauncher; |
192 | delete docList; | 192 | delete docList; |
193 | delete taskBar; | 193 | delete taskBar; |
194 | ServerApplication::allowRestart = TRUE; | 194 | ServerApplication::allowRestart = TRUE; |
195 | } | 195 | } |
196 | 196 | ||
197 | void FirstUse::calcMaxWindowRect() | 197 | void FirstUse::calcMaxWindowRect() |
198 | { | 198 | { |
199 | #ifdef Q_WS_QWS | 199 | #ifdef Q_WS_QWS |
200 | QRect wr; | 200 | QRect wr; |
201 | int displayWidth = qApp->desktop()->width(); | 201 | int displayWidth = qApp->desktop()->width(); |
202 | QRect ir = inputMethods->inputRect(); | 202 | QRect ir = inputMethods->inputRect(); |
203 | if ( ir.isValid() ) { | 203 | if ( ir.isValid() ) { |
204 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 204 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
205 | } else { | 205 | } else { |
206 | wr.setCoords( 0, 0, displayWidth-1, | 206 | wr.setCoords( 0, 0, displayWidth-1, |
207 | qApp->desktop()->height() - controlHeight-1); | 207 | qApp->desktop()->height() - controlHeight-1); |
208 | } | 208 | } |
209 | 209 | ||
210 | #if QT_VERSION < 0x030000 | 210 | #if QT_VERSION < 0x030000 |
211 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, | 211 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, |
212 | QSize(qt_screen->width(),qt_screen->height())) | 212 | QSize(qt_screen->width(),qt_screen->height())) |
213 | ); | 213 | ); |
214 | #else | 214 | #else |
215 | QWSServer::setMaxWindowRect( wr ); | 215 | QWSServer::setMaxWindowRect( wr ); |
216 | #endif | 216 | #endif |
217 | #endif | 217 | #endif |
218 | } | 218 | } |
219 | 219 | ||
220 | /* cancel current dialog, and bring up next */ | 220 | /* cancel current dialog, and bring up next */ |
221 | void FirstUse::nextDialog() | 221 | void FirstUse::nextDialog() |
222 | { | 222 | { |
223 | int prevApp = currApp; | 223 | int prevApp = currApp; |
224 | do { | 224 | do { |
225 | currApp++; | 225 | currApp++; |
226 | qDebug( "currApp = %d", currApp ); | 226 | qDebug( "currApp = %d", currApp ); |
227 | if ( settingsTable[currApp].app == 0 ) { | 227 | if ( settingsTable[currApp].app == 0 ) { |
228 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { | 228 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { |
229 | // The last application is still running. | 229 | // The last application is still running. |
230 | // Tell it to stop, and when its done we'll come back | 230 | // Tell it to stop, and when its done we'll come back |
231 | // to nextDialog and exit. | 231 | // to nextDialog and exit. |
232 | qDebug( "Waiting for %s to exit", settingsTable[prevApp].app ); | 232 | qDebug( "Waiting for %s to exit", settingsTable[prevApp].app ); |
233 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 233 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
234 | settingsTable[prevApp].stop ); | 234 | settingsTable[prevApp].stop ); |
235 | currApp = prevApp; | 235 | currApp = prevApp; |
236 | } else { | 236 | } else { |
237 | qDebug( "Done!" ); | 237 | qDebug( "Done!" ); |
238 | Config config( "qpe" ); | 238 | Config config( "qpe" ); |
239 | config.setGroup( "Startup" ); | 239 | config.setGroup( "Startup" ); |
240 | config.writeEntry( "FirstUse", FALSE ); | 240 | config.writeEntry( "FirstUse", FALSE ); |
241 | QPixmap pix = Resource::loadPixmap("bigwait"); | 241 | QPixmap pix = Resource::loadPixmap("bigwait"); |
242 | QLabel *lblWait = new QLabel(0, "wait hack!", // No tr | 242 | QLabel *lblWait = new QLabel(0, "wait hack!", // No tr |
243 | QWidget::WStyle_Customize | QWidget::WDestructiveClose | | 243 | QWidget::WStyle_Customize | QWidget::WDestructiveClose | |
244 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | | 244 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | |
245 | QWidget::WStyle_StaysOnTop); | 245 | QWidget::WStyle_StaysOnTop); |
246 | lblWait->setPixmap( pix ); | 246 | lblWait->setPixmap( pix ); |
247 | lblWait->setAlignment( QWidget::AlignCenter ); | 247 | lblWait->setAlignment( QWidget::AlignCenter ); |
248 | lblWait->setGeometry( qApp->desktop()->geometry() ); | 248 | lblWait->setGeometry( qApp->desktop()->geometry() ); |
249 | lblWait->show(); | 249 | lblWait->show(); |
250 | qApp->processEvents(); | 250 | qApp->processEvents(); |
251 | QTimer::singleShot( 1000, lblWait, SLOT(close()) ); | 251 | QTimer::singleShot( 1000, lblWait, SLOT(close()) ); |
252 | repaint(); | 252 | repaint(); |
253 | close(); | 253 | close(); |
254 | ServerApplication::allowRestart = TRUE; | 254 | ServerApplication::allowRestart = TRUE; |
255 | } | 255 | } |
256 | return; | 256 | return; |
257 | } | 257 | } |
258 | } while ( !settingsTable[currApp].enabled ); | 258 | } while ( !settingsTable[currApp].enabled ); |
259 | 259 | ||
260 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { | 260 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { |
261 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); | 261 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); |
262 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 262 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
263 | settingsTable[prevApp].stop ); | 263 | settingsTable[prevApp].stop ); |
264 | waitForExit = prevApp; | 264 | waitForExit = prevApp; |
265 | } else { | 265 | } else { |
266 | qDebug( "Startup: %s", settingsTable[currApp].app ); | 266 | qDebug( "Startup: %s", settingsTable[currApp].app ); |
267 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, | 267 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, |
268 | settingsTable[currApp].start ); | 268 | settingsTable[currApp].start ); |
269 | waitingForLaunch = TRUE; | 269 | waitingForLaunch = TRUE; |
270 | } | 270 | } |
271 | 271 | ||
272 | updateButtons(); | 272 | updateButtons(); |
273 | } | 273 | } |
274 | 274 | ||
275 | /* accept current dialog and bring up previous */ | 275 | /* accept current dialog and bring up previous */ |
276 | void FirstUse::previousDialog() | 276 | void FirstUse::previousDialog() |
277 | { | 277 | { |
278 | int prevApp = currApp; | 278 | int prevApp = currApp; |
279 | do { | 279 | do { |
280 | currApp--; | 280 | currApp--; |
281 | if ( currApp < 0 ) { | 281 | if ( currApp < 0 ) { |
282 | currApp = prevApp; | 282 | currApp = prevApp; |
283 | return; | 283 | return; |
284 | } | 284 | } |
285 | } while ( !settingsTable[currApp].enabled ); | 285 | } while ( !settingsTable[currApp].enabled ); |
286 | 286 | ||
287 | if ( prevApp >= 0 ) { | 287 | if ( prevApp >= 0 ) { |
288 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); | 288 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); |
289 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 289 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
290 | settingsTable[prevApp].stop ); | 290 | settingsTable[prevApp].stop ); |
291 | /* | 291 | /* |
292 | if (settingsTable[prevApp].app == QString("systemtime")) | 292 | if (settingsTable[prevApp].app == QString("systemtime")) |
293 | QCopEnvelope e("QPE/Application/citytime", "close()"); | 293 | QCopEnvelope e("QPE/Application/citytime", "close()"); |
294 | */ | 294 | */ |
295 | waitForExit = prevApp; | 295 | waitForExit = prevApp; |
296 | } else { | 296 | } else { |
297 | qDebug( "Startup: %s", settingsTable[currApp].app ); | 297 | qDebug( "Startup: %s", settingsTable[currApp].app ); |
298 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, | 298 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, |
299 | settingsTable[currApp].start ); | 299 | settingsTable[currApp].start ); |
300 | waitingForLaunch = TRUE; | 300 | waitingForLaunch = TRUE; |
301 | } | 301 | } |
302 | 302 | ||
303 | updateButtons(); | 303 | updateButtons(); |
304 | } | 304 | } |
305 | 305 | ||
306 | void FirstUse::message(const QCString &msg, const QByteArray &data) | 306 | void FirstUse::message(const QCString &msg, const QByteArray &data) |
307 | { | 307 | { |
308 | QDataStream stream( data, IO_ReadOnly ); | 308 | QDataStream stream( data, IO_ReadOnly ); |
309 | if ( msg == "timeChange(QString)" ) { | 309 | if ( msg == "timeChange(QString)" ) { |
310 | QString t; | 310 | QString t; |
311 | stream >> t; | 311 | stream >> t; |
312 | if ( t.isNull() ) | 312 | if ( t.isNull() ) |
313 | unsetenv("TZ"); | 313 | unsetenv("TZ"); |
314 | else | 314 | else |
315 | setenv( "TZ", t.latin1(), 1 ); | 315 | setenv( "TZ", t.latin1(), 1 ); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | void FirstUse::terminated( int, const QString &app ) | 319 | void FirstUse::terminated( int, const QString &app ) |
320 | { | 320 | { |
321 | qDebug( "--- terminated: %s", app.latin1() ); | 321 | qDebug( "--- terminated: %s", app.latin1() ); |
322 | if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) { | 322 | if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) { |
323 | qDebug( "Startup: %s", settingsTable[currApp].app ); | 323 | qDebug( "Startup: %s", settingsTable[currApp].app ); |
324 | if ( settingsTable[waitForExit].app == "language" ) { // No tr | 324 | if ( settingsTable[waitForExit].app == "language" ) { // No tr |
325 | Config config("locale"); | 325 | Config config("locale"); |
326 | config.setGroup( "Language"); | 326 | config.setGroup( "Language"); |
327 | QString l = config.readEntry( "Language", "en"); | 327 | QString l = config.readEntry( "Language", "en"); |
328 | if ( l != lang ) { | 328 | if ( l != lang ) { |
329 | reloadLanguages(); | 329 | reloadLanguages(); |
330 | needRestart = TRUE; | 330 | needRestart = TRUE; |
331 | lang = l; | 331 | lang = l; |
332 | } | 332 | } |
333 | } | 333 | } |
334 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, | 334 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, |
335 | settingsTable[currApp].start ); | 335 | settingsTable[currApp].start ); |
336 | waitingForLaunch = TRUE; | 336 | waitingForLaunch = TRUE; |
337 | updateButtons(); | 337 | updateButtons(); |
338 | repaint(); | 338 | repaint(); |
339 | waitForExit = -1; | 339 | waitForExit = -1; |
340 | } else if ( settingsTable[currApp].app == app ) { | 340 | } else if ( settingsTable[currApp].app == app ) { |
341 | nextDialog(); | 341 | nextDialog(); |
342 | } else { | 342 | } else { |
343 | back->setEnabled(TRUE); | 343 | back->setEnabled(TRUE); |
344 | next->setEnabled(TRUE); | 344 | next->setEnabled(TRUE); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | void FirstUse::newQcopChannel(const QString& channelName) | 348 | void FirstUse::newQcopChannel(const QString& channelName) |
349 | { | 349 | { |
350 | qDebug("channel %s added", channelName.data() ); | 350 | qDebug("channel %s added", channelName.data() ); |
351 | QString prefix("QPE/Application/"); | 351 | QString prefix("QPE/Application/"); |
352 | if (channelName.startsWith(prefix)) { | 352 | if (channelName.startsWith(prefix)) { |
353 | QString appName = channelName.mid(prefix.length()); | 353 | QString appName = channelName.mid(prefix.length()); |
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 683f1e2..19e799a 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -1,341 +1,341 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
23 | 23 | ||
24 | #include <qtopia/config.h> | 24 | #include <qtopia/config.h> |
25 | #include <qtopia/qpeapplication.h> | 25 | #include <qtopia/qpeapplication.h> |
26 | 26 | ||
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qwidgetstack.h> | 29 | #include <qwidgetstack.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <stdlib.h> | 32 | #include <stdlib.h> |
33 | #include <qtl.h> | 33 | #include <qtl.h> |
34 | 34 | ||
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | #include <qwsevent_qws.h> | 37 | #include <qwsevent_qws.h> |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | /* ### SingleFloppy if someone is interested? */ | 41 | /* ### SingleFloppy if someone is interested? */ |
42 | #if 0 | 42 | #if 0 |
43 | #ifdef QT_NO_COMPONENT | 43 | #ifdef QT_NO_COMPONENT |
44 | #include "../plugins/inputmethods/handwriting/handwritingimpl.h" | 44 | #include "../plugins/inputmethods/handwriting/handwritingimpl.h" |
45 | #include "../plugins/inputmethods/keyboard/keyboardimpl.h" | 45 | #include "../plugins/inputmethods/keyboard/keyboardimpl.h" |
46 | #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" | 46 | #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" |
47 | #endif | 47 | #endif |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | /* XPM */ | 50 | /* XPM */ |
51 | static const char * tri_xpm[]={ | 51 | static const char * tri_xpm[]={ |
52 | "9 9 2 1", | 52 | "9 9 2 1", |
53 | "a c #000000", | 53 | "a c #000000", |
54 | ". c None", | 54 | ". c None", |
55 | ".........", | 55 | ".........", |
56 | ".........", | 56 | ".........", |
57 | ".........", | 57 | ".........", |
58 | "....a....", | 58 | "....a....", |
59 | "...aaa...", | 59 | "...aaa...", |
60 | "..aaaaa..", | 60 | "..aaaaa..", |
61 | ".aaaaaaa.", | 61 | ".aaaaaaa.", |
62 | ".........", | 62 | ".........", |
63 | "........."}; | 63 | "........."}; |
64 | 64 | ||
65 | int InputMethod::operator <(const InputMethod& o) const | 65 | int InputMethod::operator <(const InputMethod& o) const |
66 | { | 66 | { |
67 | return name() < o.name(); | 67 | return name() < o.name(); |
68 | } | 68 | } |
69 | int InputMethod::operator >(const InputMethod& o) const | 69 | int InputMethod::operator >(const InputMethod& o) const |
70 | { | 70 | { |
71 | return name() > o.name(); | 71 | return name() > o.name(); |
72 | } | 72 | } |
73 | int InputMethod::operator <=(const InputMethod& o) const | 73 | int InputMethod::operator <=(const InputMethod& o) const |
74 | { | 74 | { |
75 | return name() <= o.name(); | 75 | return name() <= o.name(); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | /* | 79 | /* |
80 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget | 80 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget |
81 | belongs to the IM system, so clicking it should not cause a reset". | 81 | belongs to the IM system, so clicking it should not cause a reset". |
82 | */ | 82 | */ |
83 | class IMToolButton : public QToolButton | 83 | class IMToolButton : public QToolButton |
84 | { | 84 | { |
85 | public: | 85 | public: |
86 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) | 86 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) |
87 | { setWFlags( WStyle_Tool ); } | 87 | { setWFlags( WStyle_Tool ); } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | InputMethods::InputMethods( QWidget *parent ) : | 91 | InputMethods::InputMethods( QWidget *parent ) : |
92 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), | 92 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), |
93 | mkeyboard(0), imethod(0) | 93 | mkeyboard(0), imethod(0) |
94 | { | 94 | { |
95 | Config cfg( "Launcher" ); | 95 | Config cfg( "Launcher" ); |
96 | cfg.setGroup( "InputMethods" ); | 96 | cfg.setGroup( "InputMethods" ); |
97 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; | 97 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; |
98 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; | 98 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; |
99 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); | 99 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); |
100 | 100 | ||
101 | setBackgroundMode( PaletteBackground ); | 101 | setBackgroundMode( PaletteBackground ); |
102 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 102 | QHBoxLayout *hbox = new QHBoxLayout( this ); |
103 | 103 | ||
104 | kbdButton = new IMToolButton( this); | 104 | kbdButton = new IMToolButton( this); |
105 | kbdButton->setFocusPolicy(NoFocus); | 105 | kbdButton->setFocusPolicy(NoFocus); |
106 | kbdButton->setToggleButton( TRUE ); | 106 | kbdButton->setToggleButton( TRUE ); |
107 | if (parent->sizeHint().height() > 0) | 107 | if (parent->sizeHint().height() > 0) |
108 | kbdButton->setFixedHeight( parent->sizeHint().height() ); | 108 | kbdButton->setFixedHeight( parent->sizeHint().height() ); |
109 | kbdButton->setFixedWidth( 32 ); | 109 | kbdButton->setFixedWidth( 32 ); |
110 | kbdButton->setAutoRaise( TRUE ); | 110 | kbdButton->setAutoRaise( TRUE ); |
111 | kbdButton->setUsesBigPixmap( TRUE ); | 111 | kbdButton->setUsesBigPixmap( TRUE ); |
112 | hbox->addWidget( kbdButton ); | 112 | hbox->addWidget( kbdButton ); |
113 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); | 113 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); |
114 | 114 | ||
115 | kbdChoice = new IMToolButton( this ); | 115 | kbdChoice = new IMToolButton( this ); |
116 | kbdChoice->setFocusPolicy(NoFocus); | 116 | kbdChoice->setFocusPolicy(NoFocus); |
117 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 117 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
118 | if (parent->sizeHint().height() > 0) | 118 | if (parent->sizeHint().height() > 0) |
119 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); | 119 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); |
120 | kbdChoice->setFixedWidth( 13 ); | 120 | kbdChoice->setFixedWidth( 13 ); |
121 | kbdChoice->setAutoRaise( TRUE ); | 121 | kbdChoice->setAutoRaise( TRUE ); |
122 | hbox->addWidget( kbdChoice ); | 122 | hbox->addWidget( kbdChoice ); |
123 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); | 123 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); |
124 | 124 | ||
125 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), | 125 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), |
126 | this, SLOT(resetStates()) ); | 126 | this, SLOT(resetStates()) ); |
127 | 127 | ||
128 | 128 | ||
129 | imButton = new QWidgetStack( this ); // later a widget stack | 129 | imButton = new QWidgetStack( this ); // later a widget stack |
130 | imButton->setFocusPolicy(NoFocus); | 130 | imButton->setFocusPolicy(NoFocus); |
131 | if (parent->sizeHint().height() > 0) | 131 | if (parent->sizeHint().height() > 0) |
132 | imButton->setFixedHeight( parent->sizeHint().height() ); | 132 | imButton->setFixedHeight( parent->sizeHint().height() ); |
133 | hbox->addWidget(imButton); | 133 | hbox->addWidget(imButton); |
134 | 134 | ||
135 | imChoice = new QToolButton( this ); | 135 | imChoice = new QToolButton( this ); |
136 | imChoice->setFocusPolicy(NoFocus); | 136 | imChoice->setFocusPolicy(NoFocus); |
137 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 137 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
138 | if (parent->sizeHint().height() > 0) | 138 | if (parent->sizeHint().height() > 0) |
139 | imChoice->setFixedHeight( parent->sizeHint().height() ); | 139 | imChoice->setFixedHeight( parent->sizeHint().height() ); |
140 | imChoice->setFixedWidth( 13 ); | 140 | imChoice->setFixedWidth( 13 ); |
141 | imChoice->setAutoRaise( TRUE ); | 141 | imChoice->setAutoRaise( TRUE ); |
142 | hbox->addWidget( imChoice ); | 142 | hbox->addWidget( imChoice ); |
143 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); | 143 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); |
144 | 144 | ||
145 | loadInputMethods(); | 145 | loadInputMethods(); |
146 | 146 | ||
147 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); | 147 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); |
148 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 148 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
149 | this, SLOT(qcopReceive(const QCString&, const QByteArray&)) ); | 149 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); |
150 | } | 150 | } |
151 | 151 | ||
152 | InputMethods::~InputMethods() | 152 | InputMethods::~InputMethods() |
153 | { | 153 | { |
154 | Config cfg("qpe"); | 154 | Config cfg("qpe"); |
155 | cfg.setGroup("InputMethod"); | 155 | cfg.setGroup("InputMethod"); |
156 | if (imethod) | 156 | if (imethod) |
157 | cfg.writeEntry("im", imethod->name() ); | 157 | cfg.writeEntry("im", imethod->name() ); |
158 | if (mkeyboard) | 158 | if (mkeyboard) |
159 | cfg.writeEntry("current", mkeyboard->name() ); | 159 | cfg.writeEntry("current", mkeyboard->name() ); |
160 | 160 | ||
161 | unloadInputMethods(); | 161 | unloadInputMethods(); |
162 | } | 162 | } |
163 | 163 | ||
164 | void InputMethods::hideInputMethod() | 164 | void InputMethods::hideInputMethod() |
165 | { | 165 | { |
166 | kbdButton->setOn( FALSE ); | 166 | kbdButton->setOn( FALSE ); |
167 | } | 167 | } |
168 | 168 | ||
169 | void InputMethods::showInputMethod() | 169 | void InputMethods::showInputMethod() |
170 | { | 170 | { |
171 | kbdButton->setOn( TRUE ); | 171 | kbdButton->setOn( TRUE ); |
172 | } | 172 | } |
173 | 173 | ||
174 | void InputMethods::showInputMethod(const QString& name) | 174 | void InputMethods::showInputMethod(const QString& name) |
175 | { | 175 | { |
176 | int i = 0; | 176 | int i = 0; |
177 | QValueList<InputMethod>::Iterator it; | 177 | QValueList<InputMethod>::Iterator it; |
178 | InputMethod *im = 0; | 178 | InputMethod *im = 0; |
179 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 179 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
180 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); | 180 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); |
181 | if ( (*it).name() == name || lname == name ) { | 181 | if ( (*it).name() == name || lname == name ) { |
182 | im = &(*it); | 182 | im = &(*it); |
183 | break; | 183 | break; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | if ( im ) | 186 | if ( im ) |
187 | chooseKeyboard(im); | 187 | chooseKeyboard(im); |
188 | } | 188 | } |
189 | 189 | ||
190 | void InputMethods::resetStates() | 190 | void InputMethods::resetStates() |
191 | { | 191 | { |
192 | if ( mkeyboard && !mkeyboard->newIM ) | 192 | if ( mkeyboard && !mkeyboard->newIM ) |
193 | mkeyboard->interface->resetState(); | 193 | mkeyboard->interface->resetState(); |
194 | } | 194 | } |
195 | 195 | ||
196 | QRect InputMethods::inputRect() const | 196 | QRect InputMethods::inputRect() const |
197 | { | 197 | { |
198 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) | 198 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) |
199 | return QRect(); | 199 | return QRect(); |
200 | else | 200 | else |
201 | return mkeyboard->widget->geometry(); | 201 | return mkeyboard->widget->geometry(); |
202 | } | 202 | } |
203 | 203 | ||
204 | void InputMethods::unloadInputMethods() | 204 | void InputMethods::unloadInputMethods() |
205 | { | 205 | { |
206 | unloadMethod( inputMethodList ); | 206 | unloadMethod( inputMethodList ); |
207 | unloadMethod( inputModifierList ); | 207 | unloadMethod( inputModifierList ); |
208 | inputMethodList.clear(); | 208 | inputMethodList.clear(); |
209 | inputModifierList.clear(); | 209 | inputModifierList.clear(); |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { | 213 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { |
214 | QValueList<InputMethod>::Iterator it; | 214 | QValueList<InputMethod>::Iterator it; |
215 | 215 | ||
216 | for (it = list.begin(); it != list.end(); ++it ) | 216 | for (it = list.begin(); it != list.end(); ++it ) |
217 | (*it).releaseInterface(); | 217 | (*it).releaseInterface(); |
218 | 218 | ||
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | QStringList InputMethods::plugins()const { | 222 | QStringList InputMethods::plugins()const { |
223 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 223 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
224 | #ifdef Q_OS_MACX | 224 | #ifdef Q_OS_MACX |
225 | QDir dir( path, "lib*.dylib" ); | 225 | QDir dir( path, "lib*.dylib" ); |
226 | #else | 226 | #else |
227 | QDir dir( path, "lib*.so" ); | 227 | QDir dir( path, "lib*.so" ); |
228 | #endif /* Q_OS_MACX */ | 228 | #endif /* Q_OS_MACX */ |
229 | return dir.entryList(); | 229 | return dir.entryList(); |
230 | } | 230 | } |
231 | 231 | ||
232 | void InputMethods::installTranslator( const QString& type ) { | 232 | void InputMethods::installTranslator( const QString& type ) { |
233 | QStringList langs = Global::languageList(); | 233 | QStringList langs = Global::languageList(); |
234 | QStringList::ConstIterator lit; | 234 | QStringList::ConstIterator lit; |
235 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { | 235 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { |
236 | QString lang = *lit; | 236 | QString lang = *lit; |
237 | QTranslator * trans = new QTranslator(qApp); | 237 | QTranslator * trans = new QTranslator(qApp); |
238 | 238 | ||
239 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 239 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
240 | 240 | ||
241 | if ( trans->load( tfn )) | 241 | if ( trans->load( tfn )) |
242 | qApp->installTranslator( trans ); | 242 | qApp->installTranslator( trans ); |
243 | else | 243 | else |
244 | delete trans; | 244 | delete trans; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | void InputMethods::setPreferedHandlers() { | 248 | void InputMethods::setPreferedHandlers() { |
249 | Config cfg("qpe"); | 249 | Config cfg("qpe"); |
250 | cfg.setGroup("InputMethod"); | 250 | cfg.setGroup("InputMethod"); |
251 | QString current = cfg.readEntry("current"); | 251 | QString current = cfg.readEntry("current"); |
252 | QString im = cfg.readEntry("im"); | 252 | QString im = cfg.readEntry("im"); |
253 | 253 | ||
254 | QValueList<InputMethod>::Iterator it; | 254 | QValueList<InputMethod>::Iterator it; |
255 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { | 255 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { |
256 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) | 256 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) |
257 | if ( (*it).name() == im ) { | 257 | if ( (*it).name() == im ) { |
258 | imethod = &(*it); break; | 258 | imethod = &(*it); break; |
259 | } | 259 | } |
260 | 260 | ||
261 | } | 261 | } |
262 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { | 262 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { |
263 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) | 263 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) |
264 | if ( (*it).name() == current ) { | 264 | if ( (*it).name() == current ) { |
265 | qWarning("preferred keyboard is %s", current.latin1() ); | 265 | qWarning("preferred keyboard is %s", current.latin1() ); |
266 | mkeyboard = &(*it); | 266 | mkeyboard = &(*it); |
267 | kbdButton->setPixmap( *mkeyboard->icon() ); | 267 | kbdButton->setPixmap( *mkeyboard->icon() ); |
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | } | 272 | } |
273 | 273 | ||
274 | void InputMethods::loadInputMethods() | 274 | void InputMethods::loadInputMethods() |
275 | { | 275 | { |
276 | #ifndef QT_NO_COMPONENT | 276 | #ifndef QT_NO_COMPONENT |
277 | hideInputMethod(); | 277 | hideInputMethod(); |
278 | mkeyboard = 0; | 278 | mkeyboard = 0; |
279 | 279 | ||
280 | unloadInputMethods(); | 280 | unloadInputMethods(); |
281 | 281 | ||
282 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 282 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
283 | QStringList list = plugins(); | 283 | QStringList list = plugins(); |
284 | QStringList::Iterator it; | 284 | QStringList::Iterator it; |
285 | for ( it = list.begin(); it != list.end(); ++it ) { | 285 | for ( it = list.begin(); it != list.end(); ++it ) { |
286 | InputMethodInterface *iface = 0; | 286 | InputMethodInterface *iface = 0; |
287 | ExtInputMethodInterface *eface = 0; | 287 | ExtInputMethodInterface *eface = 0; |
288 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 288 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
289 | 289 | ||
290 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { | 290 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { |
291 | InputMethod input; | 291 | InputMethod input; |
292 | input.newIM = FALSE; | 292 | input.newIM = FALSE; |
293 | input.library = lib; | 293 | input.library = lib; |
294 | input.libName = *it; | 294 | input.libName = *it; |
295 | input.interface = iface; | 295 | input.interface = iface; |
296 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); | 296 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); |
297 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); | 297 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); |
298 | inputMethodList.append( input ); | 298 | inputMethodList.append( input ); |
299 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { | 299 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { |
300 | InputMethod input; | 300 | InputMethod input; |
301 | input.newIM = TRUE; | 301 | input.newIM = TRUE; |
302 | input.library = lib; | 302 | input.library = lib; |
303 | input.libName = *it; | 303 | input.libName = *it; |
304 | input.extInterface = eface; | 304 | input.extInterface = eface; |
305 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); | 305 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); |
306 | // may be either a simple, or advanced. | 306 | // may be either a simple, or advanced. |
307 | if (input.widget) { | 307 | if (input.widget) { |
308 | //qDebug("its a keyboard"); | 308 | //qDebug("its a keyboard"); |
309 | inputMethodList.append( input ); | 309 | inputMethodList.append( input ); |
310 | } else { | 310 | } else { |
311 | //qDebug("its a real im"); | 311 | //qDebug("its a real im"); |
312 | input.widget = input.extInterface->statusWidget( 0, 0 ); | 312 | input.widget = input.extInterface->statusWidget( 0, 0 ); |
313 | if (input.widget) { | 313 | if (input.widget) { |
314 | //qDebug("blah"); | 314 | //qDebug("blah"); |
315 | inputModifierList.append( input ); | 315 | inputModifierList.append( input ); |
316 | imButton->addWidget(input.widget, inputModifierList.count()); | 316 | imButton->addWidget(input.widget, inputModifierList.count()); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | }else{ | 319 | }else{ |
320 | delete lib; | 320 | delete lib; |
321 | lib = 0l; | 321 | lib = 0l; |
322 | } | 322 | } |
323 | installTranslator( (*it).left( (*it).find(".") ) ); | 323 | installTranslator( (*it).left( (*it).find(".") ) ); |
324 | } | 324 | } |
325 | qHeapSort( inputMethodList ); | 325 | qHeapSort( inputMethodList ); |
326 | #endif /* killed BUILT in cause they would not compile */ | 326 | #endif /* killed BUILT in cause they would not compile */ |
327 | 327 | ||
328 | QWSServer::setCurrentInputMethod( 0 ); | 328 | QWSServer::setCurrentInputMethod( 0 ); |
329 | 329 | ||
330 | /* set the prefered IM + handler */ | 330 | /* set the prefered IM + handler */ |
331 | setPreferedHandlers(); | 331 | setPreferedHandlers(); |
332 | if ( !inputModifierList.isEmpty() ) { | 332 | if ( !inputModifierList.isEmpty() ) { |
333 | if (!imethod) | 333 | if (!imethod) |
334 | imethod = &inputModifierList[0]; | 334 | imethod = &inputModifierList[0]; |
335 | imButton->raiseWidget(imethod->widget); | 335 | imButton->raiseWidget(imethod->widget); |
336 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 336 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
337 | } else { | 337 | } else { |
338 | imethod = 0; | 338 | imethod = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | // we need to update keyboards afterwards, as some of them may not be compatible with | 341 | // we need to update keyboards afterwards, as some of them may not be compatible with |
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 54efb0b..5d0c778 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,673 +1,673 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qtopia/global.h> | 21 | #include <qtopia/global.h> |
22 | #ifdef Q_WS_QWS | 22 | #ifdef Q_WS_QWS |
23 | #include <qtopia/qcopenvelope_qws.h> | 23 | #include <qtopia/qcopenvelope_qws.h> |
24 | #endif | 24 | #endif |
25 | #include <qtopia/resource.h> | 25 | #include <qtopia/resource.h> |
26 | #include <qtopia/applnk.h> | 26 | #include <qtopia/applnk.h> |
27 | #include <qtopia/config.h> | 27 | #include <qtopia/config.h> |
28 | #include <qtopia/qpeapplication.h> | 28 | #include <qtopia/qpeapplication.h> |
29 | #include <qtopia/mimetype.h> | 29 | #include <qtopia/mimetype.h> |
30 | #include <qtopia/private/categories.h> | 30 | #include <qtopia/private/categories.h> |
31 | //#include <qtopia/custom.h> | 31 | //#include <qtopia/custom.h> |
32 | 32 | ||
33 | #include <qdir.h> | 33 | #include <qdir.h> |
34 | #ifdef Q_WS_QWS | 34 | #ifdef Q_WS_QWS |
35 | #include <qwindowsystem_qws.h> | 35 | #include <qwindowsystem_qws.h> |
36 | #endif | 36 | #endif |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qvbox.h> | 39 | #include <qvbox.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qstyle.h> | 41 | #include <qstyle.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qtabbar.h> | 43 | #include <qtabbar.h> |
44 | #include <qwidgetstack.h> | 44 | #include <qwidgetstack.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qframe.h> | 47 | #include <qframe.h> |
48 | #include <qpainter.h> | 48 | #include <qpainter.h> |
49 | #include <qlabel.h> | 49 | #include <qlabel.h> |
50 | #include <qtextstream.h> | 50 | #include <qtextstream.h> |
51 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
52 | 52 | ||
53 | #include "startmenu.h" | 53 | #include "startmenu.h" |
54 | #include "taskbar.h" | 54 | #include "taskbar.h" |
55 | 55 | ||
56 | #include "serverinterface.h" | 56 | #include "serverinterface.h" |
57 | #include "launcherview.h" | 57 | #include "launcherview.h" |
58 | #include "launcher.h" | 58 | #include "launcher.h" |
59 | #include "server.h" | 59 | #include "server.h" |
60 | 60 | ||
61 | #define QTOPIA_INTERNAL_FSLP | 61 | #define QTOPIA_INTERNAL_FSLP |
62 | #include <qtopia/lnkproperties.h> | 62 | #include <qtopia/lnkproperties.h> |
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include <assert.h> | 64 | #include <assert.h> |
65 | 65 | ||
66 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 66 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #include <stdio.h> | 68 | #include <stdio.h> |
69 | #include <sys/vfs.h> | 69 | #include <sys/vfs.h> |
70 | #include <mntent.h> | 70 | #include <mntent.h> |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #ifdef Q_WS_QWS | 73 | #ifdef Q_WS_QWS |
74 | #include <qkeyboard_qws.h> | 74 | #include <qkeyboard_qws.h> |
75 | #include <qpe/lnkproperties.h> | 75 | #include <qpe/lnkproperties.h> |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | 78 | ||
79 | static bool isVisibleWindow( int ); | 79 | static bool isVisibleWindow( int ); |
80 | //=========================================================================== | 80 | //=========================================================================== |
81 | 81 | ||
82 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : | 82 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : |
83 | QVBox( parent ), docview( 0 ) | 83 | QVBox( parent ), docview( 0 ) |
84 | { | 84 | { |
85 | docLoadingWidgetEnabled = false; | 85 | docLoadingWidgetEnabled = false; |
86 | docLoadingWidget = 0; | 86 | docLoadingWidget = 0; |
87 | docLoadingWidgetProgress = 0; | 87 | docLoadingWidgetProgress = 0; |
88 | launcher = parent; | 88 | launcher = parent; |
89 | categoryBar = new LauncherTabBar( this ); | 89 | categoryBar = new LauncherTabBar( this ); |
90 | QPalette pal = categoryBar->palette(); | 90 | QPalette pal = categoryBar->palette(); |
91 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 91 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
92 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 92 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
93 | categoryBar->setPalette( pal ); | 93 | categoryBar->setPalette( pal ); |
94 | stack = new QWidgetStack(this); | 94 | stack = new QWidgetStack(this); |
95 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); | 95 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); |
96 | categoryBar->show(); | 96 | categoryBar->show(); |
97 | stack->show(); | 97 | stack->show(); |
98 | 98 | ||
99 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 99 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
100 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 100 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
101 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 101 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
102 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); | 102 | this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); |
103 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 103 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
104 | this, SLOT(appMessage(const QCString&, const QByteArray&))); | 104 | this, SLOT(appMessage(const QCString&,const QByteArray&))); |
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | createDocLoadingWidget(); | 107 | createDocLoadingWidget(); |
108 | } | 108 | } |
109 | 109 | ||
110 | void LauncherTabWidget::createDocLoadingWidget() | 110 | void LauncherTabWidget::createDocLoadingWidget() |
111 | { | 111 | { |
112 | // Construct the 'doc loading widget' shown when finding documents | 112 | // Construct the 'doc loading widget' shown when finding documents |
113 | 113 | ||
114 | // ### LauncherView class needs changing to be more generic so | 114 | // ### LauncherView class needs changing to be more generic so |
115 | // this widget can change its background similar to the iconviews | 115 | // this widget can change its background similar to the iconviews |
116 | // so the background for this matches | 116 | // so the background for this matches |
117 | docLoadingWidget = new LauncherView( stack ); | 117 | docLoadingWidget = new LauncherView( stack ); |
118 | docLoadingWidget->hideIcons(); | 118 | docLoadingWidget->hideIcons(); |
119 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); | 119 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); |
120 | 120 | ||
121 | docLoadingVBox->setSpacing( 20 ); | 121 | docLoadingVBox->setSpacing( 20 ); |
122 | docLoadingVBox->setMargin( 10 ); | 122 | docLoadingVBox->setMargin( 10 ); |
123 | 123 | ||
124 | QWidget *space1 = new QWidget( docLoadingVBox ); | 124 | QWidget *space1 = new QWidget( docLoadingVBox ); |
125 | docLoadingVBox->setStretchFactor( space1, 1 ); | 125 | docLoadingVBox->setStretchFactor( space1, 1 ); |
126 | 126 | ||
127 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); | 127 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); |
128 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); | 128 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); |
129 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); | 129 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); |
130 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); | 130 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); |
131 | 131 | ||
132 | Config cfg( "Launcher" ); | 132 | Config cfg( "Launcher" ); |
133 | cfg.setGroup( "DocTab" ); | 133 | cfg.setGroup( "DocTab" ); |
134 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 134 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
135 | 135 | ||
136 | QLabel *textLabel = new QLabel( docLoadingVBox ); | 136 | QLabel *textLabel = new QLabel( docLoadingVBox ); |
137 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); | 137 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); |
138 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); | 138 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); |
139 | docLoadingWidgetProgress->setProgress( 0 ); | 139 | docLoadingWidgetProgress->setProgress( 0 ); |
140 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); | 140 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); |
141 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker | 141 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker |
142 | setProgressStyle(); | 142 | setProgressStyle(); |
143 | 143 | ||
144 | if ( docTabEnabled ) | 144 | if ( docTabEnabled ) |
145 | { | 145 | { |
146 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); | 146 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); |
147 | } | 147 | } |
148 | else | 148 | else |
149 | { | 149 | { |
150 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" | 150 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" |
151 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); | 151 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); |
152 | docLoadingWidgetProgress->hide(); | 152 | docLoadingWidgetProgress->hide(); |
153 | docLoadingWidgetEnabled = true; | 153 | docLoadingWidgetEnabled = true; |
154 | } | 154 | } |
155 | 155 | ||
156 | QWidget *space2 = new QWidget( docLoadingVBox ); | 156 | QWidget *space2 = new QWidget( docLoadingVBox ); |
157 | docLoadingVBox->setStretchFactor( space2, 1 ); | 157 | docLoadingVBox->setStretchFactor( space2, 1 ); |
158 | 158 | ||
159 | cfg.setGroup( "Tab Documents" ); // No tr | 159 | cfg.setGroup( "Tab Documents" ); // No tr |
160 | setTabViewAppearance( docLoadingWidget, cfg ); | 160 | setTabViewAppearance( docLoadingWidget, cfg ); |
161 | 161 | ||
162 | stack->addWidget( docLoadingWidget, 0 ); | 162 | stack->addWidget( docLoadingWidget, 0 ); |
163 | } | 163 | } |
164 | 164 | ||
165 | void LauncherTabWidget::initLayout() | 165 | void LauncherTabWidget::initLayout() |
166 | { | 166 | { |
167 | layout()->activate(); | 167 | layout()->activate(); |
168 | docView()->setFocus(); | 168 | docView()->setFocus(); |
169 | categoryBar->showTab("Documents"); | 169 | categoryBar->showTab("Documents"); |
170 | } | 170 | } |
171 | 171 | ||
172 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) | 172 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) |
173 | { | 173 | { |
174 | if ( message == "nextView()" ) | 174 | if ( message == "nextView()" ) |
175 | categoryBar->nextTab(); | 175 | categoryBar->nextTab(); |
176 | } | 176 | } |
177 | 177 | ||
178 | void LauncherTabWidget::raiseTabWidget() | 178 | void LauncherTabWidget::raiseTabWidget() |
179 | { | 179 | { |
180 | if ( categoryBar->currentView() == docView() | 180 | if ( categoryBar->currentView() == docView() |
181 | && docLoadingWidgetEnabled ) { | 181 | && docLoadingWidgetEnabled ) { |
182 | stack->raiseWidget( docLoadingWidget ); | 182 | stack->raiseWidget( docLoadingWidget ); |
183 | docLoadingWidget->updateGeometry(); | 183 | docLoadingWidget->updateGeometry(); |
184 | } else { | 184 | } else { |
185 | stack->raiseWidget( categoryBar->currentView() ); | 185 | stack->raiseWidget( categoryBar->currentView() ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | void LauncherTabWidget::tabProperties() | 189 | void LauncherTabWidget::tabProperties() |
190 | { | 190 | { |
191 | LauncherView *view = categoryBar->currentView(); | 191 | LauncherView *view = categoryBar->currentView(); |
192 | QPopupMenu *m = new QPopupMenu( this ); | 192 | QPopupMenu *m = new QPopupMenu( this ); |
193 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 193 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
194 | m->insertItem( tr("List View"), LauncherView::List ); | 194 | m->insertItem( tr("List View"), LauncherView::List ); |
195 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 195 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
196 | int rv = m->exec( QCursor::pos() ); | 196 | int rv = m->exec( QCursor::pos() ); |
197 | if ( rv >= 0 && rv != view->viewMode() ) { | 197 | if ( rv >= 0 && rv != view->viewMode() ) { |
198 | view->setViewMode( (LauncherView::ViewMode)rv ); | 198 | view->setViewMode( (LauncherView::ViewMode)rv ); |
199 | } | 199 | } |
200 | 200 | ||
201 | delete m; | 201 | delete m; |
202 | } | 202 | } |
203 | 203 | ||
204 | void LauncherTabWidget::deleteView( const QString& id ) | 204 | void LauncherTabWidget::deleteView( const QString& id ) |
205 | { | 205 | { |
206 | LauncherTab *t = categoryBar->launcherTab(id); | 206 | LauncherTab *t = categoryBar->launcherTab(id); |
207 | if ( t ) { | 207 | if ( t ) { |
208 | stack->removeWidget( t->view ); | 208 | stack->removeWidget( t->view ); |
209 | delete t->view; | 209 | delete t->view; |
210 | categoryBar->removeTab( t ); | 210 | categoryBar->removeTab( t ); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 214 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
215 | { | 215 | { |
216 | LauncherView* view = new LauncherView( stack ); | 216 | LauncherView* view = new LauncherView( stack ); |
217 | connect( view, SIGNAL(clicked(const AppLnk*)), | 217 | connect( view, SIGNAL(clicked(const AppLnk*)), |
218 | this, SIGNAL(clicked(const AppLnk*))); | 218 | this, SIGNAL(clicked(const AppLnk*))); |
219 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 219 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
220 | this, SIGNAL(rightPressed(AppLnk*))); | 220 | this, SIGNAL(rightPressed(AppLnk*))); |
221 | 221 | ||
222 | int n = categoryBar->count(); | 222 | int n = categoryBar->count(); |
223 | stack->addWidget( view, n ); | 223 | stack->addWidget( view, n ); |
224 | 224 | ||
225 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); | 225 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); |
226 | categoryBar->insertTab( tab, n-1 ); | 226 | categoryBar->insertTab( tab, n-1 ); |
227 | 227 | ||
228 | if ( id == "Documents" ) | 228 | if ( id == "Documents" ) |
229 | docview = view; | 229 | docview = view; |
230 | 230 | ||
231 | qDebug("inserting %s at %d", id.latin1(), n-1 ); | 231 | qDebug("inserting %s at %d", id.latin1(), n-1 ); |
232 | 232 | ||
233 | Config cfg("Launcher"); | 233 | Config cfg("Launcher"); |
234 | setTabAppearance( tab, cfg ); | 234 | setTabAppearance( tab, cfg ); |
235 | 235 | ||
236 | cfg.setGroup( "GUI" ); | 236 | cfg.setGroup( "GUI" ); |
237 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); | 237 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); |
238 | 238 | ||
239 | return view; | 239 | return view; |
240 | } | 240 | } |
241 | 241 | ||
242 | LauncherView *LauncherTabWidget::view( const QString &id ) | 242 | LauncherView *LauncherTabWidget::view( const QString &id ) |
243 | { | 243 | { |
244 | LauncherTab *t = categoryBar->launcherTab(id); | 244 | LauncherTab *t = categoryBar->launcherTab(id); |
245 | if ( !t ) | 245 | if ( !t ) |
246 | return 0; | 246 | return 0; |
247 | return t->view; | 247 | return t->view; |
248 | } | 248 | } |
249 | 249 | ||
250 | LauncherView *LauncherTabWidget::docView() | 250 | LauncherView *LauncherTabWidget::docView() |
251 | { | 251 | { |
252 | return docview; | 252 | return docview; |
253 | } | 253 | } |
254 | 254 | ||
255 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) | 255 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) |
256 | { | 256 | { |
257 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { | 257 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { |
258 | docLoadingWidgetEnabled = v; | 258 | docLoadingWidgetEnabled = v; |
259 | raiseTabWidget(); | 259 | raiseTabWidget(); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | void LauncherTabWidget::setLoadingProgress( int percent ) | 263 | void LauncherTabWidget::setLoadingProgress( int percent ) |
264 | { | 264 | { |
265 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); | 265 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); |
266 | } | 266 | } |
267 | 267 | ||
268 | // ### this function could more to LauncherView | 268 | // ### this function could more to LauncherView |
269 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) | 269 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) |
270 | { | 270 | { |
271 | // View | 271 | // View |
272 | QString view = cfg.readEntry( "View", "Icon" ); | 272 | QString view = cfg.readEntry( "View", "Icon" ); |
273 | if ( view == "List" ) // No tr | 273 | if ( view == "List" ) // No tr |
274 | v->setViewMode( LauncherView::List ); | 274 | v->setViewMode( LauncherView::List ); |
275 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 275 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
276 | if ( bgType == "Image" ) { // No tr | 276 | if ( bgType == "Image" ) { // No tr |
277 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 277 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
278 | v->setBackgroundType( LauncherView::Image, pm ); | 278 | v->setBackgroundType( LauncherView::Image, pm ); |
279 | } else if ( bgType == "SolidColor" ) { | 279 | } else if ( bgType == "SolidColor" ) { |
280 | QString c = cfg.readEntry( "BackgroundColor" ); | 280 | QString c = cfg.readEntry( "BackgroundColor" ); |
281 | v->setBackgroundType( LauncherView::SolidColor, c ); | 281 | v->setBackgroundType( LauncherView::SolidColor, c ); |
282 | } else { | 282 | } else { |
283 | v->setBackgroundType( LauncherView::Ruled, QString::null ); | 283 | v->setBackgroundType( LauncherView::Ruled, QString::null ); |
284 | } | 284 | } |
285 | QString textCol = cfg.readEntry( "TextColor" ); | 285 | QString textCol = cfg.readEntry( "TextColor" ); |
286 | if ( textCol.isEmpty() ) | 286 | if ( textCol.isEmpty() ) |
287 | v->setTextColor( QColor() ); | 287 | v->setTextColor( QColor() ); |
288 | else | 288 | else |
289 | v->setTextColor( QColor(textCol) ); | 289 | v->setTextColor( QColor(textCol) ); |
290 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); | 290 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); |
291 | 291 | ||
292 | 292 | ||
293 | QStringList font = cfg.readListEntry( "Font", ',' ); | 293 | QStringList font = cfg.readListEntry( "Font", ',' ); |
294 | if ( font.count() == 4 ) | 294 | if ( font.count() == 4 ) |
295 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 295 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
296 | 296 | ||
297 | // ### FIXME TabColor TabTextColor | 297 | // ### FIXME TabColor TabTextColor |
298 | 298 | ||
299 | } | 299 | } |
300 | 300 | ||
301 | // ### Could move to LauncherTab | 301 | // ### Could move to LauncherTab |
302 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) | 302 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) |
303 | { | 303 | { |
304 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr | 304 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr |
305 | 305 | ||
306 | setTabViewAppearance( tab->view, cfg ); | 306 | setTabViewAppearance( tab->view, cfg ); |
307 | 307 | ||
308 | // Tabs | 308 | // Tabs |
309 | QString tabCol = cfg.readEntry( "TabColor" ); | 309 | QString tabCol = cfg.readEntry( "TabColor" ); |
310 | if ( tabCol.isEmpty() ) | 310 | if ( tabCol.isEmpty() ) |
311 | tab->bgColor = QColor(); | 311 | tab->bgColor = QColor(); |
312 | else | 312 | else |
313 | tab->bgColor = QColor(tabCol); | 313 | tab->bgColor = QColor(tabCol); |
314 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 314 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
315 | if ( tabTextCol.isEmpty() ) | 315 | if ( tabTextCol.isEmpty() ) |
316 | tab->fgColor = QColor(); | 316 | tab->fgColor = QColor(); |
317 | else | 317 | else |
318 | tab->fgColor = QColor(tabTextCol); | 318 | tab->fgColor = QColor(tabTextCol); |
319 | } | 319 | } |
320 | 320 | ||
321 | void LauncherTabWidget::paletteChange( const QPalette &p ) | 321 | void LauncherTabWidget::paletteChange( const QPalette &p ) |
322 | { | 322 | { |
323 | QVBox::paletteChange( p ); | 323 | QVBox::paletteChange( p ); |
324 | QPalette pal = palette(); | 324 | QPalette pal = palette(); |
325 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 325 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
326 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 326 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
327 | categoryBar->setPalette( pal ); | 327 | categoryBar->setPalette( pal ); |
328 | categoryBar->update(); | 328 | categoryBar->update(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void LauncherTabWidget::styleChange( QStyle & ) | 331 | void LauncherTabWidget::styleChange( QStyle & ) |
332 | { | 332 | { |
333 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); | 333 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); |
334 | } | 334 | } |
335 | 335 | ||
336 | void LauncherTabWidget::setProgressStyle() | 336 | void LauncherTabWidget::setProgressStyle() |
337 | { | 337 | { |
338 | if (docLoadingWidgetProgress) { | 338 | if (docLoadingWidgetProgress) { |
339 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); | 339 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); |
340 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); | 340 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); |
341 | docLoadingWidgetProgress->setMargin( 1 ); | 341 | docLoadingWidgetProgress->setMargin( 1 ); |
342 | docLoadingWidgetProgress->setLineWidth( 1 ); | 342 | docLoadingWidgetProgress->setLineWidth( 1 ); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | void LauncherTabWidget::setBusy(bool on) | 346 | void LauncherTabWidget::setBusy(bool on) |
347 | { | 347 | { |
348 | if ( on ) | 348 | if ( on ) |
349 | currentView()->setBusy(TRUE); | 349 | currentView()->setBusy(TRUE); |
350 | else { | 350 | else { |
351 | for ( int i = 0; i < categoryBar->count(); i++ ) { | 351 | for ( int i = 0; i < categoryBar->count(); i++ ) { |
352 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; | 352 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; |
353 | view->setBusy( FALSE ); | 353 | view->setBusy( FALSE ); |
354 | } | 354 | } |
355 | } | 355 | } |
356 | } | 356 | } |
357 | 357 | ||
358 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { | 358 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { |
359 | for (int i = 0; i < categoryBar->count(); i++ ) { | 359 | for (int i = 0; i < categoryBar->count(); i++ ) { |
360 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; | 360 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; |
361 | view->setBusyIndicatorType( str ); | 361 | view->setBusyIndicatorType( str ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | LauncherView *LauncherTabWidget::currentView(void) | 365 | LauncherView *LauncherTabWidget::currentView(void) |
366 | { | 366 | { |
367 | return (LauncherView*)stack->visibleWidget(); | 367 | return (LauncherView*)stack->visibleWidget(); |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
371 | 371 | ||
372 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) | 372 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) |
373 | { | 373 | { |
374 | QDataStream stream( data, IO_ReadOnly ); | 374 | QDataStream stream( data, IO_ReadOnly ); |
375 | if ( msg == "setTabView(QString,int)" ) { | 375 | if ( msg == "setTabView(QString,int)" ) { |
376 | QString id; | 376 | QString id; |
377 | stream >> id; | 377 | stream >> id; |
378 | int mode; | 378 | int mode; |
379 | stream >> mode; | 379 | stream >> mode; |
380 | if ( view(id) ) | 380 | if ( view(id) ) |
381 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 381 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
382 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 382 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
383 | QString id; | 383 | QString id; |
384 | stream >> id; | 384 | stream >> id; |
385 | int mode; | 385 | int mode; |
386 | stream >> mode; | 386 | stream >> mode; |
387 | QString pixmapOrColor; | 387 | QString pixmapOrColor; |
388 | stream >> pixmapOrColor; | 388 | stream >> pixmapOrColor; |
389 | if ( view(id) ) | 389 | if ( view(id) ) |
390 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 390 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
391 | if ( id == "Documents" ) | 391 | if ( id == "Documents" ) |
392 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 392 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
393 | } else if ( msg == "setTextColor(QString,QString)" ) { | 393 | } else if ( msg == "setTextColor(QString,QString)" ) { |
394 | QString id; | 394 | QString id; |
395 | stream >> id; | 395 | stream >> id; |
396 | QString color; | 396 | QString color; |
397 | stream >> color; | 397 | stream >> color; |
398 | if ( view(id) ) | 398 | if ( view(id) ) |
399 | view(id)->setTextColor( QColor(color) ); | 399 | view(id)->setTextColor( QColor(color) ); |
400 | if ( id == "Documents" ) | 400 | if ( id == "Documents" ) |
401 | docLoadingWidget->setTextColor( QColor(color) ); | 401 | docLoadingWidget->setTextColor( QColor(color) ); |
402 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 402 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
403 | QString id; | 403 | QString id; |
404 | stream >> id; | 404 | stream >> id; |
405 | QString fam; | 405 | QString fam; |
406 | stream >> fam; | 406 | stream >> fam; |
407 | int size; | 407 | int size; |
408 | stream >> size; | 408 | stream >> size; |
409 | int weight; | 409 | int weight; |
410 | stream >> weight; | 410 | stream >> weight; |
411 | int italic; | 411 | int italic; |
412 | stream >> italic; | 412 | stream >> italic; |
413 | if ( view(id) ) { | 413 | if ( view(id) ) { |
414 | if ( !fam.isEmpty() ) { | 414 | if ( !fam.isEmpty() ) { |
415 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 415 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
416 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | 416 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); |
417 | } else { | 417 | } else { |
418 | view(id)->clearViewFont(); | 418 | view(id)->clearViewFont(); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | }else if ( msg == "setBusyIndicatorType(QString)" ) { | 421 | }else if ( msg == "setBusyIndicatorType(QString)" ) { |
422 | QString type; | 422 | QString type; |
423 | stream >> type; | 423 | stream >> type; |
424 | setBusyIndicatorType( type ); | 424 | setBusyIndicatorType( type ); |
425 | }else if ( msg == "home()" ) { | 425 | }else if ( msg == "home()" ) { |
426 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { | 426 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { |
427 | if (categoryBar) | 427 | if (categoryBar) |
428 | categoryBar->nextTab(); | 428 | categoryBar->nextTab(); |
429 | }else | 429 | }else |
430 | static_cast<QWidget*>(parent())->raise(); | 430 | static_cast<QWidget*>(parent())->raise(); |
431 | } | 431 | } |
432 | } | 432 | } |
433 | 433 | ||
434 | 434 | ||
435 | 435 | ||
436 | //--------------------------------------------------------------------------- | 436 | //--------------------------------------------------------------------------- |
437 | 437 | ||
438 | Launcher::Launcher() | 438 | Launcher::Launcher() |
439 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) | 439 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) |
440 | { | 440 | { |
441 | tabs = 0; | 441 | tabs = 0; |
442 | tb = 0; | 442 | tb = 0; |
443 | Config cfg( "Launcher" ); | 443 | Config cfg( "Launcher" ); |
444 | cfg.setGroup( "DocTab" ); | 444 | cfg.setGroup( "DocTab" ); |
445 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 445 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
446 | } | 446 | } |
447 | 447 | ||
448 | void Launcher::createGUI() | 448 | void Launcher::createGUI() |
449 | { | 449 | { |
450 | setCaption( tr("Launcher") ); | 450 | setCaption( tr("Launcher") ); |
451 | 451 | ||
452 | // we have a pretty good idea how big we'll be | 452 | // we have a pretty good idea how big we'll be |
453 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 453 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
454 | 454 | ||
455 | tb = new TaskBar; | 455 | tb = new TaskBar; |
456 | tabs = new LauncherTabWidget( this ); | 456 | tabs = new LauncherTabWidget( this ); |
457 | setCentralWidget( tabs ); | 457 | setCentralWidget( tabs ); |
458 | 458 | ||
459 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); | 459 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); |
460 | tb->show(); | 460 | tb->show(); |
461 | 461 | ||
462 | qApp->installEventFilter( this ); | 462 | qApp->installEventFilter( this ); |
463 | 463 | ||
464 | 464 | ||
465 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); | 465 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); |
466 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); | 466 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); |
467 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); | 467 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); |
468 | 468 | ||
469 | connect( tb, SIGNAL(tabSelected(const QString&)), | 469 | connect( tb, SIGNAL(tabSelected(const QString&)), |
470 | this, SLOT(showTab(const QString&)) ); | 470 | this, SLOT(showTab(const QString&)) ); |
471 | connect( tabs, SIGNAL(selected(const QString&)), | 471 | connect( tabs, SIGNAL(selected(const QString&)), |
472 | this, SLOT(viewSelected(const QString&)) ); | 472 | this, SLOT(viewSelected(const QString&)) ); |
473 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 473 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
474 | this, SLOT(select(const AppLnk*))); | 474 | this, SLOT(select(const AppLnk*))); |
475 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 475 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
476 | this, SLOT(properties(AppLnk*))); | 476 | this, SLOT(properties(AppLnk*))); |
477 | 477 | ||
478 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 478 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
479 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 479 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
480 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 480 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
481 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 481 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); |
482 | #endif | 482 | #endif |
483 | 483 | ||
484 | // all documents | 484 | // all documents |
485 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 485 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
486 | QPixmap pm; | 486 | QPixmap pm; |
487 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 487 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
488 | // It could add this itself if it handles docs | 488 | // It could add this itself if it handles docs |
489 | 489 | ||
490 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); | 490 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); |
491 | 491 | ||
492 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); | 492 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); |
493 | qApp->setMainWidget( this ); | 493 | qApp->setMainWidget( this ); |
494 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); | 494 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); |
495 | } | 495 | } |
496 | 496 | ||
497 | Launcher::~Launcher() | 497 | Launcher::~Launcher() |
498 | { | 498 | { |
499 | if ( tb ) | 499 | if ( tb ) |
500 | destroyGUI(); | 500 | destroyGUI(); |
501 | } | 501 | } |
502 | 502 | ||
503 | bool Launcher::requiresDocuments() const | 503 | bool Launcher::requiresDocuments() const |
504 | { | 504 | { |
505 | Config cfg( "Launcher" ); | 505 | Config cfg( "Launcher" ); |
506 | cfg.setGroup( "DocTab" ); | 506 | cfg.setGroup( "DocTab" ); |
507 | return cfg.readBoolEntry( "Enable", true ); | 507 | return cfg.readBoolEntry( "Enable", true ); |
508 | } | 508 | } |
509 | 509 | ||
510 | void Launcher::makeVisible() | 510 | void Launcher::makeVisible() |
511 | { | 511 | { |
512 | showMaximized(); | 512 | showMaximized(); |
513 | } | 513 | } |
514 | 514 | ||
515 | void Launcher::destroyGUI() | 515 | void Launcher::destroyGUI() |
516 | { | 516 | { |
517 | delete tb; | 517 | delete tb; |
518 | tb = 0; | 518 | tb = 0; |
519 | delete tabs; | 519 | delete tabs; |
520 | tabs =0; | 520 | tabs =0; |
521 | } | 521 | } |
522 | 522 | ||
523 | bool Launcher::eventFilter( QObject*, QEvent *ev ) | 523 | bool Launcher::eventFilter( QObject*, QEvent *ev ) |
524 | { | 524 | { |
525 | #ifdef QT_QWS_CUSTOM | 525 | #ifdef QT_QWS_CUSTOM |
526 | if ( ev->type() == QEvent::KeyPress ) { | 526 | if ( ev->type() == QEvent::KeyPress ) { |
527 | QKeyEvent *ke = (QKeyEvent *)ev; | 527 | QKeyEvent *ke = (QKeyEvent *)ev; |
528 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 528 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
529 | QWidget *active = qApp->activeWindow(); | 529 | QWidget *active = qApp->activeWindow(); |
530 | if ( active && active->isPopup() ) | 530 | if ( active && active->isPopup() ) |
531 | active->close(); | 531 | active->close(); |
532 | else { | 532 | else { |
533 | Global::terminateBuiltin("calibrate"); // No tr | 533 | Global::terminateBuiltin("calibrate"); // No tr |
534 | tb->launchStartMenu(); | 534 | tb->launchStartMenu(); |
535 | } | 535 | } |
536 | return TRUE; | 536 | return TRUE; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | #else | 539 | #else |
540 | Q_UNUSED(ev); | 540 | Q_UNUSED(ev); |
541 | #endif | 541 | #endif |
542 | return FALSE; | 542 | return FALSE; |
543 | } | 543 | } |
544 | 544 | ||
545 | void Launcher::toggleSymbolInput() | 545 | void Launcher::toggleSymbolInput() |
546 | { | 546 | { |
547 | tb->toggleSymbolInput(); | 547 | tb->toggleSymbolInput(); |
548 | } | 548 | } |
549 | 549 | ||
550 | void Launcher::toggleNumLockState() | 550 | void Launcher::toggleNumLockState() |
551 | { | 551 | { |
552 | tb->toggleNumLockState(); | 552 | tb->toggleNumLockState(); |
553 | } | 553 | } |
554 | 554 | ||
555 | void Launcher::toggleCapsLockState() | 555 | void Launcher::toggleCapsLockState() |
556 | { | 556 | { |
557 | tb->toggleCapsLockState(); | 557 | tb->toggleCapsLockState(); |
558 | } | 558 | } |
559 | 559 | ||
560 | static bool isVisibleWindow(int wid) | 560 | static bool isVisibleWindow(int wid) |
561 | { | 561 | { |
562 | #ifdef Q_WS_QWS | 562 | #ifdef Q_WS_QWS |
563 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 563 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
564 | QWSWindow* w; | 564 | QWSWindow* w; |
565 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 565 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
566 | if ( w->winId() == wid ) | 566 | if ( w->winId() == wid ) |
567 | return !w->isFullyObscured(); | 567 | return !w->isFullyObscured(); |
568 | } | 568 | } |
569 | #endif | 569 | #endif |
570 | return FALSE; | 570 | return FALSE; |
571 | } | 571 | } |
572 | 572 | ||
573 | void Launcher::viewSelected(const QString& s) | 573 | void Launcher::viewSelected(const QString& s) |
574 | { | 574 | { |
575 | setCaption( s + tr(" - Launcher") ); | 575 | setCaption( s + tr(" - Launcher") ); |
576 | } | 576 | } |
577 | 577 | ||
578 | void Launcher::showTab(const QString& id) | 578 | void Launcher::showTab(const QString& id) |
579 | { | 579 | { |
580 | tabs->categoryBar->showTab(id); | 580 | tabs->categoryBar->showTab(id); |
581 | raise(); | 581 | raise(); |
582 | } | 582 | } |
583 | 583 | ||
584 | void Launcher::select( const AppLnk *appLnk ) | 584 | void Launcher::select( const AppLnk *appLnk ) |
585 | { | 585 | { |
586 | if ( appLnk->type() == "Folder" ) { // No tr | 586 | if ( appLnk->type() == "Folder" ) { // No tr |
587 | // Not supported: flat is simpler for the user | 587 | // Not supported: flat is simpler for the user |
588 | } else { | 588 | } else { |
589 | if ( appLnk->exec().isNull() ) { | 589 | if ( appLnk->exec().isNull() ) { |
590 | int i = QMessageBox::information(this,tr("No application"), | 590 | int i = QMessageBox::information(this,tr("No application"), |
591 | tr("<p>No application is defined for this document." | 591 | tr("<p>No application is defined for this document." |
592 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); | 592 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); |
593 | 593 | ||
594 | /* ### Fixme */ | 594 | /* ### Fixme */ |
595 | if ( i == 1 ) | 595 | if ( i == 1 ) |
596 | Global::execute("textedit",appLnk->file()); | 596 | Global::execute("textedit",appLnk->file()); |
597 | 597 | ||
598 | return; | 598 | return; |
599 | } | 599 | } |
600 | tabs->setBusy(TRUE); | 600 | tabs->setBusy(TRUE); |
601 | emit executing( appLnk ); | 601 | emit executing( appLnk ); |
602 | appLnk->execute(); | 602 | appLnk->execute(); |
603 | } | 603 | } |
604 | } | 604 | } |
605 | 605 | ||
606 | void Launcher::properties( AppLnk *appLnk ) | 606 | void Launcher::properties( AppLnk *appLnk ) |
607 | { | 607 | { |
608 | if ( appLnk->type() == "Folder" ) { // No tr | 608 | if ( appLnk->type() == "Folder" ) { // No tr |
609 | // Not supported: flat is simpler for the user | 609 | // Not supported: flat is simpler for the user |
610 | } else { | 610 | } else { |
611 | /* ### libqtopia FIXME also moving docLnks... */ | 611 | /* ### libqtopia FIXME also moving docLnks... */ |
612 | LnkProperties prop(appLnk,0 ); | 612 | LnkProperties prop(appLnk,0 ); |
613 | 613 | ||
614 | QPEApplication::execDialog( &prop ); | 614 | QPEApplication::execDialog( &prop ); |
615 | } | 615 | } |
616 | } | 616 | } |
617 | 617 | ||
618 | void Launcher::storageChanged( const QList<FileSystem> &fs ) | 618 | void Launcher::storageChanged( const QList<FileSystem> &fs ) |
619 | { | 619 | { |
620 | // ### update combo boxes if we had a combo box for the storage type | 620 | // ### update combo boxes if we had a combo box for the storage type |
621 | } | 621 | } |
622 | 622 | ||
623 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 623 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
624 | { | 624 | { |
625 | QDataStream stream( data, IO_ReadOnly ); | 625 | QDataStream stream( data, IO_ReadOnly ); |
626 | if ( msg == "busy()" ) { | 626 | if ( msg == "busy()" ) { |
627 | tb->startWait(); | 627 | tb->startWait(); |
628 | } else if ( msg == "notBusy(QString)" ) { | 628 | } else if ( msg == "notBusy(QString)" ) { |
629 | QString app; | 629 | QString app; |
630 | stream >> app; | 630 | stream >> app; |
631 | tabs->setBusy(FALSE); | 631 | tabs->setBusy(FALSE); |
632 | tb->stopWait(app); | 632 | tb->stopWait(app); |
633 | } else if (msg == "applyStyle()") { | 633 | } else if (msg == "applyStyle()") { |
634 | tabs->currentView()->relayout(); | 634 | tabs->currentView()->relayout(); |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | // These are the update functions from the server | 638 | // These are the update functions from the server |
639 | void Launcher::typeAdded( const QString& type, const QString& name, | 639 | void Launcher::typeAdded( const QString& type, const QString& name, |
640 | const QPixmap& pixmap, const QPixmap& ) | 640 | const QPixmap& pixmap, const QPixmap& ) |
641 | { | 641 | { |
642 | tabs->newView( type, pixmap, name ); | 642 | tabs->newView( type, pixmap, name ); |
643 | ids.append( type ); | 643 | ids.append( type ); |
644 | /* this will be called in applicationScanningProgress with value 100! */ | 644 | /* this will be called in applicationScanningProgress with value 100! */ |
645 | // tb->refreshStartMenu(); | 645 | // tb->refreshStartMenu(); |
646 | 646 | ||
647 | static bool first = TRUE; | 647 | static bool first = TRUE; |
648 | if ( first ) { | 648 | if ( first ) { |
649 | first = FALSE; | 649 | first = FALSE; |
650 | tabs->categoryBar->showTab(type); | 650 | tabs->categoryBar->showTab(type); |
651 | } | 651 | } |
652 | 652 | ||
653 | tabs->view( type )->setUpdatesEnabled( FALSE ); | 653 | tabs->view( type )->setUpdatesEnabled( FALSE ); |
654 | tabs->view( type )->setSortEnabled( FALSE ); | 654 | tabs->view( type )->setSortEnabled( FALSE ); |
655 | } | 655 | } |
656 | 656 | ||
657 | void Launcher::typeRemoved( const QString& type ) | 657 | void Launcher::typeRemoved( const QString& type ) |
658 | { | 658 | { |
659 | tabs->view( type )->removeAllItems(); | 659 | tabs->view( type )->removeAllItems(); |
660 | tabs->deleteView( type ); | 660 | tabs->deleteView( type ); |
661 | ids.remove( type ); | 661 | ids.remove( type ); |
662 | /* this will be called in applicationScanningProgress with value 100! */ | 662 | /* this will be called in applicationScanningProgress with value 100! */ |
663 | // tb->refreshStartMenu(); | 663 | // tb->refreshStartMenu(); |
664 | } | 664 | } |
665 | 665 | ||
666 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) | 666 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) |
667 | { | 667 | { |
668 | if ( app.type() == "Separator" ) // No tr | 668 | if ( app.type() == "Separator" ) // No tr |
669 | return; | 669 | return; |
670 | 670 | ||
671 | LauncherView *view = tabs->view( type ); | 671 | LauncherView *view = tabs->view( type ); |
672 | if ( view ) | 672 | if ( view ) |
673 | view->addItem( new AppLnk( app ), FALSE ); | 673 | view->addItem( new AppLnk( app ), FALSE ); |
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 513b1bd..6c7d487 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -426,392 +426,392 @@ void LauncherItem::paintAnimatedIcon( QPainter *p ) | |||
426 | x1 = x() + (width() - w) / 2 - liv->contentsX(); | 426 | x1 = x() + (width() - w) / 2 - liv->contentsX(); |
427 | y1 = y() - liv->contentsY(); | 427 | y1 = y() - liv->contentsY(); |
428 | } else { | 428 | } else { |
429 | x1 = x() - liv->contentsX(); | 429 | x1 = x() - liv->contentsX(); |
430 | y1 = y() + (height() - h) / 2 - liv->contentsY(); | 430 | y1 = y() + (height() - h) / 2 - liv->contentsY(); |
431 | } | 431 | } |
432 | y1 -= 2; | 432 | y1 -= 2; |
433 | p2.translate(-x1,-y1); | 433 | p2.translate(-x1,-y1); |
434 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); | 434 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); |
435 | int bounceY = 2; | 435 | int bounceY = 2; |
436 | #ifdef BOUNCE_BUSY_ICON | 436 | #ifdef BOUNCE_BUSY_ICON |
437 | if ( busyType == BIT_Animated ) { | 437 | if ( busyType == BIT_Animated ) { |
438 | bounceY = 4 - ((iteration+2)%8); | 438 | bounceY = 4 - ((iteration+2)%8); |
439 | bounceY = bounceY < 0 ? -bounceY : bounceY; | 439 | bounceY = bounceY < 0 ? -bounceY : bounceY; |
440 | } | 440 | } |
441 | #endif | 441 | #endif |
442 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); | 442 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); |
443 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 443 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
444 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); | 444 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); |
445 | #endif | 445 | #endif |
446 | p->drawPixmap( x1, y1, dblBuf ); | 446 | p->drawPixmap( x1, y1, dblBuf ); |
447 | } | 447 | } |
448 | 448 | ||
449 | void LauncherItem::animateIcon() | 449 | void LauncherItem::animateIcon() |
450 | { | 450 | { |
451 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 451 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
452 | 452 | ||
453 | if ( liv->busyItem() != this || !app ) | 453 | if ( liv->busyItem() != this || !app ) |
454 | return; | 454 | return; |
455 | 455 | ||
456 | // Highlight the icon | 456 | // Highlight the icon |
457 | if ( iteration == 0 ) { | 457 | if ( iteration == 0 ) { |
458 | QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); | 458 | QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); |
459 | QImage img = src.convertToImage(); | 459 | QImage img = src.convertToImage(); |
460 | QRgb *rgb; | 460 | QRgb *rgb; |
461 | int count; | 461 | int count; |
462 | if ( img.depth() == 32 ) { | 462 | if ( img.depth() == 32 ) { |
463 | rgb = (QRgb*)img.bits(); | 463 | rgb = (QRgb*)img.bits(); |
464 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); | 464 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); |
465 | } else { | 465 | } else { |
466 | rgb = img.colorTable(); | 466 | rgb = img.colorTable(); |
467 | count = img.numColors(); | 467 | count = img.numColors(); |
468 | } | 468 | } |
469 | for ( int r = 0; r < count; r++, rgb++ ) { | 469 | for ( int r = 0; r < count; r++, rgb++ ) { |
470 | #if defined(BRIGHTEN_BUSY_ICON) | 470 | #if defined(BRIGHTEN_BUSY_ICON) |
471 | QColor c(*rgb); | 471 | QColor c(*rgb); |
472 | int h, s, v; | 472 | int h, s, v; |
473 | c.hsv(&h,&s,&v); | 473 | c.hsv(&h,&s,&v); |
474 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); | 474 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); |
475 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); | 475 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); |
476 | #elif defined(ALPHA_FADE_BUSY_ICON) | 476 | #elif defined(ALPHA_FADE_BUSY_ICON) |
477 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); | 477 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); |
478 | #endif | 478 | #endif |
479 | } | 479 | } |
480 | src.convertFromImage( img ); | 480 | src.convertFromImage( img ); |
481 | setPixmap( src ); | 481 | setPixmap( src ); |
482 | } | 482 | } |
483 | 483 | ||
484 | iteration++; | 484 | iteration++; |
485 | 485 | ||
486 | // Paint animation overlay | 486 | // Paint animation overlay |
487 | QPainter p( liv->viewport() ); | 487 | QPainter p( liv->viewport() ); |
488 | paintAnimatedIcon( &p ); | 488 | paintAnimatedIcon( &p ); |
489 | } | 489 | } |
490 | 490 | ||
491 | void LauncherItem::resetIcon() | 491 | void LauncherItem::resetIcon() |
492 | { | 492 | { |
493 | iteration = 0; | 493 | iteration = 0; |
494 | setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); | 494 | setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); |
495 | } | 495 | } |
496 | 496 | ||
497 | //=========================================================================== | 497 | //=========================================================================== |
498 | 498 | ||
499 | QStringList LauncherIconView::mimeTypes() const | 499 | QStringList LauncherIconView::mimeTypes() const |
500 | { | 500 | { |
501 | QStringList r; | 501 | QStringList r; |
502 | QDictIterator<void> it(mimes); | 502 | QDictIterator<void> it(mimes); |
503 | while (it.current()) { | 503 | while (it.current()) { |
504 | r.append(it.currentKey()); | 504 | r.append(it.currentKey()); |
505 | ++it; | 505 | ++it; |
506 | } | 506 | } |
507 | r.sort(); | 507 | r.sort(); |
508 | return r; | 508 | return r; |
509 | } | 509 | } |
510 | 510 | ||
511 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 511 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
512 | { | 512 | { |
513 | addCatsAndMimes(app); | 513 | addCatsAndMimes(app); |
514 | 514 | ||
515 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 515 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
516 | && (cf == 0 || app->categories().contains(cf) | 516 | && (cf == 0 || app->categories().contains(cf) |
517 | || cf == -1 && app->categories().count() == 0 ) ) | 517 | || cf == -1 && app->categories().count() == 0 ) ) |
518 | (void) new LauncherItem( this, app, bigIcns ); | 518 | (void) new LauncherItem( this, app, bigIcns ); |
519 | else | 519 | else |
520 | hidden.append(app); | 520 | hidden.append(app); |
521 | if ( resort ) | 521 | if ( resort ) |
522 | sort(); | 522 | sort(); |
523 | } | 523 | } |
524 | 524 | ||
525 | void LauncherIconView::updateCategoriesAndMimeTypes() | 525 | void LauncherIconView::updateCategoriesAndMimeTypes() |
526 | { | 526 | { |
527 | mimes.clear(); | 527 | mimes.clear(); |
528 | cats.clear(); | 528 | cats.clear(); |
529 | LauncherItem* item = (LauncherItem*)firstItem(); | 529 | LauncherItem* item = (LauncherItem*)firstItem(); |
530 | while (item) { | 530 | while (item) { |
531 | addCatsAndMimes(item->appLnk()); | 531 | addCatsAndMimes(item->appLnk()); |
532 | item = (LauncherItem*)item->nextItem(); | 532 | item = (LauncherItem*)item->nextItem(); |
533 | } | 533 | } |
534 | QListIterator<AppLnk> it(hidden); | 534 | QListIterator<AppLnk> it(hidden); |
535 | AppLnk* l; | 535 | AppLnk* l; |
536 | while ((l=it.current())) { | 536 | while ((l=it.current())) { |
537 | addCatsAndMimes(l); | 537 | addCatsAndMimes(l); |
538 | ++it; | 538 | ++it; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | void LauncherIconView::hideOrShowItems(bool resort) | 542 | void LauncherIconView::hideOrShowItems(bool resort) |
543 | { | 543 | { |
544 | viewport()->setUpdatesEnabled( FALSE ); | 544 | viewport()->setUpdatesEnabled( FALSE ); |
545 | hidden.setAutoDelete(FALSE); | 545 | hidden.setAutoDelete(FALSE); |
546 | QList<AppLnk> links=hidden; | 546 | QList<AppLnk> links=hidden; |
547 | hidden.clear(); | 547 | hidden.clear(); |
548 | hidden.setAutoDelete(TRUE); | 548 | hidden.setAutoDelete(TRUE); |
549 | LauncherItem* item = (LauncherItem*)firstItem(); | 549 | LauncherItem* item = (LauncherItem*)firstItem(); |
550 | while (item) { | 550 | while (item) { |
551 | links.append(item->takeAppLnk()); | 551 | links.append(item->takeAppLnk()); |
552 | item = (LauncherItem*)item->nextItem(); | 552 | item = (LauncherItem*)item->nextItem(); |
553 | } | 553 | } |
554 | clear(); | 554 | clear(); |
555 | QListIterator<AppLnk> it(links); | 555 | QListIterator<AppLnk> it(links); |
556 | AppLnk* l; | 556 | AppLnk* l; |
557 | while ((l=it.current())) { | 557 | while ((l=it.current())) { |
558 | addItem(l,FALSE); | 558 | addItem(l,FALSE); |
559 | ++it; | 559 | ++it; |
560 | } | 560 | } |
561 | if ( resort && !autoArrange() ) | 561 | if ( resort && !autoArrange() ) |
562 | sort(); | 562 | sort(); |
563 | viewport()->setUpdatesEnabled( TRUE ); | 563 | viewport()->setUpdatesEnabled( TRUE ); |
564 | } | 564 | } |
565 | 565 | ||
566 | bool LauncherIconView::removeLink(const QString& linkfile) | 566 | bool LauncherIconView::removeLink(const QString& linkfile) |
567 | { | 567 | { |
568 | LauncherItem* item = (LauncherItem*)firstItem(); | 568 | LauncherItem* item = (LauncherItem*)firstItem(); |
569 | AppLnk* l; | 569 | AppLnk* l; |
570 | bool did = FALSE; | 570 | bool did = FALSE; |
571 | DocLnk dl(linkfile); | 571 | DocLnk dl(linkfile); |
572 | while (item) { | 572 | while (item) { |
573 | l = item->appLnk(); | 573 | l = item->appLnk(); |
574 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); | 574 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); |
575 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 575 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
576 | || l->fileKnown() && ( | 576 | || l->fileKnown() && ( |
577 | l->file() == linkfile | 577 | l->file() == linkfile |
578 | || dl.isValid() && dl.file() == l->file() ) ) { | 578 | || dl.isValid() && dl.file() == l->file() ) ) { |
579 | delete item; | 579 | delete item; |
580 | did = TRUE; | 580 | did = TRUE; |
581 | } | 581 | } |
582 | item = nextItem; | 582 | item = nextItem; |
583 | } | 583 | } |
584 | QListIterator<AppLnk> it(hidden); | 584 | QListIterator<AppLnk> it(hidden); |
585 | while ((l=it.current())) { | 585 | while ((l=it.current())) { |
586 | ++it; | 586 | ++it; |
587 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 587 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
588 | || l->file() == linkfile | 588 | || l->file() == linkfile |
589 | || dl.isValid() && dl.file() == l->file() ) { | 589 | || dl.isValid() && dl.file() == l->file() ) { |
590 | hidden.removeRef(l); | 590 | hidden.removeRef(l); |
591 | did = TRUE; | 591 | did = TRUE; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | return did; | 594 | return did; |
595 | } | 595 | } |
596 | 596 | ||
597 | //=========================================================================== | 597 | //=========================================================================== |
598 | 598 | ||
599 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 599 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
600 | : QVBox( parent, name, fl ) | 600 | : QVBox( parent, name, fl ) |
601 | { | 601 | { |
602 | catmb = 0; | 602 | catmb = 0; |
603 | icons = new LauncherIconView( this ); | 603 | icons = new LauncherIconView( this ); |
604 | setFocusProxy(icons); | 604 | setFocusProxy(icons); |
605 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); | 605 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); |
606 | 606 | ||
607 | icons->setItemsMovable( FALSE ); | 607 | icons->setItemsMovable( FALSE ); |
608 | icons->setAutoArrange( TRUE ); | 608 | icons->setAutoArrange( TRUE ); |
609 | icons->setSorting( TRUE ); | 609 | icons->setSorting( TRUE ); |
610 | icons->setFrameStyle( QFrame::NoFrame ); | 610 | icons->setFrameStyle( QFrame::NoFrame ); |
611 | icons->setMargin( 0 ); | 611 | icons->setMargin( 0 ); |
612 | icons->setSelectionMode( QIconView::NoSelection ); | 612 | icons->setSelectionMode( QIconView::NoSelection ); |
613 | icons->setBackgroundMode( PaletteBase ); | 613 | icons->setBackgroundMode( PaletteBase ); |
614 | icons->setResizeMode( QIconView::Fixed ); | 614 | icons->setResizeMode( QIconView::Fixed ); |
615 | vmode = (ViewMode)-1; | 615 | vmode = (ViewMode)-1; |
616 | setViewMode( Icon ); | 616 | setViewMode( Icon ); |
617 | 617 | ||
618 | connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), | 618 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), |
619 | SLOT(itemClicked(int, QIconViewItem *)) ); | 619 | SLOT(itemClicked(int,QIconViewItem*)) ); |
620 | connect( icons, SIGNAL(selectionChanged()), | 620 | connect( icons, SIGNAL(selectionChanged()), |
621 | SLOT(selectionChanged()) ); | 621 | SLOT(selectionChanged()) ); |
622 | connect( icons, SIGNAL(returnPressed(QIconViewItem *)), | 622 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), |
623 | SLOT(returnPressed(QIconViewItem *)) ); | 623 | SLOT(returnPressed(QIconViewItem*)) ); |
624 | connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), | 624 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), |
625 | SLOT(itemPressed(int, QIconViewItem *)) ); | 625 | SLOT(itemPressed(int,QIconViewItem*)) ); |
626 | 626 | ||
627 | tools = 0; | 627 | tools = 0; |
628 | setBackgroundType( Ruled, QString::null ); | 628 | setBackgroundType( Ruled, QString::null ); |
629 | } | 629 | } |
630 | 630 | ||
631 | LauncherView::~LauncherView() | 631 | LauncherView::~LauncherView() |
632 | { | 632 | { |
633 | if ( bgCache && bgCache->contains( bgName ) ) | 633 | if ( bgCache && bgCache->contains( bgName ) ) |
634 | (*bgCache)[bgName]->ref--; | 634 | (*bgCache)[bgName]->ref--; |
635 | } | 635 | } |
636 | 636 | ||
637 | void LauncherView::hideIcons() | 637 | void LauncherView::hideIcons() |
638 | { | 638 | { |
639 | icons->hide(); | 639 | icons->hide(); |
640 | } | 640 | } |
641 | 641 | ||
642 | void LauncherView::setToolsEnabled(bool y) | 642 | void LauncherView::setToolsEnabled(bool y) |
643 | { | 643 | { |
644 | if ( !y != !tools ) { | 644 | if ( !y != !tools ) { |
645 | if ( y ) { | 645 | if ( y ) { |
646 | tools = new QHBox(this); | 646 | tools = new QHBox(this); |
647 | 647 | ||
648 | // Type filter | 648 | // Type filter |
649 | typemb = new QComboBox(tools); | 649 | typemb = new QComboBox(tools); |
650 | QSizePolicy p = typemb->sizePolicy(); | 650 | QSizePolicy p = typemb->sizePolicy(); |
651 | p.setHorData(QSizePolicy::Expanding); | 651 | p.setHorData(QSizePolicy::Expanding); |
652 | typemb->setSizePolicy(p); | 652 | typemb->setSizePolicy(p); |
653 | 653 | ||
654 | // Category filter | 654 | // Category filter |
655 | updateTools(); | 655 | updateTools(); |
656 | tools->show(); | 656 | tools->show(); |
657 | 657 | ||
658 | // Always show vscrollbar | 658 | // Always show vscrollbar |
659 | icons->setVScrollBarMode( QScrollView::AlwaysOn ); | 659 | icons->setVScrollBarMode( QScrollView::AlwaysOn ); |
660 | } else { | 660 | } else { |
661 | delete tools; | 661 | delete tools; |
662 | tools = 0; | 662 | tools = 0; |
663 | } | 663 | } |
664 | } | 664 | } |
665 | } | 665 | } |
666 | 666 | ||
667 | void LauncherView::updateTools() | 667 | void LauncherView::updateTools() |
668 | { | 668 | { |
669 | disconnect( typemb, SIGNAL(activated(int)), | 669 | disconnect( typemb, SIGNAL(activated(int)), |
670 | this, SLOT(showType(int)) ); | 670 | this, SLOT(showType(int)) ); |
671 | if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), | 671 | if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), |
672 | this, SLOT(showCategory(int)) ); | 672 | this, SLOT(showCategory(int)) ); |
673 | 673 | ||
674 | // ### I want to remove this | 674 | // ### I want to remove this |
675 | icons->updateCategoriesAndMimeTypes(); | 675 | icons->updateCategoriesAndMimeTypes(); |
676 | 676 | ||
677 | QString prev; | 677 | QString prev; |
678 | 678 | ||
679 | // Type filter | 679 | // Type filter |
680 | QStringList types; | 680 | QStringList types; |
681 | typelist = icons->mimeTypes(); | 681 | typelist = icons->mimeTypes(); |
682 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { | 682 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { |
683 | QString t = *it; | 683 | QString t = *it; |
684 | if ( t.left(12) == "application/" ) { | 684 | if ( t.left(12) == "application/" ) { |
685 | MimeType mt(t); | 685 | MimeType mt(t); |
686 | const AppLnk* app = mt.application(); | 686 | const AppLnk* app = mt.application(); |
687 | if ( app ) | 687 | if ( app ) |
688 | t = app->name(); | 688 | t = app->name(); |
689 | else | 689 | else |
690 | t = t.mid(12); | 690 | t = t.mid(12); |
691 | } else { | 691 | } else { |
692 | t[0] = t[0].upper(); | 692 | t[0] = t[0].upper(); |
693 | } | 693 | } |
694 | types += t; | 694 | types += t; |
695 | } | 695 | } |
696 | types << tr("All types"); | 696 | types << tr("All types"); |
697 | prev = typemb->currentText(); | 697 | prev = typemb->currentText(); |
698 | typemb->clear(); | 698 | typemb->clear(); |
699 | typemb->insertStringList(types); | 699 | typemb->insertStringList(types); |
700 | for (int i=0; i<typemb->count(); i++) { | 700 | for (int i=0; i<typemb->count(); i++) { |
701 | if ( typemb->text(i) == prev ) { | 701 | if ( typemb->text(i) == prev ) { |
702 | typemb->setCurrentItem(i); | 702 | typemb->setCurrentItem(i); |
703 | break; | 703 | break; |
704 | } | 704 | } |
705 | } | 705 | } |
706 | if ( prev.isNull() ) | 706 | if ( prev.isNull() ) |
707 | typemb->setCurrentItem(typemb->count()-1); | 707 | typemb->setCurrentItem(typemb->count()-1); |
708 | 708 | ||
709 | int pcat = catmb ? catmb->currentCategory() : -2; | 709 | int pcat = catmb ? catmb->currentCategory() : -2; |
710 | if ( !catmb ) | 710 | if ( !catmb ) |
711 | catmb = new CategorySelect(tools); | 711 | catmb = new CategorySelect(tools); |
712 | Categories cats( 0 ); | 712 | Categories cats( 0 ); |
713 | cats.load( categoryFileName() ); | 713 | cats.load( categoryFileName() ); |
714 | QArray<int> vl( 0 ); | 714 | QArray<int> vl( 0 ); |
715 | catmb->setCategories( vl, "Document View", // No tr | 715 | catmb->setCategories( vl, "Document View", // No tr |
716 | tr("Document View") ); | 716 | tr("Document View") ); |
717 | catmb->setRemoveCategoryEdit( TRUE ); | 717 | catmb->setRemoveCategoryEdit( TRUE ); |
718 | catmb->setAllCategories( TRUE ); | 718 | catmb->setAllCategories( TRUE ); |
719 | catmb->setCurrentCategory(pcat); | 719 | catmb->setCurrentCategory(pcat); |
720 | 720 | ||
721 | // if type has changed we need to redisplay | 721 | // if type has changed we need to redisplay |
722 | if ( typemb->currentText() != prev ) | 722 | if ( typemb->currentText() != prev ) |
723 | showType( typemb->currentItem() ); | 723 | showType( typemb->currentItem() ); |
724 | 724 | ||
725 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); | 725 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); |
726 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); | 726 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); |
727 | } | 727 | } |
728 | 728 | ||
729 | void LauncherView::sortBy(int s) | 729 | void LauncherView::sortBy(int s) |
730 | { | 730 | { |
731 | icons->setSortMethod((LauncherIconView::SortMethod)s); | 731 | icons->setSortMethod((LauncherIconView::SortMethod)s); |
732 | } | 732 | } |
733 | 733 | ||
734 | void LauncherView::showType(int t) | 734 | void LauncherView::showType(int t) |
735 | { | 735 | { |
736 | if ( t >= (int)typelist.count() ) { | 736 | if ( t >= (int)typelist.count() ) { |
737 | icons->setTypeFilter("",TRUE); | 737 | icons->setTypeFilter("",TRUE); |
738 | } else { | 738 | } else { |
739 | QString ty = typelist[t]; | 739 | QString ty = typelist[t]; |
740 | if ( !ty.contains('/') ) | 740 | if ( !ty.contains('/') ) |
741 | ty += "/*"; | 741 | ty += "/*"; |
742 | icons->setTypeFilter(ty,TRUE); | 742 | icons->setTypeFilter(ty,TRUE); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
746 | void LauncherView::showCategory( int c ) | 746 | void LauncherView::showCategory( int c ) |
747 | { | 747 | { |
748 | icons->setCategoryFilter( c, TRUE ); | 748 | icons->setCategoryFilter( c, TRUE ); |
749 | } | 749 | } |
750 | 750 | ||
751 | void LauncherView::setViewMode( ViewMode m ) | 751 | void LauncherView::setViewMode( ViewMode m ) |
752 | { | 752 | { |
753 | if ( vmode != m ) { | 753 | if ( vmode != m ) { |
754 | bool bigIcons = m == Icon; | 754 | bool bigIcons = m == Icon; |
755 | icons->viewport()->setUpdatesEnabled( FALSE ); | 755 | icons->viewport()->setUpdatesEnabled( FALSE ); |
756 | icons->setBigIcons( bigIcons ); | 756 | icons->setBigIcons( bigIcons ); |
757 | switch ( m ) { | 757 | switch ( m ) { |
758 | case List: | 758 | case List: |
759 | icons->setItemTextPos( QIconView::Right ); | 759 | icons->setItemTextPos( QIconView::Right ); |
760 | break; | 760 | break; |
761 | case Icon: | 761 | case Icon: |
762 | icons->setItemTextPos( QIconView::Bottom ); | 762 | icons->setItemTextPos( QIconView::Bottom ); |
763 | break; | 763 | break; |
764 | } | 764 | } |
765 | icons->hideOrShowItems( FALSE ); | 765 | icons->hideOrShowItems( FALSE ); |
766 | icons->viewport()->setUpdatesEnabled( TRUE ); | 766 | icons->viewport()->setUpdatesEnabled( TRUE ); |
767 | vmode = m; | 767 | vmode = m; |
768 | } | 768 | } |
769 | } | 769 | } |
770 | 770 | ||
771 | // | 771 | // |
772 | // User images may require scaling. | 772 | // User images may require scaling. |
773 | // | 773 | // |
774 | QImage LauncherView::loadBackgroundImage(QString &bgName) | 774 | QImage LauncherView::loadBackgroundImage(QString &bgName) |
775 | { | 775 | { |
776 | QImageIO imgio; | 776 | QImageIO imgio; |
777 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop | 777 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop |
778 | bool further_scaling = TRUE; | 778 | bool further_scaling = TRUE; |
779 | 779 | ||
780 | imgio.setFileName( bgName ); | 780 | imgio.setFileName( bgName ); |
781 | imgio.setParameters("GetHeaderInformation"); | 781 | imgio.setParameters("GetHeaderInformation"); |
782 | 782 | ||
783 | if (imgio.read() == FALSE) { | 783 | if (imgio.read() == FALSE) { |
784 | return imgio.image(); | 784 | return imgio.image(); |
785 | } | 785 | } |
786 | 786 | ||
787 | if (imgio.image().width() < ds.width() && | 787 | if (imgio.image().width() < ds.width() && |
788 | imgio.image().height() < ds.height()) { | 788 | imgio.image().height() < ds.height()) { |
789 | further_scaling = FALSE; | 789 | further_scaling = FALSE; |
790 | } | 790 | } |
791 | 791 | ||
792 | if (!imgio.image().bits()) { | 792 | if (!imgio.image().bits()) { |
793 | // | 793 | // |
794 | // Scale and load. Note we don't scale up. | 794 | // Scale and load. Note we don't scale up. |
795 | // | 795 | // |
796 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr | 796 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr |
797 | imgio.setParameters(further_scaling ? | 797 | imgio.setParameters(further_scaling ? |
798 | param.arg(ds.width()).arg(ds.height()).latin1() : | 798 | param.arg(ds.width()).arg(ds.height()).latin1() : |
799 | ""); | 799 | ""); |
800 | imgio.read(); | 800 | imgio.read(); |
801 | } else { | 801 | } else { |
802 | if (further_scaling) { | 802 | if (further_scaling) { |
803 | intt1 = imgio.image().width() * ds.height(); | 803 | intt1 = imgio.image().width() * ds.height(); |
804 | int t2 = imgio.image().height() * ds.width(); | 804 | int t2 = imgio.image().height() * ds.width(); |
805 | int dsth = ds.height(); | 805 | int dsth = ds.height(); |
806 | int dstw = ds.width(); | 806 | int dstw = ds.width(); |
807 | 807 | ||
808 | if (t1 > t2) { | 808 | if (t1 > t2) { |
809 | dsth = t2 / imgio.image().width(); | 809 | dsth = t2 / imgio.image().width(); |
810 | } else { | 810 | } else { |
811 | dstw = t1 / imgio.image().height(); | 811 | dstw = t1 / imgio.image().height(); |
812 | } | 812 | } |
813 | 813 | ||
814 | // | 814 | // |
815 | // Loader didn't scale for us. Do it manually. | 815 | // Loader didn't scale for us. Do it manually. |
816 | // | 816 | // |
817 | return imgio.image().smoothScale(dstw, dsth); | 817 | return imgio.image().smoothScale(dstw, dsth); |
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index 321b5dd..7e61b0e 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp | |||
@@ -1,248 +1,248 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "packageslave.h" | 21 | #include "packageslave.h" |
22 | #include <qtopia/qprocess.h> | 22 | #include <qtopia/qprocess.h> |
23 | 23 | ||
24 | #ifdef Q_WS_QWS | 24 | #ifdef Q_WS_QWS |
25 | #include <qtopia/qcopenvelope_qws.h> | 25 | #include <qtopia/qcopenvelope_qws.h> |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #ifdef Q_WS_QWS | 28 | #ifdef Q_WS_QWS |
29 | #include <qcopchannel_qws.h> | 29 | #include <qcopchannel_qws.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | 33 | ||
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <sys/stat.h> // mkdir() | 35 | #include <sys/stat.h> // mkdir() |
36 | 36 | ||
37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <sys/vfs.h> | 39 | #include <sys/vfs.h> |
40 | #include <mntent.h> | 40 | #include <mntent.h> |
41 | #elif defined(Q_OS_WIN32) | 41 | #elif defined(Q_OS_WIN32) |
42 | #include <windows.h> | 42 | #include <windows.h> |
43 | #include <winbase.h> | 43 | #include <winbase.h> |
44 | #elif defined(Q_OS_MACX) | 44 | #elif defined(Q_OS_MACX) |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | PackageHandler::PackageHandler( QObject *parent, char* name ) | 49 | PackageHandler::PackageHandler( QObject *parent, char* name ) |
50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) | 50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) |
51 | { | 51 | { |
52 | // setup qcop channel | 52 | // setup qcop channel |
53 | #ifndef QT_NO_COP | 53 | #ifndef QT_NO_COP |
54 | packageChannel = new QCopChannel( "QPE/Package", this ); | 54 | packageChannel = new QCopChannel( "QPE/Package", this ); |
55 | connect( packageChannel, SIGNAL( received(const QCString &, const QByteArray &) ), | 55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
56 | this, SLOT( qcopMessage( const QCString &, const QByteArray &) ) ); | 56 | this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) ); |
57 | #endif | 57 | #endif |
58 | } | 58 | } |
59 | 59 | ||
60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) | 60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) |
61 | { | 61 | { |
62 | QDataStream stream( data, IO_ReadOnly ); | 62 | QDataStream stream( data, IO_ReadOnly ); |
63 | 63 | ||
64 | if ( msg == "installPackage(QString)" ) { | 64 | if ( msg == "installPackage(QString)" ) { |
65 | QString file; | 65 | QString file; |
66 | stream >> file; | 66 | stream >> file; |
67 | installPackage( file ); | 67 | installPackage( file ); |
68 | } else if ( msg == "removePackage(QString)" ) { | 68 | } else if ( msg == "removePackage(QString)" ) { |
69 | QString file; | 69 | QString file; |
70 | stream >> file; | 70 | stream >> file; |
71 | removePackage( file ); | 71 | removePackage( file ); |
72 | } else if ( msg == "addPackageFiles(QString,QString)" ) { | 72 | } else if ( msg == "addPackageFiles(QString,QString)" ) { |
73 | QString location, listfile; | 73 | QString location, listfile; |
74 | stream >> location >> listfile; | 74 | stream >> location >> listfile; |
75 | addPackageFiles( location, listfile); | 75 | addPackageFiles( location, listfile); |
76 | } else if ( msg == "addPackages(QString)" ) { | 76 | } else if ( msg == "addPackages(QString)" ) { |
77 | QString location; | 77 | QString location; |
78 | stream >> location; | 78 | stream >> location; |
79 | addPackages( location ); | 79 | addPackages( location ); |
80 | } else if ( msg == "cleanupPackageFiles(QString)" ) { | 80 | } else if ( msg == "cleanupPackageFiles(QString)" ) { |
81 | QString listfile; | 81 | QString listfile; |
82 | stream >> listfile; | 82 | stream >> listfile; |
83 | cleanupPackageFiles( listfile ); | 83 | cleanupPackageFiles( listfile ); |
84 | } else if ( msg == "cleanupPackages(QString)" ) { | 84 | } else if ( msg == "cleanupPackages(QString)" ) { |
85 | QString location; | 85 | QString location; |
86 | stream >> location; | 86 | stream >> location; |
87 | cleanupPackages( location ); | 87 | cleanupPackages( location ); |
88 | } else if ( msg == "prepareInstall(QString,QString)" ) { | 88 | } else if ( msg == "prepareInstall(QString,QString)" ) { |
89 | QString size, path; | 89 | QString size, path; |
90 | stream >> size; | 90 | stream >> size; |
91 | stream >> path; | 91 | stream >> path; |
92 | prepareInstall( size, path ); | 92 | prepareInstall( size, path ); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void PackageHandler::installPackage( const QString &package ) | 96 | void PackageHandler::installPackage( const QString &package ) |
97 | { | 97 | { |
98 | if ( mNoSpaceLeft ) { | 98 | if ( mNoSpaceLeft ) { |
99 | mNoSpaceLeft = FALSE; | 99 | mNoSpaceLeft = FALSE; |
100 | // Don't emit that for now, I still couldn't test it (Wener) | 100 | // Don't emit that for now, I still couldn't test it (Wener) |
101 | //sendReply( "installFailed(QString)", package ); | 101 | //sendReply( "installFailed(QString)", package ); |
102 | //return; | 102 | //return; |
103 | } | 103 | } |
104 | 104 | ||
105 | currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr | 105 | currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr |
106 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); | 106 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); |
107 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 107 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
108 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 108 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
109 | currentPackage = package; | 109 | currentPackage = package; |
110 | 110 | ||
111 | currentProcessError=""; | 111 | currentProcessError=""; |
112 | sendReply( "installStarted(QString)", package ); | 112 | sendReply( "installStarted(QString)", package ); |
113 | currentProcess->start(); | 113 | currentProcess->start(); |
114 | } | 114 | } |
115 | 115 | ||
116 | void PackageHandler::removePackage( const QString &package ) | 116 | void PackageHandler::removePackage( const QString &package ) |
117 | { | 117 | { |
118 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr | 118 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr |
119 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); | 119 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); |
120 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 120 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
121 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 121 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
122 | currentPackage = package; | 122 | currentPackage = package; |
123 | 123 | ||
124 | currentProcessError=""; | 124 | currentProcessError=""; |
125 | sendReply( "removeStarted(QString)", package ); | 125 | sendReply( "removeStarted(QString)", package ); |
126 | currentProcess->start(); | 126 | currentProcess->start(); |
127 | } | 127 | } |
128 | 128 | ||
129 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) | 129 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) |
130 | { | 130 | { |
131 | #ifndef QT_NO_COP | 131 | #ifndef QT_NO_COP |
132 | QCopEnvelope e( "QPE/Desktop", msg ); | 132 | QCopEnvelope e( "QPE/Desktop", msg ); |
133 | e << arg; | 133 | e << arg; |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | void PackageHandler::addPackageFiles( const QString &location, | 137 | void PackageHandler::addPackageFiles( const QString &location, |
138 | const QString &listfile ) | 138 | const QString &listfile ) |
139 | { | 139 | { |
140 | QFile f(listfile); | 140 | QFile f(listfile); |
141 | #ifndef Q_OS_WIN32 | 141 | #ifndef Q_OS_WIN32 |
142 | //make a copy so we can remove the symlinks later | 142 | //make a copy so we can remove the symlinks later |
143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); | 143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); |
144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
145 | #else | 145 | #else |
146 | QDir d; | 146 | QDir d; |
147 | //#### revise | 147 | //#### revise |
148 | qDebug("Copy file at %s: %s", __FILE__, __LINE__ ); | 148 | qDebug("Copy file at %s: %s", __FILE__, __LINE__ ); |
149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); | 149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); |
150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | 153 | ||
154 | if ( f.open(IO_ReadOnly) ) { | 154 | if ( f.open(IO_ReadOnly) ) { |
155 | QTextStream ts(&f); | 155 | QTextStream ts(&f); |
156 | 156 | ||
157 | QString s; | 157 | QString s; |
158 | while ( !ts.eof() ) { // until end of file... | 158 | while ( !ts.eof() ) { // until end of file... |
159 | s = ts.readLine(); // line of text excluding '\n' | 159 | s = ts.readLine(); // line of text excluding '\n' |
160 | // for s, do link/mkdir. | 160 | // for s, do link/mkdir. |
161 | if ( s.right(1) == "/" ) { | 161 | if ( s.right(1) == "/" ) { |
162 | qDebug("do mkdir for %s", s.ascii()); | 162 | qDebug("do mkdir for %s", s.ascii()); |
163 | #ifndef Q_OS_WIN32 | 163 | #ifndef Q_OS_WIN32 |
164 | mkdir( s.ascii(), 0777 ); | 164 | mkdir( s.ascii(), 0777 ); |
165 | //possible optimization: symlink directories | 165 | //possible optimization: symlink directories |
166 | //that don't exist already. -- Risky. | 166 | //that don't exist already. -- Risky. |
167 | #else | 167 | #else |
168 | d.mkdir( s.ascii()); | 168 | d.mkdir( s.ascii()); |
169 | #endif | 169 | #endif |
170 | 170 | ||
171 | } else { | 171 | } else { |
172 | #ifndef Q_OS_WIN32 | 172 | #ifndef Q_OS_WIN32 |
173 | qDebug("do symlink for %s", s.ascii()); | 173 | qDebug("do symlink for %s", s.ascii()); |
174 | symlink( (location + s).ascii(), s.ascii() ); | 174 | symlink( (location + s).ascii(), s.ascii() ); |
175 | #else | 175 | #else |
176 | qDebug("Copy file instead of a symlink for WIN32"); | 176 | qDebug("Copy file instead of a symlink for WIN32"); |
177 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) | 177 | if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) |
178 | qWarning("Unable to create symlinkfor %s", | 178 | qWarning("Unable to create symlinkfor %s", |
179 | (location + s).ascii()); | 179 | (location + s).ascii()); |
180 | #endif | 180 | #endif |
181 | } | 181 | } |
182 | } | 182 | } |
183 | f.close(); | 183 | f.close(); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | void PackageHandler::addPackages( const QString &location ) | 187 | void PackageHandler::addPackages( const QString &location ) |
188 | { | 188 | { |
189 | // get list of *.list in location/usr/lib/ipkg/info/*.list | 189 | // get list of *.list in location/usr/lib/ipkg/info/*.list |
190 | QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr | 190 | QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr |
191 | QDir::Name, QDir::Files); | 191 | QDir::Name, QDir::Files); |
192 | if ( !dir.exists() ) | 192 | if ( !dir.exists() ) |
193 | return; | 193 | return; |
194 | 194 | ||
195 | QStringList packages = dir.entryList(); | 195 | QStringList packages = dir.entryList(); |
196 | for ( QStringList::Iterator it = packages.begin(); | 196 | for ( QStringList::Iterator it = packages.begin(); |
197 | it != packages.end(); ++it ) { | 197 | it != packages.end(); ++it ) { |
198 | addPackageFiles( location, *it ); | 198 | addPackageFiles( location, *it ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | void PackageHandler::cleanupPackageFiles( const QString &listfile ) | 203 | void PackageHandler::cleanupPackageFiles( const QString &listfile ) |
204 | { | 204 | { |
205 | QFile f(listfile); | 205 | QFile f(listfile); |
206 | 206 | ||
207 | if ( f.open(IO_ReadOnly) ) { | 207 | if ( f.open(IO_ReadOnly) ) { |
208 | QTextStream ts(&f); | 208 | QTextStream ts(&f); |
209 | 209 | ||
210 | QString s; | 210 | QString s; |
211 | while ( !ts.eof() ) { // until end of file... | 211 | while ( !ts.eof() ) { // until end of file... |
212 | s = ts.readLine(); // line of text excluding '\n' | 212 | s = ts.readLine(); // line of text excluding '\n' |
213 | // for s, do link/mkdir. | 213 | // for s, do link/mkdir. |
214 | if ( s.right(1) == "/" ) { | 214 | if ( s.right(1) == "/" ) { |
215 | //should rmdir if empty, after all files have been removed | 215 | //should rmdir if empty, after all files have been removed |
216 | } else { | 216 | } else { |
217 | #ifndef Q_OS_WIN32 | 217 | #ifndef Q_OS_WIN32 |
218 | qDebug("remove symlink for %s", s.ascii()); | 218 | qDebug("remove symlink for %s", s.ascii()); |
219 | //check if it is a symlink first (don't remove /etc/passwd...) | 219 | //check if it is a symlink first (don't remove /etc/passwd...) |
220 | char buf[10]; //we don't care about the contents | 220 | char buf[10]; //we don't care about the contents |
221 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) | 221 | if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) |
222 | ::unlink( s.ascii() ); | 222 | ::unlink( s.ascii() ); |
223 | #else | 223 | #else |
224 | // ### revise | 224 | // ### revise |
225 | qWarning("Unable to remove symlink %s:%s", __FILE__, __LINE__); | 225 | qWarning("Unable to remove symlink %s:%s", __FILE__, __LINE__); |
226 | #endif | 226 | #endif |
227 | } | 227 | } |
228 | } | 228 | } |
229 | f.close(); | 229 | f.close(); |
230 | 230 | ||
231 | //remove the list file | 231 | //remove the list file |
232 | ::unlink( listfile.ascii() ); | 232 | ::unlink( listfile.ascii() ); |
233 | 233 | ||
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | void PackageHandler::cleanupPackages( const QString &location ) | 237 | void PackageHandler::cleanupPackages( const QString &location ) |
238 | { | 238 | { |
239 | // get list of *.list in location/usr/lib/ipkg/info/*.list | 239 | // get list of *.list in location/usr/lib/ipkg/info/*.list |
240 | QDir dir( "/usr/lib/ipkg/info/"+location, "*.list", // No tr | 240 | QDir dir( "/usr/lib/ipkg/info/"+location, "*.list", // No tr |
241 | QDir::Name, QDir::Files); | 241 | QDir::Name, QDir::Files); |
242 | if ( !dir.exists() ) | 242 | if ( !dir.exists() ) |
243 | return; | 243 | return; |
244 | 244 | ||
245 | QStringList packages = dir.entryList(); | 245 | QStringList packages = dir.entryList(); |
246 | for ( QStringList::Iterator it = packages.begin(); | 246 | for ( QStringList::Iterator it = packages.begin(); |
247 | it != packages.end(); ++it ) { | 247 | it != packages.end(); ++it ) { |
248 | cleanupPackageFiles( *it ); | 248 | cleanupPackageFiles( *it ); |
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index 24f471d..53efba4 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -1,298 +1,298 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qcopbridge.h" | 21 | #include "qcopbridge.h" |
22 | #include "transferserver.h" | 22 | #include "transferserver.h" |
23 | 23 | ||
24 | #include <opie2/oglobal.h> | 24 | #include <opie2/oglobal.h> |
25 | 25 | ||
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #endif | 28 | #endif |
29 | #include <qtopia/qpeapplication.h> | 29 | #include <qtopia/qpeapplication.h> |
30 | 30 | ||
31 | #include <qtopia/version.h> | 31 | #include <qtopia/version.h> |
32 | 32 | ||
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | #include <qcopchannel_qws.h> | 36 | #include <qcopchannel_qws.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #ifndef _XOPEN_SOURCE | 39 | #ifndef _XOPEN_SOURCE |
40 | #define _XOPEN_SOURCE | 40 | #define _XOPEN_SOURCE |
41 | #endif | 41 | #endif |
42 | #ifndef Q_OS_WIN32 | 42 | #ifndef Q_OS_WIN32 |
43 | #include <pwd.h> | 43 | #include <pwd.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #if defined(_OS_LINUX_) | 48 | #if defined(_OS_LINUX_) |
49 | #include <shadow.h> | 49 | #include <shadow.h> |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | 52 | ||
53 | //#define INSECURE | 53 | //#define INSECURE |
54 | 54 | ||
55 | const int block_size = 51200; | 55 | const int block_size = 51200; |
56 | 56 | ||
57 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, | 57 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, |
58 | const char* name ) | 58 | const char* name ) |
59 | : QServerSocket( port, 1, parent, name ), | 59 | : QServerSocket( port, 1, parent, name ), |
60 | desktopChannel( 0 ), | 60 | desktopChannel( 0 ), |
61 | cardChannel( 0 ) | 61 | cardChannel( 0 ) |
62 | { | 62 | { |
63 | if ( !ok() ) | 63 | if ( !ok() ) |
64 | qWarning( "Failed to bind to port %d", port ); | 64 | qWarning( "Failed to bind to port %d", port ); |
65 | else { | 65 | else { |
66 | #ifndef QT_NO_COP | 66 | #ifndef QT_NO_COP |
67 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 67 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
68 | connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 68 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
69 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 69 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
70 | cardChannel = new QCopChannel( "QPE/Card", this ); | 70 | cardChannel = new QCopChannel( "QPE/Card", this ); |
71 | connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 71 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
72 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 72 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
73 | #endif | 73 | #endif |
74 | } | 74 | } |
75 | sendSync = FALSE; | 75 | sendSync = FALSE; |
76 | openConnections.setAutoDelete( TRUE ); | 76 | openConnections.setAutoDelete( TRUE ); |
77 | authorizeConnections(); | 77 | authorizeConnections(); |
78 | } | 78 | } |
79 | 79 | ||
80 | QCopBridge::~QCopBridge() | 80 | QCopBridge::~QCopBridge() |
81 | { | 81 | { |
82 | #ifndef QT_NO_COP | 82 | #ifndef QT_NO_COP |
83 | delete desktopChannel; | 83 | delete desktopChannel; |
84 | #endif | 84 | #endif |
85 | } | 85 | } |
86 | 86 | ||
87 | void QCopBridge::authorizeConnections() | 87 | void QCopBridge::authorizeConnections() |
88 | { | 88 | { |
89 | Config cfg("Security"); | 89 | Config cfg("Security"); |
90 | cfg.setGroup("SyncMode"); | 90 | cfg.setGroup("SyncMode"); |
91 | m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); | 91 | m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); |
92 | QListIterator<QCopBridgePI> it(openConnections); | 92 | QListIterator<QCopBridgePI> it(openConnections); |
93 | while ( it.current() ) { | 93 | while ( it.current() ) { |
94 | if ( !it.current()->verifyAuthorised() ) { | 94 | if ( !it.current()->verifyAuthorised() ) { |
95 | disconnect ( it.current(), SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( closed( QCopBridgePI *) ) ); | 95 | disconnect ( it.current(), SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); |
96 | openConnections.removeRef( it.current() ); | 96 | openConnections.removeRef( it.current() ); |
97 | } else | 97 | } else |
98 | ++it; | 98 | ++it; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | void QCopBridge::newConnection( int socket ) | 102 | void QCopBridge::newConnection( int socket ) |
103 | { | 103 | { |
104 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); | 104 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); |
105 | openConnections.append( pi ); | 105 | openConnections.append( pi ); |
106 | connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( closed( QCopBridgePI *) ) ); | 106 | connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); |
107 | 107 | ||
108 | /* ### libqtopia merge FIXME */ | 108 | /* ### libqtopia merge FIXME */ |
109 | #if 0 | 109 | #if 0 |
110 | QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend ); | 110 | QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend ); |
111 | #endif | 111 | #endif |
112 | #ifndef QT_NO_COP | 112 | #ifndef QT_NO_COP |
113 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 113 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | if ( sendSync ) { | 116 | if ( sendSync ) { |
117 | pi ->startSync(); | 117 | pi ->startSync(); |
118 | sendSync = FALSE; | 118 | sendSync = FALSE; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void QCopBridge::closed( QCopBridgePI *pi ) | 122 | void QCopBridge::closed( QCopBridgePI *pi ) |
123 | { | 123 | { |
124 | emit connectionClosed( pi->peerAddress() ); | 124 | emit connectionClosed( pi->peerAddress() ); |
125 | openConnections.removeRef( pi ); | 125 | openConnections.removeRef( pi ); |
126 | if ( openConnections.count() == 0 ) { | 126 | if ( openConnections.count() == 0 ) { |
127 | /* ### FIXME libqtopia merge */ | 127 | /* ### FIXME libqtopia merge */ |
128 | #if 0 | 128 | #if 0 |
129 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); | 129 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); |
130 | #endif | 130 | #endif |
131 | #ifndef QT_NO_COP | 131 | #ifndef QT_NO_COP |
132 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 132 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
133 | #endif | 133 | #endif |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | void QCopBridge::closeOpenConnections() | 137 | void QCopBridge::closeOpenConnections() |
138 | { | 138 | { |
139 | QCopBridgePI *pi; | 139 | QCopBridgePI *pi; |
140 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 140 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
141 | pi->close(); | 141 | pi->close(); |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) | 145 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) |
146 | { | 146 | { |
147 | if ( command == "startSync()" ) { | 147 | if ( command == "startSync()" ) { |
148 | // we need to buffer it a bit | 148 | // we need to buffer it a bit |
149 | sendSync = TRUE; | 149 | sendSync = TRUE; |
150 | startTimer( 20000 ); | 150 | startTimer( 20000 ); |
151 | } | 151 | } |
152 | 152 | ||
153 | if ( m_mode & Qtopia1_7 ) { | 153 | if ( m_mode & Qtopia1_7 ) { |
154 | // send the command to all open connections | 154 | // send the command to all open connections |
155 | QCopBridgePI *pi; | 155 | QCopBridgePI *pi; |
156 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | 156 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { |
157 | pi->sendDesktopMessage( command, data ); | 157 | pi->sendDesktopMessage( command, data ); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | if ( ( m_mode & Sharp ) || (m_mode & IntelliSync) ) | 160 | if ( ( m_mode & Sharp ) || (m_mode & IntelliSync) ) |
161 | sendDesktopMessageOld( command, data ); | 161 | sendDesktopMessageOld( command, data ); |
162 | } | 162 | } |
163 | 163 | ||
164 | #ifndef OPIE_NO_OLD_SYNC_CODE | 164 | #ifndef OPIE_NO_OLD_SYNC_CODE |
165 | /* | 165 | /* |
166 | * Old compat mode | 166 | * Old compat mode |
167 | */ | 167 | */ |
168 | void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { | 168 | void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { |
169 | command.stripWhiteSpace(); | 169 | command.stripWhiteSpace(); |
170 | 170 | ||
171 | int paren = command.find( "(" ); | 171 | int paren = command.find( "(" ); |
172 | if ( paren <= 0 ) { | 172 | if ( paren <= 0 ) { |
173 | qDebug("DesktopMessage: bad qcop syntax"); | 173 | qDebug("DesktopMessage: bad qcop syntax"); |
174 | return; | 174 | return; |
175 | } | 175 | } |
176 | 176 | ||
177 | QString params = command.mid( paren + 1 ); | 177 | QString params = command.mid( paren + 1 ); |
178 | if ( params[params.length()-1] != ')' ) { | 178 | if ( params[params.length()-1] != ')' ) { |
179 | qDebug("DesktopMessage: bad qcop syntax"); | 179 | qDebug("DesktopMessage: bad qcop syntax"); |
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | 182 | ||
183 | params.truncate( params.length()-1 ); | 183 | params.truncate( params.length()-1 ); |
184 | 184 | ||
185 | QStringList paramList = QStringList::split( ",", params ); | 185 | QStringList paramList = QStringList::split( ",", params ); |
186 | QString data; | 186 | QString data; |
187 | if ( paramList.count() ) { | 187 | if ( paramList.count() ) { |
188 | QDataStream stream( args, IO_ReadOnly ); | 188 | QDataStream stream( args, IO_ReadOnly ); |
189 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | 189 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { |
190 | QString str; | 190 | QString str; |
191 | if ( *it == "QString" ) { | 191 | if ( *it == "QString" ) { |
192 | stream >> str; | 192 | stream >> str; |
193 | } else if ( *it == "QCString" ) { | 193 | } else if ( *it == "QCString" ) { |
194 | QCString cstr; | 194 | QCString cstr; |
195 | stream >> cstr; | 195 | stream >> cstr; |
196 | str = QString::fromLocal8Bit( cstr ); | 196 | str = QString::fromLocal8Bit( cstr ); |
197 | } else if ( *it == "int" ) { | 197 | } else if ( *it == "int" ) { |
198 | int i; | 198 | int i; |
199 | stream >> i; | 199 | stream >> i; |
200 | str = QString::number( i ); | 200 | str = QString::number( i ); |
201 | } else if ( *it == "bool" ) { | 201 | } else if ( *it == "bool" ) { |
202 | int i; | 202 | int i; |
203 | stream >> i; | 203 | stream >> i; |
204 | str = QString::number( i ); | 204 | str = QString::number( i ); |
205 | } else { | 205 | } else { |
206 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); | 206 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | QString estr; | 209 | QString estr; |
210 | for (int i=0; i<(int)str.length(); i++) { | 210 | for (int i=0; i<(int)str.length(); i++) { |
211 | QChar ch = str[i]; | 211 | QChar ch = str[i]; |
212 | if ( ch.row() ) | 212 | if ( ch.row() ) |
213 | goto quick; | 213 | goto quick; |
214 | switch (ch.cell()) { | 214 | switch (ch.cell()) { |
215 | case '&': | 215 | case '&': |
216 | estr.append( "&" ); | 216 | estr.append( "&" ); |
217 | break; | 217 | break; |
218 | case ' ': | 218 | case ' ': |
219 | estr.append( "&0x20;" ); | 219 | estr.append( "&0x20;" ); |
220 | break; | 220 | break; |
221 | case '\n': | 221 | case '\n': |
222 | estr.append( "&0x0d;" ); | 222 | estr.append( "&0x0d;" ); |
223 | break; | 223 | break; |
224 | case '\r': | 224 | case '\r': |
225 | estr.append( "&0x0a;" ); | 225 | estr.append( "&0x0a;" ); |
226 | break; | 226 | break; |
227 | default: quick: | 227 | default: quick: |
228 | estr.append(ch); | 228 | estr.append(ch); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | data += " " + estr; | 231 | data += " " + estr; |
232 | } | 232 | } |
233 | } | 233 | } |
234 | QString sendCommand = QString(command.data()) + data; | 234 | QString sendCommand = QString(command.data()) + data; |
235 | 235 | ||
236 | 236 | ||
237 | // send the command to all open connections | 237 | // send the command to all open connections |
238 | QCopBridgePI *pi; | 238 | QCopBridgePI *pi; |
239 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 239 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
240 | pi->sendDesktopMessage( sendCommand ); | 240 | pi->sendDesktopMessage( sendCommand ); |
241 | 241 | ||
242 | } | 242 | } |
243 | #endif | 243 | #endif |
244 | 244 | ||
245 | 245 | ||
246 | void QCopBridge::timerEvent( QTimerEvent * ) | 246 | void QCopBridge::timerEvent( QTimerEvent * ) |
247 | { | 247 | { |
248 | sendSync = FALSE; | 248 | sendSync = FALSE; |
249 | killTimers(); | 249 | killTimers(); |
250 | } | 250 | } |
251 | 251 | ||
252 | 252 | ||
253 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent, const char* name ) | 253 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent, const char* name ) |
254 | : QSocket( parent, name ) | 254 | : QSocket( parent, name ) |
255 | { | 255 | { |
256 | setSocket( socket ); | 256 | setSocket( socket ); |
257 | 257 | ||
258 | peerport = peerPort(); | 258 | peerport = peerPort(); |
259 | peeraddress = peerAddress(); | 259 | peeraddress = peerAddress(); |
260 | 260 | ||
261 | #ifndef INSECURE | 261 | #ifndef INSECURE |
262 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { | 262 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { |
263 | state = Forbidden; | 263 | state = Forbidden; |
264 | close(); | 264 | close(); |
265 | } else | 265 | } else |
266 | #endif | 266 | #endif |
267 | { | 267 | { |
268 | state = Connected; | 268 | state = Connected; |
269 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 269 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
270 | QString intro="220 Qtopia "; | 270 | QString intro="220 Qtopia "; |
271 | intro += QPE_VERSION; intro += ";"; | 271 | intro += QPE_VERSION; intro += ";"; |
272 | intro += "challenge="; intro += SyncAuthentication::serverId(); intro += ";"; // No tr | 272 | intro += "challenge="; intro += SyncAuthentication::serverId(); intro += ";"; // No tr |
273 | intro += "loginname="; intro += SyncAuthentication::loginName(); intro += ";"; | 273 | intro += "loginname="; intro += SyncAuthentication::loginName(); intro += ";"; |
274 | intro += "displayname="; intro += SyncAuthentication::ownerName(); intro += ";"; | 274 | intro += "displayname="; intro += SyncAuthentication::ownerName(); intro += ";"; |
275 | send( intro ); | 275 | send( intro ); |
276 | state = Wait_USER; | 276 | state = Wait_USER; |
277 | } | 277 | } |
278 | sendSync = FALSE; | 278 | sendSync = FALSE; |
279 | connect( this, SIGNAL( connectionClosed() ), SLOT( myConnectionClosed() ) ); | 279 | connect( this, SIGNAL( connectionClosed() ), SLOT( myConnectionClosed() ) ); |
280 | 280 | ||
281 | // idle timer to close connections when not used anymore | 281 | // idle timer to close connections when not used anymore |
282 | timer = new QTimer(this); | 282 | timer = new QTimer(this); |
283 | connect( timer, SIGNAL(timeout()), this, SLOT(myConnectionClosed()) ); | 283 | connect( timer, SIGNAL(timeout()), this, SLOT(myConnectionClosed()) ); |
284 | timer->start( 300000, TRUE ); | 284 | timer->start( 300000, TRUE ); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | QCopBridgePI::~QCopBridgePI() | 288 | QCopBridgePI::~QCopBridgePI() |
289 | { | 289 | { |
290 | } | 290 | } |
291 | 291 | ||
292 | bool QCopBridgePI::verifyAuthorised() | 292 | bool QCopBridgePI::verifyAuthorised() |
293 | { | 293 | { |
294 | if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { | 294 | if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { |
295 | state = Forbidden; | 295 | state = Forbidden; |
296 | return FALSE; | 296 | return FALSE; |
297 | } | 297 | } |
298 | return TRUE; | 298 | return TRUE; |
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp index 11d10dc..2e9d2a9 100644 --- a/core/launcher/runningappbar.cpp +++ b/core/launcher/runningappbar.cpp | |||
@@ -1,172 +1,172 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ***********************************************************************/ | 19 | ***********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_PRELOADACCESS | 21 | #define QTOPIA_INTERNAL_PRELOADACCESS |
22 | 22 | ||
23 | 23 | ||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | 27 | ||
28 | #include <qtopia/qcopenvelope_qws.h> | 28 | #include <qtopia/qcopenvelope_qws.h> |
29 | 29 | ||
30 | #include "runningappbar.h" | 30 | #include "runningappbar.h" |
31 | #include "serverinterface.h" | 31 | #include "serverinterface.h" |
32 | 32 | ||
33 | RunningAppBar::RunningAppBar(QWidget* parent) | 33 | RunningAppBar::RunningAppBar(QWidget* parent) |
34 | : QFrame(parent), selectedAppIndex(-1) | 34 | : QFrame(parent), selectedAppIndex(-1) |
35 | { | 35 | { |
36 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 36 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
37 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 37 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
38 | this, SLOT(received(const QCString&, const QByteArray&)) ); | 38 | this, SLOT(received(const QCString&,const QByteArray&)) ); |
39 | 39 | ||
40 | spacing = AppLnk::smallIconSize()+3; | 40 | spacing = AppLnk::smallIconSize()+3; |
41 | } | 41 | } |
42 | 42 | ||
43 | RunningAppBar::~RunningAppBar() | 43 | RunningAppBar::~RunningAppBar() |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) { | 47 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) { |
48 | // Since fast apps appear and disappear without disconnecting from their | 48 | // Since fast apps appear and disappear without disconnecting from their |
49 | // channel we need to watch for the showing/hiding events and update according. | 49 | // channel we need to watch for the showing/hiding events and update according. |
50 | QDataStream stream( data, IO_ReadOnly ); | 50 | QDataStream stream( data, IO_ReadOnly ); |
51 | if ( msg == "fastAppShowing(QString)") { | 51 | if ( msg == "fastAppShowing(QString)") { |
52 | QString appName; | 52 | QString appName; |
53 | stream >> appName; | 53 | stream >> appName; |
54 | // qDebug("fastAppShowing %s", appName.data() ); | 54 | // qDebug("fastAppShowing %s", appName.data() ); |
55 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); | 55 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); |
56 | if ( f ) addTask(*f); | 56 | if ( f ) addTask(*f); |
57 | } else if ( msg == "fastAppHiding(QString)") { | 57 | } else if ( msg == "fastAppHiding(QString)") { |
58 | QString appName; | 58 | QString appName; |
59 | stream >> appName; | 59 | stream >> appName; |
60 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); | 60 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); |
61 | if ( f ) removeTask(*f); | 61 | if ( f ) removeTask(*f); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | void RunningAppBar::addTask(const AppLnk& appLnk) { | 65 | void RunningAppBar::addTask(const AppLnk& appLnk) { |
66 | qDebug("Added %s to app list.", appLnk.name().latin1()); | 66 | qDebug("Added %s to app list.", appLnk.name().latin1()); |
67 | AppLnk* newApp = new AppLnk(appLnk); | 67 | AppLnk* newApp = new AppLnk(appLnk); |
68 | newApp->setExec(appLnk.exec()); | 68 | newApp->setExec(appLnk.exec()); |
69 | appList.prepend(newApp); | 69 | appList.prepend(newApp); |
70 | update(); | 70 | update(); |
71 | } | 71 | } |
72 | 72 | ||
73 | void RunningAppBar::removeTask(const AppLnk& appLnk) { | 73 | void RunningAppBar::removeTask(const AppLnk& appLnk) { |
74 | unsigned int i = 0; | 74 | unsigned int i = 0; |
75 | for (; i < appList.count() ; i++) { | 75 | for (; i < appList.count() ; i++) { |
76 | AppLnk* target = appList.at(i); | 76 | AppLnk* target = appList.at(i); |
77 | if (target->exec() == appLnk.exec()) { | 77 | if (target->exec() == appLnk.exec()) { |
78 | qDebug("Removing %s from app list.", appLnk.name().latin1()); | 78 | qDebug("Removing %s from app list.", appLnk.name().latin1()); |
79 | appList.remove(); | 79 | appList.remove(); |
80 | delete target; | 80 | delete target; |
81 | } | 81 | } |
82 | } | 82 | } |
83 | update(); | 83 | update(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void RunningAppBar::mousePressEvent(QMouseEvent *e) | 86 | void RunningAppBar::mousePressEvent(QMouseEvent *e) |
87 | { | 87 | { |
88 | // Find out if the user is clicking on an app icon... | 88 | // Find out if the user is clicking on an app icon... |
89 | // If so, snag the index so when we repaint we show it | 89 | // If so, snag the index so when we repaint we show it |
90 | // as highlighed. | 90 | // as highlighed. |
91 | selectedAppIndex = 0; | 91 | selectedAppIndex = 0; |
92 | int x=0; | 92 | int x=0; |
93 | QListIterator<AppLnk> it( appList ); | 93 | QListIterator<AppLnk> it( appList ); |
94 | for ( ; it.current(); ++it,++selectedAppIndex,x+=spacing ) { | 94 | for ( ; it.current(); ++it,++selectedAppIndex,x+=spacing ) { |
95 | if ( x + spacing <= width() ) { | 95 | if ( x + spacing <= width() ) { |
96 | if ( e->x() >= x && e->x() < x+spacing ) { | 96 | if ( e->x() >= x && e->x() < x+spacing ) { |
97 | if ( selectedAppIndex < (int)appList.count() ) { | 97 | if ( selectedAppIndex < (int)appList.count() ) { |
98 | repaint(FALSE); | 98 | repaint(FALSE); |
99 | return; | 99 | return; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } else { | 102 | } else { |
103 | break; | 103 | break; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | selectedAppIndex = -1; | 106 | selectedAppIndex = -1; |
107 | repaint( FALSE ); | 107 | repaint( FALSE ); |
108 | } | 108 | } |
109 | 109 | ||
110 | void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) | 110 | void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) |
111 | { | 111 | { |
112 | if (e->button() == QMouseEvent::RightButton) | 112 | if (e->button() == QMouseEvent::RightButton) |
113 | return; | 113 | return; |
114 | if ( selectedAppIndex >= 0 ) { | 114 | if ( selectedAppIndex >= 0 ) { |
115 | QString app = appList.at(selectedAppIndex)->exec(); | 115 | QString app = appList.at(selectedAppIndex)->exec(); |
116 | QCopEnvelope e("QPE/System", "raise(QString)"); | 116 | QCopEnvelope e("QPE/System", "raise(QString)"); |
117 | e << app; | 117 | e << app; |
118 | selectedAppIndex = -1; | 118 | selectedAppIndex = -1; |
119 | update(); | 119 | update(); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void RunningAppBar::paintEvent( QPaintEvent * ) | 123 | void RunningAppBar::paintEvent( QPaintEvent * ) |
124 | { | 124 | { |
125 | QPainter p( this ); | 125 | QPainter p( this ); |
126 | AppLnk *curApp; | 126 | AppLnk *curApp; |
127 | int x = 0; | 127 | int x = 0; |
128 | int y = (height() - AppLnk::smallIconSize()) / 2; | 128 | int y = (height() - AppLnk::smallIconSize()) / 2; |
129 | int i = 0; | 129 | int i = 0; |
130 | 130 | ||
131 | p.fillRect( 0, 0, width(), height(), colorGroup().background() ); | 131 | p.fillRect( 0, 0, width(), height(), colorGroup().background() ); |
132 | 132 | ||
133 | QListIterator<AppLnk> it(appList); | 133 | QListIterator<AppLnk> it(appList); |
134 | 134 | ||
135 | for (; it.current(); i++, ++it ) { | 135 | for (; it.current(); i++, ++it ) { |
136 | if ( x + spacing <= width() ) { | 136 | if ( x + spacing <= width() ) { |
137 | curApp = it.current(); | 137 | curApp = it.current(); |
138 | qWarning("Drawing %s", curApp->name().latin1() ); | 138 | qWarning("Drawing %s", curApp->name().latin1() ); |
139 | if ( (int)i == selectedAppIndex ) | 139 | if ( (int)i == selectedAppIndex ) |
140 | p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); | 140 | p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); |
141 | else | 141 | else |
142 | p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); | 142 | p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); |
143 | p.drawPixmap( x, y, curApp->pixmap() ); | 143 | p.drawPixmap( x, y, curApp->pixmap() ); |
144 | x += spacing; | 144 | x += spacing; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | QSize RunningAppBar::sizeHint() const | 149 | QSize RunningAppBar::sizeHint() const |
150 | { | 150 | { |
151 | return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); | 151 | return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); |
152 | } | 152 | } |
153 | 153 | ||
154 | void RunningAppBar::applicationLaunched(const QString &appName) | 154 | void RunningAppBar::applicationLaunched(const QString &appName) |
155 | { | 155 | { |
156 | qDebug("desktop:: app: %s launched with pid ", appName.data() ); | 156 | qDebug("desktop:: app: %s launched with pid ", appName.data() ); |
157 | const AppLnk* newGuy = ServerInterface::appLnks().findExec(appName); | 157 | const AppLnk* newGuy = ServerInterface::appLnks().findExec(appName); |
158 | if ( newGuy && !newGuy->isPreloaded() ) { | 158 | if ( newGuy && !newGuy->isPreloaded() ) { |
159 | addTask( *newGuy ); | 159 | addTask( *newGuy ); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | void RunningAppBar::applicationTerminated(const QString &app) | 163 | void RunningAppBar::applicationTerminated(const QString &app) |
164 | { | 164 | { |
165 | const AppLnk* gone = ServerInterface::appLnks().findExec(app); | 165 | const AppLnk* gone = ServerInterface::appLnks().findExec(app); |
166 | if ( gone ) { | 166 | if ( gone ) { |
167 | removeTask(*gone); | 167 | removeTask(*gone); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | 172 | ||
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 068d716..ea0b792 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -1,365 +1,365 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "server.h" | 21 | #include "server.h" |
22 | #include "serverapp.h" | 22 | #include "serverapp.h" |
23 | #include "startmenu.h" | 23 | #include "startmenu.h" |
24 | #include "launcher.h" | 24 | #include "launcher.h" |
25 | #include "transferserver.h" | 25 | #include "transferserver.h" |
26 | #include "qcopbridge.h" | 26 | #include "qcopbridge.h" |
27 | #include "irserver.h" | 27 | #include "irserver.h" |
28 | #include "packageslave.h" | 28 | #include "packageslave.h" |
29 | #include "calibrate.h" | 29 | #include "calibrate.h" |
30 | #include "qrsync.h" | 30 | #include "qrsync.h" |
31 | #include "syncdialog.h" | 31 | #include "syncdialog.h" |
32 | #include "shutdownimpl.h" | 32 | #include "shutdownimpl.h" |
33 | #include "applauncher.h" | 33 | #include "applauncher.h" |
34 | #if 0 | 34 | #if 0 |
35 | #include "suspendmonitor.h" | 35 | #include "suspendmonitor.h" |
36 | #endif | 36 | #endif |
37 | #include "documentlist.h" | 37 | #include "documentlist.h" |
38 | 38 | ||
39 | #include <qtopia/applnk.h> | 39 | #include <qtopia/applnk.h> |
40 | #include <qtopia/private/categories.h> | 40 | #include <qtopia/private/categories.h> |
41 | #include <qtopia/mimetype.h> | 41 | #include <qtopia/mimetype.h> |
42 | #include <qtopia/config.h> | 42 | #include <qtopia/config.h> |
43 | #include <qtopia/resource.h> | 43 | #include <qtopia/resource.h> |
44 | #include <qtopia/version.h> | 44 | #include <qtopia/version.h> |
45 | #include <qtopia/storage.h> | 45 | #include <qtopia/storage.h> |
46 | 46 | ||
47 | #include <qtopia/qcopenvelope_qws.h> | 47 | #include <qtopia/qcopenvelope_qws.h> |
48 | #include <qwindowsystem_qws.h> | 48 | #include <qwindowsystem_qws.h> |
49 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
50 | #include <qtopia/global.h> | 50 | #include <qtopia/global.h> |
51 | //#include <qtopia/custom.h> | 51 | //#include <qtopia/custom.h> |
52 | 52 | ||
53 | #include <opie2/odevicebutton.h> | 53 | #include <opie2/odevicebutton.h> |
54 | #include <opie2/odevice.h> | 54 | #include <opie2/odevice.h> |
55 | 55 | ||
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #include <qmainwindow.h> | 57 | #include <qmainwindow.h> |
58 | #include <qmessagebox.h> | 58 | #include <qmessagebox.h> |
59 | #include <qtimer.h> | 59 | #include <qtimer.h> |
60 | #include <qtextstream.h> | 60 | #include <qtextstream.h> |
61 | 61 | ||
62 | #include <stdlib.h> | 62 | #include <stdlib.h> |
63 | 63 | ||
64 | extern QRect qt_maxWindowRect; | 64 | extern QRect qt_maxWindowRect; |
65 | 65 | ||
66 | using namespace Opie; | 66 | using namespace Opie; |
67 | 67 | ||
68 | static QWidget *calibrate(bool) | 68 | static QWidget *calibrate(bool) |
69 | { | 69 | { |
70 | #ifdef Q_WS_QWS | 70 | #ifdef Q_WS_QWS |
71 | Calibrate *c = new Calibrate; | 71 | Calibrate *c = new Calibrate; |
72 | c->show(); | 72 | c->show(); |
73 | return c; | 73 | return c; |
74 | #else | 74 | #else |
75 | return 0; | 75 | return 0; |
76 | #endif | 76 | #endif |
77 | } | 77 | } |
78 | 78 | ||
79 | #define FACTORY(T) \ | 79 | #define FACTORY(T) \ |
80 | static QWidget *new##T( bool maximized ) { \ | 80 | static QWidget *new##T( bool maximized ) { \ |
81 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 81 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
82 | if ( maximized ) { \ | 82 | if ( maximized ) { \ |
83 | if ( qApp->desktop()->width() <= 350 ) { \ | 83 | if ( qApp->desktop()->width() <= 350 ) { \ |
84 | w->showMaximized(); \ | 84 | w->showMaximized(); \ |
85 | } else { \ | 85 | } else { \ |
86 | w->resize( QSize( 300, 300 ) ); \ | 86 | w->resize( QSize( 300, 300 ) ); \ |
87 | } \ | 87 | } \ |
88 | } \ | 88 | } \ |
89 | w->show(); \ | 89 | w->show(); \ |
90 | return w; \ | 90 | return w; \ |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | #ifdef SINGLE_APP | 94 | #ifdef SINGLE_APP |
95 | #define APP(a,b,c,d) FACTORY(b) | 95 | #define APP(a,b,c,d) FACTORY(b) |
96 | #include "apps.h" | 96 | #include "apps.h" |
97 | #undef APP | 97 | #undef APP |
98 | #endif // SINGLE_APP | 98 | #endif // SINGLE_APP |
99 | 99 | ||
100 | static Global::Command builtins[] = { | 100 | static Global::Command builtins[] = { |
101 | 101 | ||
102 | #ifdef SINGLE_APP | 102 | #ifdef SINGLE_APP |
103 | #define APP(a,b,c,d) { a, new##b, c, d }, | 103 | #define APP(a,b,c,d) { a, new##b, c, d }, |
104 | #include "apps.h" | 104 | #include "apps.h" |
105 | #undef APP | 105 | #undef APP |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | /* FIXME defines need to be defined*/ | 108 | /* FIXME defines need to be defined*/ |
109 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) | 109 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) |
110 | { "calibrate", calibrate, 1, 0 }, // No tr | 110 | { "calibrate", calibrate, 1, 0 }, // No tr |
111 | #endif | 111 | #endif |
112 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) | 112 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) |
113 | { "shutdown", Global::shutdown, 1, 0 }, // No tr | 113 | { "shutdown", Global::shutdown, 1, 0 }, // No tr |
114 | // { "run", run, 1, 0 }, // No tr | 114 | // { "run", run, 1, 0 }, // No tr |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | { 0, calibrate,0, 0 }, | 117 | { 0, calibrate,0, 0 }, |
118 | }; | 118 | }; |
119 | 119 | ||
120 | 120 | ||
121 | //--------------------------------------------------------------------------- | 121 | //--------------------------------------------------------------------------- |
122 | 122 | ||
123 | 123 | ||
124 | //=========================================================================== | 124 | //=========================================================================== |
125 | 125 | ||
126 | Server::Server() : | 126 | Server::Server() : |
127 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 127 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
128 | qcopBridge( 0 ), | 128 | qcopBridge( 0 ), |
129 | transferServer( 0 ), | 129 | transferServer( 0 ), |
130 | packageHandler( 0 ), | 130 | packageHandler( 0 ), |
131 | syncDialog( 0 ) | 131 | syncDialog( 0 ) |
132 | { | 132 | { |
133 | Global::setBuiltinCommands(builtins); | 133 | Global::setBuiltinCommands(builtins); |
134 | 134 | ||
135 | tid_xfer = 0; | 135 | tid_xfer = 0; |
136 | /* ### FIXME ### */ | 136 | /* ### FIXME ### */ |
137 | /* tid_today = startTimer(3600*2*1000);*/ | 137 | /* tid_today = startTimer(3600*2*1000);*/ |
138 | last_today_show = QDate::currentDate(); | 138 | last_today_show = QDate::currentDate(); |
139 | 139 | ||
140 | #if 0 | 140 | #if 0 |
141 | tsmMonitor = new TempScreenSaverMode(); | 141 | tsmMonitor = new TempScreenSaverMode(); |
142 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); | 142 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | serverGui = new Launcher; | 145 | serverGui = new Launcher; |
146 | serverGui->createGUI(); | 146 | serverGui->createGUI(); |
147 | 147 | ||
148 | docList = new DocumentList( serverGui ); | 148 | docList = new DocumentList( serverGui ); |
149 | appLauncher = new AppLauncher(this); | 149 | appLauncher = new AppLauncher(this); |
150 | connect(appLauncher, SIGNAL(launched(int, const QString &)), this, SLOT(applicationLaunched(int, const QString &)) ); | 150 | connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); |
151 | connect(appLauncher, SIGNAL(terminated(int, const QString &)), this, SLOT(applicationTerminated(int, const QString &)) ); | 151 | connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); |
152 | connect(appLauncher, SIGNAL(connected(const QString &)), this, SLOT(applicationConnected(const QString &)) ); | 152 | connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); |
153 | 153 | ||
154 | storage = new StorageInfo( this ); | 154 | storage = new StorageInfo( this ); |
155 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); | 155 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); |
156 | 156 | ||
157 | // start services | 157 | // start services |
158 | startTransferServer(); | 158 | startTransferServer(); |
159 | (void) new IrServer( this ); | 159 | (void) new IrServer( this ); |
160 | 160 | ||
161 | packageHandler = new PackageHandler( this ); | 161 | packageHandler = new PackageHandler( this ); |
162 | connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 162 | connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
163 | this,SLOT(activate(const Opie::ODeviceButton*,bool))); | 163 | this,SLOT(activate(const Opie::ODeviceButton*,bool))); |
164 | 164 | ||
165 | setGeometry( -10, -10, 9, 9 ); | 165 | setGeometry( -10, -10, 9, 9 ); |
166 | 166 | ||
167 | QCopChannel *channel = new QCopChannel("QPE/System", this); | 167 | QCopChannel *channel = new QCopChannel("QPE/System", this); |
168 | connect(channel, SIGNAL(received(const QCString &, const QByteArray &)), | 168 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
169 | this, SLOT(systemMsg(const QCString &, const QByteArray &)) ); | 169 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); |
170 | 170 | ||
171 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); | 171 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); |
172 | connect( tbChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 172 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
173 | this, SLOT(receiveTaskBar(const QCString&, const QByteArray&)) ); | 173 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); |
174 | 174 | ||
175 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); | 175 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); |
176 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); | 176 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); |
177 | 177 | ||
178 | preloadApps(); | 178 | preloadApps(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void Server::show() | 181 | void Server::show() |
182 | { | 182 | { |
183 | ServerApplication::login(TRUE); | 183 | ServerApplication::login(TRUE); |
184 | QWidget::show(); | 184 | QWidget::show(); |
185 | } | 185 | } |
186 | 186 | ||
187 | Server::~Server() | 187 | Server::~Server() |
188 | { | 188 | { |
189 | serverGui->destroyGUI(); | 189 | serverGui->destroyGUI(); |
190 | delete docList; | 190 | delete docList; |
191 | delete qcopBridge; | 191 | delete qcopBridge; |
192 | delete transferServer; | 192 | delete transferServer; |
193 | delete serverGui; | 193 | delete serverGui; |
194 | #if 0 | 194 | #if 0 |
195 | delete tsmMonitor; | 195 | delete tsmMonitor; |
196 | #endif | 196 | #endif |
197 | } | 197 | } |
198 | 198 | ||
199 | static bool hasVisibleWindow(const QString& clientname, bool partial) | 199 | static bool hasVisibleWindow(const QString& clientname, bool partial) |
200 | { | 200 | { |
201 | #ifdef QWS | 201 | #ifdef QWS |
202 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 202 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
203 | QWSWindow* w; | 203 | QWSWindow* w; |
204 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 204 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
205 | if ( w->client()->identity() == clientname ) { | 205 | if ( w->client()->identity() == clientname ) { |
206 | if ( partial && !w->isFullyObscured() ) | 206 | if ( partial && !w->isFullyObscured() ) |
207 | return TRUE; | 207 | return TRUE; |
208 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | 208 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { |
209 | # if QT_VERSION < 0x030000 | 209 | # if QT_VERSION < 0x030000 |
210 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | 210 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, |
211 | QSize(qt_screen->width(),qt_screen->height()) ); | 211 | QSize(qt_screen->width(),qt_screen->height()) ); |
212 | # else | 212 | # else |
213 | QRect mwr = qt_maxWindowRect; | 213 | QRect mwr = qt_maxWindowRect; |
214 | # endif | 214 | # endif |
215 | if ( mwr.contains(w->requested().boundingRect()) ) | 215 | if ( mwr.contains(w->requested().boundingRect()) ) |
216 | return TRUE; | 216 | return TRUE; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | #endif | 220 | #endif |
221 | return FALSE; | 221 | return FALSE; |
222 | } | 222 | } |
223 | 223 | ||
224 | void Server::activate(const Opie::ODeviceButton* button, bool held) | 224 | void Server::activate(const Opie::ODeviceButton* button, bool held) |
225 | { | 225 | { |
226 | Global::terminateBuiltin("calibrate"); // No tr | 226 | Global::terminateBuiltin("calibrate"); // No tr |
227 | Opie::OQCopMessage om; | 227 | Opie::OQCopMessage om; |
228 | if ( held ) { | 228 | if ( held ) { |
229 | om = button->heldAction(); | 229 | om = button->heldAction(); |
230 | } else { | 230 | } else { |
231 | om = button->pressedAction(); | 231 | om = button->pressedAction(); |
232 | } | 232 | } |
233 | 233 | ||
234 | if ( om.channel() != "ignore" ) | 234 | if ( om.channel() != "ignore" ) |
235 | om.send(); | 235 | om.send(); |
236 | 236 | ||
237 | // A button with no action defined, will return a null ServiceRequest. Don't attempt | 237 | // A button with no action defined, will return a null ServiceRequest. Don't attempt |
238 | // to send/do anything with this as it will crash | 238 | // to send/do anything with this as it will crash |
239 | /* ### FIXME */ | 239 | /* ### FIXME */ |
240 | #if 0 | 240 | #if 0 |
241 | if ( !sr.isNull() ) { | 241 | if ( !sr.isNull() ) { |
242 | QString app = sr.app(); | 242 | QString app = sr.app(); |
243 | bool vis = hasVisibleWindow(app, app != "qpe"); | 243 | bool vis = hasVisibleWindow(app, app != "qpe"); |
244 | if ( sr.message() == "raise()" && vis ) { | 244 | if ( sr.message() == "raise()" && vis ) { |
245 | sr.setMessage("nextView()"); | 245 | sr.setMessage("nextView()"); |
246 | } else { | 246 | } else { |
247 | // "back door" | 247 | // "back door" |
248 | sr << (int)vis; | 248 | sr << (int)vis; |
249 | } | 249 | } |
250 | 250 | ||
251 | sr.send(); | 251 | sr.send(); |
252 | } | 252 | } |
253 | #endif | 253 | #endif |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | #ifdef Q_WS_QWS | 257 | #ifdef Q_WS_QWS |
258 | 258 | ||
259 | 259 | ||
260 | typedef struct KeyOverride { | 260 | typedef struct KeyOverride { |
261 | ushort scan_code; | 261 | ushort scan_code; |
262 | QWSServer::KeyMap map; | 262 | QWSServer::KeyMap map; |
263 | }; | 263 | }; |
264 | 264 | ||
265 | 265 | ||
266 | static const KeyOverride jp109keys[] = { | 266 | static const KeyOverride jp109keys[] = { |
267 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, | 267 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, |
268 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, | 268 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, |
269 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, | 269 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, |
270 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, | 270 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, |
271 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, | 271 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, |
272 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, | 272 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, |
273 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, | 273 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, |
274 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, | 274 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, |
275 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, | 275 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, |
276 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, | 276 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, |
277 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, | 277 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, |
278 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, | 278 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, |
279 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, | 279 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, |
280 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, | 280 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, |
281 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, | 281 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, |
282 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, | 282 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, |
283 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, | 283 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, |
284 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, | 284 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, |
285 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, | 285 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, |
286 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } | 286 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } |
287 | }; | 287 | }; |
288 | 288 | ||
289 | bool Server::setKeyboardLayout( const QString &kb ) | 289 | bool Server::setKeyboardLayout( const QString &kb ) |
290 | { | 290 | { |
291 | //quick demo version that can be extended | 291 | //quick demo version that can be extended |
292 | 292 | ||
293 | QIntDict<QWSServer::KeyMap> *om = 0; | 293 | QIntDict<QWSServer::KeyMap> *om = 0; |
294 | if ( kb == "us101" ) { // No tr | 294 | if ( kb == "us101" ) { // No tr |
295 | om = 0; | 295 | om = 0; |
296 | } else if ( kb == "jp109" ) { | 296 | } else if ( kb == "jp109" ) { |
297 | om = new QIntDict<QWSServer::KeyMap>(37); | 297 | om = new QIntDict<QWSServer::KeyMap>(37); |
298 | const KeyOverride *k = jp109keys; | 298 | const KeyOverride *k = jp109keys; |
299 | while ( k->scan_code ) { | 299 | while ( k->scan_code ) { |
300 | om->insert( k->scan_code, &k->map ); | 300 | om->insert( k->scan_code, &k->map ); |
301 | k++; | 301 | k++; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | QWSServer::setOverrideKeys( om ); | 304 | QWSServer::setOverrideKeys( om ); |
305 | 305 | ||
306 | return TRUE; | 306 | return TRUE; |
307 | } | 307 | } |
308 | 308 | ||
309 | #endif | 309 | #endif |
310 | 310 | ||
311 | void Server::systemMsg(const QCString &msg, const QByteArray &data) | 311 | void Server::systemMsg(const QCString &msg, const QByteArray &data) |
312 | { | 312 | { |
313 | QDataStream stream( data, IO_ReadOnly ); | 313 | QDataStream stream( data, IO_ReadOnly ); |
314 | 314 | ||
315 | if ( msg == "securityChanged()" ) { | 315 | if ( msg == "securityChanged()" ) { |
316 | if ( transferServer ) | 316 | if ( transferServer ) |
317 | transferServer->authorizeConnections(); | 317 | transferServer->authorizeConnections(); |
318 | if ( qcopBridge ) | 318 | if ( qcopBridge ) |
319 | qcopBridge->authorizeConnections(); | 319 | qcopBridge->authorizeConnections(); |
320 | } | 320 | } |
321 | /* ### FIXME support TempScreenSaverMode */ | 321 | /* ### FIXME support TempScreenSaverMode */ |
322 | #if 0 | 322 | #if 0 |
323 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { | 323 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { |
324 | int mode, pid; | 324 | int mode, pid; |
325 | stream >> mode >> pid; | 325 | stream >> mode >> pid; |
326 | tsmMonitor->setTempMode(mode, pid); | 326 | tsmMonitor->setTempMode(mode, pid); |
327 | } | 327 | } |
328 | #endif | 328 | #endif |
329 | else if ( msg == "linkChanged(QString)" ) { | 329 | else if ( msg == "linkChanged(QString)" ) { |
330 | QString link; | 330 | QString link; |
331 | stream >> link; | 331 | stream >> link; |
332 | qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); | 332 | qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); |
333 | docList->linkChanged(link); | 333 | docList->linkChanged(link); |
334 | } else if ( msg == "serviceChanged(QString)" ) { | 334 | } else if ( msg == "serviceChanged(QString)" ) { |
335 | MimeType::updateApplications(); | 335 | MimeType::updateApplications(); |
336 | } else if ( msg == "mkdir(QString)" ) { | 336 | } else if ( msg == "mkdir(QString)" ) { |
337 | QString dir; | 337 | QString dir; |
338 | stream >> dir; | 338 | stream >> dir; |
339 | if ( !dir.isEmpty() ) | 339 | if ( !dir.isEmpty() ) |
340 | mkdir( dir ); | 340 | mkdir( dir ); |
341 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 341 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
342 | QString baseFile, sigFile; | 342 | QString baseFile, sigFile; |
343 | stream >> baseFile >> sigFile; | 343 | stream >> baseFile >> sigFile; |
344 | QRsync::generateSignature( baseFile, sigFile ); | 344 | QRsync::generateSignature( baseFile, sigFile ); |
345 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 345 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
346 | QString baseFile, sigFile, deltaFile; | 346 | QString baseFile, sigFile, deltaFile; |
347 | stream >> baseFile >> sigFile >> deltaFile; | 347 | stream >> baseFile >> sigFile >> deltaFile; |
348 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 348 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
349 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 349 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
350 | QString baseFile, deltaFile; | 350 | QString baseFile, deltaFile; |
351 | stream >> baseFile >> deltaFile; | 351 | stream >> baseFile >> deltaFile; |
352 | if ( !QFile::exists( baseFile ) ) { | 352 | if ( !QFile::exists( baseFile ) ) { |
353 | QFile f( baseFile ); | 353 | QFile f( baseFile ); |
354 | f.open( IO_WriteOnly ); | 354 | f.open( IO_WriteOnly ); |
355 | f.close(); | 355 | f.close(); |
356 | } | 356 | } |
357 | QRsync::applyDiff( baseFile, deltaFile ); | 357 | QRsync::applyDiff( baseFile, deltaFile ); |
358 | #ifndef QT_NO_COP | 358 | #ifndef QT_NO_COP |
359 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 359 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
360 | e << baseFile; | 360 | e << baseFile; |
361 | #endif | 361 | #endif |
362 | } else if ( msg == "rdiffCleanup()" ) { | 362 | } else if ( msg == "rdiffCleanup()" ) { |
363 | mkdir( "/tmp/rdiff" ); | 363 | mkdir( "/tmp/rdiff" ); |
364 | QDir dir; | 364 | QDir dir; |
365 | dir.setPath( "/tmp/rdiff" ); | 365 | dir.setPath( "/tmp/rdiff" ); |
@@ -424,306 +424,306 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
424 | cfg.setGroup("SyncDate"); | 424 | cfg.setGroup("SyncDate"); |
425 | #ifndef QT_NO_COP | 425 | #ifndef QT_NO_COP |
426 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 426 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
427 | e << app << cfg.readEntry( app ); | 427 | e << app << cfg.readEntry( app ); |
428 | #endif | 428 | #endif |
429 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 429 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
430 | //cfg.readEntry( app ).latin1() ); | 430 | //cfg.readEntry( app ).latin1() ); |
431 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 431 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
432 | QString app, date; | 432 | QString app, date; |
433 | stream >> app >> date; | 433 | stream >> app >> date; |
434 | Config cfg( "qpe" ); | 434 | Config cfg( "qpe" ); |
435 | cfg.setGroup("SyncDate"); | 435 | cfg.setGroup("SyncDate"); |
436 | cfg.writeEntry( app, date ); | 436 | cfg.writeEntry( app, date ); |
437 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 437 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
438 | } else if ( msg == "startSync(QString)" ) { | 438 | } else if ( msg == "startSync(QString)" ) { |
439 | QString what; | 439 | QString what; |
440 | stream >> what; | 440 | stream >> what; |
441 | delete syncDialog; | 441 | delete syncDialog; |
442 | syncDialog = new SyncDialog( this, what ); | 442 | syncDialog = new SyncDialog( this, what ); |
443 | syncDialog->show(); | 443 | syncDialog->show(); |
444 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 444 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
445 | } else if ( msg == "stopSync()") { | 445 | } else if ( msg == "stopSync()") { |
446 | delete syncDialog; | 446 | delete syncDialog; |
447 | syncDialog = 0; | 447 | syncDialog = 0; |
448 | } else if (msg == "restoreDone(QString)") { | 448 | } else if (msg == "restoreDone(QString)") { |
449 | docList->restoreDone(); | 449 | docList->restoreDone(); |
450 | } else if ( msg == "getAllDocLinks()" ) { | 450 | } else if ( msg == "getAllDocLinks()" ) { |
451 | docList->sendAllDocLinks(); | 451 | docList->sendAllDocLinks(); |
452 | } | 452 | } |
453 | #ifdef Q_WS_QWS | 453 | #ifdef Q_WS_QWS |
454 | else if ( msg == "setMouseProto(QString)" ) { | 454 | else if ( msg == "setMouseProto(QString)" ) { |
455 | QString mice; | 455 | QString mice; |
456 | stream >> mice; | 456 | stream >> mice; |
457 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 457 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
458 | qwsServer->openMouse(); | 458 | qwsServer->openMouse(); |
459 | } else if ( msg == "setKeyboard(QString)" ) { | 459 | } else if ( msg == "setKeyboard(QString)" ) { |
460 | QString kb; | 460 | QString kb; |
461 | stream >> kb; | 461 | stream >> kb; |
462 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 462 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
463 | qwsServer->openKeyboard(); | 463 | qwsServer->openKeyboard(); |
464 | 464 | ||
465 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | 465 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
466 | int delay, period; | 466 | int delay, period; |
467 | stream >> delay >> period; | 467 | stream >> delay >> period; |
468 | qwsSetKeyboardAutoRepeat( delay, period ); | 468 | qwsSetKeyboardAutoRepeat( delay, period ); |
469 | Config cfg( "qpe" ); | 469 | Config cfg( "qpe" ); |
470 | cfg.setGroup("Keyboard"); | 470 | cfg.setGroup("Keyboard"); |
471 | cfg.writeEntry( "RepeatDelay", delay ); | 471 | cfg.writeEntry( "RepeatDelay", delay ); |
472 | cfg.writeEntry( "RepeatPeriod", period ); | 472 | cfg.writeEntry( "RepeatPeriod", period ); |
473 | } else if ( msg == "setKeyboardLayout(QString)" ) { | 473 | } else if ( msg == "setKeyboardLayout(QString)" ) { |
474 | QString kb; | 474 | QString kb; |
475 | stream >> kb; | 475 | stream >> kb; |
476 | setKeyboardLayout( kb ); | 476 | setKeyboardLayout( kb ); |
477 | Config cfg( "qpe" ); | 477 | Config cfg( "qpe" ); |
478 | cfg.setGroup("Keyboard"); | 478 | cfg.setGroup("Keyboard"); |
479 | cfg.writeEntry( "Layout", kb ); | 479 | cfg.writeEntry( "Layout", kb ); |
480 | } else if ( msg == "autoStart(QString)" ) { | 480 | } else if ( msg == "autoStart(QString)" ) { |
481 | QString appName; | 481 | QString appName; |
482 | stream >> appName; | 482 | stream >> appName; |
483 | Config cfg( "autostart" ); | 483 | Config cfg( "autostart" ); |
484 | cfg.setGroup( "AutoStart" ); | 484 | cfg.setGroup( "AutoStart" ); |
485 | if ( appName.compare("clear") == 0){ | 485 | if ( appName.compare("clear") == 0){ |
486 | cfg.writeEntry("Apps", ""); | 486 | cfg.writeEntry("Apps", ""); |
487 | } | 487 | } |
488 | } else if ( msg == "autoStart(QString,QString)" ) { | 488 | } else if ( msg == "autoStart(QString,QString)" ) { |
489 | QString modifier, appName; | 489 | QString modifier, appName; |
490 | stream >> modifier >> appName; | 490 | stream >> modifier >> appName; |
491 | Config cfg( "autostart" ); | 491 | Config cfg( "autostart" ); |
492 | cfg.setGroup( "AutoStart" ); | 492 | cfg.setGroup( "AutoStart" ); |
493 | if ( modifier.compare("add") == 0 ){ | 493 | if ( modifier.compare("add") == 0 ){ |
494 | // only add if appname is entered | 494 | // only add if appname is entered |
495 | if (!appName.isEmpty()) { | 495 | if (!appName.isEmpty()) { |
496 | cfg.writeEntry("Apps", appName); | 496 | cfg.writeEntry("Apps", appName); |
497 | } | 497 | } |
498 | } else if (modifier.compare("remove") == 0 ) { | 498 | } else if (modifier.compare("remove") == 0 ) { |
499 | // need to change for multiple entries | 499 | // need to change for multiple entries |
500 | // actually remove is right now simular to clear, but in future there | 500 | // actually remove is right now simular to clear, but in future there |
501 | // should be multiple apps in autostart possible. | 501 | // should be multiple apps in autostart possible. |
502 | QString checkName; | 502 | QString checkName; |
503 | checkName = cfg.readEntry("Apps", ""); | 503 | checkName = cfg.readEntry("Apps", ""); |
504 | if (checkName == appName) { | 504 | if (checkName == appName) { |
505 | cfg.writeEntry("Apps", ""); | 505 | cfg.writeEntry("Apps", ""); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | // case the autostart feature should be delayed | 508 | // case the autostart feature should be delayed |
509 | } else if ( msg == "autoStart(QString,QString,QString)") { | 509 | } else if ( msg == "autoStart(QString,QString,QString)") { |
510 | QString modifier, appName, delay; | 510 | QString modifier, appName, delay; |
511 | stream >> modifier >> appName >> delay; | 511 | stream >> modifier >> appName >> delay; |
512 | Config cfg( "autostart" ); | 512 | Config cfg( "autostart" ); |
513 | 513 | ||
514 | cfg.setGroup( "AutoStart" ); | 514 | cfg.setGroup( "AutoStart" ); |
515 | if ( modifier.compare("add") == 0 ){ | 515 | if ( modifier.compare("add") == 0 ){ |
516 | // only add it appname is entered | 516 | // only add it appname is entered |
517 | if (!appName.isEmpty()) { | 517 | if (!appName.isEmpty()) { |
518 | cfg.writeEntry("Apps", appName); | 518 | cfg.writeEntry("Apps", appName); |
519 | cfg.writeEntry("Delay", delay); | 519 | cfg.writeEntry("Delay", delay); |
520 | } | 520 | } |
521 | } else { | 521 | } else { |
522 | } | 522 | } |
523 | } | 523 | } |
524 | #endif | 524 | #endif |
525 | } | 525 | } |
526 | 526 | ||
527 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) | 527 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) |
528 | { | 528 | { |
529 | QDataStream stream( data, IO_ReadOnly ); | 529 | QDataStream stream( data, IO_ReadOnly ); |
530 | 530 | ||
531 | if ( msg == "reloadApps()" ) { | 531 | if ( msg == "reloadApps()" ) { |
532 | docList->reloadAppLnks(); | 532 | docList->reloadAppLnks(); |
533 | } else if ( msg == "soundAlarm()" ) { | 533 | } else if ( msg == "soundAlarm()" ) { |
534 | ServerApplication::soundAlarm(); | 534 | ServerApplication::soundAlarm(); |
535 | } | 535 | } |
536 | else if ( msg == "setLed(int,bool)" ) { | 536 | else if ( msg == "setLed(int,bool)" ) { |
537 | int led, status; | 537 | int led, status; |
538 | stream >> led >> status; | 538 | stream >> led >> status; |
539 | 539 | ||
540 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); | 540 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); |
541 | if ( ll. count ( )){ | 541 | if ( ll. count ( )){ |
542 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | 542 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; |
543 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); | 543 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); |
544 | 544 | ||
545 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); | 545 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); |
546 | } | 546 | } |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | void Server::cancelSync() | 550 | void Server::cancelSync() |
551 | { | 551 | { |
552 | #ifndef QT_NO_COP | 552 | #ifndef QT_NO_COP |
553 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 553 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
554 | #endif | 554 | #endif |
555 | delete syncDialog; | 555 | delete syncDialog; |
556 | syncDialog = 0; | 556 | syncDialog = 0; |
557 | } | 557 | } |
558 | 558 | ||
559 | bool Server::mkdir(const QString &localPath) | 559 | bool Server::mkdir(const QString &localPath) |
560 | { | 560 | { |
561 | QDir fullDir(localPath); | 561 | QDir fullDir(localPath); |
562 | if (fullDir.exists()) | 562 | if (fullDir.exists()) |
563 | return true; | 563 | return true; |
564 | 564 | ||
565 | // at this point the directory doesn't exist | 565 | // at this point the directory doesn't exist |
566 | // go through the directory tree and start creating the direcotories | 566 | // go through the directory tree and start creating the direcotories |
567 | // that don't exist; if we can't create the directories, return false | 567 | // that don't exist; if we can't create the directories, return false |
568 | 568 | ||
569 | QString dirSeps = "/"; | 569 | QString dirSeps = "/"; |
570 | int dirIndex = localPath.find(dirSeps); | 570 | int dirIndex = localPath.find(dirSeps); |
571 | QString checkedPath; | 571 | QString checkedPath; |
572 | 572 | ||
573 | // didn't find any seps; weird, use the cur dir instead | 573 | // didn't find any seps; weird, use the cur dir instead |
574 | if (dirIndex == -1) { | 574 | if (dirIndex == -1) { |
575 | //qDebug("No seperators found in path %s", localPath.latin1()); | 575 | //qDebug("No seperators found in path %s", localPath.latin1()); |
576 | checkedPath = QDir::currentDirPath(); | 576 | checkedPath = QDir::currentDirPath(); |
577 | } | 577 | } |
578 | 578 | ||
579 | while (checkedPath != localPath) { | 579 | while (checkedPath != localPath) { |
580 | // no more seperators found, use the local path | 580 | // no more seperators found, use the local path |
581 | if (dirIndex == -1) | 581 | if (dirIndex == -1) |
582 | checkedPath = localPath; | 582 | checkedPath = localPath; |
583 | else { | 583 | else { |
584 | // the next directory to check | 584 | // the next directory to check |
585 | checkedPath = localPath.left(dirIndex) + "/"; | 585 | checkedPath = localPath.left(dirIndex) + "/"; |
586 | // advance the iterator; the next dir seperator | 586 | // advance the iterator; the next dir seperator |
587 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 587 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
588 | } | 588 | } |
589 | 589 | ||
590 | QDir checkDir(checkedPath); | 590 | QDir checkDir(checkedPath); |
591 | if (!checkDir.exists()) { | 591 | if (!checkDir.exists()) { |
592 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 592 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
593 | 593 | ||
594 | if (!checkDir.mkdir(checkedPath)) { | 594 | if (!checkDir.mkdir(checkedPath)) { |
595 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 595 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
596 | return FALSE; | 596 | return FALSE; |
597 | } | 597 | } |
598 | } | 598 | } |
599 | 599 | ||
600 | } | 600 | } |
601 | return TRUE; | 601 | return TRUE; |
602 | } | 602 | } |
603 | 603 | ||
604 | void Server::styleChange( QStyle &s ) | 604 | void Server::styleChange( QStyle &s ) |
605 | { | 605 | { |
606 | QWidget::styleChange( s ); | 606 | QWidget::styleChange( s ); |
607 | } | 607 | } |
608 | 608 | ||
609 | void Server::startTransferServer() | 609 | void Server::startTransferServer() |
610 | { | 610 | { |
611 | if ( !qcopBridge ) { | 611 | if ( !qcopBridge ) { |
612 | // start qcop bridge server | 612 | // start qcop bridge server |
613 | qcopBridge = new QCopBridge( 4243 ); | 613 | qcopBridge = new QCopBridge( 4243 ); |
614 | if ( qcopBridge->ok() ) { | 614 | if ( qcopBridge->ok() ) { |
615 | // ... OK | 615 | // ... OK |
616 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress &)), | 616 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), |
617 | this, SLOT(syncConnectionClosed(const QHostAddress &)) ); | 617 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); |
618 | } else { | 618 | } else { |
619 | delete qcopBridge; | 619 | delete qcopBridge; |
620 | qcopBridge = 0; | 620 | qcopBridge = 0; |
621 | } | 621 | } |
622 | } | 622 | } |
623 | if ( !transferServer ) { | 623 | if ( !transferServer ) { |
624 | // start transfer server | 624 | // start transfer server |
625 | transferServer = new TransferServer( 4242 ); | 625 | transferServer = new TransferServer( 4242 ); |
626 | if ( transferServer->ok() ) { | 626 | if ( transferServer->ok() ) { |
627 | // ... OK | 627 | // ... OK |
628 | } else { | 628 | } else { |
629 | delete transferServer; | 629 | delete transferServer; |
630 | transferServer = 0; | 630 | transferServer = 0; |
631 | } | 631 | } |
632 | } | 632 | } |
633 | if ( !transferServer || !qcopBridge ) | 633 | if ( !transferServer || !qcopBridge ) |
634 | tid_xfer = startTimer( 2000 ); | 634 | tid_xfer = startTimer( 2000 ); |
635 | } | 635 | } |
636 | 636 | ||
637 | void Server::timerEvent( QTimerEvent *e ) | 637 | void Server::timerEvent( QTimerEvent *e ) |
638 | { | 638 | { |
639 | if ( e->timerId() == tid_xfer ) { | 639 | if ( e->timerId() == tid_xfer ) { |
640 | killTimer( tid_xfer ); | 640 | killTimer( tid_xfer ); |
641 | tid_xfer = 0; | 641 | tid_xfer = 0; |
642 | startTransferServer(); | 642 | startTransferServer(); |
643 | } | 643 | } |
644 | /* ### FIXME today startin */ | 644 | /* ### FIXME today startin */ |
645 | #if 0 | 645 | #if 0 |
646 | else if ( e->timerId() == tid_today ) { | 646 | else if ( e->timerId() == tid_today ) { |
647 | QDate today = QDate::currentDate(); | 647 | QDate today = QDate::currentDate(); |
648 | if ( today != last_today_show ) { | 648 | if ( today != last_today_show ) { |
649 | last_today_show = today; | 649 | last_today_show = today; |
650 | Config cfg("today"); | 650 | Config cfg("today"); |
651 | cfg.setGroup("Start"); | 651 | cfg.setGroup("Start"); |
652 | #ifndef QPE_DEFAULT_TODAY_MODE | 652 | #ifndef QPE_DEFAULT_TODAY_MODE |
653 | #define QPE_DEFAULT_TODAY_MODE "Never" | 653 | #define QPE_DEFAULT_TODAY_MODE "Never" |
654 | #endif | 654 | #endif |
655 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { | 655 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { |
656 | QCopEnvelope env(Service::channel("today"),"raise()"); | 656 | QCopEnvelope env(Service::channel("today"),"raise()"); |
657 | } | 657 | } |
658 | } | 658 | } |
659 | } | 659 | } |
660 | #endif | 660 | #endif |
661 | } | 661 | } |
662 | 662 | ||
663 | void Server::terminateServers() | 663 | void Server::terminateServers() |
664 | { | 664 | { |
665 | delete transferServer; | 665 | delete transferServer; |
666 | delete qcopBridge; | 666 | delete qcopBridge; |
667 | transferServer = 0; | 667 | transferServer = 0; |
668 | qcopBridge = 0; | 668 | qcopBridge = 0; |
669 | } | 669 | } |
670 | 670 | ||
671 | void Server::syncConnectionClosed( const QHostAddress & ) | 671 | void Server::syncConnectionClosed( const QHostAddress & ) |
672 | { | 672 | { |
673 | qDebug( "Lost sync connection" ); | 673 | qDebug( "Lost sync connection" ); |
674 | delete syncDialog; | 674 | delete syncDialog; |
675 | syncDialog = 0; | 675 | syncDialog = 0; |
676 | } | 676 | } |
677 | 677 | ||
678 | void Server::pokeTimeMonitors() | 678 | void Server::pokeTimeMonitors() |
679 | { | 679 | { |
680 | #if 0 | 680 | #if 0 |
681 | // inform all TimeMonitors | 681 | // inform all TimeMonitors |
682 | QStrList tms = Service::channels("TimeMonitor"); | 682 | QStrList tms = Service::channels("TimeMonitor"); |
683 | for (const char* ch = tms.first(); ch; ch=tms.next()) { | 683 | for (const char* ch = tms.first(); ch; ch=tms.next()) { |
684 | QString t = getenv("TZ"); | 684 | QString t = getenv("TZ"); |
685 | QCopEnvelope e(ch, "timeChange(QString)"); | 685 | QCopEnvelope e(ch, "timeChange(QString)"); |
686 | e << t; | 686 | e << t; |
687 | } | 687 | } |
688 | #endif | 688 | #endif |
689 | } | 689 | } |
690 | 690 | ||
691 | void Server::applicationLaunched(int, const QString &app) | 691 | void Server::applicationLaunched(int, const QString &app) |
692 | { | 692 | { |
693 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); | 693 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); |
694 | } | 694 | } |
695 | 695 | ||
696 | void Server::applicationTerminated(int pid, const QString &app) | 696 | void Server::applicationTerminated(int pid, const QString &app) |
697 | { | 697 | { |
698 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); | 698 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); |
699 | #if 0 | 699 | #if 0 |
700 | tsmMonitor->applicationTerminated( pid ); | 700 | tsmMonitor->applicationTerminated( pid ); |
701 | #endif | 701 | #endif |
702 | } | 702 | } |
703 | 703 | ||
704 | void Server::applicationConnected(const QString &app) | 704 | void Server::applicationConnected(const QString &app) |
705 | { | 705 | { |
706 | serverGui->applicationStateChanged( app, ServerInterface::Running ); | 706 | serverGui->applicationStateChanged( app, ServerInterface::Running ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void Server::storageChanged() | 709 | void Server::storageChanged() |
710 | { | 710 | { |
711 | system( "qtopia-update-symlinks" ); | 711 | system( "qtopia-update-symlinks" ); |
712 | serverGui->storageChanged( storage->fileSystems() ); | 712 | serverGui->storageChanged( storage->fileSystems() ); |
713 | docList->storageChanged(); | 713 | docList->storageChanged(); |
714 | } | 714 | } |
715 | 715 | ||
716 | 716 | ||
717 | 717 | ||
718 | void Server::preloadApps() | 718 | void Server::preloadApps() |
719 | { | 719 | { |
720 | Config cfg("Launcher"); | 720 | Config cfg("Launcher"); |
721 | cfg.setGroup("Preload"); | 721 | cfg.setGroup("Preload"); |
722 | QStringList apps = cfg.readListEntry("Apps",','); | 722 | QStringList apps = cfg.readListEntry("Apps",','); |
723 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 723 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
724 | #ifndef QT_NO_COP | 724 | #ifndef QT_NO_COP |
725 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 725 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
726 | #endif | 726 | #endif |
727 | } | 727 | } |
728 | } | 728 | } |
729 | 729 | ||
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index f7c2341..d38dd97 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -112,396 +112,396 @@ private: | |||
112 | int alertCount; | 112 | int alertCount; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 115 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
116 | { | 116 | { |
117 | alertCount++; | 117 | alertCount++; |
118 | if ( alertCount < priority ) | 118 | if ( alertCount < priority ) |
119 | return; | 119 | return; |
120 | if ( priority > currentPriority ) | 120 | if ( priority > currentPriority ) |
121 | return; | 121 | return; |
122 | currentPriority = priority; | 122 | currentPriority = priority; |
123 | setText( text ); | 123 | setText( text ); |
124 | show(); | 124 | show(); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 128 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
129 | { | 129 | { |
130 | QMessageBox::hideEvent( e ); | 130 | QMessageBox::hideEvent( e ); |
131 | alertCount = 0; | 131 | alertCount = 0; |
132 | currentPriority = INT_MAX; | 132 | currentPriority = INT_MAX; |
133 | } | 133 | } |
134 | 134 | ||
135 | //--------------------------------------------------------------------------- | 135 | //--------------------------------------------------------------------------- |
136 | 136 | ||
137 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 137 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) |
138 | { | 138 | { |
139 | /* We don't do this cause it would interfere with ODevice */ | 139 | /* We don't do this cause it would interfere with ODevice */ |
140 | #if 0 | 140 | #if 0 |
141 | qwsServer->setKeyboardFilter(this); | 141 | qwsServer->setKeyboardFilter(this); |
142 | #endif | 142 | #endif |
143 | } | 143 | } |
144 | 144 | ||
145 | void KeyFilter::timerEvent(QTimerEvent* e) | 145 | void KeyFilter::timerEvent(QTimerEvent* e) |
146 | { | 146 | { |
147 | if ( e->timerId() == held_tid ) { | 147 | if ( e->timerId() == held_tid ) { |
148 | killTimer(held_tid); | 148 | killTimer(held_tid); |
149 | // button held | 149 | // button held |
150 | if ( heldButton ) { | 150 | if ( heldButton ) { |
151 | emit activate(heldButton, TRUE); | 151 | emit activate(heldButton, TRUE); |
152 | heldButton = 0; | 152 | heldButton = 0; |
153 | } | 153 | } |
154 | held_tid = 0; | 154 | held_tid = 0; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { | 158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { |
159 | m_keys.insert( key.keyCode(), key ); | 159 | m_keys.insert( key.keyCode(), key ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { | 162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { |
163 | m_keys.remove( key.keyCode() ); | 163 | m_keys.remove( key.keyCode() ); |
164 | } | 164 | } |
165 | 165 | ||
166 | bool KeyFilter::keyRegistered( int key ) { | 166 | bool KeyFilter::keyRegistered( int key ) { |
167 | /* | 167 | /* |
168 | * Check if we've a key registered | 168 | * Check if we've a key registered |
169 | */ | 169 | */ |
170 | if ( !m_keys[key].send()) | 170 | if ( !m_keys[key].send()) |
171 | return false; | 171 | return false; |
172 | else | 172 | else |
173 | return true; | 173 | return true; |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
178 | { | 178 | { |
179 | if ( !loggedin | 179 | if ( !loggedin |
180 | // Permitted keys | 180 | // Permitted keys |
181 | && keycode != Key_F34 // power | 181 | && keycode != Key_F34 // power |
182 | && keycode != Key_F30 // select | 182 | && keycode != Key_F30 // select |
183 | && keycode != Key_Enter | 183 | && keycode != Key_Enter |
184 | && keycode != Key_Return | 184 | && keycode != Key_Return |
185 | && keycode != Key_Space | 185 | && keycode != Key_Space |
186 | && keycode != Key_Left | 186 | && keycode != Key_Left |
187 | && keycode != Key_Right | 187 | && keycode != Key_Right |
188 | && keycode != Key_Up | 188 | && keycode != Key_Up |
189 | && keycode != Key_Down ) | 189 | && keycode != Key_Down ) |
190 | return TRUE; | 190 | return TRUE; |
191 | 191 | ||
192 | /* check if it was registered */ | 192 | /* check if it was registered */ |
193 | if (!db ) { | 193 | if (!db ) { |
194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
195 | return true; | 195 | return true; |
196 | }else { | 196 | }else { |
197 | 197 | ||
198 | 198 | ||
199 | // First check to see if DeviceButtonManager knows something about this button: | 199 | // First check to see if DeviceButtonManager knows something about this button: |
200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); | 200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); |
201 | if (button && !autoRepeat) { | 201 | if (button && !autoRepeat) { |
202 | if ( held_tid ) { | 202 | if ( held_tid ) { |
203 | killTimer(held_tid); | 203 | killTimer(held_tid); |
204 | held_tid = 0; | 204 | held_tid = 0; |
205 | } | 205 | } |
206 | if ( button->heldAction().isNull() ) { | 206 | if ( button->heldAction().isNull() ) { |
207 | if ( press ) | 207 | if ( press ) |
208 | emit activate(button, FALSE); | 208 | emit activate(button, FALSE); |
209 | } else if ( press ) { | 209 | } else if ( press ) { |
210 | heldButton = button; | 210 | heldButton = button; |
211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
212 | } else if ( heldButton ) { | 212 | } else if ( heldButton ) { |
213 | heldButton = 0; | 213 | heldButton = 0; |
214 | emit activate(button, FALSE); | 214 | emit activate(button, FALSE); |
215 | } | 215 | } |
216 | QWSServer::screenSaverActivate(FALSE); | 216 | QWSServer::screenSaverActivate(FALSE); |
217 | return TRUE; | 217 | return TRUE; |
218 | } | 218 | } |
219 | return false; | 219 | return false; |
220 | } | 220 | } |
221 | if ( keycode == HardKey_Suspend ) { | 221 | if ( keycode == HardKey_Suspend ) { |
222 | if ( press ) emit power(); | 222 | if ( press ) emit power(); |
223 | return TRUE; | 223 | return TRUE; |
224 | } | 224 | } |
225 | if ( keycode == HardKey_Backlight ) { | 225 | if ( keycode == HardKey_Backlight ) { |
226 | if ( press ) emit backlight(); | 226 | if ( press ) emit backlight(); |
227 | return TRUE; | 227 | return TRUE; |
228 | } | 228 | } |
229 | if ( keycode == Key_F32 ) { | 229 | if ( keycode == Key_F32 ) { |
230 | #ifndef QT_NO_COP | 230 | #ifndef QT_NO_COP |
231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
232 | #endif | 232 | #endif |
233 | return TRUE; | 233 | return TRUE; |
234 | } | 234 | } |
235 | if ( keycode == Key_F31 ) { | 235 | if ( keycode == Key_F31 ) { |
236 | if ( press ) emit symbol(); | 236 | if ( press ) emit symbol(); |
237 | QWSServer::screenSaverActivate(FALSE); | 237 | QWSServer::screenSaverActivate(FALSE); |
238 | return TRUE; | 238 | return TRUE; |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( keycode == Key_NumLock ) | 241 | if ( keycode == Key_NumLock ) |
242 | if ( press ) emit numLockStateToggle(); | 242 | if ( press ) emit numLockStateToggle(); |
243 | 243 | ||
244 | if ( keycode == Key_CapsLock ) | 244 | if ( keycode == Key_CapsLock ) |
245 | if ( press ) emit capsLockStateToggle(); | 245 | if ( press ) emit capsLockStateToggle(); |
246 | 246 | ||
247 | if ( serverApp ) | 247 | if ( serverApp ) |
248 | serverApp->keyClick(keycode,press,autoRepeat); | 248 | serverApp->keyClick(keycode,press,autoRepeat); |
249 | 249 | ||
250 | return FALSE; | 250 | return FALSE; |
251 | } | 251 | } |
252 | 252 | ||
253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
254 | 254 | ||
255 | #if defined(QPE_HAVE_MEMALERTER) | 255 | #if defined(QPE_HAVE_MEMALERTER) |
256 | QPE_MEMALERTER_IMPL | 256 | QPE_MEMALERTER_IMPL |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | 259 | ||
260 | 260 | ||
261 | //--------------------------------------------------------------------------- | 261 | //--------------------------------------------------------------------------- |
262 | 262 | ||
263 | bool ServerApplication::doRestart = FALSE; | 263 | bool ServerApplication::doRestart = FALSE; |
264 | bool ServerApplication::allowRestart = TRUE; | 264 | bool ServerApplication::allowRestart = TRUE; |
265 | bool ServerApplication::ms_is_starting = TRUE; | 265 | bool ServerApplication::ms_is_starting = TRUE; |
266 | 266 | ||
267 | void ServerApplication::switchLCD( bool on ) { | 267 | void ServerApplication::switchLCD( bool on ) { |
268 | if ( !qApp ) | 268 | if ( !qApp ) |
269 | return; | 269 | return; |
270 | 270 | ||
271 | ServerApplication *dapp = ServerApplication::me() ; | 271 | ServerApplication *dapp = ServerApplication::me() ; |
272 | 272 | ||
273 | if ( !dapp-> m_screensaver ) | 273 | if ( !dapp-> m_screensaver ) |
274 | return; | 274 | return; |
275 | 275 | ||
276 | if ( on ) { | 276 | if ( on ) { |
277 | dapp-> m_screensaver-> setDisplayState ( true ); | 277 | dapp-> m_screensaver-> setDisplayState ( true ); |
278 | dapp-> m_screensaver-> setBacklight ( -3 ); | 278 | dapp-> m_screensaver-> setBacklight ( -3 ); |
279 | }else | 279 | }else |
280 | dapp-> m_screensaver-> setDisplayState ( false ); | 280 | dapp-> m_screensaver-> setDisplayState ( false ); |
281 | 281 | ||
282 | 282 | ||
283 | } | 283 | } |
284 | 284 | ||
285 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 285 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |
286 | : QPEApplication( argc, argv, t ) | 286 | : QPEApplication( argc, argv, t ) |
287 | { | 287 | { |
288 | ms_is_starting = true; | 288 | ms_is_starting = true; |
289 | 289 | ||
290 | // We know we'll have lots of cached pixmaps due to App/DocLnks | 290 | // We know we'll have lots of cached pixmaps due to App/DocLnks |
291 | QPixmapCache::setCacheLimit(512); | 291 | QPixmapCache::setCacheLimit(512); |
292 | 292 | ||
293 | m_ps = new PowerStatus; | 293 | m_ps = new PowerStatus; |
294 | m_ps_last = new PowerStatus; | 294 | m_ps_last = new PowerStatus; |
295 | pa = new DesktopPowerAlerter( 0 ); | 295 | pa = new DesktopPowerAlerter( 0 ); |
296 | 296 | ||
297 | m_apm_timer = new QTimer( this ); | 297 | m_apm_timer = new QTimer( this ); |
298 | connect(m_apm_timer, SIGNAL( timeout() ), | 298 | connect(m_apm_timer, SIGNAL( timeout() ), |
299 | this, SLOT( apmTimeout() ) ); | 299 | this, SLOT( apmTimeout() ) ); |
300 | 300 | ||
301 | reloadPowerWarnSettings(); | 301 | reloadPowerWarnSettings(); |
302 | 302 | ||
303 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 303 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
304 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 304 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), |
305 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); | 305 | this, SLOT(systemMessage(const QCString&,const QByteArray&) ) ); |
306 | 306 | ||
307 | channel = new QCopChannel("QPE/Launcher", this ); | 307 | channel = new QCopChannel("QPE/Launcher", this ); |
308 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 308 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), |
309 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); | 309 | this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); |
310 | 310 | ||
311 | m_screensaver = new OpieScreenSaver(); | 311 | m_screensaver = new OpieScreenSaver(); |
312 | m_screensaver->setInterval( -1 ); | 312 | m_screensaver->setInterval( -1 ); |
313 | QWSServer::setScreenSaver( m_screensaver ); | 313 | QWSServer::setScreenSaver( m_screensaver ); |
314 | 314 | ||
315 | connect( qApp, SIGNAL( volumeChanged( bool ) ), | 315 | connect( qApp, SIGNAL( volumeChanged(bool) ), |
316 | this, SLOT( rereadVolumes() ) ); | 316 | this, SLOT( rereadVolumes() ) ); |
317 | 317 | ||
318 | 318 | ||
319 | /* ### PluginLoader libqtopia SafeMode */ | 319 | /* ### PluginLoader libqtopia SafeMode */ |
320 | #if 0 | 320 | #if 0 |
321 | if ( PluginLoader::inSafeMode() ) | 321 | if ( PluginLoader::inSafeMode() ) |
322 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 322 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
323 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 323 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
324 | #endif | 324 | #endif |
325 | 325 | ||
326 | kf = new KeyFilter(this); | 326 | kf = new KeyFilter(this); |
327 | 327 | ||
328 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 328 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
329 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 329 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
330 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 330 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
331 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 331 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
332 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 332 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
333 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 333 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
334 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 334 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
335 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | 335 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); |
336 | 336 | ||
337 | 337 | ||
338 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 338 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
339 | 339 | ||
340 | connect( this, SIGNAL(power() ), | 340 | connect( this, SIGNAL(power() ), |
341 | SLOT(togglePower() ) ); | 341 | SLOT(togglePower() ) ); |
342 | 342 | ||
343 | rereadVolumes(); | 343 | rereadVolumes(); |
344 | 344 | ||
345 | serverApp = this; | 345 | serverApp = this; |
346 | 346 | ||
347 | apmTimeout(); | 347 | apmTimeout(); |
348 | grabKeyboard(); | 348 | grabKeyboard(); |
349 | 349 | ||
350 | /* make sure the event filter is installed */ | 350 | /* make sure the event filter is installed */ |
351 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | 351 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | ServerApplication::~ServerApplication() | 355 | ServerApplication::~ServerApplication() |
356 | { | 356 | { |
357 | ungrabKeyboard(); | 357 | ungrabKeyboard(); |
358 | 358 | ||
359 | 359 | ||
360 | delete pa; | 360 | delete pa; |
361 | delete m_ps; | 361 | delete m_ps; |
362 | delete m_ps_last; | 362 | delete m_ps_last; |
363 | } | 363 | } |
364 | 364 | ||
365 | void ServerApplication::apmTimeout() { | 365 | void ServerApplication::apmTimeout() { |
366 | serverApp-> checkMemory( ); // in case no events are generated | 366 | serverApp-> checkMemory( ); // in case no events are generated |
367 | *m_ps_last = *m_ps; | 367 | *m_ps_last = *m_ps; |
368 | *m_ps = PowerStatusManager::readStatus(); | 368 | *m_ps = PowerStatusManager::readStatus(); |
369 | 369 | ||
370 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 370 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
371 | m_screensaver-> powerStatusChanged( *m_ps ); | 371 | m_screensaver-> powerStatusChanged( *m_ps ); |
372 | 372 | ||
373 | if ( m_ps->acStatus() == PowerStatus::Online ) { | 373 | if ( m_ps->acStatus() == PowerStatus::Online ) { |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | 376 | ||
377 | int bat = m_ps-> batteryPercentRemaining(); | 377 | int bat = m_ps-> batteryPercentRemaining(); |
378 | 378 | ||
379 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | 379 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { |
380 | if ( bat <= m_powerCritical ) { | 380 | if ( bat <= m_powerCritical ) { |
381 | QMessageBox battlow( | 381 | QMessageBox battlow( |
382 | tr("WARNING"), | 382 | tr("WARNING"), |
383 | tr("<p>The battery level is critical!" | 383 | tr("<p>The battery level is critical!" |
384 | "<p>Keep power off until AC is restored"), | 384 | "<p>Keep power off until AC is restored"), |
385 | QMessageBox::Warning, | 385 | QMessageBox::Warning, |
386 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 386 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
387 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 387 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
388 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 388 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
389 | battlow.exec(); | 389 | battlow.exec(); |
390 | } else if ( bat <= m_powerVeryLow ) | 390 | } else if ( bat <= m_powerVeryLow ) |
391 | pa->alert( tr( "The battery is running very low. "), 2 ); | 391 | pa->alert( tr( "The battery is running very low. "), 2 ); |
392 | } | 392 | } |
393 | 393 | ||
394 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { | 394 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { |
395 | QMessageBox battlow( | 395 | QMessageBox battlow( |
396 | tr("WARNING"), | 396 | tr("WARNING"), |
397 | tr("<p>The Back-up battery is very low" | 397 | tr("<p>The Back-up battery is very low" |
398 | "<p>Please charge the back-up battery"), | 398 | "<p>Please charge the back-up battery"), |
399 | QMessageBox::Warning, | 399 | QMessageBox::Warning, |
400 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 400 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
401 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 401 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
402 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 402 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
403 | battlow.exec(); | 403 | battlow.exec(); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | 406 | ||
407 | void ServerApplication::systemMessage( const QCString& msg, | 407 | void ServerApplication::systemMessage( const QCString& msg, |
408 | const QByteArray& data ) { | 408 | const QByteArray& data ) { |
409 | QDataStream stream ( data, IO_ReadOnly ); | 409 | QDataStream stream ( data, IO_ReadOnly ); |
410 | 410 | ||
411 | if ( msg == "setScreenSaverInterval(int)" ) { | 411 | if ( msg == "setScreenSaverInterval(int)" ) { |
412 | int time; | 412 | int time; |
413 | stream >> time; | 413 | stream >> time; |
414 | m_screensaver-> setInterval( time ); | 414 | m_screensaver-> setInterval( time ); |
415 | } | 415 | } |
416 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 416 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
417 | int t1, t2, t3; | 417 | int t1, t2, t3; |
418 | stream >> t1 >> t2 >> t3; | 418 | stream >> t1 >> t2 >> t3; |
419 | m_screensaver-> setIntervals( t1, t2, t3 ); | 419 | m_screensaver-> setIntervals( t1, t2, t3 ); |
420 | } | 420 | } |
421 | else if ( msg == "setBacklight(int)" ) { | 421 | else if ( msg == "setBacklight(int)" ) { |
422 | int bright; | 422 | int bright; |
423 | stream >> bright; | 423 | stream >> bright; |
424 | m_screensaver-> setBacklight( bright ); | 424 | m_screensaver-> setBacklight( bright ); |
425 | } | 425 | } |
426 | else if ( msg == "setScreenSaverMode(int)" ) { | 426 | else if ( msg == "setScreenSaverMode(int)" ) { |
427 | int mode; | 427 | int mode; |
428 | stream >> mode; | 428 | stream >> mode; |
429 | m_screensaver-> setMode ( mode ); | 429 | m_screensaver-> setMode ( mode ); |
430 | } | 430 | } |
431 | else if ( msg == "reloadPowerWarnSettings()" ) { | 431 | else if ( msg == "reloadPowerWarnSettings()" ) { |
432 | reloadPowerWarnSettings(); | 432 | reloadPowerWarnSettings(); |
433 | } | 433 | } |
434 | else if ( msg == "setDisplayState(int)" ) { | 434 | else if ( msg == "setDisplayState(int)" ) { |
435 | int state; | 435 | int state; |
436 | stream >> state; | 436 | stream >> state; |
437 | m_screensaver-> setDisplayState ( state != 0 ); | 437 | m_screensaver-> setDisplayState ( state != 0 ); |
438 | } | 438 | } |
439 | else if ( msg == "suspend()" ) { | 439 | else if ( msg == "suspend()" ) { |
440 | emit power(); | 440 | emit power(); |
441 | } | 441 | } |
442 | else if ( msg == "sendBusinessCard()" ) { | 442 | else if ( msg == "sendBusinessCard()" ) { |
443 | QString card = ::getenv ( "HOME" ); | 443 | QString card = ::getenv ( "HOME" ); |
444 | card += "/Applications/addressbook/businesscard.vcf"; | 444 | card += "/Applications/addressbook/businesscard.vcf"; |
445 | 445 | ||
446 | if ( QFile::exists( card ) ) { | 446 | if ( QFile::exists( card ) ) { |
447 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 447 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
448 | QString mimetype = "text/x-vCard"; | 448 | QString mimetype = "text/x-vCard"; |
449 | e << tr( "business card" ) << card << mimetype; | 449 | e << tr( "business card" ) << card << mimetype; |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | 453 | ||
454 | void ServerApplication::reloadPowerWarnSettings ( ) | 454 | void ServerApplication::reloadPowerWarnSettings ( ) |
455 | { | 455 | { |
456 | Config cfg ( "apm" ); | 456 | Config cfg ( "apm" ); |
457 | cfg. setGroup ( "Warnings" ); | 457 | cfg. setGroup ( "Warnings" ); |
458 | 458 | ||
459 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | 459 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); |
460 | 460 | ||
461 | m_apm_timer-> stop ( ); | 461 | m_apm_timer-> stop ( ); |
462 | if ( iv ) | 462 | if ( iv ) |
463 | m_apm_timer-> start ( iv ); | 463 | m_apm_timer-> start ( iv ); |
464 | 464 | ||
465 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | 465 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); |
466 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | 466 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); |
467 | } | 467 | } |
468 | 468 | ||
469 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | 469 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
470 | { | 470 | { |
471 | QDataStream stream ( data, IO_ReadOnly ); | 471 | QDataStream stream ( data, IO_ReadOnly ); |
472 | 472 | ||
473 | if ( msg == "deviceButton(int,int,int)" ) { | 473 | if ( msg == "deviceButton(int,int,int)" ) { |
474 | int keycode, press, autoRepeat; | 474 | int keycode, press, autoRepeat; |
475 | stream >> keycode >> press >> autoRepeat; | 475 | stream >> keycode >> press >> autoRepeat; |
476 | 476 | ||
477 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); | 477 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); |
478 | } | 478 | } |
479 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | 479 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { |
480 | int k; | 480 | int k; |
481 | QCString c, m; | 481 | QCString c, m; |
482 | stream >> k >> c >> m; | 482 | stream >> k >> c >> m; |
483 | 483 | ||
484 | kf -> registerKey( QCopKeyRegister(k, c, m) ); | 484 | kf -> registerKey( QCopKeyRegister(k, c, m) ); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | 488 | ||
489 | bool ServerApplication::screenLocked() | 489 | bool ServerApplication::screenLocked() |
490 | { | 490 | { |
491 | return loggedin == 0; | 491 | return loggedin == 0; |
492 | } | 492 | } |
493 | 493 | ||
494 | void ServerApplication::login(bool at_poweron) | 494 | void ServerApplication::login(bool at_poweron) |
495 | { | 495 | { |
496 | if ( !loggedin ) { | 496 | if ( !loggedin ) { |
497 | Global::terminateBuiltin("calibrate"); // No tr | 497 | Global::terminateBuiltin("calibrate"); // No tr |
498 | Password::authenticate(at_poweron); | 498 | Password::authenticate(at_poweron); |
499 | loggedin=1; | 499 | loggedin=1; |
500 | #ifndef QT_NO_COP | 500 | #ifndef QT_NO_COP |
501 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 501 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
502 | #endif | 502 | #endif |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | #if defined(QPE_HAVE_TOGGLELIGHT) | 506 | #if defined(QPE_HAVE_TOGGLELIGHT) |
507 | #include <qtopia/config.h> | 507 | #include <qtopia/config.h> |
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp index f43a2a3..2731568 100644 --- a/core/launcher/shutdownimpl.cpp +++ b/core/launcher/shutdownimpl.cpp | |||
@@ -1,173 +1,173 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "shutdownimpl.h" | 21 | #include "shutdownimpl.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | 25 | ||
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qprogressbar.h> | 27 | #include <qprogressbar.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | 32 | ||
33 | 33 | ||
34 | static void changeButtonColor ( QPushButton *btn, const QColor &col ) | 34 | static void changeButtonColor ( QPushButton *btn, const QColor &col ) |
35 | { | 35 | { |
36 | QPalette pal = btn-> palette ( ); | 36 | QPalette pal = btn-> palette ( ); |
37 | 37 | ||
38 | pal. setColor ( QPalette::Active, QColorGroup::Button, col ); | 38 | pal. setColor ( QPalette::Active, QColorGroup::Button, col ); |
39 | pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); | 39 | pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); |
40 | pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); | 40 | pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); |
41 | 41 | ||
42 | btn-> setPalette ( pal ); | 42 | btn-> setPalette ( pal ); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) | 46 | ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) |
47 | : QWidget ( parent, name, fl ) | 47 | : QWidget ( parent, name, fl ) |
48 | { | 48 | { |
49 | setCaption ( tr( "Shutdown..." ) ); | 49 | setCaption ( tr( "Shutdown..." ) ); |
50 | 50 | ||
51 | QVBoxLayout *vbox = new QVBoxLayout ( this ); | 51 | QVBoxLayout *vbox = new QVBoxLayout ( this ); |
52 | vbox-> setSpacing ( 3 ); | 52 | vbox-> setSpacing ( 3 ); |
53 | vbox-> setMargin ( 6 ); | 53 | vbox-> setMargin ( 6 ); |
54 | 54 | ||
55 | QButtonGroup *btngrp = new QButtonGroup ( this ); | 55 | QButtonGroup *btngrp = new QButtonGroup ( this ); |
56 | 56 | ||
57 | btngrp-> setTitle ( tr( "Terminate" ) ); | 57 | btngrp-> setTitle ( tr( "Terminate" ) ); |
58 | btngrp-> setColumnLayout ( 0, Qt::Vertical ); | 58 | btngrp-> setColumnLayout ( 0, Qt::Vertical ); |
59 | btngrp-> layout ( ) -> setSpacing ( 0 ); | 59 | btngrp-> layout ( ) -> setSpacing ( 0 ); |
60 | btngrp-> layout ( ) -> setMargin ( 0 ); | 60 | btngrp-> layout ( ) -> setMargin ( 0 ); |
61 | 61 | ||
62 | QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) ); | 62 | QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) ); |
63 | grid-> setAlignment ( Qt::AlignTop ); | 63 | grid-> setAlignment ( Qt::AlignTop ); |
64 | grid-> setSpacing ( 3 ); | 64 | grid-> setSpacing ( 3 ); |
65 | grid-> setMargin ( 7 ); | 65 | grid-> setMargin ( 7 ); |
66 | 66 | ||
67 | QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" ); | 67 | QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" ); |
68 | changeButtonColor ( quit, QColor ( 236, 236, 179 ) ); | 68 | changeButtonColor ( quit, QColor ( 236, 236, 179 ) ); |
69 | btngrp-> insert ( quit, 4 ); | 69 | btngrp-> insert ( quit, 4 ); |
70 | grid-> addWidget ( quit, 1, 1 ); | 70 | grid-> addWidget ( quit, 1, 1 ); |
71 | 71 | ||
72 | QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" ); | 72 | QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" ); |
73 | changeButtonColor ( reboot, QColor( 236, 183, 181 ) ); | 73 | changeButtonColor ( reboot, QColor( 236, 183, 181 ) ); |
74 | btngrp-> insert ( reboot, 2 ); | 74 | btngrp-> insert ( reboot, 2 ); |
75 | grid-> addWidget( reboot, 1, 0 ); | 75 | grid-> addWidget( reboot, 1, 0 ); |
76 | 76 | ||
77 | QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" ); | 77 | QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" ); |
78 | changeButtonColor ( restart, QColor( 236, 236, 179 ) ); | 78 | changeButtonColor ( restart, QColor( 236, 236, 179 ) ); |
79 | btngrp-> insert ( restart, 3 ); | 79 | btngrp-> insert ( restart, 3 ); |
80 | grid-> addWidget ( restart, 0, 1 ); | 80 | grid-> addWidget ( restart, 0, 1 ); |
81 | 81 | ||
82 | QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" ); | 82 | QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" ); |
83 | changeButtonColor ( shutdown, QColor( 236, 183, 181 ) ); | 83 | changeButtonColor ( shutdown, QColor( 236, 183, 181 ) ); |
84 | btngrp-> insert ( shutdown, 1 ); | 84 | btngrp-> insert ( shutdown, 1 ); |
85 | grid-> addWidget ( shutdown, 0, 0 ); | 85 | grid-> addWidget ( shutdown, 0, 0 ); |
86 | 86 | ||
87 | vbox-> addWidget ( btngrp ); | 87 | vbox-> addWidget ( btngrp ); |
88 | 88 | ||
89 | m_info = new QLabel ( this, "info" ); | 89 | m_info = new QLabel ( this, "info" ); |
90 | m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) ); | 90 | m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) ); |
91 | vbox-> addWidget ( m_info ); | 91 | vbox-> addWidget ( m_info ); |
92 | 92 | ||
93 | m_progress = new QProgressBar ( this, "progressBar" ); | 93 | m_progress = new QProgressBar ( this, "progressBar" ); |
94 | m_progress-> setFrameShape ( QProgressBar::Panel ); | 94 | m_progress-> setFrameShape ( QProgressBar::Panel ); |
95 | m_progress-> setFrameShadow ( QProgressBar::Sunken ); | 95 | m_progress-> setFrameShadow ( QProgressBar::Sunken ); |
96 | m_progress-> setTotalSteps ( 20 ); | 96 | m_progress-> setTotalSteps ( 20 ); |
97 | m_progress-> setIndicatorFollowsStyle ( false ); | 97 | m_progress-> setIndicatorFollowsStyle ( false ); |
98 | vbox-> addWidget ( m_progress ); | 98 | vbox-> addWidget ( m_progress ); |
99 | 99 | ||
100 | vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 100 | vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
101 | 101 | ||
102 | QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); | 102 | QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); |
103 | changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); | 103 | changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); |
104 | cancel-> setDefault ( true ); | 104 | cancel-> setDefault ( true ); |
105 | cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); | 105 | cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); |
106 | vbox-> addWidget ( cancel ); | 106 | vbox-> addWidget ( cancel ); |
107 | 107 | ||
108 | m_timer = new QTimer ( this ); | 108 | m_timer = new QTimer ( this ); |
109 | connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) ); | 109 | connect ( m_timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); |
110 | 110 | ||
111 | connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) ); | 111 | connect ( btngrp, SIGNAL( clicked(int) ), this, SLOT( buttonClicked(int) ) ); |
112 | connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) ); | 112 | connect ( cancel, SIGNAL( clicked() ), this, SLOT( cancelClicked() ) ); |
113 | 113 | ||
114 | m_progress-> hide ( ); | 114 | m_progress-> hide ( ); |
115 | Global::hideInputMethod ( ); | 115 | Global::hideInputMethod ( ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void ShutdownImpl::buttonClicked ( int b ) | 118 | void ShutdownImpl::buttonClicked ( int b ) |
119 | { | 119 | { |
120 | m_counter = 0; | 120 | m_counter = 0; |
121 | 121 | ||
122 | switch ( b ) { | 122 | switch ( b ) { |
123 | case 1: | 123 | case 1: |
124 | m_operation = ShutdownSystem; | 124 | m_operation = ShutdownSystem; |
125 | break; | 125 | break; |
126 | case 2: | 126 | case 2: |
127 | m_operation = RebootSystem; | 127 | m_operation = RebootSystem; |
128 | break; | 128 | break; |
129 | case 3: | 129 | case 3: |
130 | m_operation = RestartDesktop; | 130 | m_operation = RestartDesktop; |
131 | break; | 131 | break; |
132 | case 4: | 132 | case 4: |
133 | m_operation = TerminateDesktop; | 133 | m_operation = TerminateDesktop; |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | m_info-> hide ( ); | 136 | m_info-> hide ( ); |
137 | m_progress-> show ( ); | 137 | m_progress-> show ( ); |
138 | m_timer-> start ( 300 ); | 138 | m_timer-> start ( 300 ); |
139 | timeout ( ); | 139 | timeout ( ); |
140 | } | 140 | } |
141 | 141 | ||
142 | void ShutdownImpl::cancelClicked ( ) | 142 | void ShutdownImpl::cancelClicked ( ) |
143 | { | 143 | { |
144 | m_progress-> hide ( ); | 144 | m_progress-> hide ( ); |
145 | m_info-> show ( ); | 145 | m_info-> show ( ); |
146 | if ( m_timer-> isActive ( ) ) | 146 | if ( m_timer-> isActive ( ) ) |
147 | m_timer-> stop ( ); | 147 | m_timer-> stop ( ); |
148 | else | 148 | else |
149 | close ( ); | 149 | close ( ); |
150 | } | 150 | } |
151 | 151 | ||
152 | void ShutdownImpl::timeout ( ) | 152 | void ShutdownImpl::timeout ( ) |
153 | { | 153 | { |
154 | if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) { | 154 | if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) { |
155 | m_progress-> hide ( ); | 155 | m_progress-> hide ( ); |
156 | m_timer-> stop ( ); | 156 | m_timer-> stop ( ); |
157 | emit shutdown ( m_operation ); | 157 | emit shutdown ( m_operation ); |
158 | } | 158 | } |
159 | else | 159 | else |
160 | m_progress-> setProgress ( m_counter ); | 160 | m_progress-> setProgress ( m_counter ); |
161 | } | 161 | } |
162 | 162 | ||
163 | void ShutdownImpl::hide ( ) | 163 | void ShutdownImpl::hide ( ) |
164 | { | 164 | { |
165 | if ( isVisible ( )) { | 165 | if ( isVisible ( )) { |
166 | // hack - shutdown is a launcher dialog, but treated like a standalone app | 166 | // hack - shutdown is a launcher dialog, but treated like a standalone app |
167 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 167 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
168 | e << QString ( "shutdown" ); | 168 | e << QString ( "shutdown" ); |
169 | 169 | ||
170 | } | 170 | } |
171 | QWidget::hide ( ); | 171 | QWidget::hide ( ); |
172 | } | 172 | } |
173 | 173 | ||
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index 491a8a3..91e2f20 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp | |||
@@ -24,354 +24,354 @@ | |||
24 | #include "systray.h" | 24 | #include "systray.h" |
25 | #include "wait.h" | 25 | #include "wait.h" |
26 | #include "appicons.h" | 26 | #include "appicons.h" |
27 | 27 | ||
28 | #include "taskbar.h" | 28 | #include "taskbar.h" |
29 | #include "server.h" | 29 | #include "server.h" |
30 | 30 | ||
31 | #include <qtopia/config.h> | 31 | #include <qtopia/config.h> |
32 | #include <qtopia/qpeapplication.h> | 32 | #include <qtopia/qpeapplication.h> |
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | #include <qtopia/qcopenvelope_qws.h> | 34 | #include <qtopia/qcopenvelope_qws.h> |
35 | #endif | 35 | #endif |
36 | #include <qtopia/global.h> | 36 | #include <qtopia/global.h> |
37 | //#include <qtopia/custom.h> | 37 | //#include <qtopia/custom.h> |
38 | 38 | ||
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qtimer.h> | 41 | #include <qtimer.h> |
42 | #ifdef QWS | 42 | #ifdef QWS |
43 | #include <qwindowsystem_qws.h> | 43 | #include <qwindowsystem_qws.h> |
44 | #endif | 44 | #endif |
45 | #include <qwidgetstack.h> | 45 | #include <qwidgetstack.h> |
46 | 46 | ||
47 | #if defined( Q_WS_QWS ) | 47 | #if defined( Q_WS_QWS ) |
48 | #include <qwsdisplay_qws.h> | 48 | #include <qwsdisplay_qws.h> |
49 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | 52 | ||
53 | static bool initNumLock() | 53 | static bool initNumLock() |
54 | { | 54 | { |
55 | #ifdef QPE_INITIAL_NUMLOCK_STATE | 55 | #ifdef QPE_INITIAL_NUMLOCK_STATE |
56 | QPE_INITIAL_NUMLOCK_STATE | 56 | QPE_INITIAL_NUMLOCK_STATE |
57 | #endif | 57 | #endif |
58 | return FALSE; | 58 | return FALSE; |
59 | } | 59 | } |
60 | 60 | ||
61 | //--------------------------------------------------------------------------- | 61 | //--------------------------------------------------------------------------- |
62 | 62 | ||
63 | class SafeMode : public QWidget | 63 | class SafeMode : public QWidget |
64 | { | 64 | { |
65 | Q_OBJECT | 65 | Q_OBJECT |
66 | public: | 66 | public: |
67 | SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) | 67 | SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) |
68 | { | 68 | { |
69 | message = tr("Safe Mode"); | 69 | message = tr("Safe Mode"); |
70 | QFont f( font() ); | 70 | QFont f( font() ); |
71 | f.setWeight( QFont::Bold ); | 71 | f.setWeight( QFont::Bold ); |
72 | setFont( f ); | 72 | setFont( f ); |
73 | } | 73 | } |
74 | 74 | ||
75 | void mousePressEvent( QMouseEvent *); | 75 | void mousePressEvent( QMouseEvent *); |
76 | QSize sizeHint() const; | 76 | QSize sizeHint() const; |
77 | void paintEvent( QPaintEvent* ); | 77 | void paintEvent( QPaintEvent* ); |
78 | 78 | ||
79 | private slots: | 79 | private slots: |
80 | void action(int i); | 80 | void action(int i); |
81 | 81 | ||
82 | private: | 82 | private: |
83 | QString message; | 83 | QString message; |
84 | QPopupMenu *menu; | 84 | QPopupMenu *menu; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | void SafeMode::mousePressEvent( QMouseEvent *) | 87 | void SafeMode::mousePressEvent( QMouseEvent *) |
88 | { | 88 | { |
89 | if ( !menu ) { | 89 | if ( !menu ) { |
90 | menu = new QPopupMenu(this); | 90 | menu = new QPopupMenu(this); |
91 | menu->insertItem( tr("Plugin Manager..."), 0 ); | 91 | menu->insertItem( tr("Plugin Manager..."), 0 ); |
92 | menu->insertItem( tr("Restart Qtopia"), 1 ); | 92 | menu->insertItem( tr("Restart Qtopia"), 1 ); |
93 | menu->insertItem( tr("Help..."), 2 ); | 93 | menu->insertItem( tr("Help..."), 2 ); |
94 | connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); | 94 | connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); |
95 | } | 95 | } |
96 | QPoint curPos = mapToGlobal( QPoint(0,0) ); | 96 | QPoint curPos = mapToGlobal( QPoint(0,0) ); |
97 | QSize sh = menu->sizeHint(); | 97 | QSize sh = menu->sizeHint(); |
98 | menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); | 98 | menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void SafeMode::action(int i) | 101 | void SafeMode::action(int i) |
102 | { | 102 | { |
103 | switch (i) { | 103 | switch (i) { |
104 | case 0: | 104 | case 0: |
105 | Global::execute( "pluginmanager" ); | 105 | Global::execute( "pluginmanager" ); |
106 | break; | 106 | break; |
107 | case 1: | 107 | case 1: |
108 | Global::restart(); | 108 | Global::restart(); |
109 | break; | 109 | break; |
110 | case 2: | 110 | case 2: |
111 | Global::execute( "helpbrowser", "safemode.html" ); | 111 | Global::execute( "helpbrowser", "safemode.html" ); |
112 | break; | 112 | break; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | QSize SafeMode::sizeHint() const | 116 | QSize SafeMode::sizeHint() const |
117 | { | 117 | { |
118 | QFontMetrics fm = fontMetrics(); | 118 | QFontMetrics fm = fontMetrics(); |
119 | 119 | ||
120 | return QSize( fm.width(message), fm.height() ); | 120 | return QSize( fm.width(message), fm.height() ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void SafeMode::paintEvent( QPaintEvent* ) | 123 | void SafeMode::paintEvent( QPaintEvent* ) |
124 | { | 124 | { |
125 | QPainter p(this); | 125 | QPainter p(this); |
126 | p.drawText( rect(), AlignCenter, message ); | 126 | p.drawText( rect(), AlignCenter, message ); |
127 | } | 127 | } |
128 | 128 | ||
129 | //--------------------------------------------------------------------------- | 129 | //--------------------------------------------------------------------------- |
130 | 130 | ||
131 | class LockKeyState : public QWidget | 131 | class LockKeyState : public QWidget |
132 | { | 132 | { |
133 | public: | 133 | public: |
134 | LockKeyState( QWidget *parent ) : | 134 | LockKeyState( QWidget *parent ) : |
135 | QWidget(parent), | 135 | QWidget(parent), |
136 | nl(initNumLock()), cl(FALSE) | 136 | nl(initNumLock()), cl(FALSE) |
137 | { | 137 | { |
138 | nl_pm = Resource::loadPixmap("numlock"); | 138 | nl_pm = Resource::loadPixmap("numlock"); |
139 | cl_pm = Resource::loadPixmap("capslock"); | 139 | cl_pm = Resource::loadPixmap("capslock"); |
140 | } | 140 | } |
141 | QSize sizeHint() const | 141 | QSize sizeHint() const |
142 | { | 142 | { |
143 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); | 143 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); |
144 | } | 144 | } |
145 | void toggleNumLockState() | 145 | void toggleNumLockState() |
146 | { | 146 | { |
147 | nl = !nl; repaint(); | 147 | nl = !nl; repaint(); |
148 | } | 148 | } |
149 | void toggleCapsLockState() | 149 | void toggleCapsLockState() |
150 | { | 150 | { |
151 | cl = !cl; repaint(); | 151 | cl = !cl; repaint(); |
152 | } | 152 | } |
153 | void paintEvent( QPaintEvent * ) | 153 | void paintEvent( QPaintEvent * ) |
154 | { | 154 | { |
155 | int y = (height()-sizeHint().height())/2; | 155 | int y = (height()-sizeHint().height())/2; |
156 | QPainter p(this); | 156 | QPainter p(this); |
157 | if ( nl ) | 157 | if ( nl ) |
158 | p.drawPixmap(1,y,nl_pm); | 158 | p.drawPixmap(1,y,nl_pm); |
159 | if ( cl ) | 159 | if ( cl ) |
160 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); | 160 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); |
161 | } | 161 | } |
162 | private: | 162 | private: |
163 | QPixmap nl_pm, cl_pm; | 163 | QPixmap nl_pm, cl_pm; |
164 | bool nl, cl; | 164 | bool nl, cl; |
165 | }; | 165 | }; |
166 | 166 | ||
167 | //--------------------------------------------------------------------------- | 167 | //--------------------------------------------------------------------------- |
168 | 168 | ||
169 | TaskBar::~TaskBar() | 169 | TaskBar::~TaskBar() |
170 | { | 170 | { |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) | 174 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) |
175 | { | 175 | { |
176 | Config cfg( "Launcher" ); | 176 | Config cfg( "Launcher" ); |
177 | cfg.setGroup( "InputMethods" ); | 177 | cfg.setGroup( "InputMethods" ); |
178 | resizeRunningApp = cfg.readBoolEntry( "Resize", true ); | 178 | resizeRunningApp = cfg.readBoolEntry( "Resize", true ); |
179 | 179 | ||
180 | sm = new StartMenu( this ); | 180 | sm = new StartMenu( this ); |
181 | connect( sm, SIGNAL(tabSelected(const QString&)), this, | 181 | connect( sm, SIGNAL(tabSelected(const QString&)), this, |
182 | SIGNAL(tabSelected(const QString&)) ); | 182 | SIGNAL(tabSelected(const QString&)) ); |
183 | 183 | ||
184 | inputMethods = new InputMethods( this ); | 184 | inputMethods = new InputMethods( this ); |
185 | connect( inputMethods, SIGNAL(inputToggled(bool)), | 185 | connect( inputMethods, SIGNAL(inputToggled(bool)), |
186 | this, SLOT(calcMaxWindowRect()) ); | 186 | this, SLOT(calcMaxWindowRect()) ); |
187 | 187 | ||
188 | stack = new QWidgetStack( this ); | 188 | stack = new QWidgetStack( this ); |
189 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 189 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
190 | label = new QLabel(stack); | 190 | label = new QLabel(stack); |
191 | 191 | ||
192 | runningAppBar = new RunningAppBar(stack); | 192 | runningAppBar = new RunningAppBar(stack); |
193 | stack->raiseWidget(runningAppBar); | 193 | stack->raiseWidget(runningAppBar); |
194 | 194 | ||
195 | waitIcon = new Wait( this ); | 195 | waitIcon = new Wait( this ); |
196 | (void) new AppIcons( this ); | 196 | (void) new AppIcons( this ); |
197 | 197 | ||
198 | sysTray = new SysTray( this ); | 198 | sysTray = new SysTray( this ); |
199 | 199 | ||
200 | /* ### FIXME plugin loader and safe mode */ | 200 | /* ### FIXME plugin loader and safe mode */ |
201 | #if 0 | 201 | #if 0 |
202 | if (PluginLoader::inSafeMode()) | 202 | if (PluginLoader::inSafeMode()) |
203 | (void)new SafeMode( this ); | 203 | (void)new SafeMode( this ); |
204 | #endif | 204 | #endif |
205 | 205 | ||
206 | // ## make customizable in some way? | 206 | // ## make customizable in some way? |
207 | #ifdef QT_QWS_CUSTOM | 207 | #ifdef QT_QWS_CUSTOM |
208 | lockState = new LockKeyState( this ); | 208 | lockState = new LockKeyState( this ); |
209 | #else | 209 | #else |
210 | lockState = 0; | 210 | lockState = 0; |
211 | #endif | 211 | #endif |
212 | 212 | ||
213 | #if defined(Q_WS_QWS) | 213 | #if defined(Q_WS_QWS) |
214 | #if !defined(QT_NO_COP) | 214 | #if !defined(QT_NO_COP) |
215 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); | 215 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); |
216 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 216 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
217 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 217 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
218 | #endif | 218 | #endif |
219 | #endif | 219 | #endif |
220 | waitTimer = new QTimer( this ); | 220 | waitTimer = new QTimer( this ); |
221 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); | 221 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); |
222 | clearer = new QTimer( this ); | 222 | clearer = new QTimer( this ); |
223 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); | 223 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); |
224 | 224 | ||
225 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); | 225 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); |
226 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); | 226 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); |
227 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); | 227 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); |
228 | } | 228 | } |
229 | 229 | ||
230 | void TaskBar::setStatusMessage( const QString &text ) | 230 | void TaskBar::setStatusMessage( const QString &text ) |
231 | { | 231 | { |
232 | if ( !text.isEmpty() ) { | 232 | if ( !text.isEmpty() ) { |
233 | label->setText( text ); | 233 | label->setText( text ); |
234 | stack->raiseWidget( label ); | 234 | stack->raiseWidget( label ); |
235 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) | 235 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) |
236 | sysTray->hide(); | 236 | sysTray->hide(); |
237 | clearer->start( 3000, TRUE ); | 237 | clearer->start( 3000, TRUE ); |
238 | } else { | 238 | } else { |
239 | clearStatusBar(); | 239 | clearStatusBar(); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | void TaskBar::clearStatusBar() | 243 | void TaskBar::clearStatusBar() |
244 | { | 244 | { |
245 | label->clear(); | 245 | label->clear(); |
246 | stack->raiseWidget(runningAppBar); | 246 | stack->raiseWidget(runningAppBar); |
247 | if ( sysTray ) | 247 | if ( sysTray ) |
248 | sysTray->show(); | 248 | sysTray->show(); |
249 | // stack->raiseWidget( mru ); | 249 | // stack->raiseWidget( mru ); |
250 | } | 250 | } |
251 | 251 | ||
252 | void TaskBar::startWait() | 252 | void TaskBar::startWait() |
253 | { | 253 | { |
254 | waitIcon->setWaiting( true ); | 254 | waitIcon->setWaiting( true ); |
255 | // a catchall stop after 10 seconds... | 255 | // a catchall stop after 10 seconds... |
256 | waitTimer->start( 10 * 1000, true ); | 256 | waitTimer->start( 10 * 1000, true ); |
257 | } | 257 | } |
258 | 258 | ||
259 | void TaskBar::stopWait(const QString&) | 259 | void TaskBar::stopWait(const QString&) |
260 | { | 260 | { |
261 | waitTimer->stop(); | 261 | waitTimer->stop(); |
262 | waitIcon->setWaiting( false ); | 262 | waitIcon->setWaiting( false ); |
263 | } | 263 | } |
264 | 264 | ||
265 | void TaskBar::stopWait() | 265 | void TaskBar::stopWait() |
266 | { | 266 | { |
267 | waitTimer->stop(); | 267 | waitTimer->stop(); |
268 | waitIcon->setWaiting( false ); | 268 | waitIcon->setWaiting( false ); |
269 | } | 269 | } |
270 | 270 | ||
271 | /* | 271 | /* |
272 | * This resizeEvent will be captured by | 272 | * This resizeEvent will be captured by |
273 | * the ServerInterface and it'll layout | 273 | * the ServerInterface and it'll layout |
274 | * and calc rect. Now if we go from bigger | 274 | * and calc rect. Now if we go from bigger |
275 | * to smaller screen the SysTray is out of | 275 | * to smaller screen the SysTray is out of |
276 | * bounds and repaint() won't trigger an Event | 276 | * bounds and repaint() won't trigger an Event |
277 | */ | 277 | */ |
278 | void TaskBar::resizeEvent( QResizeEvent *e ) | 278 | void TaskBar::resizeEvent( QResizeEvent *e ) |
279 | { | 279 | { |
280 | if ( sysTray ) | 280 | if ( sysTray ) |
281 | sysTray->hide(); | 281 | sysTray->hide(); |
282 | 282 | ||
283 | QHBox::resizeEvent( e ); | 283 | QHBox::resizeEvent( e ); |
284 | 284 | ||
285 | if ( sysTray ) | 285 | if ( sysTray ) |
286 | sysTray->show(); | 286 | sysTray->show(); |
287 | 287 | ||
288 | qWarning("TaskBar::resize event"); | 288 | qWarning("TaskBar::resize event"); |
289 | } | 289 | } |
290 | 290 | ||
291 | void TaskBar::styleChange( QStyle &s ) | 291 | void TaskBar::styleChange( QStyle &s ) |
292 | { | 292 | { |
293 | QHBox::styleChange( s ); | 293 | QHBox::styleChange( s ); |
294 | calcMaxWindowRect(); | 294 | calcMaxWindowRect(); |
295 | } | 295 | } |
296 | 296 | ||
297 | void TaskBar::calcMaxWindowRect() | 297 | void TaskBar::calcMaxWindowRect() |
298 | { | 298 | { |
299 | if ( resizeRunningApp ) | 299 | if ( resizeRunningApp ) |
300 | { | 300 | { |
301 | #if defined(Q_WS_QWS) | 301 | #if defined(Q_WS_QWS) |
302 | QRect wr; | 302 | QRect wr; |
303 | int displayWidth = qApp->desktop()->width(); | 303 | int displayWidth = qApp->desktop()->width(); |
304 | QRect ir = inputMethods->inputRect(); | 304 | QRect ir = inputMethods->inputRect(); |
305 | if ( ir.isValid() ) { | 305 | if ( ir.isValid() ) { |
306 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 306 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
307 | } else { | 307 | } else { |
308 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); | 308 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); |
309 | } | 309 | } |
310 | #if QT_VERSION < 0x030000 | 310 | #if QT_VERSION < 0x030000 |
311 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) ); | 311 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) ); |
312 | #else | 312 | #else |
313 | QWSServer::setMaxWindowRect( wr ); | 313 | QWSServer::setMaxWindowRect( wr ); |
314 | #endif | 314 | #endif |
315 | #endif | 315 | #endif |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) | 319 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) |
320 | { | 320 | { |
321 | QDataStream stream( data, IO_ReadOnly ); | 321 | QDataStream stream( data, IO_ReadOnly ); |
322 | if ( msg == "message(QString)" ) { | 322 | if ( msg == "message(QString)" ) { |
323 | QString text; | 323 | QString text; |
324 | stream >> text; | 324 | stream >> text; |
325 | setStatusMessage( text ); | 325 | setStatusMessage( text ); |
326 | } else if ( msg == "hideInputMethod()" ) { | 326 | } else if ( msg == "hideInputMethod()" ) { |
327 | inputMethods->hideInputMethod(); | 327 | inputMethods->hideInputMethod(); |
328 | } else if ( msg == "showInputMethod()" ) { | 328 | } else if ( msg == "showInputMethod()" ) { |
329 | inputMethods->showInputMethod(); | 329 | inputMethods->showInputMethod(); |
330 | } else if ( msg == "showInputMethod(QString)" ) { | 330 | } else if ( msg == "showInputMethod(QString)" ) { |
331 | QString name; | 331 | QString name; |
332 | stream >> name; | 332 | stream >> name; |
333 | inputMethods->showInputMethod(name); | 333 | inputMethods->showInputMethod(name); |
334 | } else if ( msg == "reloadInputMethods()" ) { | 334 | } else if ( msg == "reloadInputMethods()" ) { |
335 | inputMethods->loadInputMethods(); | 335 | inputMethods->loadInputMethods(); |
336 | } else if ( msg == "reloadApplets()" ) { | 336 | } else if ( msg == "reloadApplets()" ) { |
337 | sysTray->clearApplets(); | 337 | sysTray->clearApplets(); |
338 | sm->createMenu(); | 338 | sm->createMenu(); |
339 | sysTray->addApplets(); | 339 | sysTray->addApplets(); |
340 | }else if ( msg == "toggleMenu()" ) { | 340 | }else if ( msg == "toggleMenu()" ) { |
341 | if ( sm-> launchMenu-> isVisible() ) | 341 | if ( sm-> launchMenu-> isVisible() ) |
342 | sm-> launch(); | 342 | sm-> launch(); |
343 | else | 343 | else |
344 | QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" ); | 344 | QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" ); |
345 | }else if ( msg == "toggleStartMenu()" ) | 345 | }else if ( msg == "toggleStartMenu()" ) |
346 | sm->launch(); | 346 | sm->launch(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) | 349 | void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) |
350 | { | 350 | { |
351 | if ( state == ServerInterface::Launching ) | 351 | if ( state == ServerInterface::Launching ) |
352 | runningAppBar->applicationLaunched( name ); | 352 | runningAppBar->applicationLaunched( name ); |
353 | else if ( state == ServerInterface::Terminated ) | 353 | else if ( state == ServerInterface::Terminated ) |
354 | runningAppBar->applicationTerminated( name ); | 354 | runningAppBar->applicationTerminated( name ); |
355 | } | 355 | } |
356 | 356 | ||
357 | void TaskBar::toggleNumLockState() | 357 | void TaskBar::toggleNumLockState() |
358 | { | 358 | { |
359 | if ( lockState ) lockState->toggleNumLockState(); | 359 | if ( lockState ) lockState->toggleNumLockState(); |
360 | } | 360 | } |
361 | 361 | ||
362 | void TaskBar::toggleCapsLockState() | 362 | void TaskBar::toggleCapsLockState() |
363 | { | 363 | { |
364 | if ( lockState ) lockState->toggleCapsLockState(); | 364 | if ( lockState ) lockState->toggleCapsLockState(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void TaskBar::toggleSymbolInput() | 367 | void TaskBar::toggleSymbolInput() |
368 | { | 368 | { |
369 | QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); | 369 | QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); |
370 | if ( inputMethods->currentShown() == unicodeInput ) { | 370 | if ( inputMethods->currentShown() == unicodeInput ) { |
371 | inputMethods->hideInputMethod(); | 371 | inputMethods->hideInputMethod(); |
372 | } else { | 372 | } else { |
373 | inputMethods->showInputMethod( unicodeInput ); | 373 | inputMethods->showInputMethod( unicodeInput ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | 376 | ||
377 | #include "taskbar.moc" | 377 | #include "taskbar.moc" |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index b998e95..a5e20b2 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -1,540 +1,540 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | //#define _XOPEN_SOURCE | 20 | //#define _XOPEN_SOURCE |
21 | 21 | ||
22 | #include <opie2/oglobal.h> | 22 | #include <opie2/oglobal.h> |
23 | 23 | ||
24 | #ifndef Q_OS_WIN32 | 24 | #ifndef Q_OS_WIN32 |
25 | #include <pwd.h> | 25 | #include <pwd.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <time.h> | 29 | #include <time.h> |
30 | 30 | ||
31 | #ifndef Q_OS_MACX | 31 | #ifndef Q_OS_MACX |
32 | #include <shadow.h> | 32 | #include <shadow.h> |
33 | #include <crypt.h> | 33 | #include <crypt.h> |
34 | #endif /* Q_OS_MACX */ | 34 | #endif /* Q_OS_MACX */ |
35 | 35 | ||
36 | #else | 36 | #else |
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | #include <time.h> | 38 | #include <time.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | 41 | ||
42 | #if defined(_OS_LINUX_) | 42 | #if defined(_OS_LINUX_) |
43 | #include <shadow.h> | 43 | #include <shadow.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include <qtextstream.h> | 46 | #include <qtextstream.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | //#include <qtopia/qcopchannel_qws.h> | 48 | //#include <qtopia/qcopchannel_qws.h> |
49 | #include <qtopia/process.h> | 49 | #include <qtopia/process.h> |
50 | #include <qtopia/private/contact.h> | 50 | #include <qtopia/private/contact.h> |
51 | #include <qtopia/version.h> | 51 | #include <qtopia/version.h> |
52 | #ifdef Q_WS_QWS | 52 | #ifdef Q_WS_QWS |
53 | #include <qtopia/qcopenvelope_qws.h> | 53 | #include <qtopia/qcopenvelope_qws.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | 56 | ||
57 | #include "transferserver.h" | 57 | #include "transferserver.h" |
58 | #include <qtopia/qprocess.h> | 58 | #include <qtopia/qprocess.h> |
59 | 59 | ||
60 | const int block_size = 51200; | 60 | const int block_size = 51200; |
61 | 61 | ||
62 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, | 62 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, |
63 | const char* name) | 63 | const char* name) |
64 | : QServerSocket( port, 1, parent, name ) | 64 | : QServerSocket( port, 1, parent, name ) |
65 | { | 65 | { |
66 | connections.setAutoDelete( TRUE ); | 66 | connections.setAutoDelete( TRUE ); |
67 | if ( !ok() ) | 67 | if ( !ok() ) |
68 | qWarning( "Failed to bind to port %d", port ); | 68 | qWarning( "Failed to bind to port %d", port ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void TransferServer::authorizeConnections() | 71 | void TransferServer::authorizeConnections() |
72 | { | 72 | { |
73 | QListIterator<ServerPI> it(connections); | 73 | QListIterator<ServerPI> it(connections); |
74 | while ( it.current() ) { | 74 | while ( it.current() ) { |
75 | if ( !it.current()->verifyAuthorised() ) { | 75 | if ( !it.current()->verifyAuthorised() ) { |
76 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); | 76 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
77 | connections.removeRef( it.current() ); | 77 | connections.removeRef( it.current() ); |
78 | } else | 78 | } else |
79 | ++it; | 79 | ++it; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | void TransferServer::closed(ServerPI *item) | 83 | void TransferServer::closed(ServerPI *item) |
84 | { | 84 | { |
85 | connections.removeRef(item); | 85 | connections.removeRef(item); |
86 | } | 86 | } |
87 | 87 | ||
88 | TransferServer::~TransferServer() | 88 | TransferServer::~TransferServer() |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | void TransferServer::newConnection( int socket ) | 92 | void TransferServer::newConnection( int socket ) |
93 | { | 93 | { |
94 | ServerPI *ptr = new ServerPI( socket, this ); | 94 | ServerPI *ptr = new ServerPI( socket, this ); |
95 | connect( ptr, SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); | 95 | connect( ptr, SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
96 | connections.append( ptr ); | 96 | connections.append( ptr ); |
97 | } | 97 | } |
98 | 98 | ||
99 | QString SyncAuthentication::serverId() | 99 | QString SyncAuthentication::serverId() |
100 | { | 100 | { |
101 | Config cfg("Security"); | 101 | Config cfg("Security"); |
102 | cfg.setGroup("Sync"); | 102 | cfg.setGroup("Sync"); |
103 | QString r = cfg.readEntry("serverid"); | 103 | QString r = cfg.readEntry("serverid"); |
104 | 104 | ||
105 | if ( r.isEmpty() ) { | 105 | if ( r.isEmpty() ) { |
106 | r = OGlobal::generateUuid(); | 106 | r = OGlobal::generateUuid(); |
107 | cfg.writeEntry("serverid", r ); | 107 | cfg.writeEntry("serverid", r ); |
108 | } | 108 | } |
109 | return r; | 109 | return r; |
110 | } | 110 | } |
111 | 111 | ||
112 | QString SyncAuthentication::ownerName() | 112 | QString SyncAuthentication::ownerName() |
113 | { | 113 | { |
114 | QString vfilename = Global::applicationFileName("addressbook", | 114 | QString vfilename = Global::applicationFileName("addressbook", |
115 | "businesscard.vcf"); | 115 | "businesscard.vcf"); |
116 | if (QFile::exists(vfilename)) { | 116 | if (QFile::exists(vfilename)) { |
117 | Contact c; | 117 | Contact c; |
118 | c = Contact::readVCard( vfilename )[0]; | 118 | c = Contact::readVCard( vfilename )[0]; |
119 | return c.fullName(); | 119 | return c.fullName(); |
120 | } | 120 | } |
121 | 121 | ||
122 | return QString::null; | 122 | return QString::null; |
123 | } | 123 | } |
124 | 124 | ||
125 | QString SyncAuthentication::loginName() | 125 | QString SyncAuthentication::loginName() |
126 | { | 126 | { |
127 | struct passwd *pw = 0L; | 127 | struct passwd *pw = 0L; |
128 | #ifndef Q_OS_WIN32 | 128 | #ifndef Q_OS_WIN32 |
129 | pw = getpwuid( geteuid() ); | 129 | pw = getpwuid( geteuid() ); |
130 | return QString::fromLocal8Bit( pw->pw_name ); | 130 | return QString::fromLocal8Bit( pw->pw_name ); |
131 | #else | 131 | #else |
132 | //### revise | 132 | //### revise |
133 | return QString(); | 133 | return QString(); |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) | 137 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) |
138 | { | 138 | { |
139 | Config cfg("Security"); | 139 | Config cfg("Security"); |
140 | cfg.setGroup("Sync"); | 140 | cfg.setGroup("Sync"); |
141 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); | 141 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); |
142 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); | 142 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); |
143 | 143 | ||
144 | // QHostAddress allowed; | 144 | // QHostAddress allowed; |
145 | // allowed.setAddress(allowedstr); | 145 | // allowed.setAddress(allowedstr); |
146 | // uint auth_peer = allowed.ip4Addr(); | 146 | // uint auth_peer = allowed.ip4Addr(); |
147 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); | 147 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); |
148 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined | 148 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined |
149 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); | 149 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); |
150 | 150 | ||
151 | return (peeraddress.ip4Addr() & mask) == auth_peer; | 151 | return (peeraddress.ip4Addr() & mask) == auth_peer; |
152 | } | 152 | } |
153 | 153 | ||
154 | bool SyncAuthentication::checkUser( const QString& user ) | 154 | bool SyncAuthentication::checkUser( const QString& user ) |
155 | { | 155 | { |
156 | if ( user.isEmpty() ) return FALSE; | 156 | if ( user.isEmpty() ) return FALSE; |
157 | QString euser = loginName(); | 157 | QString euser = loginName(); |
158 | return user == euser; | 158 | return user == euser; |
159 | } | 159 | } |
160 | 160 | ||
161 | bool SyncAuthentication::checkPassword( const QString& password ) | 161 | bool SyncAuthentication::checkPassword( const QString& password ) |
162 | { | 162 | { |
163 | #ifdef ALLOW_UNIX_USER_FTP | 163 | #ifdef ALLOW_UNIX_USER_FTP |
164 | // First, check system password... | 164 | // First, check system password... |
165 | 165 | ||
166 | struct passwd *pw = 0; | 166 | struct passwd *pw = 0; |
167 | struct spwd *spw = 0; | 167 | struct spwd *spw = 0; |
168 | 168 | ||
169 | pw = getpwuid( geteuid() ); | 169 | pw = getpwuid( geteuid() ); |
170 | spw = getspnam( pw->pw_name ); | 170 | spw = getspnam( pw->pw_name ); |
171 | 171 | ||
172 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 172 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
173 | if ( cpwd == "x" && spw ) | 173 | if ( cpwd == "x" && spw ) |
174 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 174 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
175 | 175 | ||
176 | // Note: some systems use more than crypt for passwords. | 176 | // Note: some systems use more than crypt for passwords. |
177 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 177 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
178 | if ( cpwd == cpassword ) | 178 | if ( cpwd == cpassword ) |
179 | return TRUE; | 179 | return TRUE; |
180 | #endif | 180 | #endif |
181 | 181 | ||
182 | static int lastdenial=0; | 182 | static int lastdenial=0; |
183 | static int denials=0; | 183 | static int denials=0; |
184 | int now = time(0); | 184 | int now = time(0); |
185 | 185 | ||
186 | Config cfg("Security"); | 186 | Config cfg("Security"); |
187 | cfg.setGroup("SyncMode"); | 187 | cfg.setGroup("SyncMode"); |
188 | int mode = cfg.readNumEntry("Mode", 0x02 ); | 188 | int mode = cfg.readNumEntry("Mode", 0x02 ); |
189 | 189 | ||
190 | //No pass word needed if the user really needs it | 190 | //No pass word needed if the user really needs it |
191 | if (mode & 0x04) { | 191 | if (mode & 0x04) { |
192 | QMessageBox unauth( | 192 | QMessageBox unauth( |
193 | tr("Sync Connection"), | 193 | tr("Sync Connection"), |
194 | tr("<qt><p>An unauthorized system is requesting access to this device." | 194 | tr("<qt><p>An unauthorized system is requesting access to this device." |
195 | "<p>You chose IntelliSync so you may I allow or deny this connection.</qt>" ), | 195 | "<p>You chose IntelliSync so you may I allow or deny this connection.</qt>" ), |
196 | QMessageBox::Warning, | 196 | QMessageBox::Warning, |
197 | QMessageBox::Ok, QMessageBox::Cancel|QMessageBox::Default, QMessageBox::NoButton, | 197 | QMessageBox::Ok, QMessageBox::Cancel|QMessageBox::Default, QMessageBox::NoButton, |
198 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 198 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
199 | unauth.setButtonText(QMessageBox::Ok, tr("Allow" ) ); | 199 | unauth.setButtonText(QMessageBox::Ok, tr("Allow" ) ); |
200 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); | 200 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); |
201 | switch( unauth.exec() ) { | 201 | switch( unauth.exec() ) { |
202 | case QMessageBox::Ok: | 202 | case QMessageBox::Ok: |
203 | return TRUE; | 203 | return TRUE; |
204 | break; | 204 | break; |
205 | case QMessageBox::Cancel: | 205 | case QMessageBox::Cancel: |
206 | default: | 206 | default: |
207 | denials++; | 207 | denials++; |
208 | lastdenial=now; | 208 | lastdenial=now; |
209 | return FALSE; | 209 | return FALSE; |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | // Detect old Qtopia Desktop (no password) and fail | 213 | // Detect old Qtopia Desktop (no password) and fail |
214 | if ( password.isEmpty() ) { | 214 | if ( password.isEmpty() ) { |
215 | if ( denials < 3 || now > lastdenial+600 ) { | 215 | if ( denials < 3 || now > lastdenial+600 ) { |
216 | QMessageBox unauth( | 216 | QMessageBox unauth( |
217 | tr("Sync Connection"), | 217 | tr("Sync Connection"), |
218 | tr("<p>An unauthorized system is requesting access to this device." | 218 | tr("<p>An unauthorized system is requesting access to this device." |
219 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " | 219 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " |
220 | "please upgrade or change the security setting to use IntelliSync." ), | 220 | "please upgrade or change the security setting to use IntelliSync." ), |
221 | QMessageBox::Warning, | 221 | QMessageBox::Warning, |
222 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 222 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
223 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 223 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
224 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); | 224 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); |
225 | unauth.exec(); | 225 | unauth.exec(); |
226 | 226 | ||
227 | denials++; | 227 | denials++; |
228 | lastdenial=now; | 228 | lastdenial=now; |
229 | } | 229 | } |
230 | return FALSE; | 230 | return FALSE; |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | // Second, check sync password... | 234 | // Second, check sync password... |
235 | 235 | ||
236 | static int lock=0; | 236 | static int lock=0; |
237 | if ( lock ) return FALSE; | 237 | if ( lock ) return FALSE; |
238 | 238 | ||
239 | ++lock; | 239 | ++lock; |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * we need to support old Sync software and QtopiaDesktop | 242 | * we need to support old Sync software and QtopiaDesktop |
243 | */ | 243 | */ |
244 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { | 244 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { |
245 | Config cfg( "Security" ); | 245 | Config cfg( "Security" ); |
246 | cfg.setGroup("Sync"); | 246 | cfg.setGroup("Sync"); |
247 | QStringList pwds = cfg.readListEntry("Passwords",' '); | 247 | QStringList pwds = cfg.readListEntry("Passwords",' '); |
248 | for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { | 248 | for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { |
249 | #ifndef Q_OS_WIN32 | 249 | #ifndef Q_OS_WIN32 |
250 | QString cpassword = QString::fromLocal8Bit( | 250 | QString cpassword = QString::fromLocal8Bit( |
251 | crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); | 251 | crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); |
252 | #else | 252 | #else |
253 | // ### revise | 253 | // ### revise |
254 | QString cpassword(""); | 254 | QString cpassword(""); |
255 | #endif | 255 | #endif |
256 | if ( *it == cpassword ) { | 256 | if ( *it == cpassword ) { |
257 | lock--; | 257 | lock--; |
258 | return TRUE; | 258 | return TRUE; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | // Unrecognized system. Be careful... | 262 | // Unrecognized system. Be careful... |
263 | QMessageBox unrecbox( | 263 | QMessageBox unrecbox( |
264 | tr("Sync Connection"), | 264 | tr("Sync Connection"), |
265 | tr("<p>An unrecognized system is requesting access to this device." | 265 | tr("<p>An unrecognized system is requesting access to this device." |
266 | "<p>If you have just initiated a Sync for the first time, this is normal."), | 266 | "<p>If you have just initiated a Sync for the first time, this is normal."), |
267 | QMessageBox::Warning, | 267 | QMessageBox::Warning, |
268 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, | 268 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, |
269 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 269 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
270 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny")); | 270 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny")); |
271 | unrecbox.setButtonText(QMessageBox::Yes, tr("Allow")); | 271 | unrecbox.setButtonText(QMessageBox::Yes, tr("Allow")); |
272 | 272 | ||
273 | if ( (denials > 2 && now < lastdenial+600) | 273 | if ( (denials > 2 && now < lastdenial+600) |
274 | || unrecbox.exec() != QMessageBox::Yes) | 274 | || unrecbox.exec() != QMessageBox::Yes) |
275 | { | 275 | { |
276 | denials++; | 276 | denials++; |
277 | lastdenial=now; | 277 | lastdenial=now; |
278 | lock--; | 278 | lock--; |
279 | return FALSE; | 279 | return FALSE; |
280 | } else { | 280 | } else { |
281 | const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/."; | 281 | const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/."; |
282 | char salt[2]; | 282 | char salt[2]; |
283 | salt[0]= salty[rand() % (sizeof(salty)-1)]; | 283 | salt[0]= salty[rand() % (sizeof(salty)-1)]; |
284 | salt[1]= salty[rand() % (sizeof(salty)-1)]; | 284 | salt[1]= salty[rand() % (sizeof(salty)-1)]; |
285 | #ifndef Q_OS_WIN32 | 285 | #ifndef Q_OS_WIN32 |
286 | QString cpassword = QString::fromLocal8Bit( | 286 | QString cpassword = QString::fromLocal8Bit( |
287 | crypt( password.mid(8).local8Bit(), salt ) ); | 287 | crypt( password.mid(8).local8Bit(), salt ) ); |
288 | #else | 288 | #else |
289 | //### revise | 289 | //### revise |
290 | QString cpassword(""); | 290 | QString cpassword(""); |
291 | #endif | 291 | #endif |
292 | denials=0; | 292 | denials=0; |
293 | pwds.prepend(cpassword); | 293 | pwds.prepend(cpassword); |
294 | cfg.writeEntry("Passwords",pwds,' '); | 294 | cfg.writeEntry("Passwords",pwds,' '); |
295 | lock--; | 295 | lock--; |
296 | return TRUE; | 296 | return TRUE; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | lock--; | 299 | lock--; |
300 | 300 | ||
301 | return FALSE; | 301 | return FALSE; |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | ServerPI::ServerPI( int socket, QObject *parent, const char* name ) | 305 | ServerPI::ServerPI( int socket, QObject *parent, const char* name ) |
306 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ), | 306 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ), |
307 | storFileSize(-1) | 307 | storFileSize(-1) |
308 | { | 308 | { |
309 | state = Connected; | 309 | state = Connected; |
310 | 310 | ||
311 | setSocket( socket ); | 311 | setSocket( socket ); |
312 | 312 | ||
313 | peerport = peerPort(); | 313 | peerport = peerPort(); |
314 | peeraddress = peerAddress(); | 314 | peeraddress = peerAddress(); |
315 | 315 | ||
316 | #ifndef INSECURE | 316 | #ifndef INSECURE |
317 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { | 317 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { |
318 | state = Forbidden; | 318 | state = Forbidden; |
319 | startTimer( 0 ); | 319 | startTimer( 0 ); |
320 | } else | 320 | } else |
321 | #endif | 321 | #endif |
322 | { | 322 | { |
323 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 323 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
324 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 324 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
325 | 325 | ||
326 | passiv = FALSE; | 326 | passiv = FALSE; |
327 | for( int i = 0; i < 4; i++ ) | 327 | for( int i = 0; i < 4; i++ ) |
328 | wait[i] = FALSE; | 328 | wait[i] = FALSE; |
329 | 329 | ||
330 | send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr | 330 | send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr |
331 | state = Wait_USER; | 331 | state = Wait_USER; |
332 | 332 | ||
333 | dtp = new ServerDTP( this ); | 333 | dtp = new ServerDTP( this ); |
334 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); | 334 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); |
335 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); | 335 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); |
336 | connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); | 336 | connect( dtp, SIGNAL( error(int) ), SLOT( dtpError(int) ) ); |
337 | 337 | ||
338 | 338 | ||
339 | directory = QDir::currentDirPath(); | 339 | directory = QDir::currentDirPath(); |
340 | 340 | ||
341 | static int p = 1024; | 341 | static int p = 1024; |
342 | 342 | ||
343 | while ( !serversocket || !serversocket->ok() ) { | 343 | while ( !serversocket || !serversocket->ok() ) { |
344 | delete serversocket; | 344 | delete serversocket; |
345 | serversocket = new ServerSocket( ++p, this ); | 345 | serversocket = new ServerSocket( ++p, this ); |
346 | } | 346 | } |
347 | connect( serversocket, SIGNAL( newIncomming( int ) ), | 347 | connect( serversocket, SIGNAL( newIncomming(int) ), |
348 | SLOT( newConnection( int ) ) ); | 348 | SLOT( newConnection(int) ) ); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | ServerPI::~ServerPI() | 352 | ServerPI::~ServerPI() |
353 | { | 353 | { |
354 | close(); | 354 | close(); |
355 | 355 | ||
356 | if ( dtp ) | 356 | if ( dtp ) |
357 | dtp->close(); | 357 | dtp->close(); |
358 | delete dtp; | 358 | delete dtp; |
359 | delete serversocket; | 359 | delete serversocket; |
360 | } | 360 | } |
361 | 361 | ||
362 | bool ServerPI::verifyAuthorised() | 362 | bool ServerPI::verifyAuthorised() |
363 | { | 363 | { |
364 | if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { | 364 | if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { |
365 | state = Forbidden; | 365 | state = Forbidden; |
366 | return FALSE; | 366 | return FALSE; |
367 | } | 367 | } |
368 | return TRUE; | 368 | return TRUE; |
369 | } | 369 | } |
370 | 370 | ||
371 | void ServerPI::connectionClosed() | 371 | void ServerPI::connectionClosed() |
372 | { | 372 | { |
373 | // qDebug( "Debug: Connection closed" ); | 373 | // qDebug( "Debug: Connection closed" ); |
374 | emit connectionClosed(this); | 374 | emit connectionClosed(this); |
375 | } | 375 | } |
376 | 376 | ||
377 | void ServerPI::send( const QString& msg ) | 377 | void ServerPI::send( const QString& msg ) |
378 | { | 378 | { |
379 | QTextStream os( this ); | 379 | QTextStream os( this ); |
380 | os << msg << endl; | 380 | os << msg << endl; |
381 | //qDebug( "Reply: %s", msg.latin1() ); | 381 | //qDebug( "Reply: %s", msg.latin1() ); |
382 | } | 382 | } |
383 | 383 | ||
384 | void ServerPI::read() | 384 | void ServerPI::read() |
385 | { | 385 | { |
386 | while ( canReadLine() ) | 386 | while ( canReadLine() ) |
387 | process( readLine().stripWhiteSpace() ); | 387 | process( readLine().stripWhiteSpace() ); |
388 | } | 388 | } |
389 | 389 | ||
390 | bool ServerPI::checkReadFile( const QString& file ) | 390 | bool ServerPI::checkReadFile( const QString& file ) |
391 | { | 391 | { |
392 | QString filename; | 392 | QString filename; |
393 | 393 | ||
394 | if ( file[0] != "/" ) | 394 | if ( file[0] != "/" ) |
395 | filename = directory.path() + "/" + file; | 395 | filename = directory.path() + "/" + file; |
396 | else | 396 | else |
397 | filename = file; | 397 | filename = file; |
398 | 398 | ||
399 | QFileInfo fi( filename ); | 399 | QFileInfo fi( filename ); |
400 | return ( fi.exists() && fi.isReadable() ); | 400 | return ( fi.exists() && fi.isReadable() ); |
401 | } | 401 | } |
402 | 402 | ||
403 | bool ServerPI::checkWriteFile( const QString& file ) | 403 | bool ServerPI::checkWriteFile( const QString& file ) |
404 | { | 404 | { |
405 | QString filename; | 405 | QString filename; |
406 | 406 | ||
407 | if ( file[0] != "/" ) | 407 | if ( file[0] != "/" ) |
408 | filename = directory.path() + "/" + file; | 408 | filename = directory.path() + "/" + file; |
409 | else | 409 | else |
410 | filename = file; | 410 | filename = file; |
411 | 411 | ||
412 | QFileInfo fi( filename ); | 412 | QFileInfo fi( filename ); |
413 | 413 | ||
414 | if ( fi.exists() ) | 414 | if ( fi.exists() ) |
415 | if ( !QFile( filename ).remove() ) | 415 | if ( !QFile( filename ).remove() ) |
416 | return FALSE; | 416 | return FALSE; |
417 | return TRUE; | 417 | return TRUE; |
418 | } | 418 | } |
419 | 419 | ||
420 | void ServerPI::process( const QString& message ) | 420 | void ServerPI::process( const QString& message ) |
421 | { | 421 | { |
422 | //qDebug( "Command: %s", message.latin1() ); | 422 | //qDebug( "Command: %s", message.latin1() ); |
423 | 423 | ||
424 | // split message using "," as separator | 424 | // split message using "," as separator |
425 | QStringList msg = QStringList::split( " ", message ); | 425 | QStringList msg = QStringList::split( " ", message ); |
426 | if ( msg.isEmpty() ) return; | 426 | if ( msg.isEmpty() ) return; |
427 | 427 | ||
428 | // command token | 428 | // command token |
429 | QString cmd = msg[0].upper(); | 429 | QString cmd = msg[0].upper(); |
430 | 430 | ||
431 | // argument token | 431 | // argument token |
432 | QString arg; | 432 | QString arg; |
433 | if ( msg.count() >= 2 ) | 433 | if ( msg.count() >= 2 ) |
434 | arg = msg[1]; | 434 | arg = msg[1]; |
435 | 435 | ||
436 | // full argument string | 436 | // full argument string |
437 | QString args; | 437 | QString args; |
438 | if ( msg.count() >= 2 ) { | 438 | if ( msg.count() >= 2 ) { |
439 | QStringList copy( msg ); | 439 | QStringList copy( msg ); |
440 | // FIXME: for Qt3 | 440 | // FIXME: for Qt3 |
441 | // copy.pop_front() | 441 | // copy.pop_front() |
442 | copy.remove( copy.begin() ); | 442 | copy.remove( copy.begin() ); |
443 | args = copy.join( " " ); | 443 | args = copy.join( " " ); |
444 | } | 444 | } |
445 | 445 | ||
446 | //qDebug( "args: %s", args.latin1() ); | 446 | //qDebug( "args: %s", args.latin1() ); |
447 | 447 | ||
448 | // we always respond to QUIT, regardless of state | 448 | // we always respond to QUIT, regardless of state |
449 | if ( cmd == "QUIT" ) { | 449 | if ( cmd == "QUIT" ) { |
450 | send( "211 Good bye!" ); // No tr | 450 | send( "211 Good bye!" ); // No tr |
451 | close(); | 451 | close(); |
452 | return; | 452 | return; |
453 | } | 453 | } |
454 | 454 | ||
455 | // connected to client | 455 | // connected to client |
456 | if ( Connected == state ) | 456 | if ( Connected == state ) |
457 | return; | 457 | return; |
458 | 458 | ||
459 | // waiting for user name | 459 | // waiting for user name |
460 | if ( Wait_USER == state ) { | 460 | if ( Wait_USER == state ) { |
461 | 461 | ||
462 | if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { | 462 | if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { |
463 | send( "530 Please login with USER and PASS" ); // No tr | 463 | send( "530 Please login with USER and PASS" ); // No tr |
464 | return; | 464 | return; |
465 | } | 465 | } |
466 | send( "331 User name ok, need password" ); // No tr | 466 | send( "331 User name ok, need password" ); // No tr |
467 | state = Wait_PASS; | 467 | state = Wait_PASS; |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | 470 | ||
471 | // waiting for password | 471 | // waiting for password |
472 | if ( Wait_PASS == state ) { | 472 | if ( Wait_PASS == state ) { |
473 | 473 | ||
474 | if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { | 474 | if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { |
475 | send( "530 Please login with USER and PASS" ); // No tr | 475 | send( "530 Please login with USER and PASS" ); // No tr |
476 | return; | 476 | return; |
477 | } | 477 | } |
478 | send( "230 User logged in, proceed" ); // No tr | 478 | send( "230 User logged in, proceed" ); // No tr |
479 | state = Ready; | 479 | state = Ready; |
480 | return; | 480 | return; |
481 | } | 481 | } |
482 | 482 | ||
483 | // ACCESS CONTROL COMMANDS | 483 | // ACCESS CONTROL COMMANDS |
484 | 484 | ||
485 | // Only an ALLO sent immediately before STOR is valid. | 485 | // Only an ALLO sent immediately before STOR is valid. |
486 | if ( cmd != "STOR" ) | 486 | if ( cmd != "STOR" ) |
487 | storFileSize = -1; | 487 | storFileSize = -1; |
488 | 488 | ||
489 | // account (ACCT) | 489 | // account (ACCT) |
490 | if ( cmd == "ACCT" ) { | 490 | if ( cmd == "ACCT" ) { |
491 | // even wu-ftp does not support it | 491 | // even wu-ftp does not support it |
492 | send( "502 Command not implemented" ); // No tr | 492 | send( "502 Command not implemented" ); // No tr |
493 | } | 493 | } |
494 | 494 | ||
495 | // change working directory (CWD) | 495 | // change working directory (CWD) |
496 | else if ( cmd == "CWD" ) { | 496 | else if ( cmd == "CWD" ) { |
497 | 497 | ||
498 | if ( !args.isEmpty() ) { | 498 | if ( !args.isEmpty() ) { |
499 | if ( directory.cd( args, TRUE ) ) | 499 | if ( directory.cd( args, TRUE ) ) |
500 | send( "250 Requested file action okay, completed" ); // No tr | 500 | send( "250 Requested file action okay, completed" ); // No tr |
501 | else | 501 | else |
502 | send( "550 Requested action not taken" ); // No tr | 502 | send( "550 Requested action not taken" ); // No tr |
503 | } | 503 | } |
504 | else | 504 | else |
505 | send( "500 Syntax error, command unrecognized" ); // No tr | 505 | send( "500 Syntax error, command unrecognized" ); // No tr |
506 | } | 506 | } |
507 | 507 | ||
508 | // change to parent directory (CDUP) | 508 | // change to parent directory (CDUP) |
509 | else if ( cmd == "CDUP" ) { | 509 | else if ( cmd == "CDUP" ) { |
510 | if ( directory.cdUp() ) | 510 | if ( directory.cdUp() ) |
511 | send( "250 Requested file action okay, completed" ); // No tr | 511 | send( "250 Requested file action okay, completed" ); // No tr |
512 | else | 512 | else |
513 | send( "550 Requested action not taken" ); // No tr | 513 | send( "550 Requested action not taken" ); // No tr |
514 | } | 514 | } |
515 | 515 | ||
516 | // structure mount (SMNT) | 516 | // structure mount (SMNT) |
517 | else if ( cmd == "SMNT" ) { | 517 | else if ( cmd == "SMNT" ) { |
518 | // even wu-ftp does not support it | 518 | // even wu-ftp does not support it |
519 | send( "502 Command not implemented" ); // No tr | 519 | send( "502 Command not implemented" ); // No tr |
520 | } | 520 | } |
521 | 521 | ||
522 | // reinitialize (REIN) | 522 | // reinitialize (REIN) |
523 | else if ( cmd == "REIN" ) { | 523 | else if ( cmd == "REIN" ) { |
524 | // even wu-ftp does not support it | 524 | // even wu-ftp does not support it |
525 | send( "502 Command not implemented" ); // No tr | 525 | send( "502 Command not implemented" ); // No tr |
526 | } | 526 | } |
527 | 527 | ||
528 | 528 | ||
529 | // TRANSFER PARAMETER COMMANDS | 529 | // TRANSFER PARAMETER COMMANDS |
530 | 530 | ||
531 | 531 | ||
532 | // data port (PORT) | 532 | // data port (PORT) |
533 | else if ( cmd == "PORT" ) { | 533 | else if ( cmd == "PORT" ) { |
534 | if ( parsePort( arg ) ) | 534 | if ( parsePort( arg ) ) |
535 | send( "200 Command okay" ); // No tr | 535 | send( "200 Command okay" ); // No tr |
536 | else | 536 | else |
537 | send( "500 Syntax error, command unrecognized" ); // No tr | 537 | send( "500 Syntax error, command unrecognized" ); // No tr |
538 | } | 538 | } |
539 | 539 | ||
540 | // passive (PASV) | 540 | // passive (PASV) |
@@ -897,385 +897,385 @@ bool ServerPI::sendList( const QString& arg ) | |||
897 | } | 897 | } |
898 | 898 | ||
899 | // return directory listing | 899 | // return directory listing |
900 | else if ( fi.isDir() ) { | 900 | else if ( fi.isDir() ) { |
901 | QDir dir( fn ); | 901 | QDir dir( fn ); |
902 | const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); | 902 | const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); |
903 | 903 | ||
904 | QFileInfoListIterator it( *list ); | 904 | QFileInfoListIterator it( *list ); |
905 | QFileInfo *info; | 905 | QFileInfo *info; |
906 | 906 | ||
907 | unsigned long total = 0; | 907 | unsigned long total = 0; |
908 | while ( ( info = it.current() ) ) { | 908 | while ( ( info = it.current() ) ) { |
909 | if ( info->fileName() != "." && info->fileName() != ".." ) | 909 | if ( info->fileName() != "." && info->fileName() != ".." ) |
910 | total += info->size(); | 910 | total += info->size(); |
911 | ++it; | 911 | ++it; |
912 | } | 912 | } |
913 | 913 | ||
914 | ts << "total " << QString::number( total / 1024 ) << endl; // No tr | 914 | ts << "total " << QString::number( total / 1024 ) << endl; // No tr |
915 | 915 | ||
916 | it.toFirst(); | 916 | it.toFirst(); |
917 | while ( ( info = it.current() ) ) { | 917 | while ( ( info = it.current() ) ) { |
918 | if ( info->fileName() == "." || info->fileName() == ".." ) { | 918 | if ( info->fileName() == "." || info->fileName() == ".." ) { |
919 | ++it; | 919 | ++it; |
920 | continue; | 920 | continue; |
921 | } | 921 | } |
922 | ts << fileListing( info ) << endl; | 922 | ts << fileListing( info ) << endl; |
923 | ++it; | 923 | ++it; |
924 | } | 924 | } |
925 | } | 925 | } |
926 | 926 | ||
927 | if ( passiv ) { | 927 | if ( passiv ) { |
928 | waitarray = buffer.buffer(); | 928 | waitarray = buffer.buffer(); |
929 | wait[SendByteArray] = TRUE; | 929 | wait[SendByteArray] = TRUE; |
930 | if ( waitsocket ) | 930 | if ( waitsocket ) |
931 | newConnection( waitsocket ); | 931 | newConnection( waitsocket ); |
932 | } | 932 | } |
933 | else | 933 | else |
934 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); | 934 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); |
935 | return TRUE; | 935 | return TRUE; |
936 | } | 936 | } |
937 | 937 | ||
938 | QString ServerPI::fileListing( QFileInfo *info ) | 938 | QString ServerPI::fileListing( QFileInfo *info ) |
939 | { | 939 | { |
940 | if ( !info ) return QString::null; | 940 | if ( !info ) return QString::null; |
941 | QString s; | 941 | QString s; |
942 | 942 | ||
943 | // type char | 943 | // type char |
944 | if ( info->isDir() ) | 944 | if ( info->isDir() ) |
945 | s += "d"; | 945 | s += "d"; |
946 | else if ( info->isSymLink() ) | 946 | else if ( info->isSymLink() ) |
947 | s += "l"; | 947 | s += "l"; |
948 | else | 948 | else |
949 | s += "-"; | 949 | s += "-"; |
950 | 950 | ||
951 | // permisson string | 951 | // permisson string |
952 | s += permissionString( info ) + " "; | 952 | s += permissionString( info ) + " "; |
953 | 953 | ||
954 | // number of hardlinks | 954 | // number of hardlinks |
955 | int subdirs = 1; | 955 | int subdirs = 1; |
956 | 956 | ||
957 | if ( info->isDir() ) | 957 | if ( info->isDir() ) |
958 | subdirs = 2; | 958 | subdirs = 2; |
959 | // FIXME : this is to slow | 959 | // FIXME : this is to slow |
960 | //if ( info->isDir() ) | 960 | //if ( info->isDir() ) |
961 | //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); | 961 | //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); |
962 | 962 | ||
963 | s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; | 963 | s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; |
964 | 964 | ||
965 | // owner | 965 | // owner |
966 | QString o = info->owner(); | 966 | QString o = info->owner(); |
967 | if ( o.isEmpty() ) | 967 | if ( o.isEmpty() ) |
968 | o = QString::number(info->ownerId()); | 968 | o = QString::number(info->ownerId()); |
969 | s += o.leftJustify( 8, ' ', TRUE ) + " "; | 969 | s += o.leftJustify( 8, ' ', TRUE ) + " "; |
970 | 970 | ||
971 | // group | 971 | // group |
972 | QString g = info->group(); | 972 | QString g = info->group(); |
973 | if ( g.isEmpty() ) | 973 | if ( g.isEmpty() ) |
974 | g = QString::number(info->groupId()); | 974 | g = QString::number(info->groupId()); |
975 | s += g.leftJustify( 8, ' ', TRUE ) + " "; | 975 | s += g.leftJustify( 8, ' ', TRUE ) + " "; |
976 | 976 | ||
977 | // file size in bytes | 977 | // file size in bytes |
978 | s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; | 978 | s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; |
979 | 979 | ||
980 | // last modified date | 980 | // last modified date |
981 | QDate date = info->lastModified().date(); | 981 | QDate date = info->lastModified().date(); |
982 | QTime time = info->lastModified().time(); | 982 | QTime time = info->lastModified().time(); |
983 | s += date.monthName( date.month() ) + " " | 983 | s += date.monthName( date.month() ) + " " |
984 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " | 984 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " |
985 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" | 985 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" |
986 | + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; | 986 | + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; |
987 | 987 | ||
988 | // file name | 988 | // file name |
989 | s += info->fileName(); | 989 | s += info->fileName(); |
990 | 990 | ||
991 | return s; | 991 | return s; |
992 | } | 992 | } |
993 | 993 | ||
994 | QString ServerPI::permissionString( QFileInfo *info ) | 994 | QString ServerPI::permissionString( QFileInfo *info ) |
995 | { | 995 | { |
996 | if ( !info ) return QString( "---------" ); | 996 | if ( !info ) return QString( "---------" ); |
997 | QString s; | 997 | QString s; |
998 | 998 | ||
999 | // user | 999 | // user |
1000 | if ( info->permission( QFileInfo::ReadUser ) ) s += "r"; | 1000 | if ( info->permission( QFileInfo::ReadUser ) ) s += "r"; |
1001 | else s += "-"; | 1001 | else s += "-"; |
1002 | if ( info->permission( QFileInfo::WriteUser ) ) s += "w"; | 1002 | if ( info->permission( QFileInfo::WriteUser ) ) s += "w"; |
1003 | else s += "-"; | 1003 | else s += "-"; |
1004 | if ( info->permission( QFileInfo::ExeUser ) ) s += "x"; | 1004 | if ( info->permission( QFileInfo::ExeUser ) ) s += "x"; |
1005 | else s += "-"; | 1005 | else s += "-"; |
1006 | 1006 | ||
1007 | // group | 1007 | // group |
1008 | if ( info->permission( QFileInfo::ReadGroup ) ) s += "r"; | 1008 | if ( info->permission( QFileInfo::ReadGroup ) ) s += "r"; |
1009 | else s += "-"; | 1009 | else s += "-"; |
1010 | if ( info->permission( QFileInfo::WriteGroup ) )s += "w"; | 1010 | if ( info->permission( QFileInfo::WriteGroup ) )s += "w"; |
1011 | else s += "-"; | 1011 | else s += "-"; |
1012 | if ( info->permission( QFileInfo::ExeGroup ) ) s += "x"; | 1012 | if ( info->permission( QFileInfo::ExeGroup ) ) s += "x"; |
1013 | else s += "-"; | 1013 | else s += "-"; |
1014 | 1014 | ||
1015 | // exec | 1015 | // exec |
1016 | if ( info->permission( QFileInfo::ReadOther ) ) s += "r"; | 1016 | if ( info->permission( QFileInfo::ReadOther ) ) s += "r"; |
1017 | else s += "-"; | 1017 | else s += "-"; |
1018 | if ( info->permission( QFileInfo::WriteOther ) ) s += "w"; | 1018 | if ( info->permission( QFileInfo::WriteOther ) ) s += "w"; |
1019 | else s += "-"; | 1019 | else s += "-"; |
1020 | if ( info->permission( QFileInfo::ExeOther ) ) s += "x"; | 1020 | if ( info->permission( QFileInfo::ExeOther ) ) s += "x"; |
1021 | else s += "-"; | 1021 | else s += "-"; |
1022 | 1022 | ||
1023 | return s; | 1023 | return s; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | void ServerPI::newConnection( int socket ) | 1026 | void ServerPI::newConnection( int socket ) |
1027 | { | 1027 | { |
1028 | //qDebug( "New incomming connection" ); | 1028 | //qDebug( "New incomming connection" ); |
1029 | 1029 | ||
1030 | if ( !passiv ) return; | 1030 | if ( !passiv ) return; |
1031 | 1031 | ||
1032 | if ( wait[SendFile] ) { | 1032 | if ( wait[SendFile] ) { |
1033 | QStringList targets; | 1033 | QStringList targets; |
1034 | if ( backupRestoreGzip( waitfile, targets ) ) | 1034 | if ( backupRestoreGzip( waitfile, targets ) ) |
1035 | dtp->sendGzipFile( waitfile, targets ); | 1035 | dtp->sendGzipFile( waitfile, targets ); |
1036 | else | 1036 | else |
1037 | dtp->sendFile( waitfile ); | 1037 | dtp->sendFile( waitfile ); |
1038 | dtp->setSocket( socket ); | 1038 | dtp->setSocket( socket ); |
1039 | } | 1039 | } |
1040 | else if ( wait[RetrieveFile] ) { | 1040 | else if ( wait[RetrieveFile] ) { |
1041 | qDebug("check retrieve file"); | 1041 | qDebug("check retrieve file"); |
1042 | if ( backupRestoreGzip( waitfile ) ) | 1042 | if ( backupRestoreGzip( waitfile ) ) |
1043 | dtp->retrieveGzipFile( waitfile ); | 1043 | dtp->retrieveGzipFile( waitfile ); |
1044 | else | 1044 | else |
1045 | dtp->retrieveFile( waitfile, storFileSize ); | 1045 | dtp->retrieveFile( waitfile, storFileSize ); |
1046 | dtp->setSocket( socket ); | 1046 | dtp->setSocket( socket ); |
1047 | } | 1047 | } |
1048 | else if ( wait[SendByteArray] ) { | 1048 | else if ( wait[SendByteArray] ) { |
1049 | dtp->sendByteArray( waitarray ); | 1049 | dtp->sendByteArray( waitarray ); |
1050 | dtp->setSocket( socket ); | 1050 | dtp->setSocket( socket ); |
1051 | } | 1051 | } |
1052 | else if ( wait[RetrieveByteArray] ) { | 1052 | else if ( wait[RetrieveByteArray] ) { |
1053 | qDebug("retrieve byte array"); | 1053 | qDebug("retrieve byte array"); |
1054 | dtp->retrieveByteArray(); | 1054 | dtp->retrieveByteArray(); |
1055 | dtp->setSocket( socket ); | 1055 | dtp->setSocket( socket ); |
1056 | } | 1056 | } |
1057 | else | 1057 | else |
1058 | waitsocket = socket; | 1058 | waitsocket = socket; |
1059 | 1059 | ||
1060 | for( int i = 0; i < 4; i++ ) | 1060 | for( int i = 0; i < 4; i++ ) |
1061 | wait[i] = FALSE; | 1061 | wait[i] = FALSE; |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | QString ServerPI::absFilePath( const QString& file ) | 1064 | QString ServerPI::absFilePath( const QString& file ) |
1065 | { | 1065 | { |
1066 | if ( file.isEmpty() ) return file; | 1066 | if ( file.isEmpty() ) return file; |
1067 | 1067 | ||
1068 | QString filepath( file ); | 1068 | QString filepath( file ); |
1069 | if ( file[0] != "/" ) | 1069 | if ( file[0] != "/" ) |
1070 | filepath = directory.path() + "/" + file; | 1070 | filepath = directory.path() + "/" + file; |
1071 | 1071 | ||
1072 | return filepath; | 1072 | return filepath; |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | 1075 | ||
1076 | void ServerPI::timerEvent( QTimerEvent * ) | 1076 | void ServerPI::timerEvent( QTimerEvent * ) |
1077 | { | 1077 | { |
1078 | connectionClosed(); | 1078 | connectionClosed(); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | ServerDTP::ServerDTP( QObject *parent, const char* name) | 1082 | ServerDTP::ServerDTP( QObject *parent, const char* name) |
1083 | : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), | 1083 | : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), |
1084 | retrieveTargzProc( 0 ) | 1084 | retrieveTargzProc( 0 ) |
1085 | { | 1085 | { |
1086 | 1086 | ||
1087 | connect( this, SIGNAL( connected() ), SLOT( connected() ) ); | 1087 | connect( this, SIGNAL( connected() ), SLOT( connected() ) ); |
1088 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 1088 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
1089 | connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) ); | 1089 | connect( this, SIGNAL( bytesWritten(int) ), SLOT( bytesWritten(int) ) ); |
1090 | connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); | 1090 | connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); |
1091 | 1091 | ||
1092 | createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); // No tr | 1092 | createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); // No tr |
1093 | createTargzProc->setCommunication( QProcess::Stdout ); | 1093 | createTargzProc->setCommunication( QProcess::Stdout ); |
1094 | createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); | 1094 | createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); |
1095 | connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) ); | 1095 | connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) ); |
1096 | 1096 | ||
1097 | retrieveTargzProc = new QProcess( this, "retrieveTargzProc" ); | 1097 | retrieveTargzProc = new QProcess( this, "retrieveTargzProc" ); |
1098 | retrieveTargzProc->setCommunication( QProcess::Stdin ); | 1098 | retrieveTargzProc->setCommunication( QProcess::Stdin ); |
1099 | retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); | 1099 | retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); |
1100 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 1100 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
1101 | SIGNAL( completed() ) ); | 1101 | SIGNAL( completed() ) ); |
1102 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 1102 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
1103 | SLOT( extractTarDone() ) ); | 1103 | SLOT( extractTarDone() ) ); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | ServerDTP::~ServerDTP() | 1106 | ServerDTP::~ServerDTP() |
1107 | { | 1107 | { |
1108 | buf.close(); | 1108 | buf.close(); |
1109 | if ( RetrieveFile == mode && file.isOpen() ) { | 1109 | if ( RetrieveFile == mode && file.isOpen() ) { |
1110 | // We're being shutdown before the client closed. | 1110 | // We're being shutdown before the client closed. |
1111 | file.close(); | 1111 | file.close(); |
1112 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { | 1112 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { |
1113 | qDebug( "STOR incomplete" ); | 1113 | qDebug( "STOR incomplete" ); |
1114 | file.remove(); | 1114 | file.remove(); |
1115 | } | 1115 | } |
1116 | } else { | 1116 | } else { |
1117 | file.close(); | 1117 | file.close(); |
1118 | } | 1118 | } |
1119 | createTargzProc->kill(); | 1119 | createTargzProc->kill(); |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | void ServerDTP::extractTarDone() | 1122 | void ServerDTP::extractTarDone() |
1123 | { | 1123 | { |
1124 | qDebug("extract done"); | 1124 | qDebug("extract done"); |
1125 | #ifndef QT_NO_COP | 1125 | #ifndef QT_NO_COP |
1126 | QCopEnvelope e( "QPE/System", "restoreDone(QString)" ); | 1126 | QCopEnvelope e( "QPE/System", "restoreDone(QString)" ); |
1127 | e << file.name(); | 1127 | e << file.name(); |
1128 | #endif | 1128 | #endif |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | void ServerDTP::connected() | 1131 | void ServerDTP::connected() |
1132 | { | 1132 | { |
1133 | // send file mode | 1133 | // send file mode |
1134 | switch ( mode ) { | 1134 | switch ( mode ) { |
1135 | case SendFile : | 1135 | case SendFile : |
1136 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { | 1136 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { |
1137 | emit failed(); | 1137 | emit failed(); |
1138 | mode = Idle; | 1138 | mode = Idle; |
1139 | return; | 1139 | return; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); | 1142 | //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); |
1143 | 1143 | ||
1144 | bytes_written = 0; | 1144 | bytes_written = 0; |
1145 | if ( file.size() == 0 ) { | 1145 | if ( file.size() == 0 ) { |
1146 | //make sure it doesn't hang on empty files | 1146 | //make sure it doesn't hang on empty files |
1147 | file.close(); | 1147 | file.close(); |
1148 | emit completed(); | 1148 | emit completed(); |
1149 | mode = Idle; | 1149 | mode = Idle; |
1150 | } else { | 1150 | } else { |
1151 | // Don't write more if there is plenty buffered already. | 1151 | // Don't write more if there is plenty buffered already. |
1152 | if ( bytesToWrite() <= block_size && !file.atEnd() ) { | 1152 | if ( bytesToWrite() <= block_size && !file.atEnd() ) { |
1153 | QCString s; | 1153 | QCString s; |
1154 | s.resize( block_size ); | 1154 | s.resize( block_size ); |
1155 | int bytes = file.readBlock( s.data(), block_size ); | 1155 | int bytes = file.readBlock( s.data(), block_size ); |
1156 | writeBlock( s.data(), bytes ); | 1156 | writeBlock( s.data(), bytes ); |
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | break; | 1159 | break; |
1160 | case SendGzipFile: | 1160 | case SendGzipFile: |
1161 | if ( createTargzProc->isRunning() ) { | 1161 | if ( createTargzProc->isRunning() ) { |
1162 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY | 1162 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY |
1163 | qWarning("Previous tar --gzip process is still running; killing it..."); | 1163 | qWarning("Previous tar --gzip process is still running; killing it..."); |
1164 | createTargzProc->kill(); | 1164 | createTargzProc->kill(); |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | bytes_written = 0; | 1167 | bytes_written = 0; |
1168 | qDebug("==>start send tar process"); | 1168 | qDebug("==>start send tar process"); |
1169 | if ( !createTargzProc->start() ) | 1169 | if ( !createTargzProc->start() ) |
1170 | qWarning("Error starting %s", | 1170 | qWarning("Error starting %s", |
1171 | createTargzProc->arguments().join(" ").latin1()); | 1171 | createTargzProc->arguments().join(" ").latin1()); |
1172 | break; | 1172 | break; |
1173 | case SendBuffer: | 1173 | case SendBuffer: |
1174 | if ( !buf.open( IO_ReadOnly) ) { | 1174 | if ( !buf.open( IO_ReadOnly) ) { |
1175 | emit failed(); | 1175 | emit failed(); |
1176 | mode = Idle; | 1176 | mode = Idle; |
1177 | return; | 1177 | return; |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | // qDebug( "Debug: Sending byte array" ); | 1180 | // qDebug( "Debug: Sending byte array" ); |
1181 | bytes_written = 0; | 1181 | bytes_written = 0; |
1182 | while( !buf.atEnd() ) | 1182 | while( !buf.atEnd() ) |
1183 | putch( buf.getch() ); | 1183 | putch( buf.getch() ); |
1184 | buf.close(); | 1184 | buf.close(); |
1185 | break; | 1185 | break; |
1186 | case RetrieveFile: | 1186 | case RetrieveFile: |
1187 | // retrieve file mode | 1187 | // retrieve file mode |
1188 | if ( file.exists() && !file.remove() ) { | 1188 | if ( file.exists() && !file.remove() ) { |
1189 | emit failed(); | 1189 | emit failed(); |
1190 | mode = Idle; | 1190 | mode = Idle; |
1191 | return; | 1191 | return; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | if ( !file.open( IO_WriteOnly) ) { | 1194 | if ( !file.open( IO_WriteOnly) ) { |
1195 | emit failed(); | 1195 | emit failed(); |
1196 | mode = Idle; | 1196 | mode = Idle; |
1197 | return; | 1197 | return; |
1198 | } | 1198 | } |
1199 | // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); | 1199 | // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); |
1200 | break; | 1200 | break; |
1201 | case RetrieveGzipFile: | 1201 | case RetrieveGzipFile: |
1202 | qDebug("=-> starting tar process to receive .tgz file"); | 1202 | qDebug("=-> starting tar process to receive .tgz file"); |
1203 | break; | 1203 | break; |
1204 | case RetrieveBuffer: | 1204 | case RetrieveBuffer: |
1205 | // retrieve buffer mode | 1205 | // retrieve buffer mode |
1206 | if ( !buf.open( IO_WriteOnly) ) { | 1206 | if ( !buf.open( IO_WriteOnly) ) { |
1207 | emit failed(); | 1207 | emit failed(); |
1208 | mode = Idle; | 1208 | mode = Idle; |
1209 | return; | 1209 | return; |
1210 | } | 1210 | } |
1211 | // qDebug( "Debug: Retrieving byte array" ); | 1211 | // qDebug( "Debug: Retrieving byte array" ); |
1212 | break; | 1212 | break; |
1213 | case Idle: | 1213 | case Idle: |
1214 | qDebug("connection established but mode set to Idle; BUG!"); | 1214 | qDebug("connection established but mode set to Idle; BUG!"); |
1215 | break; | 1215 | break; |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | void ServerDTP::connectionClosed() | 1219 | void ServerDTP::connectionClosed() |
1220 | { | 1220 | { |
1221 | //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); | 1221 | //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); |
1222 | 1222 | ||
1223 | // send file mode | 1223 | // send file mode |
1224 | if ( SendFile == mode ) { | 1224 | if ( SendFile == mode ) { |
1225 | if ( bytes_written == file.size() ) | 1225 | if ( bytes_written == file.size() ) |
1226 | emit completed(); | 1226 | emit completed(); |
1227 | else | 1227 | else |
1228 | emit failed(); | 1228 | emit failed(); |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | // send buffer mode | 1231 | // send buffer mode |
1232 | else if ( SendBuffer == mode ) { | 1232 | else if ( SendBuffer == mode ) { |
1233 | if ( bytes_written == buf.size() ) | 1233 | if ( bytes_written == buf.size() ) |
1234 | emit completed(); | 1234 | emit completed(); |
1235 | else | 1235 | else |
1236 | emit failed(); | 1236 | emit failed(); |
1237 | } | 1237 | } |
1238 | 1238 | ||
1239 | // retrieve file mode | 1239 | // retrieve file mode |
1240 | else if ( RetrieveFile == mode ) { | 1240 | else if ( RetrieveFile == mode ) { |
1241 | file.close(); | 1241 | file.close(); |
1242 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { | 1242 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { |
1243 | qDebug( "STOR incomplete" ); | 1243 | qDebug( "STOR incomplete" ); |
1244 | file.remove(); | 1244 | file.remove(); |
1245 | emit failed(); | 1245 | emit failed(); |
1246 | } else { | 1246 | } else { |
1247 | emit completed(); | 1247 | emit completed(); |
1248 | } | 1248 | } |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | else if ( RetrieveGzipFile == mode ) { | 1251 | else if ( RetrieveGzipFile == mode ) { |
1252 | qDebug("Done writing ungzip file; closing input"); | 1252 | qDebug("Done writing ungzip file; closing input"); |
1253 | retrieveTargzProc->flushStdin(); | 1253 | retrieveTargzProc->flushStdin(); |
1254 | retrieveTargzProc->closeStdin(); | 1254 | retrieveTargzProc->closeStdin(); |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | // retrieve buffer mode | 1257 | // retrieve buffer mode |
1258 | else if ( RetrieveBuffer == mode ) { | 1258 | else if ( RetrieveBuffer == mode ) { |
1259 | buf.close(); | 1259 | buf.close(); |
1260 | emit completed(); | 1260 | emit completed(); |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | mode = Idle; | 1263 | mode = Idle; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | void ServerDTP::bytesWritten( int bytes ) | 1266 | void ServerDTP::bytesWritten( int bytes ) |
1267 | { | 1267 | { |
1268 | bytes_written += bytes; | 1268 | bytes_written += bytes; |
1269 | 1269 | ||
1270 | // send file mode | 1270 | // send file mode |
1271 | if ( SendFile == mode ) { | 1271 | if ( SendFile == mode ) { |
1272 | 1272 | ||
1273 | if ( bytes_written == file.size() ) { | 1273 | if ( bytes_written == file.size() ) { |
1274 | // qDebug( "Debug: Sending complete: %d bytes", file.size() ); | 1274 | // qDebug( "Debug: Sending complete: %d bytes", file.size() ); |
1275 | file.close(); | 1275 | file.close(); |
1276 | emit completed(); | 1276 | emit completed(); |
1277 | mode = Idle; | 1277 | mode = Idle; |
1278 | } | 1278 | } |
1279 | else if( !file.atEnd() ) { | 1279 | else if( !file.atEnd() ) { |
1280 | QCString s; | 1280 | QCString s; |
1281 | s.resize( block_size ); | 1281 | s.resize( block_size ); |
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 82242a3..4ed5921 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -252,234 +252,234 @@ void LoopControl::startAudio() { | |||
252 | if( mediaPlayerState->isStreaming == FALSE) | 252 | if( mediaPlayerState->isStreaming == FALSE) |
253 | audioSampleCounter = currentSample + samplesRead - 1; | 253 | audioSampleCounter = currentSample + samplesRead - 1; |
254 | 254 | ||
255 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); | 255 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); |
256 | 256 | ||
257 | } else { | 257 | } else { |
258 | 258 | ||
259 | moreAudio = FALSE; | 259 | moreAudio = FALSE; |
260 | 260 | ||
261 | } | 261 | } |
262 | 262 | ||
263 | } | 263 | } |
264 | 264 | ||
265 | audioMutex->unlock(); | 265 | audioMutex->unlock(); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | void LoopControl::killTimers() { | 269 | void LoopControl::killTimers() { |
270 | 270 | ||
271 | audioMutex->lock(); | 271 | audioMutex->lock(); |
272 | 272 | ||
273 | if ( hasVideoChannel ) | 273 | if ( hasVideoChannel ) |
274 | killTimer( videoId ); | 274 | killTimer( videoId ); |
275 | killTimer( sliderId ); | 275 | killTimer( sliderId ); |
276 | threadOkToGo = FALSE; | 276 | threadOkToGo = FALSE; |
277 | 277 | ||
278 | audioMutex->unlock(); | 278 | audioMutex->unlock(); |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
282 | void LoopControl::startTimers() { | 282 | void LoopControl::startTimers() { |
283 | 283 | ||
284 | audioMutex->lock(); | 284 | audioMutex->lock(); |
285 | 285 | ||
286 | moreVideo = FALSE; | 286 | moreVideo = FALSE; |
287 | moreAudio = FALSE; | 287 | moreAudio = FALSE; |
288 | 288 | ||
289 | if ( hasVideoChannel ) { | 289 | if ( hasVideoChannel ) { |
290 | moreVideo = TRUE; | 290 | moreVideo = TRUE; |
291 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value | 291 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value |
292 | videoId = startTimer( mSecsBetweenFrames ); | 292 | videoId = startTimer( mSecsBetweenFrames ); |
293 | } | 293 | } |
294 | 294 | ||
295 | if ( hasAudioChannel ) { | 295 | if ( hasAudioChannel ) { |
296 | moreAudio = TRUE; | 296 | moreAudio = TRUE; |
297 | threadOkToGo = TRUE; | 297 | threadOkToGo = TRUE; |
298 | } | 298 | } |
299 | 299 | ||
300 | sliderId = startTimer( 300 ); // update slider every 1/3 second | 300 | sliderId = startTimer( 300 ); // update slider every 1/3 second |
301 | 301 | ||
302 | audioMutex->unlock(); | 302 | audioMutex->unlock(); |
303 | } | 303 | } |
304 | 304 | ||
305 | 305 | ||
306 | void LoopControl::setPaused( bool pause ) { | 306 | void LoopControl::setPaused( bool pause ) { |
307 | 307 | ||
308 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) | 308 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) |
309 | return; | 309 | return; |
310 | 310 | ||
311 | if ( pause ) { | 311 | if ( pause ) { |
312 | killTimers(); | 312 | killTimers(); |
313 | } else { | 313 | } else { |
314 | // Force an update of the position | 314 | // Force an update of the position |
315 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 315 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
316 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 316 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
317 | // Just like we never stopped | 317 | // Just like we never stopped |
318 | startTimers(); | 318 | startTimers(); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | void LoopControl::stop( bool willPlayAgainShortly ) { | 323 | void LoopControl::stop( bool willPlayAgainShortly ) { |
324 | 324 | ||
325 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 325 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
326 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { | 326 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { |
327 | disabledSuspendScreenSaver = FALSE; | 327 | disabledSuspendScreenSaver = FALSE; |
328 | // Re-enable the suspend mode | 328 | // Re-enable the suspend mode |
329 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 329 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
330 | } | 330 | } |
331 | #endif | 331 | #endif |
332 | 332 | ||
333 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { | 333 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { |
334 | 334 | ||
335 | killTimers(); | 335 | killTimers(); |
336 | 336 | ||
337 | audioMutex->lock(); | 337 | audioMutex->lock(); |
338 | 338 | ||
339 | mediaPlayerState->curDecoder()->close(); | 339 | mediaPlayerState->curDecoder()->close(); |
340 | 340 | ||
341 | if ( audioDevice ) { | 341 | if ( audioDevice ) { |
342 | delete audioDevice; | 342 | delete audioDevice; |
343 | delete audioBuffer; | 343 | delete audioBuffer; |
344 | audioDevice = 0; | 344 | audioDevice = 0; |
345 | audioBuffer = 0; | 345 | audioBuffer = 0; |
346 | } | 346 | } |
347 | 347 | ||
348 | audioMutex->unlock(); | 348 | audioMutex->unlock(); |
349 | } | 349 | } |
350 | audioSampleCounter=0; | 350 | audioSampleCounter=0; |
351 | current_frame=0; | 351 | current_frame=0; |
352 | total_audio_samples=0; | 352 | total_audio_samples=0; |
353 | } | 353 | } |
354 | 354 | ||
355 | 355 | ||
356 | bool LoopControl::init( const QString& filename ) { | 356 | bool LoopControl::init( const QString& filename ) { |
357 | stop(); | 357 | stop(); |
358 | audioMutex->lock(); | 358 | audioMutex->lock(); |
359 | 359 | ||
360 | fileName = filename; | 360 | fileName = filename; |
361 | stream = 0; // only play stream 0 for now | 361 | stream = 0; // only play stream 0 for now |
362 | current_frame = total_video_frames = total_audio_samples = 0; | 362 | current_frame = total_video_frames = total_audio_samples = 0; |
363 | 363 | ||
364 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 364 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); |
365 | 365 | ||
366 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 366 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
367 | // if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 367 | // if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
368 | // if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { | 368 | // if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { |
369 | // total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 369 | // total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
370 | // mediaPlayerState->libMpeg3Decoder()->close(); | 370 | // mediaPlayerState->libMpeg3Decoder()->close(); |
371 | // } | 371 | // } |
372 | // } | 372 | // } |
373 | 373 | ||
374 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 374 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
375 | audioMutex->unlock(); | 375 | audioMutex->unlock(); |
376 | return FALSE; | 376 | return FALSE; |
377 | } | 377 | } |
378 | 378 | ||
379 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 379 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
380 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 380 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
381 | 381 | ||
382 | if ( hasAudioChannel ) { | 382 | if ( hasAudioChannel ) { |
383 | int astream = 0; | 383 | int astream = 0; |
384 | 384 | ||
385 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") ) | 385 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") ) |
386 | channels = 2; //dont akx me why, but it needs this hack | 386 | channels = 2; //dont akx me why, but it needs this hack |
387 | else | 387 | else |
388 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 388 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
389 | 389 | ||
390 | // qDebug( "LC- channels = %d", channels ); | 390 | // qDebug( "LC- channels = %d", channels ); |
391 | 391 | ||
392 | // if ( !total_audio_samples ) | 392 | // if ( !total_audio_samples ) |
393 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 393 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
394 | 394 | ||
395 | total_audio_samples += 1000; | 395 | total_audio_samples += 1000; |
396 | // qDebug("total samples %d", total_audio_samples); | 396 | // qDebug("total samples %d", total_audio_samples); |
397 | mediaPlayerState->setLength( total_audio_samples ); | 397 | mediaPlayerState->setLength( total_audio_samples ); |
398 | 398 | ||
399 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 399 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
400 | // qDebug( "LC- frequency = %d", freq ); | 400 | // qDebug( "LC- frequency = %d", freq ); |
401 | 401 | ||
402 | audioSampleCounter = 0; | 402 | audioSampleCounter = 0; |
403 | int bits_per_sample; | 403 | int bits_per_sample; |
404 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { | 404 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { |
405 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); | 405 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); |
406 | // qDebug("using stupid hack"); | 406 | // qDebug("using stupid hack"); |
407 | } else { | 407 | } else { |
408 | bits_per_sample=0; | 408 | bits_per_sample=0; |
409 | } | 409 | } |
410 | 410 | ||
411 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); | 411 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); |
412 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 412 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
413 | channels = audioDevice->channels(); | 413 | channels = audioDevice->channels(); |
414 | 414 | ||
415 | //### must check which frequency is actually used. | 415 | //### must check which frequency is actually used. |
416 | static const int size = 1; | 416 | static const int size = 1; |
417 | short int buf[size]; | 417 | short int buf[size]; |
418 | long samplesRead = 0; | 418 | long samplesRead = 0; |
419 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 419 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
420 | } | 420 | } |
421 | 421 | ||
422 | if ( hasVideoChannel ) { | 422 | if ( hasVideoChannel ) { |
423 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 423 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
424 | 424 | ||
425 | mediaPlayerState->setLength( total_video_frames ); | 425 | mediaPlayerState->setLength( total_video_frames ); |
426 | 426 | ||
427 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 427 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
428 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 428 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
429 | 429 | ||
430 | if ( framerate <= 1.0 ) { | 430 | if ( framerate <= 1.0 ) { |
431 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 431 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
432 | framerate = 25; | 432 | framerate = 25; |
433 | } | 433 | } |
434 | 434 | ||
435 | if ( total_video_frames == 1 ) { | 435 | if ( total_video_frames == 1 ) { |
436 | DecodeLoopDebug(( "Cannot seek to frame" )); | 436 | DecodeLoopDebug(( "Cannot seek to frame" )); |
437 | } | 437 | } |
438 | 438 | ||
439 | } | 439 | } |
440 | 440 | ||
441 | current_frame = 0; | 441 | current_frame = 0; |
442 | prev_frame = -1; | 442 | prev_frame = -1; |
443 | 443 | ||
444 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); | 444 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) ); |
445 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); | 445 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
446 | 446 | ||
447 | audioMutex->unlock(); | 447 | audioMutex->unlock(); |
448 | 448 | ||
449 | return TRUE; | 449 | return TRUE; |
450 | } | 450 | } |
451 | 451 | ||
452 | 452 | ||
453 | void LoopControl::play() { | 453 | void LoopControl::play() { |
454 | // qDebug("LC- play"); | 454 | // qDebug("LC- play"); |
455 | mediaPlayerState->setPosition( 0); //uglyhack | 455 | mediaPlayerState->setPosition( 0); //uglyhack |
456 | 456 | ||
457 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 457 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
458 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 458 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
459 | disabledSuspendScreenSaver = TRUE; | 459 | disabledSuspendScreenSaver = TRUE; |
460 | previousSuspendMode = hasVideoChannel; | 460 | previousSuspendMode = hasVideoChannel; |
461 | // Stop the screen from blanking and power saving state | 461 | // Stop the screen from blanking and power saving state |
462 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 462 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
463 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 463 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
464 | } | 464 | } |
465 | #endif | 465 | #endif |
466 | 466 | ||
467 | playtime.start(); | 467 | playtime.start(); |
468 | startTimers(); | 468 | startTimers(); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | void LoopControl::setMute( bool on ) { | 472 | void LoopControl::setMute( bool on ) { |
473 | if ( on != isMuted ) { | 473 | if ( on != isMuted ) { |
474 | isMuted = on; | 474 | isMuted = on; |
475 | if ( !on ) { | 475 | if ( !on ) { |
476 | // Force an update of the position | 476 | // Force an update of the position |
477 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 477 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
478 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 478 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
479 | // Resume playing audio | 479 | // Resume playing audio |
480 | moreAudio = TRUE; | 480 | moreAudio = TRUE; |
481 | } | 481 | } |
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp index 3796549..0a1fc17 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp +++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp | |||
@@ -392,233 +392,233 @@ void LoopControl::startAudio() { | |||
392 | moreAudio = audioSampleCounter <= total_audio_samples; | 392 | moreAudio = audioSampleCounter <= total_audio_samples; |
393 | 393 | ||
394 | } else { | 394 | } else { |
395 | 395 | ||
396 | if ( mediaPlayerState->curDecoder() && hasAudioChannel ) | 396 | if ( mediaPlayerState->curDecoder() && hasAudioChannel ) |
397 | usleep( 100000 ); // Check every 1/10 sec to see if mute is off | 397 | usleep( 100000 ); // Check every 1/10 sec to see if mute is off |
398 | else | 398 | else |
399 | moreAudio = FALSE; | 399 | moreAudio = FALSE; |
400 | 400 | ||
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | // qDebug( "End of file" ); | 404 | // qDebug( "End of file" ); |
405 | 405 | ||
406 | if ( !moreVideo && !moreAudio ) | 406 | if ( !moreVideo && !moreAudio ) |
407 | emitPlayFinished = TRUE; | 407 | emitPlayFinished = TRUE; |
408 | 408 | ||
409 | pthread_exit(NULL); | 409 | pthread_exit(NULL); |
410 | } | 410 | } |
411 | 411 | ||
412 | void LoopControl::killTimers() { | 412 | void LoopControl::killTimers() { |
413 | if ( hasVideoChannel ) { | 413 | if ( hasVideoChannel ) { |
414 | if ( pthread_self() != video_tid ) { | 414 | if ( pthread_self() != video_tid ) { |
415 | if ( pthread_cancel(video_tid) == 0 ) { | 415 | if ( pthread_cancel(video_tid) == 0 ) { |
416 | void *thread_result = 0; | 416 | void *thread_result = 0; |
417 | if ( pthread_join(video_tid,&thread_result) != 0 ) | 417 | if ( pthread_join(video_tid,&thread_result) != 0 ) |
418 | // qDebug("thread join error 1"); | 418 | // qDebug("thread join error 1"); |
419 | pthread_attr_destroy(&video_attr); | 419 | pthread_attr_destroy(&video_attr); |
420 | } | 420 | } |
421 | } | 421 | } |
422 | } | 422 | } |
423 | if ( hasAudioChannel ) { | 423 | if ( hasAudioChannel ) { |
424 | if ( pthread_self() != audio_tid ) { | 424 | if ( pthread_self() != audio_tid ) { |
425 | if ( pthread_cancel(audio_tid) == 0 ) { | 425 | if ( pthread_cancel(audio_tid) == 0 ) { |
426 | void *thread_result = 0; | 426 | void *thread_result = 0; |
427 | if ( pthread_join(audio_tid,&thread_result) != 0 ) | 427 | if ( pthread_join(audio_tid,&thread_result) != 0 ) |
428 | // qDebug("thread join error 2"); | 428 | // qDebug("thread join error 2"); |
429 | pthread_attr_destroy(&audio_attr); | 429 | pthread_attr_destroy(&audio_attr); |
430 | } | 430 | } |
431 | } | 431 | } |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | void LoopControl::startTimers() { | 435 | void LoopControl::startTimers() { |
436 | moreVideo = FALSE; | 436 | moreVideo = FALSE; |
437 | moreAudio = FALSE; | 437 | moreAudio = FALSE; |
438 | 438 | ||
439 | if ( hasVideoChannel ) { | 439 | if ( hasVideoChannel ) { |
440 | moreVideo = TRUE; | 440 | moreVideo = TRUE; |
441 | pthread_attr_init(&video_attr); | 441 | pthread_attr_init(&video_attr); |
442 | pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this); | 442 | pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this); |
443 | } | 443 | } |
444 | 444 | ||
445 | if ( hasAudioChannel ) { | 445 | if ( hasAudioChannel ) { |
446 | moreAudio = TRUE; | 446 | moreAudio = TRUE; |
447 | pthread_attr_init(&audio_attr); | 447 | pthread_attr_init(&audio_attr); |
448 | #ifdef USE_REALTIME_AUDIO_THREAD | 448 | #ifdef USE_REALTIME_AUDIO_THREAD |
449 | pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin | 449 | pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin |
450 | //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) ); | 450 | //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) ); |
451 | sched_param params; | 451 | sched_param params; |
452 | params.sched_priority = 50; | 452 | params.sched_priority = 50; |
453 | pthread_attr_setschedparam(&audio_attr,¶ms); | 453 | pthread_attr_setschedparam(&audio_attr,¶ms); |
454 | #endif | 454 | #endif |
455 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 455 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | 460 | ||
461 | 461 | ||
462 | void LoopControl::setPaused( bool pause ) { | 462 | void LoopControl::setPaused( bool pause ) { |
463 | static int whenPaused = 0; | 463 | static int whenPaused = 0; |
464 | 464 | ||
465 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) | 465 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) |
466 | return; | 466 | return; |
467 | 467 | ||
468 | if ( pause ) { | 468 | if ( pause ) { |
469 | // Remember where we are | 469 | // Remember where we are |
470 | whenPaused = playtime.elapsed(); | 470 | whenPaused = playtime.elapsed(); |
471 | killTimers(); | 471 | killTimers(); |
472 | } else { | 472 | } else { |
473 | // Just like we never stopped | 473 | // Just like we never stopped |
474 | playtime.restart(); | 474 | playtime.restart(); |
475 | playtime = playtime.addMSecs( -whenPaused ); | 475 | playtime = playtime.addMSecs( -whenPaused ); |
476 | whenPaused = 0; | 476 | whenPaused = 0; |
477 | startTimers(); | 477 | startTimers(); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | void LoopControl::stop( bool willPlayAgainShortly ) { | 482 | void LoopControl::stop( bool willPlayAgainShortly ) { |
483 | 483 | ||
484 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 484 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
485 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { | 485 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { |
486 | disabledSuspendScreenSaver = FALSE; | 486 | disabledSuspendScreenSaver = FALSE; |
487 | // Re-enable the suspend mode | 487 | // Re-enable the suspend mode |
488 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 488 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
489 | } | 489 | } |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { | 492 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { |
493 | 493 | ||
494 | killTimers(); | 494 | killTimers(); |
495 | 495 | ||
496 | mediaPlayerState->curDecoder()->close(); | 496 | mediaPlayerState->curDecoder()->close(); |
497 | 497 | ||
498 | if ( audioDevice ) { | 498 | if ( audioDevice ) { |
499 | delete audioDevice; | 499 | delete audioDevice; |
500 | delete audioBuffer; | 500 | delete audioBuffer; |
501 | audioDevice = 0; | 501 | audioDevice = 0; |
502 | audioBuffer = 0; | 502 | audioBuffer = 0; |
503 | } | 503 | } |
504 | 504 | ||
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | bool LoopControl::init( const QString& filename ) { | 509 | bool LoopControl::init( const QString& filename ) { |
510 | stop(); | 510 | stop(); |
511 | fileName = filename; | 511 | fileName = filename; |
512 | stream = 0; // only play stream 0 for now | 512 | stream = 0; // only play stream 0 for now |
513 | current_frame = total_video_frames = total_audio_samples = 0; | 513 | current_frame = total_video_frames = total_audio_samples = 0; |
514 | 514 | ||
515 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 515 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); |
516 | 516 | ||
517 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 517 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
518 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 518 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
519 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { | 519 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { |
520 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 520 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
521 | mediaPlayerState->libMpeg3Decoder()->close(); | 521 | mediaPlayerState->libMpeg3Decoder()->close(); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) | 525 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) |
526 | return FALSE; | 526 | return FALSE; |
527 | 527 | ||
528 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 528 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
529 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 529 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
530 | 530 | ||
531 | if ( hasAudioChannel ) { | 531 | if ( hasAudioChannel ) { |
532 | int astream = 0; | 532 | int astream = 0; |
533 | 533 | ||
534 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 534 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
535 | DecodeLoopDebug(( "channels = %d\n", channels )); | 535 | DecodeLoopDebug(( "channels = %d\n", channels )); |
536 | 536 | ||
537 | if ( !total_audio_samples ) | 537 | if ( !total_audio_samples ) |
538 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 538 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
539 | 539 | ||
540 | mediaPlayerState->setLength( total_audio_samples ); | 540 | mediaPlayerState->setLength( total_audio_samples ); |
541 | 541 | ||
542 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 542 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
543 | DecodeLoopDebug(( "frequency = %d\n", freq )); | 543 | DecodeLoopDebug(( "frequency = %d\n", freq )); |
544 | 544 | ||
545 | audioSampleCounter = 0; | 545 | audioSampleCounter = 0; |
546 | 546 | ||
547 | static const int bytes_per_sample = 2; //16 bit | 547 | static const int bytes_per_sample = 2; //16 bit |
548 | 548 | ||
549 | audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); | 549 | audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); |
550 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 550 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
551 | channels = audioDevice->channels(); | 551 | channels = audioDevice->channels(); |
552 | 552 | ||
553 | //### must check which frequency is actually used. | 553 | //### must check which frequency is actually used. |
554 | static const int size = 1; | 554 | static const int size = 1; |
555 | short int buf[size]; | 555 | short int buf[size]; |
556 | long samplesRead = 0; | 556 | long samplesRead = 0; |
557 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 557 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
558 | } | 558 | } |
559 | 559 | ||
560 | if ( hasVideoChannel ) { | 560 | if ( hasVideoChannel ) { |
561 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 561 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
562 | 562 | ||
563 | mediaPlayerState->setLength( total_video_frames ); | 563 | mediaPlayerState->setLength( total_video_frames ); |
564 | 564 | ||
565 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 565 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
566 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 566 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
567 | 567 | ||
568 | if ( framerate <= 1.0 ) { | 568 | if ( framerate <= 1.0 ) { |
569 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 569 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
570 | framerate = 25; | 570 | framerate = 25; |
571 | } | 571 | } |
572 | 572 | ||
573 | if ( total_video_frames == 1 ) { | 573 | if ( total_video_frames == 1 ) { |
574 | DecodeLoopDebug(( "Cannot seek to frame" )); | 574 | DecodeLoopDebug(( "Cannot seek to frame" )); |
575 | } | 575 | } |
576 | 576 | ||
577 | } | 577 | } |
578 | 578 | ||
579 | videoMutex->lock(); | 579 | videoMutex->lock(); |
580 | current_frame = 0; | 580 | current_frame = 0; |
581 | prev_frame = -1; | 581 | prev_frame = -1; |
582 | videoMutex->unlock(); | 582 | videoMutex->unlock(); |
583 | 583 | ||
584 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); | 584 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) ); |
585 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); | 585 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
586 | 586 | ||
587 | //setBackgroundColor( black ); | 587 | //setBackgroundColor( black ); |
588 | return TRUE; | 588 | return TRUE; |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | void LoopControl::play() { | 592 | void LoopControl::play() { |
593 | 593 | ||
594 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 594 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
595 | if ( !disabledSuspendScreenSaver ) { | 595 | if ( !disabledSuspendScreenSaver ) { |
596 | disabledSuspendScreenSaver = TRUE; | 596 | disabledSuspendScreenSaver = TRUE; |
597 | // Stop the screen from blanking and power saving state | 597 | // Stop the screen from blanking and power saving state |
598 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 598 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
599 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 599 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
600 | } | 600 | } |
601 | #endif | 601 | #endif |
602 | 602 | ||
603 | //begin = clock(); | 603 | //begin = clock(); |
604 | playtime.start(); | 604 | playtime.start(); |
605 | startTimers(); | 605 | startTimers(); |
606 | //updateGeometry(); | 606 | //updateGeometry(); |
607 | } | 607 | } |
608 | 608 | ||
609 | 609 | ||
610 | void LoopControl::setMute( bool on ) { | 610 | void LoopControl::setMute( bool on ) { |
611 | if ( isMuted != on ) { | 611 | if ( isMuted != on ) { |
612 | isMuted = on; | 612 | isMuted = on; |
613 | if ( isMuted ) { | 613 | if ( isMuted ) { |
614 | } else { | 614 | } else { |
615 | int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream ); | 615 | int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream ); |
616 | playtime.restart(); | 616 | playtime.restart(); |
617 | playtime = playtime.addMSecs( -frame * 1000 / framerate ); | 617 | playtime = playtime.addMSecs( -frame * 1000 / framerate ); |
618 | //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate; | 618 | //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate; |
619 | mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream ); | 619 | mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream ); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | } | 622 | } |
623 | 623 | ||
624 | 624 | ||
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index b77708c..6c743ec 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp | |||
@@ -1,238 +1,238 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | 21 | ||
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | 23 | ||
24 | #include "mediaplayer.h" | 24 | #include "mediaplayer.h" |
25 | #include "playlistwidget.h" | 25 | #include "playlistwidget.h" |
26 | #include "audiowidget.h" | 26 | #include "audiowidget.h" |
27 | #include "loopcontrol.h" | 27 | #include "loopcontrol.h" |
28 | #include "audiodevice.h" | 28 | #include "audiodevice.h" |
29 | 29 | ||
30 | #include "mediaplayerstate.h" | 30 | #include "mediaplayerstate.h" |
31 | 31 | ||
32 | 32 | ||
33 | extern AudioWidget *audioUI; | 33 | extern AudioWidget *audioUI; |
34 | extern PlayListWidget *playList; | 34 | extern PlayListWidget *playList; |
35 | extern LoopControl *loopControl; | 35 | extern LoopControl *loopControl; |
36 | extern MediaPlayerState *mediaPlayerState; | 36 | extern MediaPlayerState *mediaPlayerState; |
37 | 37 | ||
38 | 38 | ||
39 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 39 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
40 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 40 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
41 | 41 | ||
42 | // QPEApplication::grabKeyboard(); | 42 | // QPEApplication::grabKeyboard(); |
43 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 43 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
44 | 44 | ||
45 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 45 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
46 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 46 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); |
47 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 47 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
48 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 48 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
49 | 49 | ||
50 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 50 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
51 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 51 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
52 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 52 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
53 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 53 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | MediaPlayer::~MediaPlayer() { | 57 | MediaPlayer::~MediaPlayer() { |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void MediaPlayer::pauseCheck( bool b ) { | 62 | void MediaPlayer::pauseCheck( bool b ) { |
63 | // Only pause if playing | 63 | // Only pause if playing |
64 | if ( b && !mediaPlayerState->playing() ) | 64 | if ( b && !mediaPlayerState->playing() ) |
65 | mediaPlayerState->setPaused( FALSE ); | 65 | mediaPlayerState->setPaused( FALSE ); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | void MediaPlayer::play() { | 69 | void MediaPlayer::play() { |
70 | mediaPlayerState->setPlaying( FALSE ); | 70 | mediaPlayerState->setPlaying( FALSE ); |
71 | mediaPlayerState->setPlaying( TRUE ); | 71 | mediaPlayerState->setPlaying( TRUE ); |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | void MediaPlayer::setPlaying( bool play ) { | 75 | void MediaPlayer::setPlaying( bool play ) { |
76 | // qDebug("MediaPlayer setPlaying %d", play); | 76 | // qDebug("MediaPlayer setPlaying %d", play); |
77 | if ( !play ) { | 77 | if ( !play ) { |
78 | mediaPlayerState->setPaused( FALSE ); | 78 | mediaPlayerState->setPaused( FALSE ); |
79 | loopControl->stop( FALSE ); | 79 | loopControl->stop( FALSE ); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | if ( mediaPlayerState->paused() ) { | 83 | if ( mediaPlayerState->paused() ) { |
84 | mediaPlayerState->setPaused( FALSE ); | 84 | mediaPlayerState->setPaused( FALSE ); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | // qDebug("about to ctrash"); | 87 | // qDebug("about to ctrash"); |
88 | const DocLnk *playListCurrent = playList->current(); | 88 | const DocLnk *playListCurrent = playList->current(); |
89 | 89 | ||
90 | if ( playListCurrent != NULL ) { | 90 | if ( playListCurrent != NULL ) { |
91 | loopControl->stop( TRUE ); | 91 | loopControl->stop( TRUE ); |
92 | currentFile = playListCurrent; | 92 | currentFile = playListCurrent; |
93 | } | 93 | } |
94 | if ( currentFile == NULL ) { | 94 | if ( currentFile == NULL ) { |
95 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); | 95 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); |
96 | mediaPlayerState->setPlaying( FALSE ); | 96 | mediaPlayerState->setPlaying( FALSE ); |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | 99 | ||
100 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { | 100 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { |
101 | QMessageBox::critical( 0, tr( "File not found"), | 101 | QMessageBox::critical( 0, tr( "File not found"), |
102 | tr( "The following file was not found: <i>" ) | 102 | tr( "The following file was not found: <i>" ) |
103 | + currentFile->file() + "</i>" ); | 103 | + currentFile->file() + "</i>" ); |
104 | mediaPlayerState->setPlaying( FALSE ); | 104 | mediaPlayerState->setPlaying( FALSE ); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | 107 | ||
108 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { | 108 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { |
109 | QMessageBox::critical( 0, tr( "No decoder found"), | 109 | QMessageBox::critical( 0, tr( "No decoder found"), |
110 | tr( "Sorry, no appropriate decoders found for this file: <i>" ) | 110 | tr( "Sorry, no appropriate decoders found for this file: <i>" ) |
111 | + currentFile->file() + "</i>" ); | 111 | + currentFile->file() + "</i>" ); |
112 | mediaPlayerState->setPlaying( FALSE ); | 112 | mediaPlayerState->setPlaying( FALSE ); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | 115 | ||
116 | if ( !loopControl->init( currentFile->file() ) ) { | 116 | if ( !loopControl->init( currentFile->file() ) ) { |
117 | QMessageBox::critical( 0, tr( "Error opening file"), | 117 | QMessageBox::critical( 0, tr( "Error opening file"), |
118 | tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); | 118 | tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); |
119 | mediaPlayerState->setPlaying( FALSE ); | 119 | mediaPlayerState->setPlaying( FALSE ); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | long seconds = loopControl->totalPlaytime(); | 122 | long seconds = loopControl->totalPlaytime(); |
123 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 123 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
124 | QString tickerText; | 124 | QString tickerText; |
125 | if( currentFile->file().left(4) == "http" ) | 125 | if( currentFile->file().left(4) == "http" ) |
126 | tickerText= tr( " File: " ) + currentFile->name(); | 126 | tickerText= tr( " File: " ) + currentFile->name(); |
127 | else | 127 | else |
128 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 128 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; |
129 | 129 | ||
130 | QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | 130 | QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); |
131 | if ( !fileInfo.isEmpty() ) | 131 | if ( !fileInfo.isEmpty() ) |
132 | tickerText += ", " + fileInfo; | 132 | tickerText += ", " + fileInfo; |
133 | audioUI->setTickerText( tickerText + "." ); | 133 | audioUI->setTickerText( tickerText + "." ); |
134 | 134 | ||
135 | loopControl->play(); | 135 | loopControl->play(); |
136 | 136 | ||
137 | mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); | 137 | mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | void MediaPlayer::prev() { | 141 | void MediaPlayer::prev() { |
142 | if ( playList->prev() ) | 142 | if ( playList->prev() ) |
143 | play(); | 143 | play(); |
144 | else if ( mediaPlayerState->looping() ) { | 144 | else if ( mediaPlayerState->looping() ) { |
145 | if ( playList->last() ) | 145 | if ( playList->last() ) |
146 | play(); | 146 | play(); |
147 | } else | 147 | } else |
148 | mediaPlayerState->setList(); | 148 | mediaPlayerState->setList(); |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | void MediaPlayer::next() { | 152 | void MediaPlayer::next() { |
153 | if ( playList->next() ) | 153 | if ( playList->next() ) |
154 | play(); | 154 | play(); |
155 | else if ( mediaPlayerState->looping() ) { | 155 | else if ( mediaPlayerState->looping() ) { |
156 | if ( playList->first() ) | 156 | if ( playList->first() ) |
157 | play(); | 157 | play(); |
158 | } else | 158 | } else |
159 | mediaPlayerState->setList(); | 159 | mediaPlayerState->setList(); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void MediaPlayer::startDecreasingVolume() { | 163 | void MediaPlayer::startDecreasingVolume() { |
164 | volumeDirection = -1; | 164 | volumeDirection = -1; |
165 | startTimer( 100 ); | 165 | startTimer( 100 ); |
166 | AudioDevice::decreaseVolume(); | 166 | AudioDevice::decreaseVolume(); |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | void MediaPlayer::startIncreasingVolume() { | 170 | void MediaPlayer::startIncreasingVolume() { |
171 | volumeDirection = +1; | 171 | volumeDirection = +1; |
172 | startTimer( 100 ); | 172 | startTimer( 100 ); |
173 | AudioDevice::increaseVolume(); | 173 | AudioDevice::increaseVolume(); |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | bool drawnOnScreenDisplay = FALSE; | 177 | bool drawnOnScreenDisplay = FALSE; |
178 | unsigned int onScreenDisplayVolume = 0; | 178 | unsigned int onScreenDisplayVolume = 0; |
179 | const int yoff = 110; | 179 | const int yoff = 110; |
180 | 180 | ||
181 | void MediaPlayer::stopChangingVolume() { | 181 | void MediaPlayer::stopChangingVolume() { |
182 | killTimers(); | 182 | killTimers(); |
183 | 183 | ||
184 | // Get rid of the on-screen display stuff | 184 | // Get rid of the on-screen display stuff |
185 | drawnOnScreenDisplay = FALSE; | 185 | drawnOnScreenDisplay = FALSE; |
186 | onScreenDisplayVolume = 0; | 186 | onScreenDisplayVolume = 0; |
187 | int w = audioUI->width(); | 187 | int w = audioUI->width(); |
188 | int h = audioUI->height(); | 188 | int h = audioUI->height(); |
189 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 189 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 193 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
194 | // qDebug("timer"); | 194 | // qDebug("timer"); |
195 | if ( volumeDirection == +1 ) | 195 | if ( volumeDirection == +1 ) |
196 | AudioDevice::increaseVolume(); | 196 | AudioDevice::increaseVolume(); |
197 | else if ( volumeDirection == -1 ) | 197 | else if ( volumeDirection == -1 ) |
198 | AudioDevice::decreaseVolume(); | 198 | AudioDevice::decreaseVolume(); |
199 | 199 | ||
200 | // Display an on-screen display volume | 200 | // Display an on-screen display volume |
201 | unsigned int l, r, v; bool m; | 201 | unsigned int l, r, v; bool m; |
202 | AudioDevice::getVolume( l, r, m ); | 202 | AudioDevice::getVolume( l, r, m ); |
203 | v = ((l + r) * 11) / (2*0xFFFF); | 203 | v = ((l + r) * 11) / (2*0xFFFF); |
204 | 204 | ||
205 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 205 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
206 | // qDebug("returning %d, %d, %d, %d", v, l, r, m); | 206 | // qDebug("returning %d, %d, %d, %d", v, l, r, m); |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | 209 | ||
210 | int w = audioUI->width(); | 210 | int w = audioUI->width(); |
211 | int h = audioUI->height(); | 211 | int h = audioUI->height(); |
212 | 212 | ||
213 | if ( drawnOnScreenDisplay ) { | 213 | if ( drawnOnScreenDisplay ) { |
214 | if ( onScreenDisplayVolume > v ) | 214 | if ( onScreenDisplayVolume > v ) |
215 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, | 215 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, |
216 | (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 216 | (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
217 | } | 217 | } |
218 | 218 | ||
219 | drawnOnScreenDisplay = TRUE; | 219 | drawnOnScreenDisplay = TRUE; |
220 | onScreenDisplayVolume = v; | 220 | onScreenDisplayVolume = v; |
221 | 221 | ||
222 | QPainter p( audioUI ); | 222 | QPainter p( audioUI ); |
223 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 223 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
224 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 224 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
225 | 225 | ||
226 | QFont f; | 226 | QFont f; |
227 | f.setPixelSize( 20 ); | 227 | f.setPixelSize( 20 ); |
228 | f.setBold( TRUE ); | 228 | f.setBold( TRUE ); |
229 | p.setFont( f ); | 229 | p.setFont( f ); |
230 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 230 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
231 | 231 | ||
232 | for ( unsigned int i = 0; i < 10; i++ ) { | 232 | for ( unsigned int i = 0; i < 10; i++ ) { |
233 | if ( v > i ) | 233 | if ( v > i ) |
234 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 234 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
235 | else | 235 | else |
236 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 236 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
237 | } | 237 | } |
238 | } | 238 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index a359843..efb5df3 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,522 +1,522 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qtoolbar.h> | 23 | #include <qtoolbar.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/lnkproperties.h> | 25 | #include <qpe/lnkproperties.h> |
26 | 26 | ||
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | 30 | ||
31 | //#include <qtimer.h> | 31 | //#include <qtimer.h> |
32 | 32 | ||
33 | #include "playlistselection.h" | 33 | #include "playlistselection.h" |
34 | #include "playlistwidget.h" | 34 | #include "playlistwidget.h" |
35 | #include "mediaplayerstate.h" | 35 | #include "mediaplayerstate.h" |
36 | 36 | ||
37 | #include "inputDialog.h" | 37 | #include "inputDialog.h" |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include "audiowidget.h" | 40 | #include "audiowidget.h" |
41 | #include "videowidget.h" | 41 | #include "videowidget.h" |
42 | 42 | ||
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | #include <sys/file.h> | 44 | #include <sys/file.h> |
45 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
46 | #include <sys/soundcard.h> | 46 | #include <sys/soundcard.h> |
47 | 47 | ||
48 | // for setBacklight() | 48 | // for setBacklight() |
49 | #include <linux/fb.h> | 49 | #include <linux/fb.h> |
50 | #include <sys/types.h> | 50 | #include <sys/types.h> |
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #define BUTTONS_ON_TOOLBAR | 54 | #define BUTTONS_ON_TOOLBAR |
55 | #define SIDE_BUTTONS | 55 | #define SIDE_BUTTONS |
56 | #define CAN_SAVE_LOAD_PLAYLISTS | 56 | #define CAN_SAVE_LOAD_PLAYLISTS |
57 | 57 | ||
58 | extern AudioWidget *audioUI; | 58 | extern AudioWidget *audioUI; |
59 | extern VideoWidget *videoUI; | 59 | extern VideoWidget *videoUI; |
60 | extern MediaPlayerState *mediaPlayerState; | 60 | extern MediaPlayerState *mediaPlayerState; |
61 | 61 | ||
62 | static inline QString fullBaseName ( const QFileInfo &fi ) | 62 | static inline QString fullBaseName ( const QFileInfo &fi ) |
63 | { | 63 | { |
64 | QString str = fi. fileName ( ); | 64 | QString str = fi. fileName ( ); |
65 | return str. left ( str. findRev ( '.' )); | 65 | return str. left ( str. findRev ( '.' )); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; | 69 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; |
70 | // class myFileSelector { | 70 | // class myFileSelector { |
71 | 71 | ||
72 | // }; | 72 | // }; |
73 | class PlayListWidgetPrivate { | 73 | class PlayListWidgetPrivate { |
74 | public: | 74 | public: |
75 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 75 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
76 | QFrame *playListFrame; | 76 | QFrame *playListFrame; |
77 | FileSelector *files; | 77 | FileSelector *files; |
78 | PlayListSelection *selectedFiles; | 78 | PlayListSelection *selectedFiles; |
79 | bool setDocumentUsed; | 79 | bool setDocumentUsed; |
80 | DocLnk *current; | 80 | DocLnk *current; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | class ToolButton : public QToolButton { | 84 | class ToolButton : public QToolButton { |
85 | public: | 85 | public: |
86 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 86 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
87 | : QToolButton( parent, name ) { | 87 | : QToolButton( parent, name ) { |
88 | setTextLabel( name ); | 88 | setTextLabel( name ); |
89 | setPixmap( Resource::loadPixmap( icon ) ); | 89 | setPixmap( Resource::loadPixmap( icon ) ); |
90 | setAutoRaise( TRUE ); | 90 | setAutoRaise( TRUE ); |
91 | setFocusPolicy( QWidget::NoFocus ); | 91 | setFocusPolicy( QWidget::NoFocus ); |
92 | setToggleButton( t ); | 92 | setToggleButton( t ); |
93 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 93 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
94 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 94 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
95 | } | 95 | } |
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | class MenuItem : public QAction { | 99 | class MenuItem : public QAction { |
100 | public: | 100 | public: |
101 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 101 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
102 | : QAction( text, QString::null, 0, 0 ) { | 102 | : QAction( text, QString::null, 0, 0 ) { |
103 | connect( this, SIGNAL( activated() ), handler, slot ); | 103 | connect( this, SIGNAL( activated() ), handler, slot ); |
104 | addTo( parent ); | 104 | addTo( parent ); |
105 | } | 105 | } |
106 | }; | 106 | }; |
107 | 107 | ||
108 | 108 | ||
109 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 109 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
110 | : QMainWindow( parent, name, fl ) { | 110 | : QMainWindow( parent, name, fl ) { |
111 | 111 | ||
112 | d = new PlayListWidgetPrivate; | 112 | d = new PlayListWidgetPrivate; |
113 | d->setDocumentUsed = FALSE; | 113 | d->setDocumentUsed = FALSE; |
114 | d->current = NULL; | 114 | d->current = NULL; |
115 | fromSetDocument = FALSE; | 115 | fromSetDocument = FALSE; |
116 | insanityBool=FALSE; | 116 | insanityBool=FALSE; |
117 | audioScan = FALSE; | 117 | audioScan = FALSE; |
118 | videoScan = FALSE; | 118 | videoScan = FALSE; |
119 | // menuTimer = new QTimer( this ,"menu timer"), | 119 | // menuTimer = new QTimer( this ,"menu timer"), |
120 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 120 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
121 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | 121 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); |
122 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 122 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
123 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 123 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
124 | 124 | ||
125 | setBackgroundMode( PaletteButton ); | 125 | setBackgroundMode( PaletteButton ); |
126 | 126 | ||
127 | setCaption( tr("OpiePlayer") ); | 127 | setCaption( tr("OpiePlayer") ); |
128 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 128 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
129 | 129 | ||
130 | setToolBarsMovable( FALSE ); | 130 | setToolBarsMovable( FALSE ); |
131 | 131 | ||
132 | // Create Toolbar | 132 | // Create Toolbar |
133 | QToolBar *toolbar = new QToolBar( this ); | 133 | QToolBar *toolbar = new QToolBar( this ); |
134 | toolbar->setHorizontalStretchable( TRUE ); | 134 | toolbar->setHorizontalStretchable( TRUE ); |
135 | 135 | ||
136 | // Create Menubar | 136 | // Create Menubar |
137 | QMenuBar *menu = new QMenuBar( toolbar ); | 137 | QMenuBar *menu = new QMenuBar( toolbar ); |
138 | menu->setMargin( 0 ); | 138 | menu->setMargin( 0 ); |
139 | 139 | ||
140 | QToolBar *bar = new QToolBar( this ); | 140 | QToolBar *bar = new QToolBar( this ); |
141 | bar->setLabel( tr( "Play Operations" ) ); | 141 | bar->setLabel( tr( "Play Operations" ) ); |
142 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 142 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
143 | // this , SLOT( addSelected()) ); | 143 | // this , SLOT( addSelected()) ); |
144 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 144 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
145 | tbDeletePlaylist->setFlat(TRUE); | 145 | tbDeletePlaylist->setFlat(TRUE); |
146 | 146 | ||
147 | tbDeletePlaylist->setFixedSize(20,20); | 147 | tbDeletePlaylist->setFixedSize(20,20); |
148 | 148 | ||
149 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 149 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
150 | this , SLOT(addSelected()) ); | 150 | this , SLOT(addSelected()) ); |
151 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 151 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
152 | this , SLOT(removeSelected()) ); | 152 | this , SLOT(removeSelected()) ); |
153 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 153 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); |
154 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 154 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
155 | this , SLOT( btnPlay(bool) ), TRUE ); | 155 | this , SLOT( btnPlay(bool) ), TRUE ); |
156 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 156 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
157 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 157 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
158 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 158 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
159 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 159 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
160 | tbDeletePlaylist->hide(); | 160 | tbDeletePlaylist->hide(); |
161 | 161 | ||
162 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 162 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
163 | menu->insertItem( tr( "File" ), pmPlayList ); | 163 | menu->insertItem( tr( "File" ), pmPlayList ); |
164 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 164 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
165 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 165 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
166 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 166 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
167 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 167 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
168 | pmPlayList->insertSeparator(-1); | 168 | pmPlayList->insertSeparator(-1); |
169 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 169 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
170 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 170 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
171 | pmPlayList->insertSeparator(-1); | 171 | pmPlayList->insertSeparator(-1); |
172 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 172 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
173 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 173 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
174 | 174 | ||
175 | QPopupMenu *pmView = new QPopupMenu( this ); | 175 | QPopupMenu *pmView = new QPopupMenu( this ); |
176 | menu->insertItem( tr( "View" ), pmView ); | 176 | menu->insertItem( tr( "View" ), pmView ); |
177 | 177 | ||
178 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 178 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
179 | fullScreenButton->addTo(pmView); | 179 | fullScreenButton->addTo(pmView); |
180 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 180 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
181 | scaleButton->addTo(pmView); | 181 | scaleButton->addTo(pmView); |
182 | 182 | ||
183 | 183 | ||
184 | skinsMenu = new QPopupMenu( this ); | 184 | skinsMenu = new QPopupMenu( this ); |
185 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 185 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
186 | skinsMenu->isCheckable(); | 186 | skinsMenu->isCheckable(); |
187 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 187 | connect( skinsMenu, SIGNAL( activated(int) ) , |
188 | this, SLOT( skinsMenuActivated( int ) ) ); | 188 | this, SLOT( skinsMenuActivated(int) ) ); |
189 | populateSkinsMenu(); | 189 | populateSkinsMenu(); |
190 | 190 | ||
191 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 191 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
192 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 192 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
193 | 193 | ||
194 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 194 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
195 | 195 | ||
196 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 196 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
197 | // tabWidget->setTabShape(QTabWidget::Triangular); | 197 | // tabWidget->setTabShape(QTabWidget::Triangular); |
198 | 198 | ||
199 | QWidget *pTab; | 199 | QWidget *pTab; |
200 | pTab = new QWidget( tabWidget, "pTab" ); | 200 | pTab = new QWidget( tabWidget, "pTab" ); |
201 | // playlistView = new QListView( pTab, "playlistview" ); | 201 | // playlistView = new QListView( pTab, "playlistview" ); |
202 | // playlistView->setMinimumSize(236,260); | 202 | // playlistView->setMinimumSize(236,260); |
203 | tabWidget->insertTab( pTab,"Playlist"); | 203 | tabWidget->insertTab( pTab,"Playlist"); |
204 | 204 | ||
205 | 205 | ||
206 | // Add the playlist area | 206 | // Add the playlist area |
207 | 207 | ||
208 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 208 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
209 | d->playListFrame = vbox3; | 209 | d->playListFrame = vbox3; |
210 | 210 | ||
211 | QGridLayout *layoutF = new QGridLayout( pTab ); | 211 | QGridLayout *layoutF = new QGridLayout( pTab ); |
212 | layoutF->setSpacing( 2); | 212 | layoutF->setSpacing( 2); |
213 | layoutF->setMargin( 2); | 213 | layoutF->setMargin( 2); |
214 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 214 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
215 | 215 | ||
216 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 216 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
217 | 217 | ||
218 | d->selectedFiles = new PlayListSelection( hbox2); | 218 | d->selectedFiles = new PlayListSelection( hbox2); |
219 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 219 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
220 | 220 | ||
221 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 221 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
222 | 222 | ||
223 | 223 | ||
224 | 224 | ||
225 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 225 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
226 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 226 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
227 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 227 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
228 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 228 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
229 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 229 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
230 | 230 | ||
231 | QWidget *aTab; | 231 | QWidget *aTab; |
232 | aTab = new QWidget( tabWidget, "aTab" ); | 232 | aTab = new QWidget( tabWidget, "aTab" ); |
233 | audioView = new QListView( aTab, "Audioview" ); | 233 | audioView = new QListView( aTab, "Audioview" ); |
234 | 234 | ||
235 | QGridLayout *layoutA = new QGridLayout( aTab ); | 235 | QGridLayout *layoutA = new QGridLayout( aTab ); |
236 | layoutA->setSpacing( 2); | 236 | layoutA->setSpacing( 2); |
237 | layoutA->setMargin( 2); | 237 | layoutA->setMargin( 2); |
238 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 238 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
239 | 239 | ||
240 | audioView->addColumn( tr("Title"),-1); | 240 | audioView->addColumn( tr("Title"),-1); |
241 | audioView->addColumn(tr("Size"), -1); | 241 | audioView->addColumn(tr("Size"), -1); |
242 | audioView->addColumn(tr("Media"),-1); | 242 | audioView->addColumn(tr("Media"),-1); |
243 | audioView->addColumn( tr( "Path" ), -1 ); | 243 | audioView->addColumn( tr( "Path" ), -1 ); |
244 | 244 | ||
245 | audioView->setColumnAlignment(1, Qt::AlignRight); | 245 | audioView->setColumnAlignment(1, Qt::AlignRight); |
246 | audioView->setColumnAlignment(2, Qt::AlignRight); | 246 | audioView->setColumnAlignment(2, Qt::AlignRight); |
247 | audioView->setAllColumnsShowFocus(TRUE); | 247 | audioView->setAllColumnsShowFocus(TRUE); |
248 | 248 | ||
249 | audioView->setMultiSelection( TRUE ); | 249 | audioView->setMultiSelection( TRUE ); |
250 | audioView->setSelectionMode( QListView::Extended); | 250 | audioView->setSelectionMode( QListView::Extended); |
251 | audioView->setSorting( 3, TRUE ); | 251 | audioView->setSorting( 3, TRUE ); |
252 | 252 | ||
253 | tabWidget->insertTab(aTab,tr("Audio")); | 253 | tabWidget->insertTab(aTab,tr("Audio")); |
254 | 254 | ||
255 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 255 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
256 | 256 | ||
257 | // audioView | 257 | // audioView |
258 | // populateAudioView(); | 258 | // populateAudioView(); |
259 | // videowidget | 259 | // videowidget |
260 | 260 | ||
261 | QWidget *vTab; | 261 | QWidget *vTab; |
262 | vTab = new QWidget( tabWidget, "vTab" ); | 262 | vTab = new QWidget( tabWidget, "vTab" ); |
263 | videoView = new QListView( vTab, "Videoview" ); | 263 | videoView = new QListView( vTab, "Videoview" ); |
264 | 264 | ||
265 | QGridLayout *layoutV = new QGridLayout( vTab ); | 265 | QGridLayout *layoutV = new QGridLayout( vTab ); |
266 | layoutV->setSpacing( 2); | 266 | layoutV->setSpacing( 2); |
267 | layoutV->setMargin( 2); | 267 | layoutV->setMargin( 2); |
268 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 268 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
269 | 269 | ||
270 | videoView->addColumn(tr("Title"),-1); | 270 | videoView->addColumn(tr("Title"),-1); |
271 | videoView->addColumn(tr("Size"),-1); | 271 | videoView->addColumn(tr("Size"),-1); |
272 | videoView->addColumn(tr("Media"),-1); | 272 | videoView->addColumn(tr("Media"),-1); |
273 | videoView->addColumn(tr( "Path" ), -1 ); | 273 | videoView->addColumn(tr( "Path" ), -1 ); |
274 | videoView->setColumnAlignment(1, Qt::AlignRight); | 274 | videoView->setColumnAlignment(1, Qt::AlignRight); |
275 | videoView->setColumnAlignment(2, Qt::AlignRight); | 275 | videoView->setColumnAlignment(2, Qt::AlignRight); |
276 | videoView->setAllColumnsShowFocus(TRUE); | 276 | videoView->setAllColumnsShowFocus(TRUE); |
277 | videoView->setMultiSelection( TRUE ); | 277 | videoView->setMultiSelection( TRUE ); |
278 | videoView->setSelectionMode( QListView::Extended); | 278 | videoView->setSelectionMode( QListView::Extended); |
279 | 279 | ||
280 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 280 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
281 | 281 | ||
282 | tabWidget->insertTab( vTab,tr("Video")); | 282 | tabWidget->insertTab( vTab,tr("Video")); |
283 | 283 | ||
284 | QWidget *LTab; | 284 | QWidget *LTab; |
285 | LTab = new QWidget( tabWidget, "LTab" ); | 285 | LTab = new QWidget( tabWidget, "LTab" ); |
286 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); | 286 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); |
287 | 287 | ||
288 | QGridLayout *layoutL = new QGridLayout( LTab ); | 288 | QGridLayout *layoutL = new QGridLayout( LTab ); |
289 | layoutL->setSpacing( 2); | 289 | layoutL->setSpacing( 2); |
290 | layoutL->setMargin( 2); | 290 | layoutL->setMargin( 2); |
291 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 291 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
292 | 292 | ||
293 | tabWidget->insertTab(LTab,tr("Lists")); | 293 | tabWidget->insertTab(LTab,tr("Lists")); |
294 | 294 | ||
295 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 295 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
296 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 296 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
297 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 297 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
298 | 298 | ||
299 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 299 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
300 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 300 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); |
301 | 301 | ||
302 | 302 | ||
303 | ///audioView | 303 | ///audioView |
304 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 304 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
305 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 305 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); |
306 | 306 | ||
307 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 307 | connect( audioView, SIGNAL( returnPressed(QListViewItem*)), |
308 | this,SLOT( playIt( QListViewItem *)) ); | 308 | this,SLOT( playIt(QListViewItem*)) ); |
309 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 309 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); |
310 | 310 | ||
311 | 311 | ||
312 | //videoView | 312 | //videoView |
313 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 313 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
314 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 314 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); |
315 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 315 | connect( videoView, SIGNAL( returnPressed(QListViewItem*)), |
316 | this,SLOT( playIt( QListViewItem *)) ); | 316 | this,SLOT( playIt(QListViewItem*)) ); |
317 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 317 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); |
318 | 318 | ||
319 | //playlists | 319 | //playlists |
320 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 320 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); |
321 | 321 | ||
322 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 322 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
323 | 323 | ||
324 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 324 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); |
325 | 325 | ||
326 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 326 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); |
327 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 327 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); |
328 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 328 | connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); |
329 | 329 | ||
330 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 330 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); |
331 | 331 | ||
332 | setCentralWidget( vbox5 ); | 332 | setCentralWidget( vbox5 ); |
333 | 333 | ||
334 | Config cfg( "OpiePlayer" ); | 334 | Config cfg( "OpiePlayer" ); |
335 | readConfig( cfg ); | 335 | readConfig( cfg ); |
336 | 336 | ||
337 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); | 337 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); |
338 | loadList(DocLnk( currentPlayList)); | 338 | loadList(DocLnk( currentPlayList)); |
339 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); | 339 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); |
340 | 340 | ||
341 | initializeStates(); | 341 | initializeStates(); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | PlayListWidget::~PlayListWidget() { | 345 | PlayListWidget::~PlayListWidget() { |
346 | Config cfg( "OpiePlayer" ); | 346 | Config cfg( "OpiePlayer" ); |
347 | writeConfig( cfg ); | 347 | writeConfig( cfg ); |
348 | 348 | ||
349 | if ( d->current ) | 349 | if ( d->current ) |
350 | delete d->current; | 350 | delete d->current; |
351 | if(d) delete d; | 351 | if(d) delete d; |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | void PlayListWidget::initializeStates() { | 355 | void PlayListWidget::initializeStates() { |
356 | 356 | ||
357 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 357 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
358 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 358 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
359 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 359 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
360 | setPlaylist( true); | 360 | setPlaylist( true); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | void PlayListWidget::readConfig( Config& cfg ) { | 364 | void PlayListWidget::readConfig( Config& cfg ) { |
365 | cfg.setGroup("PlayList"); | 365 | cfg.setGroup("PlayList"); |
366 | QString currentString = cfg.readEntry("current", "" ); | 366 | QString currentString = cfg.readEntry("current", "" ); |
367 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 367 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
368 | for ( int i = 0; i < noOfFiles; i++ ) { | 368 | for ( int i = 0; i < noOfFiles; i++ ) { |
369 | QString entryName; | 369 | QString entryName; |
370 | entryName.sprintf( "File%i", i + 1 ); | 370 | entryName.sprintf( "File%i", i + 1 ); |
371 | QString linkFile = cfg.readEntry( entryName ); | 371 | QString linkFile = cfg.readEntry( entryName ); |
372 | DocLnk lnk( linkFile ); | 372 | DocLnk lnk( linkFile ); |
373 | if ( lnk.isValid() ) { | 373 | if ( lnk.isValid() ) { |
374 | d->selectedFiles->addToSelection( lnk ); | 374 | d->selectedFiles->addToSelection( lnk ); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | d->selectedFiles->setSelectedItem( currentString); | 377 | d->selectedFiles->setSelectedItem( currentString); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::writeConfig( Config& cfg ) const { | 381 | void PlayListWidget::writeConfig( Config& cfg ) const { |
382 | 382 | ||
383 | d->selectedFiles->writeCurrent( cfg); | 383 | d->selectedFiles->writeCurrent( cfg); |
384 | cfg.setGroup("PlayList"); | 384 | cfg.setGroup("PlayList"); |
385 | int noOfFiles = 0; | 385 | int noOfFiles = 0; |
386 | d->selectedFiles->first(); | 386 | d->selectedFiles->first(); |
387 | do { | 387 | do { |
388 | const DocLnk *lnk = d->selectedFiles->current(); | 388 | const DocLnk *lnk = d->selectedFiles->current(); |
389 | if ( lnk ) { | 389 | if ( lnk ) { |
390 | QString entryName; | 390 | QString entryName; |
391 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 391 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
392 | // qDebug(entryName); | 392 | // qDebug(entryName); |
393 | cfg.writeEntry( entryName, lnk->linkFile() ); | 393 | cfg.writeEntry( entryName, lnk->linkFile() ); |
394 | // if this link does exist, add it so we have the file | 394 | // if this link does exist, add it so we have the file |
395 | // next time... | 395 | // next time... |
396 | if ( !QFile::exists( lnk->linkFile() ) ) { | 396 | if ( !QFile::exists( lnk->linkFile() ) ) { |
397 | // the way writing lnks doesn't really check for out | 397 | // the way writing lnks doesn't really check for out |
398 | // of disk space, but check it anyway. | 398 | // of disk space, but check it anyway. |
399 | // if ( !lnk->writeLink() ) { | 399 | // if ( !lnk->writeLink() ) { |
400 | // QMessageBox::critical( 0, tr("Out of space"), | 400 | // QMessageBox::critical( 0, tr("Out of space"), |
401 | // tr( "There was a problem saving " | 401 | // tr( "There was a problem saving " |
402 | // "the playlist.\n" | 402 | // "the playlist.\n" |
403 | // "Your playlist " | 403 | // "Your playlist " |
404 | // "may be missing some entries\n" | 404 | // "may be missing some entries\n" |
405 | // "the next time you start it." ) | 405 | // "the next time you start it." ) |
406 | // ); | 406 | // ); |
407 | // } | 407 | // } |
408 | 408 | ||
409 | } | 409 | } |
410 | noOfFiles++; | 410 | noOfFiles++; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | while ( d->selectedFiles->next() ); | 413 | while ( d->selectedFiles->next() ); |
414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
419 | d->setDocumentUsed = false; | 419 | d->setDocumentUsed = false; |
420 | if ( mediaPlayerState->playlist() ) { | 420 | if ( mediaPlayerState->playlist() ) { |
421 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 421 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
422 | d->selectedFiles->addToSelection( lnk ); | 422 | d->selectedFiles->addToSelection( lnk ); |
423 | } | 423 | } |
424 | else | 424 | else |
425 | mediaPlayerState->setPlaying( true); | 425 | mediaPlayerState->setPlaying( true); |
426 | 426 | ||
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | void PlayListWidget::clearList() { | 430 | void PlayListWidget::clearList() { |
431 | while ( first() ) | 431 | while ( first() ) |
432 | d->selectedFiles->removeSelected(); | 432 | d->selectedFiles->removeSelected(); |
433 | Config cfg( "OpiePlayer" ); | 433 | Config cfg( "OpiePlayer" ); |
434 | cfg.setGroup("PlayList"); | 434 | cfg.setGroup("PlayList"); |
435 | cfg.writeEntry("CurrentPlaylist",""); | 435 | cfg.writeEntry("CurrentPlaylist",""); |
436 | currentPlayList=""; | 436 | currentPlayList=""; |
437 | 437 | ||
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | void PlayListWidget::addAllToList() { | 441 | void PlayListWidget::addAllToList() { |
442 | DocLnkSet filesAll; | 442 | DocLnkSet filesAll; |
443 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 443 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
444 | QListIterator<DocLnk> Adit( filesAll.children() ); | 444 | QListIterator<DocLnk> Adit( filesAll.children() ); |
445 | for ( ; Adit.current(); ++Adit ) | 445 | for ( ; Adit.current(); ++Adit ) |
446 | if(QFileInfo(Adit.current()->file()).exists()) | 446 | if(QFileInfo(Adit.current()->file()).exists()) |
447 | d->selectedFiles->addToSelection( **Adit ); | 447 | d->selectedFiles->addToSelection( **Adit ); |
448 | tabWidget->setCurrentPage(0); | 448 | tabWidget->setCurrentPage(0); |
449 | 449 | ||
450 | writeCurrentM3u(); | 450 | writeCurrentM3u(); |
451 | d->selectedFiles->first(); | 451 | d->selectedFiles->first(); |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | void PlayListWidget::addAllMusicToList() { | 455 | void PlayListWidget::addAllMusicToList() { |
456 | QListIterator<DocLnk> dit( files.children() ); | 456 | QListIterator<DocLnk> dit( files.children() ); |
457 | for ( ; dit.current(); ++dit ) | 457 | for ( ; dit.current(); ++dit ) |
458 | if(QFileInfo(dit.current()->file()).exists()) | 458 | if(QFileInfo(dit.current()->file()).exists()) |
459 | d->selectedFiles->addToSelection( **dit ); | 459 | d->selectedFiles->addToSelection( **dit ); |
460 | tabWidget->setCurrentPage(0); | 460 | tabWidget->setCurrentPage(0); |
461 | 461 | ||
462 | writeCurrentM3u(); | 462 | writeCurrentM3u(); |
463 | d->selectedFiles->first(); | 463 | d->selectedFiles->first(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void PlayListWidget::addAllVideoToList() { | 467 | void PlayListWidget::addAllVideoToList() { |
468 | QListIterator<DocLnk> dit( vFiles.children() ); | 468 | QListIterator<DocLnk> dit( vFiles.children() ); |
469 | for ( ; dit.current(); ++dit ) | 469 | for ( ; dit.current(); ++dit ) |
470 | if(QFileInfo( dit.current()->file()).exists()) | 470 | if(QFileInfo( dit.current()->file()).exists()) |
471 | d->selectedFiles->addToSelection( **dit ); | 471 | d->selectedFiles->addToSelection( **dit ); |
472 | tabWidget->setCurrentPage(0); | 472 | tabWidget->setCurrentPage(0); |
473 | 473 | ||
474 | writeCurrentM3u(); | 474 | writeCurrentM3u(); |
475 | d->selectedFiles->first(); | 475 | d->selectedFiles->first(); |
476 | } | 476 | } |
477 | 477 | ||
478 | 478 | ||
479 | void PlayListWidget::setDocument(const QString& fileref) { | 479 | void PlayListWidget::setDocument(const QString& fileref) { |
480 | fromSetDocument = true; | 480 | fromSetDocument = true; |
481 | d->setDocumentUsed = TRUE; | 481 | d->setDocumentUsed = TRUE; |
482 | setDocumentEx(fileref); | 482 | setDocumentEx(fileref); |
483 | } | 483 | } |
484 | 484 | ||
485 | void PlayListWidget::setDocumentEx(const QString& fileref) { | 485 | void PlayListWidget::setDocumentEx(const QString& fileref) { |
486 | qDebug("opieplayer receive "+fileref); | 486 | qDebug("opieplayer receive "+fileref); |
487 | clearList(); | 487 | clearList(); |
488 | DocLnk lnk; | 488 | DocLnk lnk; |
489 | QFileInfo fileInfo(fileref); | 489 | QFileInfo fileInfo(fileref); |
490 | if ( !fileInfo.exists() ) { | 490 | if ( !fileInfo.exists() ) { |
491 | QMessageBox::critical( 0, tr( "Invalid File" ), | 491 | QMessageBox::critical( 0, tr( "Invalid File" ), |
492 | tr( "There was a problem in getting the file." ) ); | 492 | tr( "There was a problem in getting the file." ) ); |
493 | return; | 493 | return; |
494 | } | 494 | } |
495 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); | 495 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); |
496 | QString extension = fileInfo.extension(false); | 496 | QString extension = fileInfo.extension(false); |
497 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 497 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
498 | readm3u( fileref); | 498 | readm3u( fileref); |
499 | } | 499 | } |
500 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 500 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
501 | readPls( fileref); | 501 | readPls( fileref); |
502 | } | 502 | } |
503 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 503 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
504 | clearList(); | 504 | clearList(); |
505 | lnk.setName( fileInfo.baseName() ); //sets name | 505 | lnk.setName( fileInfo.baseName() ); //sets name |
506 | lnk.setFile( fileref ); //sets file name | 506 | lnk.setFile( fileref ); //sets file name |
507 | lnk.setIcon("Sound"); | 507 | lnk.setIcon("Sound"); |
508 | //addToSelection( lnk ); | 508 | //addToSelection( lnk ); |
509 | 509 | ||
510 | loadList( lnk); | 510 | loadList( lnk); |
511 | d->selectedFiles->first(); | 511 | d->selectedFiles->first(); |
512 | } else { | 512 | } else { |
513 | if( fileref.find(".desktop",0,TRUE) != -1) { | 513 | if( fileref.find(".desktop",0,TRUE) != -1) { |
514 | lnk = DocLnk(fileref); | 514 | lnk = DocLnk(fileref); |
515 | } else { | 515 | } else { |
516 | lnk.setName( fileInfo.baseName() ); //sets name | 516 | lnk.setName( fileInfo.baseName() ); //sets name |
517 | lnk.setFile( fileref ); //sets file name | 517 | lnk.setFile( fileref ); //sets file name |
518 | lnk.setIcon("Sound"); | 518 | lnk.setIcon("Sound"); |
519 | } | 519 | } |
520 | 520 | ||
521 | addToSelection( lnk ); | 521 | addToSelection( lnk ); |
522 | // addToSelection( DocLnk( fileref ) ); | 522 | // addToSelection( DocLnk( fileref ) ); |
@@ -751,385 +751,385 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
751 | }; | 751 | }; |
752 | // case 1: { | 752 | // case 1: { |
753 | DocLnk lnk; | 753 | DocLnk lnk; |
754 | QString filename; | 754 | QString filename; |
755 | 755 | ||
756 | filename=it->text(3); | 756 | filename=it->text(3); |
757 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 757 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
758 | lnk.setFile( filename ); //sets file name | 758 | lnk.setFile( filename ); //sets file name |
759 | d->selectedFiles->addToSelection( lnk); | 759 | d->selectedFiles->addToSelection( lnk); |
760 | 760 | ||
761 | if(tabWidget->currentPageIndex() == 0) | 761 | if(tabWidget->currentPageIndex() == 0) |
762 | writeCurrentM3u(); | 762 | writeCurrentM3u(); |
763 | // tabWidget->setCurrentPage(0); | 763 | // tabWidget->setCurrentPage(0); |
764 | 764 | ||
765 | } | 765 | } |
766 | } | 766 | } |
767 | 767 | ||
768 | void PlayListWidget::tabChanged(QWidget *) { | 768 | void PlayListWidget::tabChanged(QWidget *) { |
769 | 769 | ||
770 | switch ( tabWidget->currentPageIndex()) { | 770 | switch ( tabWidget->currentPageIndex()) { |
771 | case 0: | 771 | case 0: |
772 | { | 772 | { |
773 | if( !tbDeletePlaylist->isHidden()) | 773 | if( !tbDeletePlaylist->isHidden()) |
774 | tbDeletePlaylist->hide(); | 774 | tbDeletePlaylist->hide(); |
775 | d->tbRemoveFromList->setEnabled(TRUE); | 775 | d->tbRemoveFromList->setEnabled(TRUE); |
776 | d->tbAddToList->setEnabled(FALSE); | 776 | d->tbAddToList->setEnabled(FALSE); |
777 | } | 777 | } |
778 | break; | 778 | break; |
779 | case 1: | 779 | case 1: |
780 | { | 780 | { |
781 | audioView->clear(); | 781 | audioView->clear(); |
782 | populateAudioView(); | 782 | populateAudioView(); |
783 | 783 | ||
784 | if( !tbDeletePlaylist->isHidden()) | 784 | if( !tbDeletePlaylist->isHidden()) |
785 | tbDeletePlaylist->hide(); | 785 | tbDeletePlaylist->hide(); |
786 | d->tbRemoveFromList->setEnabled(FALSE); | 786 | d->tbRemoveFromList->setEnabled(FALSE); |
787 | d->tbAddToList->setEnabled(TRUE); | 787 | d->tbAddToList->setEnabled(TRUE); |
788 | } | 788 | } |
789 | break; | 789 | break; |
790 | case 2: | 790 | case 2: |
791 | { | 791 | { |
792 | videoView->clear(); | 792 | videoView->clear(); |
793 | populateVideoView(); | 793 | populateVideoView(); |
794 | if( !tbDeletePlaylist->isHidden()) | 794 | if( !tbDeletePlaylist->isHidden()) |
795 | tbDeletePlaylist->hide(); | 795 | tbDeletePlaylist->hide(); |
796 | d->tbRemoveFromList->setEnabled(FALSE); | 796 | d->tbRemoveFromList->setEnabled(FALSE); |
797 | d->tbAddToList->setEnabled(TRUE); | 797 | d->tbAddToList->setEnabled(TRUE); |
798 | } | 798 | } |
799 | break; | 799 | break; |
800 | case 3: | 800 | case 3: |
801 | { | 801 | { |
802 | if( tbDeletePlaylist->isHidden()) | 802 | if( tbDeletePlaylist->isHidden()) |
803 | tbDeletePlaylist->show(); | 803 | tbDeletePlaylist->show(); |
804 | playLists->reread(); | 804 | playLists->reread(); |
805 | } | 805 | } |
806 | break; | 806 | break; |
807 | }; | 807 | }; |
808 | } | 808 | } |
809 | 809 | ||
810 | void PlayListWidget::btnPlay(bool b) { | 810 | void PlayListWidget::btnPlay(bool b) { |
811 | // mediaPlayerState->setPlaying(b); | 811 | // mediaPlayerState->setPlaying(b); |
812 | switch ( tabWidget->currentPageIndex()) { | 812 | switch ( tabWidget->currentPageIndex()) { |
813 | case 0: | 813 | case 0: |
814 | { | 814 | { |
815 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 815 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
816 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 816 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
817 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 817 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
818 | // } else { | 818 | // } else { |
819 | mediaPlayerState->setPlaying(b); | 819 | mediaPlayerState->setPlaying(b); |
820 | insanityBool=FALSE; | 820 | insanityBool=FALSE; |
821 | qDebug("insanity"); | 821 | qDebug("insanity"); |
822 | // } | 822 | // } |
823 | } | 823 | } |
824 | break; | 824 | break; |
825 | case 1: | 825 | case 1: |
826 | { | 826 | { |
827 | // d->selectedFiles->unSelect(); | 827 | // d->selectedFiles->unSelect(); |
828 | addToSelection( audioView->currentItem() ); | 828 | addToSelection( audioView->currentItem() ); |
829 | mediaPlayerState->setPlaying( b); | 829 | mediaPlayerState->setPlaying( b); |
830 | d->selectedFiles->removeSelected( ); | 830 | d->selectedFiles->removeSelected( ); |
831 | d->selectedFiles->unSelect(); | 831 | d->selectedFiles->unSelect(); |
832 | tabWidget->setCurrentPage(1); | 832 | tabWidget->setCurrentPage(1); |
833 | insanityBool=FALSE; | 833 | insanityBool=FALSE; |
834 | }// audioView->clearSelection(); | 834 | }// audioView->clearSelection(); |
835 | break; | 835 | break; |
836 | case 2: | 836 | case 2: |
837 | { | 837 | { |
838 | 838 | ||
839 | addToSelection( videoView->currentItem() ); | 839 | addToSelection( videoView->currentItem() ); |
840 | mediaPlayerState->setPlaying( b); | 840 | mediaPlayerState->setPlaying( b); |
841 | // qApp->processEvents(); | 841 | // qApp->processEvents(); |
842 | d->selectedFiles->removeSelected( ); | 842 | d->selectedFiles->removeSelected( ); |
843 | d->selectedFiles->unSelect(); | 843 | d->selectedFiles->unSelect(); |
844 | tabWidget->setCurrentPage(2); | 844 | tabWidget->setCurrentPage(2); |
845 | insanityBool=FALSE; | 845 | insanityBool=FALSE; |
846 | }// videoView->clearSelection(); | 846 | }// videoView->clearSelection(); |
847 | break; | 847 | break; |
848 | }; | 848 | }; |
849 | 849 | ||
850 | } | 850 | } |
851 | 851 | ||
852 | void PlayListWidget::deletePlaylist() { | 852 | void PlayListWidget::deletePlaylist() { |
853 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 853 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
854 | (tr("You really want to delete\nthis playlist?")), | 854 | (tr("You really want to delete\nthis playlist?")), |
855 | (tr("Yes")), (tr("No")), 0 )){ | 855 | (tr("Yes")), (tr("No")), 0 )){ |
856 | case 0: // Yes clicked, | 856 | case 0: // Yes clicked, |
857 | QFile().remove(playLists->selectedDocument().file()); | 857 | QFile().remove(playLists->selectedDocument().file()); |
858 | QFile().remove(playLists->selectedDocument().linkFile()); | 858 | QFile().remove(playLists->selectedDocument().linkFile()); |
859 | playLists->reread(); | 859 | playLists->reread(); |
860 | break; | 860 | break; |
861 | case 1: // Cancel | 861 | case 1: // Cancel |
862 | break; | 862 | break; |
863 | }; | 863 | }; |
864 | } | 864 | } |
865 | 865 | ||
866 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 866 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
867 | { | 867 | { |
868 | switch (mouse) { | 868 | switch (mouse) { |
869 | case 1: | 869 | case 1: |
870 | break; | 870 | break; |
871 | case 2:{ | 871 | case 2:{ |
872 | 872 | ||
873 | QPopupMenu m; | 873 | QPopupMenu m; |
874 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 874 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
875 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 875 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
876 | m.insertSeparator(); | 876 | m.insertSeparator(); |
877 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 877 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
878 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 878 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
879 | 879 | ||
880 | m.exec( QCursor::pos() ); | 880 | m.exec( QCursor::pos() ); |
881 | } | 881 | } |
882 | break; | 882 | break; |
883 | }; | 883 | }; |
884 | } | 884 | } |
885 | 885 | ||
886 | void PlayListWidget::playSelected() | 886 | void PlayListWidget::playSelected() |
887 | { | 887 | { |
888 | btnPlay( true); | 888 | btnPlay( true); |
889 | // d->selectedFiles->unSelect(); | 889 | // d->selectedFiles->unSelect(); |
890 | } | 890 | } |
891 | 891 | ||
892 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 892 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
893 | { | 893 | { |
894 | switch (mouse) { | 894 | switch (mouse) { |
895 | case 1: | 895 | case 1: |
896 | 896 | ||
897 | break; | 897 | break; |
898 | case 2:{ | 898 | case 2:{ |
899 | QPopupMenu m; | 899 | QPopupMenu m; |
900 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 900 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
901 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 901 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
902 | // m.insertSeparator(); | 902 | // m.insertSeparator(); |
903 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 903 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
904 | m.exec( QCursor::pos() ); | 904 | m.exec( QCursor::pos() ); |
905 | } | 905 | } |
906 | break; | 906 | break; |
907 | }; | 907 | }; |
908 | 908 | ||
909 | } | 909 | } |
910 | 910 | ||
911 | void PlayListWidget::listDelete() { | 911 | void PlayListWidget::listDelete() { |
912 | Config cfg( "OpiePlayer" ); | 912 | Config cfg( "OpiePlayer" ); |
913 | cfg.setGroup("PlayList"); | 913 | cfg.setGroup("PlayList"); |
914 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 914 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
915 | QString file; | 915 | QString file; |
916 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 916 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
917 | switch ( tabWidget->currentPageIndex()) { | 917 | switch ( tabWidget->currentPageIndex()) { |
918 | case 0: | 918 | case 0: |
919 | break; | 919 | break; |
920 | case 1: | 920 | case 1: |
921 | { | 921 | { |
922 | file = audioView->currentItem()->text(0); | 922 | file = audioView->currentItem()->text(0); |
923 | QListIterator<DocLnk> Pdit( files.children() ); | 923 | QListIterator<DocLnk> Pdit( files.children() ); |
924 | for ( ; Pdit.current(); ++Pdit ) { | 924 | for ( ; Pdit.current(); ++Pdit ) { |
925 | if( Pdit.current()->name() == file) { | 925 | if( Pdit.current()->name() == file) { |
926 | LnkProperties prop( Pdit.current() ); | 926 | LnkProperties prop( Pdit.current() ); |
927 | QPEApplication::execDialog( &prop ); | 927 | QPEApplication::execDialog( &prop ); |
928 | } | 928 | } |
929 | } | 929 | } |
930 | populateAudioView(); | 930 | populateAudioView(); |
931 | } | 931 | } |
932 | break; | 932 | break; |
933 | case 2: | 933 | case 2: |
934 | { | 934 | { |
935 | // file = videoView->selectedItem()->text(0); | 935 | // file = videoView->selectedItem()->text(0); |
936 | // for ( int i = 0; i < noOfFiles; i++ ) { | 936 | // for ( int i = 0; i < noOfFiles; i++ ) { |
937 | // QString entryName; | 937 | // QString entryName; |
938 | // entryName.sprintf( "File%i", i + 1 ); | 938 | // entryName.sprintf( "File%i", i + 1 ); |
939 | // QString linkFile = cfg.readEntry( entryName ); | 939 | // QString linkFile = cfg.readEntry( entryName ); |
940 | // AppLnk lnk( AppLnk(linkFile)); | 940 | // AppLnk lnk( AppLnk(linkFile)); |
941 | // if( lnk.name() == file ) { | 941 | // if( lnk.name() == file ) { |
942 | // LnkProperties prop( &lnk); | 942 | // LnkProperties prop( &lnk); |
943 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 943 | // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); |
944 | // prop.showMaximized(); | 944 | // prop.showMaximized(); |
945 | // prop.exec(); | 945 | // prop.exec(); |
946 | // } | 946 | // } |
947 | // } | 947 | // } |
948 | } | 948 | } |
949 | break; | 949 | break; |
950 | }; | 950 | }; |
951 | } | 951 | } |
952 | 952 | ||
953 | void PlayListWidget::scanForAudio() { | 953 | void PlayListWidget::scanForAudio() { |
954 | // qDebug("scan for audio"); | 954 | // qDebug("scan for audio"); |
955 | files.detachChildren(); | 955 | files.detachChildren(); |
956 | QListIterator<DocLnk> sdit( files.children() ); | 956 | QListIterator<DocLnk> sdit( files.children() ); |
957 | for ( ; sdit.current(); ++sdit ) { | 957 | for ( ; sdit.current(); ++sdit ) { |
958 | delete sdit.current(); | 958 | delete sdit.current(); |
959 | } | 959 | } |
960 | Global::findDocuments( &files, audioMimes); | 960 | Global::findDocuments( &files, audioMimes); |
961 | audioScan = true; | 961 | audioScan = true; |
962 | } | 962 | } |
963 | void PlayListWidget::scanForVideo() { | 963 | void PlayListWidget::scanForVideo() { |
964 | // qDebug("scan for video"); | 964 | // qDebug("scan for video"); |
965 | vFiles.detachChildren(); | 965 | vFiles.detachChildren(); |
966 | QListIterator<DocLnk> sdit( vFiles.children() ); | 966 | QListIterator<DocLnk> sdit( vFiles.children() ); |
967 | for ( ; sdit.current(); ++sdit ) { | 967 | for ( ; sdit.current(); ++sdit ) { |
968 | delete sdit.current(); | 968 | delete sdit.current(); |
969 | } | 969 | } |
970 | Global::findDocuments(&vFiles, "video/*"); | 970 | Global::findDocuments(&vFiles, "video/*"); |
971 | videoScan = true; | 971 | videoScan = true; |
972 | } | 972 | } |
973 | 973 | ||
974 | void PlayListWidget::populateAudioView() { | 974 | void PlayListWidget::populateAudioView() { |
975 | 975 | ||
976 | audioView->clear(); | 976 | audioView->clear(); |
977 | StorageInfo storageInfo; | 977 | StorageInfo storageInfo; |
978 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 978 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
979 | if(!audioScan) scanForAudio(); | 979 | if(!audioScan) scanForAudio(); |
980 | 980 | ||
981 | QListIterator<DocLnk> dit( files.children() ); | 981 | QListIterator<DocLnk> dit( files.children() ); |
982 | QListIterator<FileSystem> it ( fs ); | 982 | QListIterator<FileSystem> it ( fs ); |
983 | 983 | ||
984 | QString storage; | 984 | QString storage; |
985 | for ( ; dit.current(); ++dit ) { | 985 | for ( ; dit.current(); ++dit ) { |
986 | for( ; it.current(); ++it ){ | 986 | for( ; it.current(); ++it ){ |
987 | const QString name = (*it)->name(); | 987 | const QString name = (*it)->name(); |
988 | const QString path = (*it)->path(); | 988 | const QString path = (*it)->path(); |
989 | if(dit.current()->file().find(path) != -1 ) storage=name; | 989 | if(dit.current()->file().find(path) != -1 ) storage=name; |
990 | } | 990 | } |
991 | 991 | ||
992 | QListViewItem * newItem; | 992 | QListViewItem * newItem; |
993 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 993 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
994 | long size; | 994 | long size; |
995 | if( dit.current()->file().left(4) == "http" ) | 995 | if( dit.current()->file().left(4) == "http" ) |
996 | size=0; | 996 | size=0; |
997 | else | 997 | else |
998 | size = QFile( dit.current()->file() ).size(); | 998 | size = QFile( dit.current()->file() ).size(); |
999 | // qDebug(dit.current()->name()); | 999 | // qDebug(dit.current()->name()); |
1000 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1000 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1001 | QString::number(size ), storage, dit.current()->file()); | 1001 | QString::number(size ), storage, dit.current()->file()); |
1002 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1002 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1003 | } | 1003 | } |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void PlayListWidget::populateVideoView() { | 1008 | void PlayListWidget::populateVideoView() { |
1009 | videoView->clear(); | 1009 | videoView->clear(); |
1010 | StorageInfo storageInfo; | 1010 | StorageInfo storageInfo; |
1011 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1011 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1012 | 1012 | ||
1013 | if(!videoScan ) scanForVideo(); | 1013 | if(!videoScan ) scanForVideo(); |
1014 | 1014 | ||
1015 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1015 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1016 | QListIterator<FileSystem> it ( fs ); | 1016 | QListIterator<FileSystem> it ( fs ); |
1017 | videoView->clear(); | 1017 | videoView->clear(); |
1018 | QString storage; | 1018 | QString storage; |
1019 | for ( ; Vdit.current(); ++Vdit ) { | 1019 | for ( ; Vdit.current(); ++Vdit ) { |
1020 | for( ; it.current(); ++it ){ | 1020 | for( ; it.current(); ++it ){ |
1021 | const QString name = (*it)->name(); | 1021 | const QString name = (*it)->name(); |
1022 | const QString path = (*it)->path(); | 1022 | const QString path = (*it)->path(); |
1023 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1023 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | QListViewItem * newItem; | 1026 | QListViewItem * newItem; |
1027 | if ( QFile( Vdit.current()->file()).exists() ) { | 1027 | if ( QFile( Vdit.current()->file()).exists() ) { |
1028 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1028 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1029 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1029 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1030 | storage, Vdit.current()->file()); | 1030 | storage, Vdit.current()->file()); |
1031 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1031 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1032 | } | 1032 | } |
1033 | } | 1033 | } |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | void PlayListWidget::openFile() { | 1036 | void PlayListWidget::openFile() { |
1037 | QString filename, name; | 1037 | QString filename, name; |
1038 | InputDialog *fileDlg; | 1038 | InputDialog *fileDlg; |
1039 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1039 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1040 | fileDlg->exec(); | 1040 | fileDlg->exec(); |
1041 | if( fileDlg->result() == 1 ) { | 1041 | if( fileDlg->result() == 1 ) { |
1042 | filename = fileDlg->text(); | 1042 | filename = fileDlg->text(); |
1043 | // qDebug( "Selected filename is " + filename ); | 1043 | // qDebug( "Selected filename is " + filename ); |
1044 | DocLnk lnk; | 1044 | DocLnk lnk; |
1045 | Config cfg( "OpiePlayer" ); | 1045 | Config cfg( "OpiePlayer" ); |
1046 | cfg.setGroup("PlayList"); | 1046 | cfg.setGroup("PlayList"); |
1047 | 1047 | ||
1048 | QString m3uFile; | 1048 | QString m3uFile; |
1049 | m3uFile = filename; | 1049 | m3uFile = filename; |
1050 | if(filename.left(4) == "http") { | 1050 | if(filename.left(4) == "http") { |
1051 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1051 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1052 | 1052 | ||
1053 | m3uFile = filename; | 1053 | m3uFile = filename; |
1054 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1054 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1055 | m3uFile += "/"; | 1055 | m3uFile += "/"; |
1056 | } | 1056 | } |
1057 | filename = m3uFile; | 1057 | filename = m3uFile; |
1058 | } | 1058 | } |
1059 | lnk.setName( m3uFile ); //sets name | 1059 | lnk.setName( m3uFile ); //sets name |
1060 | lnk.setFile( filename ); //sets file name | 1060 | lnk.setFile( filename ); //sets file name |
1061 | lnk.setIcon("opieplayer2/musicfile"); | 1061 | lnk.setIcon("opieplayer2/musicfile"); |
1062 | d->selectedFiles->addToSelection( lnk ); | 1062 | d->selectedFiles->addToSelection( lnk ); |
1063 | writeCurrentM3u(); | 1063 | writeCurrentM3u(); |
1064 | } | 1064 | } |
1065 | else if( filename.right( 3) == "m3u" ) { | 1065 | else if( filename.right( 3) == "m3u" ) { |
1066 | readm3u( filename ); | 1066 | readm3u( filename ); |
1067 | 1067 | ||
1068 | } else if( filename.right(3) == "pls" ) { | 1068 | } else if( filename.right(3) == "pls" ) { |
1069 | readPls( filename ); | 1069 | readPls( filename ); |
1070 | } else { | 1070 | } else { |
1071 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1071 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1072 | lnk.setFile( filename ); //sets file name | 1072 | lnk.setFile( filename ); //sets file name |
1073 | d->selectedFiles->addToSelection( lnk); | 1073 | d->selectedFiles->addToSelection( lnk); |
1074 | lnk.removeLinkFile(); | 1074 | lnk.removeLinkFile(); |
1075 | writeCurrentM3u(); | 1075 | writeCurrentM3u(); |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | if( fileDlg ) { | 1079 | if( fileDlg ) { |
1080 | delete fileDlg; | 1080 | delete fileDlg; |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | 1084 | ||
1085 | /* | 1085 | /* |
1086 | reads m3u and shows files/urls to playlist widget */ | 1086 | reads m3u and shows files/urls to playlist widget */ |
1087 | void PlayListWidget::readm3u( const QString &filename ) { | 1087 | void PlayListWidget::readm3u( const QString &filename ) { |
1088 | // qDebug( "read m3u filename " + filename ); | 1088 | // qDebug( "read m3u filename " + filename ); |
1089 | 1089 | ||
1090 | Om3u *m3uList; | 1090 | Om3u *m3uList; |
1091 | QString s, name; | 1091 | QString s, name; |
1092 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1092 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1093 | m3uList->readM3u(); | 1093 | m3uList->readM3u(); |
1094 | DocLnk lnk; | 1094 | DocLnk lnk; |
1095 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1095 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1096 | s = *it; | 1096 | s = *it; |
1097 | // qDebug("reading "+ s); | 1097 | // qDebug("reading "+ s); |
1098 | if(s.left(4)=="http") { | 1098 | if(s.left(4)=="http") { |
1099 | lnk.setName( s ); //sets file name | 1099 | lnk.setName( s ); //sets file name |
1100 | lnk.setIcon("opieplayer2/musicfile"); | 1100 | lnk.setIcon("opieplayer2/musicfile"); |
1101 | 1101 | ||
1102 | // if(s.right(4) != '.' || s.right(5) != '.') | 1102 | // if(s.right(4) != '.' || s.right(5) != '.') |
1103 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1103 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1104 | if( s.right(1) != "/") | 1104 | if( s.right(1) != "/") |
1105 | lnk.setFile( s+"/"); //if url with no extension | 1105 | lnk.setFile( s+"/"); //if url with no extension |
1106 | else | 1106 | else |
1107 | lnk.setFile( s ); //sets file name | 1107 | lnk.setFile( s ); //sets file name |
1108 | 1108 | ||
1109 | } else { | 1109 | } else { |
1110 | // if( QFileInfo( s ).exists() ) { | 1110 | // if( QFileInfo( s ).exists() ) { |
1111 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1111 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1112 | // if(s.right(4) == '.') {//if regular file | 1112 | // if(s.right(4) == '.') {//if regular file |
1113 | if(s.left(1) != "/") { | 1113 | if(s.left(1) != "/") { |
1114 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1114 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1115 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1115 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1116 | lnk.setIcon("SoundPlayer"); | 1116 | lnk.setIcon("SoundPlayer"); |
1117 | } else { | 1117 | } else { |
1118 | // qDebug("set link2 "+s); | 1118 | // qDebug("set link2 "+s); |
1119 | lnk.setFile( s); | 1119 | lnk.setFile( s); |
1120 | lnk.setIcon("SoundPlayer"); | 1120 | lnk.setIcon("SoundPlayer"); |
1121 | } | 1121 | } |
1122 | } | 1122 | } |
1123 | d->selectedFiles->addToSelection( lnk ); | 1123 | d->selectedFiles->addToSelection( lnk ); |
1124 | } | 1124 | } |
1125 | Config config( "OpiePlayer" ); | 1125 | Config config( "OpiePlayer" ); |
1126 | config.setGroup( "PlayList" ); | 1126 | config.setGroup( "PlayList" ); |
1127 | 1127 | ||
1128 | config.writeEntry("CurrentPlaylist",filename); | 1128 | config.writeEntry("CurrentPlaylist",filename); |
1129 | config.write(); | 1129 | config.write(); |
1130 | currentPlayList=filename; | 1130 | currentPlayList=filename; |
1131 | 1131 | ||
1132 | // m3uList->write(); | 1132 | // m3uList->write(); |
1133 | m3uList->close(); | 1133 | m3uList->close(); |
1134 | if(m3uList) delete m3uList; | 1134 | if(m3uList) delete m3uList; |
1135 | 1135 | ||
diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp index 4034560..28f9b5b 100644 --- a/core/obex/obexhandler.cpp +++ b/core/obex/obexhandler.cpp | |||
@@ -1,67 +1,67 @@ | |||
1 | 1 | ||
2 | #include <qpe/qcopenvelope_qws.h> | 2 | #include <qpe/qcopenvelope_qws.h> |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | 4 | ||
5 | #include "obexsend.h" | 5 | #include "obexsend.h" |
6 | #include "receiver.h" | 6 | #include "receiver.h" |
7 | #include "obexhandler.h" | 7 | #include "obexhandler.h" |
8 | 8 | ||
9 | using namespace OpieObex; | 9 | using namespace OpieObex; |
10 | 10 | ||
11 | /* TRANSLATOR OpieObex::ObexHandler */ | 11 | /* TRANSLATOR OpieObex::ObexHandler */ |
12 | 12 | ||
13 | ObexHandler::ObexHandler() { | 13 | ObexHandler::ObexHandler() { |
14 | m_wasRec = false; | 14 | m_wasRec = false; |
15 | m_sender = 0l; | 15 | m_sender = 0l; |
16 | m_receiver = 0l; | 16 | m_receiver = 0l; |
17 | QCopChannel* chan = new QCopChannel("QPE/Obex"); | 17 | QCopChannel* chan = new QCopChannel("QPE/Obex"); |
18 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 18 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
19 | this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) ); | 19 | this, SLOT(irdaMessage(const QCString&,const QByteArray&) ) ); |
20 | } | 20 | } |
21 | ObexHandler::~ObexHandler() { | 21 | ObexHandler::~ObexHandler() { |
22 | delete m_sender; | 22 | delete m_sender; |
23 | delete m_receiver; | 23 | delete m_receiver; |
24 | } | 24 | } |
25 | void ObexHandler::doSend(const QString& str, const QString& desc) { | 25 | void ObexHandler::doSend(const QString& str, const QString& desc) { |
26 | delete m_sender; | 26 | delete m_sender; |
27 | m_sender = new SendWidget; | 27 | m_sender = new SendWidget; |
28 | m_sender->raise(); | 28 | m_sender->raise(); |
29 | QPEApplication::showWidget( m_sender ); | 29 | QPEApplication::showWidget( m_sender ); |
30 | connect(m_sender, SIGNAL(done() ), | 30 | connect(m_sender, SIGNAL(done() ), |
31 | this, SLOT(slotSent() ) ); | 31 | this, SLOT(slotSent() ) ); |
32 | m_sender->send( str, desc ); | 32 | m_sender->send( str, desc ); |
33 | } | 33 | } |
34 | void ObexHandler::doReceive(bool b) { | 34 | void ObexHandler::doReceive(bool b) { |
35 | if (m_receiver && b ) return; // we should enable receiver and it is on | 35 | if (m_receiver && b ) return; // we should enable receiver and it is on |
36 | else if (!m_receiver && !b ) return; // we should disbale receiver and it is off | 36 | else if (!m_receiver && !b ) return; // we should disbale receiver and it is off |
37 | else if (m_receiver && !b ) { | 37 | else if (m_receiver && !b ) { |
38 | delete m_receiver; | 38 | delete m_receiver; |
39 | m_receiver=0; | 39 | m_receiver=0; |
40 | }else if (!m_receiver && b ) { | 40 | }else if (!m_receiver && b ) { |
41 | m_receiver= new Receiver; | 41 | m_receiver= new Receiver; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | void ObexHandler::slotSent() { | 44 | void ObexHandler::slotSent() { |
45 | QString file = m_sender->file(); | 45 | QString file = m_sender->file(); |
46 | delete m_sender; | 46 | delete m_sender; |
47 | m_sender = 0; | 47 | m_sender = 0; |
48 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); | 48 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); |
49 | e << file; | 49 | e << file; |
50 | doReceive(m_wasRec ); | 50 | doReceive(m_wasRec ); |
51 | m_wasRec = false; | 51 | m_wasRec = false; |
52 | } | 52 | } |
53 | void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { | 53 | void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { |
54 | QDataStream stream( data, IO_ReadOnly ); | 54 | QDataStream stream( data, IO_ReadOnly ); |
55 | if ( msg == "send(QString,QString,QString)" ) { | 55 | if ( msg == "send(QString,QString,QString)" ) { |
56 | QString name, desc; | 56 | QString name, desc; |
57 | stream >> desc; | 57 | stream >> desc; |
58 | stream >> name; | 58 | stream >> name; |
59 | m_wasRec = (m_receiver != 0 ); | 59 | m_wasRec = (m_receiver != 0 ); |
60 | doReceive( false ); | 60 | doReceive( false ); |
61 | doSend(name, desc); | 61 | doSend(name, desc); |
62 | }else if (msg == "receive(int)") { | 62 | }else if (msg == "receive(int)") { |
63 | int rec; | 63 | int rec; |
64 | stream >> rec; | 64 | stream >> rec; |
65 | doReceive(rec); | 65 | doReceive(rec); |
66 | } | 66 | } |
67 | } | 67 | } |
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index 6b8d467..cd8d58e 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp | |||
@@ -1,254 +1,254 @@ | |||
1 | #include <qpushbutton.h> | 1 | #include <qpushbutton.h> |
2 | #include <qlabel.h> | 2 | #include <qlabel.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | 5 | ||
6 | 6 | ||
7 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
8 | 8 | ||
9 | #include "obex.h" | 9 | #include "obex.h" |
10 | #include "obexsend.h" | 10 | #include "obexsend.h" |
11 | 11 | ||
12 | using namespace OpieObex; | 12 | using namespace OpieObex; |
13 | 13 | ||
14 | /* TRANSLATOR OpieObex::SendWidget */ | 14 | /* TRANSLATOR OpieObex::SendWidget */ |
15 | 15 | ||
16 | 16 | ||
17 | SendWidget::SendWidget( QWidget* parent, const char* name ) | 17 | SendWidget::SendWidget( QWidget* parent, const char* name ) |
18 | : QWidget( parent, name ) { | 18 | : QWidget( parent, name ) { |
19 | initUI(); | 19 | initUI(); |
20 | } | 20 | } |
21 | SendWidget::~SendWidget() { | 21 | SendWidget::~SendWidget() { |
22 | } | 22 | } |
23 | void SendWidget::initUI() { | 23 | void SendWidget::initUI() { |
24 | m_obex = new Obex(this, "obex"); | 24 | m_obex = new Obex(this, "obex"); |
25 | connect(m_obex, SIGNAL(error(int) ), | 25 | connect(m_obex, SIGNAL(error(int) ), |
26 | this, SLOT(slotIrError(int) ) ); | 26 | this, SLOT(slotIrError(int) ) ); |
27 | connect(m_obex, SIGNAL(sent(bool) ), | 27 | connect(m_obex, SIGNAL(sent(bool) ), |
28 | this, SLOT(slotIrSent(bool) ) ); | 28 | this, SLOT(slotIrSent(bool) ) ); |
29 | connect(m_obex, SIGNAL(currentTry(unsigned int ) ), | 29 | connect(m_obex, SIGNAL(currentTry(unsigned int) ), |
30 | this, SLOT(slotIrTry(unsigned int ) ) ); | 30 | this, SLOT(slotIrTry(unsigned int) ) ); |
31 | 31 | ||
32 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); | 32 | QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); |
33 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 33 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
34 | this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); | 34 | this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) ); |
35 | 35 | ||
36 | chan = new QCopChannel("QPE/BluetoothBack", this ); | 36 | chan = new QCopChannel("QPE/BluetoothBack", this ); |
37 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 37 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
38 | this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); | 38 | this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) ); |
39 | 39 | ||
40 | QVBoxLayout* lay = new QVBoxLayout(this); | 40 | QVBoxLayout* lay = new QVBoxLayout(this); |
41 | 41 | ||
42 | QHBox* nameBox = new QHBox(this); | 42 | QHBox* nameBox = new QHBox(this); |
43 | QLabel* name = new QLabel(nameBox); | 43 | QLabel* name = new QLabel(nameBox); |
44 | name->setText( tr("<qt><h1>Sending:</h1></qt>") ); | 44 | name->setText( tr("<qt><h1>Sending:</h1></qt>") ); |
45 | name->setAlignment( AlignLeft | AlignTop ); | 45 | name->setAlignment( AlignLeft | AlignTop ); |
46 | m_lblFile = new QLabel(nameBox); | 46 | m_lblFile = new QLabel(nameBox); |
47 | lay->addWidget(nameBox, 0); | 47 | lay->addWidget(nameBox, 0); |
48 | 48 | ||
49 | QFrame* frame = new QFrame(this); | 49 | QFrame* frame = new QFrame(this); |
50 | frame->setFrameShape( QFrame::HLine ); | 50 | frame->setFrameShape( QFrame::HLine ); |
51 | frame->setFrameShadow( QFrame::Sunken ); | 51 | frame->setFrameShadow( QFrame::Sunken ); |
52 | lay->addWidget(frame, 10); | 52 | lay->addWidget(frame, 10); |
53 | 53 | ||
54 | QLabel* devices = new QLabel(this); | 54 | QLabel* devices = new QLabel(this); |
55 | devices->setText("<qt><b>Devices:</b></qt>"); | 55 | devices->setText("<qt><b>Devices:</b></qt>"); |
56 | devices->setAlignment( AlignLeft | AlignTop ); | 56 | devices->setAlignment( AlignLeft | AlignTop ); |
57 | lay->addWidget( devices,10 ); | 57 | lay->addWidget( devices,10 ); |
58 | 58 | ||
59 | m_devBox = new DeviceBox(this); | 59 | m_devBox = new DeviceBox(this); |
60 | lay->addWidget( m_devBox, 50 ); | 60 | lay->addWidget( m_devBox, 50 ); |
61 | connect(m_devBox, SIGNAL(selectedDevice(int, int ) ), | 61 | connect(m_devBox, SIGNAL(selectedDevice(int,int) ), |
62 | this, SLOT(slotSelectedDevice(int, int) ) ); | 62 | this, SLOT(slotSelectedDevice(int,int) ) ); |
63 | 63 | ||
64 | QPushButton *but = new QPushButton(this); | 64 | QPushButton *but = new QPushButton(this); |
65 | but->setText(tr("Done") ); | 65 | but->setText(tr("Done") ); |
66 | connect(but, SIGNAL(clicked() ), | 66 | connect(but, SIGNAL(clicked() ), |
67 | this, SLOT(slotDone() ) ); | 67 | this, SLOT(slotDone() ) ); |
68 | 68 | ||
69 | lay->addWidget( but ); | 69 | lay->addWidget( but ); |
70 | m_lay = lay; | 70 | m_lay = lay; |
71 | 71 | ||
72 | // QT does not like if you add items to an layout which already exits.... | 72 | // QT does not like if you add items to an layout which already exits.... |
73 | // and was layouted invalidate() does not help too | 73 | // and was layouted invalidate() does not help too |
74 | // so we use RichText.... | 74 | // so we use RichText.... |
75 | } | 75 | } |
76 | 76 | ||
77 | /* | 77 | /* |
78 | * in send we'll first set everything up | 78 | * in send we'll first set everything up |
79 | * and then wait for a list of devices. | 79 | * and then wait for a list of devices. |
80 | */ | 80 | */ |
81 | void SendWidget::send( const QString& file, const QString& desc ) { | 81 | void SendWidget::send( const QString& file, const QString& desc ) { |
82 | m_file = file; | 82 | m_file = file; |
83 | m_irDa.clear(); | 83 | m_irDa.clear(); |
84 | m_start = 0; | 84 | m_start = 0; |
85 | m_lblFile->setText(desc.isEmpty() ? file : desc ); | 85 | m_lblFile->setText(desc.isEmpty() ? file : desc ); |
86 | 86 | ||
87 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { | 87 | if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { |
88 | m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); | 88 | m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); |
89 | m_start++; | 89 | m_start++; |
90 | }else | 90 | }else |
91 | m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); | 91 | m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); |
92 | 92 | ||
93 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { | 93 | if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { |
94 | m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); | 94 | m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); |
95 | m_start++; | 95 | m_start++; |
96 | }else | 96 | }else |
97 | m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); | 97 | m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); |
98 | 98 | ||
99 | if (m_start != 2 ) { | 99 | if (m_start != 2 ) { |
100 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); | 100 | QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); |
101 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); | 101 | QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); |
102 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 102 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
103 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); | 103 | QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | void SendWidget::slotIrDaDevices( const QStringList& list) { | 106 | void SendWidget::slotIrDaDevices( const QStringList& list) { |
107 | qWarning("slot it irda devices "); | 107 | qWarning("slot it irda devices "); |
108 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 108 | for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
109 | int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); | 109 | int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); |
110 | m_irDa.insert( id, (*it) ); | 110 | m_irDa.insert( id, (*it) ); |
111 | } | 111 | } |
112 | m_devBox->removeDevice( m_irDeSearch ); | 112 | m_devBox->removeDevice( m_irDeSearch ); |
113 | m_irDaIt = m_irDa.begin(); | 113 | m_irDaIt = m_irDa.begin(); |
114 | 114 | ||
115 | slotStartIrda(); | 115 | slotStartIrda(); |
116 | } | 116 | } |
117 | 117 | ||
118 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { | 118 | void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { |
119 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { | 119 | for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { |
120 | int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); | 120 | int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); |
121 | m_bt.insert( id, Pair( it.key(), it.data() ) ); | 121 | m_bt.insert( id, Pair( it.key(), it.data() ) ); |
122 | } | 122 | } |
123 | m_devBox->removeDevice( m_btDeSearch ); | 123 | m_devBox->removeDevice( m_btDeSearch ); |
124 | } | 124 | } |
125 | void SendWidget::slotSelectedDevice( int name, int dev ) { | 125 | void SendWidget::slotSelectedDevice( int name, int dev ) { |
126 | qWarning("Start beam? %d %d", name, dev ); | 126 | qWarning("Start beam? %d %d", name, dev ); |
127 | if ( name == m_irDeSearch ) { | 127 | if ( name == m_irDeSearch ) { |
128 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) | 128 | for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) |
129 | m_devBox->removeDevice( it.key() ); | 129 | m_devBox->removeDevice( it.key() ); |
130 | 130 | ||
131 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); | 131 | QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { | 134 | void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { |
135 | qWarning("dispatch irda %s", str.data() ); | 135 | qWarning("dispatch irda %s", str.data() ); |
136 | if ( str == "devices(QStringList)" ) { | 136 | if ( str == "devices(QStringList)" ) { |
137 | QDataStream stream( ar, IO_ReadOnly ); | 137 | QDataStream stream( ar, IO_ReadOnly ); |
138 | QStringList list; | 138 | QStringList list; |
139 | stream >> list; | 139 | stream >> list; |
140 | slotIrDaDevices( list ); | 140 | slotIrDaDevices( list ); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { | 143 | void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { |
144 | 144 | ||
145 | } | 145 | } |
146 | void SendWidget::slotIrError( int ) { | 146 | void SendWidget::slotIrError( int ) { |
147 | 147 | ||
148 | } | 148 | } |
149 | void SendWidget::slotIrSent( bool b) { | 149 | void SendWidget::slotIrSent( bool b) { |
150 | qWarning("irda sent!!"); | 150 | qWarning("irda sent!!"); |
151 | QString text = b ? tr("Sent") : tr("Failure"); | 151 | QString text = b ? tr("Sent") : tr("Failure"); |
152 | m_devBox->setStatus( m_irDaIt.key(), text ); | 152 | m_devBox->setStatus( m_irDaIt.key(), text ); |
153 | ++m_irDaIt; | 153 | ++m_irDaIt; |
154 | slotStartIrda(); | 154 | slotStartIrda(); |
155 | } | 155 | } |
156 | void SendWidget::slotIrTry(unsigned int trI) { | 156 | void SendWidget::slotIrTry(unsigned int trI) { |
157 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); | 157 | m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); |
158 | } | 158 | } |
159 | void SendWidget::slotStartIrda() { | 159 | void SendWidget::slotStartIrda() { |
160 | if (m_irDaIt == m_irDa.end() ) { | 160 | if (m_irDaIt == m_irDa.end() ) { |
161 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); | 161 | m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); | 164 | m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); |
165 | m_obex->send( m_file ); | 165 | m_obex->send( m_file ); |
166 | } | 166 | } |
167 | void SendWidget::closeEvent( QCloseEvent* e) { | 167 | void SendWidget::closeEvent( QCloseEvent* e) { |
168 | e->accept(); // make sure | 168 | e->accept(); // make sure |
169 | QTimer::singleShot(0, this, SLOT(slotDone() ) ); | 169 | QTimer::singleShot(0, this, SLOT(slotDone() ) ); |
170 | } | 170 | } |
171 | void SendWidget::slotDone() { | 171 | void SendWidget::slotDone() { |
172 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); | 172 | QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); |
173 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); | 173 | QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); |
174 | emit done(); | 174 | emit done(); |
175 | } | 175 | } |
176 | QString SendWidget::file()const { | 176 | QString SendWidget::file()const { |
177 | return m_file; | 177 | return m_file; |
178 | } | 178 | } |
179 | DeviceBox::DeviceBox( QWidget* parent ) | 179 | DeviceBox::DeviceBox( QWidget* parent ) |
180 | : QTextBrowser( parent ) { | 180 | : QTextBrowser( parent ) { |
181 | 181 | ||
182 | } | 182 | } |
183 | DeviceBox::~DeviceBox() { | 183 | DeviceBox::~DeviceBox() { |
184 | 184 | ||
185 | } | 185 | } |
186 | int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { | 186 | int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { |
187 | /* return a id for a range of devices */ | 187 | /* return a id for a range of devices */ |
188 | int id = idFor ( dev ); | 188 | int id = idFor ( dev ); |
189 | DeviceItem item( name, status, dev,id ); | 189 | DeviceItem item( name, status, dev,id ); |
190 | m_dev.insert( id, item ); | 190 | m_dev.insert( id, item ); |
191 | setText( allText() ); | 191 | setText( allText() ); |
192 | 192 | ||
193 | return id; | 193 | return id; |
194 | } | 194 | } |
195 | void DeviceBox::removeDevice( int id ) { | 195 | void DeviceBox::removeDevice( int id ) { |
196 | if (!m_dev.contains(id) ) return; | 196 | if (!m_dev.contains(id) ) return; |
197 | 197 | ||
198 | m_dev.remove( id ); | 198 | m_dev.remove( id ); |
199 | setText( allText() ); | 199 | setText( allText() ); |
200 | } | 200 | } |
201 | void DeviceBox::setStatus( int id, const QString& status ) { | 201 | void DeviceBox::setStatus( int id, const QString& status ) { |
202 | if ( !m_dev.contains(id) ) return; | 202 | if ( !m_dev.contains(id) ) return; |
203 | m_dev[id].setStatus(status ); | 203 | m_dev[id].setStatus(status ); |
204 | setText( allText() ); | 204 | setText( allText() ); |
205 | } | 205 | } |
206 | void DeviceBox::setSource( const QString& str ) { | 206 | void DeviceBox::setSource( const QString& str ) { |
207 | qWarning("SetSource:%d", str.toInt() ); | 207 | qWarning("SetSource:%d", str.toInt() ); |
208 | int id = str.toInt(); | 208 | int id = str.toInt(); |
209 | emit selectedDevice( id, m_dev[id].device() ); | 209 | emit selectedDevice( id, m_dev[id].device() ); |
210 | } | 210 | } |
211 | int DeviceBox::idFor ( int id ) { | 211 | int DeviceBox::idFor ( int id ) { |
212 | static int irId = 1501; | 212 | static int irId = 1501; |
213 | static int irBT = 1001; | 213 | static int irBT = 1001; |
214 | static int irSr = 501; | 214 | static int irSr = 501; |
215 | static int irEr = 0; | 215 | static int irEr = 0; |
216 | 216 | ||
217 | int ret = -1; | 217 | int ret = -1; |
218 | switch(id ) { | 218 | switch(id ) { |
219 | case IrDa: | 219 | case IrDa: |
220 | ret = irId; | 220 | ret = irId; |
221 | irId++; | 221 | irId++; |
222 | break; | 222 | break; |
223 | case BT: | 223 | case BT: |
224 | ret = irBT; | 224 | ret = irBT; |
225 | irBT++; | 225 | irBT++; |
226 | break; | 226 | break; |
227 | case Search: | 227 | case Search: |
228 | ret = irSr; | 228 | ret = irSr; |
229 | irSr++; | 229 | irSr++; |
230 | break; | 230 | break; |
231 | case Error: | 231 | case Error: |
232 | ret = irEr; | 232 | ret = irEr; |
233 | irEr++; | 233 | irEr++; |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | return ret; | 236 | return ret; |
237 | } | 237 | } |
238 | QString DeviceBox::allText() { | 238 | QString DeviceBox::allText() { |
239 | QString str; | 239 | QString str; |
240 | typedef QMap<int, DeviceItem> DeviceMap; | 240 | typedef QMap<int, DeviceItem> DeviceMap; |
241 | 241 | ||
242 | for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) { | 242 | for (QMap<int, DeviceItem>::Iterator it = m_dev.begin(); it != m_dev.end(); ++it ) { |
243 | str += it.data().toString() + "<br>"; | 243 | str += it.data().toString() + "<br>"; |
244 | } | 244 | } |
245 | return str; | 245 | return str; |
246 | } | 246 | } |
247 | 247 | ||
248 | DeviceItem::DeviceItem( const QString& name, | 248 | DeviceItem::DeviceItem( const QString& name, |
249 | const QString& status, int dev, int id) | 249 | const QString& status, int dev, int id) |
250 | { | 250 | { |
251 | m_name = name; | 251 | m_name = name; |
252 | m_status = status; | 252 | m_status = status; |
253 | m_dev = dev; | 253 | m_dev = dev; |
254 | m_id = id; | 254 | m_id = id; |
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index 7d9f7ec..ee2668b 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp | |||
@@ -1,199 +1,199 @@ | |||
1 | #include <sys/types.h> | 1 | #include <sys/types.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/mman.h> | 3 | #include <sys/mman.h> |
4 | #include <stdlib.h> // int system | 4 | #include <stdlib.h> // int system |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | 6 | ||
7 | #include <fcntl.h> | 7 | #include <fcntl.h> |
8 | 8 | ||
9 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qtextview.h> | 11 | #include <qtextview.h> |
12 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
13 | 13 | ||
14 | #include <qpe/applnk.h> | 14 | #include <qpe/applnk.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/qcopenvelope_qws.h> | 16 | #include <qpe/qcopenvelope_qws.h> |
17 | 17 | ||
18 | #include "obex.h" | 18 | #include "obex.h" |
19 | #include "receiver.h" | 19 | #include "receiver.h" |
20 | 20 | ||
21 | using namespace OpieObex; | 21 | using namespace OpieObex; |
22 | 22 | ||
23 | /* TRANSLATOR OpieObex::Receiver */ | 23 | /* TRANSLATOR OpieObex::Receiver */ |
24 | 24 | ||
25 | Receiver::Receiver() { | 25 | Receiver::Receiver() { |
26 | m_obex = new Obex(this, "Receiver"); | 26 | m_obex = new Obex(this, "Receiver"); |
27 | connect(m_obex, SIGNAL(receivedFile(const QString& ) ), | 27 | connect(m_obex, SIGNAL(receivedFile(const QString&) ), |
28 | this, SLOT(slotReceived(const QString& ) ) ); | 28 | this, SLOT(slotReceived(const QString&) ) ); |
29 | m_obex->receive(); | 29 | m_obex->receive(); |
30 | } | 30 | } |
31 | Receiver::~Receiver() { | 31 | Receiver::~Receiver() { |
32 | m_obex->setReceiveEnabled( false ); | 32 | m_obex->setReceiveEnabled( false ); |
33 | delete m_obex; | 33 | delete m_obex; |
34 | } | 34 | } |
35 | void Receiver::slotReceived( const QString& _file ) { | 35 | void Receiver::slotReceived( const QString& _file ) { |
36 | QString file = _file; | 36 | QString file = _file; |
37 | int check = checkFile(file); | 37 | int check = checkFile(file); |
38 | if ( check == AddressBook ) | 38 | if ( check == AddressBook ) |
39 | handleAddr( file ); | 39 | handleAddr( file ); |
40 | else if ( check == Datebook ) | 40 | else if ( check == Datebook ) |
41 | handleDateTodo( file ); | 41 | handleDateTodo( file ); |
42 | else | 42 | else |
43 | handleOther( file ); | 43 | handleOther( file ); |
44 | } | 44 | } |
45 | void Receiver::handleAddr( const QString& str ) { | 45 | void Receiver::handleAddr( const QString& str ) { |
46 | QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); | 46 | QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); |
47 | e << str; | 47 | e << str; |
48 | } | 48 | } |
49 | /* we can not say for sure if it's a VEevent ot VTodo */ | 49 | /* we can not say for sure if it's a VEevent ot VTodo */ |
50 | void Receiver::handleDateTodo( const QString& str ) { | 50 | void Receiver::handleDateTodo( const QString& str ) { |
51 | QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); | 51 | QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); |
52 | e0 << str; | 52 | e0 << str; |
53 | QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); | 53 | QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); |
54 | e1 << str; | 54 | e1 << str; |
55 | } | 55 | } |
56 | /* | 56 | /* |
57 | * Handle other asks if it should accept the | 57 | * Handle other asks if it should accept the |
58 | * beamed object and creates a DocLnk | 58 | * beamed object and creates a DocLnk |
59 | */ | 59 | */ |
60 | void Receiver::handleOther( const QString& other ) { | 60 | void Receiver::handleOther( const QString& other ) { |
61 | OtherHandler* hand = new OtherHandler(); | 61 | OtherHandler* hand = new OtherHandler(); |
62 | hand->handle( other ); | 62 | hand->handle( other ); |
63 | } | 63 | } |
64 | void Receiver::tidyUp( QString& _file, const QString& ending) { | 64 | void Receiver::tidyUp( QString& _file, const QString& ending) { |
65 | /* libversit fails on BASE64 encoding we try to sed it away */ | 65 | /* libversit fails on BASE64 encoding we try to sed it away */ |
66 | QString file = _file; | 66 | QString file = _file; |
67 | char foo[24]; // big enough | 67 | char foo[24]; // big enough |
68 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); | 68 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); |
69 | 69 | ||
70 | int fd = ::mkstemp(foo); | 70 | int fd = ::mkstemp(foo); |
71 | 71 | ||
72 | if ( fd == -1 ) | 72 | if ( fd == -1 ) |
73 | return; | 73 | return; |
74 | 74 | ||
75 | (void)::strncat( foo, ending.latin1(), 4 ); | 75 | (void)::strncat( foo, ending.latin1(), 4 ); |
76 | _file = QString::fromLatin1( foo ); | 76 | _file = QString::fromLatin1( foo ); |
77 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); | 77 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); |
78 | qWarning("Executing: %s", cmd.latin1() ); | 78 | qWarning("Executing: %s", cmd.latin1() ); |
79 | (void)::system( cmd.latin1() ); | 79 | (void)::system( cmd.latin1() ); |
80 | 80 | ||
81 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); | 81 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); |
82 | (void)::system( cmd.latin1() ); | 82 | (void)::system( cmd.latin1() ); |
83 | } | 83 | } |
84 | int Receiver::checkFile( QString& file ) { | 84 | int Receiver::checkFile( QString& file ) { |
85 | qWarning("check file!! %s", file.latin1() ); | 85 | qWarning("check file!! %s", file.latin1() ); |
86 | int ret; | 86 | int ret; |
87 | QString ending; | 87 | QString ending; |
88 | 88 | ||
89 | if (file.right(4) == ".vcs" ) { | 89 | if (file.right(4) == ".vcs" ) { |
90 | ret = Datebook; | 90 | ret = Datebook; |
91 | ending = QString::fromLatin1(".vcs"); | 91 | ending = QString::fromLatin1(".vcs"); |
92 | }else if ( file.right(4) == ".vcf") { | 92 | }else if ( file.right(4) == ".vcf") { |
93 | ret = AddressBook; | 93 | ret = AddressBook; |
94 | ending = QString::fromLatin1(".vcf"); | 94 | ending = QString::fromLatin1(".vcf"); |
95 | }else | 95 | }else |
96 | ret = Other; | 96 | ret = Other; |
97 | 97 | ||
98 | 98 | ||
99 | if (ending.isEmpty() ) | 99 | if (ending.isEmpty() ) |
100 | return ret; | 100 | return ret; |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * currently the parser is broken in regard of BASE64 encoding | 103 | * currently the parser is broken in regard of BASE64 encoding |
104 | * and M$ likes to send that. So we will executed a small | 104 | * and M$ likes to send that. So we will executed a small |
105 | * tidy up system sed script | 105 | * tidy up system sed script |
106 | * At this point we can also remove umlaute from the filename | 106 | * At this point we can also remove umlaute from the filename |
107 | */ | 107 | */ |
108 | tidyUp( file, ending ); | 108 | tidyUp( file, ending ); |
109 | 109 | ||
110 | qWarning("check it now %d", ret ); | 110 | qWarning("check it now %d", ret ); |
111 | return ret; | 111 | return ret; |
112 | } | 112 | } |
113 | 113 | ||
114 | /* TRANSLATOR OpieObex::OtherHandler */ | 114 | /* TRANSLATOR OpieObex::OtherHandler */ |
115 | 115 | ||
116 | OtherHandler::OtherHandler() | 116 | OtherHandler::OtherHandler() |
117 | : QVBox() | 117 | : QVBox() |
118 | { | 118 | { |
119 | QHBox* box = new QHBox(this); | 119 | QHBox* box = new QHBox(this); |
120 | QLabel* lbl = new QLabel(box); | 120 | QLabel* lbl = new QLabel(box); |
121 | lbl->setText(tr("<qt><b>Received:</b></qt>")); | 121 | lbl->setText(tr("<qt><b>Received:</b></qt>")); |
122 | m_na = new QLabel(box); | 122 | m_na = new QLabel(box); |
123 | 123 | ||
124 | QFrame* frame = new QFrame(this); | 124 | QFrame* frame = new QFrame(this); |
125 | frame->setFrameShape( QFrame::HLine ); | 125 | frame->setFrameShape( QFrame::HLine ); |
126 | frame->setFrameShadow( QFrame::Sunken ); | 126 | frame->setFrameShadow( QFrame::Sunken ); |
127 | 127 | ||
128 | m_view = new QTextView(this); | 128 | m_view = new QTextView(this); |
129 | 129 | ||
130 | box = new QHBox(this); | 130 | box = new QHBox(this); |
131 | QPushButton *but = new QPushButton(box); | 131 | QPushButton *but = new QPushButton(box); |
132 | but->setText(tr("Accept") ); | 132 | but->setText(tr("Accept") ); |
133 | connect(but, SIGNAL(clicked() ), | 133 | connect(but, SIGNAL(clicked() ), |
134 | this, SLOT(accept()) ); | 134 | this, SLOT(accept()) ); |
135 | 135 | ||
136 | but = new QPushButton(box); | 136 | but = new QPushButton(box); |
137 | but->setText(tr("Deny") ); | 137 | but->setText(tr("Deny") ); |
138 | connect(but, SIGNAL(clicked() ), | 138 | connect(but, SIGNAL(clicked() ), |
139 | this, SLOT(deny() ) ); | 139 | this, SLOT(deny() ) ); |
140 | 140 | ||
141 | raise(); | 141 | raise(); |
142 | showMaximized(); | 142 | showMaximized(); |
143 | } | 143 | } |
144 | OtherHandler::~OtherHandler() { | 144 | OtherHandler::~OtherHandler() { |
145 | 145 | ||
146 | } | 146 | } |
147 | void OtherHandler::handle( const QString& file ) { | 147 | void OtherHandler::handle( const QString& file ) { |
148 | m_file = file; | 148 | m_file = file; |
149 | m_na->setText(file); | 149 | m_na->setText(file); |
150 | DocLnk lnk(file); | 150 | DocLnk lnk(file); |
151 | qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() ); | 151 | qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() ); |
152 | 152 | ||
153 | QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); | 153 | QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); |
154 | m_view->setText( str ); | 154 | m_view->setText( str ); |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * hehe evil evil mmap ahead :) | 158 | * hehe evil evil mmap ahead :) |
159 | * we quickly copy the file and then we'll create a DocLnk for it | 159 | * we quickly copy the file and then we'll create a DocLnk for it |
160 | */ | 160 | */ |
161 | void OtherHandler::accept() { | 161 | void OtherHandler::accept() { |
162 | QString na = targetName( m_file ); | 162 | QString na = targetName( m_file ); |
163 | copy(m_file, na ); | 163 | copy(m_file, na ); |
164 | DocLnk lnk(na); | 164 | DocLnk lnk(na); |
165 | lnk.writeLink(); | 165 | lnk.writeLink(); |
166 | QFile::remove(m_file); | 166 | QFile::remove(m_file); |
167 | delete this; | 167 | delete this; |
168 | } | 168 | } |
169 | void OtherHandler::deny() { | 169 | void OtherHandler::deny() { |
170 | QFile::remove( m_file ); | 170 | QFile::remove( m_file ); |
171 | delete this; | 171 | delete this; |
172 | } | 172 | } |
173 | QString OtherHandler::targetName( const QString& file ) { | 173 | QString OtherHandler::targetName( const QString& file ) { |
174 | QFileInfo info( file ); | 174 | QFileInfo info( file ); |
175 | 175 | ||
176 | /* $HOME needs to be set!!!! */ | 176 | /* $HOME needs to be set!!!! */ |
177 | Global::createDocDir(); | 177 | Global::createDocDir(); |
178 | 178 | ||
179 | QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); | 179 | QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); |
180 | QString newFileBase = newFile; | 180 | QString newFileBase = newFile; |
181 | 181 | ||
182 | int trie = 0; | 182 | int trie = 0; |
183 | while (QFile::exists(newFile + "."+info.extension() ) ) { | 183 | while (QFile::exists(newFile + "."+info.extension() ) ) { |
184 | newFile = newFileBase + "_"+QString::number(trie) ; | 184 | newFile = newFileBase + "_"+QString::number(trie) ; |
185 | trie++; | 185 | trie++; |
186 | } | 186 | } |
187 | newFile += "." + info.extension(); | 187 | newFile += "." + info.extension(); |
188 | 188 | ||
189 | return newFile; | 189 | return newFile; |
190 | } | 190 | } |
191 | 191 | ||
192 | /* fast cpy */ | 192 | /* fast cpy */ |
193 | void OtherHandler::copy(const QString& src, const QString& file) { | 193 | void OtherHandler::copy(const QString& src, const QString& file) { |
194 | qWarning("src %s, dest %s", src.latin1(),file.latin1() ); | 194 | qWarning("src %s, dest %s", src.latin1(),file.latin1() ); |
195 | QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). | 195 | QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). |
196 | arg( Global::shellQuote( file ) ); | 196 | arg( Global::shellQuote( file ) ); |
197 | ::system( cmd.latin1() ); | 197 | ::system( cmd.latin1() ); |
198 | // done | 198 | // done |
199 | } | 199 | } |
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 3037ba3..e1b9360 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp | |||
@@ -1,250 +1,250 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | #include <qpe/version.h> | 27 | #include <qpe/version.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #if QT_VERSION < 300 | 36 | #if QT_VERSION < 300 |
37 | #include <qgfx_qws.h> | 37 | #include <qgfx_qws.h> |
38 | #endif | 38 | #endif |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | 40 | ||
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
44 | 44 | ||
45 | #include <opie/odevice.h> | 45 | #include <opie/odevice.h> |
46 | 46 | ||
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | #include "loginwindowimpl.h" | 50 | #include "loginwindowimpl.h" |
51 | #include "loginapplication.h" | 51 | #include "loginapplication.h" |
52 | #include "inputmethods.h" | 52 | #include "inputmethods.h" |
53 | 53 | ||
54 | using namespace Opie; | 54 | using namespace Opie; |
55 | 55 | ||
56 | 56 | ||
57 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) | 57 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) |
58 | { | 58 | { |
59 | QPopupMenu *pop = new QPopupMenu ( this ); | 59 | QPopupMenu *pop = new QPopupMenu ( this ); |
60 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); | 60 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart())); |
61 | pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( ))); | 61 | pop-> insertItem ( tr( "Quit" ), this, SLOT( quit())); |
62 | m_menu-> setPopup ( pop ); | 62 | m_menu-> setPopup ( pop ); |
63 | 63 | ||
64 | QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this ); | 64 | QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this ); |
65 | connect ( channel, SIGNAL( received ( const QCString &, const QByteArray & )), this, SLOT( receive ( const QCString &, const QByteArray & ))); | 65 | connect ( channel, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( receive(const QCString&,const QByteArray&))); |
66 | 66 | ||
67 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); | 67 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); |
68 | m_input = new InputMethods ( m_taskbar ); | 68 | m_input = new InputMethods ( m_taskbar ); |
69 | connect ( m_input, SIGNAL( inputToggled ( bool )), this, SLOT( calcMaxWindowRect ( ))); | 69 | connect ( m_input, SIGNAL( inputToggled(bool)), this, SLOT( calcMaxWindowRect())); |
70 | lay-> addWidget ( m_input ); | 70 | lay-> addWidget ( m_input ); |
71 | lay-> addStretch ( 10 ); | 71 | lay-> addStretch ( 10 ); |
72 | 72 | ||
73 | setActiveWindow ( ); | 73 | setActiveWindow ( ); |
74 | m_password-> setFocus ( ); | 74 | m_password-> setFocus ( ); |
75 | 75 | ||
76 | m_user-> insertStringList ( lApp-> allUsers ( )); | 76 | m_user-> insertStringList ( lApp-> allUsers ( )); |
77 | 77 | ||
78 | //there is no point in displaying the IM for a zaurus | 78 | //there is no point in displaying the IM for a zaurus |
79 | if (ODevice::inst ( )-> series ( ) != Model_Zaurus){ | 79 | if (ODevice::inst ( )-> series ( ) != Model_Zaurus){ |
80 | QTimer::singleShot ( 0, this, SLOT( showIM ( ))); | 80 | QTimer::singleShot ( 0, this, SLOT( showIM())); |
81 | } | 81 | } |
82 | 82 | ||
83 | QString opiedir = ::getenv ( "OPIEDIR" ); | 83 | QString opiedir = ::getenv ( "OPIEDIR" ); |
84 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); | 84 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); |
85 | 85 | ||
86 | if ( !bgpix. isNull ( )) { | 86 | if ( !bgpix. isNull ( )) { |
87 | setBackgroundPixmap ( bgpix ); | 87 | setBackgroundPixmap ( bgpix ); |
88 | m_caption-> setBackgroundPixmap ( bgpix); | 88 | m_caption-> setBackgroundPixmap ( bgpix); |
89 | TextLabel1-> setBackgroundPixmap ( bgpix); | 89 | TextLabel1-> setBackgroundPixmap ( bgpix); |
90 | TextLabel2-> setBackgroundPixmap ( bgpix); | 90 | TextLabel2-> setBackgroundPixmap ( bgpix); |
91 | } | 91 | } |
92 | 92 | ||
93 | m_caption-> setText ( tr("<center>Welcome to OPIE %1</center><center>& %2 %3</center>"). arg(QPE_VERSION). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); | 93 | m_caption-> setText ( tr("<center>Welcome to OPIE %1</center><center>& %2 %3</center>"). arg(QPE_VERSION). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); |
94 | 94 | ||
95 | Config cfg ( "opie-login" ); | 95 | Config cfg ( "opie-login" ); |
96 | cfg. setGroup ( "General" ); | 96 | cfg. setGroup ( "General" ); |
97 | QString last = cfg. readEntry ( "LastLogin" ); | 97 | QString last = cfg. readEntry ( "LastLogin" ); |
98 | 98 | ||
99 | if ( !last. isEmpty ( )) | 99 | if ( !last. isEmpty ( )) |
100 | m_user-> setEditText ( last ); | 100 | m_user-> setEditText ( last ); |
101 | 101 | ||
102 | calcMaxWindowRect ( ); | 102 | calcMaxWindowRect ( ); |
103 | } | 103 | } |
104 | 104 | ||
105 | LoginWindowImpl::~LoginWindowImpl ( ) | 105 | LoginWindowImpl::~LoginWindowImpl ( ) |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) | 110 | void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) |
111 | { | 111 | { |
112 | QDataStream stream ( data, IO_ReadOnly ); | 112 | QDataStream stream ( data, IO_ReadOnly ); |
113 | 113 | ||
114 | if ( msg == "hideInputMethod()" ) | 114 | if ( msg == "hideInputMethod()" ) |
115 | m_input-> hideInputMethod ( ); | 115 | m_input-> hideInputMethod ( ); |
116 | else if ( msg == "showInputMethod()" ) | 116 | else if ( msg == "showInputMethod()" ) |
117 | m_input-> showInputMethod ( ); | 117 | m_input-> showInputMethod ( ); |
118 | else if ( msg == "reloadInputMethods()" ) | 118 | else if ( msg == "reloadInputMethods()" ) |
119 | m_input-> loadInputMethods ( ); | 119 | m_input-> loadInputMethods ( ); |
120 | } | 120 | } |
121 | 121 | ||
122 | void LoginWindowImpl::calcMaxWindowRect ( ) | 122 | void LoginWindowImpl::calcMaxWindowRect ( ) |
123 | { | 123 | { |
124 | #ifdef Q_WS_QWS | 124 | #ifdef Q_WS_QWS |
125 | QRect wr; | 125 | QRect wr; |
126 | int displayWidth = qApp-> desktop ( )-> width ( ); | 126 | int displayWidth = qApp-> desktop ( )-> width ( ); |
127 | QRect ir = m_input-> inputRect ( ); | 127 | QRect ir = m_input-> inputRect ( ); |
128 | if ( ir.isValid() ) | 128 | if ( ir.isValid() ) |
129 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 129 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
130 | else | 130 | else |
131 | wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); | 131 | wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); |
132 | 132 | ||
133 | #if QT_VERSION < 300 | 133 | #if QT_VERSION < 300 |
134 | wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 134 | wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | QWSServer::setMaxWindowRect( wr ); | 137 | QWSServer::setMaxWindowRect( wr ); |
138 | #endif | 138 | #endif |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) | 142 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) |
143 | { | 143 | { |
144 | switch ( e-> key ( )) { | 144 | switch ( e-> key ( )) { |
145 | case HardKey_Suspend: suspend ( ); | 145 | case HardKey_Suspend: suspend ( ); |
146 | break; | 146 | break; |
147 | case HardKey_Backlight: backlight ( ); | 147 | case HardKey_Backlight: backlight ( ); |
148 | break; | 148 | break; |
149 | default: e-> ignore ( ); | 149 | default: e-> ignore ( ); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | LoginWindow::keyPressEvent ( e ); | 152 | LoginWindow::keyPressEvent ( e ); |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | void LoginWindowImpl::toggleEchoMode ( bool t ) | 156 | void LoginWindowImpl::toggleEchoMode ( bool t ) |
157 | { | 157 | { |
158 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); | 158 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); |
159 | } | 159 | } |
160 | 160 | ||
161 | void LoginWindowImpl::showIM ( ) | 161 | void LoginWindowImpl::showIM ( ) |
162 | { | 162 | { |
163 | m_input-> showInputMethod ( ); | 163 | m_input-> showInputMethod ( ); |
164 | } | 164 | } |
165 | 165 | ||
166 | void LoginWindowImpl::restart ( ) | 166 | void LoginWindowImpl::restart ( ) |
167 | { | 167 | { |
168 | qApp-> quit ( ); | 168 | qApp-> quit ( ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void LoginWindowImpl::quit ( ) | 171 | void LoginWindowImpl::quit ( ) |
172 | { | 172 | { |
173 | lApp-> quitToConsole ( ); | 173 | lApp-> quitToConsole ( ); |
174 | } | 174 | } |
175 | 175 | ||
176 | void LoginWindowImpl::suspend ( ) | 176 | void LoginWindowImpl::suspend ( ) |
177 | { | 177 | { |
178 | ODevice::inst ( )-> suspend ( ); | 178 | ODevice::inst ( )-> suspend ( ); |
179 | 179 | ||
180 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 180 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
181 | e << -3; // Force on | 181 | e << -3; // Force on |
182 | } | 182 | } |
183 | 183 | ||
184 | void LoginWindowImpl::backlight ( ) | 184 | void LoginWindowImpl::backlight ( ) |
185 | { | 185 | { |
186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
187 | e << -2; // toggle | 187 | e << -2; // toggle |
188 | } | 188 | } |
189 | 189 | ||
190 | class WaitLogo : public QLabel { | 190 | class WaitLogo : public QLabel { |
191 | public: | 191 | public: |
192 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) | 192 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) |
193 | { | 193 | { |
194 | QImage img = Resource::loadImage ( "launcher/new_wait" ); | 194 | QImage img = Resource::loadImage ( "launcher/new_wait" ); |
195 | QPixmap pix; | 195 | QPixmap pix; |
196 | pix. convertFromImage ( img ); | 196 | pix. convertFromImage ( img ); |
197 | setPixmap ( pix ); | 197 | setPixmap ( pix ); |
198 | setAlignment ( AlignCenter ); | 198 | setAlignment ( AlignCenter ); |
199 | move ( 0, 0 ); | 199 | move ( 0, 0 ); |
200 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); | 200 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); |
201 | 201 | ||
202 | m_visible = false; | 202 | m_visible = false; |
203 | show ( ); | 203 | show ( ); |
204 | } | 204 | } |
205 | 205 | ||
206 | virtual void showEvent ( QShowEvent *e ) | 206 | virtual void showEvent ( QShowEvent *e ) |
207 | { | 207 | { |
208 | QLabel::showEvent ( e ); | 208 | QLabel::showEvent ( e ); |
209 | m_visible = true; | 209 | m_visible = true; |
210 | } | 210 | } |
211 | 211 | ||
212 | virtual void paintEvent ( QPaintEvent *e ) | 212 | virtual void paintEvent ( QPaintEvent *e ) |
213 | { | 213 | { |
214 | QLabel::paintEvent ( e ); | 214 | QLabel::paintEvent ( e ); |
215 | if ( m_visible ) | 215 | if ( m_visible ) |
216 | qApp-> quit ( ); | 216 | qApp-> quit ( ); |
217 | } | 217 | } |
218 | 218 | ||
219 | private: | 219 | private: |
220 | bool m_visible; | 220 | bool m_visible; |
221 | }; | 221 | }; |
222 | 222 | ||
223 | void LoginWindowImpl::login ( ) | 223 | void LoginWindowImpl::login ( ) |
224 | { | 224 | { |
225 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); | 225 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); |
226 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); | 226 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); |
227 | 227 | ||
228 | if ( !user || !user [0] ) | 228 | if ( !user || !user [0] ) |
229 | return; | 229 | return; |
230 | if ( !pass ) | 230 | if ( !pass ) |
231 | pass = ""; | 231 | pass = ""; |
232 | 232 | ||
233 | if ( lApp-> checkPassword ( user, pass )) { | 233 | if ( lApp-> checkPassword ( user, pass )) { |
234 | Config cfg ( "opie-login" ); | 234 | Config cfg ( "opie-login" ); |
235 | cfg. setGroup ( "General" ); | 235 | cfg. setGroup ( "General" ); |
236 | cfg. writeEntry ( "LastLogin", user ); | 236 | cfg. writeEntry ( "LastLogin", user ); |
237 | cfg. write ( ); | 237 | cfg. write ( ); |
238 | 238 | ||
239 | lApp-> setLoginAs ( user ); | 239 | lApp-> setLoginAs ( user ); |
240 | 240 | ||
241 | // Draw a big wait icon, the image can be altered in later revisions | 241 | // Draw a big wait icon, the image can be altered in later revisions |
242 | m_input-> hideInputMethod ( ); | 242 | m_input-> hideInputMethod ( ); |
243 | new WaitLogo ( ); | 243 | new WaitLogo ( ); |
244 | // WaitLogo::showEvent() calls qApp-> quit() | 244 | // WaitLogo::showEvent() calls qApp-> quit() |
245 | } | 245 | } |
246 | else { | 246 | else { |
247 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); | 247 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); |
248 | m_password-> clear ( ); | 248 | m_password-> clear ( ); |
249 | } | 249 | } |
250 | } | 250 | } |
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index 7d5792e..8d0976f 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp | |||
@@ -1,366 +1,366 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "loginapplication.h" | 28 | #include "loginapplication.h" |
29 | #include "loginwindowimpl.h" | 29 | #include "loginwindowimpl.h" |
30 | #include "calibrate.h" | 30 | #include "calibrate.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/odevice.h> | 33 | #include <opie2/odevice.h> |
34 | #include <qpe/qpestyle.h> | 34 | #include <qpe/qpestyle.h> |
35 | #include <qpe/power.h> | 35 | #include <qpe/power.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qfile.h> | 43 | #include <qfile.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <sys/types.h> | 46 | #include <sys/types.h> |
47 | #include <time.h> | 47 | #include <time.h> |
48 | #include <sys/time.h> | 48 | #include <sys/time.h> |
49 | #include <sys/resource.h> | 49 | #include <sys/resource.h> |
50 | #include <unistd.h> | 50 | #include <unistd.h> |
51 | #include <syslog.h> | 51 | #include <syslog.h> |
52 | #include <sys/wait.h> | 52 | #include <sys/wait.h> |
53 | #include <stdio.h> | 53 | #include <stdio.h> |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <signal.h> | 55 | #include <signal.h> |
56 | #include <getopt.h> | 56 | #include <getopt.h> |
57 | #include <string.h> | 57 | #include <string.h> |
58 | 58 | ||
59 | using namespace Opie; | 59 | using namespace Opie; |
60 | 60 | ||
61 | int login_main ( int argc, char **argv, pid_t ppid ); | 61 | int login_main ( int argc, char **argv, pid_t ppid ); |
62 | void sigterm ( int sig ); | 62 | void sigterm ( int sig ); |
63 | void sigint ( int sig ); | 63 | void sigint ( int sig ); |
64 | void exit_closelog ( ); | 64 | void exit_closelog ( ); |
65 | 65 | ||
66 | static struct option long_options [] = { | 66 | static struct option long_options [] = { |
67 | { "autologin", 1, 0, 'a' }, | 67 | { "autologin", 1, 0, 'a' }, |
68 | { 0, 0, 0, 0 } | 68 | { 0, 0, 0, 0 } |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | int main ( int argc, char **argv ) | 72 | int main ( int argc, char **argv ) |
73 | { | 73 | { |
74 | int userExited = 0; | 74 | int userExited = 0; |
75 | pid_t ppid = ::getpid ( ); | 75 | pid_t ppid = ::getpid ( ); |
76 | 76 | ||
77 | if ( ::geteuid ( ) != 0 ) { | 77 | if ( ::geteuid ( ) != 0 ) { |
78 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); | 78 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); |
79 | return 1; | 79 | return 1; |
80 | } | 80 | } |
81 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and | 81 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and |
82 | ::setuid ( 0 ); // messes up things like config files | 82 | ::setuid ( 0 ); // messes up things like config files |
83 | 83 | ||
84 | char *autolog = 0; | 84 | char *autolog = 0; |
85 | int c; | 85 | int c; |
86 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { | 86 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { |
87 | switch ( c ) { | 87 | switch ( c ) { |
88 | case 'a': | 88 | case 'a': |
89 | autolog = optarg; | 89 | autolog = optarg; |
90 | break; | 90 | break; |
91 | default: | 91 | default: |
92 | ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); | 92 | ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); |
93 | return 2; | 93 | return 2; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | //struct rlimit rl; | 97 | //struct rlimit rl; |
98 | //::getrlimit ( RLIMIT_NOFILE, &rl ); | 98 | //::getrlimit ( RLIMIT_NOFILE, &rl ); |
99 | 99 | ||
100 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) | 100 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) |
101 | // ::close ( i ); | 101 | // ::close ( i ); |
102 | 102 | ||
103 | ::setpgid ( 0, 0 ); | 103 | ::setpgid ( 0, 0 ); |
104 | ::setsid ( ); | 104 | ::setsid ( ); |
105 | 105 | ||
106 | ::signal ( SIGTERM, sigterm ); | 106 | ::signal ( SIGTERM, sigterm ); |
107 | ::signal ( SIGINT, sigterm ); | 107 | ::signal ( SIGINT, sigterm ); |
108 | 108 | ||
109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); | 109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); |
110 | ::atexit ( exit_closelog ); | 110 | ::atexit ( exit_closelog ); |
111 | 111 | ||
112 | while ( true ) { | 112 | while ( true ) { |
113 | pid_t child = ::fork ( ); | 113 | pid_t child = ::fork ( ); |
114 | 114 | ||
115 | if ( child < 0 ) { | 115 | if ( child < 0 ) { |
116 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); | 116 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | else if ( child > 0 ) { | 119 | else if ( child > 0 ) { |
120 | int status = 0; | 120 | int status = 0; |
121 | time_t started = ::time ( 0 ); | 121 | time_t started = ::time ( 0 ); |
122 | 122 | ||
123 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } | 123 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } |
124 | 124 | ||
125 | LoginApplication::logout ( ); | 125 | LoginApplication::logout ( ); |
126 | 126 | ||
127 | if (( ::time ( 0 ) - started ) < 3 ) { | 127 | if (( ::time ( 0 ) - started ) < 3 ) { |
128 | if ( autolog ) { | 128 | if ( autolog ) { |
129 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); | 129 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); |
130 | autolog = 0; | 130 | autolog = 0; |
131 | } | 131 | } |
132 | else { | 132 | else { |
133 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); | 133 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | int killedbysig = 0; | 137 | int killedbysig = 0; |
138 | userExited=0; | 138 | userExited=0; |
139 | if (WIFEXITED(status)!=0 ) { | 139 | if (WIFEXITED(status)!=0 ) { |
140 | if (WEXITSTATUS(status)==137) { | 140 | if (WEXITSTATUS(status)==137) { |
141 | userExited=1; | 141 | userExited=1; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | if ( WIFSIGNALED( status )) { | 145 | if ( WIFSIGNALED( status )) { |
146 | switch ( WTERMSIG( status )) { | 146 | switch ( WTERMSIG( status )) { |
147 | case SIGTERM: | 147 | case SIGTERM: |
148 | case SIGINT : | 148 | case SIGINT : |
149 | case SIGKILL: | 149 | case SIGKILL: |
150 | break; | 150 | break; |
151 | 151 | ||
152 | default : | 152 | default : |
153 | killedbysig = WTERMSIG( status ); | 153 | killedbysig = WTERMSIG( status ); |
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | if ( killedbysig ) { // qpe was killed by an uncaught signal | 157 | if ( killedbysig ) { // qpe was killed by an uncaught signal |
158 | qApp = 0; | 158 | qApp = 0; |
159 | 159 | ||
160 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); | 160 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); |
161 | 161 | ||
162 | QWSServer::setDesktopBackground ( QImage ( )); | 162 | QWSServer::setDesktopBackground ( QImage ( )); |
163 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); | 163 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); |
164 | app-> setFont ( QFont ( "Helvetica", 10 )); | 164 | app-> setFont ( QFont ( "Helvetica", 10 )); |
165 | app-> setStyle ( new QPEStyle ( )); | 165 | app-> setStyle ( new QPEStyle ( )); |
166 | 166 | ||
167 | const char *sig = ::strsignal ( killedbysig ); | 167 | const char *sig = ::strsignal ( killedbysig ); |
168 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); | 168 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); |
169 | l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); | 169 | l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); |
170 | l-> setAlignment ( Qt::AlignCenter ); | 170 | l-> setAlignment ( Qt::AlignCenter ); |
171 | l-> move ( 0, 0 ); | 171 | l-> move ( 0, 0 ); |
172 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); | 172 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); |
173 | l-> show ( ); | 173 | l-> show ( ); |
174 | QTimer::singleShot ( 3000, app, SLOT( quit ( ))); | 174 | QTimer::singleShot ( 3000, app, SLOT( quit())); |
175 | app-> exec ( ); | 175 | app-> exec ( ); |
176 | delete app; | 176 | delete app; |
177 | qApp = 0; | 177 | qApp = 0; |
178 | } | 178 | } |
179 | } | 179 | } |
180 | else { | 180 | else { |
181 | if ( !autolog ) { | 181 | if ( !autolog ) { |
182 | QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 182 | QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
183 | Config cfg ( confFile, Config::File ); | 183 | Config cfg ( confFile, Config::File ); |
184 | cfg. setGroup ( "General" ); | 184 | cfg. setGroup ( "General" ); |
185 | QString user = cfg. readEntry ( "AutoLogin" ); | 185 | QString user = cfg. readEntry ( "AutoLogin" ); |
186 | 186 | ||
187 | if ( !user. isEmpty ( )) | 187 | if ( !user. isEmpty ( )) |
188 | autolog = ::strdup ( user. latin1 ( )); | 188 | autolog = ::strdup ( user. latin1 ( )); |
189 | } | 189 | } |
190 | 190 | ||
191 | if ( autolog && !userExited ) { | 191 | if ( autolog && !userExited ) { |
192 | 192 | ||
193 | QWSServer::setDesktopBackground( QImage() ); | 193 | QWSServer::setDesktopBackground( QImage() ); |
194 | ODevice::inst ( )-> setDisplayStatus ( true ); | 194 | ODevice::inst ( )-> setDisplayStatus ( true ); |
195 | ODevice::inst ( )-> setSoftSuspend ( false ); | 195 | ODevice::inst ( )-> setSoftSuspend ( false ); |
196 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); | 196 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
197 | LoginApplication::setLoginAs ( autolog ); | 197 | LoginApplication::setLoginAs ( autolog ); |
198 | 198 | ||
199 | 199 | ||
200 | if ( LoginApplication::changeIdentity ( )) | 200 | if ( LoginApplication::changeIdentity ( )) |
201 | ::exit ( LoginApplication::login ( )); | 201 | ::exit ( LoginApplication::login ( )); |
202 | else | 202 | else |
203 | ::exit ( 0 ); | 203 | ::exit ( 0 ); |
204 | } | 204 | } |
205 | else { | 205 | else { |
206 | ::exit ( login_main ( argc, argv, ppid )); | 206 | ::exit ( login_main ( argc, argv, ppid )); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | void sigterm ( int /*sig*/ ) | 213 | void sigterm ( int /*sig*/ ) |
214 | { | 214 | { |
215 | ::exit ( 0 ); | 215 | ::exit ( 0 ); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | void exit_closelog ( ) | 219 | void exit_closelog ( ) |
220 | { | 220 | { |
221 | ::closelog ( ); | 221 | ::closelog ( ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | class LoginScreenSaver : public QWSScreenSaver | 225 | class LoginScreenSaver : public QWSScreenSaver |
226 | { | 226 | { |
227 | public: | 227 | public: |
228 | LoginScreenSaver ( ) | 228 | LoginScreenSaver ( ) |
229 | { | 229 | { |
230 | m_lcd_status = true; | 230 | m_lcd_status = true; |
231 | 231 | ||
232 | m_backlight_bright = -1; | 232 | m_backlight_bright = -1; |
233 | m_backlight_forcedoff = false; | 233 | m_backlight_forcedoff = false; |
234 | 234 | ||
235 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 235 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
236 | ODevice::inst ( )-> setDisplayStatus ( true ); | 236 | ODevice::inst ( )-> setDisplayStatus ( true ); |
237 | } | 237 | } |
238 | void restore() | 238 | void restore() |
239 | { | 239 | { |
240 | if ( !m_lcd_status ) // We must have turned it off | 240 | if ( !m_lcd_status ) // We must have turned it off |
241 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 241 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
242 | 242 | ||
243 | setBacklight ( -3 ); | 243 | setBacklight ( -3 ); |
244 | } | 244 | } |
245 | bool save( int level ) | 245 | bool save( int level ) |
246 | { | 246 | { |
247 | switch ( level ) { | 247 | switch ( level ) { |
248 | case 0: | 248 | case 0: |
249 | if ( backlight() > 1 ) | 249 | if ( backlight() > 1 ) |
250 | setBacklight( 1 ); // lowest non-off | 250 | setBacklight( 1 ); // lowest non-off |
251 | return true; | 251 | return true; |
252 | break; | 252 | break; |
253 | case 1: | 253 | case 1: |
254 | setBacklight( 0 ); // off | 254 | setBacklight( 0 ); // off |
255 | return true; | 255 | return true; |
256 | break; | 256 | break; |
257 | case 2: | 257 | case 2: |
258 | // We're going to suspend the whole machine | 258 | // We're going to suspend the whole machine |
259 | if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { | 259 | if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { |
260 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 260 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
261 | return true; | 261 | return true; |
262 | } | 262 | } |
263 | break; | 263 | break; |
264 | } | 264 | } |
265 | return false; | 265 | return false; |
266 | } | 266 | } |
267 | 267 | ||
268 | private: | 268 | private: |
269 | public: | 269 | public: |
270 | void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) | 270 | void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) |
271 | { | 271 | { |
272 | int v [4]; | 272 | int v [4]; |
273 | 273 | ||
274 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 274 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
275 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 275 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
276 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 276 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
277 | v [ 3 ] = 0; | 277 | v [ 3 ] = 0; |
278 | 278 | ||
279 | if ( !i1 && !i2 && !i3 ) | 279 | if ( !i1 && !i2 && !i3 ) |
280 | QWSServer::setScreenSaverInterval ( 0 ); | 280 | QWSServer::setScreenSaverInterval ( 0 ); |
281 | else | 281 | else |
282 | QWSServer::setScreenSaverIntervals ( v ); | 282 | QWSServer::setScreenSaverIntervals ( v ); |
283 | } | 283 | } |
284 | 284 | ||
285 | int backlight ( ) | 285 | int backlight ( ) |
286 | { | 286 | { |
287 | if ( m_backlight_bright == -1 ) | 287 | if ( m_backlight_bright == -1 ) |
288 | m_backlight_bright = 255; | 288 | m_backlight_bright = 255; |
289 | 289 | ||
290 | return m_backlight_bright; | 290 | return m_backlight_bright; |
291 | } | 291 | } |
292 | 292 | ||
293 | void setBacklight ( int bright ) | 293 | void setBacklight ( int bright ) |
294 | { | 294 | { |
295 | if ( bright == -3 ) { | 295 | if ( bright == -3 ) { |
296 | // Forced on | 296 | // Forced on |
297 | m_backlight_forcedoff = false; | 297 | m_backlight_forcedoff = false; |
298 | bright = -1; | 298 | bright = -1; |
299 | } | 299 | } |
300 | if ( m_backlight_forcedoff && bright != -2 ) | 300 | if ( m_backlight_forcedoff && bright != -2 ) |
301 | return ; | 301 | return ; |
302 | if ( bright == -2 ) { | 302 | if ( bright == -2 ) { |
303 | // Toggle between off and on | 303 | // Toggle between off and on |
304 | bright = m_backlight_bright ? 0 : -1; | 304 | bright = m_backlight_bright ? 0 : -1; |
305 | m_backlight_forcedoff = !bright; | 305 | m_backlight_forcedoff = !bright; |
306 | } | 306 | } |
307 | 307 | ||
308 | m_backlight_bright = bright; | 308 | m_backlight_bright = bright; |
309 | 309 | ||
310 | bright = backlight ( ); | 310 | bright = backlight ( ); |
311 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 311 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
312 | 312 | ||
313 | m_backlight_bright = bright; | 313 | m_backlight_bright = bright; |
314 | } | 314 | } |
315 | 315 | ||
316 | private: | 316 | private: |
317 | bool m_lcd_status; | 317 | bool m_lcd_status; |
318 | 318 | ||
319 | int m_backlight_bright; | 319 | int m_backlight_bright; |
320 | bool m_backlight_forcedoff; | 320 | bool m_backlight_forcedoff; |
321 | }; | 321 | }; |
322 | 322 | ||
323 | 323 | ||
324 | namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting | 324 | namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting |
325 | 325 | ||
326 | 326 | ||
327 | int login_main ( int argc, char **argv, pid_t ppid ) | 327 | int login_main ( int argc, char **argv, pid_t ppid ) |
328 | { | 328 | { |
329 | QWSServer::setDesktopBackground( QImage() ); | 329 | QWSServer::setDesktopBackground( QImage() ); |
330 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); | 330 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
331 | 331 | ||
332 | Opie::force_appearance = 0; | 332 | Opie::force_appearance = 0; |
333 | 333 | ||
334 | app-> setFont ( QFont ( "Helvetica", 10 )); | 334 | app-> setFont ( QFont ( "Helvetica", 10 )); |
335 | app-> setStyle ( new QPEStyle ( )); | 335 | app-> setStyle ( new QPEStyle ( )); |
336 | 336 | ||
337 | ODevice::inst ( )-> setSoftSuspend ( true ); | 337 | ODevice::inst ( )-> setSoftSuspend ( true ); |
338 | 338 | ||
339 | if ( QWSServer::mouseHandler() && | 339 | if ( QWSServer::mouseHandler() && |
340 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { | 340 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { |
341 | if ( !QFile::exists ( "/etc/pointercal" )) { | 341 | if ( !QFile::exists ( "/etc/pointercal" )) { |
342 | // Make sure calibration widget starts on top. | 342 | // Make sure calibration widget starts on top. |
343 | Calibrate *cal = new Calibrate; | 343 | Calibrate *cal = new Calibrate; |
344 | cal-> exec ( ); | 344 | cal-> exec ( ); |
345 | delete cal; | 345 | delete cal; |
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
349 | LoginScreenSaver *saver = new LoginScreenSaver; | 349 | LoginScreenSaver *saver = new LoginScreenSaver; |
350 | 350 | ||
351 | saver-> setIntervals ( ); | 351 | saver-> setIntervals ( ); |
352 | QWSServer::setScreenSaver ( saver ); | 352 | QWSServer::setScreenSaver ( saver ); |
353 | saver-> restore ( ); | 353 | saver-> restore ( ); |
354 | 354 | ||
355 | 355 | ||
356 | LoginWindowImpl *lw = new LoginWindowImpl ( ); | 356 | LoginWindowImpl *lw = new LoginWindowImpl ( ); |
357 | app-> setMainWidget ( lw ); | 357 | app-> setMainWidget ( lw ); |
358 | lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); | 358 | lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); |
359 | lw-> show ( ); | 359 | lw-> show ( ); |
360 | 360 | ||
361 | int rc = app-> exec ( ); | 361 | int rc = app-> exec ( ); |
362 | 362 | ||
363 | ODevice::inst ( )-> setSoftSuspend ( false ); | 363 | ODevice::inst ( )-> setSoftSuspend ( false ); |
364 | 364 | ||
365 | if ( app-> loginAs ( )) { | 365 | if ( app-> loginAs ( )) { |
366 | if ( app-> changeIdentity ( )) { | 366 | if ( app-> changeIdentity ( )) { |
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index f7bff58..29f4383 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1,322 +1,322 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of Qt Palmtop Environment. | 5 | ** This file is part of Qt Palmtop Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | 22 | ||
23 | #include <qpe/timestring.h> | 23 | #include <qpe/timestring.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <opie/orecordlist.h> | 26 | #include <opie/orecordlist.h> |
27 | 27 | ||
28 | 28 | ||
29 | #include "abtable.h" | 29 | #include "abtable.h" |
30 | 30 | ||
31 | #include <errno.h> | 31 | #include <errno.h> |
32 | #include <fcntl.h> | 32 | #include <fcntl.h> |
33 | #include <unistd.h> | 33 | #include <unistd.h> |
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | 35 | ||
36 | #include <ctype.h> //toupper() for key hack | 36 | #include <ctype.h> //toupper() for key hack |
37 | 37 | ||
38 | #if 0 | 38 | #if 0 |
39 | 39 | ||
40 | /*! | 40 | /*! |
41 | \class AbTableItem abtable.h | 41 | \class AbTableItem abtable.h |
42 | 42 | ||
43 | \brief QTableItem based class for showing a field of an entry | 43 | \brief QTableItem based class for showing a field of an entry |
44 | */ | 44 | */ |
45 | 45 | ||
46 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 46 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
47 | const QString &secondSortKey) | 47 | const QString &secondSortKey) |
48 | : QTableItem( t, et, s ) | 48 | : QTableItem( t, et, s ) |
49 | { | 49 | { |
50 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 50 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
51 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 51 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
52 | } | 52 | } |
53 | 53 | ||
54 | int AbTableItem::alignment() const | 54 | int AbTableItem::alignment() const |
55 | { | 55 | { |
56 | return AlignLeft|AlignVCenter; | 56 | return AlignLeft|AlignVCenter; |
57 | } | 57 | } |
58 | 58 | ||
59 | QString AbTableItem::key() const | 59 | QString AbTableItem::key() const |
60 | { | 60 | { |
61 | return sortKey; | 61 | return sortKey; |
62 | } | 62 | } |
63 | 63 | ||
64 | // A way to reset the item, without out doing a delete or a new... | 64 | // A way to reset the item, without out doing a delete or a new... |
65 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 65 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) |
66 | { | 66 | { |
67 | setText( txt ); | 67 | setText( txt ); |
68 | sortKey = Qtopia::buildSortKey( txt, secondKey ); | 68 | sortKey = Qtopia::buildSortKey( txt, secondKey ); |
69 | 69 | ||
70 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); | 70 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); |
71 | } | 71 | } |
72 | 72 | ||
73 | /*! | 73 | /*! |
74 | \class AbPickItem abtable.h | 74 | \class AbPickItem abtable.h |
75 | 75 | ||
76 | \brief QTableItem based class for showing slection of an entry | 76 | \brief QTableItem based class for showing slection of an entry |
77 | */ | 77 | */ |
78 | 78 | ||
79 | AbPickItem::AbPickItem( QTable *t ) : | 79 | AbPickItem::AbPickItem( QTable *t ) : |
80 | QTableItem(t, WhenCurrent, "?") | 80 | QTableItem(t, WhenCurrent, "?") |
81 | { | 81 | { |
82 | } | 82 | } |
83 | 83 | ||
84 | QWidget *AbPickItem::createEditor() const | 84 | QWidget *AbPickItem::createEditor() const |
85 | { | 85 | { |
86 | QComboBox* combo = new QComboBox( table()->viewport() ); | 86 | QComboBox* combo = new QComboBox( table()->viewport() ); |
87 | ( (AbPickItem*)this )->cb = combo; | 87 | ( (AbPickItem*)this )->cb = combo; |
88 | AbTable* t = static_cast<AbTable*>(table()); | 88 | AbTable* t = static_cast<AbTable*>(table()); |
89 | QStringList c = t->choiceNames(); | 89 | QStringList c = t->choiceNames(); |
90 | int cur = 0; | 90 | int cur = 0; |
91 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { | 91 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { |
92 | if ( *it == text() ) | 92 | if ( *it == text() ) |
93 | cur = combo->count(); | 93 | cur = combo->count(); |
94 | combo->insertItem(*it); | 94 | combo->insertItem(*it); |
95 | } | 95 | } |
96 | combo->setCurrentItem(cur); | 96 | combo->setCurrentItem(cur); |
97 | return combo; | 97 | return combo; |
98 | } | 98 | } |
99 | 99 | ||
100 | void AbPickItem::setContentFromEditor( QWidget *w ) | 100 | void AbPickItem::setContentFromEditor( QWidget *w ) |
101 | { | 101 | { |
102 | if ( w->inherits("QComboBox") ) | 102 | if ( w->inherits("QComboBox") ) |
103 | setText( ( (QComboBox*)w )->currentText() ); | 103 | setText( ( (QComboBox*)w )->currentText() ); |
104 | else | 104 | else |
105 | QTableItem::setContentFromEditor( w ); | 105 | QTableItem::setContentFromEditor( w ); |
106 | } | 106 | } |
107 | 107 | ||
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | /*! | 110 | /*! |
111 | \class AbTable abtable.h | 111 | \class AbTable abtable.h |
112 | 112 | ||
113 | \brief QTable based class for showing a list of entries | 113 | \brief QTable based class for showing a list of entries |
114 | */ | 114 | */ |
115 | 115 | ||
116 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 116 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
117 | : QTable( parent, name ), | 117 | : QTable( parent, name ), |
118 | lastSortCol( -1 ), | 118 | lastSortCol( -1 ), |
119 | asc( TRUE ), | 119 | asc( TRUE ), |
120 | intFields( order ), | 120 | intFields( order ), |
121 | enablePainting( true ), | 121 | enablePainting( true ), |
122 | columnVisible( true ), | 122 | columnVisible( true ), |
123 | countNested( 0 ) | 123 | countNested( 0 ) |
124 | { | 124 | { |
125 | //qWarning("C'tor start"); | 125 | //qWarning("C'tor start"); |
126 | 126 | ||
127 | setSelectionMode( NoSelection ); | 127 | setSelectionMode( NoSelection ); |
128 | init(); | 128 | init(); |
129 | setSorting( TRUE ); | 129 | setSorting( TRUE ); |
130 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 130 | connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), |
131 | this, SLOT(itemClicked(int,int)) ); | 131 | this, SLOT(itemClicked(int,int)) ); |
132 | 132 | ||
133 | // contactList.clear(); | 133 | // contactList.clear(); |
134 | //qWarning("C'tor end"); | 134 | //qWarning("C'tor end"); |
135 | } | 135 | } |
136 | 136 | ||
137 | AbTable::~AbTable() | 137 | AbTable::~AbTable() |
138 | { | 138 | { |
139 | } | 139 | } |
140 | 140 | ||
141 | void AbTable::init() | 141 | void AbTable::init() |
142 | { | 142 | { |
143 | // :SX showChar = '\0'; | 143 | // :SX showChar = '\0'; |
144 | setNumRows( 0 ); | 144 | setNumRows( 0 ); |
145 | setNumCols( 2 ); | 145 | setNumCols( 2 ); |
146 | 146 | ||
147 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 147 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
148 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 148 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
149 | setLeftMargin( 0 ); | 149 | setLeftMargin( 0 ); |
150 | verticalHeader()->hide(); | 150 | verticalHeader()->hide(); |
151 | columnVisible = true; | 151 | columnVisible = true; |
152 | } | 152 | } |
153 | 153 | ||
154 | void AbTable::setContacts( const OContactAccess::List& viewList ) | 154 | void AbTable::setContacts( const OContactAccess::List& viewList ) |
155 | { | 155 | { |
156 | qWarning("AbTable::setContacts()"); | 156 | qWarning("AbTable::setContacts()"); |
157 | 157 | ||
158 | clear(); | 158 | clear(); |
159 | m_viewList = viewList; | 159 | m_viewList = viewList; |
160 | 160 | ||
161 | setSorting( false ); | 161 | setSorting( false ); |
162 | setPaintingEnabled( FALSE ); | 162 | setPaintingEnabled( FALSE ); |
163 | 163 | ||
164 | OContactAccess::List::Iterator it; | 164 | OContactAccess::List::Iterator it; |
165 | setNumRows( m_viewList.count() ); | 165 | setNumRows( m_viewList.count() ); |
166 | //int row = 0; | 166 | //int row = 0; |
167 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | 167 | // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) |
168 | // insertIntoTable( *it, row++ ); | 168 | // insertIntoTable( *it, row++ ); |
169 | 169 | ||
170 | // setSorting( true ); | 170 | // setSorting( true ); |
171 | 171 | ||
172 | // resort(); | 172 | // resort(); |
173 | 173 | ||
174 | updateVisible(); | 174 | updateVisible(); |
175 | 175 | ||
176 | setPaintingEnabled( TRUE ); | 176 | setPaintingEnabled( TRUE ); |
177 | 177 | ||
178 | } | 178 | } |
179 | 179 | ||
180 | void AbTable::setOrderedList( const QValueList<int> ordered ) | 180 | void AbTable::setOrderedList( const QValueList<int> ordered ) |
181 | { | 181 | { |
182 | intFields = ordered; | 182 | intFields = ordered; |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | bool AbTable::selectContact( int UID ) | 186 | bool AbTable::selectContact( int UID ) |
187 | { | 187 | { |
188 | qWarning( "AbTable::selectContact( %d )", UID ); | 188 | qWarning( "AbTable::selectContact( %d )", UID ); |
189 | int rows = numRows(); | 189 | int rows = numRows(); |
190 | OContact* foundContact = 0l; | 190 | OContact* foundContact = 0l; |
191 | bool found = false; | 191 | bool found = false; |
192 | 192 | ||
193 | setPaintingEnabled( FALSE ); | 193 | setPaintingEnabled( FALSE ); |
194 | qWarning( "search start" ); | 194 | qWarning( "search start" ); |
195 | for ( int r = 0; r < rows; ++r ) { | 195 | for ( int r = 0; r < rows; ++r ) { |
196 | if ( m_viewList.uidAt( r ) == UID ){ | 196 | if ( m_viewList.uidAt( r ) == UID ){ |
197 | ensureCellVisible( r, 0 ); | 197 | ensureCellVisible( r, 0 ); |
198 | setCurrentCell( r, 0 ); | 198 | setCurrentCell( r, 0 ); |
199 | found = true; | 199 | found = true; |
200 | break; | 200 | break; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | qWarning( "search end" ); | 203 | qWarning( "search end" ); |
204 | 204 | ||
205 | if ( !found ){ | 205 | if ( !found ){ |
206 | ensureCellVisible( 0,0 ); | 206 | ensureCellVisible( 0,0 ); |
207 | setCurrentCell( 0, 0 ); | 207 | setCurrentCell( 0, 0 ); |
208 | } | 208 | } |
209 | 209 | ||
210 | setPaintingEnabled( TRUE ); | 210 | setPaintingEnabled( TRUE ); |
211 | 211 | ||
212 | return true; | 212 | return true; |
213 | } | 213 | } |
214 | 214 | ||
215 | #if 0 | 215 | #if 0 |
216 | void AbTable::insertIntoTable( const OContact& cnt, int row ) | 216 | void AbTable::insertIntoTable( const OContact& cnt, int row ) |
217 | { | 217 | { |
218 | qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); | 218 | qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); |
219 | QString strName; | 219 | QString strName; |
220 | ContactItem contactItem; | 220 | ContactItem contactItem; |
221 | 221 | ||
222 | strName = findContactName( cnt ); | 222 | strName = findContactName( cnt ); |
223 | contactItem = findContactContact( cnt, row ); | 223 | contactItem = findContactContact( cnt, row ); |
224 | 224 | ||
225 | AbTableItem *ati; | 225 | AbTableItem *ati; |
226 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); | 226 | ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); |
227 | contactList.insert( ati, cnt ); | 227 | contactList.insert( ati, cnt ); |
228 | setItem( row, 0, ati ); | 228 | setItem( row, 0, ati ); |
229 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); | 229 | ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); |
230 | if ( !contactItem.icon.isNull() ) | 230 | if ( !contactItem.icon.isNull() ) |
231 | ati->setPixmap( contactItem.icon ); | 231 | ati->setPixmap( contactItem.icon ); |
232 | setItem( row, 1, ati ); | 232 | setItem( row, 1, ati ); |
233 | 233 | ||
234 | //### cannot do this; table only has two columns at this point | 234 | //### cannot do this; table only has two columns at this point |
235 | // setItem( row, 2, new AbPickItem( this ) ); | 235 | // setItem( row, 2, new AbPickItem( this ) ); |
236 | 236 | ||
237 | } | 237 | } |
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | 240 | ||
241 | void AbTable::columnClicked( int col ) | 241 | void AbTable::columnClicked( int col ) |
242 | { | 242 | { |
243 | if ( !sorting() ) | 243 | if ( !sorting() ) |
244 | return; | 244 | return; |
245 | 245 | ||
246 | if ( lastSortCol == -1 ) | 246 | if ( lastSortCol == -1 ) |
247 | lastSortCol = col; | 247 | lastSortCol = col; |
248 | 248 | ||
249 | if ( col == lastSortCol ) { | 249 | if ( col == lastSortCol ) { |
250 | asc = !asc; | 250 | asc = !asc; |
251 | } else { | 251 | } else { |
252 | lastSortCol = col; | 252 | lastSortCol = col; |
253 | asc = TRUE; | 253 | asc = TRUE; |
254 | } | 254 | } |
255 | //QMessageBox::information( this, "resort", "columnClicked" ); | 255 | //QMessageBox::information( this, "resort", "columnClicked" ); |
256 | resort(); | 256 | resort(); |
257 | } | 257 | } |
258 | 258 | ||
259 | void AbTable::resort() | 259 | void AbTable::resort() |
260 | { | 260 | { |
261 | qWarning( "void AbTable::resort() NOT POSSIBLE !!" ); | 261 | qWarning( "void AbTable::resort() NOT POSSIBLE !!" ); |
262 | #if 0 | 262 | #if 0 |
263 | setPaintingEnabled( FALSE ); | 263 | setPaintingEnabled( FALSE ); |
264 | if ( sorting() ) { | 264 | if ( sorting() ) { |
265 | if ( lastSortCol == -1 ) | 265 | if ( lastSortCol == -1 ) |
266 | lastSortCol = 0; | 266 | lastSortCol = 0; |
267 | sortColumn( lastSortCol, asc, TRUE ); | 267 | sortColumn( lastSortCol, asc, TRUE ); |
268 | //QMessageBox::information( this, "resort", "resort" ); | 268 | //QMessageBox::information( this, "resort", "resort" ); |
269 | updateVisible(); | 269 | updateVisible(); |
270 | } | 270 | } |
271 | setPaintingEnabled( TRUE ); | 271 | setPaintingEnabled( TRUE ); |
272 | #endif | 272 | #endif |
273 | } | 273 | } |
274 | 274 | ||
275 | OContact AbTable::currentEntry() | 275 | OContact AbTable::currentEntry() |
276 | { | 276 | { |
277 | return m_viewList[currentRow()]; | 277 | return m_viewList[currentRow()]; |
278 | } | 278 | } |
279 | 279 | ||
280 | int AbTable::currentEntry_UID() | 280 | int AbTable::currentEntry_UID() |
281 | { | 281 | { |
282 | return ( currentEntry().uid() ); | 282 | return ( currentEntry().uid() ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void AbTable::clear() | 285 | void AbTable::clear() |
286 | { | 286 | { |
287 | qWarning( "void AbTable::clear()" ); | 287 | qWarning( "void AbTable::clear()" ); |
288 | // contactList.clear(); | 288 | // contactList.clear(); |
289 | 289 | ||
290 | setPaintingEnabled( FALSE ); | 290 | setPaintingEnabled( FALSE ); |
291 | for ( int r = 0; r < numRows(); ++r ) { | 291 | for ( int r = 0; r < numRows(); ++r ) { |
292 | for ( int c = 0; c < numCols(); ++c ) { | 292 | for ( int c = 0; c < numCols(); ++c ) { |
293 | if ( cellWidget( r, c ) ) | 293 | if ( cellWidget( r, c ) ) |
294 | clearCellWidget( r, c ); | 294 | clearCellWidget( r, c ); |
295 | clearCell( r, c ); | 295 | clearCell( r, c ); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | setNumRows( 0 ); | 298 | setNumRows( 0 ); |
299 | setPaintingEnabled( TRUE ); | 299 | setPaintingEnabled( TRUE ); |
300 | } | 300 | } |
301 | 301 | ||
302 | // Refresh updates column 2 if the contactsettings changed | 302 | // Refresh updates column 2 if the contactsettings changed |
303 | void AbTable::refresh() | 303 | void AbTable::refresh() |
304 | { | 304 | { |
305 | qWarning( "void AbTable::refresh() NOT IMPLEMENTED !!" ); | 305 | qWarning( "void AbTable::refresh() NOT IMPLEMENTED !!" ); |
306 | 306 | ||
307 | #if 0 | 307 | #if 0 |
308 | int rows = numRows(); | 308 | int rows = numRows(); |
309 | AbTableItem *abi; | 309 | AbTableItem *abi; |
310 | ContactItem contactItem; | 310 | ContactItem contactItem; |
311 | 311 | ||
312 | setPaintingEnabled( FALSE ); | 312 | setPaintingEnabled( FALSE ); |
313 | for ( int r = 0; r < rows; ++r ) { | 313 | for ( int r = 0; r < rows; ++r ) { |
314 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 314 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
315 | contactItem = findContactContact( contactList[abi], r ); | 315 | contactItem = findContactContact( contactList[abi], r ); |
316 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); | 316 | static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); |
317 | if ( !contactItem.icon.isNull() ){ | 317 | if ( !contactItem.icon.isNull() ){ |
318 | static_cast<AbTableItem*>( item(r, 1) )-> | 318 | static_cast<AbTableItem*>( item(r, 1) )-> |
319 | setPixmap( contactItem.icon ); | 319 | setPixmap( contactItem.icon ); |
320 | }else{ | 320 | }else{ |
321 | static_cast<AbTableItem*>( item(r, 1) )-> | 321 | static_cast<AbTableItem*>( item(r, 1) )-> |
322 | setPixmap( QPixmap() ); | 322 | setPixmap( QPixmap() ); |
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 670cdb0..8d61582 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -1,275 +1,275 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) | 2 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** | 14 | ** |
15 | **********************************************************************/ | 15 | **********************************************************************/ |
16 | 16 | ||
17 | #include "abview.h" | 17 | #include "abview.h" |
18 | 18 | ||
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | 20 | ||
21 | #include <qpe/global.h> | 21 | #include <qpe/global.h> |
22 | 22 | ||
23 | #include <opie/ocontactaccessbackend_vcard.h> | 23 | #include <opie/ocontactaccessbackend_vcard.h> |
24 | 24 | ||
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | 26 | ||
27 | 27 | ||
28 | // Is defined in LibQPE | 28 | // Is defined in LibQPE |
29 | extern QString categoryFileName(); | 29 | extern QString categoryFileName(); |
30 | 30 | ||
31 | QString addressbookPersonalVCardName() | 31 | QString addressbookPersonalVCardName() |
32 | { | 32 | { |
33 | QString filename = Global::applicationFileName("addressbook", | 33 | QString filename = Global::applicationFileName("addressbook", |
34 | "businesscard.vcf"); | 34 | "businesscard.vcf"); |
35 | return filename; | 35 | return filename; |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): | 39 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): |
40 | QWidget(parent), | 40 | QWidget(parent), |
41 | mCat(0), | 41 | mCat(0), |
42 | m_inSearch( false ), | 42 | m_inSearch( false ), |
43 | m_inPersonal( false ), | 43 | m_inPersonal( false ), |
44 | m_curr_category( -1 ), | 44 | m_curr_category( -1 ), |
45 | m_curr_View( TableView ), | 45 | m_curr_View( TableView ), |
46 | m_prev_View( TableView ), | 46 | m_prev_View( TableView ), |
47 | m_curr_Contact ( 0 ), | 47 | m_curr_Contact ( 0 ), |
48 | m_contactdb ( 0l ), | 48 | m_contactdb ( 0l ), |
49 | m_storedDB ( 0l ), | 49 | m_storedDB ( 0l ), |
50 | m_viewStack( 0l ), | 50 | m_viewStack( 0l ), |
51 | m_abTable( 0l ), | 51 | m_abTable( 0l ), |
52 | m_orderedFields( ordered ) | 52 | m_orderedFields( ordered ) |
53 | { | 53 | { |
54 | qWarning("AbView::c'tor"); | 54 | qWarning("AbView::c'tor"); |
55 | // Load default database and handle syncing myself.. ! | 55 | // Load default database and handle syncing myself.. ! |
56 | m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ); | 56 | m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ); |
57 | m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available | 57 | m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available |
58 | mCat.load( categoryFileName() ); | 58 | mCat.load( categoryFileName() ); |
59 | 59 | ||
60 | // Create Layout and put WidgetStack into it. | 60 | // Create Layout and put WidgetStack into it. |
61 | QVBoxLayout *vb = new QVBoxLayout( this ); | 61 | QVBoxLayout *vb = new QVBoxLayout( this ); |
62 | m_viewStack = new QWidgetStack( this ); | 62 | m_viewStack = new QWidgetStack( this ); |
63 | vb->addWidget( m_viewStack ); | 63 | vb->addWidget( m_viewStack ); |
64 | 64 | ||
65 | // Creat TableView | 65 | // Creat TableView |
66 | QVBox* tableBox = new QVBox( m_viewStack ); | 66 | QVBox* tableBox = new QVBox( m_viewStack ); |
67 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); | 67 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); |
68 | m_abTable->setCurrentCell( 0, 0 ); | 68 | m_abTable->setCurrentCell( 0, 0 ); |
69 | m_abTable->setFocus(); | 69 | m_abTable->setFocus(); |
70 | 70 | ||
71 | // Add TableView to WidgetStack and raise it | 71 | // Add TableView to WidgetStack and raise it |
72 | m_viewStack -> addWidget( tableBox , TableView ); | 72 | m_viewStack -> addWidget( tableBox , TableView ); |
73 | 73 | ||
74 | // Create CardView and add it to WidgetStack | 74 | // Create CardView and add it to WidgetStack |
75 | QVBox* cardBox = new QVBox( m_viewStack ); | 75 | QVBox* cardBox = new QVBox( m_viewStack ); |
76 | m_ablabel = new AbLabel( cardBox, "CardView"); | 76 | m_ablabel = new AbLabel( cardBox, "CardView"); |
77 | m_viewStack -> addWidget( cardBox , CardView ); | 77 | m_viewStack -> addWidget( cardBox , CardView ); |
78 | 78 | ||
79 | // Connect views to me | 79 | // Connect views to me |
80 | connect ( m_abTable, SIGNAL( signalSwitch( void ) ), | 80 | connect ( m_abTable, SIGNAL( signalSwitch(void) ), |
81 | this, SLOT( slotSwitch( void ) ) ); | 81 | this, SLOT( slotSwitch(void) ) ); |
82 | connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), | 82 | connect ( m_ablabel, SIGNAL( signalOkPressed(void) ), |
83 | this, SLOT( slotSwitch( void ) ) ); | 83 | this, SLOT( slotSwitch(void) ) ); |
84 | 84 | ||
85 | load(); | 85 | load(); |
86 | } | 86 | } |
87 | 87 | ||
88 | AbView::~AbView() | 88 | AbView::~AbView() |
89 | { | 89 | { |
90 | m_contactdb -> save(); | 90 | m_contactdb -> save(); |
91 | delete m_contactdb; | 91 | delete m_contactdb; |
92 | 92 | ||
93 | if ( m_storedDB ){ | 93 | if ( m_storedDB ){ |
94 | m_storedDB -> save(); | 94 | m_storedDB -> save(); |
95 | delete m_storedDB; | 95 | delete m_storedDB; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void AbView::setView( Views view ) | 100 | void AbView::setView( Views view ) |
101 | { | 101 | { |
102 | qWarning("AbView::setView( Views view )"); | 102 | qWarning("AbView::setView( Views view )"); |
103 | m_curr_View = view; | 103 | m_curr_View = view; |
104 | load(); | 104 | load(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void AbView::addEntry( const OContact &newContact ) | 107 | void AbView::addEntry( const OContact &newContact ) |
108 | { | 108 | { |
109 | qWarning("abview:AddContact"); | 109 | qWarning("abview:AddContact"); |
110 | m_contactdb->add ( newContact ); | 110 | m_contactdb->add ( newContact ); |
111 | load(); | 111 | load(); |
112 | 112 | ||
113 | } | 113 | } |
114 | void AbView::removeEntry( const int UID ) | 114 | void AbView::removeEntry( const int UID ) |
115 | { | 115 | { |
116 | qWarning("abview:RemoveContact"); | 116 | qWarning("abview:RemoveContact"); |
117 | m_contactdb->remove( UID ); | 117 | m_contactdb->remove( UID ); |
118 | load(); | 118 | load(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void AbView::replaceEntry( const OContact &contact ) | 121 | void AbView::replaceEntry( const OContact &contact ) |
122 | { | 122 | { |
123 | qWarning("abview:ReplaceContact"); | 123 | qWarning("abview:ReplaceContact"); |
124 | m_contactdb->replace( contact ); | 124 | m_contactdb->replace( contact ); |
125 | load(); | 125 | load(); |
126 | 126 | ||
127 | } | 127 | } |
128 | 128 | ||
129 | OContact AbView::currentEntry() | 129 | OContact AbView::currentEntry() |
130 | { | 130 | { |
131 | OContact currentContact; | 131 | OContact currentContact; |
132 | 132 | ||
133 | switch ( (int) m_curr_View ) { | 133 | switch ( (int) m_curr_View ) { |
134 | case TableView: | 134 | case TableView: |
135 | currentContact = m_abTable -> currentEntry(); | 135 | currentContact = m_abTable -> currentEntry(); |
136 | break; | 136 | break; |
137 | case CardView: | 137 | case CardView: |
138 | currentContact = m_ablabel -> currentEntry(); | 138 | currentContact = m_ablabel -> currentEntry(); |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | m_curr_Contact = currentContact.uid(); | 141 | m_curr_Contact = currentContact.uid(); |
142 | return currentContact; | 142 | return currentContact; |
143 | } | 143 | } |
144 | 144 | ||
145 | bool AbView::save() | 145 | bool AbView::save() |
146 | { | 146 | { |
147 | //qWarning("abView:Save data"); | 147 | //qWarning("abView:Save data"); |
148 | 148 | ||
149 | return m_contactdb->save(); | 149 | return m_contactdb->save(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void AbView::load() | 152 | void AbView::load() |
153 | { | 153 | { |
154 | qWarning("abView:Load data"); | 154 | qWarning("abView:Load data"); |
155 | 155 | ||
156 | // Letter Search is stopped at this place | 156 | // Letter Search is stopped at this place |
157 | emit signalClearLetterPicker(); | 157 | emit signalClearLetterPicker(); |
158 | 158 | ||
159 | if ( m_inPersonal ) | 159 | if ( m_inPersonal ) |
160 | // VCard Backend does not sort.. | 160 | // VCard Backend does not sort.. |
161 | m_list = m_contactdb->allRecords(); | 161 | m_list = m_contactdb->allRecords(); |
162 | else{ | 162 | else{ |
163 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); | 163 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); |
164 | if ( m_curr_category != -1 ) | 164 | if ( m_curr_category != -1 ) |
165 | clearForCategory(); | 165 | clearForCategory(); |
166 | } | 166 | } |
167 | 167 | ||
168 | qWarning ("Number of contacts: %d", m_list.count()); | 168 | qWarning ("Number of contacts: %d", m_list.count()); |
169 | 169 | ||
170 | updateView( true ); | 170 | updateView( true ); |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | void AbView::reload() | 174 | void AbView::reload() |
175 | { | 175 | { |
176 | qWarning( "void AbView::reload()" ); | 176 | qWarning( "void AbView::reload()" ); |
177 | 177 | ||
178 | m_contactdb->reload(); | 178 | m_contactdb->reload(); |
179 | load(); | 179 | load(); |
180 | } | 180 | } |
181 | 181 | ||
182 | void AbView::clear() | 182 | void AbView::clear() |
183 | { | 183 | { |
184 | // :SX | 184 | // :SX |
185 | } | 185 | } |
186 | 186 | ||
187 | void AbView::setShowByCategory( const QString& cat ) | 187 | void AbView::setShowByCategory( const QString& cat ) |
188 | { | 188 | { |
189 | qWarning("AbView::setShowCategory( const QString& cat )"); | 189 | qWarning("AbView::setShowCategory( const QString& cat )"); |
190 | 190 | ||
191 | int intCat = 0; | 191 | int intCat = 0; |
192 | 192 | ||
193 | // All (cat == NULL) will be stored as -1 | 193 | // All (cat == NULL) will be stored as -1 |
194 | if ( cat.isNull() ) | 194 | if ( cat.isNull() ) |
195 | intCat = -1; | 195 | intCat = -1; |
196 | else | 196 | else |
197 | intCat = mCat.id("Contacts", cat ); | 197 | intCat = mCat.id("Contacts", cat ); |
198 | 198 | ||
199 | // Just do anything if we really change the category | 199 | // Just do anything if we really change the category |
200 | if ( intCat != m_curr_category ){ | 200 | if ( intCat != m_curr_category ){ |
201 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); | 201 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); |
202 | 202 | ||
203 | m_curr_category = intCat; | 203 | m_curr_category = intCat; |
204 | emit signalClearLetterPicker(); | 204 | emit signalClearLetterPicker(); |
205 | 205 | ||
206 | load(); | 206 | load(); |
207 | } | 207 | } |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | void AbView::setShowToView( Views view ) | 211 | void AbView::setShowToView( Views view ) |
212 | { | 212 | { |
213 | qWarning("void AbView::setShowToView( View %d )", view); | 213 | qWarning("void AbView::setShowToView( View %d )", view); |
214 | 214 | ||
215 | if ( m_curr_View != view ){ | 215 | if ( m_curr_View != view ){ |
216 | qWarning ("Change the View (Category is: %d)", m_curr_category); | 216 | qWarning ("Change the View (Category is: %d)", m_curr_category); |
217 | m_prev_View = m_curr_View; | 217 | m_prev_View = m_curr_View; |
218 | m_curr_View = view; | 218 | m_curr_View = view; |
219 | 219 | ||
220 | updateView(); | 220 | updateView(); |
221 | } | 221 | } |
222 | 222 | ||
223 | } | 223 | } |
224 | 224 | ||
225 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | 225 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) |
226 | { | 226 | { |
227 | qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); | 227 | qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); |
228 | 228 | ||
229 | assert( mode < AbConfig::LASTELEMENT ); | 229 | assert( mode < AbConfig::LASTELEMENT ); |
230 | 230 | ||
231 | OContact query; | 231 | OContact query; |
232 | if ( c == 0 ){ | 232 | if ( c == 0 ){ |
233 | load(); | 233 | load(); |
234 | return; | 234 | return; |
235 | }else{ | 235 | }else{ |
236 | // If the current Backend is unable to solve the query, we will | 236 | // If the current Backend is unable to solve the query, we will |
237 | // ignore the request .. | 237 | // ignore the request .. |
238 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ | 238 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ |
239 | return; | 239 | return; |
240 | } | 240 | } |
241 | 241 | ||
242 | switch( mode ){ | 242 | switch( mode ){ |
243 | case AbConfig::LastName: | 243 | case AbConfig::LastName: |
244 | query.setLastName( QString("%1*").arg(c) ); | 244 | query.setLastName( QString("%1*").arg(c) ); |
245 | break; | 245 | break; |
246 | case AbConfig::FileAs: | 246 | case AbConfig::FileAs: |
247 | query.setFileAs( QString("%1*").arg(c) ); | 247 | query.setFileAs( QString("%1*").arg(c) ); |
248 | break; | 248 | break; |
249 | default: | 249 | default: |
250 | qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); | 250 | qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); |
251 | qWarning( "I will ignore it.." ); | 251 | qWarning( "I will ignore it.." ); |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); | 254 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); |
255 | if ( m_curr_category != -1 ) | 255 | if ( m_curr_category != -1 ) |
256 | clearForCategory(); | 256 | clearForCategory(); |
257 | m_curr_Contact = 0; | 257 | m_curr_Contact = 0; |
258 | } | 258 | } |
259 | updateView( true ); | 259 | updateView( true ); |
260 | } | 260 | } |
261 | 261 | ||
262 | void AbView::setListOrder( const QValueList<int>& ordered ) | 262 | void AbView::setListOrder( const QValueList<int>& ordered ) |
263 | { | 263 | { |
264 | m_orderedFields = ordered; | 264 | m_orderedFields = ordered; |
265 | if ( m_abTable ){ | 265 | if ( m_abTable ){ |
266 | m_abTable->setOrderedList( ordered ); | 266 | m_abTable->setOrderedList( ordered ); |
267 | m_abTable->refresh(); | 267 | m_abTable->refresh(); |
268 | } | 268 | } |
269 | updateView(); | 269 | updateView(); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | QString AbView::showCategory() const | 273 | QString AbView::showCategory() const |
274 | { | 274 | { |
275 | return mCat.label( "Contacts", m_curr_category ); | 275 | return mCat.label( "Contacts", m_curr_category ); |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 9cf55b3..8a5f9d5 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,868 +1,868 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). | 5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #define QTOPIA_INTERNAL_FD | 20 | #define QTOPIA_INTERNAL_FD |
21 | 21 | ||
22 | // #include "addresssettings.h" | 22 | // #include "addresssettings.h" |
23 | #include "addressbook.h" | 23 | #include "addressbook.h" |
24 | 24 | ||
25 | 25 | ||
26 | #include <opie/ofileselector.h> | 26 | #include <opie/ofileselector.h> |
27 | #include <opie/ofiledialog.h> | 27 | #include <opie/ofiledialog.h> |
28 | #include <opie/ocontact.h> | 28 | #include <opie/ocontact.h> |
29 | #include <opie/ocontactaccessbackend_vcard.h> | 29 | #include <opie/ocontactaccessbackend_vcard.h> |
30 | 30 | ||
31 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
32 | #include <qpe/ir.h> | 32 | #include <qpe/ir.h> |
33 | #include <qpe/qpemessagebox.h> | 33 | #include <qpe/qpemessagebox.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | // #include <qtoolbar.h> | 35 | // #include <qtoolbar.h> |
36 | // #include <qmenubar.h> | 36 | // #include <qmenubar.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | 38 | ||
39 | #include <qaction.h> | 39 | #include <qaction.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
42 | #include <qtoolbutton.h> | 42 | #include <qtoolbutton.h> |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <sys/types.h> | 46 | #include <sys/types.h> |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | 50 | ||
51 | #include "picker.h" | 51 | #include "picker.h" |
52 | #include "configdlg.h" | 52 | #include "configdlg.h" |
53 | 53 | ||
54 | extern QString addressbookPersonalVCardName(); | 54 | extern QString addressbookPersonalVCardName(); |
55 | 55 | ||
56 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 56 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
57 | WFlags f ) | 57 | WFlags f ) |
58 | : QMainWindow( parent, name, f ), | 58 | : QMainWindow( parent, name, f ), |
59 | catMenu (0l), | 59 | catMenu (0l), |
60 | abEditor(0l), | 60 | abEditor(0l), |
61 | syncing(FALSE), | 61 | syncing(FALSE), |
62 | m_tableViewButton(0l), | 62 | m_tableViewButton(0l), |
63 | m_cardViewButton(0l) | 63 | m_cardViewButton(0l) |
64 | { | 64 | { |
65 | isLoading = true; | 65 | isLoading = true; |
66 | 66 | ||
67 | m_config.load(); | 67 | m_config.load(); |
68 | 68 | ||
69 | setCaption( tr("Contacts") ); | 69 | setCaption( tr("Contacts") ); |
70 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 70 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
71 | 71 | ||
72 | // Settings for Main Menu | 72 | // Settings for Main Menu |
73 | // setToolBarsMovable( false ); | 73 | // setToolBarsMovable( false ); |
74 | setToolBarsMovable( !m_config.fixedBars() ); | 74 | setToolBarsMovable( !m_config.fixedBars() ); |
75 | setRightJustification( true ); | 75 | setRightJustification( true ); |
76 | 76 | ||
77 | QToolBar *bar = new QToolBar( this ); | 77 | QToolBar *bar = new QToolBar( this ); |
78 | bar->setHorizontalStretchable( TRUE ); | 78 | bar->setHorizontalStretchable( TRUE ); |
79 | 79 | ||
80 | QMenuBar *mbList = new QMenuBar( bar ); | 80 | QMenuBar *mbList = new QMenuBar( bar ); |
81 | mbList->setMargin( 0 ); | 81 | mbList->setMargin( 0 ); |
82 | 82 | ||
83 | QPopupMenu *edit = new QPopupMenu( mbList ); | 83 | QPopupMenu *edit = new QPopupMenu( mbList ); |
84 | mbList->insertItem( tr( "Contact" ), edit ); | 84 | mbList->insertItem( tr( "Contact" ), edit ); |
85 | 85 | ||
86 | // Category Menu | 86 | // Category Menu |
87 | catMenu = new QPopupMenu( this ); | 87 | catMenu = new QPopupMenu( this ); |
88 | catMenu->setCheckable( TRUE ); | 88 | catMenu->setCheckable( TRUE ); |
89 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 89 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
90 | mbList->insertItem( tr("View"), catMenu ); | 90 | mbList->insertItem( tr("View"), catMenu ); |
91 | 91 | ||
92 | // Create Toolbar | 92 | // Create Toolbar |
93 | listTools = new QToolBar( this, "list operations" ); | 93 | listTools = new QToolBar( this, "list operations" ); |
94 | listTools->setHorizontalStretchable( true ); | 94 | listTools->setHorizontalStretchable( true ); |
95 | addToolBar( listTools ); | 95 | addToolBar( listTools ); |
96 | moveToolBar( listTools, m_config.getToolBarPos() ); | 96 | moveToolBar( listTools, m_config.getToolBarPos() ); |
97 | 97 | ||
98 | // View Icons | 98 | // View Icons |
99 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), | 99 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), |
100 | QString::null, 0, this, 0 ); | 100 | QString::null, 0, this, 0 ); |
101 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 101 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
102 | m_tableViewButton->setToggleAction( true ); | 102 | m_tableViewButton->setToggleAction( true ); |
103 | m_tableViewButton->addTo( listTools ); | 103 | m_tableViewButton->addTo( listTools ); |
104 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); | 104 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); |
105 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 105 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
106 | m_cardViewButton->setToggleAction( true ); | 106 | m_cardViewButton->setToggleAction( true ); |
107 | m_cardViewButton->addTo( listTools ); | 107 | m_cardViewButton->addTo( listTools ); |
108 | 108 | ||
109 | listTools->addSeparator(); | 109 | listTools->addSeparator(); |
110 | 110 | ||
111 | // Other Buttons | 111 | // Other Buttons |
112 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 112 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
113 | 0, this, 0 ); | 113 | 0, this, 0 ); |
114 | actionNew = a; | 114 | actionNew = a; |
115 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 115 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
116 | a->addTo( edit ); | 116 | a->addTo( edit ); |
117 | a->addTo( listTools ); | 117 | a->addTo( listTools ); |
118 | 118 | ||
119 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 119 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
120 | 0, this, 0 ); | 120 | 0, this, 0 ); |
121 | actionEdit = a; | 121 | actionEdit = a; |
122 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 122 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
123 | a->addTo( edit ); | 123 | a->addTo( edit ); |
124 | a->addTo( listTools ); | 124 | a->addTo( listTools ); |
125 | 125 | ||
126 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 126 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
127 | 0, this, 0 ); | 127 | 0, this, 0 ); |
128 | actionTrash = a; | 128 | actionTrash = a; |
129 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 129 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
130 | a->addTo( edit ); | 130 | a->addTo( edit ); |
131 | a->addTo( listTools ); | 131 | a->addTo( listTools ); |
132 | 132 | ||
133 | 133 | ||
134 | // make it possible to go directly to businesscard via qcop call | 134 | // make it possible to go directly to businesscard via qcop call |
135 | //#if defined(Q_WS_QWS) // Why this ? (se) | 135 | //#if defined(Q_WS_QWS) // Why this ? (se) |
136 | #if !defined(QT_NO_COP) | 136 | #if !defined(QT_NO_COP) |
137 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 137 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
138 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 138 | connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), |
139 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 139 | this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); |
140 | #endif | 140 | #endif |
141 | // #endif | 141 | // #endif |
142 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 142 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
143 | QString::null, 0, this, 0 ); | 143 | QString::null, 0, this, 0 ); |
144 | actionFind = a; | 144 | actionFind = a; |
145 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 145 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
146 | a->addTo( edit ); | 146 | a->addTo( edit ); |
147 | a->addTo( listTools ); | 147 | a->addTo( listTools ); |
148 | 148 | ||
149 | // Much better search widget, taken from QTReader.. (se) | 149 | // Much better search widget, taken from QTReader.. (se) |
150 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 150 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
151 | searchBar->setHorizontalStretchable( TRUE ); | 151 | searchBar->setHorizontalStretchable( TRUE ); |
152 | searchBar->hide(); | 152 | searchBar->hide(); |
153 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 153 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
154 | 154 | ||
155 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 155 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
156 | // searchEdit->setFont( f ); | 156 | // searchEdit->setFont( f ); |
157 | 157 | ||
158 | searchBar->setStretchableWidget( searchEdit ); | 158 | searchBar->setStretchableWidget( searchEdit ); |
159 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 159 | connect( searchEdit, SIGNAL( returnPressed() ), |
160 | this, SLOT( slotFind( ) ) ); | 160 | this, SLOT( slotFind() ) ); |
161 | 161 | ||
162 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 162 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
163 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 163 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
164 | a->addTo( searchBar ); | 164 | a->addTo( searchBar ); |
165 | 165 | ||
166 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 166 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
167 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 167 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
168 | a->addTo( searchBar ); | 168 | a->addTo( searchBar ); |
169 | 169 | ||
170 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), | 170 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), |
171 | QString::null, 0, this, 0 ); | 171 | QString::null, 0, this, 0 ); |
172 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 172 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
173 | actionMail = a; | 173 | actionMail = a; |
174 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 174 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
175 | a->addTo( edit ); | 175 | a->addTo( edit ); |
176 | a->addTo( listTools ); | 176 | a->addTo( listTools ); |
177 | 177 | ||
178 | if ( Ir::supported() ) { | 178 | if ( Ir::supported() ) { |
179 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 179 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
180 | 0, this, 0 ); | 180 | 0, this, 0 ); |
181 | actionBeam = a; | 181 | actionBeam = a; |
182 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 182 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
183 | a->addTo( edit ); | 183 | a->addTo( edit ); |
184 | a->addTo( listTools ); | 184 | a->addTo( listTools ); |
185 | } | 185 | } |
186 | 186 | ||
187 | edit->insertSeparator(); | 187 | edit->insertSeparator(); |
188 | 188 | ||
189 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, | 189 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, |
190 | 0, this, 0); | 190 | 0, this, 0); |
191 | actionPersonal = a; | 191 | actionPersonal = a; |
192 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 192 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
193 | a->addTo( edit ); | 193 | a->addTo( edit ); |
194 | 194 | ||
195 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, | 195 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, |
196 | 0, this, 0); | 196 | 0, this, 0); |
197 | actionPersonal = a; | 197 | actionPersonal = a; |
198 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); |
199 | a->addTo( edit ); | 199 | a->addTo( edit ); |
200 | 200 | ||
201 | edit->insertSeparator(); | 201 | edit->insertSeparator(); |
202 | 202 | ||
203 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), | 203 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), |
204 | QString::null, 0, this, 0 , TRUE ); | 204 | QString::null, 0, this, 0 , TRUE ); |
205 | actionPersonal = a; | 205 | actionPersonal = a; |
206 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 206 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
207 | a->addTo( edit ); | 207 | a->addTo( edit ); |
208 | 208 | ||
209 | 209 | ||
210 | #ifdef __DEBUG_RELEASE | 210 | #ifdef __DEBUG_RELEASE |
211 | // Remove this function for public Release ! This is only | 211 | // Remove this function for public Release ! This is only |
212 | // for debug purposes .. | 212 | // for debug purposes .. |
213 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 213 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
214 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 214 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
215 | a->addTo( edit ); | 215 | a->addTo( edit ); |
216 | #endif | 216 | #endif |
217 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, | 217 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, |
218 | 0, this, 0 ); | 218 | 0, this, 0 ); |
219 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 219 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
220 | a->addTo( edit ); | 220 | a->addTo( edit ); |
221 | 221 | ||
222 | // Create Views | 222 | // Create Views |
223 | listContainer = new QWidget( this ); | 223 | listContainer = new QWidget( this ); |
224 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 224 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
225 | 225 | ||
226 | m_abView = new AbView( listContainer, m_config.orderList() ); | 226 | m_abView = new AbView( listContainer, m_config.orderList() ); |
227 | vb->addWidget( m_abView ); | 227 | vb->addWidget( m_abView ); |
228 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 228 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
229 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), | 229 | connect( m_abView, SIGNAL( signalViewSwitched(int) ), |
230 | this, SLOT( slotViewSwitched( int ) ) ); | 230 | this, SLOT( slotViewSwitched(int) ) ); |
231 | 231 | ||
232 | 232 | ||
233 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 233 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
234 | 234 | ||
235 | // m_abView->load(); // Already done by c'tor . | 235 | // m_abView->load(); // Already done by c'tor . |
236 | 236 | ||
237 | // Letter Picker | 237 | // Letter Picker |
238 | pLabel = new LetterPicker( listContainer ); | 238 | pLabel = new LetterPicker( listContainer ); |
239 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 239 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
240 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); | 240 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); |
241 | 241 | ||
242 | vb->addWidget( pLabel ); | 242 | vb->addWidget( pLabel ); |
243 | 243 | ||
244 | // All Categories into view-menu.. | 244 | // All Categories into view-menu.. |
245 | populateCategories(); | 245 | populateCategories(); |
246 | 246 | ||
247 | // Fontsize | 247 | // Fontsize |
248 | defaultFont = new QFont( m_abView->font() ); | 248 | defaultFont = new QFont( m_abView->font() ); |
249 | slotSetFont(m_config.fontSize()); | 249 | slotSetFont(m_config.fontSize()); |
250 | m_curFontSize = m_config.fontSize(); | 250 | m_curFontSize = m_config.fontSize(); |
251 | 251 | ||
252 | setCentralWidget(listContainer); | 252 | setCentralWidget(listContainer); |
253 | 253 | ||
254 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 254 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
255 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 255 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
256 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); | 256 | connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); |
257 | connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), | 257 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
258 | this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); | 258 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
259 | 259 | ||
260 | 260 | ||
261 | isLoading = false; | 261 | isLoading = false; |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | void AddressbookWindow::slotConfig() | 265 | void AddressbookWindow::slotConfig() |
266 | { | 266 | { |
267 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 267 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
268 | dlg -> setConfig( m_config ); | 268 | dlg -> setConfig( m_config ); |
269 | if ( QPEApplication::execDialog( dlg ) ) { | 269 | if ( QPEApplication::execDialog( dlg ) ) { |
270 | qWarning ("Config Dialog accepted!"); | 270 | qWarning ("Config Dialog accepted!"); |
271 | m_config = dlg -> getConfig(); | 271 | m_config = dlg -> getConfig(); |
272 | if ( m_curFontSize != m_config.fontSize() ){ | 272 | if ( m_curFontSize != m_config.fontSize() ){ |
273 | qWarning("Font was changed!"); | 273 | qWarning("Font was changed!"); |
274 | m_curFontSize = m_config.fontSize(); | 274 | m_curFontSize = m_config.fontSize(); |
275 | emit slotSetFont( m_curFontSize ); | 275 | emit slotSetFont( m_curFontSize ); |
276 | } | 276 | } |
277 | m_abView -> setListOrder( m_config.orderList() ); | 277 | m_abView -> setListOrder( m_config.orderList() ); |
278 | } | 278 | } |
279 | 279 | ||
280 | delete dlg; | 280 | delete dlg; |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void AddressbookWindow::slotSetFont( int size ) | 284 | void AddressbookWindow::slotSetFont( int size ) |
285 | { | 285 | { |
286 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); | 286 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); |
287 | 287 | ||
288 | if (size > 2 || size < 0) | 288 | if (size > 2 || size < 0) |
289 | size = 1; | 289 | size = 1; |
290 | 290 | ||
291 | m_config.setFontSize( size ); | 291 | m_config.setFontSize( size ); |
292 | 292 | ||
293 | QFont *currentFont; | 293 | QFont *currentFont; |
294 | 294 | ||
295 | switch (size) { | 295 | switch (size) { |
296 | case 0: | 296 | case 0: |
297 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 297 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
298 | currentFont = new QFont (m_abView->font()); | 298 | currentFont = new QFont (m_abView->font()); |
299 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 299 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
300 | // abList->resizeRows(); | 300 | // abList->resizeRows(); |
301 | break; | 301 | break; |
302 | case 1: | 302 | case 1: |
303 | m_abView->setFont( *defaultFont ); | 303 | m_abView->setFont( *defaultFont ); |
304 | currentFont = new QFont (m_abView->font()); | 304 | currentFont = new QFont (m_abView->font()); |
305 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 305 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
306 | // abList->resizeRows(); | 306 | // abList->resizeRows(); |
307 | break; | 307 | break; |
308 | case 2: | 308 | case 2: |
309 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 309 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
310 | currentFont = new QFont (m_abView->font()); | 310 | currentFont = new QFont (m_abView->font()); |
311 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 311 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
312 | // abList->resizeRows(); | 312 | // abList->resizeRows(); |
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | 318 | ||
319 | void AddressbookWindow::importvCard() { | 319 | void AddressbookWindow::importvCard() { |
320 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 320 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
321 | if(!str.isEmpty() ){ | 321 | if(!str.isEmpty() ){ |
322 | setDocument((const QString&) str ); | 322 | setDocument((const QString&) str ); |
323 | } | 323 | } |
324 | 324 | ||
325 | } | 325 | } |
326 | void AddressbookWindow::exportvCard() | 326 | void AddressbookWindow::exportvCard() |
327 | { | 327 | { |
328 | qWarning(" void AddressbookWindow::exportvCard()"); | 328 | qWarning(" void AddressbookWindow::exportvCard()"); |
329 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 329 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
330 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 330 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
331 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); | 331 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); |
332 | OContact curCont = m_abView->currentEntry(); | 332 | OContact curCont = m_abView->currentEntry(); |
333 | if ( !curCont.isEmpty() ){ | 333 | if ( !curCont.isEmpty() ){ |
334 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 334 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
335 | filename ); | 335 | filename ); |
336 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); | 336 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); |
337 | if ( access ){ | 337 | if ( access ){ |
338 | access->add( curCont ); | 338 | access->add( curCont ); |
339 | access->save(); | 339 | access->save(); |
340 | } | 340 | } |
341 | delete access; | 341 | delete access; |
342 | }else | 342 | }else |
343 | QMessageBox::critical( 0, "Export VCard", | 343 | QMessageBox::critical( 0, "Export VCard", |
344 | QString( tr( "You have to select a contact !") ) ); | 344 | QString( tr( "You have to select a contact !") ) ); |
345 | 345 | ||
346 | }else | 346 | }else |
347 | QMessageBox::critical( 0, "Export VCard", | 347 | QMessageBox::critical( 0, "Export VCard", |
348 | QString( tr( "You have to set a filename !") ) ); | 348 | QString( tr( "You have to set a filename !") ) ); |
349 | } | 349 | } |
350 | 350 | ||
351 | void AddressbookWindow::setDocument( const QString &filename ) | 351 | void AddressbookWindow::setDocument( const QString &filename ) |
352 | { | 352 | { |
353 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); | 353 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); |
354 | 354 | ||
355 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 355 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
356 | 356 | ||
357 | 357 | ||
358 | 358 | ||
359 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 359 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
360 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 360 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
361 | tr( "&Yes" ), tr( "&No" ), QString::null, | 361 | tr( "&Yes" ), tr( "&No" ), QString::null, |
362 | 0, // Enter == button 0 | 362 | 0, // Enter == button 0 |
363 | 2 ) ) { // Escape == button 2 | 363 | 2 ) ) { // Escape == button 2 |
364 | case 0: | 364 | case 0: |
365 | qWarning("YES clicked"); | 365 | qWarning("YES clicked"); |
366 | break; | 366 | break; |
367 | case 1: | 367 | case 1: |
368 | qWarning("NO clicked"); | 368 | qWarning("NO clicked"); |
369 | return; | 369 | return; |
370 | break; | 370 | break; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 374 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
375 | filename ); | 375 | filename ); |
376 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 376 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
377 | OContactAccess::List allList = access->allRecords(); | 377 | OContactAccess::List allList = access->allRecords(); |
378 | qWarning( "Found number of contacts in File: %d", allList.count() ); | 378 | qWarning( "Found number of contacts in File: %d", allList.count() ); |
379 | 379 | ||
380 | if ( !allList.count() ) { | 380 | if ( !allList.count() ) { |
381 | QMessageBox::information( this, "Import VCard", | 381 | QMessageBox::information( this, "Import VCard", |
382 | "It was impossible to import\nthe VCard.\n" | 382 | "It was impossible to import\nthe VCard.\n" |
383 | "The VCard may be corrupted!" ); | 383 | "The VCard may be corrupted!" ); |
384 | } | 384 | } |
385 | 385 | ||
386 | bool doAsk = true; | 386 | bool doAsk = true; |
387 | OContactAccess::List::Iterator it; | 387 | OContactAccess::List::Iterator it; |
388 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 388 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
389 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); | 389 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); |
390 | if ( doAsk ){ | 390 | if ( doAsk ){ |
391 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 391 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
392 | tr( "Do you really want add contact for \n%1?" ) | 392 | tr( "Do you really want add contact for \n%1?" ) |
393 | .arg( (*it).fullName().latin1() ), | 393 | .arg( (*it).fullName().latin1() ), |
394 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 394 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
395 | 0, // Enter == button 0 | 395 | 0, // Enter == button 0 |
396 | 2 ) ) { // Escape == button 2 | 396 | 2 ) ) { // Escape == button 2 |
397 | case 0: | 397 | case 0: |
398 | qWarning("YES clicked"); | 398 | qWarning("YES clicked"); |
399 | m_abView->addEntry( *it ); | 399 | m_abView->addEntry( *it ); |
400 | break; | 400 | break; |
401 | case 1: | 401 | case 1: |
402 | qWarning("NO clicked"); | 402 | qWarning("NO clicked"); |
403 | break; | 403 | break; |
404 | case 2: | 404 | case 2: |
405 | qWarning("YesAll clicked"); | 405 | qWarning("YesAll clicked"); |
406 | doAsk = false; | 406 | doAsk = false; |
407 | break; | 407 | break; |
408 | } | 408 | } |
409 | }else | 409 | }else |
410 | m_abView->addEntry( *it ); | 410 | m_abView->addEntry( *it ); |
411 | 411 | ||
412 | } | 412 | } |
413 | 413 | ||
414 | delete access; | 414 | delete access; |
415 | } | 415 | } |
416 | 416 | ||
417 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 417 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
418 | { | 418 | { |
419 | QMainWindow::resizeEvent( e ); | 419 | QMainWindow::resizeEvent( e ); |
420 | 420 | ||
421 | 421 | ||
422 | } | 422 | } |
423 | 423 | ||
424 | AddressbookWindow::~AddressbookWindow() | 424 | AddressbookWindow::~AddressbookWindow() |
425 | { | 425 | { |
426 | ToolBarDock dock; | 426 | ToolBarDock dock; |
427 | int dummy; | 427 | int dummy; |
428 | bool bDummy; | 428 | bool bDummy; |
429 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 429 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
430 | m_config.setToolBarDock( dock ); | 430 | m_config.setToolBarDock( dock ); |
431 | m_config.save(); | 431 | m_config.save(); |
432 | } | 432 | } |
433 | 433 | ||
434 | void AddressbookWindow::slotUpdateToolbar() | 434 | void AddressbookWindow::slotUpdateToolbar() |
435 | { | 435 | { |
436 | OContact ce = m_abView->currentEntry(); | 436 | OContact ce = m_abView->currentEntry(); |
437 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 437 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
438 | } | 438 | } |
439 | 439 | ||
440 | void AddressbookWindow::slotListNew() | 440 | void AddressbookWindow::slotListNew() |
441 | { | 441 | { |
442 | OContact cnt; | 442 | OContact cnt; |
443 | if( !syncing ) { | 443 | if( !syncing ) { |
444 | editEntry( NewEntry ); | 444 | editEntry( NewEntry ); |
445 | } else { | 445 | } else { |
446 | QMessageBox::warning(this, tr("Contacts"), | 446 | QMessageBox::warning(this, tr("Contacts"), |
447 | tr("Can not edit data, currently syncing")); | 447 | tr("Can not edit data, currently syncing")); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | // void AddressbookWindow::slotListView() | 451 | // void AddressbookWindow::slotListView() |
452 | // { | 452 | // { |
453 | // m_abView -> init( abList->currentEntry() ); | 453 | // m_abView -> init( abList->currentEntry() ); |
454 | // // :SX mView->sync(); | 454 | // // :SX mView->sync(); |
455 | // //:SXshowView(); | 455 | // //:SXshowView(); |
456 | // } | 456 | // } |
457 | 457 | ||
458 | void AddressbookWindow::slotListDelete() | 458 | void AddressbookWindow::slotListDelete() |
459 | { | 459 | { |
460 | if(!syncing) { | 460 | if(!syncing) { |
461 | OContact tmpEntry = m_abView ->currentEntry(); | 461 | OContact tmpEntry = m_abView ->currentEntry(); |
462 | 462 | ||
463 | // get a name, do the best we can... | 463 | // get a name, do the best we can... |
464 | QString strName = tmpEntry.fullName(); | 464 | QString strName = tmpEntry.fullName(); |
465 | if ( strName.isEmpty() ) { | 465 | if ( strName.isEmpty() ) { |
466 | strName = tmpEntry.company(); | 466 | strName = tmpEntry.company(); |
467 | if ( strName.isEmpty() ) | 467 | if ( strName.isEmpty() ) |
468 | strName = "No Name"; | 468 | strName = "No Name"; |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 472 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
473 | strName ) ) { | 473 | strName ) ) { |
474 | m_abView->removeEntry( tmpEntry.uid() ); | 474 | m_abView->removeEntry( tmpEntry.uid() ); |
475 | } | 475 | } |
476 | } else { | 476 | } else { |
477 | QMessageBox::warning( this, tr("Contacts"), | 477 | QMessageBox::warning( this, tr("Contacts"), |
478 | tr("Can not edit data, currently syncing") ); | 478 | tr("Can not edit data, currently syncing") ); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | void AddressbookWindow::slotFindOpen() | 482 | void AddressbookWindow::slotFindOpen() |
483 | { | 483 | { |
484 | searchBar->show(); | 484 | searchBar->show(); |
485 | m_abView -> inSearch(); | 485 | m_abView -> inSearch(); |
486 | searchEdit->setFocus(); | 486 | searchEdit->setFocus(); |
487 | } | 487 | } |
488 | void AddressbookWindow::slotFindClose() | 488 | void AddressbookWindow::slotFindClose() |
489 | { | 489 | { |
490 | searchBar->hide(); | 490 | searchBar->hide(); |
491 | m_abView -> offSearch(); | 491 | m_abView -> offSearch(); |
492 | // m_abView->setFocus(); | 492 | // m_abView->setFocus(); |
493 | } | 493 | } |
494 | 494 | ||
495 | 495 | ||
496 | void AddressbookWindow::slotFind() | 496 | void AddressbookWindow::slotFind() |
497 | { | 497 | { |
498 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 498 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
499 | 499 | ||
500 | searchEdit->clearFocus(); | 500 | searchEdit->clearFocus(); |
501 | // m_abView->setFocus(); | 501 | // m_abView->setFocus(); |
502 | 502 | ||
503 | } | 503 | } |
504 | 504 | ||
505 | void AddressbookWindow::slotViewBack() | 505 | void AddressbookWindow::slotViewBack() |
506 | { | 506 | { |
507 | // :SX showList(); | 507 | // :SX showList(); |
508 | } | 508 | } |
509 | 509 | ||
510 | void AddressbookWindow::slotViewEdit() | 510 | void AddressbookWindow::slotViewEdit() |
511 | { | 511 | { |
512 | if(!syncing) { | 512 | if(!syncing) { |
513 | if (actionPersonal->isOn()) { | 513 | if (actionPersonal->isOn()) { |
514 | editPersonal(); | 514 | editPersonal(); |
515 | } else { | 515 | } else { |
516 | editEntry( EditEntry ); | 516 | editEntry( EditEntry ); |
517 | } | 517 | } |
518 | } else { | 518 | } else { |
519 | QMessageBox::warning( this, tr("Contacts"), | 519 | QMessageBox::warning( this, tr("Contacts"), |
520 | tr("Can not edit data, currently syncing") ); | 520 | tr("Can not edit data, currently syncing") ); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | 523 | ||
524 | 524 | ||
525 | 525 | ||
526 | void AddressbookWindow::writeMail() | 526 | void AddressbookWindow::writeMail() |
527 | { | 527 | { |
528 | OContact c = m_abView -> currentEntry(); | 528 | OContact c = m_abView -> currentEntry(); |
529 | QString name = c.fileAs(); | 529 | QString name = c.fileAs(); |
530 | QString email = c.defaultEmail(); | 530 | QString email = c.defaultEmail(); |
531 | 531 | ||
532 | // I prefer the OPIE-Environment variable before the | 532 | // I prefer the OPIE-Environment variable before the |
533 | // QPE-one.. | 533 | // QPE-one.. |
534 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 534 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
535 | if ( basepath.isEmpty() ) | 535 | if ( basepath.isEmpty() ) |
536 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 536 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
537 | 537 | ||
538 | // Try to access the preferred. If not possible, try to | 538 | // Try to access the preferred. If not possible, try to |
539 | // switch to the other one.. | 539 | // switch to the other one.. |
540 | if ( m_config.useQtMail() ){ | 540 | if ( m_config.useQtMail() ){ |
541 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 541 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
542 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 542 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
543 | qWarning ("QCop"); | 543 | qWarning ("QCop"); |
544 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 544 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
545 | e << name << email; | 545 | e << name << email; |
546 | return; | 546 | return; |
547 | } else | 547 | } else |
548 | m_config.setUseOpieMail( true ); | 548 | m_config.setUseOpieMail( true ); |
549 | } | 549 | } |
550 | if ( m_config.useOpieMail() ){ | 550 | if ( m_config.useOpieMail() ){ |
551 | qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1()); | 551 | qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1()); |
552 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ | 552 | if ( QFile::exists( basepath + "/bin/opiemail" ) ){ |
553 | qWarning ("QCop"); | 553 | qWarning ("QCop"); |
554 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); | 554 | QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); |
555 | e << name << email; | 555 | e << name << email; |
556 | return; | 556 | return; |
557 | } else | 557 | } else |
558 | m_config.setUseQtMail( true ); | 558 | m_config.setUseQtMail( true ); |
559 | } | 559 | } |
560 | 560 | ||
561 | } | 561 | } |
562 | 562 | ||
563 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 563 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
564 | 564 | ||
565 | void AddressbookWindow::slotBeam() | 565 | void AddressbookWindow::slotBeam() |
566 | { | 566 | { |
567 | QString beamFilename; | 567 | QString beamFilename; |
568 | OContact c; | 568 | OContact c; |
569 | if ( actionPersonal->isOn() ) { | 569 | if ( actionPersonal->isOn() ) { |
570 | beamFilename = addressbookPersonalVCardName(); | 570 | beamFilename = addressbookPersonalVCardName(); |
571 | if ( !QFile::exists( beamFilename ) ) | 571 | if ( !QFile::exists( beamFilename ) ) |
572 | return; // can't beam a non-existent file | 572 | return; // can't beam a non-existent file |
573 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 573 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
574 | beamFilename ); | 574 | beamFilename ); |
575 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 575 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
576 | OContactAccess::List allList = access->allRecords(); | 576 | OContactAccess::List allList = access->allRecords(); |
577 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 577 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
578 | c = *it; | 578 | c = *it; |
579 | 579 | ||
580 | delete access; | 580 | delete access; |
581 | } else { | 581 | } else { |
582 | unlink( beamfile ); // delete if exists | 582 | unlink( beamfile ); // delete if exists |
583 | mkdir("/tmp/obex/", 0755); | 583 | mkdir("/tmp/obex/", 0755); |
584 | c = m_abView -> currentEntry(); | 584 | c = m_abView -> currentEntry(); |
585 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 585 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
586 | beamfile ); | 586 | beamfile ); |
587 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 587 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
588 | access->add( c ); | 588 | access->add( c ); |
589 | access->save(); | 589 | access->save(); |
590 | delete access; | 590 | delete access; |
591 | 591 | ||
592 | beamFilename = beamfile; | 592 | beamFilename = beamfile; |
593 | } | 593 | } |
594 | 594 | ||
595 | qWarning("Beaming: %s", beamFilename.latin1() ); | 595 | qWarning("Beaming: %s", beamFilename.latin1() ); |
596 | 596 | ||
597 | Ir *ir = new Ir( this ); | 597 | Ir *ir = new Ir( this ); |
598 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 598 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
599 | QString description = c.fullName(); | 599 | QString description = c.fullName(); |
600 | ir->send( beamFilename, description, "text/x-vCard" ); | 600 | ir->send( beamFilename, description, "text/x-vCard" ); |
601 | } | 601 | } |
602 | 602 | ||
603 | void AddressbookWindow::beamDone( Ir *ir ) | 603 | void AddressbookWindow::beamDone( Ir *ir ) |
604 | { | 604 | { |
605 | 605 | ||
606 | delete ir; | 606 | delete ir; |
607 | unlink( beamfile ); | 607 | unlink( beamfile ); |
608 | } | 608 | } |
609 | 609 | ||
610 | 610 | ||
611 | static void parseName( const QString& name, QString *first, QString *middle, | 611 | static void parseName( const QString& name, QString *first, QString *middle, |
612 | QString * last ) | 612 | QString * last ) |
613 | { | 613 | { |
614 | 614 | ||
615 | int comma = name.find ( "," ); | 615 | int comma = name.find ( "," ); |
616 | QString rest; | 616 | QString rest; |
617 | if ( comma > 0 ) { | 617 | if ( comma > 0 ) { |
618 | *last = name.left( comma ); | 618 | *last = name.left( comma ); |
619 | comma++; | 619 | comma++; |
620 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 620 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
621 | comma++; | 621 | comma++; |
622 | rest = name.mid( comma ); | 622 | rest = name.mid( comma ); |
623 | } else { | 623 | } else { |
624 | int space = name.findRev( ' ' ); | 624 | int space = name.findRev( ' ' ); |
625 | *last = name.mid( space+1 ); | 625 | *last = name.mid( space+1 ); |
626 | rest = name.left( space ); | 626 | rest = name.left( space ); |
627 | } | 627 | } |
628 | int space = rest.find( ' ' ); | 628 | int space = rest.find( ' ' ); |
629 | if ( space <= 0 ) { | 629 | if ( space <= 0 ) { |
630 | *first = rest; | 630 | *first = rest; |
631 | } else { | 631 | } else { |
632 | *first = rest.left( space ); | 632 | *first = rest.left( space ); |
633 | *middle = rest.mid( space+1 ); | 633 | *middle = rest.mid( space+1 ); |
634 | } | 634 | } |
635 | 635 | ||
636 | } | 636 | } |
637 | 637 | ||
638 | 638 | ||
639 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 639 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
640 | { | 640 | { |
641 | bool needShow = FALSE; | 641 | bool needShow = FALSE; |
642 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | 642 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); |
643 | 643 | ||
644 | 644 | ||
645 | if (msg == "editPersonal()") { | 645 | if (msg == "editPersonal()") { |
646 | editPersonal(); | 646 | editPersonal(); |
647 | } else if (msg == "editPersonalAndClose()") { | 647 | } else if (msg == "editPersonalAndClose()") { |
648 | editPersonal(); | 648 | editPersonal(); |
649 | close(); | 649 | close(); |
650 | } else if ( msg == "addContact(QString,QString)" ) { | 650 | } else if ( msg == "addContact(QString,QString)" ) { |
651 | QDataStream stream(data,IO_ReadOnly); | 651 | QDataStream stream(data,IO_ReadOnly); |
652 | QString name, email; | 652 | QString name, email; |
653 | stream >> name >> email; | 653 | stream >> name >> email; |
654 | 654 | ||
655 | OContact cnt; | 655 | OContact cnt; |
656 | QString fn, mn, ln; | 656 | QString fn, mn, ln; |
657 | parseName( name, &fn, &mn, &ln ); | 657 | parseName( name, &fn, &mn, &ln ); |
658 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 658 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
659 | cnt.setFirstName( fn ); | 659 | cnt.setFirstName( fn ); |
660 | cnt.setMiddleName( mn ); | 660 | cnt.setMiddleName( mn ); |
661 | cnt.setLastName( ln ); | 661 | cnt.setLastName( ln ); |
662 | cnt.insertEmails( email ); | 662 | cnt.insertEmails( email ); |
663 | cnt.setDefaultEmail( email ); | 663 | cnt.setDefaultEmail( email ); |
664 | cnt.setFileAs(); | 664 | cnt.setFileAs(); |
665 | 665 | ||
666 | m_abView -> addEntry( cnt ); | 666 | m_abView -> addEntry( cnt ); |
667 | 667 | ||
668 | // :SXm_abView()->init( cnt ); | 668 | // :SXm_abView()->init( cnt ); |
669 | editEntry( EditEntry ); | 669 | editEntry( EditEntry ); |
670 | } else if ( msg == "beamBusinessCard()" ) { | 670 | } else if ( msg == "beamBusinessCard()" ) { |
671 | QString beamFilename = addressbookPersonalVCardName(); | 671 | QString beamFilename = addressbookPersonalVCardName(); |
672 | if ( !QFile::exists( beamFilename ) ) | 672 | if ( !QFile::exists( beamFilename ) ) |
673 | return; // can't beam a non-existent file | 673 | return; // can't beam a non-existent file |
674 | 674 | ||
675 | Ir *ir = new Ir( this ); | 675 | Ir *ir = new Ir( this ); |
676 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 676 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
677 | QString description = "mycard.vcf"; | 677 | QString description = "mycard.vcf"; |
678 | ir->send( beamFilename, description, "text/x-vCard" ); | 678 | ir->send( beamFilename, description, "text/x-vCard" ); |
679 | } else if ( msg == "show(int)" ) { | 679 | } else if ( msg == "show(int)" ) { |
680 | raise(); | 680 | raise(); |
681 | QDataStream stream(data,IO_ReadOnly); | 681 | QDataStream stream(data,IO_ReadOnly); |
682 | int uid; | 682 | int uid; |
683 | stream >> uid; | 683 | stream >> uid; |
684 | 684 | ||
685 | qWarning( "Showing uid: %d" , uid ); | 685 | qWarning( "Showing uid: %d" , uid ); |
686 | 686 | ||
687 | // Deactivate Personal View.. | 687 | // Deactivate Personal View.. |
688 | if ( actionPersonal->isOn() ){ | 688 | if ( actionPersonal->isOn() ){ |
689 | actionPersonal->setOn( false ); | 689 | actionPersonal->setOn( false ); |
690 | slotPersonalView(); | 690 | slotPersonalView(); |
691 | } | 691 | } |
692 | 692 | ||
693 | // Reset category and show as card.. | 693 | // Reset category and show as card.. |
694 | m_abView -> setShowByCategory( QString::null ); | 694 | m_abView -> setShowByCategory( QString::null ); |
695 | m_abView -> setCurrentUid( uid ); | 695 | m_abView -> setCurrentUid( uid ); |
696 | slotViewSwitched ( AbView::CardView ); | 696 | slotViewSwitched ( AbView::CardView ); |
697 | 697 | ||
698 | needShow = true; | 698 | needShow = true; |
699 | 699 | ||
700 | 700 | ||
701 | } else if ( msg == "edit(int)" ) { | 701 | } else if ( msg == "edit(int)" ) { |
702 | QDataStream stream(data,IO_ReadOnly); | 702 | QDataStream stream(data,IO_ReadOnly); |
703 | int uid; | 703 | int uid; |
704 | stream >> uid; | 704 | stream >> uid; |
705 | 705 | ||
706 | // Deactivate Personal View.. | 706 | // Deactivate Personal View.. |
707 | if ( actionPersonal->isOn() ){ | 707 | if ( actionPersonal->isOn() ){ |
708 | actionPersonal->setOn( false ); | 708 | actionPersonal->setOn( false ); |
709 | slotPersonalView(); | 709 | slotPersonalView(); |
710 | } | 710 | } |
711 | 711 | ||
712 | // Reset category and edit.. | 712 | // Reset category and edit.. |
713 | m_abView -> setShowByCategory( QString::null ); | 713 | m_abView -> setShowByCategory( QString::null ); |
714 | m_abView -> setCurrentUid( uid ); | 714 | m_abView -> setCurrentUid( uid ); |
715 | slotViewEdit(); | 715 | slotViewEdit(); |
716 | } | 716 | } |
717 | 717 | ||
718 | if (needShow) | 718 | if (needShow) |
719 | QPEApplication::setKeepRunning(); | 719 | QPEApplication::setKeepRunning(); |
720 | 720 | ||
721 | } | 721 | } |
722 | 722 | ||
723 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 723 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
724 | { | 724 | { |
725 | OContact entry; | 725 | OContact entry; |
726 | if ( !abEditor ) { | 726 | if ( !abEditor ) { |
727 | abEditor = new ContactEditor( entry, this, "editor" ); | 727 | abEditor = new ContactEditor( entry, this, "editor" ); |
728 | } | 728 | } |
729 | if ( entryMode == EditEntry ) | 729 | if ( entryMode == EditEntry ) |
730 | abEditor->setEntry( m_abView -> currentEntry() ); | 730 | abEditor->setEntry( m_abView -> currentEntry() ); |
731 | else if ( entryMode == NewEntry ) | 731 | else if ( entryMode == NewEntry ) |
732 | abEditor->setEntry( entry ); | 732 | abEditor->setEntry( entry ); |
733 | // other things may change the caption. | 733 | // other things may change the caption. |
734 | abEditor->setCaption( tr("Edit Address") ); | 734 | abEditor->setCaption( tr("Edit Address") ); |
735 | 735 | ||
736 | // fix the foxus... | 736 | // fix the foxus... |
737 | abEditor->setNameFocus(); | 737 | abEditor->setNameFocus(); |
738 | if ( QPEApplication::execDialog( abEditor ) ) { | 738 | if ( QPEApplication::execDialog( abEditor ) ) { |
739 | setFocus(); | 739 | setFocus(); |
740 | if ( entryMode == NewEntry ) { | 740 | if ( entryMode == NewEntry ) { |
741 | OContact insertEntry = abEditor->entry(); | 741 | OContact insertEntry = abEditor->entry(); |
742 | insertEntry.assignUid(); | 742 | insertEntry.assignUid(); |
743 | m_abView -> addEntry( insertEntry ); | 743 | m_abView -> addEntry( insertEntry ); |
744 | m_abView -> setCurrentUid( insertEntry.uid() ); | 744 | m_abView -> setCurrentUid( insertEntry.uid() ); |
745 | } else { | 745 | } else { |
746 | OContact replEntry = abEditor->entry(); | 746 | OContact replEntry = abEditor->entry(); |
747 | 747 | ||
748 | if ( !replEntry.isValidUid() ) | 748 | if ( !replEntry.isValidUid() ) |
749 | replEntry.assignUid(); | 749 | replEntry.assignUid(); |
750 | 750 | ||
751 | m_abView -> replaceEntry( replEntry ); | 751 | m_abView -> replaceEntry( replEntry ); |
752 | } | 752 | } |
753 | } | 753 | } |
754 | // populateCategories(); | 754 | // populateCategories(); |
755 | 755 | ||
756 | } | 756 | } |
757 | 757 | ||
758 | void AddressbookWindow::editPersonal() | 758 | void AddressbookWindow::editPersonal() |
759 | { | 759 | { |
760 | OContact entry; | 760 | OContact entry; |
761 | 761 | ||
762 | // Switch to personal view if not selected | 762 | // Switch to personal view if not selected |
763 | // but take care of the menu, too | 763 | // but take care of the menu, too |
764 | if ( ! actionPersonal->isOn() ){ | 764 | if ( ! actionPersonal->isOn() ){ |
765 | qWarning("*** ++++"); | 765 | qWarning("*** ++++"); |
766 | actionPersonal->setOn( true ); | 766 | actionPersonal->setOn( true ); |
767 | slotPersonalView(); | 767 | slotPersonalView(); |
768 | } | 768 | } |
769 | 769 | ||
770 | if ( !abEditor ) { | 770 | if ( !abEditor ) { |
771 | abEditor = new ContactEditor( entry, this, "editor" ); | 771 | abEditor = new ContactEditor( entry, this, "editor" ); |
772 | } | 772 | } |
773 | 773 | ||
774 | abEditor->setCaption(tr("Edit My Personal Details")); | 774 | abEditor->setCaption(tr("Edit My Personal Details")); |
775 | abEditor->setPersonalView( true ); | 775 | abEditor->setPersonalView( true ); |
776 | editEntry( EditEntry ); | 776 | editEntry( EditEntry ); |
777 | abEditor->setPersonalView( false ); | 777 | abEditor->setPersonalView( false ); |
778 | 778 | ||
779 | } | 779 | } |
780 | 780 | ||
781 | 781 | ||
782 | void AddressbookWindow::slotPersonalView() | 782 | void AddressbookWindow::slotPersonalView() |
783 | { | 783 | { |
784 | qWarning("slotPersonalView()"); | 784 | qWarning("slotPersonalView()"); |
785 | if (!actionPersonal->isOn()) { | 785 | if (!actionPersonal->isOn()) { |
786 | // we just turned it off | 786 | // we just turned it off |
787 | qWarning("slotPersonalView()-> OFF"); | 787 | qWarning("slotPersonalView()-> OFF"); |
788 | setCaption( tr("Contacts") ); | 788 | setCaption( tr("Contacts") ); |
789 | actionNew->setEnabled(TRUE); | 789 | actionNew->setEnabled(TRUE); |
790 | actionTrash->setEnabled(TRUE); | 790 | actionTrash->setEnabled(TRUE); |
791 | actionFind->setEnabled(TRUE); | 791 | actionFind->setEnabled(TRUE); |
792 | actionMail->setEnabled(TRUE); | 792 | actionMail->setEnabled(TRUE); |
793 | // slotUpdateToolbar(); | 793 | // slotUpdateToolbar(); |
794 | 794 | ||
795 | m_abView->showPersonal( false ); | 795 | m_abView->showPersonal( false ); |
796 | 796 | ||
797 | return; | 797 | return; |
798 | } | 798 | } |
799 | 799 | ||
800 | qWarning("slotPersonalView()-> ON"); | 800 | qWarning("slotPersonalView()-> ON"); |
801 | // XXX need to disable some QActions. | 801 | // XXX need to disable some QActions. |
802 | actionNew->setEnabled(FALSE); | 802 | actionNew->setEnabled(FALSE); |
803 | actionTrash->setEnabled(FALSE); | 803 | actionTrash->setEnabled(FALSE); |
804 | actionFind->setEnabled(FALSE); | 804 | actionFind->setEnabled(FALSE); |
805 | actionMail->setEnabled(FALSE); | 805 | actionMail->setEnabled(FALSE); |
806 | 806 | ||
807 | setCaption( tr("Contacts - My Personal Details") ); | 807 | setCaption( tr("Contacts - My Personal Details") ); |
808 | 808 | ||
809 | m_abView->showPersonal( true ); | 809 | m_abView->showPersonal( true ); |
810 | 810 | ||
811 | } | 811 | } |
812 | 812 | ||
813 | 813 | ||
814 | void AddressbookWindow::listIsEmpty( bool empty ) | 814 | void AddressbookWindow::listIsEmpty( bool empty ) |
815 | { | 815 | { |
816 | if ( !empty ) { | 816 | if ( !empty ) { |
817 | deleteButton->setEnabled( TRUE ); | 817 | deleteButton->setEnabled( TRUE ); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | 820 | ||
821 | void AddressbookWindow::reload() | 821 | void AddressbookWindow::reload() |
822 | { | 822 | { |
823 | syncing = FALSE; | 823 | syncing = FALSE; |
824 | m_abView->clear(); | 824 | m_abView->clear(); |
825 | m_abView->reload(); | 825 | m_abView->reload(); |
826 | } | 826 | } |
827 | 827 | ||
828 | void AddressbookWindow::flush() | 828 | void AddressbookWindow::flush() |
829 | { | 829 | { |
830 | syncing = TRUE; | 830 | syncing = TRUE; |
831 | m_abView->save(); | 831 | m_abView->save(); |
832 | } | 832 | } |
833 | 833 | ||
834 | 834 | ||
835 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 835 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
836 | { | 836 | { |
837 | if(active_view == AbView::CardView){ | 837 | if(active_view == AbView::CardView){ |
838 | slotViewSwitched( AbView::TableView ); | 838 | slotViewSwitched( AbView::TableView ); |
839 | e->ignore(); | 839 | e->ignore(); |
840 | return; | 840 | return; |
841 | } | 841 | } |
842 | if(syncing) { | 842 | if(syncing) { |
843 | /* shouldn't we save, I hear you say? well its already been set | 843 | /* shouldn't we save, I hear you say? well its already been set |
844 | so that an edit can not occur during a sync, and we flushed | 844 | so that an edit can not occur during a sync, and we flushed |
845 | at the start of the sync, so there is no need to save | 845 | at the start of the sync, so there is no need to save |
846 | Saving however itself would cause problems. */ | 846 | Saving however itself would cause problems. */ |
847 | e->accept(); | 847 | e->accept(); |
848 | return; | 848 | return; |
849 | } | 849 | } |
850 | //################## shouldn't always save | 850 | //################## shouldn't always save |
851 | // True, but the database handles this automatically ! (se) | 851 | // True, but the database handles this automatically ! (se) |
852 | if ( save() ) | 852 | if ( save() ) |
853 | e->accept(); | 853 | e->accept(); |
854 | else | 854 | else |
855 | e->ignore(); | 855 | e->ignore(); |
856 | } | 856 | } |
857 | 857 | ||
858 | /* | 858 | /* |
859 | Returns TRUE if it is OK to exit | 859 | Returns TRUE if it is OK to exit |
860 | */ | 860 | */ |
861 | 861 | ||
862 | bool AddressbookWindow::save() | 862 | bool AddressbookWindow::save() |
863 | { | 863 | { |
864 | if ( !m_abView->save() ) { | 864 | if ( !m_abView->save() ) { |
865 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 865 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
866 | tr("Unable to save information.\n" | 866 | tr("Unable to save information.\n" |
867 | "Free up some space\n" | 867 | "Free up some space\n" |
868 | "and try again.\n" | 868 | "and try again.\n" |
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index b1eb042..8acf570 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -346,519 +346,519 @@ void ContactEditor::init() { | |||
346 | cmbCountry->insertItem( tr ( "Greenland" ) ); | 346 | cmbCountry->insertItem( tr ( "Greenland" ) ); |
347 | cmbCountry->insertItem( tr ( "Grenada" ) ); | 347 | cmbCountry->insertItem( tr ( "Grenada" ) ); |
348 | cmbCountry->insertItem( tr ( "Guadeloupe" ) ); | 348 | cmbCountry->insertItem( tr ( "Guadeloupe" ) ); |
349 | cmbCountry->insertItem( tr ( "Guam" ) ); | 349 | cmbCountry->insertItem( tr ( "Guam" ) ); |
350 | cmbCountry->insertItem( tr ( "Guatemala" ) ); | 350 | cmbCountry->insertItem( tr ( "Guatemala" ) ); |
351 | cmbCountry->insertItem( tr ( "Guinea" ) ); | 351 | cmbCountry->insertItem( tr ( "Guinea" ) ); |
352 | cmbCountry->insertItem( tr ( "Guinea-Bissau" ) ); | 352 | cmbCountry->insertItem( tr ( "Guinea-Bissau" ) ); |
353 | cmbCountry->insertItem( tr ( "Guyana" ) ); | 353 | cmbCountry->insertItem( tr ( "Guyana" ) ); |
354 | cmbCountry->insertItem( tr ( "Haiti" ) ); | 354 | cmbCountry->insertItem( tr ( "Haiti" ) ); |
355 | cmbCountry->insertItem( tr ( "Holy See" ) ); | 355 | cmbCountry->insertItem( tr ( "Holy See" ) ); |
356 | cmbCountry->insertItem( tr ( "Honduras" ) ); | 356 | cmbCountry->insertItem( tr ( "Honduras" ) ); |
357 | cmbCountry->insertItem( tr ( "Hong Kong" ) ); | 357 | cmbCountry->insertItem( tr ( "Hong Kong" ) ); |
358 | cmbCountry->insertItem( tr ( "Hungary" ) ); | 358 | cmbCountry->insertItem( tr ( "Hungary" ) ); |
359 | cmbCountry->insertItem( tr ( "Iceland" ) ); | 359 | cmbCountry->insertItem( tr ( "Iceland" ) ); |
360 | cmbCountry->insertItem( tr ( "India" ) ); | 360 | cmbCountry->insertItem( tr ( "India" ) ); |
361 | cmbCountry->insertItem( tr ( "Indonesia" ) ); | 361 | cmbCountry->insertItem( tr ( "Indonesia" ) ); |
362 | cmbCountry->insertItem( tr ( "Ireland" ) ); | 362 | cmbCountry->insertItem( tr ( "Ireland" ) ); |
363 | cmbCountry->insertItem( tr ( "Israel" ) ); | 363 | cmbCountry->insertItem( tr ( "Israel" ) ); |
364 | cmbCountry->insertItem( tr ( "Italy" ) ); | 364 | cmbCountry->insertItem( tr ( "Italy" ) ); |
365 | cmbCountry->insertItem( tr ( "Jamaica" ) ); | 365 | cmbCountry->insertItem( tr ( "Jamaica" ) ); |
366 | cmbCountry->insertItem( tr ( "Japan" ) ); | 366 | cmbCountry->insertItem( tr ( "Japan" ) ); |
367 | cmbCountry->insertItem( tr ( "Jordan" ) ); | 367 | cmbCountry->insertItem( tr ( "Jordan" ) ); |
368 | cmbCountry->insertItem( tr ( "Kazakhstan" ) ); | 368 | cmbCountry->insertItem( tr ( "Kazakhstan" ) ); |
369 | cmbCountry->insertItem( tr ( "Kenya" ) ); | 369 | cmbCountry->insertItem( tr ( "Kenya" ) ); |
370 | cmbCountry->insertItem( tr ( "Kiribati" ) ); | 370 | cmbCountry->insertItem( tr ( "Kiribati" ) ); |
371 | cmbCountry->insertItem( tr ( "Korea" ) ); | 371 | cmbCountry->insertItem( tr ( "Korea" ) ); |
372 | cmbCountry->insertItem( tr ( "Kuwait" ) ); | 372 | cmbCountry->insertItem( tr ( "Kuwait" ) ); |
373 | cmbCountry->insertItem( tr ( "Kyrgyzstan" ) ); | 373 | cmbCountry->insertItem( tr ( "Kyrgyzstan" ) ); |
374 | cmbCountry->insertItem( tr ( "Laos" ) ); | 374 | cmbCountry->insertItem( tr ( "Laos" ) ); |
375 | cmbCountry->insertItem( tr ( "Latvia" ) ); | 375 | cmbCountry->insertItem( tr ( "Latvia" ) ); |
376 | cmbCountry->insertItem( tr ( "Lebanon" ) ); | 376 | cmbCountry->insertItem( tr ( "Lebanon" ) ); |
377 | cmbCountry->insertItem( tr ( "Lesotho" ) ); | 377 | cmbCountry->insertItem( tr ( "Lesotho" ) ); |
378 | cmbCountry->insertItem( tr ( "Liberia" ) ); | 378 | cmbCountry->insertItem( tr ( "Liberia" ) ); |
379 | cmbCountry->insertItem( tr ( "Liechtenstein" ) ); | 379 | cmbCountry->insertItem( tr ( "Liechtenstein" ) ); |
380 | cmbCountry->insertItem( tr ( "Lithuania" ) ); | 380 | cmbCountry->insertItem( tr ( "Lithuania" ) ); |
381 | cmbCountry->insertItem( tr ( "Luxembourg" ) ); | 381 | cmbCountry->insertItem( tr ( "Luxembourg" ) ); |
382 | cmbCountry->insertItem( tr ( "Macau" ) ); | 382 | cmbCountry->insertItem( tr ( "Macau" ) ); |
383 | cmbCountry->insertItem( tr ( "Macedonia" ) ); | 383 | cmbCountry->insertItem( tr ( "Macedonia" ) ); |
384 | cmbCountry->insertItem( tr ( "Madagascar" ) ); | 384 | cmbCountry->insertItem( tr ( "Madagascar" ) ); |
385 | cmbCountry->insertItem( tr ( "Malawi" ) ); | 385 | cmbCountry->insertItem( tr ( "Malawi" ) ); |
386 | cmbCountry->insertItem( tr ( "Malaysia" ) ); | 386 | cmbCountry->insertItem( tr ( "Malaysia" ) ); |
387 | cmbCountry->insertItem( tr ( "Maldives" ) ); | 387 | cmbCountry->insertItem( tr ( "Maldives" ) ); |
388 | cmbCountry->insertItem( tr ( "Mali" ) ); | 388 | cmbCountry->insertItem( tr ( "Mali" ) ); |
389 | cmbCountry->insertItem( tr ( "Malta" ) ); | 389 | cmbCountry->insertItem( tr ( "Malta" ) ); |
390 | cmbCountry->insertItem( tr ( "Martinique" ) ); | 390 | cmbCountry->insertItem( tr ( "Martinique" ) ); |
391 | cmbCountry->insertItem( tr ( "Mauritania" ) ); | 391 | cmbCountry->insertItem( tr ( "Mauritania" ) ); |
392 | cmbCountry->insertItem( tr ( "Mauritius" ) ); | 392 | cmbCountry->insertItem( tr ( "Mauritius" ) ); |
393 | cmbCountry->insertItem( tr ( "Mayotte" ) ); | 393 | cmbCountry->insertItem( tr ( "Mayotte" ) ); |
394 | cmbCountry->insertItem( tr ( "Mexico" ) ); | 394 | cmbCountry->insertItem( tr ( "Mexico" ) ); |
395 | cmbCountry->insertItem( tr ( "Micronesia" ) ); | 395 | cmbCountry->insertItem( tr ( "Micronesia" ) ); |
396 | cmbCountry->insertItem( tr ( "Moldova" ) ); | 396 | cmbCountry->insertItem( tr ( "Moldova" ) ); |
397 | cmbCountry->insertItem( tr ( "Monaco" ) ); | 397 | cmbCountry->insertItem( tr ( "Monaco" ) ); |
398 | cmbCountry->insertItem( tr ( "Mongolia" ) ); | 398 | cmbCountry->insertItem( tr ( "Mongolia" ) ); |
399 | cmbCountry->insertItem( tr ( "Montserrat" ) ); | 399 | cmbCountry->insertItem( tr ( "Montserrat" ) ); |
400 | cmbCountry->insertItem( tr ( "Morocco" ) ); | 400 | cmbCountry->insertItem( tr ( "Morocco" ) ); |
401 | cmbCountry->insertItem( tr ( "Mozambique" ) ); | 401 | cmbCountry->insertItem( tr ( "Mozambique" ) ); |
402 | cmbCountry->insertItem( tr ( "Myanmar" ) ); | 402 | cmbCountry->insertItem( tr ( "Myanmar" ) ); |
403 | cmbCountry->insertItem( tr ( "Namibia" ) ); | 403 | cmbCountry->insertItem( tr ( "Namibia" ) ); |
404 | cmbCountry->insertItem( tr ( "Nauru" ) ); | 404 | cmbCountry->insertItem( tr ( "Nauru" ) ); |
405 | cmbCountry->insertItem( tr ( "Nepal" ) ); | 405 | cmbCountry->insertItem( tr ( "Nepal" ) ); |
406 | cmbCountry->insertItem( tr ( "Netherlands" ) ); | 406 | cmbCountry->insertItem( tr ( "Netherlands" ) ); |
407 | cmbCountry->insertItem( tr ( "New Caledonia" ) ); | 407 | cmbCountry->insertItem( tr ( "New Caledonia" ) ); |
408 | cmbCountry->insertItem( tr ( "New Zealand" ) ); | 408 | cmbCountry->insertItem( tr ( "New Zealand" ) ); |
409 | cmbCountry->insertItem( tr ( "Nicaragua" ) ); | 409 | cmbCountry->insertItem( tr ( "Nicaragua" ) ); |
410 | cmbCountry->insertItem( tr ( "Niger" ) ); | 410 | cmbCountry->insertItem( tr ( "Niger" ) ); |
411 | cmbCountry->insertItem( tr ( "Nigeria" ) ); | 411 | cmbCountry->insertItem( tr ( "Nigeria" ) ); |
412 | cmbCountry->insertItem( tr ( "Niue" ) ); | 412 | cmbCountry->insertItem( tr ( "Niue" ) ); |
413 | cmbCountry->insertItem( tr ( "Norway" ) ); | 413 | cmbCountry->insertItem( tr ( "Norway" ) ); |
414 | cmbCountry->insertItem( tr ( "Oman" ) ); | 414 | cmbCountry->insertItem( tr ( "Oman" ) ); |
415 | cmbCountry->insertItem( tr ( "Pakistan" ) ); | 415 | cmbCountry->insertItem( tr ( "Pakistan" ) ); |
416 | cmbCountry->insertItem( tr ( "Palau" ) ); | 416 | cmbCountry->insertItem( tr ( "Palau" ) ); |
417 | cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) ); | 417 | cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) ); |
418 | cmbCountry->insertItem( tr ( "Panama" ) ); | 418 | cmbCountry->insertItem( tr ( "Panama" ) ); |
419 | cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); | 419 | cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); |
420 | cmbCountry->insertItem( tr ( "Paraguay" ) ); | 420 | cmbCountry->insertItem( tr ( "Paraguay" ) ); |
421 | cmbCountry->insertItem( tr ( "Peru" ) ); | 421 | cmbCountry->insertItem( tr ( "Peru" ) ); |
422 | cmbCountry->insertItem( tr ( "Philippines" ) ); | 422 | cmbCountry->insertItem( tr ( "Philippines" ) ); |
423 | cmbCountry->insertItem( tr ( "Pitcairn Islands" ) ); | 423 | cmbCountry->insertItem( tr ( "Pitcairn Islands" ) ); |
424 | cmbCountry->insertItem( tr ( "Poland" ) ); | 424 | cmbCountry->insertItem( tr ( "Poland" ) ); |
425 | cmbCountry->insertItem( tr ( "Portugal" ) ); | 425 | cmbCountry->insertItem( tr ( "Portugal" ) ); |
426 | cmbCountry->insertItem( tr ( "Puerto Rico" ) ); | 426 | cmbCountry->insertItem( tr ( "Puerto Rico" ) ); |
427 | cmbCountry->insertItem( tr ( "Qatar" ) ); | 427 | cmbCountry->insertItem( tr ( "Qatar" ) ); |
428 | cmbCountry->insertItem( tr ( "Reunion" ) ); | 428 | cmbCountry->insertItem( tr ( "Reunion" ) ); |
429 | cmbCountry->insertItem( tr ( "Romania" ) ); | 429 | cmbCountry->insertItem( tr ( "Romania" ) ); |
430 | cmbCountry->insertItem( tr ( "Russia" ) ); | 430 | cmbCountry->insertItem( tr ( "Russia" ) ); |
431 | cmbCountry->insertItem( tr ( "Rwanda" ) ); | 431 | cmbCountry->insertItem( tr ( "Rwanda" ) ); |
432 | cmbCountry->insertItem( tr ( "Saint Lucia" ) ); | 432 | cmbCountry->insertItem( tr ( "Saint Lucia" ) ); |
433 | cmbCountry->insertItem( tr ( "Samoa" ) ); | 433 | cmbCountry->insertItem( tr ( "Samoa" ) ); |
434 | cmbCountry->insertItem( tr ( "San Marino" ) ); | 434 | cmbCountry->insertItem( tr ( "San Marino" ) ); |
435 | cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); | 435 | cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); |
436 | cmbCountry->insertItem( tr ( "Senegal" ) ); | 436 | cmbCountry->insertItem( tr ( "Senegal" ) ); |
437 | cmbCountry->insertItem( tr ( "Seychelles" ) ); | 437 | cmbCountry->insertItem( tr ( "Seychelles" ) ); |
438 | cmbCountry->insertItem( tr ( "Sierra Leone" ) ); | 438 | cmbCountry->insertItem( tr ( "Sierra Leone" ) ); |
439 | cmbCountry->insertItem( tr ( "Singapore" ) ); | 439 | cmbCountry->insertItem( tr ( "Singapore" ) ); |
440 | cmbCountry->insertItem( tr ( "Slovakia" ) ); | 440 | cmbCountry->insertItem( tr ( "Slovakia" ) ); |
441 | cmbCountry->insertItem( tr ( "Slovenia" ) ); | 441 | cmbCountry->insertItem( tr ( "Slovenia" ) ); |
442 | cmbCountry->insertItem( tr ( "Solomon Islands" ) ); | 442 | cmbCountry->insertItem( tr ( "Solomon Islands" ) ); |
443 | cmbCountry->insertItem( tr ( "Somalia" ) ); | 443 | cmbCountry->insertItem( tr ( "Somalia" ) ); |
444 | cmbCountry->insertItem( tr ( "South Africa" ) ); | 444 | cmbCountry->insertItem( tr ( "South Africa" ) ); |
445 | cmbCountry->insertItem( tr ( "Spain" ) ); | 445 | cmbCountry->insertItem( tr ( "Spain" ) ); |
446 | cmbCountry->insertItem( tr ( "Sri Lanka" ) ); | 446 | cmbCountry->insertItem( tr ( "Sri Lanka" ) ); |
447 | cmbCountry->insertItem( tr ( "St. Helena" ) ); | 447 | cmbCountry->insertItem( tr ( "St. Helena" ) ); |
448 | cmbCountry->insertItem( tr ( "Sudan" ) ); | 448 | cmbCountry->insertItem( tr ( "Sudan" ) ); |
449 | cmbCountry->insertItem( tr ( "Suriname" ) ); | 449 | cmbCountry->insertItem( tr ( "Suriname" ) ); |
450 | cmbCountry->insertItem( tr ( "Swaziland" ) ); | 450 | cmbCountry->insertItem( tr ( "Swaziland" ) ); |
451 | cmbCountry->insertItem( tr ( "Sweden" ) ); | 451 | cmbCountry->insertItem( tr ( "Sweden" ) ); |
452 | cmbCountry->insertItem( tr ( "Switzerland" ) ); | 452 | cmbCountry->insertItem( tr ( "Switzerland" ) ); |
453 | cmbCountry->insertItem( tr ( "Taiwan" ) ); | 453 | cmbCountry->insertItem( tr ( "Taiwan" ) ); |
454 | cmbCountry->insertItem( tr ( "Tajikistan" ) ); | 454 | cmbCountry->insertItem( tr ( "Tajikistan" ) ); |
455 | cmbCountry->insertItem( tr ( "Tanzania" ) ); | 455 | cmbCountry->insertItem( tr ( "Tanzania" ) ); |
456 | cmbCountry->insertItem( tr ( "Thailand" ) ); | 456 | cmbCountry->insertItem( tr ( "Thailand" ) ); |
457 | cmbCountry->insertItem( tr ( "Togo" ) ); | 457 | cmbCountry->insertItem( tr ( "Togo" ) ); |
458 | cmbCountry->insertItem( tr ( "Tokelau" ) ); | 458 | cmbCountry->insertItem( tr ( "Tokelau" ) ); |
459 | cmbCountry->insertItem( tr ( "Tonga" ) ); | 459 | cmbCountry->insertItem( tr ( "Tonga" ) ); |
460 | cmbCountry->insertItem( tr ( "Tunisia" ) ); | 460 | cmbCountry->insertItem( tr ( "Tunisia" ) ); |
461 | cmbCountry->insertItem( tr ( "Turkey" ) ); | 461 | cmbCountry->insertItem( tr ( "Turkey" ) ); |
462 | cmbCountry->insertItem( tr ( "Turkmenistan" ) ); | 462 | cmbCountry->insertItem( tr ( "Turkmenistan" ) ); |
463 | cmbCountry->insertItem( tr ( "Tuvalu" ) ); | 463 | cmbCountry->insertItem( tr ( "Tuvalu" ) ); |
464 | cmbCountry->insertItem( tr ( "Uganda" ) ); | 464 | cmbCountry->insertItem( tr ( "Uganda" ) ); |
465 | cmbCountry->insertItem( tr ( "Ukraine" ) ); | 465 | cmbCountry->insertItem( tr ( "Ukraine" ) ); |
466 | cmbCountry->insertItem( tr ( "Uruguay" ) ); | 466 | cmbCountry->insertItem( tr ( "Uruguay" ) ); |
467 | cmbCountry->insertItem( tr ( "Uzbekistan" ) ); | 467 | cmbCountry->insertItem( tr ( "Uzbekistan" ) ); |
468 | cmbCountry->insertItem( tr ( "Vanuatu" ) ); | 468 | cmbCountry->insertItem( tr ( "Vanuatu" ) ); |
469 | cmbCountry->insertItem( tr ( "Venezuela" ) ); | 469 | cmbCountry->insertItem( tr ( "Venezuela" ) ); |
470 | cmbCountry->insertItem( tr ( "Vietnam" ) ); | 470 | cmbCountry->insertItem( tr ( "Vietnam" ) ); |
471 | cmbCountry->insertItem( tr ( "Virgin Islands" ) ); | 471 | cmbCountry->insertItem( tr ( "Virgin Islands" ) ); |
472 | cmbCountry->insertItem( tr ( "Western Sahara" ) ); | 472 | cmbCountry->insertItem( tr ( "Western Sahara" ) ); |
473 | cmbCountry->insertItem( tr ( "Yemen" ) ); | 473 | cmbCountry->insertItem( tr ( "Yemen" ) ); |
474 | cmbCountry->insertItem( tr ( "Yugoslavia" ) ); | 474 | cmbCountry->insertItem( tr ( "Yugoslavia" ) ); |
475 | cmbCountry->insertItem( tr ( "Zambia" ) ); | 475 | cmbCountry->insertItem( tr ( "Zambia" ) ); |
476 | cmbCountry->insertItem( tr ( "Zimbabwe" ) ); | 476 | cmbCountry->insertItem( tr ( "Zimbabwe" ) ); |
477 | if (cmbCountry->listBox()!=0) | 477 | if (cmbCountry->listBox()!=0) |
478 | cmbCountry->listBox()->sort(); | 478 | cmbCountry->listBox()->sort(); |
479 | 479 | ||
480 | cmbCountry->setMaximumWidth( 135 ); | 480 | cmbCountry->setMaximumWidth( 135 ); |
481 | 481 | ||
482 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); | 482 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); |
483 | 483 | ||
484 | // Chooser 4 | 484 | // Chooser 4 |
485 | cmbChooserField4 = new QComboBox( FALSE, container ); | 485 | cmbChooserField4 = new QComboBox( FALSE, container ); |
486 | cmbChooserField4->setMaximumWidth( 90 ); | 486 | cmbChooserField4->setMaximumWidth( 90 ); |
487 | gl->addWidget( cmbChooserField4, 6, 0 ); | 487 | gl->addWidget( cmbChooserField4, 6, 0 ); |
488 | // Textfield for chooser 2 | 488 | // Textfield for chooser 2 |
489 | // Now use WidgetStack to contain the textfield and the default-email combo! | 489 | // Now use WidgetStack to contain the textfield and the default-email combo! |
490 | m_widgetStack4 = new QWidgetStack( container ); | 490 | m_widgetStack4 = new QWidgetStack( container ); |
491 | txtChooserField4 = new QLineEdit( m_widgetStack4 ); | 491 | txtChooserField4 = new QLineEdit( m_widgetStack4 ); |
492 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); | 492 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); |
493 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); | 493 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); |
494 | m_widgetStack4 -> raiseWidget( TextField ); | 494 | m_widgetStack4 -> raiseWidget( TextField ); |
495 | 495 | ||
496 | QSpacerItem *space = new QSpacerItem(1,1, | 496 | QSpacerItem *space = new QSpacerItem(1,1, |
497 | QSizePolicy::Maximum, | 497 | QSizePolicy::Maximum, |
498 | QSizePolicy::MinimumExpanding ); | 498 | QSizePolicy::MinimumExpanding ); |
499 | gl->addItem( space, 7, 0 ); | 499 | gl->addItem( space, 7, 0 ); |
500 | 500 | ||
501 | tabMain->insertTab( tabViewport, tr( "Address" ) ); | 501 | tabMain->insertTab( tabViewport, tr( "Address" ) ); |
502 | 502 | ||
503 | tabViewport = new QWidget ( tabMain ); | 503 | tabViewport = new QWidget ( tabMain ); |
504 | 504 | ||
505 | vb = new QVBoxLayout( tabViewport ); | 505 | vb = new QVBoxLayout( tabViewport ); |
506 | 506 | ||
507 | svDetails = new QScrollView( tabViewport ); | 507 | svDetails = new QScrollView( tabViewport ); |
508 | vb->addWidget( svDetails, 0, 0 ); | 508 | vb->addWidget( svDetails, 0, 0 ); |
509 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); | 509 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); |
510 | svDetails->setFrameStyle( QFrame::NoFrame ); | 510 | svDetails->setFrameStyle( QFrame::NoFrame ); |
511 | 511 | ||
512 | container = new QWidget( svDetails->viewport() ); | 512 | container = new QWidget( svDetails->viewport() ); |
513 | svDetails->addChild( container ); | 513 | svDetails->addChild( container ); |
514 | 514 | ||
515 | gl = new QGridLayout( container, 1, 2, 2, 4 ); | 515 | gl = new QGridLayout( container, 1, 2, 2, 4 ); |
516 | 516 | ||
517 | int counter = 0; | 517 | int counter = 0; |
518 | 518 | ||
519 | // Birthday | 519 | // Birthday |
520 | QHBox* hBox = new QHBox( container ); | 520 | QHBox* hBox = new QHBox( container ); |
521 | l = new QLabel( tr("Birthday"), container ); | 521 | l = new QLabel( tr("Birthday"), container ); |
522 | gl->addWidget( l, counter, 0 ); | 522 | gl->addWidget( l, counter, 0 ); |
523 | 523 | ||
524 | QPopupMenu* m1 = new QPopupMenu( container ); | 524 | QPopupMenu* m1 = new QPopupMenu( container ); |
525 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); | 525 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); |
526 | m1->insertItem( birthdayPicker ); | 526 | m1->insertItem( birthdayPicker ); |
527 | 527 | ||
528 | birthdayButton= new QToolButton( hBox, "buttonStart" ); | 528 | birthdayButton= new QToolButton( hBox, "buttonStart" ); |
529 | birthdayButton->setPopup( m1 ); | 529 | birthdayButton->setPopup( m1 ); |
530 | birthdayButton->setPopupDelay(0); | 530 | birthdayButton->setPopupDelay(0); |
531 | 531 | ||
532 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 532 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
533 | tr( "Delete" ), | 533 | tr( "Delete" ), |
534 | hBox, 0 ); | 534 | hBox, 0 ); |
535 | 535 | ||
536 | gl->addWidget( hBox, counter , 1 ); | 536 | gl->addWidget( hBox, counter , 1 ); |
537 | 537 | ||
538 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), | 538 | connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ), |
539 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); | 539 | this, SLOT( slotBirthdayDateChanged(int,int,int) ) ); |
540 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); | 540 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); |
541 | 541 | ||
542 | ++counter; | 542 | ++counter; |
543 | 543 | ||
544 | // Anniversary | 544 | // Anniversary |
545 | hBox = new QHBox( container ); | 545 | hBox = new QHBox( container ); |
546 | l = new QLabel( tr("Anniversary"), container ); | 546 | l = new QLabel( tr("Anniversary"), container ); |
547 | gl->addWidget( l, counter, 0 ); | 547 | gl->addWidget( l, counter, 0 ); |
548 | 548 | ||
549 | m1 = new QPopupMenu( container ); | 549 | m1 = new QPopupMenu( container ); |
550 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); | 550 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); |
551 | m1->insertItem( anniversaryPicker ); | 551 | m1->insertItem( anniversaryPicker ); |
552 | 552 | ||
553 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); | 553 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); |
554 | anniversaryButton->setPopup( m1 ); | 554 | anniversaryButton->setPopup( m1 ); |
555 | anniversaryButton->setPopupDelay(0); | 555 | anniversaryButton->setPopupDelay(0); |
556 | 556 | ||
557 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 557 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
558 | tr( "Delete" ), | 558 | tr( "Delete" ), |
559 | hBox, 0 ); | 559 | hBox, 0 ); |
560 | gl->addWidget( hBox, counter , 1 ); | 560 | gl->addWidget( hBox, counter , 1 ); |
561 | 561 | ||
562 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), | 562 | connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ), |
563 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); | 563 | this, SLOT( slotAnniversaryDateChanged(int,int,int) ) ); |
564 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); | 564 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); |
565 | 565 | ||
566 | ++counter; | 566 | ++counter; |
567 | 567 | ||
568 | // Gender | 568 | // Gender |
569 | l = new QLabel( tr("Gender"), container ); | 569 | l = new QLabel( tr("Gender"), container ); |
570 | gl->addWidget( l, counter, 0 ); | 570 | gl->addWidget( l, counter, 0 ); |
571 | cmbGender = new QComboBox( container ); | 571 | cmbGender = new QComboBox( container ); |
572 | cmbGender->insertItem( "", 0 ); | 572 | cmbGender->insertItem( "", 0 ); |
573 | cmbGender->insertItem( tr("Male"), 1); | 573 | cmbGender->insertItem( tr("Male"), 1); |
574 | cmbGender->insertItem( tr("Female"), 2); | 574 | cmbGender->insertItem( tr("Female"), 2); |
575 | gl->addWidget( cmbGender, counter, 1 ); | 575 | gl->addWidget( cmbGender, counter, 1 ); |
576 | 576 | ||
577 | ++counter; | 577 | ++counter; |
578 | 578 | ||
579 | // Create Labels and lineedit fields for every dynamic entry | 579 | // Create Labels and lineedit fields for every dynamic entry |
580 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 580 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
581 | QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); | 581 | QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); |
582 | QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); | 582 | QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); |
583 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { | 583 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { |
584 | 584 | ||
585 | if (((*it) == "Anniversary") || | 585 | if (((*it) == "Anniversary") || |
586 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; | 586 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; |
587 | 587 | ||
588 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); | 588 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); |
589 | listName.append( l ); | 589 | listName.append( l ); |
590 | gl->addWidget( l, i, 0 ); | 590 | gl->addWidget( l, i, 0 ); |
591 | QLineEdit *e = new QLineEdit( container ); | 591 | QLineEdit *e = new QLineEdit( container ); |
592 | listValue.append( e ); | 592 | listValue.append( e ); |
593 | gl->addWidget( e, i, 1); | 593 | gl->addWidget( e, i, 1); |
594 | } | 594 | } |
595 | // Fill labels with names.. | 595 | // Fill labels with names.. |
596 | //loadFields(); | 596 | //loadFields(); |
597 | 597 | ||
598 | 598 | ||
599 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 599 | tabMain->insertTab( tabViewport, tr( "Details" ) ); |
600 | 600 | ||
601 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 601 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
602 | dlgNote->setCaption( tr("Enter Note") ); | 602 | dlgNote->setCaption( tr("Enter Note") ); |
603 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 603 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
604 | txtNote = new QMultiLineEdit( dlgNote ); | 604 | txtNote = new QMultiLineEdit( dlgNote ); |
605 | vbNote->addWidget( txtNote ); | 605 | vbNote->addWidget( txtNote ); |
606 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 606 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
607 | 607 | ||
608 | dlgName = new QDialog( this, "Name Dialog", TRUE ); | 608 | dlgName = new QDialog( this, "Name Dialog", TRUE ); |
609 | dlgName->setCaption( tr("Edit Name") ); | 609 | dlgName->setCaption( tr("Edit Name") ); |
610 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); | 610 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); |
611 | 611 | ||
612 | l = new QLabel( tr("First Name"), dlgName ); | 612 | l = new QLabel( tr("First Name"), dlgName ); |
613 | gl->addWidget( l, 0, 0 ); | 613 | gl->addWidget( l, 0, 0 ); |
614 | txtFirstName = new QLineEdit( dlgName ); | 614 | txtFirstName = new QLineEdit( dlgName ); |
615 | gl->addWidget( txtFirstName, 0, 1 ); | 615 | gl->addWidget( txtFirstName, 0, 1 ); |
616 | 616 | ||
617 | l = new QLabel( tr("Middle Name"), dlgName ); | 617 | l = new QLabel( tr("Middle Name"), dlgName ); |
618 | gl->addWidget( l, 1, 0 ); | 618 | gl->addWidget( l, 1, 0 ); |
619 | txtMiddleName = new QLineEdit( dlgName ); | 619 | txtMiddleName = new QLineEdit( dlgName ); |
620 | gl->addWidget( txtMiddleName, 1, 1 ); | 620 | gl->addWidget( txtMiddleName, 1, 1 ); |
621 | 621 | ||
622 | l = new QLabel( tr("Last Name"), dlgName ); | 622 | l = new QLabel( tr("Last Name"), dlgName ); |
623 | gl->addWidget( l, 2, 0 ); | 623 | gl->addWidget( l, 2, 0 ); |
624 | txtLastName = new QLineEdit( dlgName ); | 624 | txtLastName = new QLineEdit( dlgName ); |
625 | gl->addWidget( txtLastName, 2, 1 ); | 625 | gl->addWidget( txtLastName, 2, 1 ); |
626 | 626 | ||
627 | // l = new QLabel( tr("Suffix"), dlgName ); | 627 | // l = new QLabel( tr("Suffix"), dlgName ); |
628 | // gl->addWidget( l, 3, 0 ); | 628 | // gl->addWidget( l, 3, 0 ); |
629 | // txtSuffix = new QLineEdit( dlgName ); | 629 | // txtSuffix = new QLineEdit( dlgName ); |
630 | // gl->addWidget( txtSuffix, 3, 1 ); | 630 | // gl->addWidget( txtSuffix, 3, 1 ); |
631 | space = new QSpacerItem(1,1, | 631 | space = new QSpacerItem(1,1, |
632 | QSizePolicy::Maximum, | 632 | QSizePolicy::Maximum, |
633 | QSizePolicy::MinimumExpanding ); | 633 | QSizePolicy::MinimumExpanding ); |
634 | gl->addItem( space, 4, 0 ); | 634 | gl->addItem( space, 4, 0 ); |
635 | 635 | ||
636 | cmbChooserField1->insertStringList( trlChooserNames ); | 636 | cmbChooserField1->insertStringList( trlChooserNames ); |
637 | cmbChooserField2->insertStringList( trlChooserNames ); | 637 | cmbChooserField2->insertStringList( trlChooserNames ); |
638 | cmbChooserField3->insertStringList( trlChooserNames ); | 638 | cmbChooserField3->insertStringList( trlChooserNames ); |
639 | cmbChooserField4->insertStringList( trlChooserNames ); | 639 | cmbChooserField4->insertStringList( trlChooserNames ); |
640 | 640 | ||
641 | cmbChooserField1->setCurrentItem( 0 ); | 641 | cmbChooserField1->setCurrentItem( 0 ); |
642 | cmbChooserField2->setCurrentItem( 1 ); | 642 | cmbChooserField2->setCurrentItem( 1 ); |
643 | cmbChooserField3->setCurrentItem( 2 ); | 643 | cmbChooserField3->setCurrentItem( 2 ); |
644 | 644 | ||
645 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); | 645 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); |
646 | 646 | ||
647 | connect( txtFullName, SIGNAL(textChanged(const QString &)), | 647 | connect( txtFullName, SIGNAL(textChanged(const QString&)), |
648 | this, SLOT(slotFullNameChange(const QString &)) ); | 648 | this, SLOT(slotFullNameChange(const QString&)) ); |
649 | connect( txtSuffix, SIGNAL(textChanged(const QString &)), | 649 | connect( txtSuffix, SIGNAL(textChanged(const QString&)), |
650 | this, SLOT(slotSuffixChange(const QString &)) ); | 650 | this, SLOT(slotSuffixChange(const QString&)) ); |
651 | connect( txtOrganization, SIGNAL(textChanged(const QString &)), | 651 | connect( txtOrganization, SIGNAL(textChanged(const QString&)), |
652 | this, SLOT(slotOrganizationChange(const QString &)) ); | 652 | this, SLOT(slotOrganizationChange(const QString&)) ); |
653 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), | 653 | connect( txtChooserField1, SIGNAL(textChanged(const QString&)), |
654 | this, SLOT(slotChooser1Change(const QString &)) ); | 654 | this, SLOT(slotChooser1Change(const QString&)) ); |
655 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), | 655 | connect( txtChooserField2, SIGNAL(textChanged(const QString&)), |
656 | this, SLOT(slotChooser2Change(const QString &)) ); | 656 | this, SLOT(slotChooser2Change(const QString&)) ); |
657 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), | 657 | connect( txtChooserField3, SIGNAL(textChanged(const QString&)), |
658 | this, SLOT(slotChooser3Change(const QString &)) ); | 658 | this, SLOT(slotChooser3Change(const QString&)) ); |
659 | connect( txtChooserField4, SIGNAL(textChanged(const QString &)), | 659 | connect( txtChooserField4, SIGNAL(textChanged(const QString&)), |
660 | this, SLOT(slotChooser4Change(const QString &)) ); | 660 | this, SLOT(slotChooser4Change(const QString&)) ); |
661 | connect( txtAddress, SIGNAL(textChanged(const QString &)), | 661 | connect( txtAddress, SIGNAL(textChanged(const QString&)), |
662 | this, SLOT(slotAddressChange(const QString &)) ); | 662 | this, SLOT(slotAddressChange(const QString&)) ); |
663 | connect( txtCity, SIGNAL(textChanged(const QString &)), | 663 | connect( txtCity, SIGNAL(textChanged(const QString&)), |
664 | this, SLOT(slotCityChange(const QString &)) ); | 664 | this, SLOT(slotCityChange(const QString&)) ); |
665 | connect( txtState, SIGNAL(textChanged(const QString &)), | 665 | connect( txtState, SIGNAL(textChanged(const QString&)), |
666 | this, SLOT(slotStateChange(const QString &)) ); | 666 | this, SLOT(slotStateChange(const QString&)) ); |
667 | connect( txtZip, SIGNAL(textChanged(const QString &)), | 667 | connect( txtZip, SIGNAL(textChanged(const QString&)), |
668 | this, SLOT(slotZipChange(const QString &)) ); | 668 | this, SLOT(slotZipChange(const QString&)) ); |
669 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), | 669 | connect( cmbCountry, SIGNAL(textChanged(const QString&)), |
670 | this, SLOT(slotCountryChange(const QString &)) ); | 670 | this, SLOT(slotCountryChange(const QString&)) ); |
671 | connect( cmbCountry, SIGNAL(activated(const QString &)), | 671 | connect( cmbCountry, SIGNAL(activated(const QString&)), |
672 | this, SLOT(slotCountryChange(const QString &)) ); | 672 | this, SLOT(slotCountryChange(const QString&)) ); |
673 | connect( cmbChooserField1, SIGNAL(activated(int)), | 673 | connect( cmbChooserField1, SIGNAL(activated(int)), |
674 | this, SLOT(slotCmbChooser1Change(int)) ); | 674 | this, SLOT(slotCmbChooser1Change(int)) ); |
675 | connect( cmbChooserField2, SIGNAL(activated(int)), | 675 | connect( cmbChooserField2, SIGNAL(activated(int)), |
676 | this, SLOT(slotCmbChooser2Change(int)) ); | 676 | this, SLOT(slotCmbChooser2Change(int)) ); |
677 | connect( cmbChooserField3, SIGNAL(activated(int)), | 677 | connect( cmbChooserField3, SIGNAL(activated(int)), |
678 | this, SLOT(slotCmbChooser3Change(int)) ); | 678 | this, SLOT(slotCmbChooser3Change(int)) ); |
679 | connect( cmbChooserField4, SIGNAL(activated(int)), | 679 | connect( cmbChooserField4, SIGNAL(activated(int)), |
680 | this, SLOT(slotCmbChooser4Change(int)) ); | 680 | this, SLOT(slotCmbChooser4Change(int)) ); |
681 | connect( cmbAddress, SIGNAL(activated(int)), | 681 | connect( cmbAddress, SIGNAL(activated(int)), |
682 | this, SLOT(slotAddressTypeChange(int)) ); | 682 | this, SLOT(slotAddressTypeChange(int)) ); |
683 | 683 | ||
684 | new QPEDialogListener(this); | 684 | new QPEDialogListener(this); |
685 | 685 | ||
686 | setPersonalView ( m_personalView ); | 686 | setPersonalView ( m_personalView ); |
687 | 687 | ||
688 | qWarning("init() END"); | 688 | qWarning("init() END"); |
689 | } | 689 | } |
690 | 690 | ||
691 | void ContactEditor::defaultEmailChanged(int i){ | 691 | void ContactEditor::defaultEmailChanged(int i){ |
692 | qDebug("defaultEmailChanged"); | 692 | qDebug("defaultEmailChanged"); |
693 | 693 | ||
694 | // was sollte das ? (se) | 694 | // was sollte das ? (se) |
695 | // int index = cmbChooserField1->currentItem(); | 695 | // int index = cmbChooserField1->currentItem(); |
696 | // slChooserValues[index] = cmbDefaultEmail->text(i); | 696 | // slChooserValues[index] = cmbDefaultEmail->text(i); |
697 | 697 | ||
698 | defaultEmail = cmbDefaultEmail->text(i); | 698 | defaultEmail = cmbDefaultEmail->text(i); |
699 | qDebug ("Changed to: %s", defaultEmail.latin1()); | 699 | qDebug ("Changed to: %s", defaultEmail.latin1()); |
700 | 700 | ||
701 | } | 701 | } |
702 | 702 | ||
703 | void ContactEditor::populateDefaultEmailCmb(){ | 703 | void ContactEditor::populateDefaultEmailCmb(){ |
704 | 704 | ||
705 | // if the default-email combo was not selected and therfore not created | 705 | // if the default-email combo was not selected and therfore not created |
706 | // we get a lot of trouble.. Therfore create an invisible one.. | 706 | // we get a lot of trouble.. Therfore create an invisible one.. |
707 | if ( !cmbDefaultEmail ){ | 707 | if ( !cmbDefaultEmail ){ |
708 | cmbDefaultEmail = new QComboBox(this); | 708 | cmbDefaultEmail = new QComboBox(this); |
709 | cmbDefaultEmail -> hide(); | 709 | cmbDefaultEmail -> hide(); |
710 | } | 710 | } |
711 | cmbDefaultEmail->clear(); | 711 | cmbDefaultEmail->clear(); |
712 | cmbDefaultEmail->insertStringList( emails ); | 712 | cmbDefaultEmail->insertStringList( emails ); |
713 | // cmbDefaultEmail->show(); | 713 | // cmbDefaultEmail->show(); |
714 | 714 | ||
715 | // Select default email in combo.. | 715 | // Select default email in combo.. |
716 | bool found = false; | 716 | bool found = false; |
717 | for ( int i = 0; i < cmbDefaultEmail->count(); i++){ | 717 | for ( int i = 0; i < cmbDefaultEmail->count(); i++){ |
718 | qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", | 718 | qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", |
719 | cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); | 719 | cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); |
720 | 720 | ||
721 | if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ | 721 | if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ |
722 | cmbDefaultEmail->setCurrentItem( i ); | 722 | cmbDefaultEmail->setCurrentItem( i ); |
723 | qDebug("set"); | 723 | qDebug("set"); |
724 | found = true; | 724 | found = true; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | 727 | ||
728 | // If the current default email is not found in the list, we choose the | 728 | // If the current default email is not found in the list, we choose the |
729 | // first one.. | 729 | // first one.. |
730 | if ( !found ) | 730 | if ( !found ) |
731 | defaultEmail = cmbDefaultEmail->text(0); | 731 | defaultEmail = cmbDefaultEmail->text(0); |
732 | } | 732 | } |
733 | 733 | ||
734 | // Called when any combobox was changed. | 734 | // Called when any combobox was changed. |
735 | // "true" returned if the change was chandled by this function, else it should | 735 | // "true" returned if the change was chandled by this function, else it should |
736 | // be handled by something else.. | 736 | // be handled by something else.. |
737 | bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { | 737 | bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { |
738 | QString type = slChooserNames[index]; | 738 | QString type = slChooserNames[index]; |
739 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); | 739 | qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); |
740 | 740 | ||
741 | if ( !initializing ) | 741 | if ( !initializing ) |
742 | contactfields.setFieldOrder( widgetPos-1, index ); | 742 | contactfields.setFieldOrder( widgetPos-1, index ); |
743 | 743 | ||
744 | // Create and connect combobox for selecting the default email | 744 | // Create and connect combobox for selecting the default email |
745 | if ( type == "Default Email"){ | 745 | if ( type == "Default Email"){ |
746 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); | 746 | qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); |
747 | 747 | ||
748 | // More than one default-email chooser is not allowed ! | 748 | // More than one default-email chooser is not allowed ! |
749 | if ( ( defaultEmailChooserPosition != -1 ) && | 749 | if ( ( defaultEmailChooserPosition != -1 ) && |
750 | defaultEmailChooserPosition != widgetPos && !initializing){ | 750 | defaultEmailChooserPosition != widgetPos && !initializing){ |
751 | chooserError( widgetPos ); | 751 | chooserError( widgetPos ); |
752 | return true; | 752 | return true; |
753 | } | 753 | } |
754 | 754 | ||
755 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); | 755 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
756 | if ( cmbo ){ | 756 | if ( cmbo ){ |
757 | inputStack->raiseWidget( TextField ); | 757 | inputStack->raiseWidget( TextField ); |
758 | inputStack -> removeWidget( cmbo ); | 758 | inputStack -> removeWidget( cmbo ); |
759 | delete cmbo; | 759 | delete cmbo; |
760 | } | 760 | } |
761 | cmbo = new QComboBox( inputStack ); | 761 | cmbo = new QComboBox( inputStack ); |
762 | cmbo -> insertStringList( emails ); | 762 | cmbo -> insertStringList( emails ); |
763 | 763 | ||
764 | inputStack -> addWidget( cmbo, Combo ); | 764 | inputStack -> addWidget( cmbo, Combo ); |
765 | inputStack -> raiseWidget( Combo ); | 765 | inputStack -> raiseWidget( Combo ); |
766 | 766 | ||
767 | defaultEmailChooserPosition = widgetPos; | 767 | defaultEmailChooserPosition = widgetPos; |
768 | cmbDefaultEmail = cmbo; | 768 | cmbDefaultEmail = cmbo; |
769 | 769 | ||
770 | connect( cmbo,SIGNAL( activated(int) ), | 770 | connect( cmbo,SIGNAL( activated(int) ), |
771 | SLOT( defaultEmailChanged(int) ) ); | 771 | SLOT( defaultEmailChanged(int) ) ); |
772 | 772 | ||
773 | // Set current default email | 773 | // Set current default email |
774 | populateDefaultEmailCmb(); | 774 | populateDefaultEmailCmb(); |
775 | 775 | ||
776 | 776 | ||
777 | } else { | 777 | } else { |
778 | // Something else was selected: Hide combo.. | 778 | // Something else was selected: Hide combo.. |
779 | qWarning(" Hiding default-email combo" ); | 779 | qWarning(" Hiding default-email combo" ); |
780 | if ( defaultEmailChooserPosition == widgetPos ){ | 780 | if ( defaultEmailChooserPosition == widgetPos ){ |
781 | defaultEmailChooserPosition = -1; | 781 | defaultEmailChooserPosition = -1; |
782 | } | 782 | } |
783 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); | 783 | QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); |
784 | if ( cmbo ){ | 784 | if ( cmbo ){ |
785 | inputStack->raiseWidget( TextField ); | 785 | inputStack->raiseWidget( TextField ); |
786 | inputStack -> removeWidget( cmbo ); | 786 | inputStack -> removeWidget( cmbo ); |
787 | cmbDefaultEmail = 0l; | 787 | cmbDefaultEmail = 0l; |
788 | delete cmbo; | 788 | delete cmbo; |
789 | } | 789 | } |
790 | 790 | ||
791 | // Caller should initialize the responsible textfield, therefore | 791 | // Caller should initialize the responsible textfield, therefore |
792 | // "false" is returned | 792 | // "false" is returned |
793 | return false; | 793 | return false; |
794 | } | 794 | } |
795 | 795 | ||
796 | // Everything is worked off .. | 796 | // Everything is worked off .. |
797 | return true; | 797 | return true; |
798 | 798 | ||
799 | } | 799 | } |
800 | 800 | ||
801 | // Currently accessed when we select default-email more than once ! | 801 | // Currently accessed when we select default-email more than once ! |
802 | void ContactEditor::chooserError( int index ) | 802 | void ContactEditor::chooserError( int index ) |
803 | { | 803 | { |
804 | qWarning("ContactEditor::chooserError( %d )", index); | 804 | qWarning("ContactEditor::chooserError( %d )", index); |
805 | QMessageBox::warning( this, "Chooser Error", | 805 | QMessageBox::warning( this, "Chooser Error", |
806 | "Multiple selection of this\n" | 806 | "Multiple selection of this\n" |
807 | "Item is not allowed !\n\n" | 807 | "Item is not allowed !\n\n" |
808 | "First deselect the previous one !", | 808 | "First deselect the previous one !", |
809 | "&OK", 0, 0, | 809 | "&OK", 0, 0, |
810 | 0, 0 ); | 810 | 0, 0 ); |
811 | 811 | ||
812 | // Reset the selected Chooser. Unfortunately the chooser | 812 | // Reset the selected Chooser. Unfortunately the chooser |
813 | // generates no signal, therfore we have to | 813 | // generates no signal, therfore we have to |
814 | // call the cmbChooserChange function manually.. | 814 | // call the cmbChooserChange function manually.. |
815 | switch( index ){ | 815 | switch( index ){ |
816 | case 1: | 816 | case 1: |
817 | cmbChooserField1 -> setCurrentItem( 0 ); | 817 | cmbChooserField1 -> setCurrentItem( 0 ); |
818 | slotCmbChooser1Change( 0 ); | 818 | slotCmbChooser1Change( 0 ); |
819 | break; | 819 | break; |
820 | case 2: | 820 | case 2: |
821 | cmbChooserField2 -> setCurrentItem( 0 ); | 821 | cmbChooserField2 -> setCurrentItem( 0 ); |
822 | slotCmbChooser2Change( 0 ); | 822 | slotCmbChooser2Change( 0 ); |
823 | break; | 823 | break; |
824 | case 3: | 824 | case 3: |
825 | cmbChooserField3 -> setCurrentItem( 0 ); | 825 | cmbChooserField3 -> setCurrentItem( 0 ); |
826 | slotCmbChooser3Change( 0 ); | 826 | slotCmbChooser3Change( 0 ); |
827 | break; | 827 | break; |
828 | case 4: | 828 | case 4: |
829 | cmbChooserField4 -> setCurrentItem( 0 ); | 829 | cmbChooserField4 -> setCurrentItem( 0 ); |
830 | slotCmbChooser4Change( 0 ); | 830 | slotCmbChooser4Change( 0 ); |
831 | break; | 831 | break; |
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | // Called when something was changed in a textfield (shouldn't it called textchanged? (se)) | 835 | // Called when something was changed in a textfield (shouldn't it called textchanged? (se)) |
836 | void ContactEditor::chooserChange( const QString &textChanged, int index, | 836 | void ContactEditor::chooserChange( const QString &textChanged, int index, |
837 | QLineEdit* , int widgetPos ) { | 837 | QLineEdit* , int widgetPos ) { |
838 | 838 | ||
839 | QString type = slChooserNames[index]; // :SX | 839 | QString type = slChooserNames[index]; // :SX |
840 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", | 840 | qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", |
841 | type.latin1(),textChanged.latin1(), index, widgetPos ); | 841 | type.latin1(),textChanged.latin1(), index, widgetPos ); |
842 | 842 | ||
843 | if ( type == "Default Email"){ | 843 | if ( type == "Default Email"){ |
844 | qWarning ("??? Wozu??: %s", textChanged.latin1()); | 844 | qWarning ("??? Wozu??: %s", textChanged.latin1()); |
845 | defaultEmail = textChanged; | 845 | defaultEmail = textChanged; |
846 | 846 | ||
847 | populateDefaultEmailCmb(); | 847 | populateDefaultEmailCmb(); |
848 | 848 | ||
849 | }else if (type == "Emails"){ | 849 | }else if (type == "Emails"){ |
850 | qDebug("emails"); | 850 | qDebug("emails"); |
851 | 851 | ||
852 | QString de; | 852 | QString de; |
853 | emails = QStringList::split (",", textChanged ); | 853 | emails = QStringList::split (",", textChanged ); |
854 | 854 | ||
855 | populateDefaultEmailCmb(); | 855 | populateDefaultEmailCmb(); |
856 | } | 856 | } |
857 | 857 | ||
858 | slChooserValues[index] = textChanged; | 858 | slChooserValues[index] = textChanged; |
859 | 859 | ||
860 | } | 860 | } |
861 | 861 | ||
862 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { | 862 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { |
863 | qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); | 863 | qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); |
864 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); | 864 | chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); |
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index af26302..3934411 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -1,1072 +1,1070 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "datebook.h" | 25 | #include "datebook.h" |
26 | #include "datebookday.h" | 26 | #include "datebookday.h" |
27 | #include "datebooksettings.h" | 27 | #include "datebooksettings.h" |
28 | #include "datebookweek.h" | 28 | #include "datebookweek.h" |
29 | #include "datebookweeklst.h" | 29 | #include "datebookweeklst.h" |
30 | #include "dateentryimpl.h" | 30 | #include "dateentryimpl.h" |
31 | 31 | ||
32 | #include <qpe/datebookmonth.h> | 32 | #include <qpe/datebookmonth.h> |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/finddialog.h> | 35 | #include <qpe/finddialog.h> |
36 | #include <qpe/ir.h> | 36 | #include <qpe/ir.h> |
37 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | #include <qpe/sound.h> | 39 | #include <qpe/sound.h> |
40 | #include <qtoolbar.h> | 40 | #include <qtoolbar.h> |
41 | #include <qpe/tzselect.h> | 41 | #include <qpe/tzselect.h> |
42 | 42 | ||
43 | #include <qaction.h> | 43 | #include <qaction.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qtimer.h> | 47 | #include <qtimer.h> |
48 | #include <qtl.h> | 48 | #include <qtl.h> |
49 | #include <qwidgetstack.h> | 49 | #include <qwidgetstack.h> |
50 | 50 | ||
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <sys/types.h> | 52 | #include <sys/types.h> |
53 | #include <fcntl.h> | 53 | #include <fcntl.h> |
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | 55 | ||
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | 57 | ||
58 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 58 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
59 | : QMainWindow( parent, "datebook", f ), | 59 | : QMainWindow( parent, "datebook", f ), |
60 | aPreset( FALSE ), | 60 | aPreset( FALSE ), |
61 | presetTime( -1 ), | 61 | presetTime( -1 ), |
62 | startTime( 8 ), // an acceptable default | 62 | startTime( 8 ), // an acceptable default |
63 | rowStyle( 0 ), | 63 | rowStyle( 0 ), |
64 | bJumpToCurTime(FALSE), | 64 | bJumpToCurTime(FALSE), |
65 | syncing(FALSE), | 65 | syncing(FALSE), |
66 | inSearch(FALSE), | 66 | inSearch(FALSE), |
67 | alarmCounter(0) | 67 | alarmCounter(0) |
68 | { | 68 | { |
69 | bool needEvilHack= false; // if we need an Evil Hack | 69 | bool needEvilHack= false; // if we need an Evil Hack |
70 | QTime t; | 70 | QTime t; |
71 | t.start(); | 71 | t.start(); |
72 | db = new DateBookDBHack; | 72 | db = new DateBookDBHack; |
73 | qDebug("loading db t=%d", t.elapsed() ); | 73 | qDebug("loading db t=%d", t.elapsed() ); |
74 | loadSettings(); | 74 | loadSettings(); |
75 | setCaption( tr("Calendar") ); | 75 | setCaption( tr("Calendar") ); |
76 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 76 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
77 | 77 | ||
78 | setToolBarsMovable( FALSE ); | 78 | setToolBarsMovable( FALSE ); |
79 | 79 | ||
80 | views = new QWidgetStack( this ); | 80 | views = new QWidgetStack( this ); |
81 | setCentralWidget( views ); | 81 | setCentralWidget( views ); |
82 | 82 | ||
83 | dayView = 0; | 83 | dayView = 0; |
84 | weekView = 0; | 84 | weekView = 0; |
85 | weekLstView = 0; | 85 | weekLstView = 0; |
86 | monthView = 0; | 86 | monthView = 0; |
87 | 87 | ||
88 | // QToolBar *bar = new QToolBar( this ); | 88 | // QToolBar *bar = new QToolBar( this ); |
89 | // bar->setHorizontalStretchable( TRUE ); | 89 | // bar->setHorizontalStretchable( TRUE ); |
90 | 90 | ||
91 | // QMenuBar *mb = new QMenuBar( bar ); | 91 | // QMenuBar *mb = new QMenuBar( bar ); |
92 | // mb->setMargin( 0 ); | 92 | // mb->setMargin( 0 ); |
93 | 93 | ||
94 | // QPopupMenu *view = new QPopupMenu( this ); | 94 | // QPopupMenu *view = new QPopupMenu( this ); |
95 | // mb->insertItem( tr( "View" ), view ); | 95 | // mb->insertItem( tr( "View" ), view ); |
96 | 96 | ||
97 | QToolBar *sub_bar = new QToolBar(this); | 97 | QToolBar *sub_bar = new QToolBar(this); |
98 | sub_bar->setHorizontalStretchable(TRUE); | 98 | sub_bar->setHorizontalStretchable(TRUE); |
99 | 99 | ||
100 | QActionGroup *g = new QActionGroup( this ); | 100 | QActionGroup *g = new QActionGroup( this ); |
101 | g->setExclusive( TRUE ); | 101 | g->setExclusive( TRUE ); |
102 | 102 | ||
103 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 103 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
104 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 104 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
105 | a->addTo( sub_bar ); | 105 | a->addTo( sub_bar ); |
106 | 106 | ||
107 | sub_bar->addSeparator(); | 107 | sub_bar->addSeparator(); |
108 | 108 | ||
109 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 109 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); |
110 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 110 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
111 | a->addTo( sub_bar ); | 111 | a->addTo( sub_bar ); |
112 | //a->addTo( view ); | 112 | //a->addTo( view ); |
113 | 113 | ||
114 | sub_bar->addSeparator(); | 114 | sub_bar->addSeparator(); |
115 | 115 | ||
116 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 116 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
117 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 117 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
118 | a->addTo( sub_bar ); | 118 | a->addTo( sub_bar ); |
119 | // a->addTo( view ); | 119 | // a->addTo( view ); |
120 | a->setToggleAction( TRUE ); | 120 | a->setToggleAction( TRUE ); |
121 | a->setOn( TRUE ); | 121 | a->setOn( TRUE ); |
122 | dayAction = a; | 122 | dayAction = a; |
123 | 123 | ||
124 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 124 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
125 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
126 | a->addTo( sub_bar ); | 126 | a->addTo( sub_bar ); |
127 | // a->addTo( view ); | 127 | // a->addTo( view ); |
128 | a->setToggleAction( TRUE ); | 128 | a->setToggleAction( TRUE ); |
129 | weekAction = a; | 129 | weekAction = a; |
130 | 130 | ||
131 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 131 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
132 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
133 | a->addTo( sub_bar ); | 133 | a->addTo( sub_bar ); |
134 | // a->addTo( view ); | 134 | // a->addTo( view ); |
135 | a->setToggleAction( TRUE ); | 135 | a->setToggleAction( TRUE ); |
136 | weekLstAction = a; | 136 | weekLstAction = a; |
137 | 137 | ||
138 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 138 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
139 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 139 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
140 | a->addTo( sub_bar ); | 140 | a->addTo( sub_bar ); |
141 | // a->addTo( view ); | 141 | // a->addTo( view ); |
142 | a->setToggleAction( TRUE ); | 142 | a->setToggleAction( TRUE ); |
143 | monthAction = a; | 143 | monthAction = a; |
144 | 144 | ||
145 | sub_bar->addSeparator(); | 145 | sub_bar->addSeparator(); |
146 | 146 | ||
147 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 147 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
148 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 148 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
149 | a->addTo( sub_bar ); | 149 | a->addTo( sub_bar ); |
150 | 150 | ||
151 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | 151 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); |
152 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 152 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
153 | a->addTo( sub_bar ); | 153 | a->addTo( sub_bar ); |
154 | 154 | ||
155 | if(defaultView==DAY) viewDay(); | 155 | if(defaultView==DAY) viewDay(); |
156 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); | 156 | if(defaultView==WEEK) needEvilHack=true;// viewWeek(); |
157 | if(defaultView==WEEKLST) viewWeekLst(); | 157 | if(defaultView==WEEKLST) viewWeekLst(); |
158 | if(defaultView==MONTH) viewMonth(); | 158 | if(defaultView==MONTH) viewMonth(); |
159 | 159 | ||
160 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 160 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
161 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 161 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
162 | 162 | ||
163 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 163 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
164 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 164 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | // listen on QPE/System | 167 | // listen on QPE/System |
168 | #if defined(Q_WS_QWS) | 168 | #if defined(Q_WS_QWS) |
169 | #if !defined(QT_NO_COP) | 169 | #if !defined(QT_NO_COP) |
170 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 170 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
171 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 171 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
172 | channel = new QCopChannel( "QPE/Datebook", this ); | 172 | channel = new QCopChannel( "QPE/Datebook", this ); |
173 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); | 173 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
174 | #endif | 174 | #endif |
175 | #endif | 175 | #endif |
176 | 176 | ||
177 | qDebug("done t=%d", t.elapsed() ); | 177 | qDebug("done t=%d", t.elapsed() ); |
178 | 178 | ||
179 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 179 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
180 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | 180 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); |
181 | /* | 181 | /* |
182 | * Here is a problem description: | 182 | * Here is a problem description: |
183 | * When Weekview is the default view | 183 | * When Weekview is the default view |
184 | * a DateBookWeekView get's created | 184 | * a DateBookWeekView get's created |
185 | * redraw() get's called. So what? | 185 | * redraw() get's called. So what? |
186 | * Remember that we're still in the c'tor | 186 | * Remember that we're still in the c'tor |
187 | * and no final layout has happened? Ok | 187 | * and no final layout has happened? Ok |
188 | * now all Events get arranged. Their x | 188 | * now all Events get arranged. Their x |
189 | * position get's determined by a QHeader | 189 | * position get's determined by a QHeader |
190 | * position. But the QHeader isn't layouted or | 190 | * position. But the QHeader isn't layouted or |
191 | * at the right position. redraw() is a slot | 191 | * at the right position. redraw() is a slot |
192 | * so we'll call it then via a singleShot | 192 | * so we'll call it then via a singleShot |
193 | * from view() | 193 | * from view() |
194 | */ | 194 | */ |
195 | if( needEvilHack ){ | 195 | if( needEvilHack ){ |
196 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 196 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 200 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
201 | { | 201 | { |
202 | QDataStream stream( data, IO_ReadOnly ); | 202 | QDataStream stream( data, IO_ReadOnly ); |
203 | if ( msg == "timeChange(QString)" ) { | 203 | if ( msg == "timeChange(QString)" ) { |
204 | // update active view! | 204 | // update active view! |
205 | if ( dayAction->isOn() ) | 205 | if ( dayAction->isOn() ) |
206 | viewDay(); | 206 | viewDay(); |
207 | else if ( weekAction->isOn() ) | 207 | else if ( weekAction->isOn() ) |
208 | viewWeek(); | 208 | viewWeek(); |
209 | else if ( monthAction->isOn() ) | 209 | else if ( monthAction->isOn() ) |
210 | viewMonth(); | 210 | viewMonth(); |
211 | } | 211 | } |
212 | else if (msg == "editEvent(int)") { | 212 | else if (msg == "editEvent(int)") { |
213 | int uid; | 213 | int uid; |
214 | stream >> uid; | 214 | stream >> uid; |
215 | Event e=db->eventByUID(uid); | 215 | Event e=db->eventByUID(uid); |
216 | editEvent(e); | 216 | editEvent(e); |
217 | }else if (msg == "viewDefault(QDate)"){ | 217 | }else if (msg == "viewDefault(QDate)"){ |
218 | QDate day; | 218 | QDate day; |
219 | stream >> day; | 219 | stream >> day; |
220 | viewDefault(day); | 220 | viewDefault(day); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | DateBook::~DateBook() | 224 | DateBook::~DateBook() |
225 | { | 225 | { |
226 | } | 226 | } |
227 | 227 | ||
228 | void DateBook::slotSettings() | 228 | void DateBook::slotSettings() |
229 | { | 229 | { |
230 | DateBookSettings frmSettings( ampm, this ); | 230 | DateBookSettings frmSettings( ampm, this ); |
231 | frmSettings.setStartTime( startTime ); | 231 | frmSettings.setStartTime( startTime ); |
232 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 232 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
233 | frmSettings.setJumpToCurTime( bJumpToCurTime ); | 233 | frmSettings.setJumpToCurTime( bJumpToCurTime ); |
234 | frmSettings.setRowStyle( rowStyle ); | 234 | frmSettings.setRowStyle( rowStyle ); |
235 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); | 235 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); |
236 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); | 236 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); |
237 | 237 | ||
238 | bool found=false; | 238 | bool found=false; |
239 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { | 239 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { |
240 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { | 240 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { |
241 | frmSettings.comboLocation->setCurrentItem(i); | 241 | frmSettings.comboLocation->setCurrentItem(i); |
242 | found=true; | 242 | found=true; |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | if(!found) { | 246 | if(!found) { |
247 | frmSettings.comboLocation->insertItem(defaultLocation); | 247 | frmSettings.comboLocation->insertItem(defaultLocation); |
248 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); | 248 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); |
249 | } | 249 | } |
250 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); | 250 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); |
251 | 251 | ||
252 | if ( QPEApplication::execDialog( &frmSettings ) ) { | 252 | if ( QPEApplication::execDialog( &frmSettings ) ) { |
253 | aPreset = frmSettings.alarmPreset(); | 253 | aPreset = frmSettings.alarmPreset(); |
254 | presetTime = frmSettings.presetTime(); | 254 | presetTime = frmSettings.presetTime(); |
255 | startTime = frmSettings.startTime(); | 255 | startTime = frmSettings.startTime(); |
256 | bJumpToCurTime = frmSettings.jumpToCurTime(); | 256 | bJumpToCurTime = frmSettings.jumpToCurTime(); |
257 | rowStyle = frmSettings.rowStyle(); | 257 | rowStyle = frmSettings.rowStyle(); |
258 | defaultView=frmSettings.comboDefaultView->currentItem()+1; | 258 | defaultView=frmSettings.comboDefaultView->currentItem()+1; |
259 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); | 259 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); |
260 | defaultLocation=frmSettings.comboLocation->currentText(); | 260 | defaultLocation=frmSettings.comboLocation->currentText(); |
261 | defaultCategories=frmSettings.comboCategory->currentCategories(); | 261 | defaultCategories=frmSettings.comboCategory->currentCategories(); |
262 | 262 | ||
263 | if ( dayView ) { | 263 | if ( dayView ) { |
264 | dayView->setStartViewTime( startTime ); | 264 | dayView->setStartViewTime( startTime ); |
265 | dayView->setJumpToCurTime( bJumpToCurTime ); | 265 | dayView->setJumpToCurTime( bJumpToCurTime ); |
266 | dayView->setRowStyle( rowStyle ); | 266 | dayView->setRowStyle( rowStyle ); |
267 | } | 267 | } |
268 | if ( weekView ) { | 268 | if ( weekView ) { |
269 | weekView->setStartViewTime( startTime ); | 269 | weekView->setStartViewTime( startTime ); |
270 | } | 270 | } |
271 | saveSettings(); | 271 | saveSettings(); |
272 | 272 | ||
273 | // make the change obvious | 273 | // make the change obvious |
274 | if ( views->visibleWidget() ) { | 274 | if ( views->visibleWidget() ) { |
275 | if ( views->visibleWidget() == dayView ) | 275 | if ( views->visibleWidget() == dayView ) |
276 | dayView->redraw(); | 276 | dayView->redraw(); |
277 | else if ( views->visibleWidget() == weekView ) | 277 | else if ( views->visibleWidget() == weekView ) |
278 | weekView->redraw(); | 278 | weekView->redraw(); |
279 | else if ( views->visibleWidget() == weekLstView ) | 279 | else if ( views->visibleWidget() == weekLstView ) |
280 | weekLstView->redraw(); | 280 | weekLstView->redraw(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void DateBook::fileNew() | 285 | void DateBook::fileNew() |
286 | { | 286 | { |
287 | slotNewEventFromKey(""); | 287 | slotNewEventFromKey(""); |
288 | } | 288 | } |
289 | 289 | ||
290 | QString DateBook::checkEvent(const Event &e) | 290 | QString DateBook::checkEvent(const Event &e) |
291 | { | 291 | { |
292 | /* check if overlaps with itself */ | 292 | /* check if overlaps with itself */ |
293 | bool checkFailed = FALSE; | 293 | bool checkFailed = FALSE; |
294 | 294 | ||
295 | /* check the next 12 repeats. should catch most problems */ | 295 | /* check the next 12 repeats. should catch most problems */ |
296 | QDate current_date = e.start().date(); | 296 | QDate current_date = e.start().date(); |
297 | Event previous = e; | 297 | Event previous = e; |
298 | for(int i = 0; i < 12; i++) | 298 | for(int i = 0; i < 12; i++) |
299 | { | 299 | { |
300 | QDateTime next; | 300 | QDateTime next; |
301 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 301 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
302 | break; // no more repeats | 302 | break; // no more repeats |
303 | } | 303 | } |
304 | if(next < previous.end()) { | 304 | if(next < previous.end()) { |
305 | checkFailed = TRUE; | 305 | checkFailed = TRUE; |
306 | break; | 306 | break; |
307 | } | 307 | } |
308 | current_date = next.date(); | 308 | current_date = next.date(); |
309 | } | 309 | } |
310 | 310 | ||
311 | if(checkFailed) | 311 | if(checkFailed) |
312 | return tr("Event duration is potentially longer\n" | 312 | return tr("Event duration is potentially longer\n" |
313 | "than interval between repeats."); | 313 | "than interval between repeats."); |
314 | 314 | ||
315 | return QString::null; | 315 | return QString::null; |
316 | } | 316 | } |
317 | 317 | ||
318 | QDate DateBook::currentDate() | 318 | QDate DateBook::currentDate() |
319 | { | 319 | { |
320 | QDate d = QDate::currentDate(); | 320 | QDate d = QDate::currentDate(); |
321 | 321 | ||
322 | if ( dayView && views->visibleWidget() == dayView ) { | 322 | if ( dayView && views->visibleWidget() == dayView ) { |
323 | d = dayView->date(); | 323 | d = dayView->date(); |
324 | } else if ( weekView && views->visibleWidget() == weekView ) { | 324 | } else if ( weekView && views->visibleWidget() == weekView ) { |
325 | d = weekView->date(); | 325 | d = weekView->date(); |
326 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 326 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
327 | d = weekLstView->date(); | 327 | d = weekLstView->date(); |
328 | } else if ( monthView && views->visibleWidget() == monthView ) { | 328 | } else if ( monthView && views->visibleWidget() == monthView ) { |
329 | d = monthView->selectedDate(); | 329 | d = monthView->selectedDate(); |
330 | } | 330 | } |
331 | 331 | ||
332 | return d; | 332 | return d; |
333 | } | 333 | } |
334 | 334 | ||
335 | void DateBook::view(int v, const QDate &d) { | 335 | void DateBook::view(int v, const QDate &d) { |
336 | if (v==DAY) { | 336 | if (v==DAY) { |
337 | initDay(); | 337 | initDay(); |
338 | dayAction->setOn( TRUE ); | 338 | dayAction->setOn( TRUE ); |
339 | dayView->setDate( d ); | 339 | dayView->setDate( d ); |
340 | views->raiseWidget( dayView ); | 340 | views->raiseWidget( dayView ); |
341 | dayView->redraw(); | 341 | dayView->redraw(); |
342 | } else if (v==WEEK) { | 342 | } else if (v==WEEK) { |
343 | initWeek(); | 343 | initWeek(); |
344 | weekAction->setOn( TRUE ); | 344 | weekAction->setOn( TRUE ); |
345 | weekView->setDate( d ); | 345 | weekView->setDate( d ); |
346 | views->raiseWidget( weekView ); | 346 | views->raiseWidget( weekView ); |
347 | weekView->redraw(); | 347 | weekView->redraw(); |
348 | } else if (v==WEEKLST) { | 348 | } else if (v==WEEKLST) { |
349 | initWeekLst(); | 349 | initWeekLst(); |
350 | weekLstAction->setOn( TRUE ); | 350 | weekLstAction->setOn( TRUE ); |
351 | weekLstView->setDate(d); | 351 | weekLstView->setDate(d); |
352 | views->raiseWidget( weekLstView ); | 352 | views->raiseWidget( weekLstView ); |
353 | weekLstView->redraw(); | 353 | weekLstView->redraw(); |
354 | } else if (v==MONTH) { | 354 | } else if (v==MONTH) { |
355 | initMonth(); | 355 | initMonth(); |
356 | monthAction->setOn( TRUE ); | 356 | monthAction->setOn( TRUE ); |
357 | monthView->setDate( d.year(), d.month(), d.day() ); | 357 | monthView->setDate( d.year(), d.month(), d.day() ); |
358 | views->raiseWidget( monthView ); | 358 | views->raiseWidget( monthView ); |
359 | monthView->redraw(); | 359 | monthView->redraw(); |
360 | } | 360 | } |
361 | } | 361 | } |
362 | 362 | ||
363 | void DateBook::viewDefault(const QDate &d) { | 363 | void DateBook::viewDefault(const QDate &d) { |
364 | view(defaultView,d); | 364 | view(defaultView,d); |
365 | } | 365 | } |
366 | 366 | ||
367 | void DateBook::viewDay() { | 367 | void DateBook::viewDay() { |
368 | view(DAY,currentDate()); | 368 | view(DAY,currentDate()); |
369 | } | 369 | } |
370 | 370 | ||
371 | void DateBook::viewWeek() { | 371 | void DateBook::viewWeek() { |
372 | view(WEEK,currentDate()); | 372 | view(WEEK,currentDate()); |
373 | } | 373 | } |
374 | 374 | ||
375 | void DateBook::viewWeekLst() { | 375 | void DateBook::viewWeekLst() { |
376 | view(WEEKLST,currentDate()); | 376 | view(WEEKLST,currentDate()); |
377 | } | 377 | } |
378 | 378 | ||
379 | void DateBook::viewMonth() { | 379 | void DateBook::viewMonth() { |
380 | view(MONTH,currentDate()); | 380 | view(MONTH,currentDate()); |
381 | } | 381 | } |
382 | 382 | ||
383 | void DateBook::insertEvent( const Event &e ) | 383 | void DateBook::insertEvent( const Event &e ) |
384 | { | 384 | { |
385 | Event dupEvent=e; | 385 | Event dupEvent=e; |
386 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different | 386 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different |
387 | dupEvent.assignUid(); | 387 | dupEvent.assignUid(); |
388 | dupEvent.setLocation(defaultLocation); | 388 | dupEvent.setLocation(defaultLocation); |
389 | dupEvent.setCategories(defaultCategories); | 389 | dupEvent.setCategories(defaultCategories); |
390 | db->addEvent(dupEvent); | 390 | db->addEvent(dupEvent); |
391 | emit newEvent(); | 391 | emit newEvent(); |
392 | } | 392 | } |
393 | 393 | ||
394 | void DateBook::duplicateEvent( const Event &e ) | 394 | void DateBook::duplicateEvent( const Event &e ) |
395 | { | 395 | { |
396 | // Alot of code duplication, as this is almost like editEvent(); | 396 | // Alot of code duplication, as this is almost like editEvent(); |
397 | if (syncing) { | 397 | if (syncing) { |
398 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 398 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
399 | return; | 399 | return; |
400 | } | 400 | } |
401 | 401 | ||
402 | Event dupevent(e);// Make a duplicate. | 402 | Event dupevent(e);// Make a duplicate. |
403 | 403 | ||
404 | // workaround added for text input. | 404 | // workaround added for text input. |
405 | QDialog editDlg( this, 0, TRUE ); | 405 | QDialog editDlg( this, 0, TRUE ); |
406 | DateEntry *entry; | 406 | DateEntry *entry; |
407 | editDlg.setCaption( tr("Duplicate Event") ); | 407 | editDlg.setCaption( tr("Duplicate Event") ); |
408 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 408 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
409 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 409 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
410 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 410 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
411 | // KLUDGE!!! | 411 | // KLUDGE!!! |
412 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 412 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
413 | vb->addWidget( sv ); | 413 | vb->addWidget( sv ); |
414 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); | 414 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); |
415 | entry->timezone->setEnabled( FALSE ); | 415 | entry->timezone->setEnabled( FALSE ); |
416 | sv->addChild( entry ); | 416 | sv->addChild( entry ); |
417 | 417 | ||
418 | while ( QPEApplication::execDialog( &editDlg ) ) { | 418 | while ( QPEApplication::execDialog( &editDlg ) ) { |
419 | Event newEv = entry->event(); | 419 | Event newEv = entry->event(); |
420 | QString error = checkEvent(newEv); | 420 | QString error = checkEvent(newEv); |
421 | if (!error.isNull()) { | 421 | if (!error.isNull()) { |
422 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) | 422 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) |
423 | continue; | 423 | continue; |
424 | } | 424 | } |
425 | /* | 425 | /* |
426 | * The problem: | 426 | * The problem: |
427 | * DateBookDB does remove repeating events not by uid but by the time | 427 | * DateBookDB does remove repeating events not by uid but by the time |
428 | * the recurrence was created | 428 | * the recurrence was created |
429 | * so we need to update that time as well | 429 | * so we need to update that time as well |
430 | */ | 430 | */ |
431 | Event::RepeatPattern rp = newEv.repeatPattern(); | 431 | Event::RepeatPattern rp = newEv.repeatPattern(); |
432 | rp.createTime = ::time( NULL ); | 432 | rp.createTime = ::time( NULL ); |
433 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... | 433 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... |
434 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) | 434 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) |
435 | newEv.assignUid(); | 435 | newEv.assignUid(); |
436 | 436 | ||
437 | db->addEvent(newEv); | 437 | db->addEvent(newEv); |
438 | emit newEvent(); | 438 | emit newEvent(); |
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | void DateBook::editEvent( const Event &e ) | 443 | void DateBook::editEvent( const Event &e ) |
444 | { | 444 | { |
445 | if (syncing) { | 445 | if (syncing) { |
446 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 446 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | 449 | ||
450 | // workaround added for text input. | 450 | // workaround added for text input. |
451 | QDialog editDlg( this, 0, TRUE ); | 451 | QDialog editDlg( this, 0, TRUE ); |
452 | DateEntry *entry; | 452 | DateEntry *entry; |
453 | editDlg.setCaption( tr("Edit Event") ); | 453 | editDlg.setCaption( tr("Edit Event") ); |
454 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 454 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
455 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 455 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
456 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 456 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
457 | // KLUDGE!!! | 457 | // KLUDGE!!! |
458 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 458 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
459 | vb->addWidget( sv ); | 459 | vb->addWidget( sv ); |
460 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 460 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
461 | entry->timezone->setEnabled( FALSE ); | 461 | entry->timezone->setEnabled( FALSE ); |
462 | sv->addChild( entry ); | 462 | sv->addChild( entry ); |
463 | 463 | ||
464 | while ( QPEApplication::execDialog( &editDlg ) ) { | 464 | while ( QPEApplication::execDialog( &editDlg ) ) { |
465 | Event newEv = entry->event(); | 465 | Event newEv = entry->event(); |
466 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | 466 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) |
467 | break; | 467 | break; |
468 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 468 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
469 | QString error = checkEvent(newEv); | 469 | QString error = checkEvent(newEv); |
470 | if (!error.isNull()) { | 470 | if (!error.isNull()) { |
471 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; | 471 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; |
472 | } | 472 | } |
473 | db->editEvent(e, newEv); | 473 | db->editEvent(e, newEv); |
474 | emit newEvent(); | 474 | emit newEvent(); |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | void DateBook::removeEvent( const Event &e ) | 479 | void DateBook::removeEvent( const Event &e ) |
480 | { | 480 | { |
481 | if (syncing) { | 481 | if (syncing) { |
482 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 482 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
483 | return; | 483 | return; |
484 | } | 484 | } |
485 | 485 | ||
486 | QString strName = e.description(); | 486 | QString strName = e.description(); |
487 | 487 | ||
488 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 488 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
489 | return; | 489 | return; |
490 | 490 | ||
491 | db->removeEvent( e ); | 491 | db->removeEvent( e ); |
492 | if ( views->visibleWidget() == dayView && dayView ) | 492 | if ( views->visibleWidget() == dayView && dayView ) |
493 | dayView->redraw(); | 493 | dayView->redraw(); |
494 | 494 | ||
495 | } | 495 | } |
496 | 496 | ||
497 | void DateBook::addEvent( const Event &e ) | 497 | void DateBook::addEvent( const Event &e ) |
498 | { | 498 | { |
499 | QDate d = e.start().date(); | 499 | QDate d = e.start().date(); |
500 | initDay(); | 500 | initDay(); |
501 | dayView->setDate( d ); | 501 | dayView->setDate( d ); |
502 | } | 502 | } |
503 | 503 | ||
504 | void DateBook::showDay( int year, int month, int day ) | 504 | void DateBook::showDay( int year, int month, int day ) |
505 | { | 505 | { |
506 | QDate d(year, month, day); | 506 | QDate d(year, month, day); |
507 | view(DAY,d); | 507 | view(DAY,d); |
508 | } | 508 | } |
509 | 509 | ||
510 | void DateBook::initDay() | 510 | void DateBook::initDay() |
511 | { | 511 | { |
512 | if ( !dayView ) { | 512 | if ( !dayView ) { |
513 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 513 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
514 | views->addWidget( dayView, DAY ); | 514 | views->addWidget( dayView, DAY ); |
515 | dayView->setJumpToCurTime( bJumpToCurTime ); | 515 | dayView->setJumpToCurTime( bJumpToCurTime ); |
516 | dayView->setStartViewTime( startTime ); | 516 | dayView->setStartViewTime( startTime ); |
517 | dayView->setRowStyle( rowStyle ); | 517 | dayView->setRowStyle( rowStyle ); |
518 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); | 518 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); |
519 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); | 519 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); |
520 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); | 520 | connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); |
521 | connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); | 521 | connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
522 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); | 522 | connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); |
523 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); | 523 | connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); |
524 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); | 524 | connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); |
525 | } | 525 | } |
526 | } | 526 | } |
527 | 527 | ||
528 | void DateBook::initWeek() | 528 | void DateBook::initWeek() |
529 | { | 529 | { |
530 | if ( !weekView ) { | 530 | if ( !weekView ) { |
531 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 531 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
532 | weekView->setStartViewTime( startTime ); | 532 | weekView->setStartViewTime( startTime ); |
533 | views->addWidget( weekView, WEEK ); | 533 | views->addWidget( weekView, WEEK ); |
534 | connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); | 534 | connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
535 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); | 535 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); |
536 | } | 536 | } |
537 | 537 | ||
538 | //But also get it right: the year that we display can be different | 538 | //But also get it right: the year that we display can be different |
539 | //from the year of the current date. So, first find the year | 539 | //from the year of the current date. So, first find the year |
540 | //number of the current week. | 540 | //number of the current week. |
541 | int yearNumber, totWeeks; | 541 | int yearNumber, totWeeks; |
542 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 542 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
543 | 543 | ||
544 | QDate d = QDate( yearNumber, 12, 31 ); | 544 | QDate d = QDate( yearNumber, 12, 31 ); |
545 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 545 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
546 | 546 | ||
547 | while ( totWeeks == 1 ) { | 547 | while ( totWeeks == 1 ) { |
548 | d = d.addDays( -1 ); | 548 | d = d.addDays( -1 ); |
549 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 549 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
550 | } | 550 | } |
551 | } | 551 | } |
552 | 552 | ||
553 | void DateBook::initWeekLst() { | 553 | void DateBook::initWeekLst() { |
554 | if ( !weekLstView ) { | 554 | if ( !weekLstView ) { |
555 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); | 555 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); |
556 | views->addWidget( weekLstView, WEEKLST ); | 556 | views->addWidget( weekLstView, WEEKLST ); |
557 | 557 | ||
558 | //weekLstView->setStartViewTime( startTime ); | 558 | //weekLstView->setStartViewTime( startTime ); |
559 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); | 559 | connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
560 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), | 560 | connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), |
561 | this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); | 561 | this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); |
562 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); | 562 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
563 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); | 563 | connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
564 | } | 564 | } |
565 | } | 565 | } |
566 | 566 | ||
567 | 567 | ||
568 | void DateBook::initMonth() | 568 | void DateBook::initMonth() |
569 | { | 569 | { |
570 | if ( !monthView ) { | 570 | if ( !monthView ) { |
571 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 571 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
572 | views->addWidget( monthView, MONTH ); | 572 | views->addWidget( monthView, MONTH ); |
573 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); | 573 | connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
574 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); | 574 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); |
575 | qApp->processEvents(); | 575 | qApp->processEvents(); |
576 | } | 576 | } |
577 | } | 577 | } |
578 | 578 | ||
579 | void DateBook::loadSettings() | 579 | void DateBook::loadSettings() |
580 | { | 580 | { |
581 | Config qpeconfig( "qpe" ); | 581 | Config qpeconfig( "qpe" ); |
582 | qpeconfig.setGroup("Time"); | 582 | qpeconfig.setGroup("Time"); |
583 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); | 583 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); |
584 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); | 584 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); |
585 | 585 | ||
586 | Config config("DateBook"); | 586 | Config config("DateBook"); |
587 | config.setGroup("Main"); | 587 | config.setGroup("Main"); |
588 | startTime = config.readNumEntry("startviewtime", 8); | 588 | startTime = config.readNumEntry("startviewtime", 8); |
589 | aPreset = config.readBoolEntry("alarmpreset"); | 589 | aPreset = config.readBoolEntry("alarmpreset"); |
590 | presetTime = config.readNumEntry("presettime"); | 590 | presetTime = config.readNumEntry("presettime"); |
591 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 591 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
592 | rowStyle = config.readNumEntry("rowstyle"); | 592 | rowStyle = config.readNumEntry("rowstyle"); |
593 | defaultView = config.readNumEntry("defaultview",DAY); | 593 | defaultView = config.readNumEntry("defaultview",DAY); |
594 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); | 594 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); |
595 | 595 | ||
596 | defaultLocation=config.readEntry("defaultLocation"); | 596 | defaultLocation=config.readEntry("defaultLocation"); |
597 | QString tmpString=config.readEntry("defaultCategories"); | 597 | QString tmpString=config.readEntry("defaultCategories"); |
598 | QStringList tmpStringList=QStringList::split(",",tmpString); | 598 | QStringList tmpStringList=QStringList::split(",",tmpString); |
599 | defaultCategories.truncate(0); | 599 | defaultCategories.truncate(0); |
600 | 600 | ||
601 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { | 601 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { |
602 | defaultCategories.resize(defaultCategories.count()+1); | 602 | defaultCategories.resize(defaultCategories.count()+1); |
603 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); | 603 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); |
604 | } | 604 | } |
605 | } | 605 | } |
606 | 606 | ||
607 | void DateBook::saveSettings() | 607 | void DateBook::saveSettings() |
608 | { | 608 | { |
609 | Config config( "qpe" ); | 609 | Config config( "qpe" ); |
610 | Config configDB( "DateBook" ); | 610 | Config configDB( "DateBook" ); |
611 | configDB.setGroup( "Main" ); | 611 | configDB.setGroup( "Main" ); |
612 | configDB.writeEntry("startviewtime",startTime); | 612 | configDB.writeEntry("startviewtime",startTime); |
613 | configDB.writeEntry("alarmpreset",aPreset); | 613 | configDB.writeEntry("alarmpreset",aPreset); |
614 | configDB.writeEntry("presettime",presetTime); | 614 | configDB.writeEntry("presettime",presetTime); |
615 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 615 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
616 | configDB.writeEntry("rowstyle", rowStyle); | 616 | configDB.writeEntry("rowstyle", rowStyle); |
617 | configDB.writeEntry("defaultview",defaultView); | 617 | configDB.writeEntry("defaultview",defaultView); |
618 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); | 618 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); |
619 | 619 | ||
620 | configDB.writeEntry("defaultLocation",defaultLocation); | 620 | configDB.writeEntry("defaultLocation",defaultLocation); |
621 | QStringList tmpStringList; | 621 | QStringList tmpStringList; |
622 | for( uint i=0; i<defaultCategories.count(); i++) { | 622 | for( uint i=0; i<defaultCategories.count(); i++) { |
623 | tmpStringList << QString::number(defaultCategories[i]); | 623 | tmpStringList << QString::number(defaultCategories[i]); |
624 | } | 624 | } |
625 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); | 625 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); |
626 | } | 626 | } |
627 | 627 | ||
628 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 628 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
629 | { | 629 | { |
630 | bool needShow = FALSE; | 630 | bool needShow = FALSE; |
631 | if ( msg == "alarm(QDateTime,int)" ) { | 631 | if ( msg == "alarm(QDateTime,int)" ) { |
632 | QDataStream ds(data,IO_ReadOnly); | 632 | QDataStream ds(data,IO_ReadOnly); |
633 | QDateTime when; int warn; | 633 | QDateTime when; int warn; |
634 | ds >> when >> warn; | 634 | ds >> when >> warn; |
635 | 635 | ||
636 | // check to make it's okay to continue, | 636 | // check to make it's okay to continue, |
637 | // this is the case that the time was set ahead, and | 637 | // this is the case that the time was set ahead, and |
638 | // we are forced given a stale alarm... | 638 | // we are forced given a stale alarm... |
639 | QDateTime current = QDateTime::currentDateTime(); | 639 | QDateTime current = QDateTime::currentDateTime(); |
640 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) | 640 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) |
641 | return; | 641 | return; |
642 | 642 | ||
643 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 643 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
644 | if ( list.count() > 0 ) { | 644 | if ( list.count() > 0 ) { |
645 | QString msg; | 645 | QString msg; |
646 | bool bSound = FALSE; | 646 | bool bSound = FALSE; |
647 | int stopTimer = 0; | 647 | int stopTimer = 0; |
648 | bool found = FALSE; | 648 | bool found = FALSE; |
649 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { | 649 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { |
650 | if ( (*it).event().hasAlarm() ) { | 650 | if ( (*it).event().hasAlarm() ) { |
651 | found = TRUE; | 651 | found = TRUE; |
652 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 652 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
653 | + "<BR>" + (*it).location() + "<BR>" | 653 | + "<BR>" + (*it).location() + "<BR>" |
654 | + TimeString::dateString((*it).event().start(),ampm) | 654 | + TimeString::dateString((*it).event().start(),ampm) |
655 | + (warn | 655 | + (warn |
656 | ? tr(" (in " + QString::number(warn) | 656 | ? tr(" (in " + QString::number(warn) |
657 | + tr(" minutes)")) | 657 | + tr(" minutes)")) |
658 | : QString("")) | 658 | : QString("")) |
659 | + "<BR>" | 659 | + "<BR>" |
660 | + (*it).notes() + "</CENTER>"; | 660 | + (*it).notes() + "</CENTER>"; |
661 | if ( (*it).event().alarmSound() != Event::Silent ) { | 661 | if ( (*it).event().alarmSound() != Event::Silent ) { |
662 | bSound = TRUE; | 662 | bSound = TRUE; |
663 | } | 663 | } |
664 | } | 664 | } |
665 | } | 665 | } |
666 | if ( found ) { | 666 | if ( found ) { |
667 | if ( bSound ) { | 667 | if ( bSound ) { |
668 | Sound::soundAlarm(); | 668 | Sound::soundAlarm(); |
669 | alarmCounter = 0; | 669 | alarmCounter = 0; |
670 | stopTimer = startTimer( 5000 ); | 670 | stopTimer = startTimer( 5000 ); |
671 | } | 671 | } |
672 | QDialog dlg( this, 0, TRUE ); | 672 | QDialog dlg( this, 0, TRUE ); |
673 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 673 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
674 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 674 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
675 | view->setResizePolicy( QScrollView::AutoOneFit ); | 675 | view->setResizePolicy( QScrollView::AutoOneFit ); |
676 | vb->addWidget( view ); | 676 | vb->addWidget( view ); |
677 | QLabel *lblMsg = new QLabel( msg, &dlg ); | 677 | QLabel *lblMsg = new QLabel( msg, &dlg ); |
678 | view->addChild( lblMsg ); | 678 | view->addChild( lblMsg ); |
679 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); | 679 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); |
680 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); | 680 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); |
681 | vb->addWidget( cmdOk ); | 681 | vb->addWidget( cmdOk ); |
682 | 682 | ||
683 | needShow = QPEApplication::execDialog( &dlg ); | 683 | needShow = QPEApplication::execDialog( &dlg ); |
684 | 684 | ||
685 | if ( bSound ) | 685 | if ( bSound ) |
686 | killTimer( stopTimer ); | 686 | killTimer( stopTimer ); |
687 | } | 687 | } |
688 | } | 688 | } |
689 | } else if ( msg == "nextView()" ) { | 689 | } else if ( msg == "nextView()" ) { |
690 | needShow = true; | 690 | needShow = true; |
691 | if ( !qApp-> activeWindow ( )) { | 691 | if ( !qApp-> activeWindow ( )) { |
692 | needShow = TRUE; | 692 | needShow = TRUE; |
693 | } else { | 693 | } else { |
694 | QWidget* cur = views->visibleWidget(); | 694 | QWidget* cur = views->visibleWidget(); |
695 | if ( cur ) { | 695 | if ( cur ) { |
696 | if ( cur == dayView ) | 696 | if ( cur == dayView ) |
697 | viewWeek(); | 697 | viewWeek(); |
698 | else if ( cur == weekView ) | 698 | else if ( cur == weekView ) |
699 | viewWeekLst(); | 699 | viewWeekLst(); |
700 | else if ( cur == weekLstView ) | 700 | else if ( cur == weekLstView ) |
701 | viewMonth(); | 701 | viewMonth(); |
702 | else if ( cur == monthView ) | 702 | else if ( cur == monthView ) |
703 | viewDay(); | 703 | viewDay(); |
704 | needShow = TRUE; | 704 | needShow = TRUE; |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } else if (msg == "editEvent(int)") { | 707 | } else if (msg == "editEvent(int)") { |
708 | /* simple copy from receive */ | 708 | /* simple copy from receive */ |
709 | QDataStream stream(data,IO_ReadOnly); | 709 | QDataStream stream(data,IO_ReadOnly); |
710 | int uid; | 710 | int uid; |
711 | stream >> uid; | 711 | stream >> uid; |
712 | Event e=db->eventByUID(uid); | 712 | Event e=db->eventByUID(uid); |
713 | editEvent(e); | 713 | editEvent(e); |
714 | } else if (msg == "viewDefault(QDate)"){ | 714 | } else if (msg == "viewDefault(QDate)"){ |
715 | /* simple copy from receive */ | 715 | /* simple copy from receive */ |
716 | QDataStream stream(data,IO_ReadOnly); | 716 | QDataStream stream(data,IO_ReadOnly); |
717 | QDate day; | 717 | QDate day; |
718 | stream >> day; | 718 | stream >> day; |
719 | viewDefault(day); | 719 | viewDefault(day); |
720 | needShow = true; | 720 | needShow = true; |
721 | } | 721 | } |
722 | 722 | ||
723 | if ( needShow ) { | 723 | if ( needShow ) { |
724 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 724 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
725 | // showMaximized(); | 725 | // showMaximized(); |
726 | #else | 726 | #else |
727 | // show(); | 727 | // show(); |
728 | #endif | 728 | #endif |
729 | // raise(); | 729 | // raise(); |
730 | QPEApplication::setKeepRunning(); | 730 | QPEApplication::setKeepRunning(); |
731 | // setActiveWindow(); | 731 | // setActiveWindow(); |
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | void DateBook::reload() | 735 | void DateBook::reload() |
736 | { | 736 | { |
737 | db->reload(); | 737 | db->reload(); |
738 | if ( dayAction->isOn() ) viewDay(); | 738 | if ( dayAction->isOn() ) viewDay(); |
739 | else if ( weekAction->isOn() ) viewWeek(); | 739 | else if ( weekAction->isOn() ) viewWeek(); |
740 | else if ( monthAction->isOn() ) viewMonth(); | 740 | else if ( monthAction->isOn() ) viewMonth(); |
741 | syncing = FALSE; | 741 | syncing = FALSE; |
742 | } | 742 | } |
743 | 743 | ||
744 | void DateBook::flush() | 744 | void DateBook::flush() |
745 | { | 745 | { |
746 | syncing = TRUE; | 746 | syncing = TRUE; |
747 | db->save(); | 747 | db->save(); |
748 | } | 748 | } |
749 | 749 | ||
750 | void DateBook::timerEvent( QTimerEvent *e ) | 750 | void DateBook::timerEvent( QTimerEvent *e ) |
751 | { | 751 | { |
752 | if ( alarmCounter < 10 ) { | 752 | if ( alarmCounter < 10 ) { |
753 | alarmCounter++; | 753 | alarmCounter++; |
754 | Sound::soundAlarm(); | 754 | Sound::soundAlarm(); |
755 | } else { | 755 | } else { |
756 | killTimer( e->timerId() ); | 756 | killTimer( e->timerId() ); |
757 | } | 757 | } |
758 | } | 758 | } |
759 | 759 | ||
760 | void DateBook::changeClock( bool newClock ) | 760 | void DateBook::changeClock( bool newClock ) |
761 | { | 761 | { |
762 | ampm = newClock; | 762 | ampm = newClock; |
763 | // repaint the affected objects... | 763 | // repaint the affected objects... |
764 | if (dayView) dayView->redraw(); | 764 | if (dayView) dayView->redraw(); |
765 | if (weekView) weekView->redraw(); | 765 | if (weekView) weekView->redraw(); |
766 | if (weekLstView) weekLstView->redraw(); | 766 | if (weekLstView) weekLstView->redraw(); |
767 | } | 767 | } |
768 | 768 | ||
769 | void DateBook::changeWeek( bool m ) | 769 | void DateBook::changeWeek( bool m ) |
770 | { | 770 | { |
771 | /* no need to redraw, each widget catches. Do need to | 771 | /* no need to redraw, each widget catches. Do need to |
772 | store though for widgets we haven't made yet */ | 772 | store though for widgets we haven't made yet */ |
773 | onMonday = m; | 773 | onMonday = m; |
774 | } | 774 | } |
775 | 775 | ||
776 | void DateBook::slotToday() | 776 | void DateBook::slotToday() |
777 | { | 777 | { |
778 | // we need to view today using default view | 778 | // we need to view today using default view |
779 | view(defaultView,QDate::currentDate()); | 779 | view(defaultView,QDate::currentDate()); |
780 | } | 780 | } |
781 | 781 | ||
782 | void DateBook::closeEvent( QCloseEvent *e ) | 782 | void DateBook::closeEvent( QCloseEvent *e ) |
783 | { | 783 | { |
784 | if(syncing) { | 784 | if(syncing) { |
785 | /* no need to save, did that at flush */ | 785 | /* no need to save, did that at flush */ |
786 | e->accept(); | 786 | e->accept(); |
787 | return; | 787 | return; |
788 | } | 788 | } |
789 | 789 | ||
790 | // save settings will generate it's own error messages, no | 790 | // save settings will generate it's own error messages, no |
791 | // need to do checking ourselves. | 791 | // need to do checking ourselves. |
792 | saveSettings(); | 792 | saveSettings(); |
793 | if ( db->save() ) { | 793 | if ( db->save() ) { |
794 | e->accept(); | 794 | e->accept(); |
795 | } else { | 795 | } else { |
796 | if ( QMessageBox::critical( this, tr( "Out of space" ), | 796 | if ( QMessageBox::critical( this, tr( "Out of space" ), |
797 | tr("Calendar was unable to save\n" | 797 | tr("Calendar was unable to save\n" |
798 | "your changes.\n" | 798 | "your changes.\n" |
799 | "Free up some space and try again.\n" | 799 | "Free up some space and try again.\n" |
800 | "\nQuit anyway?"), | 800 | "\nQuit anyway?"), |
801 | QMessageBox::Yes|QMessageBox::Escape, | 801 | QMessageBox::Yes|QMessageBox::Escape, |
802 | QMessageBox::No|QMessageBox::Default ) | 802 | QMessageBox::No|QMessageBox::Default ) |
803 | != QMessageBox::No ) | 803 | != QMessageBox::No ) |
804 | e->accept(); | 804 | e->accept(); |
805 | else | 805 | else |
806 | e->ignore(); | 806 | e->ignore(); |
807 | } | 807 | } |
808 | } | 808 | } |
809 | 809 | ||
810 | // Entering directly from the "keyboard" | 810 | // Entering directly from the "keyboard" |
811 | void DateBook::slotNewEventFromKey( const QString &str ) | 811 | void DateBook::slotNewEventFromKey( const QString &str ) |
812 | { | 812 | { |
813 | if (syncing) { | 813 | if (syncing) { |
814 | QMessageBox::warning( this, tr("Calendar"), | 814 | QMessageBox::warning( this, tr("Calendar"), |
815 | tr( "Can not edit data, currently syncing") ); | 815 | tr( "Can not edit data, currently syncing") ); |
816 | return; | 816 | return; |
817 | } | 817 | } |
818 | 818 | ||
819 | // We get to here from a key pressed in the Day View | 819 | // We get to here from a key pressed in the Day View |
820 | // So we can assume some things. We want the string | 820 | // So we can assume some things. We want the string |
821 | // passed in to be part of the description. | 821 | // passed in to be part of the description. |
822 | QDateTime start, end; | 822 | QDateTime start, end; |
823 | if ( views->visibleWidget() == dayView ) { | 823 | if ( views->visibleWidget() == dayView ) { |
824 | dayView->selectedDates( start, end ); | 824 | dayView->selectedDates( start, end ); |
825 | } else if ( views->visibleWidget() == monthView ) { | 825 | } else if ( views->visibleWidget() == monthView ) { |
826 | QDate d = monthView->selectedDate(); | 826 | QDate d = monthView->selectedDate(); |
827 | start = end = d; | 827 | start = end = d; |
828 | start.setTime( QTime( 10, 0 ) ); | 828 | start.setTime( QTime( 10, 0 ) ); |
829 | end.setTime( QTime( 12, 0 ) ); | 829 | end.setTime( QTime( 12, 0 ) ); |
830 | } else if ( views->visibleWidget() == weekView ) { | 830 | } else if ( views->visibleWidget() == weekView ) { |
831 | QDate d = weekView->date(); | 831 | QDate d = weekView->date(); |
832 | start = end = d; | 832 | start = end = d; |
833 | start.setTime( QTime( 10, 0 ) ); | 833 | start.setTime( QTime( 10, 0 ) ); |
834 | end.setTime( QTime( 12, 0 ) ); | 834 | end.setTime( QTime( 12, 0 ) ); |
835 | } else if ( views->visibleWidget() == weekLstView ) { | 835 | } else if ( views->visibleWidget() == weekLstView ) { |
836 | QDate d = weekLstView->date(); | 836 | QDate d = weekLstView->date(); |
837 | start = end = d; | 837 | start = end = d; |
838 | start.setTime( QTime( 10, 0 ) ); | 838 | start.setTime( QTime( 10, 0 ) ); |
839 | end.setTime( QTime( 12, 0 ) ); | 839 | end.setTime( QTime( 12, 0 ) ); |
840 | } | 840 | } |
841 | slotNewEntry(start, end, str); | 841 | slotNewEntry(start, end, str); |
842 | } | 842 | } |
843 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { | 843 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { |
844 | // argh! This really needs to be encapsulated in a class | 844 | // argh! This really needs to be encapsulated in a class |
845 | // or function. | 845 | // or function. |
846 | QDialog newDlg( this, 0, TRUE ); | 846 | QDialog newDlg( this, 0, TRUE ); |
847 | newDlg.setCaption( DateEntryBase::tr("New Event") ); | 847 | newDlg.setCaption( DateEntryBase::tr("New Event") ); |
848 | DateEntry *e; | 848 | DateEntry *e; |
849 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); | 849 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); |
850 | QScrollView *sv = new QScrollView( &newDlg ); | 850 | QScrollView *sv = new QScrollView( &newDlg ); |
851 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 851 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
852 | sv->setFrameStyle( QFrame::NoFrame ); | 852 | sv->setFrameStyle( QFrame::NoFrame ); |
853 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 853 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
854 | vb->addWidget( sv ); | 854 | vb->addWidget( sv ); |
855 | 855 | ||
856 | Event ev; | 856 | Event ev; |
857 | ev.setDescription( str ); | 857 | ev.setDescription( str ); |
858 | // When the new gui comes in, change this... | 858 | // When the new gui comes in, change this... |
859 | if(location==0) { | 859 | if(location==0) { |
860 | if(defaultLocation.isEmpty()) { | 860 | if(defaultLocation.isEmpty()) { |
861 | ev.setLocation(tr("(Unknown)")); | 861 | ev.setLocation(tr("(Unknown)")); |
862 | } else { | 862 | } else { |
863 | ev.setLocation( defaultLocation ); | 863 | ev.setLocation( defaultLocation ); |
864 | } | 864 | } |
865 | } else { | 865 | } else { |
866 | ev.setLocation(location); | 866 | ev.setLocation(location); |
867 | } | 867 | } |
868 | ev.setCategories(defaultCategories); | 868 | ev.setCategories(defaultCategories); |
869 | ev.setStart( start ); | 869 | ev.setStart( start ); |
870 | ev.setEnd( end ); | 870 | ev.setEnd( end ); |
871 | 871 | ||
872 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); | 872 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); |
873 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); | 873 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); |
874 | sv->addChild( e ); | 874 | sv->addChild( e ); |
875 | while ( QPEApplication::execDialog( &newDlg ) ) { | 875 | while ( QPEApplication::execDialog( &newDlg ) ) { |
876 | ev = e->event(); | 876 | ev = e->event(); |
877 | ev.assignUid(); | 877 | ev.assignUid(); |
878 | QString error = checkEvent( ev ); | 878 | QString error = checkEvent( ev ); |
879 | if ( !error.isNull() ) { | 879 | if ( !error.isNull() ) { |
880 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) | 880 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) |
881 | continue; | 881 | continue; |
882 | } | 882 | } |
883 | db->addEvent( ev ); | 883 | db->addEvent( ev ); |
884 | emit newEvent(); | 884 | emit newEvent(); |
885 | break; | 885 | break; |
886 | } | 886 | } |
887 | } | 887 | } |
888 | 888 | ||
889 | void DateBook::setDocument( const QString &filename ) | 889 | void DateBook::setDocument( const QString &filename ) |
890 | { | 890 | { |
891 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 891 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
892 | 892 | ||
893 | QValueList<Event> tl = Event::readVCalendar( filename ); | 893 | QValueList<Event> tl = Event::readVCalendar( filename ); |
894 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 894 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
895 | db->addEvent( *it ); | 895 | db->addEvent( *it ); |
896 | } | 896 | } |
897 | } | 897 | } |
898 | 898 | ||
899 | static const char * beamfile = "/tmp/obex/event.vcs"; | 899 | static const char * beamfile = "/tmp/obex/event.vcs"; |
900 | 900 | ||
901 | void DateBook::beamEvent( const Event &e ) | 901 | void DateBook::beamEvent( const Event &e ) |
902 | { | 902 | { |
903 | qDebug("trying to beamn"); | 903 | qDebug("trying to beamn"); |
904 | unlink( beamfile ); // delete if exists | 904 | unlink( beamfile ); // delete if exists |
905 | mkdir("/tmp/obex/", 0755); | 905 | mkdir("/tmp/obex/", 0755); |
906 | Event::writeVCalendar( beamfile, e ); | 906 | Event::writeVCalendar( beamfile, e ); |
907 | Ir *ir = new Ir( this ); | 907 | Ir *ir = new Ir( this ); |
908 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 908 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
909 | QString description = e.description(); | 909 | QString description = e.description(); |
910 | ir->send( beamfile, description, "text/x-vCalendar" ); | 910 | ir->send( beamfile, description, "text/x-vCalendar" ); |
911 | } | 911 | } |
912 | 912 | ||
913 | void DateBook::beamDone( Ir *ir ) | 913 | void DateBook::beamDone( Ir *ir ) |
914 | { | 914 | { |
915 | delete ir; | 915 | delete ir; |
916 | unlink( beamfile ); | 916 | unlink( beamfile ); |
917 | } | 917 | } |
918 | 918 | ||
919 | void DateBook::slotFind() | 919 | void DateBook::slotFind() |
920 | { | 920 | { |
921 | // move it to the day view... | 921 | // move it to the day view... |
922 | viewDay(); | 922 | viewDay(); |
923 | FindDialog frmFind( "Calendar", this ); // no tr needed | 923 | FindDialog frmFind( "Calendar", this ); // no tr needed |
924 | frmFind.setUseDate( true ); | 924 | frmFind.setUseDate( true ); |
925 | frmFind.setDate( currentDate() ); | 925 | frmFind.setDate( currentDate() ); |
926 | QObject::connect( &frmFind, | 926 | QObject::connect( &frmFind, |
927 | SIGNAL(signalFindClicked(const QString&, const QDate&, | 927 | SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), |
928 | bool, bool, int)), | ||
929 | this, | 928 | this, |
930 | SLOT(slotDoFind(const QString&, const QDate&, | 929 | SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); |
931 | bool, bool, int)) ); | ||
932 | QObject::connect( this, | 930 | QObject::connect( this, |
933 | SIGNAL(signalNotFound()), | 931 | SIGNAL(signalNotFound()), |
934 | &frmFind, | 932 | &frmFind, |
935 | SLOT(slotNotFound()) ); | 933 | SLOT(slotNotFound()) ); |
936 | QObject::connect( this, | 934 | QObject::connect( this, |
937 | SIGNAL(signalWrapAround()), | 935 | SIGNAL(signalWrapAround()), |
938 | &frmFind, | 936 | &frmFind, |
939 | SLOT(slotWrapAround()) ); | 937 | SLOT(slotWrapAround()) ); |
940 | frmFind.move(0,0); | 938 | frmFind.move(0,0); |
941 | frmFind.exec(); | 939 | frmFind.exec(); |
942 | inSearch = false; | 940 | inSearch = false; |
943 | } | 941 | } |
944 | 942 | ||
945 | bool catComp( QArray<int> cats, int category ) | 943 | bool catComp( QArray<int> cats, int category ) |
946 | { | 944 | { |
947 | bool returnMe; | 945 | bool returnMe; |
948 | int i, | 946 | int i, |
949 | count; | 947 | count; |
950 | 948 | ||
951 | count = int(cats.count()); | 949 | count = int(cats.count()); |
952 | returnMe = false; | 950 | returnMe = false; |
953 | if ( (category == -1 && count == 0) || category == -2 ) | 951 | if ( (category == -1 && count == 0) || category == -2 ) |
954 | returnMe = true; | 952 | returnMe = true; |
955 | else { | 953 | else { |
956 | for ( i = 0; i < count; i++ ) { | 954 | for ( i = 0; i < count; i++ ) { |
957 | if ( category == cats[i] ) { | 955 | if ( category == cats[i] ) { |
958 | returnMe = true; | 956 | returnMe = true; |
959 | break; | 957 | break; |
960 | } | 958 | } |
961 | } | 959 | } |
962 | } | 960 | } |
963 | return returnMe; | 961 | return returnMe; |
964 | } | 962 | } |
965 | 963 | ||
966 | 964 | ||
967 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, | 965 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, |
968 | bool caseSensitive, bool /*backwards*/, | 966 | bool caseSensitive, bool /*backwards*/, |
969 | int category ) | 967 | int category ) |
970 | { | 968 | { |
971 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), | 969 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), |
972 | next; | 970 | next; |
973 | 971 | ||
974 | QRegExp r( txt ); | 972 | QRegExp r( txt ); |
975 | r.setCaseSensitive( caseSensitive ); | 973 | r.setCaseSensitive( caseSensitive ); |
976 | 974 | ||
977 | 975 | ||
978 | static Event rev, nonrev; | 976 | static Event rev, nonrev; |
979 | if ( !inSearch ) { | 977 | if ( !inSearch ) { |
980 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 978 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
981 | nonrev.setStart( rev.start() ); | 979 | nonrev.setStart( rev.start() ); |
982 | inSearch = true; | 980 | inSearch = true; |
983 | } | 981 | } |
984 | static QDate searchDate = dt; | 982 | static QDate searchDate = dt; |
985 | // if true at the end we will start at the begin again and afterwards | 983 | // if true at the end we will start at the begin again and afterwards |
986 | // we will emit string not found | 984 | // we will emit string not found |
987 | static bool wrapAround = true; | 985 | static bool wrapAround = true; |
988 | bool candidtate; | 986 | bool candidtate; |
989 | candidtate = false; | 987 | candidtate = false; |
990 | 988 | ||
991 | QValueList<Event> repeats = db->getRawRepeats(); | 989 | QValueList<Event> repeats = db->getRawRepeats(); |
992 | 990 | ||
993 | // find the candidate for the first repeat that matches... | 991 | // find the candidate for the first repeat that matches... |
994 | // first check if there can ever be a match and then compute | 992 | // first check if there can ever be a match and then compute |
995 | // the next occurence from start. See if this event is closer | 993 | // the next occurence from start. See if this event is closer |
996 | // to the beginning (start. next < dtEnd) and not smaller then the last | 994 | // to the beginning (start. next < dtEnd) and not smaller then the last |
997 | // result. If we find a canditate we set the dtEnd to the time | 995 | // result. If we find a canditate we set the dtEnd to the time |
998 | // of the ocurrence and rev to this occurence. | 996 | // of the ocurrence and rev to this occurence. |
999 | // set wrap around to true because there might be more events coming | 997 | // set wrap around to true because there might be more events coming |
1000 | // and we're not at the end. | 998 | // and we're not at the end. |
1001 | QValueListConstIterator<Event> it; | 999 | QValueListConstIterator<Event> it; |
1002 | QDate start = dt; | 1000 | QDate start = dt; |
1003 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { | 1001 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { |
1004 | if ( catComp( (*it).categories(), category ) ) { | 1002 | if ( catComp( (*it).categories(), category ) ) { |
1005 | if ( (*it).match( r ) ) { | 1003 | if ( (*it).match( r ) ) { |
1006 | if ( nextOccurance( *it, start, next ) ) { | 1004 | if ( nextOccurance( *it, start, next ) ) { |
1007 | if ( next < dtEnd && !(next <= rev.start() ) ) { | 1005 | if ( next < dtEnd && !(next <= rev.start() ) ) { |
1008 | rev = *it; | 1006 | rev = *it; |
1009 | dtEnd = next; | 1007 | dtEnd = next; |
1010 | rev.setStart( next ); | 1008 | rev.setStart( next ); |
1011 | candidtate = true; | 1009 | candidtate = true; |
1012 | wrapAround = true; | 1010 | wrapAround = true; |
1013 | } | 1011 | } |
1014 | } | 1012 | } |
1015 | } | 1013 | } |
1016 | } | 1014 | } |
1017 | } | 1015 | } |
1018 | 1016 | ||
1019 | // now the for first non repeat... | 1017 | // now the for first non repeat... |
1020 | // dtEnd is set by the previous iteration of repeatingEvents | 1018 | // dtEnd is set by the previous iteration of repeatingEvents |
1021 | // check if we find a closer item. Also set dtEnd to find even | 1019 | // check if we find a closer item. Also set dtEnd to find even |
1022 | // more close occurrence | 1020 | // more close occurrence |
1023 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); | 1021 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); |
1024 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); | 1022 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); |
1025 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { | 1023 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { |
1026 | if ( catComp( (*it).categories(), category ) ) { | 1024 | if ( catComp( (*it).categories(), category ) ) { |
1027 | if ( (*it).start() < dtEnd ) { | 1025 | if ( (*it).start() < dtEnd ) { |
1028 | if ( (*it).match( r ) && !(*it <= nonrev) ) { | 1026 | if ( (*it).match( r ) && !(*it <= nonrev) ) { |
1029 | nonrev = *it; | 1027 | nonrev = *it; |
1030 | dtEnd = nonrev.start(); | 1028 | dtEnd = nonrev.start(); |
1031 | candidtate = true; | 1029 | candidtate = true; |
1032 | wrapAround = true; | 1030 | wrapAround = true; |
1033 | break; | 1031 | break; |
1034 | } | 1032 | } |
1035 | } | 1033 | } |
1036 | } | 1034 | } |
1037 | } | 1035 | } |
1038 | if ( candidtate ) { | 1036 | if ( candidtate ) { |
1039 | dayView->setStartViewTime( dtEnd.time().hour() ); | 1037 | dayView->setStartViewTime( dtEnd.time().hour() ); |
1040 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), | 1038 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), |
1041 | dtEnd.date().day() ); | 1039 | dtEnd.date().day() ); |
1042 | } else { | 1040 | } else { |
1043 | if ( wrapAround ) { | 1041 | if ( wrapAround ) { |
1044 | emit signalWrapAround(); | 1042 | emit signalWrapAround(); |
1045 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 1043 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
1046 | nonrev.setStart( rev.start() ); | 1044 | nonrev.setStart( rev.start() ); |
1047 | } else | 1045 | } else |
1048 | emit signalNotFound(); | 1046 | emit signalNotFound(); |
1049 | wrapAround = !wrapAround; | 1047 | wrapAround = !wrapAround; |
1050 | } | 1048 | } |
1051 | } | 1049 | } |
1052 | 1050 | ||
1053 | Event DateBookDBHack::eventByUID(int uid) { | 1051 | Event DateBookDBHack::eventByUID(int uid) { |
1054 | 1052 | ||
1055 | // FIXME: Dirty Hacks to get hold of the private event lists | 1053 | // FIXME: Dirty Hacks to get hold of the private event lists |
1056 | QDate start; | 1054 | QDate start; |
1057 | QDate end=start.addDays(-1); | 1055 | QDate end=start.addDays(-1); |
1058 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); | 1056 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); |
1059 | QValueList<Event> myRepeatEvents=getRawRepeats(); | 1057 | QValueList<Event> myRepeatEvents=getRawRepeats(); |
1060 | 1058 | ||
1061 | QValueList<Event>::ConstIterator it; | 1059 | QValueList<Event>::ConstIterator it; |
1062 | 1060 | ||
1063 | for (it = myEventList.begin(); it != myEventList.end(); it++) { | 1061 | for (it = myEventList.begin(); it != myEventList.end(); it++) { |
1064 | if ((*it).uid() == uid) return *it; | 1062 | if ((*it).uid() == uid) return *it; |
1065 | } | 1063 | } |
1066 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { | 1064 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { |
1067 | if ((*it).uid() == uid) return *it; | 1065 | if ((*it).uid() == uid) return *it; |
1068 | } | 1066 | } |
1069 | 1067 | ||
1070 | Event ev; | 1068 | Event ev; |
1071 | return ev; // return at least | 1069 | return ev; // return at least |
1072 | } | 1070 | } |
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 751a1da..ca63dc5 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -19,553 +19,553 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "datebookday.h" | 21 | #include "datebookday.h" |
22 | #include "datebookdayheaderimpl.h" | 22 | #include "datebookdayheaderimpl.h" |
23 | #include "datebookdayallday.h" | 23 | #include "datebookdayallday.h" |
24 | 24 | ||
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/ir.h> | 27 | #include <qpe/ir.h> |
28 | 28 | ||
29 | #include <qsimplerichtext.h> | 29 | #include <qsimplerichtext.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | 31 | ||
32 | 32 | ||
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | 34 | ||
35 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) | 35 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) |
36 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) | 36 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) |
37 | { | 37 | { |
38 | enableClipper(TRUE); | 38 | enableClipper(TRUE); |
39 | setTopMargin( 0 ); | 39 | setTopMargin( 0 ); |
40 | horizontalHeader()->hide(); | 40 | horizontalHeader()->hide(); |
41 | setLeftMargin(38); | 41 | setLeftMargin(38); |
42 | setColumnStretchable( 0, TRUE ); | 42 | setColumnStretchable( 0, TRUE ); |
43 | setHScrollBarMode( QScrollView::AlwaysOff ); | 43 | setHScrollBarMode( QScrollView::AlwaysOff ); |
44 | verticalHeader()->setPalette(white); | 44 | verticalHeader()->setPalette(white); |
45 | verticalHeader()->setResizeEnabled(FALSE); | 45 | verticalHeader()->setResizeEnabled(FALSE); |
46 | setSelectionMode( Single ); | 46 | setSelectionMode( Single ); |
47 | 47 | ||
48 | // get rid of being able to edit things... | 48 | // get rid of being able to edit things... |
49 | QTableItem *tmp; | 49 | QTableItem *tmp; |
50 | int row; | 50 | int row; |
51 | for ( row = 0; row < numRows(); row++ ) { | 51 | for ( row = 0; row < numRows(); row++ ) { |
52 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 52 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
53 | setItem( row, 0, tmp ); | 53 | setItem( row, 0, tmp ); |
54 | //setRowHeight( row, 40); | 54 | //setRowHeight( row, 40); |
55 | } | 55 | } |
56 | 56 | ||
57 | initHeader(); | 57 | initHeader(); |
58 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); | 58 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); |
59 | } | 59 | } |
60 | 60 | ||
61 | void DateBookDayView::initHeader() | 61 | void DateBookDayView::initHeader() |
62 | { | 62 | { |
63 | QString strTmp; | 63 | QString strTmp; |
64 | int preferredWidth = 0; | 64 | int preferredWidth = 0; |
65 | for ( int i = 0; i < 24; ++i ) { | 65 | for ( int i = 0; i < 24; ++i ) { |
66 | if ( ampm ) { | 66 | if ( ampm ) { |
67 | if ( i == 0 ) | 67 | if ( i == 0 ) |
68 | strTmp = QString::number(12) + ":00"; | 68 | strTmp = QString::number(12) + ":00"; |
69 | else if ( i == 12 ) | 69 | else if ( i == 12 ) |
70 | strTmp = QString::number(12) + tr(":00p"); | 70 | strTmp = QString::number(12) + tr(":00p"); |
71 | else if ( i > 12 ) | 71 | else if ( i > 12 ) |
72 | strTmp = QString::number( i - 12 ) + tr(":00p"); | 72 | strTmp = QString::number( i - 12 ) + tr(":00p"); |
73 | else | 73 | else |
74 | strTmp = QString::number(i) + ":00"; | 74 | strTmp = QString::number(i) + ":00"; |
75 | } else { | 75 | } else { |
76 | if ( i < 10 ) | 76 | if ( i < 10 ) |
77 | strTmp = "0" + QString::number(i) + ":00"; | 77 | strTmp = "0" + QString::number(i) + ":00"; |
78 | else | 78 | else |
79 | strTmp = QString::number(i) + ":00"; | 79 | strTmp = QString::number(i) + ":00"; |
80 | } | 80 | } |
81 | strTmp = strTmp.rightJustify( 6, ' ' ); | 81 | strTmp = strTmp.rightJustify( 6, ' ' ); |
82 | verticalHeader()->setLabel( i, strTmp ); | 82 | verticalHeader()->setLabel( i, strTmp ); |
83 | 83 | ||
84 | // Compute correct width for current Font (Add some space right) | 84 | // Compute correct width for current Font (Add some space right) |
85 | int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); | 85 | int actWidth = QFontMetrics( QFont::defaultFont() ).width( strTmp + QString(" ") ); |
86 | if ( preferredWidth < actWidth ) | 86 | if ( preferredWidth < actWidth ) |
87 | preferredWidth = actWidth; | 87 | preferredWidth = actWidth; |
88 | setRowStretchable( i, FALSE ); | 88 | setRowStretchable( i, FALSE ); |
89 | } | 89 | } |
90 | 90 | ||
91 | // It seems as if the header has a bug. It does not resize | 91 | // It seems as if the header has a bug. It does not resize |
92 | // correct horizontally if it is used vertical.. | 92 | // correct horizontally if it is used vertical.. |
93 | // Thus, we do it manually.. | 93 | // Thus, we do it manually.. |
94 | setLeftMargin( preferredWidth ); | 94 | setLeftMargin( preferredWidth ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void DateBookDayView::slotDateChanged( int y, int m, int d ) | 97 | void DateBookDayView::slotDateChanged( int y, int m, int d ) |
98 | { | 98 | { |
99 | currDate.setYMD(y,m,d); | 99 | currDate.setYMD(y,m,d); |
100 | } | 100 | } |
101 | 101 | ||
102 | void DateBookDayView::slotChangeClock( bool newClock ) | 102 | void DateBookDayView::slotChangeClock( bool newClock ) |
103 | { | 103 | { |
104 | ampm = newClock; | 104 | ampm = newClock; |
105 | initHeader(); | 105 | initHeader(); |
106 | } | 106 | } |
107 | 107 | ||
108 | bool DateBookDayView::whichClock() const | 108 | bool DateBookDayView::whichClock() const |
109 | { | 109 | { |
110 | return ampm; | 110 | return ampm; |
111 | } | 111 | } |
112 | 112 | ||
113 | void DateBookDayView::moveUp() | 113 | void DateBookDayView::moveUp() |
114 | { | 114 | { |
115 | scrollBy(0, -20); | 115 | scrollBy(0, -20); |
116 | } | 116 | } |
117 | 117 | ||
118 | void DateBookDayView::moveDown() | 118 | void DateBookDayView::moveDown() |
119 | { | 119 | { |
120 | scrollBy(0, 20); | 120 | scrollBy(0, 20); |
121 | } | 121 | } |
122 | 122 | ||
123 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | 123 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) |
124 | { | 124 | { |
125 | int w = cr.width(); | 125 | int w = cr.width(); |
126 | int h = cr.height(); | 126 | int h = cr.height(); |
127 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); | 127 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); |
128 | if ( showGrid() ) { | 128 | if ( showGrid() ) { |
129 | // Draw our lines | 129 | // Draw our lines |
130 | int x2 = w - 1; | 130 | int x2 = w - 1; |
131 | int y2 = h - 1; | 131 | int y2 = h - 1; |
132 | QPen pen( p->pen() ); | 132 | QPen pen( p->pen() ); |
133 | p->setPen( colorGroup().dark() ); | 133 | p->setPen( colorGroup().dark() ); |
134 | p->drawLine( x2, 0, x2, y2 ); | 134 | p->drawLine( x2, 0, x2, y2 ); |
135 | p->drawLine( 0, y2, x2, y2 ); | 135 | p->drawLine( 0, y2, x2, y2 ); |
136 | 136 | ||
137 | p->setPen( colorGroup().midlight() ); | 137 | p->setPen( colorGroup().midlight() ); |
138 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | 138 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); |
139 | 139 | ||
140 | p->setPen( pen ); | 140 | p->setPen( pen ); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 144 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
145 | { | 145 | { |
146 | } | 146 | } |
147 | 147 | ||
148 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 148 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
149 | { | 149 | { |
150 | QTable::resizeEvent( e ); | 150 | QTable::resizeEvent( e ); |
151 | columnWidthChanged( 0 ); | 151 | columnWidthChanged( 0 ); |
152 | emit sigColWidthChanged(); | 152 | emit sigColWidthChanged(); |
153 | } | 153 | } |
154 | 154 | ||
155 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) | 155 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) |
156 | { | 156 | { |
157 | QString txt = e->text(); | 157 | QString txt = e->text(); |
158 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { | 158 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { |
159 | // we this is some sort of thing we know about... | 159 | // we this is some sort of thing we know about... |
160 | e->accept(); | 160 | e->accept(); |
161 | emit sigCapturedKey( txt ); | 161 | emit sigCapturedKey( txt ); |
162 | } else { | 162 | } else { |
163 | // I don't know what this key is, do you? | 163 | // I don't know what this key is, do you? |
164 | e->ignore(); | 164 | e->ignore(); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | void DateBookDayView::setRowStyle( int style ) | 168 | void DateBookDayView::setRowStyle( int style ) |
169 | { | 169 | { |
170 | if (style<0) style = 0; | 170 | if (style<0) style = 0; |
171 | 171 | ||
172 | for (int i=0; i<numRows(); i++) | 172 | for (int i=0; i<numRows(); i++) |
173 | setRowHeight(i, style*10+20); | 173 | setRowHeight(i, style*10+20); |
174 | } | 174 | } |
175 | 175 | ||
176 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) | 176 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) |
177 | { | 177 | { |
178 | int sh=99,eh=-1; | 178 | int sh=99,eh=-1; |
179 | 179 | ||
180 | for(int i=0;i<this->numSelections();i++) { | 180 | for(int i=0;i<this->numSelections();i++) { |
181 | QTableSelection sel = this->selection( i ); | 181 | QTableSelection sel = this->selection( i ); |
182 | sh = QMIN(sh,sel.topRow()); | 182 | sh = QMIN(sh,sel.topRow()); |
183 | eh = QMAX(sh,sel.bottomRow()+1); | 183 | eh = QMAX(sh,sel.bottomRow()+1); |
184 | } | 184 | } |
185 | if (sh > 23 || eh < 1) { | 185 | if (sh > 23 || eh < 1) { |
186 | sh=8; | 186 | sh=8; |
187 | eh=9; | 187 | eh=9; |
188 | } | 188 | } |
189 | 189 | ||
190 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); | 190 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); |
191 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | 191 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); |
192 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); | 192 | this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); |
193 | quickLineEdit->setFocus(); | 193 | quickLineEdit->setFocus(); |
194 | quickLineEdit->show(); | 194 | quickLineEdit->show(); |
195 | } | 195 | } |
196 | 196 | ||
197 | //=========================================================================== | 197 | //=========================================================================== |
198 | 198 | ||
199 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) | 199 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) |
200 | { | 200 | { |
201 | active=1; | 201 | active=1; |
202 | quickEvent.setStart(start); | 202 | quickEvent.setStart(start); |
203 | quickEvent.setEnd(end); | 203 | quickEvent.setEnd(end); |
204 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); | 204 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
205 | } | 205 | } |
206 | 206 | ||
207 | void DateBookDayViewQuickLineEdit::slotReturnPressed() | 207 | void DateBookDayViewQuickLineEdit::slotReturnPressed() |
208 | { | 208 | { |
209 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. | 209 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. |
210 | quickEvent.setDescription(this->text()); | 210 | quickEvent.setDescription(this->text()); |
211 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); | 211 | connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&))); |
212 | emit(insertEvent(quickEvent)); | 212 | emit(insertEvent(quickEvent)); |
213 | active=0; | 213 | active=0; |
214 | } | 214 | } |
215 | /* we need to return to this object.. */ | 215 | /* we need to return to this object.. */ |
216 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget | 216 | QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget |
217 | } | 217 | } |
218 | void DateBookDayViewQuickLineEdit::finallyCallClose() { | 218 | void DateBookDayViewQuickLineEdit::finallyCallClose() { |
219 | close(true); // also deletes this widget... | 219 | close(true); // also deletes this widget... |
220 | } | 220 | } |
221 | 221 | ||
222 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) | 222 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) |
223 | { | 223 | { |
224 | slotReturnPressed(); // Reuse code to add event and close this widget. | 224 | slotReturnPressed(); // Reuse code to add event and close this widget. |
225 | } | 225 | } |
226 | 226 | ||
227 | //=========================================================================== | 227 | //=========================================================================== |
228 | 228 | ||
229 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) | 229 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) |
230 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | 230 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) |
231 | { | 231 | { |
232 | widgetList.setAutoDelete( true ); | 232 | widgetList.setAutoDelete( true ); |
233 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 233 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); |
234 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 234 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); |
235 | 235 | ||
236 | m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); | 236 | m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); |
237 | m_allDays->hide(); | 237 | m_allDays->hide(); |
238 | 238 | ||
239 | view = new DateBookDayView( ampm, this, "day view" ); | 239 | view = new DateBookDayView( ampm, this, "day view" ); |
240 | 240 | ||
241 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); | 241 | connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) ); |
242 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); | 242 | connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) ); |
243 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); | 243 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); |
244 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 244 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
245 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); | 245 | connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) ); |
246 | 246 | ||
247 | QTimer *timer = new QTimer( this ); | 247 | QTimer *timer = new QTimer( this ); |
248 | 248 | ||
249 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | 249 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors |
250 | timer->start( 1000*60*5, FALSE ); //update every 5min | 250 | timer->start( 1000*60*5, FALSE ); //update every 5min |
251 | 251 | ||
252 | selectedWidget = 0; | 252 | selectedWidget = 0; |
253 | 253 | ||
254 | timeMarker = new DateBookDayTimeMarker( this ); | 254 | timeMarker = new DateBookDayTimeMarker( this ); |
255 | timeMarker->setTime( QTime::currentTime() ); | 255 | timeMarker->setTime( QTime::currentTime() ); |
256 | rowStyle = -1; // initialize with bogus values | 256 | rowStyle = -1; // initialize with bogus values |
257 | jumpToCurTime = false; | 257 | jumpToCurTime = false; |
258 | } | 258 | } |
259 | 259 | ||
260 | void DateBookDay::setJumpToCurTime( bool bJump ) | 260 | void DateBookDay::setJumpToCurTime( bool bJump ) |
261 | { | 261 | { |
262 | jumpToCurTime = bJump; | 262 | jumpToCurTime = bJump; |
263 | } | 263 | } |
264 | 264 | ||
265 | void DateBookDay::setRowStyle( int style ) | 265 | void DateBookDay::setRowStyle( int style ) |
266 | { | 266 | { |
267 | if (rowStyle != style) view->setRowStyle( style ); | 267 | if (rowStyle != style) view->setRowStyle( style ); |
268 | rowStyle = style; | 268 | rowStyle = style; |
269 | } | 269 | } |
270 | 270 | ||
271 | void DateBookDay::updateView( void ) | 271 | void DateBookDay::updateView( void ) |
272 | { | 272 | { |
273 | timeMarker->setTime( QTime::currentTime() ); | 273 | timeMarker->setTime( QTime::currentTime() ); |
274 | //need to find a way to update all DateBookDayWidgets | 274 | //need to find a way to update all DateBookDayWidgets |
275 | } | 275 | } |
276 | 276 | ||
277 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) | 277 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) |
278 | { | 278 | { |
279 | selectedWidget = w; | 279 | selectedWidget = w; |
280 | } | 280 | } |
281 | 281 | ||
282 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) | 282 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) |
283 | { | 283 | { |
284 | return selectedWidget; | 284 | return selectedWidget; |
285 | } | 285 | } |
286 | 286 | ||
287 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | 287 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) |
288 | { | 288 | { |
289 | start.setDate( currDate ); | 289 | start.setDate( currDate ); |
290 | end.setDate( currDate ); | 290 | end.setDate( currDate ); |
291 | 291 | ||
292 | int sh=99,eh=-1; | 292 | int sh=99,eh=-1; |
293 | 293 | ||
294 | int n = dayView()->numSelections(); | 294 | int n = dayView()->numSelections(); |
295 | 295 | ||
296 | for (int i=0; i<n; i++) { | 296 | for (int i=0; i<n; i++) { |
297 | QTableSelection sel = dayView()->selection( i ); | 297 | QTableSelection sel = dayView()->selection( i ); |
298 | sh = QMIN(sh,sel.topRow()); | 298 | sh = QMIN(sh,sel.topRow()); |
299 | eh = QMAX(sh,sel.bottomRow()+1); | 299 | eh = QMAX(sh,sel.bottomRow()+1); |
300 | } | 300 | } |
301 | 301 | ||
302 | if (sh > 23 || eh < 1) { | 302 | if (sh > 23 || eh < 1) { |
303 | sh=8; | 303 | sh=8; |
304 | eh=9; | 304 | eh=9; |
305 | } | 305 | } |
306 | 306 | ||
307 | start.setTime( QTime( sh, 0, 0 ) ); | 307 | start.setTime( QTime( sh, 0, 0 ) ); |
308 | end.setTime( QTime( eh, 0, 0 ) ); | 308 | end.setTime( QTime( eh, 0, 0 ) ); |
309 | } | 309 | } |
310 | 310 | ||
311 | void DateBookDay::setDate( int y, int m, int d ) | 311 | void DateBookDay::setDate( int y, int m, int d ) |
312 | { | 312 | { |
313 | header->setDate( y, m, d ); | 313 | header->setDate( y, m, d ); |
314 | selectedWidget = 0; | 314 | selectedWidget = 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | void DateBookDay::setDate( QDate d) | 317 | void DateBookDay::setDate( QDate d) |
318 | { | 318 | { |
319 | header->setDate( d.year(), d.month(), d.day() ); | 319 | header->setDate( d.year(), d.month(), d.day() ); |
320 | selectedWidget = 0; | 320 | selectedWidget = 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | void DateBookDay::dateChanged( int y, int m, int d ) | 323 | void DateBookDay::dateChanged( int y, int m, int d ) |
324 | { | 324 | { |
325 | QDate date( y, m, d ); | 325 | QDate date( y, m, d ); |
326 | if ( currDate == date ) | 326 | if ( currDate == date ) |
327 | return; | 327 | return; |
328 | currDate.setYMD( y, m, d ); | 328 | currDate.setYMD( y, m, d ); |
329 | relayoutPage(); | 329 | relayoutPage(); |
330 | dayView()->clearSelection(); | 330 | dayView()->clearSelection(); |
331 | QTableSelection ts; | 331 | QTableSelection ts; |
332 | 332 | ||
333 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 333 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
334 | { | 334 | { |
335 | ts.init( QTime::currentTime().hour(), 0); | 335 | ts.init( QTime::currentTime().hour(), 0); |
336 | ts.expandTo( QTime::currentTime().hour(), 0); | 336 | ts.expandTo( QTime::currentTime().hour(), 0); |
337 | } else { | 337 | } else { |
338 | ts.init( startTime, 0 ); | 338 | ts.init( startTime, 0 ); |
339 | ts.expandTo( startTime, 0 ); | 339 | ts.expandTo( startTime, 0 ); |
340 | } | 340 | } |
341 | 341 | ||
342 | dayView()->addSelection( ts ); | 342 | dayView()->addSelection( ts ); |
343 | selectedWidget = 0; | 343 | selectedWidget = 0; |
344 | } | 344 | } |
345 | 345 | ||
346 | void DateBookDay::redraw() | 346 | void DateBookDay::redraw() |
347 | { | 347 | { |
348 | if ( isUpdatesEnabled() ) | 348 | if ( isUpdatesEnabled() ) |
349 | relayoutPage(); | 349 | relayoutPage(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void DateBookDay::getEvents() | 352 | void DateBookDay::getEvents() |
353 | { | 353 | { |
354 | widgetList.clear(); | 354 | widgetList.clear(); |
355 | 355 | ||
356 | /* clear the AllDay List */ | 356 | /* clear the AllDay List */ |
357 | m_allDays->hide(); // just in case | 357 | m_allDays->hide(); // just in case |
358 | m_allDays->removeAllEvents(); | 358 | m_allDays->removeAllEvents(); |
359 | 359 | ||
360 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | 360 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); |
361 | QValueListIterator<EffectiveEvent> it; | 361 | QValueListIterator<EffectiveEvent> it; |
362 | QObject* object = 0; | 362 | QObject* object = 0; |
363 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | 363 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { |
364 | EffectiveEvent ev=*it; | 364 | EffectiveEvent ev=*it; |
365 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. | 365 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. |
366 | if (ev.event().type() == Event::AllDay ) { | 366 | if (ev.event().type() == Event::AllDay ) { |
367 | object = m_allDays->addEvent( ev ); | 367 | object = m_allDays->addEvent( ev ); |
368 | if (!object) | 368 | if (!object) |
369 | continue; | 369 | continue; |
370 | }else { | 370 | }else { |
371 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); | 371 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); |
372 | widgetList.append( w ); | 372 | widgetList.append( w ); |
373 | object = w; | 373 | object = w; |
374 | } | 374 | } |
375 | 375 | ||
376 | connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); | 376 | connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) ); |
377 | connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); | 377 | connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) ); |
378 | connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); | 378 | connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) ); |
379 | connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); | 379 | connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) ); |
380 | 380 | ||
381 | } | 381 | } |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 385 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
386 | { | 386 | { |
387 | int place = 0; | 387 | int place = 0; |
388 | int start = item->event().start().hour(); | 388 | int start = item->event().start().hour(); |
389 | QTime e = item->event().end(); | 389 | QTime e = item->event().end(); |
390 | int end = e.hour(); | 390 | int end = e.hour(); |
391 | if ( e.minute() < 5 ) | 391 | if ( e.minute() < 5 ) |
392 | end--; | 392 | end--; |
393 | if ( end < start ) | 393 | if ( end < start ) |
394 | end = start; | 394 | end = start; |
395 | while ( place < maxn ) { | 395 | while ( place < maxn ) { |
396 | bool free = TRUE; | 396 | bool free = TRUE; |
397 | int s = start; | 397 | int s = start; |
398 | while( s <= end ) { | 398 | while( s <= end ) { |
399 | if ( used[10*s+place] ) { | 399 | if ( used[10*s+place] ) { |
400 | free = FALSE; | 400 | free = FALSE; |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | s++; | 403 | s++; |
404 | } | 404 | } |
405 | if ( free ) | 405 | if ( free ) |
406 | break; | 406 | break; |
407 | place++; | 407 | place++; |
408 | } | 408 | } |
409 | if ( place == maxn ) { | 409 | if ( place == maxn ) { |
410 | return -1; | 410 | return -1; |
411 | } | 411 | } |
412 | while( start <= end ) { | 412 | while( start <= end ) { |
413 | used[10*start+place] = TRUE; | 413 | used[10*start+place] = TRUE; |
414 | start++; | 414 | start++; |
415 | } | 415 | } |
416 | return place; | 416 | return place; |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void DateBookDay::relayoutPage( bool fromResize ) | 420 | void DateBookDay::relayoutPage( bool fromResize ) |
421 | { | 421 | { |
422 | setUpdatesEnabled( FALSE ); | 422 | setUpdatesEnabled( FALSE ); |
423 | if ( !fromResize ) { | 423 | if ( !fromResize ) { |
424 | getEvents(); // no need we already have them! | 424 | getEvents(); // no need we already have them! |
425 | 425 | ||
426 | if (m_allDays->items() > 0 ) | 426 | if (m_allDays->items() > 0 ) |
427 | m_allDays->show(); | 427 | m_allDays->show(); |
428 | /* | 428 | /* |
429 | * else if ( m_allDays->items() == 0 ) already hide in getEvents | 429 | * else if ( m_allDays->items() == 0 ) already hide in getEvents |
430 | */ | 430 | */ |
431 | } | 431 | } |
432 | 432 | ||
433 | widgetList.sort(); | 433 | widgetList.sort(); |
434 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning | 434 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning |
435 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view | 435 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view |
436 | 436 | ||
437 | int wCount = widgetList.count(); | 437 | int wCount = widgetList.count(); |
438 | int wid = view->columnWidth(0)-1; | 438 | int wid = view->columnWidth(0)-1; |
439 | int wd; | 439 | int wd; |
440 | int n = 1; | 440 | int n = 1; |
441 | 441 | ||
442 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget | 442 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget |
443 | 443 | ||
444 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); | 444 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); |
445 | 445 | ||
446 | if ( wCount < 20 ) { | 446 | if ( wCount < 20 ) { |
447 | 447 | ||
448 | QArray<QRect> geometries(wCount); | 448 | QArray<QRect> geometries(wCount); |
449 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | 449 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector |
450 | 450 | ||
451 | for ( int i = 0; i < wCount; i++) { | 451 | for ( int i = 0; i < wCount; i++) { |
452 | QValueList<int> intersectedWidgets; | 452 | QValueList<int> intersectedWidgets; |
453 | 453 | ||
454 | //find all widgets intersecting with widgetList.at(i) | 454 | //find all widgets intersecting with widgetList.at(i) |
455 | for ( int j = 0; j < wCount; j++) { | 455 | for ( int j = 0; j < wCount; j++) { |
456 | if (i != j) | 456 | if (i != j) |
457 | if (geometries[j].intersects(geometries[i])) | 457 | if (geometries[j].intersects(geometries[i])) |
458 | intersectedWidgets.append(j); | 458 | intersectedWidgets.append(j); |
459 | } | 459 | } |
460 | 460 | ||
461 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 461 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
462 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 462 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
463 | { | 463 | { |
464 | QArray<int> inter(wCount); | 464 | QArray<int> inter(wCount); |
465 | inter[j]=1; | 465 | inter[j]=1; |
466 | 466 | ||
467 | if (intersectedWidgets[j] != -1) | 467 | if (intersectedWidgets[j] != -1) |
468 | for ( uint k = j; k < intersectedWidgets.count(); k++) { | 468 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
469 | if (j != k && intersectedWidgets[k] != -1) | 469 | if (j != k && intersectedWidgets[k] != -1) |
470 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { | 470 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
471 | inter[j]++; | 471 | inter[j]++; |
472 | intersectedWidgets[k] = -1; | 472 | intersectedWidgets[k] = -1; |
473 | } | 473 | } |
474 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 474 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
475 | } | 475 | } |
476 | } | 476 | } |
477 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 477 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
481 | for ( int i = 0; i < wCount; i++) { | 481 | for ( int i = 0; i < wCount; i++) { |
482 | DateBookDayWidget *w = widgetList.at(i); | 482 | DateBookDayWidget *w = widgetList.at(i); |
483 | QRect geom = w->geometry(); | 483 | QRect geom = w->geometry(); |
484 | geom.setX( 0 ); | 484 | geom.setX( 0 ); |
485 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 485 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
486 | geom.setWidth( wd ); | 486 | geom.setWidth( wd ); |
487 | while ( intersects( w, geom ) ) { | 487 | while ( intersects( w, geom ) ) { |
488 | geom.moveBy( wd + 2 + 1, 0 ); | 488 | geom.moveBy( wd + 2 + 1, 0 ); |
489 | } | 489 | } |
490 | w->setGeometry( geom ); | 490 | w->setGeometry( geom ); |
491 | } | 491 | } |
492 | 492 | ||
493 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 493 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
494 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 494 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
495 | } else { | 495 | } else { |
496 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 496 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
497 | } | 497 | } |
498 | } else { | 498 | } else { |
499 | int hours[24]; | 499 | int hours[24]; |
500 | memset( hours, 0, 24*sizeof( int ) ); | 500 | memset( hours, 0, 24*sizeof( int ) ); |
501 | bool overFlow = FALSE; | 501 | bool overFlow = FALSE; |
502 | for ( int i = 0; i < wCount; i++ ) { | 502 | for ( int i = 0; i < wCount; i++ ) { |
503 | DateBookDayWidget *w = widgetList.at(i); | 503 | DateBookDayWidget *w = widgetList.at(i); |
504 | int start = w->event().start().hour(); | 504 | int start = w->event().start().hour(); |
505 | QTime e = w->event().end(); | 505 | QTime e = w->event().end(); |
506 | int end = e.hour(); | 506 | int end = e.hour(); |
507 | if ( e.minute() < 5 ) | 507 | if ( e.minute() < 5 ) |
508 | end--; | 508 | end--; |
509 | if ( end < start ) | 509 | if ( end < start ) |
510 | end = start; | 510 | end = start; |
511 | while( start <= end ) { | 511 | while( start <= end ) { |
512 | hours[start]++; | 512 | hours[start]++; |
513 | if ( hours[start] >= 10 ) | 513 | if ( hours[start] >= 10 ) |
514 | overFlow = TRUE; | 514 | overFlow = TRUE; |
515 | ++start; | 515 | ++start; |
516 | } | 516 | } |
517 | if ( overFlow ) | 517 | if ( overFlow ) |
518 | break; | 518 | break; |
519 | } | 519 | } |
520 | for ( int i = 0; i < 24; i++ ) { | 520 | for ( int i = 0; i < 24; i++ ) { |
521 | n = QMAX( n, hours[i] ); | 521 | n = QMAX( n, hours[i] ); |
522 | } | 522 | } |
523 | wid = ( view->columnWidth(0)-1 ) / n; | 523 | wid = ( view->columnWidth(0)-1 ) / n; |
524 | 524 | ||
525 | bool used[24*10]; | 525 | bool used[24*10]; |
526 | memset( used, FALSE, 24*10*sizeof( bool ) ); | 526 | memset( used, FALSE, 24*10*sizeof( bool ) ); |
527 | 527 | ||
528 | for ( int i = 0; i < wCount; i++ ) { | 528 | for ( int i = 0; i < wCount; i++ ) { |
529 | DateBookDayWidget *w = widgetList.at(i); | 529 | DateBookDayWidget *w = widgetList.at(i); |
530 | int xp = place( w, used, n ); | 530 | int xp = place( w, used, n ); |
531 | if ( xp != -1 ) { | 531 | if ( xp != -1 ) { |
532 | QRect geom = w->geometry(); | 532 | QRect geom = w->geometry(); |
533 | geom.setX( xp*(wid+2) ); | 533 | geom.setX( xp*(wid+2) ); |
534 | geom.setWidth( wid ); | 534 | geom.setWidth( wid ); |
535 | w->setGeometry( geom ); | 535 | w->setGeometry( geom ); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 539 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
540 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 540 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
541 | } else { | 541 | } else { |
542 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 542 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | 545 | ||
546 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 546 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
547 | timeMarker->raise(); //on top of all widgets | 547 | timeMarker->raise(); //on top of all widgets |
548 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day | 548 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day |
549 | timeMarker->show(); | 549 | timeMarker->show(); |
550 | } else { | 550 | } else { |
551 | timeMarker->hide(); | 551 | timeMarker->hide(); |
552 | } | 552 | } |
553 | setUpdatesEnabled( TRUE ); | 553 | setUpdatesEnabled( TRUE ); |
554 | return; | 554 | return; |
555 | } | 555 | } |
556 | 556 | ||
557 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 557 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
558 | { | 558 | { |
559 | int i = 0; | 559 | int i = 0; |
560 | DateBookDayWidget *w = widgetList.at(i); | 560 | DateBookDayWidget *w = widgetList.at(i); |
561 | int wCount = widgetList.count(); | 561 | int wCount = widgetList.count(); |
562 | while ( i < wCount && w != item ) { | 562 | while ( i < wCount && w != item ) { |
563 | if ( w->geometry().intersects( geom ) ) { | 563 | if ( w->geometry().intersects( geom ) ) { |
564 | return w; | 564 | return w; |
565 | } | 565 | } |
566 | w = widgetList.at(++i); | 566 | w = widgetList.at(++i); |
567 | } | 567 | } |
568 | 568 | ||
569 | return 0; | 569 | return 0; |
570 | } | 570 | } |
571 | 571 | ||
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp index d43d31a..a0aefd3 100644 --- a/core/pim/datebook/datebookdayallday.cpp +++ b/core/pim/datebook/datebookdayallday.cpp | |||
@@ -1,226 +1,226 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** GPL by Rajko Albrecht | 2 | ** GPL by Rajko Albrecht |
3 | ** | 3 | ** |
4 | ** | 4 | ** |
5 | ** | 5 | ** |
6 | ** | 6 | ** |
7 | ** | 7 | ** |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "datebookdayallday.h" | 9 | #include "datebookdayallday.h" |
10 | 10 | ||
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qpe/ir.h> | 12 | #include <qpe/ir.h> |
13 | #include <qpopupmenu.h> | 13 | #include <qpopupmenu.h> |
14 | #include <qtimer.h> | 14 | #include <qtimer.h> |
15 | 15 | ||
16 | #include "datebookday.h" | 16 | #include "datebookday.h" |
17 | 17 | ||
18 | /* | 18 | /* |
19 | * Constructs a DatebookdayAllday which is a child of 'parent', with the | 19 | * Constructs a DatebookdayAllday which is a child of 'parent', with the |
20 | * name 'name' and widget flags set to 'f' | 20 | * name 'name' and widget flags set to 'f' |
21 | */ | 21 | */ |
22 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) | 22 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) |
23 | : QScrollView( parent, name ),item_count(0),dateBook(db) | 23 | : QScrollView( parent, name ),item_count(0),dateBook(db) |
24 | { | 24 | { |
25 | if ( !name ) | 25 | if ( !name ) |
26 | setName( "DatebookdayAllday" ); | 26 | setName( "DatebookdayAllday" ); |
27 | setMinimumSize( QSize( 0, 0 ) ); | 27 | setMinimumSize( QSize( 0, 0 ) ); |
28 | setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); | 28 | setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); |
29 | 29 | ||
30 | m_MainFrame = new QFrame(viewport()); | 30 | m_MainFrame = new QFrame(viewport()); |
31 | m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); | 31 | m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); |
32 | setFrameStyle(QFrame::NoFrame|QFrame::Plain); | 32 | setFrameStyle(QFrame::NoFrame|QFrame::Plain); |
33 | setResizePolicy( QScrollView::Default ); | 33 | setResizePolicy( QScrollView::Default ); |
34 | setHScrollBarMode( AlwaysOff ); | 34 | setHScrollBarMode( AlwaysOff ); |
35 | addChild(m_MainFrame); | 35 | addChild(m_MainFrame); |
36 | 36 | ||
37 | datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); | 37 | datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); |
38 | datebookdayalldayLayout->setSpacing( 0 ); | 38 | datebookdayalldayLayout->setSpacing( 0 ); |
39 | datebookdayalldayLayout->setMargin( 0 ); | 39 | datebookdayalldayLayout->setMargin( 0 ); |
40 | 40 | ||
41 | lblDesc = new DatebookEventDesc(parent->parentWidget(),""); | 41 | lblDesc = new DatebookEventDesc(parent->parentWidget(),""); |
42 | lblDesc->setBackgroundColor(Qt::yellow); | 42 | lblDesc->setBackgroundColor(Qt::yellow); |
43 | lblDesc->hide(); | 43 | lblDesc->hide(); |
44 | subWidgets.setAutoDelete(true); | 44 | subWidgets.setAutoDelete(true); |
45 | } | 45 | } |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * Destroys the object and frees any allocated resources | 48 | * Destroys the object and frees any allocated resources |
49 | */ | 49 | */ |
50 | DatebookdayAllday::~DatebookdayAllday() | 50 | DatebookdayAllday::~DatebookdayAllday() |
51 | { | 51 | { |
52 | // no need to delete child widgets, Qt does it all for us | 52 | // no need to delete child widgets, Qt does it all for us |
53 | } | 53 | } |
54 | 54 | ||
55 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) | 55 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) |
56 | { | 56 | { |
57 | DatebookAlldayDisp * lb; | 57 | DatebookAlldayDisp * lb; |
58 | lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); | 58 | lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); |
59 | lb->show(); | 59 | lb->show(); |
60 | datebookdayalldayLayout->addWidget(lb); | 60 | datebookdayalldayLayout->addWidget(lb); |
61 | subWidgets.append(lb); | 61 | subWidgets.append(lb); |
62 | 62 | ||
63 | connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&))); | 63 | connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&))); |
64 | ++item_count; | 64 | ++item_count; |
65 | 65 | ||
66 | return lb; | 66 | return lb; |
67 | } | 67 | } |
68 | 68 | ||
69 | void DatebookdayAllday::removeAllEvents() | 69 | void DatebookdayAllday::removeAllEvents() |
70 | { | 70 | { |
71 | subWidgets.clear(); | 71 | subWidgets.clear(); |
72 | item_count = 0; | 72 | item_count = 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, | 75 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, |
76 | QWidget* parent,const char* name,WFlags f) | 76 | QWidget* parent,const char* name,WFlags f) |
77 | : QLabel(parent,name,f),m_Ev(ev),dateBook(db) | 77 | : QLabel(parent,name,f),m_Ev(ev),dateBook(db) |
78 | { | 78 | { |
79 | QString strDesc = m_Ev.description(); | 79 | QString strDesc = m_Ev.description(); |
80 | strDesc = strDesc.replace(QRegExp("<"),"<"); | 80 | strDesc = strDesc.replace(QRegExp("<"),"<"); |
81 | setBackgroundColor(yellow); | 81 | setBackgroundColor(yellow); |
82 | setText(strDesc); | 82 | setText(strDesc); |
83 | setFrameStyle(QFrame::Raised|QFrame::Panel); | 83 | setFrameStyle(QFrame::Raised|QFrame::Panel); |
84 | 84 | ||
85 | int s = QFontMetrics(font()).height()+4; | 85 | int s = QFontMetrics(font()).height()+4; |
86 | setMaximumHeight( s ); | 86 | setMaximumHeight( s ); |
87 | setMinimumSize( QSize( 0, s ) ); | 87 | setMinimumSize( QSize( 0, s ) ); |
88 | } | 88 | } |
89 | 89 | ||
90 | DatebookAlldayDisp::~DatebookAlldayDisp() | 90 | DatebookAlldayDisp::~DatebookAlldayDisp() |
91 | { | 91 | { |
92 | } | 92 | } |
93 | 93 | ||
94 | void DatebookAlldayDisp::beam_single_event() | 94 | void DatebookAlldayDisp::beam_single_event() |
95 | { | 95 | { |
96 | // create an Event and beam it... | 96 | // create an Event and beam it... |
97 | /* | 97 | /* |
98 | * Start with the easy stuff. If start and end date is the same we can just use | 98 | * Start with the easy stuff. If start and end date is the same we can just use |
99 | * the values of effective m_Events | 99 | * the values of effective m_Events |
100 | * If it is a multi day m_Event we need to find the real start and end date... | 100 | * If it is a multi day m_Event we need to find the real start and end date... |
101 | */ | 101 | */ |
102 | if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { | 102 | if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { |
103 | Event m_Event( m_Ev.event() ); | 103 | Event m_Event( m_Ev.event() ); |
104 | 104 | ||
105 | QDateTime dt( m_Ev.date(), m_Ev.start() ); | 105 | QDateTime dt( m_Ev.date(), m_Ev.start() ); |
106 | m_Event.setStart( dt ); | 106 | m_Event.setStart( dt ); |
107 | 107 | ||
108 | dt.setTime( m_Ev.end() ); | 108 | dt.setTime( m_Ev.end() ); |
109 | m_Event.setEnd( dt ); | 109 | m_Event.setEnd( dt ); |
110 | emit beamMe( m_Event ); | 110 | emit beamMe( m_Event ); |
111 | }else { | 111 | }else { |
112 | /* | 112 | /* |
113 | * at least the the Times are right now | 113 | * at least the the Times are right now |
114 | */ | 114 | */ |
115 | QDateTime start( m_Ev.event().start() ); | 115 | QDateTime start( m_Ev.event().start() ); |
116 | QDateTime end ( m_Ev.event().end () ); | 116 | QDateTime end ( m_Ev.event().end () ); |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * ok we know the start date or we need to find it | 119 | * ok we know the start date or we need to find it |
120 | */ | 120 | */ |
121 | if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { | 121 | if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { |
122 | start.setDate( m_Ev.date() ); | 122 | start.setDate( m_Ev.date() ); |
123 | }else { | 123 | }else { |
124 | QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); | 124 | QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); |
125 | start.setDate( dt ); | 125 | start.setDate( dt ); |
126 | } | 126 | } |
127 | 127 | ||
128 | /* | 128 | /* |
129 | * ok we know now the end date... | 129 | * ok we know now the end date... |
130 | * else | 130 | * else |
131 | * get to know the offset btw the real start and real end | 131 | * get to know the offset btw the real start and real end |
132 | * and then add it to the new start date... | 132 | * and then add it to the new start date... |
133 | */ | 133 | */ |
134 | if ( m_Ev.end() != QTime(23, 59, 59 ) ) { | 134 | if ( m_Ev.end() != QTime(23, 59, 59 ) ) { |
135 | end.setDate( m_Ev.date() ); | 135 | end.setDate( m_Ev.date() ); |
136 | }else{ | 136 | }else{ |
137 | int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); | 137 | int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); |
138 | end.setDate( start.date().addDays( days ) ); | 138 | end.setDate( start.date().addDays( days ) ); |
139 | } | 139 | } |
140 | Event m_Event( m_Ev.event() ); | 140 | Event m_Event( m_Ev.event() ); |
141 | m_Event.setStart( start ); | 141 | m_Event.setStart( start ); |
142 | m_Event.setEnd ( end ); | 142 | m_Event.setEnd ( end ); |
143 | emit beamMe( m_Event ); | 143 | emit beamMe( m_Event ); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) | 147 | void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) |
148 | { | 148 | { |
149 | Event ev = m_Ev.event(); | 149 | Event ev = m_Ev.event(); |
150 | QColor b = backgroundColor(); | 150 | QColor b = backgroundColor(); |
151 | setBackgroundColor(green); | 151 | setBackgroundColor(green); |
152 | update(); | 152 | update(); |
153 | QPopupMenu m; | 153 | QPopupMenu m; |
154 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); | 154 | m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); |
155 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); | 155 | m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); |
156 | m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); | 156 | m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); |
157 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); | 157 | if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); |
158 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); | 158 | if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); |
159 | m.insertItem( tr( "Info"),6); | 159 | m.insertItem( tr( "Info"),6); |
160 | int r = m.exec( e->globalPos() ); | 160 | int r = m.exec( e->globalPos() ); |
161 | setBackgroundColor(b); | 161 | setBackgroundColor(b); |
162 | update(); | 162 | update(); |
163 | switch (r) { | 163 | switch (r) { |
164 | case 1: | 164 | case 1: |
165 | emit editMe( ev ); | 165 | emit editMe( ev ); |
166 | break; | 166 | break; |
167 | case 2: | 167 | case 2: |
168 | emit deleteMe( ev ); | 168 | emit deleteMe( ev ); |
169 | break; | 169 | break; |
170 | case 3: | 170 | case 3: |
171 | emit beamMe( ev ); | 171 | emit beamMe( ev ); |
172 | break; | 172 | break; |
173 | case 4: | 173 | case 4: |
174 | emit duplicateMe( ev ); | 174 | emit duplicateMe( ev ); |
175 | break; | 175 | break; |
176 | case 5: | 176 | case 5: |
177 | beam_single_event(); | 177 | beam_single_event(); |
178 | break; | 178 | break; |
179 | case 6: | 179 | case 6: |
180 | emit displayMe( ev ); | 180 | emit displayMe( ev ); |
181 | break; | 181 | break; |
182 | default: | 182 | default: |
183 | break; | 183 | break; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) | 187 | DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) |
188 | :QLabel(parent,name) | 188 | :QLabel(parent,name) |
189 | { | 189 | { |
190 | m_Timer=new QTimer(this); | 190 | m_Timer=new QTimer(this); |
191 | connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); | 191 | connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); |
192 | setFrameStyle(QFrame::Sunken|QFrame::Panel); | 192 | setFrameStyle(QFrame::Sunken|QFrame::Panel); |
193 | setTextFormat(RichText); | 193 | setTextFormat(RichText); |
194 | } | 194 | } |
195 | 195 | ||
196 | DatebookEventDesc::~DatebookEventDesc() | 196 | DatebookEventDesc::~DatebookEventDesc() |
197 | { | 197 | { |
198 | } | 198 | } |
199 | 199 | ||
200 | void DatebookEventDesc::mousePressEvent(QMouseEvent*) | 200 | void DatebookEventDesc::mousePressEvent(QMouseEvent*) |
201 | { | 201 | { |
202 | hide(); | 202 | hide(); |
203 | if (m_Timer->isActive()) m_Timer->stop(); | 203 | if (m_Timer->isActive()) m_Timer->stop(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void DatebookEventDesc::disp_event(const Event&e) | 206 | void DatebookEventDesc::disp_event(const Event&e) |
207 | { | 207 | { |
208 | if (m_Timer->isActive()) m_Timer->stop(); | 208 | if (m_Timer->isActive()) m_Timer->stop(); |
209 | QString text; | 209 | QString text; |
210 | text = "<b><i>"+e.description()+"</i></b><br>"; | 210 | text = "<b><i>"+e.description()+"</i></b><br>"; |
211 | if (e.notes().length()>0) { | 211 | if (e.notes().length()>0) { |
212 | text+="<b>"+e.notes()+"</b><br>"; | 212 | text+="<b>"+e.notes()+"</b><br>"; |
213 | } | 213 | } |
214 | if (e.location().length()>0) { | 214 | if (e.location().length()>0) { |
215 | text+="<i>"+e.location()+"</i><br>"; | 215 | text+="<i>"+e.location()+"</i><br>"; |
216 | } | 216 | } |
217 | text = text.replace(QRegExp("\n"),"<br>"); | 217 | text = text.replace(QRegExp("\n"),"<br>"); |
218 | setText(text); | 218 | setText(text); |
219 | QSize s = sizeHint(); | 219 | QSize s = sizeHint(); |
220 | s+=QSize(10,10); | 220 | s+=QSize(10,10); |
221 | resize(s); | 221 | resize(s); |
222 | move( QMAX(0,(parentWidget()->width()-width()) / 2), | 222 | move( QMAX(0,(parentWidget()->width()-width()) / 2), |
223 | (parentWidget()->height()-height())/2 ); | 223 | (parentWidget()->height()-height())/2 ); |
224 | show(); | 224 | show(); |
225 | m_Timer->start(2000,true); | 225 | m_Timer->start(2000,true); |
226 | } | 226 | } |
diff --git a/core/pim/datebook/datebookdayheaderimpl.cpp b/core/pim/datebook/datebookdayheaderimpl.cpp index 213c843..51b78ca 100644 --- a/core/pim/datebook/datebookdayheaderimpl.cpp +++ b/core/pim/datebook/datebookdayheaderimpl.cpp | |||
@@ -1,200 +1,200 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "datebookdayheaderimpl.h" | 20 | #include "datebookdayheaderimpl.h" |
21 | 21 | ||
22 | #include <qpe/datebookmonth.h> | 22 | #include <qpe/datebookmonth.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | 24 | ||
25 | #include <qbuttongroup.h> | 25 | #include <qbuttongroup.h> |
26 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
27 | 27 | ||
28 | 28 | ||
29 | /* | 29 | /* |
30 | * Constructs a DateBookDayHeader which is a child of 'parent', with the | 30 | * Constructs a DateBookDayHeader which is a child of 'parent', with the |
31 | * name 'name' and widget flags set to 'f' | 31 | * name 'name' and widget flags set to 'f' |
32 | * | 32 | * |
33 | * The dialog will by default be modeless, unless you set 'modal' to | 33 | * The dialog will by default be modeless, unless you set 'modal' to |
34 | * TRUE to construct a modal dialog. | 34 | * TRUE to construct a modal dialog. |
35 | */ | 35 | */ |
36 | DateBookDayHeader::DateBookDayHeader( bool useMonday, | 36 | DateBookDayHeader::DateBookDayHeader( bool useMonday, |
37 | QWidget* parent, const char* name ) | 37 | QWidget* parent, const char* name ) |
38 | : DateBookDayHeaderBase( parent, name ), | 38 | : DateBookDayHeaderBase( parent, name ), |
39 | bUseMonday( useMonday ) | 39 | bUseMonday( useMonday ) |
40 | { | 40 | { |
41 | connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); | 41 | connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); |
42 | 42 | ||
43 | setupNames(); | 43 | setupNames(); |
44 | 44 | ||
45 | forward->setPixmap( Resource::loadPixmap( "forward" ) ); | 45 | forward->setPixmap( Resource::loadPixmap( "forward" ) ); |
46 | back->setPixmap( Resource::loadPixmap( "back" ) ); | 46 | back->setPixmap( Resource::loadPixmap( "back" ) ); |
47 | forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); | 47 | forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); |
48 | backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); | 48 | backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); |
49 | 49 | ||
50 | setBackgroundMode( PaletteButton ); | 50 | setBackgroundMode( PaletteButton ); |
51 | grpDays->setBackgroundMode( PaletteButton ); | 51 | grpDays->setBackgroundMode( PaletteButton ); |
52 | } | 52 | } |
53 | 53 | ||
54 | /* | 54 | /* |
55 | * Destroys the object and frees any allocated resources | 55 | * Destroys the object and frees any allocated resources |
56 | */ | 56 | */ |
57 | DateBookDayHeader::~DateBookDayHeader() | 57 | DateBookDayHeader::~DateBookDayHeader() |
58 | { | 58 | { |
59 | // no need to delete child widgets, Qt does it all for us | 59 | // no need to delete child widgets, Qt does it all for us |
60 | } | 60 | } |
61 | 61 | ||
62 | void DateBookDayHeader::setStartOfWeek( bool onMonday ) | 62 | void DateBookDayHeader::setStartOfWeek( bool onMonday ) |
63 | { | 63 | { |
64 | bUseMonday = onMonday; | 64 | bUseMonday = onMonday; |
65 | setupNames(); | 65 | setupNames(); |
66 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 66 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void DateBookDayHeader::setupNames() | 69 | void DateBookDayHeader::setupNames() |
70 | { | 70 | { |
71 | if ( bUseMonday ) { | 71 | if ( bUseMonday ) { |
72 | cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); | 72 | cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); |
73 | cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); | 73 | cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); |
74 | cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); | 74 | cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); |
75 | cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); | 75 | cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); |
76 | cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); | 76 | cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); |
77 | cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); | 77 | cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); |
78 | cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); | 78 | cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); |
79 | } else { | 79 | } else { |
80 | cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); | 80 | cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); |
81 | cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); | 81 | cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); |
82 | cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); | 82 | cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); |
83 | cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); | 83 | cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); |
84 | cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); | 84 | cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); |
85 | cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); | 85 | cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); |
86 | cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); | 86 | cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | void DateBookDayHeader::pickDate() | 91 | void DateBookDayHeader::pickDate() |
92 | { | 92 | { |
93 | static QPopupMenu *m1 = 0; | 93 | static QPopupMenu *m1 = 0; |
94 | static DateBookMonth *picker = 0; | 94 | static DateBookMonth *picker = 0; |
95 | if ( !m1 ) { | 95 | if ( !m1 ) { |
96 | m1 = new QPopupMenu( this ); | 96 | m1 = new QPopupMenu( this ); |
97 | picker = new DateBookMonth( m1, 0, TRUE ); | 97 | picker = new DateBookMonth( m1, 0, TRUE ); |
98 | m1->insertItem( picker ); | 98 | m1->insertItem( picker ); |
99 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 99 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
100 | this, SLOT( setDate( int, int, int ) ) ); | 100 | this, SLOT( setDate(int,int,int) ) ); |
101 | connect( m1, SIGNAL( aboutToHide() ), | 101 | connect( m1, SIGNAL( aboutToHide() ), |
102 | this, SLOT( gotHide() ) ); | 102 | this, SLOT( gotHide() ) ); |
103 | } | 103 | } |
104 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | 104 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); |
105 | m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); | 105 | m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); |
106 | picker->setFocus(); | 106 | picker->setFocus(); |
107 | } | 107 | } |
108 | 108 | ||
109 | void DateBookDayHeader::gotHide() | 109 | void DateBookDayHeader::gotHide() |
110 | { | 110 | { |
111 | // we have to redo the button... | 111 | // we have to redo the button... |
112 | date->setDown( false ); | 112 | date->setDown( false ); |
113 | } | 113 | } |
114 | 114 | ||
115 | /* | 115 | /* |
116 | * public slot | 116 | * public slot |
117 | */ | 117 | */ |
118 | void DateBookDayHeader::goBack() | 118 | void DateBookDayHeader::goBack() |
119 | { | 119 | { |
120 | currDate = currDate.addDays( -1 ); | 120 | currDate = currDate.addDays( -1 ); |
121 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 121 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
122 | } | 122 | } |
123 | /* | 123 | /* |
124 | * public slot | 124 | * public slot |
125 | */ | 125 | */ |
126 | void DateBookDayHeader::goForward() | 126 | void DateBookDayHeader::goForward() |
127 | { | 127 | { |
128 | currDate = currDate.addDays( 1 ); | 128 | currDate = currDate.addDays( 1 ); |
129 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 129 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
130 | } | 130 | } |
131 | /* | 131 | /* |
132 | * public slot | 132 | * public slot |
133 | */ | 133 | */ |
134 | void DateBookDayHeader::goBackWeek() | 134 | void DateBookDayHeader::goBackWeek() |
135 | { | 135 | { |
136 | currDate = currDate.addDays( -7 ); | 136 | currDate = currDate.addDays( -7 ); |
137 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 137 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
138 | } | 138 | } |
139 | /* | 139 | /* |
140 | * public slot | 140 | * public slot |
141 | */ | 141 | */ |
142 | void DateBookDayHeader::goForwardWeek() | 142 | void DateBookDayHeader::goForwardWeek() |
143 | { | 143 | { |
144 | currDate = currDate.addDays( 7 ); | 144 | currDate = currDate.addDays( 7 ); |
145 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 145 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | /* | 149 | /* |
150 | * public slot | 150 | * public slot |
151 | */ | 151 | */ |
152 | void DateBookDayHeader::setDate( int y, int m, int d ) | 152 | void DateBookDayHeader::setDate( int y, int m, int d ) |
153 | { | 153 | { |
154 | currDate.setYMD( y, m, d ); | 154 | currDate.setYMD( y, m, d ); |
155 | date->setText( TimeString::shortDate( currDate ) ); | 155 | date->setText( TimeString::shortDate( currDate ) ); |
156 | 156 | ||
157 | int iDayOfWeek = currDate.dayOfWeek(); | 157 | int iDayOfWeek = currDate.dayOfWeek(); |
158 | // cleverly adjust the day depending on how we start the week | 158 | // cleverly adjust the day depending on how we start the week |
159 | if ( bUseMonday ) | 159 | if ( bUseMonday ) |
160 | iDayOfWeek--; | 160 | iDayOfWeek--; |
161 | else { | 161 | else { |
162 | if ( iDayOfWeek == 7 ) // Sunday | 162 | if ( iDayOfWeek == 7 ) // Sunday |
163 | iDayOfWeek = 0; | 163 | iDayOfWeek = 0; |
164 | } | 164 | } |
165 | grpDays->setButton( iDayOfWeek ); | 165 | grpDays->setButton( iDayOfWeek ); |
166 | emit dateChanged( y, m, d ); | 166 | emit dateChanged( y, m, d ); |
167 | } | 167 | } |
168 | 168 | ||
169 | /* | 169 | /* |
170 | * public slot | 170 | * public slot |
171 | */ | 171 | */ |
172 | void DateBookDayHeader::setDay( int day ) | 172 | void DateBookDayHeader::setDay( int day ) |
173 | { | 173 | { |
174 | int realDay; | 174 | int realDay; |
175 | int dayOfWeek = currDate.dayOfWeek(); | 175 | int dayOfWeek = currDate.dayOfWeek(); |
176 | 176 | ||
177 | // a little adjustment is needed... | 177 | // a little adjustment is needed... |
178 | if ( bUseMonday ) | 178 | if ( bUseMonday ) |
179 | realDay = day + 1 ; | 179 | realDay = day + 1 ; |
180 | else if ( !bUseMonday && day == 0 ) // sunday | 180 | else if ( !bUseMonday && day == 0 ) // sunday |
181 | realDay = 7; | 181 | realDay = 7; |
182 | else | 182 | else |
183 | realDay = day; | 183 | realDay = day; |
184 | // special cases first... | 184 | // special cases first... |
185 | if ( realDay == 7 && !bUseMonday ) { | 185 | if ( realDay == 7 && !bUseMonday ) { |
186 | while ( currDate.dayOfWeek() != realDay ) | 186 | while ( currDate.dayOfWeek() != realDay ) |
187 | currDate = currDate.addDays( -1 ); | 187 | currDate = currDate.addDays( -1 ); |
188 | } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { | 188 | } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { |
189 | while ( currDate.dayOfWeek() != realDay ) | 189 | while ( currDate.dayOfWeek() != realDay ) |
190 | currDate = currDate.addDays( 1 ); | 190 | currDate = currDate.addDays( 1 ); |
191 | } else if ( dayOfWeek < realDay ) { | 191 | } else if ( dayOfWeek < realDay ) { |
192 | while ( currDate.dayOfWeek() < realDay ) | 192 | while ( currDate.dayOfWeek() < realDay ) |
193 | currDate = currDate.addDays( 1 ); | 193 | currDate = currDate.addDays( 1 ); |
194 | } else if ( dayOfWeek > realDay ) { | 194 | } else if ( dayOfWeek > realDay ) { |
195 | while ( currDate.dayOfWeek() > realDay ) | 195 | while ( currDate.dayOfWeek() > realDay ) |
196 | currDate = currDate.addDays( -1 ); | 196 | currDate = currDate.addDays( -1 ); |
197 | } | 197 | } |
198 | // update the date... | 198 | // update the date... |
199 | setDate( currDate.year(), currDate.month(), currDate.day() ); | 199 | setDate( currDate.year(), currDate.month(), currDate.day() ); |
200 | } | 200 | } |
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp index a6d04ba..cb4b73b 100644 --- a/core/pim/datebook/datebooksettings.cpp +++ b/core/pim/datebook/datebooksettings.cpp | |||
@@ -1,155 +1,155 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "datebooksettings.h" | 21 | #include "datebooksettings.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #include <qspinbox.h> | 25 | #include <qspinbox.h> |
26 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
27 | 27 | ||
28 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, | 28 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, |
29 | const char *name, bool modal, WFlags fl ) | 29 | const char *name, bool modal, WFlags fl ) |
30 | : DateBookSettingsBase( parent, name, modal, fl ), | 30 | : DateBookSettingsBase( parent, name, modal, fl ), |
31 | ampm( whichClock ) | 31 | ampm( whichClock ) |
32 | { | 32 | { |
33 | init(); | 33 | init(); |
34 | QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) ); | 34 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); |
35 | QArray<int> categories; | 35 | QArray<int> categories; |
36 | comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); | 36 | comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); |
37 | } | 37 | } |
38 | 38 | ||
39 | DateBookSettings::~DateBookSettings() | 39 | DateBookSettings::~DateBookSettings() |
40 | { | 40 | { |
41 | } | 41 | } |
42 | 42 | ||
43 | void DateBookSettings::setStartTime( int newStartViewTime ) | 43 | void DateBookSettings::setStartTime( int newStartViewTime ) |
44 | { | 44 | { |
45 | if ( ampm ) { | 45 | if ( ampm ) { |
46 | if ( newStartViewTime >= 12 ) { | 46 | if ( newStartViewTime >= 12 ) { |
47 | newStartViewTime %= 12; | 47 | newStartViewTime %= 12; |
48 | if ( newStartViewTime == 0 ) | 48 | if ( newStartViewTime == 0 ) |
49 | newStartViewTime = 12; | 49 | newStartViewTime = 12; |
50 | spinStart->setSuffix( tr(":00 PM") ); | 50 | spinStart->setSuffix( tr(":00 PM") ); |
51 | } | 51 | } |
52 | else if ( newStartViewTime == 0 ) { | 52 | else if ( newStartViewTime == 0 ) { |
53 | newStartViewTime = 12; | 53 | newStartViewTime = 12; |
54 | spinStart->setSuffix( tr(":00 AM") ); | 54 | spinStart->setSuffix( tr(":00 AM") ); |
55 | } | 55 | } |
56 | oldtime = newStartViewTime; | 56 | oldtime = newStartViewTime; |
57 | } | 57 | } |
58 | spinStart->setValue( newStartViewTime ); | 58 | spinStart->setValue( newStartViewTime ); |
59 | } | 59 | } |
60 | 60 | ||
61 | int DateBookSettings::startTime() const | 61 | int DateBookSettings::startTime() const |
62 | { | 62 | { |
63 | int returnMe = spinStart->value(); | 63 | int returnMe = spinStart->value(); |
64 | if ( ampm ) { | 64 | if ( ampm ) { |
65 | if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) | 65 | if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) |
66 | returnMe += 12; | 66 | returnMe += 12; |
67 | else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) | 67 | else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) |
68 | returnMe = 0; | 68 | returnMe = 0; |
69 | } | 69 | } |
70 | return returnMe; | 70 | return returnMe; |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) | 74 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) |
75 | { | 75 | { |
76 | chkAlarmPreset->setChecked( bAlarm ); | 76 | chkAlarmPreset->setChecked( bAlarm ); |
77 | if ( presetTime >=5 ) | 77 | if ( presetTime >=5 ) |
78 | spinPreset->setValue( presetTime ); | 78 | spinPreset->setValue( presetTime ); |
79 | } | 79 | } |
80 | 80 | ||
81 | bool DateBookSettings::alarmPreset() const | 81 | bool DateBookSettings::alarmPreset() const |
82 | { | 82 | { |
83 | return chkAlarmPreset->isChecked(); | 83 | return chkAlarmPreset->isChecked(); |
84 | } | 84 | } |
85 | 85 | ||
86 | int DateBookSettings::presetTime() const | 86 | int DateBookSettings::presetTime() const |
87 | { | 87 | { |
88 | return spinPreset->value(); | 88 | return spinPreset->value(); |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void DateBookSettings::slot12Hour( int i ) | 92 | void DateBookSettings::slot12Hour( int i ) |
93 | { | 93 | { |
94 | if ( ampm ) { | 94 | if ( ampm ) { |
95 | if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { | 95 | if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { |
96 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | 96 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) |
97 | spinStart->setSuffix( tr(":00 PM") ); | 97 | spinStart->setSuffix( tr(":00 PM") ); |
98 | } else { | 98 | } else { |
99 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | 99 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) |
100 | spinStart->setSuffix( tr(":00 AM") ); | 100 | spinStart->setSuffix( tr(":00 AM") ); |
101 | } | 101 | } |
102 | oldtime = i; | 102 | oldtime = i; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | void DateBookSettings::init() | 106 | void DateBookSettings::init() |
107 | { | 107 | { |
108 | if ( ampm ) { | 108 | if ( ampm ) { |
109 | spinStart->setMinValue( 1 ); | 109 | spinStart->setMinValue( 1 ); |
110 | spinStart->setMaxValue( 12 ); | 110 | spinStart->setMaxValue( 12 ); |
111 | spinStart->setValue( 12 ); | 111 | spinStart->setValue( 12 ); |
112 | spinStart->setSuffix( tr(":00 AM") ); | 112 | spinStart->setSuffix( tr(":00 AM") ); |
113 | oldtime = 12; | 113 | oldtime = 12; |
114 | } else { | 114 | } else { |
115 | spinStart->setMinValue( 0 ); | 115 | spinStart->setMinValue( 0 ); |
116 | spinStart->setMaxValue( 23 ); | 116 | spinStart->setMaxValue( 23 ); |
117 | spinStart->setSuffix( tr(":00") ); | 117 | spinStart->setSuffix( tr(":00") ); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | void DateBookSettings::slotChangeClock( bool whichClock ) | 121 | void DateBookSettings::slotChangeClock( bool whichClock ) |
122 | { | 122 | { |
123 | int saveMe; | 123 | int saveMe; |
124 | saveMe = spinStart->value(); | 124 | saveMe = spinStart->value(); |
125 | if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { | 125 | if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { |
126 | if ( saveMe == 12 ) | 126 | if ( saveMe == 12 ) |
127 | saveMe = 0; | 127 | saveMe = 0; |
128 | } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { | 128 | } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { |
129 | if ( saveMe != 12 ) | 129 | if ( saveMe != 12 ) |
130 | saveMe += 12; | 130 | saveMe += 12; |
131 | } | 131 | } |
132 | ampm = whichClock; | 132 | ampm = whichClock; |
133 | init(); | 133 | init(); |
134 | setStartTime( saveMe ); | 134 | setStartTime( saveMe ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void DateBookSettings::setJumpToCurTime( bool bJump ) | 137 | void DateBookSettings::setJumpToCurTime( bool bJump ) |
138 | { | 138 | { |
139 | chkJumpToCurTime->setChecked( bJump ); | 139 | chkJumpToCurTime->setChecked( bJump ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool DateBookSettings::jumpToCurTime() const | 142 | bool DateBookSettings::jumpToCurTime() const |
143 | { | 143 | { |
144 | return chkJumpToCurTime->isChecked(); | 144 | return chkJumpToCurTime->isChecked(); |
145 | } | 145 | } |
146 | 146 | ||
147 | void DateBookSettings::setRowStyle( int style ) | 147 | void DateBookSettings::setRowStyle( int style ) |
148 | { | 148 | { |
149 | comboRowStyle->setCurrentItem( style ); | 149 | comboRowStyle->setCurrentItem( style ); |
150 | } | 150 | } |
151 | 151 | ||
152 | int DateBookSettings::rowStyle() const | 152 | int DateBookSettings::rowStyle() const |
153 | { | 153 | { |
154 | return comboRowStyle->currentItem(); | 154 | return comboRowStyle->currentItem(); |
155 | } | 155 | } |
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 933e191..7503751 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -173,388 +173,388 @@ void DateBookWeekView::positionItem( DateBookWeekItem *i ) | |||
173 | const EffectiveEvent ev = i->event(); | 173 | const EffectiveEvent ev = i->event(); |
174 | 174 | ||
175 | // 30 minute intervals | 175 | // 30 minute intervals |
176 | int y = ev.start().hour() * 2; | 176 | int y = ev.start().hour() * 2; |
177 | y += db_round30min( ev.start().minute() ); | 177 | y += db_round30min( ev.start().minute() ); |
178 | int y2 = ev.end().hour() * 2; | 178 | int y2 = ev.end().hour() * 2; |
179 | y2 += db_round30min( ev.end().minute() ); | 179 | y2 += db_round30min( ev.end().minute() ); |
180 | if ( y > 47 ) y = 47; | 180 | if ( y > 47 ) y = 47; |
181 | if ( y2 > 48 ) y2 = 48; | 181 | if ( y2 > 48 ) y2 = 48; |
182 | y = (y * rowHeight) / 2; | 182 | y = (y * rowHeight) / 2; |
183 | y2 = (y2 * rowHeight) / 2; | 183 | y2 = (y2 * rowHeight) / 2; |
184 | 184 | ||
185 | int h; | 185 | int h; |
186 | if ( ev.event().type() == Event::AllDay ) { | 186 | if ( ev.event().type() == Event::AllDay ) { |
187 | h = (48 * rowHeight) / 2; | 187 | h = (48 * rowHeight) / 2; |
188 | y = 0; | 188 | y = 0; |
189 | } else { | 189 | } else { |
190 | h=y2-y; | 190 | h=y2-y; |
191 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; | 191 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; |
192 | } | 192 | } |
193 | 193 | ||
194 | int dow = ev.date().dayOfWeek(); | 194 | int dow = ev.date().dayOfWeek(); |
195 | if ( !bOnMonday ) { | 195 | if ( !bOnMonday ) { |
196 | if ( dow == 7 ) | 196 | if ( dow == 7 ) |
197 | dow = 1; | 197 | dow = 1; |
198 | else | 198 | else |
199 | dow++; | 199 | dow++; |
200 | } | 200 | } |
201 | int x = header->sectionPos( dow ) - 1; | 201 | int x = header->sectionPos( dow ) - 1; |
202 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); | 202 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); |
203 | DateBookWeekItem *isect = 0; | 203 | DateBookWeekItem *isect = 0; |
204 | do { | 204 | do { |
205 | i->setGeometry( x, y, Width, h ); | 205 | i->setGeometry( x, y, Width, h ); |
206 | isect = intersects( i ); | 206 | isect = intersects( i ); |
207 | x += Width - 1; | 207 | x += Width - 1; |
208 | } while ( isect && x < xlim ); | 208 | } while ( isect && x < xlim ); |
209 | } | 209 | } |
210 | 210 | ||
211 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) | 211 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) |
212 | { | 212 | { |
213 | QRect geom = item->geometry(); | 213 | QRect geom = item->geometry(); |
214 | 214 | ||
215 | // We allow the edges to overlap | 215 | // We allow the edges to overlap |
216 | geom.moveBy( 1, 1 ); | 216 | geom.moveBy( 1, 1 ); |
217 | geom.setSize( geom.size()-QSize(2,2) ); | 217 | geom.setSize( geom.size()-QSize(2,2) ); |
218 | 218 | ||
219 | QListIterator<DateBookWeekItem> it(items); | 219 | QListIterator<DateBookWeekItem> it(items); |
220 | for ( ; it.current(); ++it ) { | 220 | for ( ; it.current(); ++it ) { |
221 | DateBookWeekItem *i = it.current(); | 221 | DateBookWeekItem *i = it.current(); |
222 | if ( i != item ) { | 222 | if ( i != item ) { |
223 | if ( i->geometry().intersects( geom ) ) { | 223 | if ( i->geometry().intersects( geom ) ) { |
224 | return i; | 224 | return i; |
225 | } | 225 | } |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | return 0; | 229 | return 0; |
230 | } | 230 | } |
231 | 231 | ||
232 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) | 232 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) |
233 | { | 233 | { |
234 | QListIterator<DateBookWeekItem> it(items); | 234 | QListIterator<DateBookWeekItem> it(items); |
235 | for ( ; it.current(); ++it ) { | 235 | for ( ; it.current(); ++it ) { |
236 | DateBookWeekItem *i = it.current(); | 236 | DateBookWeekItem *i = it.current(); |
237 | if ( i->geometry().contains( e->pos() ) ) { | 237 | if ( i->geometry().contains( e->pos() ) ) { |
238 | showingEvent = true; | 238 | showingEvent = true; |
239 | emit signalShowEvent( i->event() ); | 239 | emit signalShowEvent( i->event() ); |
240 | break; | 240 | break; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) | 245 | void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) |
246 | { | 246 | { |
247 | if ( showingEvent ) { | 247 | if ( showingEvent ) { |
248 | showingEvent = false; | 248 | showingEvent = false; |
249 | emit signalHideEvent(); | 249 | emit signalHideEvent(); |
250 | } else { | 250 | } else { |
251 | int d = header->sectionAt( e->pos().x() ); | 251 | int d = header->sectionAt( e->pos().x() ); |
252 | if ( d > 0 ) { | 252 | if ( d > 0 ) { |
253 | // if ( !bOnMonday ) | 253 | // if ( !bOnMonday ) |
254 | // d--; | 254 | // d--; |
255 | emit showDay( d ); | 255 | emit showDay( d ); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) | 260 | void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) |
261 | { | 261 | { |
262 | QRect ur( cx, cy, cw, ch ); | 262 | QRect ur( cx, cy, cw, ch ); |
263 | p->setPen( lightGray ); | 263 | p->setPen( lightGray ); |
264 | for ( int i = 1; i <= 7; i++ ) | 264 | for ( int i = 1; i <= 7; i++ ) |
265 | p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); | 265 | p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); |
266 | 266 | ||
267 | p->setPen( black ); | 267 | p->setPen( black ); |
268 | for ( int t = 0; t < 24; t++ ) { | 268 | for ( int t = 0; t < 24; t++ ) { |
269 | int y = t*rowHeight; | 269 | int y = t*rowHeight; |
270 | if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { | 270 | if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { |
271 | QString s; | 271 | QString s; |
272 | if ( ampm ) { | 272 | if ( ampm ) { |
273 | if ( t == 0 ) | 273 | if ( t == 0 ) |
274 | s = QString::number( 12 ); | 274 | s = QString::number( 12 ); |
275 | else if ( t == 12 ) | 275 | else if ( t == 12 ) |
276 | s = QString::number(12) + tr( "p" ); | 276 | s = QString::number(12) + tr( "p" ); |
277 | else if ( t > 12 ) { | 277 | else if ( t > 12 ) { |
278 | if ( t - 12 < 10 ) | 278 | if ( t - 12 < 10 ) |
279 | s = " "; | 279 | s = " "; |
280 | else | 280 | else |
281 | s = ""; | 281 | s = ""; |
282 | s += QString::number( t - 12 ) + tr("p"); | 282 | s += QString::number( t - 12 ) + tr("p"); |
283 | } else { | 283 | } else { |
284 | if ( 12 - t < 3 ) | 284 | if ( 12 - t < 3 ) |
285 | s = ""; | 285 | s = ""; |
286 | else | 286 | else |
287 | s = " "; | 287 | s = " "; |
288 | s += QString::number( t ); | 288 | s += QString::number( t ); |
289 | } | 289 | } |
290 | } else { | 290 | } else { |
291 | s = QString::number( t ); | 291 | s = QString::number( t ); |
292 | if ( s.length() == 1 ) | 292 | if ( s.length() == 1 ) |
293 | s.prepend( "0" ); | 293 | s.prepend( "0" ); |
294 | } | 294 | } |
295 | p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); | 295 | p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | QListIterator<DateBookWeekItem> it(items); | 299 | QListIterator<DateBookWeekItem> it(items); |
300 | for ( ; it.current(); ++it ) { | 300 | for ( ; it.current(); ++it ) { |
301 | DateBookWeekItem *i = it.current(); | 301 | DateBookWeekItem *i = it.current(); |
302 | if ( i->geometry().intersects( ur ) ) { | 302 | if ( i->geometry().intersects( ur ) ) { |
303 | p->setBrush( i->color() ); | 303 | p->setBrush( i->color() ); |
304 | p->drawRect( i->geometry() ); | 304 | p->drawRect( i->geometry() ); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | void DateBookWeekView::resizeEvent( QResizeEvent *e ) | 309 | void DateBookWeekView::resizeEvent( QResizeEvent *e ) |
310 | { | 310 | { |
311 | const int hourWidth = 20; | 311 | const int hourWidth = 20; |
312 | QScrollView::resizeEvent( e ); | 312 | QScrollView::resizeEvent( e ); |
313 | 313 | ||
314 | 314 | ||
315 | //HEAD | 315 | //HEAD |
316 | /* | 316 | /* |
317 | int avail = visibleWidth(); | 317 | int avail = visibleWidth(); |
318 | header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), | 318 | header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), |
319 | visibleWidth(), header->sizeHint().height() ); | 319 | visibleWidth(), header->sizeHint().height() ); |
320 | setMargins( 0, header->sizeHint().height(), 0, 0 ); | 320 | setMargins( 0, header->sizeHint().height(), 0, 0 ); |
321 | */ | 321 | */ |
322 | //BRANCH_1_0 | 322 | //BRANCH_1_0 |
323 | int avail = width()-qApp->style().scrollBarExtent().width()-1; | 323 | int avail = width()-qApp->style().scrollBarExtent().width()-1; |
324 | header->setGeometry( 0, 0, avail, header->sizeHint().height() ); | 324 | header->setGeometry( 0, 0, avail, header->sizeHint().height() ); |
325 | setMargins( 0, header->height(), 0, 0 ); | 325 | setMargins( 0, header->height(), 0, 0 ); |
326 | 326 | ||
327 | 327 | ||
328 | header->resizeSection( 0, hourWidth ); | 328 | header->resizeSection( 0, hourWidth ); |
329 | int sw = (avail - hourWidth) / 7; | 329 | int sw = (avail - hourWidth) / 7; |
330 | for ( int i = 1; i < 7; i++ ) | 330 | for ( int i = 1; i < 7; i++ ) |
331 | header->resizeSection( i, sw ); | 331 | header->resizeSection( i, sw ); |
332 | header->resizeSection( 7, avail - hourWidth - sw*6 ); | 332 | header->resizeSection( 7, avail - hourWidth - sw*6 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) | 335 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) |
336 | { | 336 | { |
337 | bOnMonday = bStartOnMonday; | 337 | bOnMonday = bStartOnMonday; |
338 | initNames(); | 338 | initNames(); |
339 | } | 339 | } |
340 | 340 | ||
341 | //------------------------------------------------------------------- | 341 | //------------------------------------------------------------------- |
342 | 342 | ||
343 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, | 343 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, |
344 | QWidget *parent, const char *name ) | 344 | QWidget *parent, const char *name ) |
345 | : QWidget( parent, name ), | 345 | : QWidget( parent, name ), |
346 | db( newDB ), | 346 | db( newDB ), |
347 | startTime( 0 ), | 347 | startTime( 0 ), |
348 | ampm( ap ), | 348 | ampm( ap ), |
349 | bStartOnMonday( startOnMonday ) | 349 | bStartOnMonday( startOnMonday ) |
350 | { | 350 | { |
351 | setFocusPolicy(StrongFocus); | 351 | setFocusPolicy(StrongFocus); |
352 | QVBoxLayout *vb = new QVBoxLayout( this ); | 352 | QVBoxLayout *vb = new QVBoxLayout( this ); |
353 | header = new DateBookWeekHeader( bStartOnMonday, this ); | 353 | header = new DateBookWeekHeader( bStartOnMonday, this ); |
354 | view = new DateBookWeekView( ampm, startOnMonday, this ); | 354 | view = new DateBookWeekView( ampm, startOnMonday, this ); |
355 | vb->addWidget( header ); | 355 | vb->addWidget( header ); |
356 | vb->addWidget( view ); | 356 | vb->addWidget( view ); |
357 | 357 | ||
358 | lblDesc = new QLabel( this, "event label" ); | 358 | lblDesc = new QLabel( this, "event label" ); |
359 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); | 359 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); |
360 | lblDesc->setBackgroundColor( yellow ); | 360 | lblDesc->setBackgroundColor( yellow ); |
361 | lblDesc->hide(); | 361 | lblDesc->hide(); |
362 | 362 | ||
363 | tHide = new QTimer( this ); | 363 | tHide = new QTimer( this ); |
364 | 364 | ||
365 | connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); | 365 | connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) ); |
366 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); | 366 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); |
367 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); | 367 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); |
368 | connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); | 368 | connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) ); |
369 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); | 369 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); |
370 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 370 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
371 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); | 371 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); |
372 | setDate(QDate::currentDate()); | 372 | setDate(QDate::currentDate()); |
373 | } | 373 | } |
374 | 374 | ||
375 | void DateBookWeek::keyPressEvent(QKeyEvent *e) | 375 | void DateBookWeek::keyPressEvent(QKeyEvent *e) |
376 | { | 376 | { |
377 | switch(e->key()) { | 377 | switch(e->key()) { |
378 | case Key_Up: | 378 | case Key_Up: |
379 | view->scrollBy(0, -20); | 379 | view->scrollBy(0, -20); |
380 | break; | 380 | break; |
381 | case Key_Down: | 381 | case Key_Down: |
382 | view->scrollBy(0, 20); | 382 | view->scrollBy(0, 20); |
383 | break; | 383 | break; |
384 | case Key_Left: | 384 | case Key_Left: |
385 | setDate(date().addDays(-7)); | 385 | setDate(date().addDays(-7)); |
386 | break; | 386 | break; |
387 | case Key_Right: | 387 | case Key_Right: |
388 | setDate(date().addDays(7)); | 388 | setDate(date().addDays(7)); |
389 | break; | 389 | break; |
390 | default: | 390 | default: |
391 | e->ignore(); | 391 | e->ignore(); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | void DateBookWeek::showDay( int day ) | 395 | void DateBookWeek::showDay( int day ) |
396 | { | 396 | { |
397 | QDate d=bdate; | 397 | QDate d=bdate; |
398 | 398 | ||
399 | // Calculate offset to first day of week. | 399 | // Calculate offset to first day of week. |
400 | int dayoffset=d.dayOfWeek() % 7; | 400 | int dayoffset=d.dayOfWeek() % 7; |
401 | 401 | ||
402 | if(bStartOnMonday) dayoffset--; | 402 | if(bStartOnMonday) dayoffset--; |
403 | 403 | ||
404 | day--; | 404 | day--; |
405 | d=d.addDays(day-dayoffset); | 405 | d=d.addDays(day-dayoffset); |
406 | emit showDate( d.year(), d.month(), d.day() ); | 406 | emit showDate( d.year(), d.month(), d.day() ); |
407 | } | 407 | } |
408 | 408 | ||
409 | void DateBookWeek::setDate( int y, int m, int d ) | 409 | void DateBookWeek::setDate( int y, int m, int d ) |
410 | { | 410 | { |
411 | setDate(QDate(y, m, d)); | 411 | setDate(QDate(y, m, d)); |
412 | } | 412 | } |
413 | 413 | ||
414 | void DateBookWeek::setDate(QDate newdate) | 414 | void DateBookWeek::setDate(QDate newdate) |
415 | { | 415 | { |
416 | bdate=newdate; | 416 | bdate=newdate; |
417 | dow = newdate.dayOfWeek(); | 417 | dow = newdate.dayOfWeek(); |
418 | header->setDate( newdate ); | 418 | header->setDate( newdate ); |
419 | } | 419 | } |
420 | 420 | ||
421 | void DateBookWeek::dateChanged( QDate &newdate ) | 421 | void DateBookWeek::dateChanged( QDate &newdate ) |
422 | { | 422 | { |
423 | bdate=newdate; | 423 | bdate=newdate; |
424 | getEvents(); | 424 | getEvents(); |
425 | } | 425 | } |
426 | 426 | ||
427 | QDate DateBookWeek::date() const | 427 | QDate DateBookWeek::date() const |
428 | { | 428 | { |
429 | return bdate; | 429 | return bdate; |
430 | } | 430 | } |
431 | 431 | ||
432 | void DateBookWeek::getEvents() | 432 | void DateBookWeek::getEvents() |
433 | { | 433 | { |
434 | QDate startWeek = weekDate(); | 434 | QDate startWeek = weekDate(); |
435 | 435 | ||
436 | QDate endWeek = startWeek.addDays( 6 ); | 436 | QDate endWeek = startWeek.addDays( 6 ); |
437 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); | 437 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); |
438 | view->showEvents( eventList ); | 438 | view->showEvents( eventList ); |
439 | view->moveToHour( startTime ); | 439 | view->moveToHour( startTime ); |
440 | } | 440 | } |
441 | 441 | ||
442 | void DateBookWeek::generateAllDayTooltext( QString& text ) { | 442 | void DateBookWeek::generateAllDayTooltext( QString& text ) { |
443 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 443 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
444 | } | 444 | } |
445 | 445 | ||
446 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { | 446 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { |
447 | str += "<b>" + QObject::tr("Start") + "</b>: "; | 447 | str += "<b>" + QObject::tr("Start") + "</b>: "; |
448 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); | 448 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); |
449 | if( ev.startDate()!=ev.endDate() ) { | 449 | if( ev.startDate()!=ev.endDate() ) { |
450 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; | 450 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; |
451 | } | 451 | } |
452 | str += "<br>"; | 452 | str += "<br>"; |
453 | str += "<b>" + QObject::tr("End") + "</b>: "; | 453 | str += "<b>" + QObject::tr("End") + "</b>: "; |
454 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); | 454 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); |
455 | if( ev.startDate()!=ev.endDate() ) { | 455 | if( ev.startDate()!=ev.endDate() ) { |
456 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; | 456 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | 460 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) |
461 | { | 461 | { |
462 | if ( tHide->isActive() ) | 462 | if ( tHide->isActive() ) |
463 | tHide->stop(); | 463 | tHide->stop(); |
464 | 464 | ||
465 | // why would someone use "<"? Oh well, fix it up... | 465 | // why would someone use "<"? Oh well, fix it up... |
466 | // I wonder what other things may be messed up... | 466 | // I wonder what other things may be messed up... |
467 | QString strDesc = ev.description(); | 467 | QString strDesc = ev.description(); |
468 | int where = strDesc.find( "<" ); | 468 | int where = strDesc.find( "<" ); |
469 | while ( where != -1 ) { | 469 | while ( where != -1 ) { |
470 | strDesc.remove( where, 1 ); | 470 | strDesc.remove( where, 1 ); |
471 | strDesc.insert( where, "<" ); | 471 | strDesc.insert( where, "<" ); |
472 | where = strDesc.find( "<", where ); | 472 | where = strDesc.find( "<", where ); |
473 | } | 473 | } |
474 | 474 | ||
475 | QString strCat; | 475 | QString strCat; |
476 | // ### FIX later... | 476 | // ### FIX later... |
477 | // QString strCat = ev.category(); | 477 | // QString strCat = ev.category(); |
478 | // where = strCat.find( "<" ); | 478 | // where = strCat.find( "<" ); |
479 | // while ( where != -1 ) { | 479 | // while ( where != -1 ) { |
480 | // strCat.remove( where, 1 ); | 480 | // strCat.remove( where, 1 ); |
481 | // strCat.insert( where, "<" ); | 481 | // strCat.insert( where, "<" ); |
482 | // where = strCat.find( "<", where ); | 482 | // where = strCat.find( "<", where ); |
483 | // } | 483 | // } |
484 | 484 | ||
485 | QString strLocation = ev.location(); | 485 | QString strLocation = ev.location(); |
486 | while ( where != -1 ) { | 486 | while ( where != -1 ) { |
487 | strLocation.remove( where, 1 ); | 487 | strLocation.remove( where, 1 ); |
488 | strLocation.insert( where, "<" ); | 488 | strLocation.insert( where, "<" ); |
489 | where = strLocation.find( "<", where ); | 489 | where = strLocation.find( "<", where ); |
490 | } | 490 | } |
491 | 491 | ||
492 | QString strNote = ev.notes(); | 492 | QString strNote = ev.notes(); |
493 | where = strNote.find( "<" ); | 493 | where = strNote.find( "<" ); |
494 | while ( where != -1 ) { | 494 | while ( where != -1 ) { |
495 | strNote.remove( where, 1 ); | 495 | strNote.remove( where, 1 ); |
496 | strNote.insert( where, "<" ); | 496 | strNote.insert( where, "<" ); |
497 | where = strNote.find( "<", where ); | 497 | where = strNote.find( "<", where ); |
498 | } | 498 | } |
499 | 499 | ||
500 | QString str = "<b>" + strDesc + "</b><br>" | 500 | QString str = "<b>" + strDesc + "</b><br>" |
501 | + strLocation + "<br>" | 501 | + strLocation + "<br>" |
502 | + "<i>" + strCat + "</i>" | 502 | + "<i>" + strCat + "</i>" |
503 | + "<br>" + TimeString::longDateString( ev.date() ) | 503 | + "<br>" + TimeString::longDateString( ev.date() ) |
504 | + "<br>"; | 504 | + "<br>"; |
505 | 505 | ||
506 | if (ev.event().type() == Event::Normal ) | 506 | if (ev.event().type() == Event::Normal ) |
507 | generateNormalTooltext( str, ev ); | 507 | generateNormalTooltext( str, ev ); |
508 | else | 508 | else |
509 | generateAllDayTooltext( str ); | 509 | generateAllDayTooltext( str ); |
510 | 510 | ||
511 | str += "<br><br>" + strNote; | 511 | str += "<br><br>" + strNote; |
512 | 512 | ||
513 | lblDesc->setText( str ); | 513 | lblDesc->setText( str ); |
514 | lblDesc->resize( lblDesc->sizeHint() ); | 514 | lblDesc->resize( lblDesc->sizeHint() ); |
515 | // move the label so it is "centerd" horizontally... | 515 | // move the label so it is "centerd" horizontally... |
516 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); | 516 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); |
517 | lblDesc->show(); | 517 | lblDesc->show(); |
518 | } | 518 | } |
519 | 519 | ||
520 | void DateBookWeek::slotHideEvent() | 520 | void DateBookWeek::slotHideEvent() |
521 | { | 521 | { |
522 | tHide->start( 2000, true ); | 522 | tHide->start( 2000, true ); |
523 | } | 523 | } |
524 | 524 | ||
525 | void DateBookWeek::setStartViewTime( int startHere ) | 525 | void DateBookWeek::setStartViewTime( int startHere ) |
526 | { | 526 | { |
527 | startTime = startHere; | 527 | startTime = startHere; |
528 | view->moveToHour( startTime ); | 528 | view->moveToHour( startTime ); |
529 | } | 529 | } |
530 | 530 | ||
531 | int DateBookWeek::startViewTime() const | 531 | int DateBookWeek::startViewTime() const |
532 | { | 532 | { |
533 | return startTime; | 533 | return startTime; |
534 | } | 534 | } |
535 | 535 | ||
536 | void DateBookWeek::redraw() | 536 | void DateBookWeek::redraw() |
537 | { | 537 | { |
538 | getEvents(); | 538 | getEvents(); |
539 | } | 539 | } |
540 | 540 | ||
541 | void DateBookWeek::slotYearChanged( int y ) | 541 | void DateBookWeek::slotYearChanged( int y ) |
542 | { | 542 | { |
543 | int totWeek; | 543 | int totWeek; |
544 | QDate d( y, 12, 31 ); | 544 | QDate d( y, 12, 31 ); |
545 | int throwAway; | 545 | int throwAway; |
546 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | 546 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
547 | while ( totWeek == 1 ) { | 547 | while ( totWeek == 1 ) { |
548 | d = d.addDays( -1 ); | 548 | d = d.addDays( -1 ); |
549 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | 549 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
550 | } | 550 | } |
551 | } | 551 | } |
552 | 552 | ||
553 | void DateBookWeek::slotWeekChanged( bool onMonday ) | 553 | void DateBookWeek::slotWeekChanged( bool onMonday ) |
554 | { | 554 | { |
555 | bStartOnMonday = onMonday; | 555 | bStartOnMonday = onMonday; |
556 | view->setStartOfWeek( bStartOnMonday ); | 556 | view->setStartOfWeek( bStartOnMonday ); |
557 | header->setStartOfWeek( bStartOnMonday ); | 557 | header->setStartOfWeek( bStartOnMonday ); |
558 | redraw(); | 558 | redraw(); |
559 | } | 559 | } |
560 | 560 | ||
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp index eaa9730..c237b2d 100644 --- a/core/pim/datebook/datebookweekheaderimpl.cpp +++ b/core/pim/datebook/datebookweekheaderimpl.cpp | |||
@@ -1,120 +1,120 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "datebookweekheaderimpl.h" | 20 | #include "datebookweekheaderimpl.h" |
21 | #include "datebookweek.h" | 21 | #include "datebookweek.h" |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/datebookmonth.h> | 23 | #include <qpe/datebookmonth.h> |
24 | 24 | ||
25 | #include <qtoolbutton.h> | 25 | #include <qtoolbutton.h> |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the | 28 | * Constructs a DateBookWeekHeader which is a child of 'parent', with the |
29 | * name 'name' and widget flags set to 'f' | 29 | * name 'name' and widget flags set to 'f' |
30 | */ | 30 | */ |
31 | DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) | 31 | DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) |
32 | : DateBookWeekHeaderBase( parent, name, fl ), | 32 | : DateBookWeekHeaderBase( parent, name, fl ), |
33 | bStartOnMonday( startOnMonday ) | 33 | bStartOnMonday( startOnMonday ) |
34 | { | 34 | { |
35 | setBackgroundMode( PaletteButton ); | 35 | setBackgroundMode( PaletteButton ); |
36 | labelDate->setBackgroundMode( PaletteButton ); | 36 | labelDate->setBackgroundMode( PaletteButton ); |
37 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | 37 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); |
38 | backweek->setPixmap( Resource::loadPixmap("back") ); | 38 | backweek->setPixmap( Resource::loadPixmap("back") ); |
39 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | 39 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); |
40 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | 40 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); |
41 | } | 41 | } |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * Destroys the object and frees any allocated resources | 44 | * Destroys the object and frees any allocated resources |
45 | */ | 45 | */ |
46 | DateBookWeekHeader::~DateBookWeekHeader() | 46 | DateBookWeekHeader::~DateBookWeekHeader() |
47 | { | 47 | { |
48 | // no need to delete child widgets, Qt does it all for us | 48 | // no need to delete child widgets, Qt does it all for us |
49 | } | 49 | } |
50 | 50 | ||
51 | void DateBookWeekHeader::pickDate() | 51 | void DateBookWeekHeader::pickDate() |
52 | { | 52 | { |
53 | static QPopupMenu *m1 = 0; | 53 | static QPopupMenu *m1 = 0; |
54 | static DateBookMonth *picker = 0; | 54 | static DateBookMonth *picker = 0; |
55 | if ( !m1 ) { | 55 | if ( !m1 ) { |
56 | m1 = new QPopupMenu( this ); | 56 | m1 = new QPopupMenu( this ); |
57 | picker = new DateBookMonth( m1, 0, TRUE ); | 57 | picker = new DateBookMonth( m1, 0, TRUE ); |
58 | m1->insertItem( picker ); | 58 | m1->insertItem( picker ); |
59 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) ); | 59 | connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) ); |
60 | // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); | 60 | // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); |
61 | } | 61 | } |
62 | picker->setDate( date.year(), date.month(), date.day() ); | 62 | picker->setDate( date.year(), date.month(), date.day() ); |
63 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | 63 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
64 | picker->setFocus(); | 64 | picker->setFocus(); |
65 | } | 65 | } |
66 | 66 | ||
67 | void DateBookWeekHeader::nextMonth() | 67 | void DateBookWeekHeader::nextMonth() |
68 | { | 68 | { |
69 | qWarning("nextMonth() " ); | 69 | qWarning("nextMonth() " ); |
70 | setDate(date.addDays(28)); | 70 | setDate(date.addDays(28)); |
71 | } | 71 | } |
72 | void DateBookWeekHeader::prevMonth() | 72 | void DateBookWeekHeader::prevMonth() |
73 | { | 73 | { |
74 | qWarning("prevMonth() " ); | 74 | qWarning("prevMonth() " ); |
75 | setDate(date.addDays(-28)); | 75 | setDate(date.addDays(-28)); |
76 | } | 76 | } |
77 | void DateBookWeekHeader::nextWeek() | 77 | void DateBookWeekHeader::nextWeek() |
78 | { | 78 | { |
79 | qWarning("nextWeek() " ); | 79 | qWarning("nextWeek() " ); |
80 | setDate(date.addDays(7)); | 80 | setDate(date.addDays(7)); |
81 | } | 81 | } |
82 | void DateBookWeekHeader::prevWeek() | 82 | void DateBookWeekHeader::prevWeek() |
83 | { | 83 | { |
84 | qWarning("prevWeek() "); | 84 | qWarning("prevWeek() "); |
85 | setDate(date.addDays(-7)); | 85 | setDate(date.addDays(-7)); |
86 | } | 86 | } |
87 | 87 | ||
88 | void DateBookWeekHeader::setDate( int y, int m, int d ) | 88 | void DateBookWeekHeader::setDate( int y, int m, int d ) |
89 | { | 89 | { |
90 | setDate(QDate(y,m,d)); | 90 | setDate(QDate(y,m,d)); |
91 | } | 91 | } |
92 | 92 | ||
93 | void DateBookWeekHeader::setDate(const QDate &d) { | 93 | void DateBookWeekHeader::setDate(const QDate &d) { |
94 | int year,week,dayofweek; | 94 | int year,week,dayofweek; |
95 | date=d; | 95 | date=d; |
96 | dayofweek=d.dayOfWeek(); | 96 | dayofweek=d.dayOfWeek(); |
97 | if(bStartOnMonday) | 97 | if(bStartOnMonday) |
98 | dayofweek--; | 98 | dayofweek--; |
99 | else if( dayofweek == 7 ) | 99 | else if( dayofweek == 7 ) |
100 | // we already have the right day -7 would lead to the current week.. | 100 | // we already have the right day -7 would lead to the current week.. |
101 | dayofweek = 0; | 101 | dayofweek = 0; |
102 | 102 | ||
103 | date=date.addDays(-dayofweek); | 103 | date=date.addDays(-dayofweek); |
104 | calcWeek(date,week,year,bStartOnMonday); | 104 | calcWeek(date,week,year,bStartOnMonday); |
105 | QDate start=date; | 105 | QDate start=date; |
106 | QDate stop=start.addDays(6); | 106 | QDate stop=start.addDays(6); |
107 | labelDate->setText( QString::number(start.day()) + "." + | 107 | labelDate->setText( QString::number(start.day()) + "." + |
108 | Calendar::nameOfMonth( start.month()) + "-" + | 108 | Calendar::nameOfMonth( start.month()) + "-" + |
109 | QString::number(stop.day()) + "." + | 109 | QString::number(stop.day()) + "." + |
110 | Calendar::nameOfMonth( stop.month()) +" ("+ | 110 | Calendar::nameOfMonth( stop.month()) +" ("+ |
111 | tr("w")+":"+QString::number( week ) +")"); | 111 | tr("w")+":"+QString::number( week ) +")"); |
112 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | 112 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! |
113 | emit dateChanged(date); | 113 | emit dateChanged(date); |
114 | } | 114 | } |
115 | 115 | ||
116 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) | 116 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) |
117 | { | 117 | { |
118 | bStartOnMonday = onMonday; | 118 | bStartOnMonday = onMonday; |
119 | setDate( date ); | 119 | setDate( date ); |
120 | } | 120 | } |
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 42a1753..af40143 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -1,394 +1,394 @@ | |||
1 | #include "datebookweeklst.h" | 1 | #include "datebookweeklst.h" |
2 | 2 | ||
3 | 3 | ||
4 | #include "datebook.h" | 4 | #include "datebook.h" |
5 | 5 | ||
6 | #include <qpe/datebookmonth.h> | 6 | #include <qpe/datebookmonth.h> |
7 | #include <qpe/config.h> | 7 | #include <qpe/config.h> |
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | 9 | ||
10 | #include <qlayout.h> | 10 | #include <qlayout.h> |
11 | #include <qtoolbutton.h> | 11 | #include <qtoolbutton.h> |
12 | #include <qtl.h> | 12 | #include <qtl.h> |
13 | 13 | ||
14 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); | 14 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); |
15 | 15 | ||
16 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) | 16 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) |
17 | : DateBookWeekLstHeaderBase(parent, name, fl) | 17 | : DateBookWeekLstHeaderBase(parent, name, fl) |
18 | { | 18 | { |
19 | setBackgroundMode( PaletteButton ); | 19 | setBackgroundMode( PaletteButton ); |
20 | labelDate->setBackgroundMode( PaletteButton ); | 20 | labelDate->setBackgroundMode( PaletteButton ); |
21 | forwardweek->setBackgroundMode( PaletteButton ); | 21 | forwardweek->setBackgroundMode( PaletteButton ); |
22 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); | 22 | forwardweek->setPixmap( Resource::loadPixmap("forward") ); |
23 | forwardmonth->setBackgroundMode( PaletteButton ); | 23 | forwardmonth->setBackgroundMode( PaletteButton ); |
24 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); | 24 | forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); |
25 | backweek->setBackgroundMode( PaletteButton ); | 25 | backweek->setBackgroundMode( PaletteButton ); |
26 | backweek->setPixmap( Resource::loadPixmap("back") ); | 26 | backweek->setPixmap( Resource::loadPixmap("back") ); |
27 | backmonth->setBackgroundMode( PaletteButton ); | 27 | backmonth->setBackgroundMode( PaletteButton ); |
28 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); | 28 | backmonth->setPixmap( Resource::loadPixmap("fastback") ); |
29 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); | 29 | DateBookWeekLstHeaderBaseLayout->setSpacing(0); |
30 | DateBookWeekLstHeaderBaseLayout->setMargin(0); | 30 | DateBookWeekLstHeaderBaseLayout->setMargin(0); |
31 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); | 31 | //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); |
32 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 32 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
33 | 33 | ||
34 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); | 34 | connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); |
35 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); | 35 | connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); |
36 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); | 36 | connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); |
37 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); | 37 | connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); |
38 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); | 38 | connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); |
39 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); | 39 | connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); |
40 | bStartOnMonday=onM; | 40 | bStartOnMonday=onM; |
41 | } | 41 | } |
42 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 42 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
43 | 43 | ||
44 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 44 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
45 | int year,week,dayofweek; | 45 | int year,week,dayofweek; |
46 | date=d; | 46 | date=d; |
47 | dayofweek=d.dayOfWeek(); | 47 | dayofweek=d.dayOfWeek(); |
48 | if(bStartOnMonday) | 48 | if(bStartOnMonday) |
49 | dayofweek--; | 49 | dayofweek--; |
50 | else if( dayofweek == 7 ) | 50 | else if( dayofweek == 7 ) |
51 | /* we already have the right day -7 would lead to the same week */ | 51 | /* we already have the right day -7 would lead to the same week */ |
52 | dayofweek = 0; | 52 | dayofweek = 0; |
53 | 53 | ||
54 | date=date.addDays(-dayofweek); | 54 | date=date.addDays(-dayofweek); |
55 | 55 | ||
56 | calcWeek(date,week,year,bStartOnMonday); | 56 | calcWeek(date,week,year,bStartOnMonday); |
57 | QDate start=date; | 57 | QDate start=date; |
58 | QDate stop=start.addDays(6); | 58 | QDate stop=start.addDays(6); |
59 | labelDate->setText( QString::number(start.day()) + "." + | 59 | labelDate->setText( QString::number(start.day()) + "." + |
60 | Calendar::nameOfMonth( start.month() ) + "-" + | 60 | Calendar::nameOfMonth( start.month() ) + "-" + |
61 | QString::number(stop.day()) + "." + | 61 | QString::number(stop.day()) + "." + |
62 | Calendar::nameOfMonth( stop.month()) +" ("+ | 62 | Calendar::nameOfMonth( stop.month()) +" ("+ |
63 | tr("w")+":"+QString::number( week ) +")"); | 63 | tr("w")+":"+QString::number( week ) +")"); |
64 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! | 64 | date = d; // bugfix: 0001126 - date has to be the selected date, not monday! |
65 | emit dateChanged(date); | 65 | emit dateChanged(date); |
66 | } | 66 | } |
67 | 67 | ||
68 | void DateBookWeekLstHeader::pickDate() { | 68 | void DateBookWeekLstHeader::pickDate() { |
69 | static QPopupMenu *m1 = 0; | 69 | static QPopupMenu *m1 = 0; |
70 | static DateBookMonth *picker = 0; | 70 | static DateBookMonth *picker = 0; |
71 | if ( !m1 ) { | 71 | if ( !m1 ) { |
72 | m1 = new QPopupMenu( this ); | 72 | m1 = new QPopupMenu( this ); |
73 | picker = new DateBookMonth( m1, 0, TRUE ); | 73 | picker = new DateBookMonth( m1, 0, TRUE ); |
74 | m1->insertItem( picker ); | 74 | m1->insertItem( picker ); |
75 | connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); | 75 | connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) ); |
76 | //connect( m1, SIGNAL( aboutToHide() ), | 76 | //connect( m1, SIGNAL( aboutToHide() ), |
77 | //this, SLOT( gotHide() ) ); | 77 | //this, SLOT( gotHide() ) ); |
78 | } | 78 | } |
79 | picker->setDate( date.year(), date.month(), date.day() ); | 79 | picker->setDate( date.year(), date.month(), date.day() ); |
80 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); | 80 | m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); |
81 | picker->setFocus(); | 81 | picker->setFocus(); |
82 | } | 82 | } |
83 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 83 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { |
84 | setDate(QDate(y,m,d)); | 84 | setDate(QDate(y,m,d)); |
85 | } | 85 | } |
86 | 86 | ||
87 | void DateBookWeekLstHeader::nextWeek() { | 87 | void DateBookWeekLstHeader::nextWeek() { |
88 | setDate(date.addDays(7)); | 88 | setDate(date.addDays(7)); |
89 | } | 89 | } |
90 | void DateBookWeekLstHeader::prevWeek() { | 90 | void DateBookWeekLstHeader::prevWeek() { |
91 | setDate(date.addDays(-7)); | 91 | setDate(date.addDays(-7)); |
92 | } | 92 | } |
93 | void DateBookWeekLstHeader::nextMonth() | 93 | void DateBookWeekLstHeader::nextMonth() |
94 | { | 94 | { |
95 | setDate(date.addDays(28)); | 95 | setDate(date.addDays(28)); |
96 | } | 96 | } |
97 | void DateBookWeekLstHeader::prevMonth() | 97 | void DateBookWeekLstHeader::prevMonth() |
98 | { | 98 | { |
99 | setDate(date.addDays(-28)); | 99 | setDate(date.addDays(-28)); |
100 | } | 100 | } |
101 | 101 | ||
102 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | 102 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, |
103 | QWidget* parent, | 103 | QWidget* parent, |
104 | const char* name, | 104 | const char* name, |
105 | WFlags fl ) | 105 | WFlags fl ) |
106 | : DateBookWeekLstDayHdrBase(parent, name, fl) { | 106 | : DateBookWeekLstDayHdrBase(parent, name, fl) { |
107 | 107 | ||
108 | date=d; | 108 | date=d; |
109 | 109 | ||
110 | static const QString wdays=tr("MTWTFSSM", "Week days"); | 110 | static const QString wdays=tr("MTWTFSSM", "Week days"); |
111 | char day=wdays[d.dayOfWeek()-1]; | 111 | char day=wdays[d.dayOfWeek()-1]; |
112 | 112 | ||
113 | //dont use dayOfWeek() to save space ! | 113 | //dont use dayOfWeek() to save space ! |
114 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); | 114 | label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); |
115 | 115 | ||
116 | add->setText("+"); | 116 | add->setText("+"); |
117 | 117 | ||
118 | if (d == QDate::currentDate()) { | 118 | if (d == QDate::currentDate()) { |
119 | QPalette pal=label->palette(); | 119 | QPalette pal=label->palette(); |
120 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); | 120 | pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); |
121 | label->setPalette(pal); | 121 | label->setPalette(pal); |
122 | 122 | ||
123 | /* | 123 | /* |
124 | QFont f=label->font(); | 124 | QFont f=label->font(); |
125 | f.setItalic(true); | 125 | f.setItalic(true); |
126 | label->setFont(f); | 126 | label->setFont(f); |
127 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); | 127 | label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); |
128 | */ | 128 | */ |
129 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday | 129 | } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday |
130 | QPalette pal=label->palette(); | 130 | QPalette pal=label->palette(); |
131 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); | 131 | pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); |
132 | label->setPalette(pal); | 132 | label->setPalette(pal); |
133 | } | 133 | } |
134 | 134 | ||
135 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); | 135 | connect (label, SIGNAL(clicked()), this, SLOT(showDay())); |
136 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); | 136 | connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); |
137 | } | 137 | } |
138 | 138 | ||
139 | void DateBookWeekLstDayHdr::showDay() { | 139 | void DateBookWeekLstDayHdr::showDay() { |
140 | emit showDate(date.year(), date.month(), date.day()); | 140 | emit showDate(date.year(), date.month(), date.day()); |
141 | } | 141 | } |
142 | 142 | ||
143 | void DateBookWeekLstDayHdr::newEvent() { | 143 | void DateBookWeekLstDayHdr::newEvent() { |
144 | QDateTime start, stop; | 144 | QDateTime start, stop; |
145 | start=stop=date; | 145 | start=stop=date; |
146 | start.setTime(QTime(10,0)); | 146 | start.setTime(QTime(10,0)); |
147 | stop.setTime(QTime(12,0)); | 147 | stop.setTime(QTime(12,0)); |
148 | 148 | ||
149 | emit addEvent(start,stop,"",0); | 149 | emit addEvent(start,stop,"",0); |
150 | } | 150 | } |
151 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 151 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, |
152 | int weeklistviewconfig, | 152 | int weeklistviewconfig, |
153 | QWidget* parent, | 153 | QWidget* parent, |
154 | const char* name, | 154 | const char* name, |
155 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | 155 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) |
156 | { | 156 | { |
157 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | 157 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", |
158 | QString s,start,middle,end,day; | 158 | QString s,start,middle,end,day; |
159 | 159 | ||
160 | qDebug("weeklistviewconfig=%d",weeklistviewconfig); | 160 | qDebug("weeklistviewconfig=%d",weeklistviewconfig); |
161 | if(weeklistviewconfig==NONE) {// No times displayed. | 161 | if(weeklistviewconfig==NONE) {// No times displayed. |
162 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 162 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
163 | // middle.sprintf("<--->"); | 163 | // middle.sprintf("<--->"); |
164 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 164 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); |
165 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 165 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); |
166 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. | 166 | } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. |
167 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 167 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
168 | middle.sprintf(" |---"); | 168 | middle.sprintf(" |---"); |
169 | end.sprintf("__|__"); | 169 | end.sprintf("__|__"); |
170 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 170 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
171 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. | 171 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. |
172 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 172 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
173 | middle.sprintf("<--->"); | 173 | middle.sprintf("<--->"); |
174 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 174 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); |
175 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 175 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); |
176 | } | 176 | } |
177 | 177 | ||
178 | if(ev.event().type() == Event::Normal) { | 178 | if(ev.event().type() == Event::Normal) { |
179 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. | 179 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. |
180 | s=day; | 180 | s=day; |
181 | } else if(ev.startDate()==ev.date()) {// start event. | 181 | } else if(ev.startDate()==ev.date()) {// start event. |
182 | s=start; | 182 | s=start; |
183 | } else if(ev.endDate()==ev.date()) { // end event. | 183 | } else if(ev.endDate()==ev.date()) { // end event. |
184 | s=end; | 184 | s=end; |
185 | } else {// middle day. | 185 | } else {// middle day. |
186 | s=middle; | 186 | s=middle; |
187 | } | 187 | } |
188 | } else { | 188 | } else { |
189 | s=""; | 189 | s=""; |
190 | } | 190 | } |
191 | setText(QString(s) + " " + ev.description()); | 191 | setText(QString(s) + " " + ev.description()); |
192 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 192 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
193 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 193 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
194 | } | 194 | } |
195 | void DateBookWeekLstEvent::editMe() { | 195 | void DateBookWeekLstEvent::editMe() { |
196 | emit editEvent(event.event()); | 196 | emit editEvent(event.event()); |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 200 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, |
201 | const QDate &d, bool onM, | 201 | const QDate &d, bool onM, |
202 | QWidget* parent, | 202 | QWidget* parent, |
203 | const char* name, WFlags fl) | 203 | const char* name, WFlags fl) |
204 | : QWidget( parent, name, fl ) | 204 | : QWidget( parent, name, fl ) |
205 | { | 205 | { |
206 | Config config("DateBook"); | 206 | Config config("DateBook"); |
207 | config.setGroup("Main"); | 207 | config.setGroup("Main"); |
208 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); | 208 | int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); |
209 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); | 209 | qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); |
210 | 210 | ||
211 | bStartOnMonday=onM; | 211 | bStartOnMonday=onM; |
212 | setPalette(white); | 212 | setPalette(white); |
213 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); | 213 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); |
214 | 214 | ||
215 | QVBoxLayout *layout = new QVBoxLayout( this ); | 215 | QVBoxLayout *layout = new QVBoxLayout( this ); |
216 | 216 | ||
217 | qBubbleSort(ev); | 217 | qBubbleSort(ev); |
218 | QValueListIterator<EffectiveEvent> it; | 218 | QValueListIterator<EffectiveEvent> it; |
219 | it=ev.begin(); | 219 | it=ev.begin(); |
220 | 220 | ||
221 | int dayOrder[7]; | 221 | int dayOrder[7]; |
222 | if (bStartOnMonday) { | 222 | if (bStartOnMonday) { |
223 | for (int d=0; d<7; d++) dayOrder[d]=d+1; | 223 | for (int d=0; d<7; d++) dayOrder[d]=d+1; |
224 | } else { | 224 | } else { |
225 | for (int d=0; d<7; d++) dayOrder[d]=d; | 225 | for (int d=0; d<7; d++) dayOrder[d]=d; |
226 | dayOrder[0]=7; | 226 | dayOrder[0]=7; |
227 | } | 227 | } |
228 | 228 | ||
229 | // Calculate offset to first day of week. | 229 | // Calculate offset to first day of week. |
230 | int dayoffset=d.dayOfWeek(); | 230 | int dayoffset=d.dayOfWeek(); |
231 | if(bStartOnMonday) dayoffset--; | 231 | if(bStartOnMonday) dayoffset--; |
232 | else if( dayoffset == 7 ) dayoffset = 0; | 232 | else if( dayoffset == 7 ) dayoffset = 0; |
233 | 233 | ||
234 | for (int i=0; i<7; i++) { | 234 | for (int i=0; i<7; i++) { |
235 | // Header | 235 | // Header |
236 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); | 236 | DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); |
237 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 237 | connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
238 | connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 238 | connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
239 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 239 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
240 | layout->addWidget(hdr); | 240 | layout->addWidget(hdr); |
241 | 241 | ||
242 | // Events | 242 | // Events |
243 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { | 243 | while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { |
244 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. | 244 | if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. |
245 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); | 245 | DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); |
246 | layout->addWidget(l); | 246 | layout->addWidget(l); |
247 | connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 247 | connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
248 | } | 248 | } |
249 | it++; | 249 | it++; |
250 | } | 250 | } |
251 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 251 | layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | DateBookWeekLstView::~DateBookWeekLstView(){} | 254 | DateBookWeekLstView::~DateBookWeekLstView(){} |
255 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 255 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
256 | 256 | ||
257 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 257 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, |
258 | QValueList<EffectiveEvent> &ev2, | 258 | QValueList<EffectiveEvent> &ev2, |
259 | QDate &d, bool onM, | 259 | QDate &d, bool onM, |
260 | QWidget* parent, | 260 | QWidget* parent, |
261 | const char* name, WFlags fl) | 261 | const char* name, WFlags fl) |
262 | : QWidget( parent, name, fl ) | 262 | : QWidget( parent, name, fl ) |
263 | { | 263 | { |
264 | QHBoxLayout *layout = new QHBoxLayout( this ); | 264 | QHBoxLayout *layout = new QHBoxLayout( this ); |
265 | 265 | ||
266 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); | 266 | DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); |
267 | layout->addWidget(w); | 267 | layout->addWidget(w); |
268 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 268 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
269 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 269 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
270 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), | 270 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
271 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 271 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
272 | 272 | ||
273 | 273 | ||
274 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); | 274 | w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); |
275 | layout->addWidget(w); | 275 | layout->addWidget(w); |
276 | connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 276 | connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
277 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 277 | connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
278 | connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 278 | connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
279 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 279 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
280 | } | 280 | } |
281 | 281 | ||
282 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 282 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, |
283 | QWidget *parent, | 283 | QWidget *parent, |
284 | const char *name ) | 284 | const char *name ) |
285 | : QWidget( parent, name ), | 285 | : QWidget( parent, name ), |
286 | db( newDB ), | 286 | db( newDB ), |
287 | startTime( 0 ), | 287 | startTime( 0 ), |
288 | ampm( ap ), | 288 | ampm( ap ), |
289 | bStartOnMonday(onM) | 289 | bStartOnMonday(onM) |
290 | { | 290 | { |
291 | setFocusPolicy(StrongFocus); | 291 | setFocusPolicy(StrongFocus); |
292 | layout = new QVBoxLayout( this ); | 292 | layout = new QVBoxLayout( this ); |
293 | layout->setMargin(0); | 293 | layout->setMargin(0); |
294 | 294 | ||
295 | header=new DateBookWeekLstHeader(onM, this); | 295 | header=new DateBookWeekLstHeader(onM, this); |
296 | layout->addWidget( header ); | 296 | layout->addWidget( header ); |
297 | connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &))); | 297 | connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&))); |
298 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); | 298 | connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); |
299 | 299 | ||
300 | scroll=new QScrollView(this); | 300 | scroll=new QScrollView(this); |
301 | scroll->setResizePolicy(QScrollView::AutoOneFit); | 301 | scroll->setResizePolicy(QScrollView::AutoOneFit); |
302 | layout->addWidget(scroll); | 302 | layout->addWidget(scroll); |
303 | 303 | ||
304 | view=NULL; | 304 | view=NULL; |
305 | Config config("DateBook"); | 305 | Config config("DateBook"); |
306 | config.setGroup("Main"); | 306 | config.setGroup("Main"); |
307 | dbl=config.readBoolEntry("weeklst_dbl", false); | 307 | dbl=config.readBoolEntry("weeklst_dbl", false); |
308 | header->dbl->setOn(dbl); | 308 | header->dbl->setOn(dbl); |
309 | } | 309 | } |
310 | DateBookWeekLst::~DateBookWeekLst(){ | 310 | DateBookWeekLst::~DateBookWeekLst(){ |
311 | Config config("DateBook"); | 311 | Config config("DateBook"); |
312 | config.setGroup("Main"); | 312 | config.setGroup("Main"); |
313 | config.writeEntry("weeklst_dbl", dbl); | 313 | config.writeEntry("weeklst_dbl", dbl); |
314 | } | 314 | } |
315 | 315 | ||
316 | void DateBookWeekLst::setDate(const QDate &d) { | 316 | void DateBookWeekLst::setDate(const QDate &d) { |
317 | bdate=d; | 317 | bdate=d; |
318 | header->setDate(d); | 318 | header->setDate(d); |
319 | } | 319 | } |
320 | 320 | ||
321 | void DateBookWeekLst::setDbl(bool on) { | 321 | void DateBookWeekLst::setDbl(bool on) { |
322 | dbl=on; | 322 | dbl=on; |
323 | redraw(); | 323 | redraw(); |
324 | } | 324 | } |
325 | void DateBookWeekLst::redraw() {getEvents();} | 325 | void DateBookWeekLst::redraw() {getEvents();} |
326 | 326 | ||
327 | QDate DateBookWeekLst::date() { | 327 | QDate DateBookWeekLst::date() { |
328 | return bdate; | 328 | return bdate; |
329 | } | 329 | } |
330 | 330 | ||
331 | // return the date at the beginning of the week... | 331 | // return the date at the beginning of the week... |
332 | // copied from DateBookWeek | 332 | // copied from DateBookWeek |
333 | QDate DateBookWeekLst::weekDate() const | 333 | QDate DateBookWeekLst::weekDate() const |
334 | { | 334 | { |
335 | QDate d=bdate; | 335 | QDate d=bdate; |
336 | 336 | ||
337 | // Calculate offset to first day of week. | 337 | // Calculate offset to first day of week. |
338 | int dayoffset=d.dayOfWeek(); | 338 | int dayoffset=d.dayOfWeek(); |
339 | if(bStartOnMonday) dayoffset--; | 339 | if(bStartOnMonday) dayoffset--; |
340 | else if( dayoffset == 7 ) | 340 | else if( dayoffset == 7 ) |
341 | dayoffset = 0; | 341 | dayoffset = 0; |
342 | 342 | ||
343 | return d.addDays(-dayoffset); | 343 | return d.addDays(-dayoffset); |
344 | } | 344 | } |
345 | 345 | ||
346 | void DateBookWeekLst::getEvents() { | 346 | void DateBookWeekLst::getEvents() { |
347 | QDate start = weekDate(); //date(); | 347 | QDate start = weekDate(); //date(); |
348 | QDate stop = start.addDays(6); | 348 | QDate stop = start.addDays(6); |
349 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); | 349 | QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); |
350 | 350 | ||
351 | if (view) delete view; | 351 | if (view) delete view; |
352 | if (dbl) { | 352 | if (dbl) { |
353 | QDate start2=start.addDays(7); | 353 | QDate start2=start.addDays(7); |
354 | stop=start2.addDays(6); | 354 | stop=start2.addDays(6); |
355 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); | 355 | QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); |
356 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); | 356 | view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); |
357 | } else { | 357 | } else { |
358 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); | 358 | view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); |
359 | } | 359 | } |
360 | 360 | ||
361 | connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); | 361 | connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); |
362 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); | 362 | connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); |
363 | connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), | 363 | connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), |
364 | this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); | 364 | this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); |
365 | 365 | ||
366 | scroll->addChild(view); | 366 | scroll->addChild(view); |
367 | view->show(); | 367 | view->show(); |
368 | scroll->updateScrollBars(); | 368 | scroll->updateScrollBars(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 371 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
372 | bdate=newdate; | 372 | bdate=newdate; |
373 | getEvents(); | 373 | getEvents(); |
374 | } | 374 | } |
375 | 375 | ||
376 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 376 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) |
377 | { | 377 | { |
378 | switch(e->key()) { | 378 | switch(e->key()) { |
379 | case Key_Up: | 379 | case Key_Up: |
380 | scroll->scrollBy(0, -20); | 380 | scroll->scrollBy(0, -20); |
381 | break; | 381 | break; |
382 | case Key_Down: | 382 | case Key_Down: |
383 | scroll->scrollBy(0, 20); | 383 | scroll->scrollBy(0, 20); |
384 | break; | 384 | break; |
385 | case Key_Left: | 385 | case Key_Left: |
386 | header->prevWeek(); | 386 | header->prevWeek(); |
387 | break; | 387 | break; |
388 | case Key_Right: | 388 | case Key_Right: |
389 | header->nextWeek(); | 389 | header->nextWeek(); |
390 | break; | 390 | break; |
391 | default: | 391 | default: |
392 | e->ignore(); | 392 | e->ignore(); |
393 | } | 393 | } |
394 | } | 394 | } |
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index 018bb5a..57bcd89 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp | |||
@@ -1,407 +1,407 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "dateentryimpl.h" | 21 | #include "dateentryimpl.h" |
22 | #include "repeatentry.h" | 22 | #include "repeatentry.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/categoryselect.h> | 25 | #include <qpe/categoryselect.h> |
26 | #include <qpe/datebookmonth.h> | 26 | #include <qpe/datebookmonth.h> |
27 | #include <qpe/tzselect.h> | 27 | #include <qpe/tzselect.h> |
28 | 28 | ||
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include <qspinbox.h> | 30 | #include <qspinbox.h> |
31 | 31 | ||
32 | #include <opie/otimepicker.h> | 32 | #include <opie/otimepicker.h> |
33 | #include "onoteedit.h" | 33 | #include "onoteedit.h" |
34 | 34 | ||
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <stdio.h> | 36 | #include <stdio.h> |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Constructs a DateEntry which is a child of 'parent', with the | 39 | * Constructs a DateEntry which is a child of 'parent', with the |
40 | * name 'name' and widget flags set to 'f' | 40 | * name 'name' and widget flags set to 'f' |
41 | * | 41 | * |
42 | * The dialog will by default be modeless, unless you set 'modal' to | 42 | * The dialog will by default be modeless, unless you set 'modal' to |
43 | * TRUE to construct a modal dialog. | 43 | * TRUE to construct a modal dialog. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | 46 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, |
47 | const QDateTime &end, bool whichClock, QWidget* parent, | 47 | const QDateTime &end, bool whichClock, QWidget* parent, |
48 | const char* name ) | 48 | const char* name ) |
49 | : DateEntryBase( parent, name ), | 49 | : DateEntryBase( parent, name ), |
50 | ampm( whichClock ), | 50 | ampm( whichClock ), |
51 | startWeekOnMonday( startOnMonday ), | 51 | startWeekOnMonday( startOnMonday ), |
52 | m_showStart(true) | 52 | m_showStart(true) |
53 | { | 53 | { |
54 | init(); | 54 | init(); |
55 | setDates(start,end); | 55 | setDates(start,end); |
56 | setFocusProxy(comboDescription); | 56 | setFocusProxy(comboDescription); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) | 59 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) |
60 | { | 60 | { |
61 | if( ev->type() == QEvent::FocusIn ){ | 61 | if( ev->type() == QEvent::FocusIn ){ |
62 | if( obj == comboStart ){ | 62 | if( obj == comboStart ){ |
63 | timePickerStart->setHour(startTime.hour()); | 63 | timePickerStart->setHour(startTime.hour()); |
64 | timePickerStart->setMinute(startTime.minute()); | 64 | timePickerStart->setMinute(startTime.minute()); |
65 | TimePickerLabel->setText( tr("Start Time" ) ); | 65 | TimePickerLabel->setText( tr("Start Time" ) ); |
66 | m_showStart= true; | 66 | m_showStart= true; |
67 | }else if( obj == comboEnd ){ | 67 | }else if( obj == comboEnd ){ |
68 | timePickerStart->setHour(endTime.hour()); | 68 | timePickerStart->setHour(endTime.hour()); |
69 | timePickerStart->setMinute(endTime.minute()); | 69 | timePickerStart->setMinute(endTime.minute()); |
70 | TimePickerLabel->setText( tr("End Time") ); | 70 | TimePickerLabel->setText( tr("End Time") ); |
71 | m_showStart = false; | 71 | m_showStart = false; |
72 | } | 72 | } |
73 | } else if( ev->type() == QEvent::FocusOut ){ | 73 | } else if( ev->type() == QEvent::FocusOut ){ |
74 | // if( obj == comboEnd ){ | 74 | // if( obj == comboEnd ){ |
75 | // QString s; | 75 | // QString s; |
76 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); | 76 | // s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); |
77 | // comboEnd->setText(s); | 77 | // comboEnd->setText(s); |
78 | // } | 78 | // } |
79 | // else if( obj == comboStart ){ | 79 | // else if( obj == comboStart ){ |
80 | // QString s; | 80 | // QString s; |
81 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); | 81 | // s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); |
82 | // comboStart->setText(s); | 82 | // comboStart->setText(s); |
83 | // } | 83 | // } |
84 | } | 84 | } |
85 | 85 | ||
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | 88 | ||
89 | static void addOrPick( QComboBox* combo, const QString& t ) | 89 | static void addOrPick( QComboBox* combo, const QString& t ) |
90 | { | 90 | { |
91 | // Pick an item if one excists | 91 | // Pick an item if one excists |
92 | for (int i=0; i<combo->count(); i++) { | 92 | for (int i=0; i<combo->count(); i++) { |
93 | if ( combo->text(i) == t ) { | 93 | if ( combo->text(i) == t ) { |
94 | combo->setCurrentItem(i); | 94 | combo->setCurrentItem(i); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | // Else add one | 99 | // Else add one |
100 | combo->insertItem(t); | 100 | combo->insertItem(t); |
101 | combo->setCurrentItem(combo->count()-1); | 101 | combo->setCurrentItem(combo->count()-1); |
102 | } | 102 | } |
103 | 103 | ||
104 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 104 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, |
105 | QWidget* parent, const char* name ) | 105 | QWidget* parent, const char* name ) |
106 | : DateEntryBase( parent, name ), | 106 | : DateEntryBase( parent, name ), |
107 | ampm( whichClock ), | 107 | ampm( whichClock ), |
108 | startWeekOnMonday( startOnMonday ), | 108 | startWeekOnMonday( startOnMonday ), |
109 | m_showStart(true) | 109 | m_showStart(true) |
110 | 110 | ||
111 | { | 111 | { |
112 | init(); | 112 | init(); |
113 | setDates(event.start(),event.end()); | 113 | setDates(event.start(),event.end()); |
114 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); | 114 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); |
115 | if(!event.description().isEmpty()) | 115 | if(!event.description().isEmpty()) |
116 | addOrPick( comboDescription, event.description() ); | 116 | addOrPick( comboDescription, event.description() ); |
117 | if(!event.location().isEmpty()) | 117 | if(!event.location().isEmpty()) |
118 | addOrPick( comboLocation, event.location() ); | 118 | addOrPick( comboLocation, event.location() ); |
119 | checkAlarm->setChecked( event.hasAlarm() ); | 119 | checkAlarm->setChecked( event.hasAlarm() ); |
120 | checkAllDay->setChecked( event.type() == Event::AllDay ); | 120 | checkAllDay->setChecked( event.type() == Event::AllDay ); |
121 | if(!event.notes().isEmpty()) noteStr=event.notes(); | 121 | if(!event.notes().isEmpty()) noteStr=event.notes(); |
122 | else noteStr=""; | 122 | else noteStr=""; |
123 | spinAlarm->setValue(event.alarmTime()); | 123 | spinAlarm->setValue(event.alarmTime()); |
124 | if ( event.alarmSound() != Event::Silent ) | 124 | if ( event.alarmSound() != Event::Silent ) |
125 | comboSound->setCurrentItem( 1 ); | 125 | comboSound->setCurrentItem( 1 ); |
126 | if ( event.hasRepeat() ) { | 126 | if ( event.hasRepeat() ) { |
127 | rp = event.repeatPattern(); | 127 | rp = event.repeatPattern(); |
128 | cmdRepeat->setText( tr("Repeat...") ); | 128 | cmdRepeat->setText( tr("Repeat...") ); |
129 | } | 129 | } |
130 | setRepeatLabel(); | 130 | setRepeatLabel(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | 133 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) |
134 | { | 134 | { |
135 | startDate = s.date(); | 135 | startDate = s.date(); |
136 | endDate = e.date(); | 136 | endDate = e.date(); |
137 | startTime = s.time(); | 137 | startTime = s.time(); |
138 | endTime = e.time(); | 138 | endTime = e.time(); |
139 | 139 | ||
140 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); | 140 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); |
141 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | 141 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); |
142 | 142 | ||
143 | updateTimeEdit(true,true); | 143 | updateTimeEdit(true,true); |
144 | } | 144 | } |
145 | 145 | ||
146 | void DateEntry::updateTimeEdit(bool s, bool e) { | 146 | void DateEntry::updateTimeEdit(bool s, bool e) { |
147 | 147 | ||
148 | // Comboboxes | 148 | // Comboboxes |
149 | QString strStart, strEnd; | 149 | QString strStart, strEnd; |
150 | int shour, ehour; | 150 | int shour, ehour; |
151 | if ( ampm ) { | 151 | if ( ampm ) { |
152 | shour = startTime.hour(); | 152 | shour = startTime.hour(); |
153 | ehour = endTime.hour(); | 153 | ehour = endTime.hour(); |
154 | if ( shour >= 12 ) { | 154 | if ( shour >= 12 ) { |
155 | if ( shour > 12 ) | 155 | if ( shour > 12 ) |
156 | shour -= 12; | 156 | shour -= 12; |
157 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); | 157 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
158 | } else { | 158 | } else { |
159 | if ( shour == 0 ) | 159 | if ( shour == 0 ) |
160 | shour = 12; | 160 | shour = 12; |
161 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); | 161 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
162 | } | 162 | } |
163 | if ( ehour == 24 && endTime.minute() == 0 ) { | 163 | if ( ehour == 24 && endTime.minute() == 0 ) { |
164 | strEnd = "11:59 PM"; // or "midnight" | 164 | strEnd = "11:59 PM"; // or "midnight" |
165 | } else if ( ehour >= 12 ) { | 165 | } else if ( ehour >= 12 ) { |
166 | if ( ehour > 12 ) | 166 | if ( ehour > 12 ) |
167 | ehour -= 12; | 167 | ehour -= 12; |
168 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); | 168 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
169 | } else { | 169 | } else { |
170 | if ( ehour == 0 ) | 170 | if ( ehour == 0 ) |
171 | ehour = 12; | 171 | ehour = 12; |
172 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); | 172 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
173 | } | 173 | } |
174 | } else { | 174 | } else { |
175 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); | 175 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
176 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); | 176 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
177 | } | 177 | } |
178 | 178 | ||
179 | if (s) comboStart->setText(strStart); | 179 | if (s) comboStart->setText(strStart); |
180 | if (e) comboEnd->setText(strEnd); | 180 | if (e) comboEnd->setText(strEnd); |
181 | } | 181 | } |
182 | 182 | ||
183 | void DateEntry::init() | 183 | void DateEntry::init() |
184 | { | 184 | { |
185 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); | 185 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); |
186 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); | 186 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); |
187 | 187 | ||
188 | initCombos(); | 188 | initCombos(); |
189 | QPopupMenu *m1 = new QPopupMenu( this ); | 189 | QPopupMenu *m1 = new QPopupMenu( this ); |
190 | startPicker = new DateBookMonth( m1, 0, TRUE ); | 190 | startPicker = new DateBookMonth( m1, 0, TRUE ); |
191 | m1->insertItem( startPicker ); | 191 | m1->insertItem( startPicker ); |
192 | buttonStart->setPopup( m1 ); | 192 | buttonStart->setPopup( m1 ); |
193 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 193 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), |
194 | this, SLOT( startDateChanged( int, int, int ) ) ); | 194 | this, SLOT( startDateChanged(int,int,int) ) ); |
195 | 195 | ||
196 | //Let start button change both start and end dates | 196 | //Let start button change both start and end dates |
197 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 197 | connect( startPicker, SIGNAL( dateClicked(int,int,int) ), |
198 | this, SLOT( endDateChanged( int, int, int ) ) ); | 198 | this, SLOT( endDateChanged(int,int,int) ) ); |
199 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 199 | connect( qApp, SIGNAL( clockChanged(bool) ), |
200 | this, SLOT( slotChangeClock( bool ) ) ); | 200 | this, SLOT( slotChangeClock(bool) ) ); |
201 | connect( qApp, SIGNAL(weekChanged(bool)), | 201 | connect( qApp, SIGNAL(weekChanged(bool)), |
202 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 202 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
203 | 203 | ||
204 | connect( editNote, SIGNAL(clicked()), | 204 | connect( editNote, SIGNAL(clicked()), |
205 | this, SLOT(slotEditNote()) ); | 205 | this, SLOT(slotEditNote()) ); |
206 | 206 | ||
207 | QPopupMenu *m2 = new QPopupMenu( this ); | 207 | QPopupMenu *m2 = new QPopupMenu( this ); |
208 | endPicker = new DateBookMonth( m2, 0, TRUE ); | 208 | endPicker = new DateBookMonth( m2, 0, TRUE ); |
209 | m2->insertItem( endPicker ); | 209 | m2->insertItem( endPicker ); |
210 | buttonEnd->setPopup( m2 ); | 210 | buttonEnd->setPopup( m2 ); |
211 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), | 211 | connect( endPicker, SIGNAL( dateClicked(int,int,int) ), |
212 | this, SLOT( endDateChanged( int, int, int ) ) ); | 212 | this, SLOT( endDateChanged(int,int,int) ) ); |
213 | 213 | ||
214 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), | 214 | connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ), |
215 | this, SLOT( startTimePicked(const QTime &) )); | 215 | this, SLOT( startTimePicked(const QTime&) )); |
216 | // install eventFilters | 216 | // install eventFilters |
217 | comboEnd->installEventFilter( this ); | 217 | comboEnd->installEventFilter( this ); |
218 | comboStart->installEventFilter( this ); | 218 | comboStart->installEventFilter( this ); |
219 | } | 219 | } |
220 | 220 | ||
221 | /* | 221 | /* |
222 | * Destroys the object and frees any allocated resources | 222 | * Destroys the object and frees any allocated resources |
223 | */ | 223 | */ |
224 | DateEntry::~DateEntry() | 224 | DateEntry::~DateEntry() |
225 | { | 225 | { |
226 | // no need to delete child widgets, Qt does it all for us | 226 | // no need to delete child widgets, Qt does it all for us |
227 | //cout << "Del: " << comboStart->currentText() << endl; | 227 | //cout << "Del: " << comboStart->currentText() << endl; |
228 | } | 228 | } |
229 | 229 | ||
230 | /* | 230 | /* |
231 | * public slot | 231 | * public slot |
232 | */ | 232 | */ |
233 | 233 | ||
234 | void DateEntry::slotEditNote() { | 234 | void DateEntry::slotEditNote() { |
235 | QString s; | 235 | QString s; |
236 | s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; | 236 | s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; |
237 | // s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); | 237 | // s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); |
238 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, | 238 | NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, |
239 | this,0,TRUE); | 239 | this,0,TRUE); |
240 | 240 | ||
241 | if ( QPEApplication::execDialog( ¬eDlg ) ) { | 241 | if ( QPEApplication::execDialog( ¬eDlg ) ) { |
242 | noteStr=noteDlg.note->text(); | 242 | noteStr=noteDlg.note->text(); |
243 | } | 243 | } |
244 | 244 | ||
245 | } | 245 | } |
246 | 246 | ||
247 | void DateEntry::endDateChanged( int y, int m, int d ) | 247 | void DateEntry::endDateChanged( int y, int m, int d ) |
248 | { | 248 | { |
249 | endDate.setYMD( y, m, d ); | 249 | endDate.setYMD( y, m, d ); |
250 | if ( endDate < startDate ) { | 250 | if ( endDate < startDate ) { |
251 | endDate = startDate; | 251 | endDate = startDate; |
252 | } | 252 | } |
253 | 253 | ||
254 | buttonEnd->setText( TimeString::shortDate( endDate ) ); | 254 | buttonEnd->setText( TimeString::shortDate( endDate ) ); |
255 | 255 | ||
256 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); | 256 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); |
257 | } | 257 | } |
258 | 258 | ||
259 | static QTime parseTime( const QString& s, bool ampm ) | 259 | static QTime parseTime( const QString& s, bool ampm ) |
260 | { | 260 | { |
261 | QTime tmpTime; | 261 | QTime tmpTime; |
262 | QStringList l = QStringList::split( ':', s ); | 262 | QStringList l = QStringList::split( ':', s ); |
263 | int hour = l[0].toInt(); | 263 | int hour = l[0].toInt(); |
264 | if ( ampm ) { | 264 | if ( ampm ) { |
265 | int i=0; | 265 | int i=0; |
266 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') | 266 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') |
267 | i++; | 267 | i++; |
268 | QString digits = l[1].left(i); | 268 | QString digits = l[1].left(i); |
269 | if ( l[1].contains( "PM", FALSE ) ) { | 269 | if ( l[1].contains( "PM", FALSE ) ) { |
270 | if ( hour != 12 ) | 270 | if ( hour != 12 ) |
271 | hour += 12; | 271 | hour += 12; |
272 | } else { | 272 | } else { |
273 | if ( hour == 12 ) | 273 | if ( hour == 12 ) |
274 | hour = 0; | 274 | hour = 0; |
275 | } | 275 | } |
276 | l[1] = digits; | 276 | l[1] = digits; |
277 | } | 277 | } |
278 | int minute = l[1].toInt(); | 278 | int minute = l[1].toInt(); |
279 | if ( minute > 59 ) | 279 | if ( minute > 59 ) |
280 | minute = 59; | 280 | minute = 59; |
281 | else if ( minute < 0 ) | 281 | else if ( minute < 0 ) |
282 | minute = 0; | 282 | minute = 0; |
283 | if ( hour > 23 ) { | 283 | if ( hour > 23 ) { |
284 | hour = 23; | 284 | hour = 23; |
285 | minute = 59; | 285 | minute = 59; |
286 | } else if ( hour < 0 ) | 286 | } else if ( hour < 0 ) |
287 | hour = 0; | 287 | hour = 0; |
288 | tmpTime.setHMS( hour, minute, 0 ); | 288 | tmpTime.setHMS( hour, minute, 0 ); |
289 | return tmpTime; | 289 | return tmpTime; |
290 | } | 290 | } |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * public slot | 293 | * public slot |
294 | */ | 294 | */ |
295 | void DateEntry::endTimeChanged( const QString &s ) | 295 | void DateEntry::endTimeChanged( const QString &s ) |
296 | { | 296 | { |
297 | endTimeChanged( parseTime(s,ampm) ); | 297 | endTimeChanged( parseTime(s,ampm) ); |
298 | } | 298 | } |
299 | 299 | ||
300 | void DateEntry::endTimeChanged( const QTime &t ) { | 300 | void DateEntry::endTimeChanged( const QTime &t ) { |
301 | if ( endDate > startDate || t >= startTime ) { | 301 | if ( endDate > startDate || t >= startTime ) { |
302 | endTime = t; | 302 | endTime = t; |
303 | } else { | 303 | } else { |
304 | endTime = startTime; | 304 | endTime = startTime; |
305 | //comboEnd->setCurrentItem( comboStart->currentItem() ); | 305 | //comboEnd->setCurrentItem( comboStart->currentItem() ); |
306 | } | 306 | } |
307 | timePickerStart->setHour(endTime.hour()); | 307 | timePickerStart->setHour(endTime.hour()); |
308 | timePickerStart->setMinute(endTime.minute()); | 308 | timePickerStart->setMinute(endTime.minute()); |
309 | } | 309 | } |
310 | 310 | ||
311 | /* | 311 | /* |
312 | * public slot | 312 | * public slot |
313 | */ | 313 | */ |
314 | void DateEntry::startDateChanged( int y, int m, int d ) | 314 | void DateEntry::startDateChanged( int y, int m, int d ) |
315 | { | 315 | { |
316 | QDate prev = startDate; | 316 | QDate prev = startDate; |
317 | startDate.setYMD( y, m, d ); | 317 | startDate.setYMD( y, m, d ); |
318 | if ( rp.type == Event::Weekly && | 318 | if ( rp.type == Event::Weekly && |
319 | startDate.dayOfWeek() != prev.dayOfWeek() ) { | 319 | startDate.dayOfWeek() != prev.dayOfWeek() ) { |
320 | // if we change the start of a weekly repeating event | 320 | // if we change the start of a weekly repeating event |
321 | // set the repeating day appropriately | 321 | // set the repeating day appropriately |
322 | char mask = 1 << (prev.dayOfWeek()-1); | 322 | char mask = 1 << (prev.dayOfWeek()-1); |
323 | rp.days &= (~mask); | 323 | rp.days &= (~mask); |
324 | rp.days |= 1 << (startDate.dayOfWeek()-1); | 324 | rp.days |= 1 << (startDate.dayOfWeek()-1); |
325 | } | 325 | } |
326 | 326 | ||
327 | buttonStart->setText( TimeString::shortDate( startDate ) ); | 327 | buttonStart->setText( TimeString::shortDate( startDate ) ); |
328 | 328 | ||
329 | // our pickers must be reset... | 329 | // our pickers must be reset... |
330 | startPicker->setDate( y, m, d ); | 330 | startPicker->setDate( y, m, d ); |
331 | endPicker->setDate( y, m, d ); | 331 | endPicker->setDate( y, m, d ); |
332 | } | 332 | } |
333 | 333 | ||
334 | /* | 334 | /* |
335 | * public slot | 335 | * public slot |
336 | */ | 336 | */ |
337 | void DateEntry::startTimeEdited( const QString &s ) | 337 | void DateEntry::startTimeEdited( const QString &s ) |
338 | { | 338 | { |
339 | startTimeChanged(parseTime(s,ampm)); | 339 | startTimeChanged(parseTime(s,ampm)); |
340 | updateTimeEdit(false,true); | 340 | updateTimeEdit(false,true); |
341 | timePickerStart->setHour(startTime.hour()); | 341 | timePickerStart->setHour(startTime.hour()); |
342 | timePickerStart->setMinute(startTime.minute()); | 342 | timePickerStart->setMinute(startTime.minute()); |
343 | } | 343 | } |
344 | 344 | ||
345 | void DateEntry::startTimeChanged( const QTime &t ) | 345 | void DateEntry::startTimeChanged( const QTime &t ) |
346 | { | 346 | { |
347 | int duration=startTime.secsTo(endTime); | 347 | int duration=startTime.secsTo(endTime); |
348 | startTime = t; | 348 | startTime = t; |
349 | endTime=t.addSecs(duration); | 349 | endTime=t.addSecs(duration); |
350 | } | 350 | } |
351 | void DateEntry::startTimePicked( const QTime &t ) { | 351 | void DateEntry::startTimePicked( const QTime &t ) { |
352 | if(m_showStart ){ | 352 | if(m_showStart ){ |
353 | startTimeChanged(t); | 353 | startTimeChanged(t); |
354 | updateTimeEdit(true,true); | 354 | updateTimeEdit(true,true); |
355 | }else{ | 355 | }else{ |
356 | endTimeChanged(t); | 356 | endTimeChanged(t); |
357 | updateTimeEdit(false, true ); | 357 | updateTimeEdit(false, true ); |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | /* | 361 | /* |
362 | * public slot | 362 | * public slot |
363 | */ | 363 | */ |
364 | void DateEntry::typeChanged( const QString &s ) | 364 | void DateEntry::typeChanged( const QString &s ) |
365 | { | 365 | { |
366 | bool b = s != "All Day"; | 366 | bool b = s != "All Day"; |
367 | buttonStart->setEnabled( b ); | 367 | buttonStart->setEnabled( b ); |
368 | comboStart->setEnabled( b ); | 368 | comboStart->setEnabled( b ); |
369 | comboEnd->setEnabled( b ); | 369 | comboEnd->setEnabled( b ); |
370 | } | 370 | } |
371 | 371 | ||
372 | void DateEntry::slotRepeat() | 372 | void DateEntry::slotRepeat() |
373 | { | 373 | { |
374 | // Work around for compiler Bug.. | 374 | // Work around for compiler Bug.. |
375 | RepeatEntry *e; | 375 | RepeatEntry *e; |
376 | 376 | ||
377 | // it is better in my opinion to just grab this from the mother, | 377 | // it is better in my opinion to just grab this from the mother, |
378 | // since, this dialog doesn't need to keep track of it... | 378 | // since, this dialog doesn't need to keep track of it... |
379 | if ( rp.type != Event::NoRepeat ) | 379 | if ( rp.type != Event::NoRepeat ) |
380 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); | 380 | e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); |
381 | else | 381 | else |
382 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); | 382 | e = new RepeatEntry( startWeekOnMonday, startDate, this ); |
383 | 383 | ||
384 | if ( QPEApplication::execDialog( e ) ) { | 384 | if ( QPEApplication::execDialog( e ) ) { |
385 | rp = e->repeatPattern(); | 385 | rp = e->repeatPattern(); |
386 | setRepeatLabel(); | 386 | setRepeatLabel(); |
387 | } | 387 | } |
388 | // deleting sounds like a nice idea... | 388 | // deleting sounds like a nice idea... |
389 | delete e; | 389 | delete e; |
390 | } | 390 | } |
391 | 391 | ||
392 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) | 392 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) |
393 | { | 393 | { |
394 | startWeekOnMonday = onMonday; | 394 | startWeekOnMonday = onMonday; |
395 | } | 395 | } |
396 | 396 | ||
397 | Event DateEntry::event() | 397 | Event DateEntry::event() |
398 | { | 398 | { |
399 | Event ev; | 399 | Event ev; |
400 | Event::SoundTypeChoice st; | 400 | Event::SoundTypeChoice st; |
401 | ev.setDescription( comboDescription->currentText() ); | 401 | ev.setDescription( comboDescription->currentText() ); |
402 | ev.setLocation( comboLocation->currentText() ); | 402 | ev.setLocation( comboLocation->currentText() ); |
403 | ev.setCategories( comboCategory->currentCategories() ); | 403 | ev.setCategories( comboCategory->currentCategories() ); |
404 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); | 404 | ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); |
405 | if ( startDate > endDate ) { | 405 | if ( startDate > endDate ) { |
406 | QDate tmp = endDate; | 406 | QDate tmp = endDate; |
407 | endDate = startDate; | 407 | endDate = startDate; |
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp index 7cf36da..04c3cf3 100644 --- a/core/pim/datebook/repeatentry.cpp +++ b/core/pim/datebook/repeatentry.cpp | |||
@@ -170,386 +170,386 @@ Event::RepeatPattern RepeatEntry::repeatPattern() | |||
170 | break; | 170 | break; |
171 | case WEEK: | 171 | case WEEK: |
172 | rpTmp.type = Event::Weekly; | 172 | rpTmp.type = Event::Weekly; |
173 | rpTmp.days = 0; | 173 | rpTmp.days = 0; |
174 | int day; | 174 | int day; |
175 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 175 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
176 | if ( (*itExtra)->isOn() ) { | 176 | if ( (*itExtra)->isOn() ) { |
177 | if ( startWeekOnMonday ) | 177 | if ( startWeekOnMonday ) |
178 | rpTmp.days |= day; | 178 | rpTmp.days |= day; |
179 | else { | 179 | else { |
180 | if ( day == 1 ) | 180 | if ( day == 1 ) |
181 | rpTmp.days |= Event::SUN; | 181 | rpTmp.days |= Event::SUN; |
182 | else | 182 | else |
183 | rpTmp.days |= day >> 1; | 183 | rpTmp.days |= day >> 1; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | } | 186 | } |
187 | break; | 187 | break; |
188 | case MONTH: | 188 | case MONTH: |
189 | if ( cmdExtra1->isOn() ) | 189 | if ( cmdExtra1->isOn() ) |
190 | rpTmp.type = Event::MonthlyDay; | 190 | rpTmp.type = Event::MonthlyDay; |
191 | else if ( cmdExtra2->isOn() ) | 191 | else if ( cmdExtra2->isOn() ) |
192 | rpTmp.type = Event::MonthlyDate; | 192 | rpTmp.type = Event::MonthlyDate; |
193 | // figure out the montly day... | 193 | // figure out the montly day... |
194 | rpTmp.position = week( start ); | 194 | rpTmp.position = week( start ); |
195 | break; | 195 | break; |
196 | case YEAR: | 196 | case YEAR: |
197 | rpTmp.type = Event::Yearly; | 197 | rpTmp.type = Event::Yearly; |
198 | break; | 198 | break; |
199 | } | 199 | } |
200 | break; // no need to keep looking! | 200 | break; // no need to keep looking! |
201 | } | 201 | } |
202 | } | 202 | } |
203 | rpTmp.frequency = spinFreq->value(); | 203 | rpTmp.frequency = spinFreq->value(); |
204 | rpTmp.hasEndDate = !chkNoEnd->isChecked(); | 204 | rpTmp.hasEndDate = !chkNoEnd->isChecked(); |
205 | if ( rpTmp.hasEndDate ) { | 205 | if ( rpTmp.hasEndDate ) { |
206 | rpTmp.setEndDate( end ); | 206 | rpTmp.setEndDate( end ); |
207 | } | 207 | } |
208 | // timestamp it... | 208 | // timestamp it... |
209 | rpTmp.createTime = time( NULL ); | 209 | rpTmp.createTime = time( NULL ); |
210 | return rpTmp; | 210 | return rpTmp; |
211 | } | 211 | } |
212 | 212 | ||
213 | void RepeatEntry::slotSetRType( int rtype ) | 213 | void RepeatEntry::slotSetRType( int rtype ) |
214 | { | 214 | { |
215 | // now call the right function based on the type... | 215 | // now call the right function based on the type... |
216 | currInterval = static_cast<repeatButtons>(rtype); | 216 | currInterval = static_cast<repeatButtons>(rtype); |
217 | switch ( currInterval ) { | 217 | switch ( currInterval ) { |
218 | case NONE: | 218 | case NONE: |
219 | setupNone(); | 219 | setupNone(); |
220 | break; | 220 | break; |
221 | case DAY: | 221 | case DAY: |
222 | setupDaily(); | 222 | setupDaily(); |
223 | break; | 223 | break; |
224 | case WEEK: | 224 | case WEEK: |
225 | setupWeekly(); | 225 | setupWeekly(); |
226 | slotWeekLabel(); | 226 | slotWeekLabel(); |
227 | break; | 227 | break; |
228 | case MONTH: | 228 | case MONTH: |
229 | setupMonthly(); | 229 | setupMonthly(); |
230 | cmdExtra2->setOn( TRUE ); | 230 | cmdExtra2->setOn( TRUE ); |
231 | slotMonthLabel( 1 ); | 231 | slotMonthLabel( 1 ); |
232 | break; | 232 | break; |
233 | case YEAR: | 233 | case YEAR: |
234 | setupYearly(); | 234 | setupYearly(); |
235 | break; | 235 | break; |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | void RepeatEntry::setupNone() | 239 | void RepeatEntry::setupNone() |
240 | { | 240 | { |
241 | lblRepeat->setText( tr("No Repeat") ); | 241 | lblRepeat->setText( tr("No Repeat") ); |
242 | lblVar1->hide(); | 242 | lblVar1->hide(); |
243 | lblVar2->hide(); | 243 | lblVar2->hide(); |
244 | hideExtras(); | 244 | hideExtras(); |
245 | cmdEnd->hide(); | 245 | cmdEnd->hide(); |
246 | lblFreq->hide(); | 246 | lblFreq->hide(); |
247 | lblEvery->hide(); | 247 | lblEvery->hide(); |
248 | lblFreq->hide(); | 248 | lblFreq->hide(); |
249 | spinFreq->hide(); | 249 | spinFreq->hide(); |
250 | lblEnd->hide(); | 250 | lblEnd->hide(); |
251 | lblWeekVar->hide(); | 251 | lblWeekVar->hide(); |
252 | } | 252 | } |
253 | 253 | ||
254 | void RepeatEntry::setupDaily() | 254 | void RepeatEntry::setupDaily() |
255 | { | 255 | { |
256 | hideExtras(); | 256 | hideExtras(); |
257 | lblWeekVar->hide(); | 257 | lblWeekVar->hide(); |
258 | spinFreq->setValue( 1 ); | 258 | spinFreq->setValue( 1 ); |
259 | lblFreq->setText( tr("day(s)") ); | 259 | lblFreq->setText( tr("day(s)") ); |
260 | lblVar2->show(); | 260 | lblVar2->show(); |
261 | showRepeatStuff(); | 261 | showRepeatStuff(); |
262 | lblRepeat->setText( strDayTemplate ); | 262 | lblRepeat->setText( strDayTemplate ); |
263 | setupRepeatLabel( 1 ); | 263 | setupRepeatLabel( 1 ); |
264 | } | 264 | } |
265 | 265 | ||
266 | void RepeatEntry::setupWeekly() | 266 | void RepeatEntry::setupWeekly() |
267 | { | 267 | { |
268 | // reshow the buttons... | 268 | // reshow the buttons... |
269 | fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") ); | 269 | fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") ); |
270 | fraExtra->setExclusive( FALSE ); | 270 | fraExtra->setExclusive( FALSE ); |
271 | fraExtra->show(); | 271 | fraExtra->show(); |
272 | if ( startWeekOnMonday ) { | 272 | if ( startWeekOnMonday ) { |
273 | cmdExtra1->setText( RepeatEntryBase::tr("Mon") ); | 273 | cmdExtra1->setText( RepeatEntryBase::tr("Mon") ); |
274 | cmdExtra2->setText( RepeatEntryBase::tr("Tue") ); | 274 | cmdExtra2->setText( RepeatEntryBase::tr("Tue") ); |
275 | cmdExtra3->setText( RepeatEntryBase::tr("Wed") ); | 275 | cmdExtra3->setText( RepeatEntryBase::tr("Wed") ); |
276 | cmdExtra4->setText( RepeatEntryBase::tr("Thu") ); | 276 | cmdExtra4->setText( RepeatEntryBase::tr("Thu") ); |
277 | cmdExtra5->setText( RepeatEntryBase::tr("Fri") ); | 277 | cmdExtra5->setText( RepeatEntryBase::tr("Fri") ); |
278 | cmdExtra6->setText( RepeatEntryBase::tr("Sat") ); | 278 | cmdExtra6->setText( RepeatEntryBase::tr("Sat") ); |
279 | cmdExtra7->setText( RepeatEntryBase::tr("Sun") ); | 279 | cmdExtra7->setText( RepeatEntryBase::tr("Sun") ); |
280 | } else { | 280 | } else { |
281 | cmdExtra1->setText( RepeatEntryBase::tr("Sun") ); | 281 | cmdExtra1->setText( RepeatEntryBase::tr("Sun") ); |
282 | cmdExtra2->setText( RepeatEntryBase::tr("Mon") ); | 282 | cmdExtra2->setText( RepeatEntryBase::tr("Mon") ); |
283 | cmdExtra3->setText( RepeatEntryBase::tr("Tue") ); | 283 | cmdExtra3->setText( RepeatEntryBase::tr("Tue") ); |
284 | cmdExtra4->setText( RepeatEntryBase::tr("Wed") ); | 284 | cmdExtra4->setText( RepeatEntryBase::tr("Wed") ); |
285 | cmdExtra5->setText( RepeatEntryBase::tr("Thu") ); | 285 | cmdExtra5->setText( RepeatEntryBase::tr("Thu") ); |
286 | cmdExtra6->setText( RepeatEntryBase::tr("Fri") ); | 286 | cmdExtra6->setText( RepeatEntryBase::tr("Fri") ); |
287 | cmdExtra7->setText( RepeatEntryBase::tr("Sat") ); | 287 | cmdExtra7->setText( RepeatEntryBase::tr("Sat") ); |
288 | } | 288 | } |
289 | // I hope clustering these improve performance.... | 289 | // I hope clustering these improve performance.... |
290 | cmdExtra1->setOn( FALSE ); | 290 | cmdExtra1->setOn( FALSE ); |
291 | cmdExtra2->setOn( FALSE ); | 291 | cmdExtra2->setOn( FALSE ); |
292 | cmdExtra3->setOn( FALSE ); | 292 | cmdExtra3->setOn( FALSE ); |
293 | cmdExtra4->setOn( FALSE ); | 293 | cmdExtra4->setOn( FALSE ); |
294 | cmdExtra5->setOn( FALSE ); | 294 | cmdExtra5->setOn( FALSE ); |
295 | cmdExtra6->setOn( FALSE ); | 295 | cmdExtra6->setOn( FALSE ); |
296 | cmdExtra7->setOn( FALSE ); | 296 | cmdExtra7->setOn( FALSE ); |
297 | 297 | ||
298 | cmdExtra1->show(); | 298 | cmdExtra1->show(); |
299 | cmdExtra2->show(); | 299 | cmdExtra2->show(); |
300 | cmdExtra3->show(); | 300 | cmdExtra3->show(); |
301 | cmdExtra4->show(); | 301 | cmdExtra4->show(); |
302 | cmdExtra5->show(); | 302 | cmdExtra5->show(); |
303 | cmdExtra6->show(); | 303 | cmdExtra6->show(); |
304 | cmdExtra7->show(); | 304 | cmdExtra7->show(); |
305 | 305 | ||
306 | lblWeekVar->show(); | 306 | lblWeekVar->show(); |
307 | spinFreq->setValue( 1 ); | 307 | spinFreq->setValue( 1 ); |
308 | // might as well set the day too... | 308 | // might as well set the day too... |
309 | if ( startWeekOnMonday ) { | 309 | if ( startWeekOnMonday ) { |
310 | fraExtra->setButton( start.dayOfWeek() - 1 ); | 310 | fraExtra->setButton( start.dayOfWeek() - 1 ); |
311 | } else { | 311 | } else { |
312 | fraExtra->setButton( start.dayOfWeek() % 7 ); | 312 | fraExtra->setButton( start.dayOfWeek() % 7 ); |
313 | } | 313 | } |
314 | lblFreq->setText( tr("week(s)") ); | 314 | lblFreq->setText( tr("week(s)") ); |
315 | lblVar2->show(); | 315 | lblVar2->show(); |
316 | showRepeatStuff(); | 316 | showRepeatStuff(); |
317 | setupRepeatLabel( 1 ); | 317 | setupRepeatLabel( 1 ); |
318 | } | 318 | } |
319 | 319 | ||
320 | void RepeatEntry::setupMonthly() | 320 | void RepeatEntry::setupMonthly() |
321 | { | 321 | { |
322 | hideExtras(); | 322 | hideExtras(); |
323 | lblWeekVar->hide(); | 323 | lblWeekVar->hide(); |
324 | fraExtra->setTitle( tr("Repeat By") ); | 324 | fraExtra->setTitle( tr("Repeat By") ); |
325 | fraExtra->setExclusive( TRUE ); | 325 | fraExtra->setExclusive( TRUE ); |
326 | fraExtra->show(); | 326 | fraExtra->show(); |
327 | cmdExtra1->setText( tr("Day") ); | 327 | cmdExtra1->setText( tr("Day") ); |
328 | cmdExtra1->show(); | 328 | cmdExtra1->show(); |
329 | cmdExtra2->setText( tr("Date") ); | 329 | cmdExtra2->setText( tr("Date") ); |
330 | cmdExtra2->show(); | 330 | cmdExtra2->show(); |
331 | spinFreq->setValue( 1 ); | 331 | spinFreq->setValue( 1 ); |
332 | lblFreq->setText( tr("month(s)") ); | 332 | lblFreq->setText( tr("month(s)") ); |
333 | lblVar2->show(); | 333 | lblVar2->show(); |
334 | showRepeatStuff(); | 334 | showRepeatStuff(); |
335 | setupRepeatLabel( 1 ); | 335 | setupRepeatLabel( 1 ); |
336 | } | 336 | } |
337 | 337 | ||
338 | void RepeatEntry::setupYearly() | 338 | void RepeatEntry::setupYearly() |
339 | { | 339 | { |
340 | hideExtras(); | 340 | hideExtras(); |
341 | lblWeekVar->hide(); | 341 | lblWeekVar->hide(); |
342 | spinFreq->setValue( 1 ); | 342 | spinFreq->setValue( 1 ); |
343 | lblFreq->setText( tr("year(s)") ); | 343 | lblFreq->setText( tr("year(s)") ); |
344 | lblFreq->show(); | 344 | lblFreq->show(); |
345 | lblFreq->show(); | 345 | lblFreq->show(); |
346 | showRepeatStuff(); | 346 | showRepeatStuff(); |
347 | lblVar2->show(); | 347 | lblVar2->show(); |
348 | QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); | 348 | QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); |
349 | lblRepeat->setText( strEvery ); | 349 | lblRepeat->setText( strEvery ); |
350 | setupRepeatLabel( 1 ); | 350 | setupRepeatLabel( 1 ); |
351 | 351 | ||
352 | } | 352 | } |
353 | 353 | ||
354 | void RepeatEntry::init() | 354 | void RepeatEntry::init() |
355 | { | 355 | { |
356 | QPopupMenu *m1 = new QPopupMenu( this ); | 356 | QPopupMenu *m1 = new QPopupMenu( this ); |
357 | repeatPicker = new DateBookMonth( m1, 0, TRUE ); | 357 | repeatPicker = new DateBookMonth( m1, 0, TRUE ); |
358 | m1->insertItem( repeatPicker ); | 358 | m1->insertItem( repeatPicker ); |
359 | cmdEnd->setPopup( m1 ); | 359 | cmdEnd->setPopup( m1 ); |
360 | cmdEnd->setPopupDelay( 0 ); | 360 | cmdEnd->setPopupDelay( 0 ); |
361 | 361 | ||
362 | QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), | 362 | QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)), |
363 | this, SLOT(endDateChanged(int, int, int)) ); | 363 | this, SLOT(endDateChanged(int,int,int)) ); |
364 | QObject::connect( qApp, SIGNAL(weekChanged(bool)), | 364 | QObject::connect( qApp, SIGNAL(weekChanged(bool)), |
365 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 365 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
366 | 366 | ||
367 | listRTypeButtons.setAutoDelete( TRUE ); | 367 | listRTypeButtons.setAutoDelete( TRUE ); |
368 | listRTypeButtons.append( cmdNone ); | 368 | listRTypeButtons.append( cmdNone ); |
369 | listRTypeButtons.append( cmdDay ); | 369 | listRTypeButtons.append( cmdDay ); |
370 | listRTypeButtons.append( cmdWeek ); | 370 | listRTypeButtons.append( cmdWeek ); |
371 | listRTypeButtons.append( cmdMonth ); | 371 | listRTypeButtons.append( cmdMonth ); |
372 | listRTypeButtons.append( cmdYear ); | 372 | listRTypeButtons.append( cmdYear ); |
373 | 373 | ||
374 | listExtra.setAutoDelete( TRUE ); | 374 | listExtra.setAutoDelete( TRUE ); |
375 | listExtra.append( cmdExtra1 ); | 375 | listExtra.append( cmdExtra1 ); |
376 | listExtra.append( cmdExtra2 ); | 376 | listExtra.append( cmdExtra2 ); |
377 | listExtra.append( cmdExtra3 ); | 377 | listExtra.append( cmdExtra3 ); |
378 | listExtra.append( cmdExtra4 ); | 378 | listExtra.append( cmdExtra4 ); |
379 | listExtra.append( cmdExtra5 ); | 379 | listExtra.append( cmdExtra5 ); |
380 | listExtra.append( cmdExtra6 ); | 380 | listExtra.append( cmdExtra6 ); |
381 | listExtra.append( cmdExtra7 ); | 381 | listExtra.append( cmdExtra7 ); |
382 | } | 382 | } |
383 | 383 | ||
384 | void RepeatEntry::slotNoEnd( bool unused ) | 384 | void RepeatEntry::slotNoEnd( bool unused ) |
385 | { | 385 | { |
386 | // if the item was toggled, then go ahead and set it to the maximum date | 386 | // if the item was toggled, then go ahead and set it to the maximum date |
387 | if ( unused ) { | 387 | if ( unused ) { |
388 | end.setYMD( 3000, 12, 31 ); | 388 | end.setYMD( 3000, 12, 31 ); |
389 | cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); | 389 | cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); |
390 | } else { | 390 | } else { |
391 | end = start; | 391 | end = start; |
392 | cmdEnd->setText( TimeString::shortDate(end) ); | 392 | cmdEnd->setText( TimeString::shortDate(end) ); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | void RepeatEntry::endDateChanged( int y, int m, int d ) | 396 | void RepeatEntry::endDateChanged( int y, int m, int d ) |
397 | { | 397 | { |
398 | end.setYMD( y, m, d ); | 398 | end.setYMD( y, m, d ); |
399 | if ( end < start ) | 399 | if ( end < start ) |
400 | end = start; | 400 | end = start; |
401 | cmdEnd->setText( TimeString::shortDate( end ) ); | 401 | cmdEnd->setText( TimeString::shortDate( end ) ); |
402 | repeatPicker->setDate( end.year(), end.month(), end.day() ); | 402 | repeatPicker->setDate( end.year(), end.month(), end.day() ); |
403 | } | 403 | } |
404 | 404 | ||
405 | void RepeatEntry::setupRepeatLabel( const QString &s ) | 405 | void RepeatEntry::setupRepeatLabel( const QString &s ) |
406 | { | 406 | { |
407 | lblVar1->setText( s ); | 407 | lblVar1->setText( s ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void RepeatEntry::setupRepeatLabel( int x ) | 410 | void RepeatEntry::setupRepeatLabel( int x ) |
411 | { | 411 | { |
412 | // change the spelling based on the value of x | 412 | // change the spelling based on the value of x |
413 | QString strVar2; | 413 | QString strVar2; |
414 | 414 | ||
415 | if ( x > 1 ) | 415 | if ( x > 1 ) |
416 | lblVar1->show(); | 416 | lblVar1->show(); |
417 | else | 417 | else |
418 | lblVar1->hide(); | 418 | lblVar1->hide(); |
419 | 419 | ||
420 | switch ( currInterval ) { | 420 | switch ( currInterval ) { |
421 | case NONE: | 421 | case NONE: |
422 | break; | 422 | break; |
423 | case DAY: | 423 | case DAY: |
424 | if ( x > 1 ) | 424 | if ( x > 1 ) |
425 | strVar2 = tr( "days" ); | 425 | strVar2 = tr( "days" ); |
426 | else | 426 | else |
427 | strVar2 = tr( "day" ); | 427 | strVar2 = tr( "day" ); |
428 | break; | 428 | break; |
429 | case WEEK: | 429 | case WEEK: |
430 | if ( x > 1 ) | 430 | if ( x > 1 ) |
431 | strVar2 = tr( "weeks" ); | 431 | strVar2 = tr( "weeks" ); |
432 | else | 432 | else |
433 | strVar2 = tr( "week" ); | 433 | strVar2 = tr( "week" ); |
434 | break; | 434 | break; |
435 | case MONTH: | 435 | case MONTH: |
436 | if ( x > 1 ) | 436 | if ( x > 1 ) |
437 | strVar2 = RepeatEntryBase::tr( "months" ); | 437 | strVar2 = RepeatEntryBase::tr( "months" ); |
438 | else | 438 | else |
439 | strVar2 = tr( "month" ); | 439 | strVar2 = tr( "month" ); |
440 | break; | 440 | break; |
441 | case YEAR: | 441 | case YEAR: |
442 | if ( x > 1 ) | 442 | if ( x > 1 ) |
443 | strVar2 = RepeatEntryBase::tr( "years" ); | 443 | strVar2 = RepeatEntryBase::tr( "years" ); |
444 | else | 444 | else |
445 | strVar2 = tr( "year" ); | 445 | strVar2 = tr( "year" ); |
446 | break; | 446 | break; |
447 | } | 447 | } |
448 | if ( !strVar2.isNull() ) | 448 | if ( !strVar2.isNull() ) |
449 | lblVar2->setText( strVar2 ); | 449 | lblVar2->setText( strVar2 ); |
450 | } | 450 | } |
451 | 451 | ||
452 | void RepeatEntry::showRepeatStuff() | 452 | void RepeatEntry::showRepeatStuff() |
453 | { | 453 | { |
454 | cmdEnd->show(); | 454 | cmdEnd->show(); |
455 | chkNoEnd->show(); | 455 | chkNoEnd->show(); |
456 | lblFreq->show(); | 456 | lblFreq->show(); |
457 | lblEvery->show(); | 457 | lblEvery->show(); |
458 | lblFreq->show(); | 458 | lblFreq->show(); |
459 | spinFreq->show(); | 459 | spinFreq->show(); |
460 | lblEnd->show(); | 460 | lblEnd->show(); |
461 | lblRepeat->setText( RepeatEntryBase::tr("Every") ); | 461 | lblRepeat->setText( RepeatEntryBase::tr("Every") ); |
462 | } | 462 | } |
463 | 463 | ||
464 | void RepeatEntry::slotWeekLabel() | 464 | void RepeatEntry::slotWeekLabel() |
465 | { | 465 | { |
466 | QString str; | 466 | QString str; |
467 | QListIterator<QToolButton> it( listExtra ); | 467 | QListIterator<QToolButton> it( listExtra ); |
468 | unsigned int i; | 468 | unsigned int i; |
469 | unsigned int keepMe; | 469 | unsigned int keepMe; |
470 | bool bNeedCarriage = FALSE; | 470 | bool bNeedCarriage = FALSE; |
471 | // don't do something we'll regret!!! | 471 | // don't do something we'll regret!!! |
472 | if ( currInterval != WEEK ) | 472 | if ( currInterval != WEEK ) |
473 | return; | 473 | return; |
474 | 474 | ||
475 | if ( startWeekOnMonday ) | 475 | if ( startWeekOnMonday ) |
476 | keepMe = start.dayOfWeek() - 1; | 476 | keepMe = start.dayOfWeek() - 1; |
477 | else | 477 | else |
478 | keepMe = start.dayOfWeek() % 7; | 478 | keepMe = start.dayOfWeek() % 7; |
479 | 479 | ||
480 | QStringList list; | 480 | QStringList list; |
481 | for ( i = 0; *it; ++it, i++ ) { | 481 | for ( i = 0; *it; ++it, i++ ) { |
482 | // a crazy check, if you are repeating weekly, the current day | 482 | // a crazy check, if you are repeating weekly, the current day |
483 | // must be selected!!! | 483 | // must be selected!!! |
484 | if ( i == keepMe && !( (*it)->isOn() ) ) | 484 | if ( i == keepMe && !( (*it)->isOn() ) ) |
485 | (*it)->setOn( TRUE ); | 485 | (*it)->setOn( TRUE ); |
486 | if ( (*it)->isOn() ) { | 486 | if ( (*it)->isOn() ) { |
487 | if ( startWeekOnMonday ) | 487 | if ( startWeekOnMonday ) |
488 | list.append( dayLabel[i] ); | 488 | list.append( dayLabel[i] ); |
489 | else { | 489 | else { |
490 | if ( i == 0 ) | 490 | if ( i == 0 ) |
491 | list.append( dayLabel[6] ); | 491 | list.append( dayLabel[6] ); |
492 | else | 492 | else |
493 | list.append( dayLabel[i - 1] ); | 493 | list.append( dayLabel[i - 1] ); |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } | 496 | } |
497 | QStringList::Iterator itStr; | 497 | QStringList::Iterator itStr; |
498 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { | 498 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { |
499 | if ( i == 3 ) | 499 | if ( i == 3 ) |
500 | bNeedCarriage = TRUE; | 500 | bNeedCarriage = TRUE; |
501 | else | 501 | else |
502 | bNeedCarriage = FALSE; | 502 | bNeedCarriage = FALSE; |
503 | if ( str.isNull() ) | 503 | if ( str.isNull() ) |
504 | str = *itStr; | 504 | str = *itStr; |
505 | else if ( i == list.count() - 1 ) { | 505 | else if ( i == list.count() - 1 ) { |
506 | if ( i < 2 ) | 506 | if ( i < 2 ) |
507 | str += tr(" and ") + *itStr; | 507 | str += tr(" and ") + *itStr; |
508 | else { | 508 | else { |
509 | if ( bNeedCarriage ) | 509 | if ( bNeedCarriage ) |
510 | str += tr( ",\nand " ) + *itStr; | 510 | str += tr( ",\nand " ) + *itStr; |
511 | else | 511 | else |
512 | str += tr( ", and " ) + *itStr; | 512 | str += tr( ", and " ) + *itStr; |
513 | } | 513 | } |
514 | } else { | 514 | } else { |
515 | if ( bNeedCarriage ) | 515 | if ( bNeedCarriage ) |
516 | str += ",\n" + *itStr; | 516 | str += ",\n" + *itStr; |
517 | else | 517 | else |
518 | str += ", " + *itStr; | 518 | str += ", " + *itStr; |
519 | } | 519 | } |
520 | } | 520 | } |
521 | str = str.prepend( tr("on ") ); | 521 | str = str.prepend( tr("on ") ); |
522 | lblWeekVar->setText( str ); | 522 | lblWeekVar->setText( str ); |
523 | } | 523 | } |
524 | 524 | ||
525 | void RepeatEntry::slotMonthLabel( int type ) | 525 | void RepeatEntry::slotMonthLabel( int type ) |
526 | { | 526 | { |
527 | QString str; | 527 | QString str; |
528 | if ( currInterval != MONTH || type > 1 ) | 528 | if ( currInterval != MONTH || type > 1 ) |
529 | return; | 529 | return; |
530 | if ( type == 1 ) | 530 | if ( type == 1 ) |
531 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); | 531 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); |
532 | else | 532 | else |
533 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) | 533 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) |
534 | .arg( dayLabel[start.dayOfWeek() - 1] ); | 534 | .arg( dayLabel[start.dayOfWeek() - 1] ); |
535 | lblRepeat->setText( str ); | 535 | lblRepeat->setText( str ); |
536 | } | 536 | } |
537 | 537 | ||
538 | void RepeatEntry::slotChangeStartOfWeek( bool onMonday ) | 538 | void RepeatEntry::slotChangeStartOfWeek( bool onMonday ) |
539 | { | 539 | { |
540 | startWeekOnMonday = onMonday; | 540 | startWeekOnMonday = onMonday; |
541 | // we need to make this unintrusive as possible... | 541 | // we need to make this unintrusive as possible... |
542 | int saveSpin = spinFreq->value(); | 542 | int saveSpin = spinFreq->value(); |
543 | char days = 0; | 543 | char days = 0; |
544 | int day; | 544 | int day; |
545 | QListIterator<QToolButton> itExtra( listExtra ); | 545 | QListIterator<QToolButton> itExtra( listExtra ); |
546 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 546 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
547 | if ( (*itExtra)->isOn() ) { | 547 | if ( (*itExtra)->isOn() ) { |
548 | if ( !startWeekOnMonday ) | 548 | if ( !startWeekOnMonday ) |
549 | days |= day; | 549 | days |= day; |
550 | else { | 550 | else { |
551 | if ( day == 1 ) | 551 | if ( day == 1 ) |
552 | days |= Event::SUN; | 552 | days |= Event::SUN; |
553 | else | 553 | else |
554 | days |= day >> 1; | 554 | days |= day >> 1; |
555 | } | 555 | } |
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp index 7ff2204..3937796 100644 --- a/core/pim/datebook2/mainwindow.cpp +++ b/core/pim/datebook2/mainwindow.cpp | |||
@@ -1,302 +1,302 @@ | |||
1 | 1 | ||
2 | #include <qcopchannel_qws.h> | 2 | #include <qcopchannel_qws.h> |
3 | #include <qwidgetstack.h> | 3 | #include <qwidgetstack.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtimer.h> | 7 | #include <qtimer.h> |
8 | 8 | ||
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/ir.h> | 10 | #include <qpe/ir.h> |
11 | #include <qmenubar.h> | 11 | #include <qmenubar.h> |
12 | #include <qtoolbar.h> | 12 | #include <qtoolbar.h> |
13 | #include <qpe/qpemessagebox.h> | 13 | #include <qpe/qpemessagebox.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | #include "editor.h" | 16 | #include "editor.h" |
17 | #include "show.h" | 17 | #include "show.h" |
18 | #include "templatemanager.h" | 18 | #include "templatemanager.h" |
19 | #include "bookmanager.h" | 19 | #include "bookmanager.h" |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | 21 | ||
22 | 22 | ||
23 | using namespace Datebook; | 23 | using namespace Datebook; |
24 | 24 | ||
25 | MainWindow::MainWindow() | 25 | MainWindow::MainWindow() |
26 | : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) | 26 | : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) |
27 | { | 27 | { |
28 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 28 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
29 | initUI(); | 29 | initUI(); |
30 | initManagers(); | 30 | initManagers(); |
31 | initView(); | 31 | initView(); |
32 | initConfig(); | 32 | initConfig(); |
33 | 33 | ||
34 | QTimer::singleShot(0, this, SLOT(populate() ) ); | 34 | QTimer::singleShot(0, this, SLOT(populate() ) ); |
35 | 35 | ||
36 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); | 36 | QCopChannel* chan = new QCopChannel( "QPE/System", this ); |
37 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 37 | connect( chan, SIGNAL( received(const QCString&,const QByteArray&) ), |
38 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 38 | this, SLOT( slotReceive(const QCString&,const QByteArray&) ) ); |
39 | 39 | ||
40 | chan = new QCopChannel( "QPE/Datebook", this ); | 40 | chan = new QCopChannel( "QPE/Datebook", this ); |
41 | connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), | 41 | connect( chan, SIGNAL( received(const QCString&,const QByteArray&) ), |
42 | this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); | 42 | this, SLOT( slotReceive(const QCString&,const QByteArray&) ) ); |
43 | } | 43 | } |
44 | MainWindow::~MainWindow() { | 44 | MainWindow::~MainWindow() { |
45 | m_tempMan.save(); | 45 | m_tempMan.save(); |
46 | m_locMan.save(); | 46 | m_locMan.save(); |
47 | m_descMan.save(); | 47 | m_descMan.save(); |
48 | 48 | ||
49 | manager()->save(); | 49 | manager()->save(); |
50 | delete m_manager; | 50 | delete m_manager; |
51 | } | 51 | } |
52 | void MainWindow::doSetDocument( const QString& str ) { | 52 | void MainWindow::doSetDocument( const QString& str ) { |
53 | 53 | ||
54 | } | 54 | } |
55 | void MainWindow::flush() { | 55 | void MainWindow::flush() { |
56 | manager()->save(); | 56 | manager()->save(); |
57 | } | 57 | } |
58 | void MainWindow::reload() { | 58 | void MainWindow::reload() { |
59 | manager()->reload(); | 59 | manager()->reload(); |
60 | } | 60 | } |
61 | int MainWindow::create() { | 61 | int MainWindow::create() { |
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | bool MainWindow::remove( int uid ) { | 64 | bool MainWindow::remove( int uid ) { |
65 | manager()->remove( uid ); | 65 | manager()->remove( uid ); |
66 | return true; | 66 | return true; |
67 | } | 67 | } |
68 | void MainWindow::beam( int uid ) { | 68 | void MainWindow::beam( int uid ) { |
69 | 69 | ||
70 | } | 70 | } |
71 | void MainWindow::show( int uid ) { | 71 | void MainWindow::show( int uid ) { |
72 | 72 | ||
73 | eventShow()->show( manager()->event( uid ) ); | 73 | eventShow()->show( manager()->event( uid ) ); |
74 | } | 74 | } |
75 | void MainWindow::add( const OPimRecord& ad) { | 75 | void MainWindow::add( const OPimRecord& ad) { |
76 | manager()->add( ad ); | 76 | manager()->add( ad ); |
77 | } | 77 | } |
78 | void MainWindow::edit() { | 78 | void MainWindow::edit() { |
79 | edit ( currentView()->currentItem() ); | 79 | edit ( currentView()->currentItem() ); |
80 | } | 80 | } |
81 | void MainWindow::edit( int uid ) { | 81 | void MainWindow::edit( int uid ) { |
82 | 82 | ||
83 | } | 83 | } |
84 | /* | 84 | /* |
85 | * init tool bars layout and so on | 85 | * init tool bars layout and so on |
86 | */ | 86 | */ |
87 | void MainWindow::initUI() { | 87 | void MainWindow::initUI() { |
88 | setToolBarsMovable( false ); | 88 | setToolBarsMovable( false ); |
89 | 89 | ||
90 | m_stack = new QWidgetStack( this ); | 90 | m_stack = new QWidgetStack( this ); |
91 | setCentralWidget( m_stack ); | 91 | setCentralWidget( m_stack ); |
92 | 92 | ||
93 | m_toolBar = new QToolBar( this ); | 93 | m_toolBar = new QToolBar( this ); |
94 | m_toolBar->setHorizontalStretchable( TRUE ); | 94 | m_toolBar->setHorizontalStretchable( TRUE ); |
95 | 95 | ||
96 | QMenuBar* mb = new QMenuBar( m_toolBar ); | 96 | QMenuBar* mb = new QMenuBar( m_toolBar ); |
97 | 97 | ||
98 | m_popView = new QPopupMenu( this ); | 98 | m_popView = new QPopupMenu( this ); |
99 | m_popSetting = new QPopupMenu( this ); | 99 | m_popSetting = new QPopupMenu( this ); |
100 | 100 | ||
101 | mb->insertItem( tr("View"), m_popView ); | 101 | mb->insertItem( tr("View"), m_popView ); |
102 | mb->insertItem( tr("Settings" ), m_popSetting ); | 102 | mb->insertItem( tr("Settings" ), m_popSetting ); |
103 | 103 | ||
104 | m_popTemplate = new QPopupMenu( this ); | 104 | m_popTemplate = new QPopupMenu( this ); |
105 | m_popTemplate->setCheckable( TRUE ); | 105 | m_popTemplate->setCheckable( TRUE ); |
106 | connect( m_popTemplate, SIGNAL(activated(int) ), | 106 | connect( m_popTemplate, SIGNAL(activated(int) ), |
107 | this, SLOT(slotNewFromTemplate(int) ) ); | 107 | this, SLOT(slotNewFromTemplate(int) ) ); |
108 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); | 108 | m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); |
109 | 109 | ||
110 | 110 | ||
111 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), | 111 | QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), |
112 | QString::null, 0, this, 0 ); | 112 | QString::null, 0, this, 0 ); |
113 | a->addTo( m_toolBar ); | 113 | a->addTo( m_toolBar ); |
114 | a->addTo( m_popView ); | 114 | a->addTo( m_popView ); |
115 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); | 115 | connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); |
116 | 116 | ||
117 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), | 117 | a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), |
118 | QString::null, 0, this, 0 ); | 118 | QString::null, 0, this, 0 ); |
119 | a->addTo( m_popView ); | 119 | a->addTo( m_popView ); |
120 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); | 120 | connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); |
121 | 121 | ||
122 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), | 122 | a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), |
123 | QString::null, 0, this, 0 ); | 123 | QString::null, 0, this, 0 ); |
124 | a->addTo( m_toolBar ); | 124 | a->addTo( m_toolBar ); |
125 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); | 125 | connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); |
126 | 126 | ||
127 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), | 127 | a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), |
128 | QString::null, 0, this, 0 ); | 128 | QString::null, 0, this, 0 ); |
129 | a->addTo( m_toolBar ); | 129 | a->addTo( m_toolBar ); |
130 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 130 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
131 | 131 | ||
132 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); | 132 | a = new QAction( tr("Configure"), QString::null, 0, 0 ); |
133 | a->addTo( m_popSetting ); | 133 | a->addTo( m_popSetting ); |
134 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 134 | connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
135 | 135 | ||
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 | } |
156 | void MainWindow::initConfig() { | 156 | void MainWindow::initConfig() { |
157 | 157 | ||
158 | } | 158 | } |
159 | void MainWindow::initView() { | 159 | void MainWindow::initView() { |
160 | 160 | ||
161 | } | 161 | } |
162 | void MainWindow::initManagers() { | 162 | void 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 | } |
171 | void MainWindow::raiseCurrentView() { | 171 | void MainWindow::raiseCurrentView() { |
172 | 172 | ||
173 | } | 173 | } |
174 | /* | 174 | /* |
175 | * populate the view | 175 | * populate the view |
176 | */ | 176 | */ |
177 | void MainWindow::populate() { | 177 | void MainWindow::populate() { |
178 | if (!manager()->isLoaded() ) | 178 | if (!manager()->isLoaded() ) |
179 | manager()->load(); | 179 | manager()->load(); |
180 | } | 180 | } |
181 | void MainWindow::slotGoToNow() { | 181 | void MainWindow::slotGoToNow() { |
182 | 182 | ||
183 | } | 183 | } |
184 | View* MainWindow::currentView() { | 184 | View* MainWindow::currentView() { |
185 | 185 | ||
186 | } | 186 | } |
187 | void MainWindow::slotFind() { | 187 | void MainWindow::slotFind() { |
188 | 188 | ||
189 | } | 189 | } |
190 | void MainWindow::slotConfigure() { | 190 | void MainWindow::slotConfigure() { |
191 | 191 | ||
192 | } | 192 | } |
193 | void MainWindow::slotClockChanged( bool ) { | 193 | void MainWindow::slotClockChanged( bool ) { |
194 | 194 | ||
195 | } | 195 | } |
196 | void MainWindow::slotWeekChanged(bool ) { | 196 | void MainWindow::slotWeekChanged(bool ) { |
197 | 197 | ||
198 | } | 198 | } |
199 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { | 199 | void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { |
200 | 200 | ||
201 | } | 201 | } |
202 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { | 202 | void MainWindow::slotReceive( const QCString&, const QByteArray& ) { |
203 | 203 | ||
204 | } | 204 | } |
205 | BookManager* MainWindow::manager() { | 205 | BookManager* MainWindow::manager() { |
206 | return m_manager; | 206 | return m_manager; |
207 | } | 207 | } |
208 | TemplateManager MainWindow::templateManager() { | 208 | TemplateManager MainWindow::templateManager() { |
209 | return m_tempMan; | 209 | return m_tempMan; |
210 | } | 210 | } |
211 | LocationManager MainWindow::locationManager() { | 211 | LocationManager MainWindow::locationManager() { |
212 | return m_locMan; | 212 | return m_locMan; |
213 | } | 213 | } |
214 | DescriptionManager MainWindow::descriptionManager() { | 214 | DescriptionManager MainWindow::descriptionManager() { |
215 | return m_descMan; | 215 | return m_descMan; |
216 | } | 216 | } |
217 | void MainWindow::setLocationManager( const LocationManager& loc) { | 217 | void MainWindow::setLocationManager( const LocationManager& loc) { |
218 | m_locMan = loc; | 218 | m_locMan = loc; |
219 | } | 219 | } |
220 | void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { | 220 | void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { |
221 | m_descMan = dsc; | 221 | m_descMan = dsc; |
222 | } | 222 | } |
223 | Show* MainWindow::eventShow() { | 223 | Show* MainWindow::eventShow() { |
224 | return m_show; | 224 | return m_show; |
225 | } | 225 | } |
226 | void MainWindow::slotAction( QAction* act ) { | 226 | void MainWindow::slotAction( QAction* act ) { |
227 | 227 | ||
228 | } | 228 | } |
229 | void MainWindow::slotConfigureLocs() { | 229 | void MainWindow::slotConfigureLocs() { |
230 | LocationManagerDialog dlg( locationManager() ); | 230 | LocationManagerDialog dlg( locationManager() ); |
231 | dlg.setCaption( tr("Configure Locations") ); | 231 | dlg.setCaption( tr("Configure Locations") ); |
232 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { | 232 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
233 | setLocationManager( dlg.manager() ); | 233 | setLocationManager( dlg.manager() ); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | void MainWindow::slotConfigureDesc() { | 236 | void MainWindow::slotConfigureDesc() { |
237 | DescriptionManagerDialog dlg( descriptionManager() ); | 237 | DescriptionManagerDialog dlg( descriptionManager() ); |
238 | dlg.setCaption( tr("Configure Descriptions") ); | 238 | dlg.setCaption( tr("Configure Descriptions") ); |
239 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { | 239 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
240 | setDescriptionManager( dlg.manager() ); | 240 | setDescriptionManager( dlg.manager() ); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | void MainWindow::slotConfigureTemp() { | 243 | void MainWindow::slotConfigureTemp() { |
244 | TemplateDialog dlg( templateManager(), editor() ); | 244 | TemplateDialog dlg( templateManager(), editor() ); |
245 | dlg.setCaption( tr("Configure Templates") ); | 245 | dlg.setCaption( tr("Configure Templates") ); |
246 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { | 246 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
247 | m_tempMan = dlg.manager(); | 247 | m_tempMan = dlg.manager(); |
248 | setTemplateMenu(); | 248 | setTemplateMenu(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | void MainWindow::hideShow() { | 251 | void MainWindow::hideShow() { |
252 | 252 | ||
253 | } | 253 | } |
254 | void MainWindow::viewPopup(int ) { | 254 | void MainWindow::viewPopup(int ) { |
255 | 255 | ||
256 | } | 256 | } |
257 | void MainWindow::viewAdd(const QDate& ) { | 257 | void MainWindow::viewAdd(const QDate& ) { |
258 | 258 | ||
259 | } | 259 | } |
260 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { | 260 | void MainWindow::viewAdd( const QDateTime&, const QDateTime& ) { |
261 | 261 | ||
262 | } | 262 | } |
263 | bool MainWindow::viewAP()const{ | 263 | bool MainWindow::viewAP()const{ |
264 | } | 264 | } |
265 | bool MainWindow::viewStartMonday()const { | 265 | bool MainWindow::viewStartMonday()const { |
266 | 266 | ||
267 | } | 267 | } |
268 | void MainWindow::setTemplateMenu() { | 268 | void MainWindow::setTemplateMenu() { |
269 | m_popTemplate->clear(); | 269 | m_popTemplate->clear(); |
270 | 270 | ||
271 | QStringList list = templateManager().names(); | 271 | QStringList list = templateManager().names(); |
272 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 272 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
273 | m_popTemplate->insertItem( (*it) ); | 273 | m_popTemplate->insertItem( (*it) ); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | /* | 276 | /* |
277 | * get the name of the item with the id id | 277 | * get the name of the item with the id id |
278 | * then ask for an OEvent from the manager | 278 | * then ask for an OEvent from the manager |
279 | */ | 279 | */ |
280 | void MainWindow::slotNewFromTemplate(int id ) { | 280 | void MainWindow::slotNewFromTemplate(int id ) { |
281 | QString name = m_popTemplate->text( id ); | 281 | QString name = m_popTemplate->text( id ); |
282 | 282 | ||
283 | OEvent ev = templateManager().value( name ); | 283 | OEvent ev = templateManager().value( name ); |
284 | 284 | ||
285 | if ( editor()->edit( ev ) ) { | 285 | if ( editor()->edit( ev ) ) { |
286 | ev = editor()->event(); | 286 | ev = editor()->event(); |
287 | ev.setUid( -1 ); | 287 | ev.setUid( -1 ); |
288 | manager()->add( ev ); | 288 | manager()->add( ev ); |
289 | 289 | ||
290 | /* | 290 | /* |
291 | * no we'll find out if the current view | 291 | * no we'll find out if the current view |
292 | * should show the new event | 292 | * should show the new event |
293 | * and then we will ask it to refresh | 293 | * and then we will ask it to refresh |
294 | * FIXME for now we'll call a refresh | 294 | * FIXME for now we'll call a refresh |
295 | */ | 295 | */ |
296 | currentView()->reschedule(); | 296 | currentView()->reschedule(); |
297 | raiseCurrentView(); | 297 | raiseCurrentView(); |
298 | } | 298 | } |
299 | } | 299 | } |
300 | Editor* MainWindow::editor() { | 300 | Editor* MainWindow::editor() { |
301 | return m_edit; | 301 | return m_edit; |
302 | } | 302 | } |
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index bfe95b0..8b6a5df 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -12,306 +12,306 @@ | |||
12 | 12 | ||
13 | #include "olistview.h" | 13 | #include "olistview.h" |
14 | #include "olistviewitem.h" | 14 | #include "olistviewitem.h" |
15 | #include "resultitem.h" | 15 | #include "resultitem.h" |
16 | #include "adresssearch.h" | 16 | #include "adresssearch.h" |
17 | #include "todosearch.h" | 17 | #include "todosearch.h" |
18 | #include "datebooksearch.h" | 18 | #include "datebooksearch.h" |
19 | #include "applnksearch.h" | 19 | #include "applnksearch.h" |
20 | #include "doclnksearch.h" | 20 | #include "doclnksearch.h" |
21 | #include "mainwindow.h" | 21 | #include "mainwindow.h" |
22 | 22 | ||
23 | #include <opie2/owait.h> | 23 | #include <opie2/owait.h> |
24 | 24 | ||
25 | #include <qpe/qpemessagebox.h> | 25 | #include <qpe/qpemessagebox.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | 28 | ||
29 | 29 | ||
30 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | 32 | ||
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qaction.h> | 34 | #include <qaction.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qhbuttongroup.h> | 41 | #include <qhbuttongroup.h> |
42 | #include <qhbox.h> | 42 | #include <qhbox.h> |
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qintdict.h> | 44 | #include <qintdict.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qsignalmapper.h> | 47 | #include <qsignalmapper.h> |
48 | #include <qtextbrowser.h> | 48 | #include <qtextbrowser.h> |
49 | #include <qregexp.h> | 49 | #include <qregexp.h> |
50 | #include <qwhatsthis.h> | 50 | #include <qwhatsthis.h> |
51 | #include <qmenubar.h> | 51 | #include <qmenubar.h> |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | static const char* const image1_data[] = { | 55 | static const char* const image1_data[] = { |
56 | "14 14 3 1", | 56 | "14 14 3 1", |
57 | ". c None", | 57 | ". c None", |
58 | "# c #000000", | 58 | "# c #000000", |
59 | "a c #ff0000", | 59 | "a c #ff0000", |
60 | "..............", | 60 | "..............", |
61 | "..##.......###", | 61 | "..##.......###", |
62 | ".#aa#....##aa#", | 62 | ".#aa#....##aa#", |
63 | "#aaaa#.##aaaa#", | 63 | "#aaaa#.##aaaa#", |
64 | ".##aaa#aaaaa##", | 64 | ".##aaa#aaaaa##", |
65 | "...#aaaaaaa#..", | 65 | "...#aaaaaaa#..", |
66 | "....#aaaaa#...", | 66 | "....#aaaaa#...", |
67 | "...#aaaaa#....", | 67 | "...#aaaaa#....", |
68 | "..#aaaaaaa#...", | 68 | "..#aaaaaaa#...", |
69 | ".#aaaaaaaaa#..", | 69 | ".#aaaaaaaaa#..", |
70 | "#aaaa###aaaa#.", | 70 | "#aaaa###aaaa#.", |
71 | "#aaa#..##aaa#.", | 71 | "#aaa#..##aaa#.", |
72 | "#aaa#...#aa#..", | 72 | "#aaa#...#aa#..", |
73 | ".###.....##..."}; | 73 | ".###.....##..."}; |
74 | 74 | ||
75 | 75 | ||
76 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 76 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
77 | QMainWindow( parent, name, f ), _currentItem(0) | 77 | QMainWindow( parent, name, f ), _currentItem(0) |
78 | { | 78 | { |
79 | setCaption( tr("OSearch") ); | 79 | setCaption( tr("OSearch") ); |
80 | 80 | ||
81 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 81 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
82 | 82 | ||
83 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); | 83 | QFrame *mainFrame = new QFrame( this, "mainFrame" ); |
84 | mainFrame->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 84 | mainFrame->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
85 | 85 | ||
86 | mainLayout = new QVBoxLayout( mainFrame ); | 86 | mainLayout = new QVBoxLayout( mainFrame ); |
87 | mainLayout->setSpacing( 0 ); | 87 | mainLayout->setSpacing( 0 ); |
88 | mainLayout->setMargin( 3 ); | 88 | mainLayout->setMargin( 3 ); |
89 | 89 | ||
90 | resultsList = new OListView( mainFrame ); | 90 | resultsList = new OListView( mainFrame ); |
91 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 91 | resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
92 | mainLayout->addWidget( resultsList ); | 92 | mainLayout->addWidget( resultsList ); |
93 | 93 | ||
94 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); | 94 | detailsFrame = new QFrame( mainFrame, "detailsFrame" ); |
95 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); | 95 | QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); |
96 | richEdit = new QTextView( detailsFrame ); | 96 | richEdit = new QTextView( detailsFrame ); |
97 | QWhatsThis::add( richEdit, tr("The details of the current result") ); | 97 | QWhatsThis::add( richEdit, tr("The details of the current result") ); |
98 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); | 98 | richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); |
99 | detailsLayout->addWidget( richEdit ); | 99 | detailsLayout->addWidget( richEdit ); |
100 | 100 | ||
101 | buttonBox = new QHBox( mainFrame, "Button Box" ); | 101 | buttonBox = new QHBox( mainFrame, "Button Box" ); |
102 | 102 | ||
103 | _buttonCount = 0; | 103 | _buttonCount = 0; |
104 | 104 | ||
105 | mainLayout->addWidget( detailsFrame ); | 105 | mainLayout->addWidget( detailsFrame ); |
106 | mainLayout->addWidget( buttonBox ); | 106 | mainLayout->addWidget( buttonBox ); |
107 | detailsFrame->hide(); | 107 | detailsFrame->hide(); |
108 | buttonBox->hide(); | 108 | buttonBox->hide(); |
109 | 109 | ||
110 | searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); | 110 | searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); |
111 | searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); | 111 | searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); |
112 | searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); | 112 | searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); |
113 | searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); | 113 | searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); |
114 | searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); | 114 | searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); |
115 | 115 | ||
116 | setCentralWidget( mainFrame ); | 116 | setCentralWidget( mainFrame ); |
117 | 117 | ||
118 | popupTimer = new QTimer(); | 118 | popupTimer = new QTimer(); |
119 | searchTimer = new QTimer(); | 119 | searchTimer = new QTimer(); |
120 | 120 | ||
121 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | 121 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); |
122 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); | 122 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); |
123 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | 123 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); |
124 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 124 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
125 | 125 | ||
126 | signalMapper = new QSignalMapper( this ); | 126 | signalMapper = new QSignalMapper( this ); |
127 | 127 | ||
128 | connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); | 128 | connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); |
129 | 129 | ||
130 | makeMenu(); | 130 | makeMenu(); |
131 | 131 | ||
132 | Config cfg( "osearch", Config::User ); | 132 | Config cfg( "osearch", Config::User ); |
133 | cfg.setGroup( "search_settings" ); | 133 | cfg.setGroup( "search_settings" ); |
134 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); | 134 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); |
135 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); | 135 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); |
136 | // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); | 136 | // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void MainWindow::makeMenu() | 139 | void MainWindow::makeMenu() |
140 | { | 140 | { |
141 | QToolBar *toolBar = new QToolBar( this ); | 141 | QToolBar *toolBar = new QToolBar( this ); |
142 | QToolBar *searchBar = new QToolBar(this); | 142 | QToolBar *searchBar = new QToolBar(this); |
143 | QMenuBar *menuBar = new QMenuBar( toolBar ); | 143 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
144 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); | 144 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); |
145 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 145 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
146 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 146 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
147 | QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); | 147 | QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); |
148 | 148 | ||
149 | setToolBarsMovable( false ); | 149 | setToolBarsMovable( false ); |
150 | toolBar->setHorizontalStretchable( true ); | 150 | toolBar->setHorizontalStretchable( true ); |
151 | menuBar->insertItem( tr( "Search" ), searchMenu ); | 151 | menuBar->insertItem( tr( "Search" ), searchMenu ); |
152 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 152 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
153 | 153 | ||
154 | //SETTINGS MENU | 154 | //SETTINGS MENU |
155 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); | 155 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); |
156 | QPopupMenu *pop; | 156 | QPopupMenu *pop; |
157 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 157 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
158 | pop = s->popupMenu(); | 158 | pop = s->popupMenu(); |
159 | if (pop){ | 159 | if (pop){ |
160 | cfgMenu->insertItem( s->text(0), pop ); | 160 | cfgMenu->insertItem( s->text(0), pop ); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | //SEARCH | 165 | //SEARCH |
166 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); | 166 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); |
167 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); | 167 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); |
168 | // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); | 168 | // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); |
169 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); | 169 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); |
170 | SearchAllAction->addTo( searchMenu ); | 170 | SearchAllAction->addTo( searchMenu ); |
171 | searchMenu->insertItem( tr( "Options" ), searchOptions ); | 171 | searchMenu->insertItem( tr( "Options" ), searchOptions ); |
172 | 172 | ||
173 | //SEARCH OPTIONS | 173 | //SEARCH OPTIONS |
174 | //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); | 174 | //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); |
175 | //actionWholeWordsOnly->addTo( searchOptions ); | 175 | //actionWholeWordsOnly->addTo( searchOptions ); |
176 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); | 176 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); |
177 | actionCaseSensitiv->addTo( searchOptions ); | 177 | actionCaseSensitiv->addTo( searchOptions ); |
178 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); | 178 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); |
179 | actionWildcards->addTo( searchOptions ); | 179 | actionWildcards->addTo( searchOptions ); |
180 | 180 | ||
181 | //SEARCH BAR | 181 | //SEARCH BAR |
182 | LabelEnterText = new QLabel( searchBar, "Label" ); | 182 | LabelEnterText = new QLabel( searchBar, "Label" ); |
183 | LabelEnterText->setAutoMask( FALSE ); | 183 | LabelEnterText->setAutoMask( FALSE ); |
184 | LabelEnterText->setText( tr( "Search for: " ) ); | 184 | LabelEnterText->setText( tr( "Search for: " ) ); |
185 | 185 | ||
186 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 186 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
187 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 187 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
188 | QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); | 188 | QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); |
189 | searchEdit->setFocus(); | 189 | searchEdit->setFocus(); |
190 | searchBar->setHorizontalStretchable( TRUE ); | 190 | searchBar->setHorizontalStretchable( TRUE ); |
191 | searchBar->setStretchableWidget( searchEdit ); | 191 | searchBar->setStretchableWidget( searchEdit ); |
192 | 192 | ||
193 | //Search button | 193 | //Search button |
194 | SearchAllAction->addTo( searchBar ); | 194 | SearchAllAction->addTo( searchBar ); |
195 | 195 | ||
196 | //image ripped of off opie-login/loginwindow.cpp | 196 | //image ripped of off opie-login/loginwindow.cpp |
197 | QPixmap image1( ( const char** ) image1_data ); | 197 | QPixmap image1( ( const char** ) image1_data ); |
198 | 198 | ||
199 | //Clear text | 199 | //Clear text |
200 | ClearSearchText = new QToolButton( searchBar, "ClearSearchText"); | 200 | ClearSearchText = new QToolButton( searchBar, "ClearSearchText"); |
201 | ClearSearchText->setText( tr( "" ) ); | 201 | ClearSearchText->setText( tr( "" ) ); |
202 | ClearSearchText->setPixmap( image1 ); | 202 | ClearSearchText->setPixmap( image1 ); |
203 | 203 | ||
204 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ),this, SLOT( setSearch( const QString & ) ) ); | 204 | connect( searchEdit, SIGNAL( textChanged(const QString&) ),this, SLOT( setSearch(const QString&) ) ); |
205 | connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) ); | 205 | connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) ); |
206 | 206 | ||
207 | } | 207 | } |
208 | 208 | ||
209 | MainWindow::~MainWindow() | 209 | MainWindow::~MainWindow() |
210 | { | 210 | { |
211 | Config cfg( "osearch", Config::User ); | 211 | Config cfg( "osearch", Config::User ); |
212 | cfg.setGroup( "search_settings" ); | 212 | cfg.setGroup( "search_settings" ); |
213 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); | 213 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); |
214 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); | 214 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); |
215 | //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); | 215 | //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); |
216 | } | 216 | } |
217 | 217 | ||
218 | void MainWindow::setCurrent(QListViewItem *item) | 218 | void MainWindow::setCurrent(QListViewItem *item) |
219 | { | 219 | { |
220 | if (!item) return; | 220 | if (!item) return; |
221 | _currentItem = (OListViewItem*)item; | 221 | _currentItem = (OListViewItem*)item; |
222 | //_currentItem = dynamic_cast<OListViewItem*>(item); | 222 | //_currentItem = dynamic_cast<OListViewItem*>(item); |
223 | if (_currentItem->rtti() == OListViewItem::Result){ | 223 | if (_currentItem->rtti() == OListViewItem::Result){ |
224 | ResultItem *res = (ResultItem*)item; | 224 | ResultItem *res = (ResultItem*)item; |
225 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 225 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
226 | richEdit->setText( res->toRichText() ); | 226 | richEdit->setText( res->toRichText() ); |
227 | QIntDict<QString> acts = res->actions(); | 227 | QIntDict<QString> acts = res->actions(); |
228 | QButton *button; | 228 | QButton *button; |
229 | for (uint i = 0; i < acts.count(); i++){ | 229 | for (uint i = 0; i < acts.count(); i++){ |
230 | button = buttonMap[i]; | 230 | button = buttonMap[i]; |
231 | if (!button) { | 231 | if (!button) { |
232 | qWarning(" no button for %s", (*acts[i]).latin1() ); | 232 | qWarning(" no button for %s", (*acts[i]).latin1() ); |
233 | button = new QPushButton( buttonBox ); | 233 | button = new QPushButton( buttonBox ); |
234 | buttonMap.insert( i, button ); | 234 | buttonMap.insert( i, button ); |
235 | signalMapper->setMapping(button, i ); | 235 | signalMapper->setMapping(button, i ); |
236 | connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); | 236 | connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); |
237 | } | 237 | } |
238 | button->setText( *acts[i] ); | 238 | button->setText( *acts[i] ); |
239 | button->show(); | 239 | button->show(); |
240 | } | 240 | } |
241 | for (uint i = acts.count(); i < _buttonCount; i++){ | 241 | for (uint i = acts.count(); i < _buttonCount; i++){ |
242 | button = buttonMap[i]; | 242 | button = buttonMap[i]; |
243 | if (button) button->hide(); | 243 | if (button) button->hide(); |
244 | } | 244 | } |
245 | _buttonCount = acts.count(); | 245 | _buttonCount = acts.count(); |
246 | detailsFrame->show(); | 246 | detailsFrame->show(); |
247 | buttonBox->show(); | 247 | buttonBox->show(); |
248 | 248 | ||
249 | }else { | 249 | }else { |
250 | detailsFrame->hide(); | 250 | detailsFrame->hide(); |
251 | buttonBox->hide(); | 251 | buttonBox->hide(); |
252 | } | 252 | } |
253 | popupTimer->start( 300, true ); | 253 | popupTimer->start( 300, true ); |
254 | } | 254 | } |
255 | 255 | ||
256 | void MainWindow::stopTimer(QListViewItem*) | 256 | void MainWindow::stopTimer(QListViewItem*) |
257 | { | 257 | { |
258 | popupTimer->stop(); | 258 | popupTimer->stop(); |
259 | } | 259 | } |
260 | 260 | ||
261 | void MainWindow::showPopup() | 261 | void MainWindow::showPopup() |
262 | { | 262 | { |
263 | popupTimer->stop(); | 263 | popupTimer->stop(); |
264 | if (!_currentItem) return; | 264 | if (!_currentItem) return; |
265 | QPopupMenu *pop = _currentItem->popupMenu(); | 265 | QPopupMenu *pop = _currentItem->popupMenu(); |
266 | if (pop) pop->popup( QCursor::pos() ); | 266 | if (pop) pop->popup( QCursor::pos() ); |
267 | } | 267 | } |
268 | 268 | ||
269 | void MainWindow::setSearch( const QString &key ) | 269 | void MainWindow::setSearch( const QString &key ) |
270 | { | 270 | { |
271 | searchTimer->stop(); | 271 | searchTimer->stop(); |
272 | _searchString = key; | 272 | _searchString = key; |
273 | searchTimer->start( 300 ); | 273 | searchTimer->start( 300 ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void MainWindow::searchStringChanged() | 276 | void MainWindow::searchStringChanged() |
277 | { | 277 | { |
278 | #ifdef NEW_OWAIT | 278 | #ifdef NEW_OWAIT |
279 | OWait("setting search string"); | 279 | OWait("setting search string"); |
280 | #endif | 280 | #endif |
281 | searchTimer->stop(); | 281 | searchTimer->stop(); |
282 | QString ss = _searchString; | 282 | QString ss = _searchString; |
283 | //ss = Global::stringQuote( _searchString ); | 283 | //ss = Global::stringQuote( _searchString ); |
284 | //if (actionWholeWordsOnly->isOn()) | 284 | //if (actionWholeWordsOnly->isOn()) |
285 | // ss = "\\s"+_searchString+"\\s"; | 285 | // ss = "\\s"+_searchString+"\\s"; |
286 | //qDebug(" set searchString >%s<",ss.latin1()); | 286 | //qDebug(" set searchString >%s<",ss.latin1()); |
287 | QRegExp re( ss ); | 287 | QRegExp re( ss ); |
288 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); | 288 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); |
289 | re.setWildcard( actionWildcards->isOn() ); | 289 | re.setWildcard( actionWildcards->isOn() ); |
290 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) | 290 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
291 | s->setSearch( re ); | 291 | s->setSearch( re ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void MainWindow::searchAll() | 294 | void MainWindow::searchAll() |
295 | { | 295 | { |
296 | #ifdef NEW_OWAIT | 296 | #ifdef NEW_OWAIT |
297 | OWait("searching..."); | 297 | OWait("searching..."); |
298 | #endif | 298 | #endif |
299 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 299 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
300 | s->doSearch(); | 300 | s->doSearch(); |
301 | //resultsList->repaint(); | 301 | //resultsList->repaint(); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | void MainWindow::slotAction( int act ) | 305 | void MainWindow::slotAction( int act ) |
306 | { | 306 | { |
307 | if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){ | 307 | if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){ |
308 | ResultItem *res = (ResultItem*)_currentItem; | 308 | ResultItem *res = (ResultItem*)_currentItem; |
309 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 309 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
310 | res->action(act); | 310 | res->action(act); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | void MainWindow::optionChanged(int ) | 314 | void MainWindow::optionChanged(int ) |
315 | { | 315 | { |
316 | searchStringChanged(); | 316 | searchStringChanged(); |
317 | } | 317 | } |
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp index c8652f3..b0d456d 100644 --- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp +++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp | |||
@@ -1,221 +1,221 @@ | |||
1 | /* | 1 | /* |
2 | * addresspluginwidget.cpp | 2 | * addresspluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2003 by Stefan Eilers | 4 | * copyright : (c) 2003 by Stefan Eilers |
5 | * email : eilers.stefan@epost.de | 5 | * email : eilers.stefan@epost.de |
6 | * | 6 | * |
7 | * This implementation was derived from the todolist plugin implementation | 7 | * This implementation was derived from the todolist plugin implementation |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "addresspluginwidget.h" | 19 | #include "addresspluginwidget.h" |
20 | 20 | ||
21 | 21 | ||
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | 23 | ||
24 | #include <opie/ocontact.h> | 24 | #include <opie/ocontact.h> |
25 | 25 | ||
26 | AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name ) | 26 | AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name ) |
27 | : QWidget( parent, name ) { | 27 | : QWidget( parent, name ) { |
28 | 28 | ||
29 | addressLabel = 0l; | 29 | addressLabel = 0l; |
30 | m_contactdb = 0l; | 30 | m_contactdb = 0l; |
31 | layoutTodo = 0l; | 31 | layoutTodo = 0l; |
32 | 32 | ||
33 | // Hä ? Nonsense ! (se) | 33 | // Hä ? Nonsense ! (se) |
34 | if ( m_contactdb ) { | 34 | if ( m_contactdb ) { |
35 | delete m_contactdb; | 35 | delete m_contactdb; |
36 | } | 36 | } |
37 | 37 | ||
38 | m_contactdb = new OContactAccess("addressplugin"); | 38 | m_contactdb = new OContactAccess("addressplugin"); |
39 | 39 | ||
40 | connect( m_contactdb, SIGNAL( signalChanged( const OContactAccess * ) ), | 40 | connect( m_contactdb, SIGNAL( signalChanged(const OContactAccess*) ), |
41 | this, SLOT( refresh( const OContactAccess * ) ) ); | 41 | this, SLOT( refresh(const OContactAccess*) ) ); |
42 | 42 | ||
43 | 43 | ||
44 | readConfig(); | 44 | readConfig(); |
45 | getAddress(); | 45 | getAddress(); |
46 | } | 46 | } |
47 | 47 | ||
48 | AddressBookPluginWidget::~AddressBookPluginWidget() { | 48 | AddressBookPluginWidget::~AddressBookPluginWidget() { |
49 | delete m_contactdb; | 49 | delete m_contactdb; |
50 | } | 50 | } |
51 | 51 | ||
52 | void AddressBookPluginWidget::refresh( const OContactAccess* ) | 52 | void AddressBookPluginWidget::refresh( const OContactAccess* ) |
53 | { | 53 | { |
54 | qWarning(" AddressBookPluginWidget::Database was changed externally ! "); | 54 | qWarning(" AddressBookPluginWidget::Database was changed externally ! "); |
55 | m_contactdb->reload(); | 55 | m_contactdb->reload(); |
56 | getAddress(); | 56 | getAddress(); |
57 | } | 57 | } |
58 | 58 | ||
59 | void AddressBookPluginWidget::reinitialize() { | 59 | void AddressBookPluginWidget::reinitialize() { |
60 | readConfig(); | 60 | readConfig(); |
61 | getAddress(); | 61 | getAddress(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void AddressBookPluginWidget::readConfig() { | 64 | void AddressBookPluginWidget::readConfig() { |
65 | Config cfg( "todayaddressplugin" ); | 65 | Config cfg( "todayaddressplugin" ); |
66 | cfg.setGroup( "config" ); | 66 | cfg.setGroup( "config" ); |
67 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); | 67 | m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); |
68 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); | 68 | m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); |
69 | m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); | 69 | m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); |
70 | m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); | 70 | m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); |
71 | m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); | 71 | m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); |
72 | m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); | 72 | m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); |
73 | m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); | 73 | m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); |
74 | m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); | 74 | m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); |
75 | m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); | 75 | m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Get the addresss | 80 | * Get the addresss |
81 | */ | 81 | */ |
82 | void AddressBookPluginWidget::getAddress() { | 82 | void AddressBookPluginWidget::getAddress() { |
83 | 83 | ||
84 | if ( ! layoutTodo ){ | 84 | if ( ! layoutTodo ){ |
85 | layoutTodo = new QVBoxLayout( this ); | 85 | layoutTodo = new QVBoxLayout( this ); |
86 | } | 86 | } |
87 | 87 | ||
88 | if ( ! addressLabel ) { | 88 | if ( ! addressLabel ) { |
89 | addressLabel = new OClickableLabel( this ); | 89 | addressLabel = new OClickableLabel( this ); |
90 | connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); | 90 | connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); |
91 | layoutTodo->addWidget( addressLabel ); | 91 | layoutTodo->addWidget( addressLabel ); |
92 | } | 92 | } |
93 | 93 | ||
94 | QString output; | 94 | QString output; |
95 | 95 | ||
96 | // Check whether the database provide the search option.. | 96 | // Check whether the database provide the search option.. |
97 | if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ | 97 | if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ |
98 | // Libopie seems to be old.. | 98 | // Libopie seems to be old.. |
99 | output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); | 99 | output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); |
100 | addressLabel->setText( output ); | 100 | addressLabel->setText( output ); |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | 103 | ||
104 | // Define the query for birthdays and start search.. | 104 | // Define the query for birthdays and start search.. |
105 | QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); | 105 | QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); |
106 | int ammount = 0; | 106 | int ammount = 0; |
107 | if ( m_showBirthdays ){ | 107 | if ( m_showBirthdays ){ |
108 | qWarning("Searching from now (%s) until %s ! ", | 108 | qWarning("Searching from now (%s) until %s ! ", |
109 | QDate::currentDate().toString().latin1(), | 109 | QDate::currentDate().toString().latin1(), |
110 | lookAheadDate.toString().latin1() ); | 110 | lookAheadDate.toString().latin1() ); |
111 | } | 111 | } |
112 | 112 | ||
113 | if ( m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ | 113 | if ( m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ |
114 | 114 | ||
115 | 115 | ||
116 | OContact querybirthdays; | 116 | OContact querybirthdays; |
117 | querybirthdays.setBirthday( lookAheadDate ); | 117 | querybirthdays.setBirthday( lookAheadDate ); |
118 | 118 | ||
119 | m_list = m_contactdb->queryByExample( querybirthdays, | 119 | m_list = m_contactdb->queryByExample( querybirthdays, |
120 | OContactAccess::DateDiff ); | 120 | OContactAccess::DateDiff ); |
121 | if ( m_list.count() > 0 ){ | 121 | if ( m_list.count() > 0 ){ |
122 | output = "<font color=" + m_headlineColor + ">" | 122 | output = "<font color=" + m_headlineColor + ">" |
123 | + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) | 123 | + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) |
124 | .arg( m_daysLookAhead ) | 124 | .arg( m_daysLookAhead ) |
125 | + "</font> <br>"; | 125 | + "</font> <br>"; |
126 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | 126 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { |
127 | if ( ammount++ < m_maxLinesTask ){ | 127 | if ( ammount++ < m_maxLinesTask ){ |
128 | // Now we want to calculate how many days | 128 | // Now we want to calculate how many days |
129 | //until birthday. We have to set | 129 | //until birthday. We have to set |
130 | // the correct year to calculate the day diff... | 130 | // the correct year to calculate the day diff... |
131 | QDate destdate = (*m_it).birthday(); | 131 | QDate destdate = (*m_it).birthday(); |
132 | destdate.setYMD( QDate::currentDate().year(), | 132 | destdate.setYMD( QDate::currentDate().year(), |
133 | destdate.month(), destdate.day() ); | 133 | destdate.month(), destdate.day() ); |
134 | if ( QDate::currentDate().daysTo(destdate) < 0 ) | 134 | if ( QDate::currentDate().daysTo(destdate) < 0 ) |
135 | destdate.setYMD( QDate::currentDate().year()+1, | 135 | destdate.setYMD( QDate::currentDate().year()+1, |
136 | destdate.month(), destdate.day() ); | 136 | destdate.month(), destdate.day() ); |
137 | 137 | ||
138 | 138 | ||
139 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) | 139 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) |
140 | output += "<font color=" + m_urgentColor + "><b>-" | 140 | output += "<font color=" + m_urgentColor + "><b>-" |
141 | + (*m_it).fullName() | 141 | + (*m_it).fullName() |
142 | + " (" | 142 | + " (" |
143 | + QString::number(QDate::currentDate() | 143 | + QString::number(QDate::currentDate() |
144 | .daysTo(destdate)) | 144 | .daysTo(destdate)) |
145 | + " Days) </b></font><br>"; | 145 | + " Days) </b></font><br>"; |
146 | 146 | ||
147 | else | 147 | else |
148 | output += "<font color=" + m_entryColor + "><b>-" | 148 | output += "<font color=" + m_entryColor + "><b>-" |
149 | + (*m_it).fullName() | 149 | + (*m_it).fullName() |
150 | + " (" | 150 | + " (" |
151 | + QString::number(QDate::currentDate() | 151 | + QString::number(QDate::currentDate() |
152 | .daysTo(destdate)) | 152 | .daysTo(destdate)) |
153 | + " Days) </b></font><br>"; | 153 | + " Days) </b></font><br>"; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } else { | 156 | } else { |
157 | output = "<font color=" + m_headlineColor + ">" | 157 | output = "<font color=" + m_headlineColor + ">" |
158 | + QObject::tr( "No birthdays in <b> %1 </b> days!" ) | 158 | + QObject::tr( "No birthdays in <b> %1 </b> days!" ) |
159 | .arg( m_daysLookAhead ) | 159 | .arg( m_daysLookAhead ) |
160 | + "</font> <br>"; | 160 | + "</font> <br>"; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | if ( m_showAnniversaries ){ | 164 | if ( m_showAnniversaries ){ |
165 | // Define the query for anniversaries and start search.. | 165 | // Define the query for anniversaries and start search.. |
166 | OContact queryanniversaries; | 166 | OContact queryanniversaries; |
167 | queryanniversaries.setAnniversary( lookAheadDate ); | 167 | queryanniversaries.setAnniversary( lookAheadDate ); |
168 | 168 | ||
169 | m_list = m_contactdb->queryByExample( queryanniversaries, OContactAccess::DateDiff ); | 169 | m_list = m_contactdb->queryByExample( queryanniversaries, OContactAccess::DateDiff ); |
170 | 170 | ||
171 | ammount = 0; | 171 | ammount = 0; |
172 | if ( m_list.count() > 0 ){ | 172 | if ( m_list.count() > 0 ){ |
173 | output += "<font color=" + m_headlineColor + ">" | 173 | output += "<font color=" + m_headlineColor + ">" |
174 | + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ) | 174 | + QObject::tr( "Next anniversaries in <b> %1 </b> days:" ) |
175 | .arg( m_daysLookAhead ) | 175 | .arg( m_daysLookAhead ) |
176 | + "</font> <br>"; | 176 | + "</font> <br>"; |
177 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { | 177 | for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { |
178 | if ( ammount++ < m_maxLinesTask ){ | 178 | if ( ammount++ < m_maxLinesTask ){ |
179 | // Now we want to calculate how many days until anniversary. | 179 | // Now we want to calculate how many days until anniversary. |
180 | // We have to set the correct year to calculate the day diff... | 180 | // We have to set the correct year to calculate the day diff... |
181 | QDate destdate = (*m_it).anniversary(); | 181 | QDate destdate = (*m_it).anniversary(); |
182 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), | 182 | destdate.setYMD( QDate::currentDate().year(), destdate.month(), |
183 | destdate.day() ); | 183 | destdate.day() ); |
184 | if ( QDate::currentDate().daysTo(destdate) < 0 ) | 184 | if ( QDate::currentDate().daysTo(destdate) < 0 ) |
185 | destdate.setYMD( QDate::currentDate().year()+1, | 185 | destdate.setYMD( QDate::currentDate().year()+1, |
186 | destdate.month(), destdate.day() ); | 186 | destdate.month(), destdate.day() ); |
187 | 187 | ||
188 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) | 188 | if ( QDate::currentDate().daysTo(destdate) < m_urgentDays ) |
189 | output += "<font color=" + m_urgentColor + "><b>-" | 189 | output += "<font color=" + m_urgentColor + "><b>-" |
190 | + (*m_it).fullName() | 190 | + (*m_it).fullName() |
191 | + " (" | 191 | + " (" |
192 | + QString::number(QDate::currentDate() | 192 | + QString::number(QDate::currentDate() |
193 | .daysTo( destdate ) ) | 193 | .daysTo( destdate ) ) |
194 | + " Days) </b></font><br>"; | 194 | + " Days) </b></font><br>"; |
195 | else | 195 | else |
196 | output += "<font color=" + m_entryColor + "><b>-" | 196 | output += "<font color=" + m_entryColor + "><b>-" |
197 | + (*m_it).fullName() | 197 | + (*m_it).fullName() |
198 | + " (" | 198 | + " (" |
199 | + QString::number(QDate::currentDate() | 199 | + QString::number(QDate::currentDate() |
200 | .daysTo( destdate ) ) | 200 | .daysTo( destdate ) ) |
201 | + " Days) </b></font><br>"; | 201 | + " Days) </b></font><br>"; |
202 | } | 202 | } |
203 | } | 203 | } |
204 | } else { | 204 | } else { |
205 | output += "<font color=" + m_headlineColor + ">" | 205 | output += "<font color=" + m_headlineColor + ">" |
206 | + QObject::tr( "No anniversaries in <b> %1 </b> days!" ) | 206 | + QObject::tr( "No anniversaries in <b> %1 </b> days!" ) |
207 | .arg( m_daysLookAhead ) | 207 | .arg( m_daysLookAhead ) |
208 | + "</font> <br>"; | 208 | + "</font> <br>"; |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | addressLabel->setText( output ); | 212 | addressLabel->setText( output ); |
213 | } | 213 | } |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * start the todolist | 216 | * start the todolist |
217 | */ | 217 | */ |
218 | void AddressBookPluginWidget::startAddressBook() { | 218 | void AddressBookPluginWidget::startAddressBook() { |
219 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 219 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
220 | e << QString( "addressbook" ); | 220 | e << QString( "addressbook" ); |
221 | } | 221 | } |
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp index b6707df..0820802 100644 --- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp +++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp | |||
@@ -1,140 +1,140 @@ | |||
1 | /* | 1 | /* |
2 | * datebookpluginwidget.cpp | 2 | * datebookpluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003, 2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003, 2004 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | 17 | ||
18 | #include "datebookpluginwidget.h" | 18 | #include "datebookpluginwidget.h" |
19 | 19 | ||
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | 21 | ||
22 | #include <qtl.h> | 22 | #include <qtl.h> |
23 | 23 | ||
24 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name ) | 24 | DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name ) |
25 | : QWidget(parent, name ) { | 25 | : QWidget(parent, name ) { |
26 | 26 | ||
27 | db = 0l; | 27 | db = 0l; |
28 | m_layoutDates = 0l; | 28 | m_layoutDates = 0l; |
29 | 29 | ||
30 | if ( m_layoutDates ) { | 30 | if ( m_layoutDates ) { |
31 | delete m_layoutDates; | 31 | delete m_layoutDates; |
32 | } | 32 | } |
33 | m_layoutDates = new QVBoxLayout( this ); | 33 | m_layoutDates = new QVBoxLayout( this ); |
34 | m_layoutDates->setAutoAdd( true ); | 34 | m_layoutDates->setAutoAdd( true ); |
35 | 35 | ||
36 | m_eventsList.setAutoDelete( true ); | 36 | m_eventsList.setAutoDelete( true ); |
37 | 37 | ||
38 | readConfig(); | 38 | readConfig(); |
39 | getDates(); | 39 | getDates(); |
40 | } | 40 | } |
41 | 41 | ||
42 | DatebookPluginWidget::~DatebookPluginWidget() { | 42 | DatebookPluginWidget::~DatebookPluginWidget() { |
43 | delete db; | 43 | delete db; |
44 | delete m_layoutDates; | 44 | delete m_layoutDates; |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
48 | void DatebookPluginWidget::readConfig() { | 48 | void DatebookPluginWidget::readConfig() { |
49 | Config cfg( "todaydatebookplugin" ); | 49 | Config cfg( "todaydatebookplugin" ); |
50 | cfg.setGroup( "config" ); | 50 | cfg.setGroup( "config" ); |
51 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); | 51 | m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); |
52 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); | 52 | m_show_location = cfg.readNumEntry( "showlocation", 1 ); |
53 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); | 53 | m_show_notes = cfg.readNumEntry( "shownotes", 0 ); |
54 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); | 54 | m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); |
55 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); | 55 | m_moreDays = cfg.readNumEntry( "moredays", 0 ); |
56 | m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 ); | 56 | m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void DatebookPluginWidget::reinitialize() { | 59 | void DatebookPluginWidget::reinitialize() { |
60 | readConfig(); | 60 | readConfig(); |
61 | refresh(); | 61 | refresh(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void DatebookPluginWidget::refresh() { | 64 | void DatebookPluginWidget::refresh() { |
65 | m_eventsList.clear(); | 65 | m_eventsList.clear(); |
66 | 66 | ||
67 | if ( m_layoutDates ) { | 67 | if ( m_layoutDates ) { |
68 | delete m_layoutDates; | 68 | delete m_layoutDates; |
69 | } | 69 | } |
70 | m_layoutDates = new QVBoxLayout( this ); | 70 | m_layoutDates = new QVBoxLayout( this ); |
71 | m_layoutDates->setAutoAdd( true ); | 71 | m_layoutDates->setAutoAdd( true ); |
72 | 72 | ||
73 | getDates(); | 73 | getDates(); |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Get all events that are in the datebook xml file for today | 77 | * Get all events that are in the datebook xml file for today |
78 | */ | 78 | */ |
79 | void DatebookPluginWidget::getDates() { | 79 | void DatebookPluginWidget::getDates() { |
80 | 80 | ||
81 | 81 | ||
82 | if ( db ) { | 82 | if ( db ) { |
83 | delete db; | 83 | delete db; |
84 | } | 84 | } |
85 | db = new DateBookDB; | 85 | db = new DateBookDB; |
86 | 86 | ||
87 | QDate date = QDate::currentDate(); | 87 | QDate date = QDate::currentDate(); |
88 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); | 88 | QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); |
89 | qBubbleSort( list ); | 89 | qBubbleSort( list ); |
90 | int count = 0; | 90 | int count = 0; |
91 | 91 | ||
92 | if ( list.count() > 0 ) { | 92 | if ( list.count() > 0 ) { |
93 | 93 | ||
94 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 94 | for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
95 | 95 | ||
96 | if ( count < m_max_lines_meet ) { | 96 | if ( count < m_max_lines_meet ) { |
97 | if ( !m_onlyLater ) { | 97 | if ( !m_onlyLater ) { |
98 | count++; | 98 | count++; |
99 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); | 99 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); |
100 | m_eventsList.append( l ); | 100 | m_eventsList.append( l ); |
101 | l->show(); | 101 | l->show(); |
102 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); | 102 | QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) ); |
103 | } else { | 103 | } else { |
104 | if ( ( QDateTime::currentDateTime() <= (*it).event().end() ) | 104 | if ( ( QDateTime::currentDateTime() <= (*it).event().end() ) |
105 | // Show events which span over many days and are not elapsed. | 105 | // Show events which span over many days and are not elapsed. |
106 | || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) ) | 106 | || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) ) |
107 | // Show repeated event for today that is not elapsed. | 107 | // Show repeated event for today that is not elapsed. |
108 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) | 108 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) |
109 | && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() ) | 109 | && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() ) |
110 | && ( QTime::currentTime() < (*it).event().start().time() ) ) ) | 110 | && ( QTime::currentTime() < (*it).event().start().time() ) ) ) |
111 | // Show repeated event for next days. | 111 | // Show repeated event for next days. |
112 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) | 112 | || ( ( (*it).event().repeatType() != Event::NoRepeat ) |
113 | && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) ) | 113 | && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) ) |
114 | ) | 114 | ) |
115 | { | 115 | { |
116 | count++; | 116 | count++; |
117 | // show only later appointments | 117 | // show only later appointments |
118 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); | 118 | DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); |
119 | m_eventsList.append( l ); | 119 | m_eventsList.append( l ); |
120 | l->show(); | 120 | l->show(); |
121 | QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); | 121 | QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) ); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | if ( m_onlyLater && count == 0 ) { | 126 | if ( m_onlyLater && count == 0 ) { |
127 | QLabel* noMoreEvents = new QLabel( this ); | 127 | QLabel* noMoreEvents = new QLabel( this ); |
128 | m_eventsList.append( noMoreEvents ); | 128 | m_eventsList.append( noMoreEvents ); |
129 | noMoreEvents->show(); | 129 | noMoreEvents->show(); |
130 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); | 130 | noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); |
131 | } | 131 | } |
132 | } else { | 132 | } else { |
133 | QLabel* noEvents = new QLabel( this ); | 133 | QLabel* noEvents = new QLabel( this ); |
134 | m_eventsList.append( noEvents ); | 134 | m_eventsList.append( noEvents ); |
135 | noEvents->show(); | 135 | noEvents->show(); |
136 | noEvents->setText( QObject::tr( "No appointments today" ) ); | 136 | noEvents->setText( QObject::tr( "No appointments today" ) ); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
diff --git a/core/pim/today/plugins/mail/mailpluginwidget.cpp b/core/pim/today/plugins/mail/mailpluginwidget.cpp index 4194270..a8e4c41 100644 --- a/core/pim/today/plugins/mail/mailpluginwidget.cpp +++ b/core/pim/today/plugins/mail/mailpluginwidget.cpp | |||
@@ -1,97 +1,97 @@ | |||
1 | /* | 1 | /* |
2 | * mailpluginwidget.cpp | 2 | * mailpluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003,2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003,2004 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | #include "mailpluginwidget.h" | 16 | #include "mailpluginwidget.h" |
17 | 17 | ||
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | 20 | ||
21 | MailPluginWidget::MailPluginWidget( QWidget *parent, const char* name) | 21 | MailPluginWidget::MailPluginWidget( QWidget *parent, const char* name) |
22 | : QWidget(parent, name ) { | 22 | : QWidget(parent, name ) { |
23 | 23 | ||
24 | m_mailLabel = 0l; | 24 | m_mailLabel = 0l; |
25 | m_layout = 0l; | 25 | m_layout = 0l; |
26 | 26 | ||
27 | if ( m_mailLabel ) { | 27 | if ( m_mailLabel ) { |
28 | delete m_mailLabel; | 28 | delete m_mailLabel; |
29 | } | 29 | } |
30 | m_mailLabel = new OClickableLabel( this ); | 30 | m_mailLabel = new OClickableLabel( this ); |
31 | connect( m_mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) ); | 31 | connect( m_mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) ); |
32 | 32 | ||
33 | if ( m_layout ) { | 33 | if ( m_layout ) { |
34 | delete m_layout; | 34 | delete m_layout; |
35 | } | 35 | } |
36 | m_layout = new QHBoxLayout( this ); | 36 | m_layout = new QHBoxLayout( this ); |
37 | m_layout->setAutoAdd( true ); | 37 | m_layout->setAutoAdd( true ); |
38 | 38 | ||
39 | 39 | ||
40 | #if defined(Q_WS_QWS) | 40 | #if defined(Q_WS_QWS) |
41 | #if !defined(QT_NO_COP) | 41 | #if !defined(QT_NO_COP) |
42 | QCopChannel *qCopChannel = new QCopChannel( "QPE/Pim" , this ); | 42 | QCopChannel *qCopChannel = new QCopChannel( "QPE/Pim" , this ); |
43 | connect ( qCopChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 43 | connect ( qCopChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
44 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 44 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); |
45 | #endif | 45 | #endif |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | readConfig(); | 48 | readConfig(); |
49 | getInfo(); | 49 | getInfo(); |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | void MailPluginWidget::channelReceived( const QCString &msg, const QByteArray & data ) { | 53 | void MailPluginWidget::channelReceived( const QCString &msg, const QByteArray & data ) { |
54 | QDataStream stream( data, IO_ReadOnly ); | 54 | QDataStream stream( data, IO_ReadOnly ); |
55 | if ( msg == "outgoingMails(int)" ) { | 55 | if ( msg == "outgoingMails(int)" ) { |
56 | stream >> m_outgoing; | 56 | stream >> m_outgoing; |
57 | } else if ( msg == "newMails(int)" ) { | 57 | } else if ( msg == "newMails(int)" ) { |
58 | stream >> m_newMails; | 58 | stream >> m_newMails; |
59 | } | 59 | } |
60 | getInfo(); | 60 | getInfo(); |
61 | } | 61 | } |
62 | MailPluginWidget::~MailPluginWidget() { | 62 | MailPluginWidget::~MailPluginWidget() { |
63 | delete m_mailLabel; | 63 | delete m_mailLabel; |
64 | delete m_layout; | 64 | delete m_layout; |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | void MailPluginWidget::readConfig() { | 68 | void MailPluginWidget::readConfig() { |
69 | Config cfg( "todaymailplugin" ); | 69 | Config cfg( "todaymailplugin" ); |
70 | cfg.setGroup( "config" ); | 70 | cfg.setGroup( "config" ); |
71 | 71 | ||
72 | Config cfg2( "mail" ); | 72 | Config cfg2( "mail" ); |
73 | cfg2.setGroup( "Status" ); | 73 | cfg2.setGroup( "Status" ); |
74 | 74 | ||
75 | m_newMails = cfg2.readNumEntry( "newMails", 0 ); | 75 | m_newMails = cfg2.readNumEntry( "newMails", 0 ); |
76 | m_outgoing = cfg2.readNumEntry( "outgoing", 0 ); | 76 | m_outgoing = cfg2.readNumEntry( "outgoing", 0 ); |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | void MailPluginWidget::refresh() { | 80 | void MailPluginWidget::refresh() { |
81 | getInfo(); | 81 | getInfo(); |
82 | } | 82 | } |
83 | 83 | ||
84 | void MailPluginWidget::getInfo() { | 84 | void MailPluginWidget::getInfo() { |
85 | 85 | ||
86 | 86 | ||
87 | 87 | ||
88 | m_mailLabel->setText( QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( m_newMails ).arg( m_outgoing ) ); | 88 | m_mailLabel->setText( QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( m_newMails ).arg( m_outgoing ) ); |
89 | } | 89 | } |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * launches datebook | 92 | * launches datebook |
93 | */ | 93 | */ |
94 | void MailPluginWidget::startMail() { | 94 | void MailPluginWidget::startMail() { |
95 | QCopEnvelope e("QPE/System", "execute(QString)"); | 95 | QCopEnvelope e("QPE/System", "execute(QString)"); |
96 | e << QString( "opiemail" ); | 96 | e << QString( "opiemail" ); |
97 | } | 97 | } |
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 72cdfd6..812f8b5 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,249 +1,249 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp | 2 | * today.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003,2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003,2004 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #define QTOPIA_INTERNAL_LANGLIST | 17 | #define QTOPIA_INTERNAL_LANGLIST |
18 | 18 | ||
19 | #include "today.h" | 19 | #include "today.h" |
20 | 20 | ||
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/contact.h> | 25 | #include <qpe/contact.h> |
26 | 26 | ||
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | struct TodayPlugin { | 31 | struct TodayPlugin { |
32 | TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} | 32 | TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} |
33 | QLibrary *library; | 33 | QLibrary *library; |
34 | QInterfacePtr<TodayPluginInterface> iface; | 34 | QInterfacePtr<TodayPluginInterface> iface; |
35 | TodayPluginObject *guiPart; | 35 | TodayPluginObject *guiPart; |
36 | QWidget *guiBox; | 36 | QWidget *guiBox; |
37 | QString name; | 37 | QString name; |
38 | bool active; | 38 | bool active; |
39 | bool excludeRefresh; | 39 | bool excludeRefresh; |
40 | int pos; | 40 | int pos; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | static QValueList<TodayPlugin> pluginList; | 43 | static QValueList<TodayPlugin> pluginList; |
44 | 44 | ||
45 | static QMap<QString, TodayPlugin> tempList; | 45 | static QMap<QString, TodayPlugin> tempList; |
46 | 46 | ||
47 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 47 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
48 | : TodayBase( parent, name, fl ) { | 48 | : TodayBase( parent, name, fl ) { |
49 | 49 | ||
50 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); | 50 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
51 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); | 51 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); |
52 | 52 | ||
53 | #if defined(Q_WS_QWS) | 53 | #if defined(Q_WS_QWS) |
54 | #if !defined(QT_NO_COP) | 54 | #if !defined(QT_NO_COP) |
55 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); | 55 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); |
56 | connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 56 | connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
57 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 57 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); |
58 | #endif | 58 | #endif |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | setOwnerField(); | 61 | setOwnerField(); |
62 | m_refreshTimer = new QTimer( this ); | 62 | m_refreshTimer = new QTimer( this ); |
63 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 63 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
64 | m_refreshTimer->start( 15000 ); | 64 | m_refreshTimer->start( 15000 ); |
65 | m_big_box = 0L; | 65 | m_big_box = 0L; |
66 | 66 | ||
67 | 67 | ||
68 | layout = new QVBoxLayout( this ); | 68 | layout = new QVBoxLayout( this ); |
69 | layout->addWidget( Frame ); | 69 | layout->addWidget( Frame ); |
70 | layout->addWidget( OwnerField ); | 70 | layout->addWidget( OwnerField ); |
71 | 71 | ||
72 | m_sv = new QScrollView( this ); | 72 | m_sv = new QScrollView( this ); |
73 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); | 73 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); |
74 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 74 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
75 | m_sv->setFrameShape( QFrame::NoFrame ); | 75 | m_sv->setFrameShape( QFrame::NoFrame ); |
76 | 76 | ||
77 | layout->addWidget( m_sv ); | 77 | layout->addWidget( m_sv ); |
78 | layout->setStretchFactor( m_sv,4 ); | 78 | layout->setStretchFactor( m_sv,4 ); |
79 | 79 | ||
80 | qApp->processEvents(); | 80 | qApp->processEvents(); |
81 | loadPlugins(); | 81 | loadPlugins(); |
82 | QPEApplication::showWidget( this ); | 82 | QPEApplication::showWidget( this ); |
83 | } | 83 | } |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Qcop receive method. | 86 | * Qcop receive method. |
87 | */ | 87 | */ |
88 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 88 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { |
89 | QDataStream stream( data, IO_ReadOnly ); | 89 | QDataStream stream( data, IO_ReadOnly ); |
90 | if ( msg == "message(QString)" ) { | 90 | if ( msg == "message(QString)" ) { |
91 | QString message; | 91 | QString message; |
92 | stream >> message; | 92 | stream >> message; |
93 | setOwnerField( message ); | 93 | setOwnerField( message ); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | void Today::setRefreshTimer( int interval ) { | 97 | void Today::setRefreshTimer( int interval ) { |
98 | 98 | ||
99 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 99 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
100 | 100 | ||
101 | // 0 is "never" case | 101 | // 0 is "never" case |
102 | if ( !interval == 0 ) { | 102 | if ( !interval == 0 ) { |
103 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 103 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
104 | m_refreshTimer->changeInterval( interval ); | 104 | m_refreshTimer->changeInterval( interval ); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Initialises the owner field with the default value, the username | 110 | * Initialises the owner field with the default value, the username |
111 | */ | 111 | */ |
112 | void Today::setOwnerField() { | 112 | void Today::setOwnerField() { |
113 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); | 113 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); |
114 | if ( QFile::exists( file ) ) { | 114 | if ( QFile::exists( file ) ) { |
115 | Contact cont = Contact::readVCard( file )[0]; | 115 | Contact cont = Contact::readVCard( file )[0]; |
116 | QString returnString = cont.fullName(); | 116 | QString returnString = cont.fullName(); |
117 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); | 117 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); |
118 | } else { | 118 | } else { |
119 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); | 119 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * Set the owner field with a given QString, for example per qcop. | 124 | * Set the owner field with a given QString, for example per qcop. |
125 | */ | 125 | */ |
126 | void Today::setOwnerField( QString &message ) { | 126 | void Today::setOwnerField( QString &message ) { |
127 | if ( !message.isEmpty() ) { | 127 | if ( !message.isEmpty() ) { |
128 | OwnerField->setText( "<b>" + message + "</b>" ); | 128 | OwnerField->setText( "<b>" + message + "</b>" ); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * Init stuff needed for today. Reads the config file. | 133 | * Init stuff needed for today. Reads the config file. |
134 | */ | 134 | */ |
135 | void Today::init() { | 135 | void Today::init() { |
136 | // read config | 136 | // read config |
137 | Config cfg( "today" ); | 137 | Config cfg( "today" ); |
138 | 138 | ||
139 | cfg.setGroup( "Plugins" ); | 139 | cfg.setGroup( "Plugins" ); |
140 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 140 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
141 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 141 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
142 | 142 | ||
143 | cfg.setGroup( "General" ); | 143 | cfg.setGroup( "General" ); |
144 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 144 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
145 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 145 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
146 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 146 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
147 | 147 | ||
148 | // set the date in top label | 148 | // set the date in top label |
149 | QDate date = QDate::currentDate(); | 149 | QDate date = QDate::currentDate(); |
150 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 150 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
151 | 151 | ||
152 | if ( m_hideBanner ) { | 152 | if ( m_hideBanner ) { |
153 | Opiezilla->hide(); | 153 | Opiezilla->hide(); |
154 | TodayLabel->hide(); | 154 | TodayLabel->hide(); |
155 | } else { | 155 | } else { |
156 | Opiezilla->show(); | 156 | Opiezilla->show(); |
157 | TodayLabel->show(); | 157 | TodayLabel->show(); |
158 | } | 158 | } |
159 | 159 | ||
160 | if ( m_big_box ) { | 160 | if ( m_big_box ) { |
161 | delete m_big_box; | 161 | delete m_big_box; |
162 | } | 162 | } |
163 | 163 | ||
164 | m_big_box = new QWidget( m_sv->viewport() ); | 164 | m_big_box = new QWidget( m_sv->viewport() ); |
165 | m_sv->addChild( m_big_box ); | 165 | m_sv->addChild( m_big_box ); |
166 | m_bblayout = new QVBoxLayout ( m_big_box ); | 166 | m_bblayout = new QVBoxLayout ( m_big_box ); |
167 | } | 167 | } |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Load the plugins | 170 | * Load the plugins |
171 | */ | 171 | */ |
172 | void Today::loadPlugins() { | 172 | void Today::loadPlugins() { |
173 | 173 | ||
174 | init(); | 174 | init(); |
175 | 175 | ||
176 | QValueList<TodayPlugin>::Iterator tit; | 176 | QValueList<TodayPlugin>::Iterator tit; |
177 | if ( !pluginList.isEmpty() ) { | 177 | if ( !pluginList.isEmpty() ) { |
178 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 178 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
179 | (*tit).guiBox->hide(); | 179 | (*tit).guiBox->hide(); |
180 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); | 180 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); |
181 | delete (*tit).guiBox; | 181 | delete (*tit).guiBox; |
182 | (*tit).library->unload(); | 182 | (*tit).library->unload(); |
183 | delete (*tit).library; | 183 | delete (*tit).library; |
184 | } | 184 | } |
185 | pluginList.clear(); | 185 | pluginList.clear(); |
186 | } | 186 | } |
187 | 187 | ||
188 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 188 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
189 | #ifdef Q_OS_MACX | 189 | #ifdef Q_OS_MACX |
190 | qWarning("Searching for Plugins in: %s", path.latin1()); | 190 | qWarning("Searching for Plugins in: %s", path.latin1()); |
191 | QDir dir( path, "lib*.dylib" ); | 191 | QDir dir( path, "lib*.dylib" ); |
192 | #else | 192 | #else |
193 | QDir dir( path, "lib*.so" ); | 193 | QDir dir( path, "lib*.so" ); |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | QStringList list = dir.entryList(); | 196 | QStringList list = dir.entryList(); |
197 | QStringList::Iterator it; | 197 | QStringList::Iterator it; |
198 | 198 | ||
199 | // QMap<QString, TodayPlugin> tempList; | 199 | // QMap<QString, TodayPlugin> tempList; |
200 | 200 | ||
201 | for ( it = list.begin(); it != list.end(); ++it ) { | 201 | for ( it = list.begin(); it != list.end(); ++it ) { |
202 | QInterfacePtr<TodayPluginInterface> iface; | 202 | QInterfacePtr<TodayPluginInterface> iface; |
203 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 203 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
204 | 204 | ||
205 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 205 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
206 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 206 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
207 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); | 207 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); |
208 | qDebug( QString(*it) ); | 208 | qDebug( QString(*it) ); |
209 | 209 | ||
210 | TodayPlugin plugin; | 210 | TodayPlugin plugin; |
211 | plugin.library = lib; | 211 | plugin.library = lib; |
212 | plugin.iface = iface; | 212 | plugin.iface = iface; |
213 | plugin.name = QString(*it); | 213 | plugin.name = QString(*it); |
214 | 214 | ||
215 | QString type = (*it).left( (*it).find(".") ); | 215 | QString type = (*it).left( (*it).find(".") ); |
216 | 216 | ||
217 | QString lang; | 217 | QString lang; |
218 | Config config("locale"); | 218 | Config config("locale"); |
219 | config.setGroup("Language"); | 219 | config.setGroup("Language"); |
220 | lang = config.readEntry( "Language", "en" ); | 220 | lang = config.readEntry( "Language", "en" ); |
221 | 221 | ||
222 | qDebug( "Languages: " + lang ); | 222 | qDebug( "Languages: " + lang ); |
223 | QTranslator * trans = new QTranslator( qApp ); | 223 | QTranslator * trans = new QTranslator( qApp ); |
224 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; | 224 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; |
225 | if ( trans->load( tfn ) ) { | 225 | if ( trans->load( tfn ) ) { |
226 | qApp->installTranslator( trans ); | 226 | qApp->installTranslator( trans ); |
227 | } else { | 227 | } else { |
228 | delete trans; | 228 | delete trans; |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | // find out if plugins should be shown | 232 | // find out if plugins should be shown |
233 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { | 233 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { |
234 | plugin.active = true; | 234 | plugin.active = true; |
235 | } else { | 235 | } else { |
236 | plugin.active = false; | 236 | plugin.active = false; |
237 | } | 237 | } |
238 | 238 | ||
239 | plugin.guiPart = plugin.iface->guiPart(); | 239 | plugin.guiPart = plugin.iface->guiPart(); |
240 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); | 240 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); |
241 | 241 | ||
242 | // package the whole thing into a qwidget so it can be shown and hidden | 242 | // package the whole thing into a qwidget so it can be shown and hidden |
243 | plugin.guiBox = new QWidget( m_big_box ); | 243 | plugin.guiBox = new QWidget( m_big_box ); |
244 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); | 244 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); |
245 | QPixmap plugPix; | 245 | QPixmap plugPix; |
246 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); | 246 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); |
247 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 247 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
248 | plugIcon->setPixmap( plugPix ); | 248 | plugIcon->setPixmap( plugPix ); |
249 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); | 249 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); |
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 5c51515..a6f53e1 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -1,230 +1,230 @@ | |||
1 | /* | 1 | /* |
2 | * todayconfig.cpp | 2 | * todayconfig.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß | 4 | * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #include "todayconfig.h" | 17 | #include "todayconfig.h" |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qspinbox.h> | 26 | #include <qspinbox.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qheader.h> | 28 | #include <qheader.h> |
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | 32 | ||
33 | class ToolButton : public QToolButton { | 33 | class ToolButton : public QToolButton { |
34 | 34 | ||
35 | public: | 35 | public: |
36 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 36 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
37 | : QToolButton( parent, name ) { | 37 | : QToolButton( parent, name ) { |
38 | setPixmap( Resource::loadPixmap( icon ) ); | 38 | setPixmap( Resource::loadPixmap( icon ) ); |
39 | setAutoRaise( TRUE ); | 39 | setAutoRaise( TRUE ); |
40 | setFocusPolicy( QWidget::NoFocus ); | 40 | setFocusPolicy( QWidget::NoFocus ); |
41 | setToggleButton( t ); | 41 | setToggleButton( t ); |
42 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 42 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
43 | } | 43 | } |
44 | }; | 44 | }; |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
48 | * The class has currently quite some duplicate code. | 48 | * The class has currently quite some duplicate code. |
49 | * By that way it would be real easy to have it as seperate app in settings tab | 49 | * By that way it would be real easy to have it as seperate app in settings tab |
50 | * | 50 | * |
51 | */ | 51 | */ |
52 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | 52 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) |
53 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { | 53 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { |
54 | 54 | ||
55 | setCaption( tr( "Today Config" ) ); | 55 | setCaption( tr( "Today Config" ) ); |
56 | 56 | ||
57 | QVBoxLayout *layout = new QVBoxLayout( this ); | 57 | QVBoxLayout *layout = new QVBoxLayout( this ); |
58 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 58 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
59 | layout->addWidget( TabWidget3 ); | 59 | layout->addWidget( TabWidget3 ); |
60 | 60 | ||
61 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | 61 | tab_2 = new QWidget( TabWidget3, "tab_2" ); |
62 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); | 62 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); |
63 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); | 63 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); |
64 | tab2Layout->addWidget( l ); | 64 | tab2Layout->addWidget( l ); |
65 | QHBox *hbox1 = new QHBox( tab_2 ); | 65 | QHBox *hbox1 = new QHBox( tab_2 ); |
66 | m_appletListView = new QListView( hbox1 ); | 66 | m_appletListView = new QListView( hbox1 ); |
67 | m_appletListView->addColumn( "PluginList" ); | 67 | m_appletListView->addColumn( "PluginList" ); |
68 | m_appletListView->header()->hide(); | 68 | m_appletListView->header()->hide(); |
69 | m_appletListView->setSorting( -1 ); | 69 | m_appletListView->setSorting( -1 ); |
70 | QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); | 70 | QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); |
71 | QVBox *vbox1 = new QVBox( hbox1 ); | 71 | QVBox *vbox1 = new QVBox( hbox1 ); |
72 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); | 72 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); |
73 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); | 73 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); |
74 | tab2Layout->addWidget( hbox1 ); | 74 | tab2Layout->addWidget( hbox1 ); |
75 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); | 75 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); |
76 | 76 | ||
77 | // Misc tab | 77 | // Misc tab |
78 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | 78 | tab_3 = new QWidget( TabWidget3, "tab_3" ); |
79 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); | 79 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); |
80 | 80 | ||
81 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); | 81 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); |
82 | 82 | ||
83 | tab3Layout->addWidget( m_guiMisc ); | 83 | tab3Layout->addWidget( m_guiMisc ); |
84 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); | 84 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); |
85 | 85 | ||
86 | m_applets_changed = false; | 86 | m_applets_changed = false; |
87 | 87 | ||
88 | connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); | 88 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); |
89 | 89 | ||
90 | readConfig(); | 90 | readConfig(); |
91 | QPEApplication::showDialog( this ); | 91 | QPEApplication::showDialog( this ); |
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Autostart, uses the new (opie only) autostart method in the launcher code. | 96 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
97 | * If registered against that today ist started on each resume. | 97 | * If registered against that today ist started on each resume. |
98 | */ | 98 | */ |
99 | void TodayConfig::setAutoStart() { | 99 | void TodayConfig::setAutoStart() { |
100 | Config cfg( "today" ); | 100 | Config cfg( "today" ); |
101 | cfg.setGroup( "Autostart" ); | 101 | cfg.setGroup( "Autostart" ); |
102 | if ( m_autoStart ) { | 102 | if ( m_autoStart ) { |
103 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); | 103 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); |
104 | e << QString( "add" ); | 104 | e << QString( "add" ); |
105 | e << QString( "today" ); | 105 | e << QString( "today" ); |
106 | e << QString( "%1" ).arg( m_autoStartTimer ); | 106 | e << QString( "%1" ).arg( m_autoStartTimer ); |
107 | } else { | 107 | } else { |
108 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); | 108 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); |
109 | e << QString( "remove" ); | 109 | e << QString( "remove" ); |
110 | e << QString( "today" ); | 110 | e << QString( "today" ); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Read the config part | 115 | * Read the config part |
116 | */ | 116 | */ |
117 | void TodayConfig::readConfig() { | 117 | void TodayConfig::readConfig() { |
118 | Config cfg( "today" ); | 118 | Config cfg( "today" ); |
119 | cfg.setGroup( "Autostart" ); | 119 | cfg.setGroup( "Autostart" ); |
120 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); | 120 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); |
121 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); | 121 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); |
122 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); | 122 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); |
123 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); | 123 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); |
124 | 124 | ||
125 | cfg.setGroup( "General" ); | 125 | cfg.setGroup( "General" ); |
126 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 126 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
127 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); | 127 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); |
128 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); | 128 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); |
129 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); | 129 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); |
130 | 130 | ||
131 | 131 | ||
132 | cfg.setGroup( "Plugins" ); | 132 | cfg.setGroup( "Plugins" ); |
133 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 133 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
134 | } | 134 | } |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Write the config part | 137 | * Write the config part |
138 | */ | 138 | */ |
139 | void TodayConfig::writeConfig() { | 139 | void TodayConfig::writeConfig() { |
140 | Config cfg( "today" ); | 140 | Config cfg( "today" ); |
141 | cfg.setGroup( "Plugins" ); | 141 | cfg.setGroup( "Plugins" ); |
142 | if ( m_applets_changed ) { | 142 | if ( m_applets_changed ) { |
143 | QStringList exclude; | 143 | QStringList exclude; |
144 | QStringList include; | 144 | QStringList include; |
145 | QStringList all_applets; | 145 | QStringList all_applets; |
146 | 146 | ||
147 | QListViewItemIterator list_it( m_appletListView ); | 147 | QListViewItemIterator list_it( m_appletListView ); |
148 | 148 | ||
149 | // this makes sure the names get saved in the order selected | 149 | // this makes sure the names get saved in the order selected |
150 | for ( ; list_it.current(); ++list_it ) { | 150 | for ( ; list_it.current(); ++list_it ) { |
151 | QMap <QString, QCheckListItem *>::Iterator it; | 151 | QMap <QString, QCheckListItem *>::Iterator it; |
152 | for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { | 152 | for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { |
153 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { | 153 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { |
154 | exclude << it.key(); | 154 | exclude << it.key(); |
155 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ | 155 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ |
156 | include << it.key(); | 156 | include << it.key(); |
157 | } | 157 | } |
158 | if ( list_it.current() == (*it) ) { | 158 | if ( list_it.current() == (*it) ) { |
159 | all_applets << it.key(); | 159 | all_applets << it.key(); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 163 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
164 | cfg.writeEntry( "IncludeApplets", include, ',' ); | 164 | cfg.writeEntry( "IncludeApplets", include, ',' ); |
165 | cfg.writeEntry( "AllApplets", all_applets, ',' ); | 165 | cfg.writeEntry( "AllApplets", all_applets, ',' ); |
166 | } | 166 | } |
167 | 167 | ||
168 | cfg.setGroup( "Autostart" ); | 168 | cfg.setGroup( "Autostart" ); |
169 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); | 169 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); |
170 | cfg.writeEntry( "autostart", m_autoStart ); | 170 | cfg.writeEntry( "autostart", m_autoStart ); |
171 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); | 171 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); |
172 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); | 172 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); |
173 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); | 173 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); |
174 | 174 | ||
175 | cfg.setGroup( "General" ); | 175 | cfg.setGroup( "General" ); |
176 | cfg.writeEntry( "IconSize", m_iconSize ); | 176 | cfg.writeEntry( "IconSize", m_iconSize ); |
177 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); | 177 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); |
178 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); | 178 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); |
179 | 179 | ||
180 | // set autostart settings | 180 | // set autostart settings |
181 | setAutoStart(); | 181 | setAutoStart(); |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void TodayConfig::moveSelectedUp() { | 185 | void TodayConfig::moveSelectedUp() { |
186 | QListViewItem *item = m_appletListView->selectedItem(); | 186 | QListViewItem *item = m_appletListView->selectedItem(); |
187 | if ( item && item->itemAbove() ) { | 187 | if ( item && item->itemAbove() ) { |
188 | item->itemAbove()->moveItem( item ); | 188 | item->itemAbove()->moveItem( item ); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | void TodayConfig::moveSelectedDown() { | 193 | void TodayConfig::moveSelectedDown() { |
194 | QListViewItem *item = m_appletListView->selectedItem(); | 194 | QListViewItem *item = m_appletListView->selectedItem(); |
195 | if ( item && item->itemBelow() ) { | 195 | if ( item && item->itemBelow() ) { |
196 | item->moveItem( item->itemBelow() ); | 196 | item->moveItem( item->itemBelow() ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | ||
201 | /** | 201 | /** |
202 | * Set up the icons in the order/active tab | 202 | * Set up the icons in the order/active tab |
203 | */ | 203 | */ |
204 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { | 204 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { |
205 | 205 | ||
206 | QCheckListItem *item; | 206 | QCheckListItem *item; |
207 | item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); | 207 | item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); |
208 | 208 | ||
209 | if ( !icon.isNull() ) { | 209 | if ( !icon.isNull() ) { |
210 | item->setPixmap( 0, icon ); | 210 | item->setPixmap( 0, icon ); |
211 | } | 211 | } |
212 | 212 | ||
213 | if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { | 213 | if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { |
214 | item->setOn( TRUE ); | 214 | item->setOn( TRUE ); |
215 | } | 215 | } |
216 | 216 | ||
217 | m_applets[libName] = item; | 217 | m_applets[libName] = item; |
218 | 218 | ||
219 | // kind of hack to get the first tab as default. | 219 | // kind of hack to get the first tab as default. |
220 | TabWidget3->setCurrentTab( tab_2 ); | 220 | TabWidget3->setCurrentTab( tab_2 ); |
221 | } | 221 | } |
222 | 222 | ||
223 | void TodayConfig::appletChanged() { | 223 | void TodayConfig::appletChanged() { |
224 | m_applets_changed = true; | 224 | m_applets_changed = true; |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | TodayConfig::~TodayConfig() { | 228 | TodayConfig::~TodayConfig() { |
229 | } | 229 | } |
230 | 230 | ||
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index b68aad2..a244e58 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,384 +1,384 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: 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 | 21 | -_. . . )=. = General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 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 <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <opie2/opimrecurrence.h> | 31 | #include <opie2/opimrecurrence.h> |
32 | #include <opie2/opimnotifymanager.h> | 32 | #include <opie2/opimnotifymanager.h> |
33 | #include <opie2/otodoaccessvcal.h> | 33 | #include <opie2/otodoaccessvcal.h> |
34 | #include <opie2/oapplicationfactory.h> | 34 | #include <opie2/oapplicationfactory.h> |
35 | 35 | ||
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/alarmserver.h> | 41 | #include <qpe/alarmserver.h> |
42 | #include <qpe/qpeapplication.h> | 42 | #include <qpe/qpeapplication.h> |
43 | 43 | ||
44 | #include <qmenubar.h> | 44 | #include <qmenubar.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | #include <qaction.h> | 47 | #include <qaction.h> |
48 | #include <qtimer.h> | 48 | #include <qtimer.h> |
49 | #include <qlayout.h> | 49 | #include <qlayout.h> |
50 | #include <qwhatsthis.h> | 50 | #include <qwhatsthis.h> |
51 | 51 | ||
52 | #include "quickeditimpl.h" | 52 | #include "quickeditimpl.h" |
53 | #include "todotemplatemanager.h" | 53 | #include "todotemplatemanager.h" |
54 | #include "templateeditor.h" | 54 | #include "templateeditor.h" |
55 | #include "tableview.h" | 55 | #include "tableview.h" |
56 | 56 | ||
57 | #include "textviewshow.h" | 57 | #include "textviewshow.h" |
58 | #include "todoeditor.h" | 58 | #include "todoeditor.h" |
59 | #include "mainwindow.h" | 59 | #include "mainwindow.h" |
60 | 60 | ||
61 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 61 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
62 | 62 | ||
63 | using namespace Todo; | 63 | using namespace Todo; |
64 | 64 | ||
65 | MainWindow::MainWindow( QWidget* parent, | 65 | MainWindow::MainWindow( QWidget* parent, |
66 | const char* name, WFlags ) | 66 | const char* name, WFlags ) |
67 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) | 67 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) |
68 | { | 68 | { |
69 | if (!name) | 69 | if (!name) |
70 | setName("todo window"); | 70 | setName("todo window"); |
71 | 71 | ||
72 | m_syncing = false; | 72 | m_syncing = false; |
73 | m_showing = false; | 73 | m_showing = false; |
74 | m_counter = 0; | 74 | m_counter = 0; |
75 | m_tempManager = new TemplateManager(); | 75 | m_tempManager = new TemplateManager(); |
76 | m_tempManager->load(); | 76 | m_tempManager->load(); |
77 | 77 | ||
78 | initUI(); | 78 | initUI(); |
79 | initConfig(); | 79 | initConfig(); |
80 | initViews(); | 80 | initViews(); |
81 | initActions(); | 81 | initActions(); |
82 | initEditor(); | 82 | initEditor(); |
83 | initShow(); | 83 | initShow(); |
84 | initTemplate(); | 84 | initTemplate(); |
85 | 85 | ||
86 | populateTemplates(); | 86 | populateTemplates(); |
87 | raiseCurrentView(); | 87 | raiseCurrentView(); |
88 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 88 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
89 | } | 89 | } |
90 | void MainWindow::initTemplate() { | 90 | void MainWindow::initTemplate() { |
91 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 91 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
92 | } | 92 | } |
93 | void MainWindow::initActions() { | 93 | void MainWindow::initActions() { |
94 | 94 | ||
95 | // Data menu | 95 | // Data menu |
96 | m_edit->insertItem(QWidget::tr("New from template"), m_template, | 96 | m_edit->insertItem(QWidget::tr("New from template"), m_template, |
97 | -1, 0 ); | 97 | -1, 0 ); |
98 | 98 | ||
99 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), | 99 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), |
100 | QString::null, 0, this, 0 ); | 100 | QString::null, 0, this, 0 ); |
101 | connect(a, SIGNAL( activated() ), | 101 | connect(a, SIGNAL( activated() ), |
102 | this, SLOT( slotNew() ) ); | 102 | this, SLOT( slotNew() ) ); |
103 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); | 103 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); |
104 | a->addTo(m_tool ); | 104 | a->addTo(m_tool ); |
105 | a->addTo(m_edit ); | 105 | a->addTo(m_edit ); |
106 | 106 | ||
107 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), | 107 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), |
108 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
109 | connect(a, SIGNAL(activated() ), | 109 | connect(a, SIGNAL(activated() ), |
110 | this, SLOT( slotEdit() ) ); | 110 | this, SLOT( slotEdit() ) ); |
111 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); | 111 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); |
112 | a->addTo( m_tool ); | 112 | a->addTo( m_tool ); |
113 | a->addTo( m_edit ); | 113 | a->addTo( m_edit ); |
114 | m_editAction = a; | 114 | m_editAction = a; |
115 | 115 | ||
116 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); | 116 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); |
117 | connect(a, SIGNAL( activated() ), | 117 | connect(a, SIGNAL( activated() ), |
118 | this, SLOT( slotShowDetails() ) ); | 118 | this, SLOT( slotShowDetails() ) ); |
119 | a->addTo( m_edit ); | 119 | a->addTo( m_edit ); |
120 | 120 | ||
121 | m_edit->insertSeparator(); | 121 | m_edit->insertSeparator(); |
122 | 122 | ||
123 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), | 123 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), |
124 | QString::null, 0, this, 0 ); | 124 | QString::null, 0, this, 0 ); |
125 | connect(a, SIGNAL(activated() ), | 125 | connect(a, SIGNAL(activated() ), |
126 | this, SLOT(slotDelete() ) ); | 126 | this, SLOT(slotDelete() ) ); |
127 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); | 127 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); |
128 | a->addTo( m_tool ); | 128 | a->addTo( m_tool ); |
129 | a->addTo( m_edit ); | 129 | a->addTo( m_edit ); |
130 | m_deleteAction = a; | 130 | m_deleteAction = a; |
131 | 131 | ||
132 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); | 132 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); |
133 | connect(a, SIGNAL( activated() ), | 133 | connect(a, SIGNAL( activated() ), |
134 | this, SLOT( slotDeleteAll() ) ); | 134 | this, SLOT( slotDeleteAll() ) ); |
135 | a->addTo(m_edit ); | 135 | a->addTo(m_edit ); |
136 | m_deleteAllAction = a; | 136 | m_deleteAllAction = a; |
137 | 137 | ||
138 | a = new QAction( QString::null, QWidget::tr("Delete completed"), | 138 | a = new QAction( QString::null, QWidget::tr("Delete completed"), |
139 | 0, this, 0 ); | 139 | 0, this, 0 ); |
140 | connect(a, SIGNAL( activated() ), | 140 | connect(a, SIGNAL( activated() ), |
141 | this, SLOT( slotDeleteCompleted() ) ); | 141 | this, SLOT( slotDeleteCompleted() ) ); |
142 | a->addTo(m_edit ); | 142 | a->addTo(m_edit ); |
143 | a->setEnabled( TRUE ); | 143 | a->setEnabled( TRUE ); |
144 | m_deleteCompleteAction = a; | 144 | m_deleteCompleteAction = a; |
145 | 145 | ||
146 | m_edit->insertSeparator(); | 146 | m_edit->insertSeparator(); |
147 | 147 | ||
148 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); | 148 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); |
149 | connect(a, SIGNAL( activated() ), | 149 | connect(a, SIGNAL( activated() ), |
150 | this, SLOT( slotDuplicate() ) ); | 150 | this, SLOT( slotDuplicate() ) ); |
151 | a->addTo(m_edit ); | 151 | a->addTo(m_edit ); |
152 | m_duplicateAction = a; | 152 | m_duplicateAction = a; |
153 | 153 | ||
154 | m_edit->insertSeparator(); | 154 | m_edit->insertSeparator(); |
155 | 155 | ||
156 | if ( Ir::supported() ) { | 156 | if ( Ir::supported() ) { |
157 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); | 157 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); |
158 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 158 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
159 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); | 159 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); |
160 | a->addTo( m_edit ); | 160 | a->addTo( m_edit ); |
161 | a->addTo( m_tool ); | 161 | a->addTo( m_tool ); |
162 | } | 162 | } |
163 | 163 | ||
164 | #if 0 | 164 | #if 0 |
165 | // Options menu | 165 | // Options menu |
166 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), | 166 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), |
167 | QString::null, 0, this, 0 ); | 167 | QString::null, 0, this, 0 ); |
168 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 168 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
169 | a->addTo( m_options ); | 169 | a->addTo( m_options ); |
170 | m_findAction = a; | 170 | m_findAction = a; |
171 | 171 | ||
172 | 172 | ||
173 | m_options->insertSeparator(); | 173 | m_options->insertSeparator(); |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 176 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
177 | 0, this, 0, TRUE ); | 177 | 0, this, 0, TRUE ); |
178 | m_completedAction->addTo( m_options ); | 178 | m_completedAction->addTo( m_options ); |
179 | m_completedAction->setOn( showCompleted() ); | 179 | m_completedAction->setOn( showCompleted() ); |
180 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); | 180 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); |
181 | 181 | ||
182 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 182 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
183 | 0, this, 0, TRUE ); | 183 | 0, this, 0, TRUE ); |
184 | a->addTo( m_options ); | 184 | a->addTo( m_options ); |
185 | a->setOn( showOverDue() ); | 185 | a->setOn( showOverDue() ); |
186 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); | 186 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); |
187 | 187 | ||
188 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 188 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
189 | 0, this, 0, TRUE ); | 189 | 0, this, 0, TRUE ); |
190 | m_showDeadLineAction->addTo( m_options ); | 190 | m_showDeadLineAction->addTo( m_options ); |
191 | m_showDeadLineAction->setOn( showDeadline() ); | 191 | m_showDeadLineAction->setOn( showDeadline() ); |
192 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); | 192 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); |
193 | 193 | ||
194 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 194 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
195 | 0, this, 0, TRUE ); | 195 | 0, this, 0, TRUE ); |
196 | m_showQuickTaskAction->addTo( m_options ); | 196 | m_showQuickTaskAction->addTo( m_options ); |
197 | m_showQuickTaskAction->setOn( showQuickTask() ); | 197 | m_showQuickTaskAction->setOn( showQuickTask() ); |
198 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); | 198 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); |
199 | 199 | ||
200 | m_options->insertSeparator(); | 200 | m_options->insertSeparator(); |
201 | 201 | ||
202 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); | 202 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); |
203 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); | 203 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); |
204 | m_bar->insertItem( QWidget::tr("Options"), m_options ); | 204 | m_bar->insertItem( QWidget::tr("Options"), m_options ); |
205 | 205 | ||
206 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 206 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
207 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); | 207 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); |
208 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 208 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
209 | 209 | ||
210 | } | 210 | } |
211 | /* m_curCat from Config */ | 211 | /* m_curCat from Config */ |
212 | void MainWindow::initConfig() { | 212 | void MainWindow::initConfig() { |
213 | Config config( "todo" ); | 213 | Config config( "todo" ); |
214 | config.setGroup( "View" ); | 214 | config.setGroup( "View" ); |
215 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 215 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
216 | m_curCat = config.readEntry( "Category", QString::null ); | 216 | m_curCat = config.readEntry( "Category", QString::null ); |
217 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 217 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
218 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); | 218 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); |
219 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); | 219 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); |
220 | } | 220 | } |
221 | void MainWindow::initUI() { | 221 | void MainWindow::initUI() { |
222 | 222 | ||
223 | m_stack = new OWidgetStack(this, "main stack"); | 223 | m_stack = new OWidgetStack(this, "main stack"); |
224 | 224 | ||
225 | setCentralWidget( m_stack ); | 225 | setCentralWidget( m_stack ); |
226 | 226 | ||
227 | setToolBarsMovable( FALSE ); | 227 | setToolBarsMovable( FALSE ); |
228 | 228 | ||
229 | QToolBar *menubarholder = new QToolBar( this ); | 229 | QToolBar *menubarholder = new QToolBar( this ); |
230 | menubarholder->setHorizontalStretchable( TRUE ); | 230 | menubarholder->setHorizontalStretchable( TRUE ); |
231 | m_bar = new QMenuBar( menubarholder ); | 231 | m_bar = new QMenuBar( menubarholder ); |
232 | 232 | ||
233 | m_tool = new QToolBar( this ); | 233 | m_tool = new QToolBar( this ); |
234 | 234 | ||
235 | /** QPopupMenu */ | 235 | /** QPopupMenu */ |
236 | m_edit = new QPopupMenu( this ); | 236 | m_edit = new QPopupMenu( this ); |
237 | m_options = new QPopupMenu( this ); | 237 | m_options = new QPopupMenu( this ); |
238 | m_catMenu = new QPopupMenu( this ); | 238 | m_catMenu = new QPopupMenu( this ); |
239 | m_template = new QPopupMenu( this ); | 239 | m_template = new QPopupMenu( this ); |
240 | 240 | ||
241 | m_catMenu->setCheckable( TRUE ); | 241 | m_catMenu->setCheckable( TRUE ); |
242 | m_template->setCheckable( TRUE ); | 242 | m_template->setCheckable( TRUE ); |
243 | 243 | ||
244 | connect(m_catMenu, SIGNAL(activated(int) ), | 244 | connect(m_catMenu, SIGNAL(activated(int) ), |
245 | this, SLOT(setCategory(int) ) ); | 245 | this, SLOT(setCategory(int) ) ); |
246 | connect(m_template, SIGNAL(activated(int) ), | 246 | connect(m_template, SIGNAL(activated(int) ), |
247 | this, SLOT(slotNewFromTemplate(int) ) ); | 247 | this, SLOT(slotNewFromTemplate(int) ) ); |
248 | } | 248 | } |
249 | void MainWindow::initViews() { | 249 | void MainWindow::initViews() { |
250 | 250 | ||
251 | TableView* tableView = new TableView( this, m_stack ); | 251 | TableView* tableView = new TableView( this, m_stack ); |
252 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); | 252 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); |
253 | m_stack->addWidget( tableView, m_counter++ ); | 253 | m_stack->addWidget( tableView, m_counter++ ); |
254 | m_views.append( tableView ); | 254 | m_views.append( tableView ); |
255 | m_curView = tableView; | 255 | m_curView = tableView; |
256 | connectBase( tableView ); | 256 | connectBase( tableView ); |
257 | /* add QString type + QString configname to | 257 | /* add QString type + QString configname to |
258 | * the View menu | 258 | * the View menu |
259 | * and subdirs for multiple views | 259 | * and subdirs for multiple views |
260 | */ | 260 | */ |
261 | } | 261 | } |
262 | void MainWindow::initEditor() { | 262 | void MainWindow::initEditor() { |
263 | m_curEdit = new Editor(); | 263 | m_curEdit = new Editor(); |
264 | } | 264 | } |
265 | void MainWindow::initShow() { | 265 | void MainWindow::initShow() { |
266 | m_curShow = new TextViewShow(this, this); | 266 | m_curShow = new TextViewShow(this, this); |
267 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 267 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
268 | } | 268 | } |
269 | MainWindow::~MainWindow() { | 269 | MainWindow::~MainWindow() { |
270 | delete templateManager(); | 270 | delete templateManager(); |
271 | } | 271 | } |
272 | void MainWindow::connectBase( ViewBase* ) { | 272 | void MainWindow::connectBase( ViewBase* ) { |
273 | // once templates and signals mix we'll use it again | 273 | // once templates and signals mix we'll use it again |
274 | } | 274 | } |
275 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 275 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
276 | QPopupMenu* menu = new QPopupMenu(); | 276 | QPopupMenu* menu = new QPopupMenu(); |
277 | 277 | ||
278 | m_editAction->addTo( menu ); | 278 | m_editAction->addTo( menu ); |
279 | m_deleteAction->addTo( menu ); | 279 | m_deleteAction->addTo( menu ); |
280 | m_duplicateAction->addTo( menu ); | 280 | m_duplicateAction->addTo( menu ); |
281 | 281 | ||
282 | menu->insertSeparator(); | 282 | menu->insertSeparator(); |
283 | 283 | ||
284 | /* | 284 | /* |
285 | * if this event recurs we allow | 285 | * if this event recurs we allow |
286 | * to detach it. | 286 | * to detach it. |
287 | * remove all | 287 | * remove all |
288 | */ | 288 | */ |
289 | if ( recur ) { | 289 | if ( recur ) { |
290 | ; // FIXME | 290 | ; // FIXME |
291 | } | 291 | } |
292 | 292 | ||
293 | return menu; | 293 | return menu; |
294 | } | 294 | } |
295 | QPopupMenu* MainWindow::options() { | 295 | QPopupMenu* MainWindow::options() { |
296 | qWarning("Options"); | 296 | qWarning("Options"); |
297 | return m_options; | 297 | return m_options; |
298 | } | 298 | } |
299 | QPopupMenu* MainWindow::edit() { | 299 | QPopupMenu* MainWindow::edit() { |
300 | return m_edit; | 300 | return m_edit; |
301 | } | 301 | } |
302 | QToolBar* MainWindow::toolbar() { | 302 | QToolBar* MainWindow::toolbar() { |
303 | return m_tool; | 303 | return m_tool; |
304 | } | 304 | } |
305 | OPimTodoAccess::List MainWindow::list()const { | 305 | OPimTodoAccess::List MainWindow::list()const { |
306 | return m_todoMgr.list(); | 306 | return m_todoMgr.list(); |
307 | } | 307 | } |
308 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 308 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
309 | int cat = 0; | 309 | int cat = 0; |
310 | if ( m_curCat != QWidget::tr("All Categories") ) | 310 | if ( m_curCat != QWidget::tr("All Categories") ) |
311 | cat = currentCatId(); | 311 | cat = currentCatId(); |
312 | if ( m_curCat == QWidget::tr("Unfiled") ) | 312 | if ( m_curCat == QWidget::tr("Unfiled") ) |
313 | cat = -1; | 313 | cat = -1; |
314 | 314 | ||
315 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); | 315 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); |
316 | 316 | ||
317 | int filter = 1; | 317 | int filter = 1; |
318 | 318 | ||
319 | if (!m_completed ) | 319 | if (!m_completed ) |
320 | filter |= 4; | 320 | filter |= 4; |
321 | if (m_overdue) | 321 | if (m_overdue) |
322 | filter |= 2; | 322 | filter |= 2; |
323 | 323 | ||
324 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 324 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
325 | } | 325 | } |
326 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 326 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
327 | int cat = 0; | 327 | int cat = 0; |
328 | if ( m_curCat != QWidget::tr("All Categories") ) | 328 | if ( m_curCat != QWidget::tr("All Categories") ) |
329 | cat = currentCatId(); | 329 | cat = currentCatId(); |
330 | 330 | ||
331 | if ( m_curCat == QWidget::tr("Unfiled") ) | 331 | if ( m_curCat == QWidget::tr("Unfiled") ) |
332 | cat = -1; | 332 | cat = -1; |
333 | 333 | ||
334 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 334 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
335 | } | 335 | } |
336 | OPimTodo MainWindow::event( int uid ) { | 336 | OPimTodo MainWindow::event( int uid ) { |
337 | return m_todoMgr.event( uid ); | 337 | return m_todoMgr.event( uid ); |
338 | } | 338 | } |
339 | bool MainWindow::isSyncing()const { | 339 | bool MainWindow::isSyncing()const { |
340 | return m_syncing; | 340 | return m_syncing; |
341 | } | 341 | } |
342 | TemplateManager* MainWindow::templateManager() { | 342 | TemplateManager* MainWindow::templateManager() { |
343 | return m_tempManager; | 343 | return m_tempManager; |
344 | } | 344 | } |
345 | Editor* MainWindow::currentEditor() { | 345 | Editor* MainWindow::currentEditor() { |
346 | return m_curEdit; | 346 | return m_curEdit; |
347 | } | 347 | } |
348 | TodoShow* MainWindow::currentShow() { | 348 | TodoShow* MainWindow::currentShow() { |
349 | return m_curShow; | 349 | return m_curShow; |
350 | } | 350 | } |
351 | void MainWindow::slotReload() { | 351 | void MainWindow::slotReload() { |
352 | m_syncing = FALSE; | 352 | m_syncing = FALSE; |
353 | m_todoMgr.reload(); | 353 | m_todoMgr.reload(); |
354 | currentView()->updateView( ); | 354 | currentView()->updateView( ); |
355 | raiseCurrentView(); | 355 | raiseCurrentView(); |
356 | } | 356 | } |
357 | void MainWindow::closeEvent( QCloseEvent* e ) { | 357 | void MainWindow::closeEvent( QCloseEvent* e ) { |
358 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 358 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
359 | m_showing = false; | 359 | m_showing = false; |
360 | raiseCurrentView(); | 360 | raiseCurrentView(); |
361 | e->ignore(); | 361 | e->ignore(); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | /* | 364 | /* |
365 | * we should have flushed and now we're still saving | 365 | * we should have flushed and now we're still saving |
366 | * so there is no need to flush | 366 | * so there is no need to flush |
367 | */ | 367 | */ |
368 | if (m_syncing ) { | 368 | if (m_syncing ) { |
369 | e->accept(); | 369 | e->accept(); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | bool quit = false; | 372 | bool quit = false; |
373 | if ( m_todoMgr.saveAll() ){ | 373 | if ( m_todoMgr.saveAll() ){ |
374 | qWarning("saved"); | 374 | qWarning("saved"); |
375 | quit = true; | 375 | quit = true; |
376 | }else { | 376 | }else { |
377 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 377 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
378 | QWidget::tr("Todo was unable\n" | 378 | QWidget::tr("Todo was unable\n" |
379 | "to save your changes.\n" | 379 | "to save your changes.\n" |
380 | "Free up some space\n" | 380 | "Free up some space\n" |
381 | "and try again.\n" | 381 | "and try again.\n" |
382 | "\nQuit Anyway?"), | 382 | "\nQuit Anyway?"), |
383 | QMessageBox::Yes|QMessageBox::Escape, | 383 | QMessageBox::Yes|QMessageBox::Escape, |
384 | QMessageBox::No|QMessageBox::Default) | 384 | QMessageBox::No|QMessageBox::Default) |
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp index ab1ce94..d1e50f7 100644 --- a/core/pim/todo/otaskeditor.cpp +++ b/core/pim/todo/otaskeditor.cpp | |||
@@ -1,90 +1,90 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | 2 | ||
3 | #include "taskeditoroverview.h" | 3 | #include "taskeditoroverview.h" |
4 | #include "taskeditorstatus.h" | 4 | #include "taskeditorstatus.h" |
5 | #include "taskeditoralarms.h" | 5 | #include "taskeditoralarms.h" |
6 | 6 | ||
7 | #include "otaskeditor.h" | 7 | #include "otaskeditor.h" |
8 | 8 | ||
9 | OTaskEditor::OTaskEditor(int cur) | 9 | OTaskEditor::OTaskEditor(int cur) |
10 | : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { | 10 | : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { |
11 | init(); | 11 | init(); |
12 | init( cur ); | 12 | init( cur ); |
13 | } | 13 | } |
14 | OTaskEditor::OTaskEditor( const OPimTodo& to) | 14 | OTaskEditor::OTaskEditor( const OPimTodo& to) |
15 | : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { | 15 | : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { |
16 | init(); | 16 | init(); |
17 | init( to ); | 17 | init( to ); |
18 | } | 18 | } |
19 | OTaskEditor::~OTaskEditor() { | 19 | OTaskEditor::~OTaskEditor() { |
20 | 20 | ||
21 | } | 21 | } |
22 | void OTaskEditor::init( int cur ) { | 22 | void OTaskEditor::init( int cur ) { |
23 | OPimTodo to; | 23 | OPimTodo to; |
24 | to.setUid( 1 ); // generate a new uid | 24 | to.setUid( 1 ); // generate a new uid |
25 | if ( cur != 0 ) | 25 | if ( cur != 0 ) |
26 | to.setCategories( cur ); | 26 | to.setCategories( cur ); |
27 | load(to); | 27 | load(to); |
28 | } | 28 | } |
29 | void OTaskEditor::init( const OPimTodo& to ) { | 29 | void OTaskEditor::init( const OPimTodo& to ) { |
30 | load( to ); | 30 | load( to ); |
31 | } | 31 | } |
32 | OPimTodo OTaskEditor::todo()const{ | 32 | OPimTodo OTaskEditor::todo()const{ |
33 | qWarning("saving!"); | 33 | qWarning("saving!"); |
34 | OPimTodo to ( m_todo ); | 34 | OPimTodo to ( m_todo ); |
35 | m_overView->save( to ); | 35 | m_overView->save( to ); |
36 | m_stat->save( to ); | 36 | m_stat->save( to ); |
37 | to.setRecurrence( m_rec->recurrence() ); | 37 | to.setRecurrence( m_rec->recurrence() ); |
38 | m_alarm->save( to ); | 38 | m_alarm->save( to ); |
39 | 39 | ||
40 | return to; | 40 | return to; |
41 | } | 41 | } |
42 | void OTaskEditor::load(const OPimTodo& to) { | 42 | void OTaskEditor::load(const OPimTodo& to) { |
43 | m_overView->load( to ); | 43 | m_overView->load( to ); |
44 | m_stat->load( to ); | 44 | m_stat->load( to ); |
45 | m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); | 45 | m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); |
46 | m_alarm->load( to ); | 46 | m_alarm->load( to ); |
47 | 47 | ||
48 | m_todo = to; | 48 | m_todo = to; |
49 | } | 49 | } |
50 | void OTaskEditor::init() { | 50 | void OTaskEditor::init() { |
51 | setCaption(tr("Task Editor") ); | 51 | setCaption(tr("Task Editor") ); |
52 | 52 | ||
53 | QVBoxLayout* layo = new QVBoxLayout( this ); | 53 | QVBoxLayout* layo = new QVBoxLayout( this ); |
54 | m_tab = new OTabWidget( this ); | 54 | m_tab = new OTabWidget( this ); |
55 | layo->addWidget( m_tab ); | 55 | layo->addWidget( m_tab ); |
56 | 56 | ||
57 | /* | 57 | /* |
58 | * Add the Widgets | 58 | * Add the Widgets |
59 | */ | 59 | */ |
60 | m_overView = new TaskEditorOverView( m_tab ); | 60 | m_overView = new TaskEditorOverView( m_tab ); |
61 | m_tab->addTab( m_overView, "todo/info", tr("Information") ); | 61 | m_tab->addTab( m_overView, "todo/info", tr("Information") ); |
62 | 62 | ||
63 | m_stat = new TaskEditorStatus( m_tab ); | 63 | m_stat = new TaskEditorStatus( m_tab ); |
64 | m_tab->addTab( m_stat, "todo/TodoList", tr("Status") ); | 64 | m_tab->addTab( m_stat, "todo/TodoList", tr("Status") ); |
65 | 65 | ||
66 | m_alarm = new TaskEditorAlarms( m_tab ); | 66 | m_alarm = new TaskEditorAlarms( m_tab ); |
67 | m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") ); | 67 | m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") ); |
68 | 68 | ||
69 | // m_remind = new TaskEditorAlarms( m_tab ); | 69 | // m_remind = new TaskEditorAlarms( m_tab ); |
70 | // m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") ); | 70 | // m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") ); |
71 | 71 | ||
72 | // QLabel* lbl = new QLabel( m_tab ); | 72 | // QLabel* lbl = new QLabel( m_tab ); |
73 | // lbl->setText( tr("X-Ref") ); | 73 | // lbl->setText( tr("X-Ref") ); |
74 | // m_tab->addTab( lbl, "todo/xref", tr("X-Ref") ); | 74 | // m_tab->addTab( lbl, "todo/xref", tr("X-Ref") ); |
75 | 75 | ||
76 | m_rec = new OPimRecurrenceWidget( true, QDate::currentDate(), this ); | 76 | m_rec = new OPimRecurrenceWidget( true, QDate::currentDate(), this ); |
77 | m_tab->addTab( m_rec, "repeat", tr("Recurrence") ); | 77 | m_tab->addTab( m_rec, "repeat", tr("Recurrence") ); |
78 | 78 | ||
79 | 79 | ||
80 | /* signal and slots */ | 80 | /* signal and slots */ |
81 | connect(m_overView, SIGNAL(recurranceEnabled(bool) ), | 81 | connect(m_overView, SIGNAL(recurranceEnabled(bool) ), |
82 | m_rec, SLOT(setEnabled(bool) ) ); | 82 | m_rec, SLOT(setEnabled(bool) ) ); |
83 | 83 | ||
84 | /* connect due date changed to the recurrence tab */ | 84 | /* connect due date changed to the recurrence tab */ |
85 | connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ), | 85 | connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ), |
86 | m_rec, SLOT(setStartDate(const QDate& ) ) ); | 86 | m_rec, SLOT(setStartDate(const QDate&) ) ); |
87 | 87 | ||
88 | 88 | ||
89 | m_tab->setCurrentTab( m_overView ); | 89 | m_tab->setCurrentTab( m_overView ); |
90 | } | 90 | } |
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 5bbf880..0d298f4 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,318 +1,318 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <zecke> | 3 | .=l. Copyright (c) 2002 <zecke> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <cmath> | 29 | #include <cmath> |
30 | #include <cctype> | 30 | #include <cctype> |
31 | 31 | ||
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <opie2/opimrecurrence.h> | 40 | #include <opie2/opimrecurrence.h> |
41 | 41 | ||
42 | #include "mainwindow.h" | 42 | #include "mainwindow.h" |
43 | //#include "tableitems.h" | 43 | //#include "tableitems.h" |
44 | #include "tableview.h" | 44 | #include "tableview.h" |
45 | 45 | ||
46 | using namespace Todo; | 46 | using namespace Todo; |
47 | 47 | ||
48 | namespace { | 48 | namespace { |
49 | static const int BoxSize = 14; | 49 | static const int BoxSize = 14; |
50 | static const int RowHeight = 20; | 50 | static const int RowHeight = 20; |
51 | } | 51 | } |
52 | 52 | ||
53 | TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { | 53 | TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { |
54 | } | 54 | } |
55 | void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { | 55 | void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { |
56 | m_wid = wid; | 56 | m_wid = wid; |
57 | m_row = row; | 57 | m_row = row; |
58 | m_col = col; | 58 | m_col = col; |
59 | } | 59 | } |
60 | void TableView::EditorWidget::releaseCellWidget() { | 60 | void TableView::EditorWidget::releaseCellWidget() { |
61 | m_wid = 0; | 61 | m_wid = 0; |
62 | m_row = m_col = -1; | 62 | m_row = m_col = -1; |
63 | } | 63 | } |
64 | QWidget* TableView::EditorWidget::cellWidget()const { | 64 | QWidget* TableView::EditorWidget::cellWidget()const { |
65 | return m_wid; | 65 | return m_wid; |
66 | } | 66 | } |
67 | int TableView::EditorWidget::cellRow()const { | 67 | int TableView::EditorWidget::cellRow()const { |
68 | return m_row; | 68 | return m_row; |
69 | } | 69 | } |
70 | int TableView::EditorWidget::cellCol()const { | 70 | int TableView::EditorWidget::cellCol()const { |
71 | return m_col; | 71 | return m_col; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | void TableView::initConfig() { | 75 | void TableView::initConfig() { |
76 | Config config( "todo" ); | 76 | Config config( "todo" ); |
77 | config.setGroup( "Options" ); | 77 | config.setGroup( "Options" ); |
78 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); | 78 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); |
79 | for (int i = 0; i < numCols(); i++ ) { | 79 | for (int i = 0; i < numCols(); i++ ) { |
80 | int width = config.readNumEntry("Width"+QString::number(i), -1 ); | 80 | int width = config.readNumEntry("Width"+QString::number(i), -1 ); |
81 | setColumnWidth(i, width == -1 ? columnWidth(i) : width ); | 81 | setColumnWidth(i, width == -1 ? columnWidth(i) : width ); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | TableView::TableView( MainWindow* window, QWidget* wid ) | 85 | TableView::TableView( MainWindow* window, QWidget* wid ) |
86 | : QTable( wid ), TodoView( window ) { | 86 | : QTable( wid ), TodoView( window ) { |
87 | 87 | ||
88 | setName("TableView"); | 88 | setName("TableView"); |
89 | // Load icons | 89 | // Load icons |
90 | // TODO - probably should be done globally somewhere else, | 90 | // TODO - probably should be done globally somewhere else, |
91 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h | 91 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h |
92 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); | 92 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); |
93 | QString namestr; | 93 | QString namestr; |
94 | for ( unsigned int i = 1; i < 6; i++ ) { | 94 | for ( unsigned int i = 1; i < 6; i++ ) { |
95 | namestr = "todo/priority"; | 95 | namestr = "todo/priority"; |
96 | namestr.append( QString::number( i ) ); | 96 | namestr.append( QString::number( i ) ); |
97 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); | 97 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); |
98 | } | 98 | } |
99 | 99 | ||
100 | setUpdatesEnabled( false ); | 100 | setUpdatesEnabled( false ); |
101 | viewport()->setUpdatesEnabled( false ); | 101 | viewport()->setUpdatesEnabled( false ); |
102 | m_enablePaint = false; | 102 | m_enablePaint = false; |
103 | setNumRows(0); | 103 | setNumRows(0); |
104 | setNumCols(4); | 104 | setNumCols(4); |
105 | 105 | ||
106 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); | 106 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); |
107 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); | 107 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); |
108 | horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) ); | 108 | horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) ); |
109 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); | 109 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); |
110 | 110 | ||
111 | setShowDeadline( todoWindow()->showDeadline() ); | 111 | setShowDeadline( todoWindow()->showDeadline() ); |
112 | 112 | ||
113 | setSorting( TRUE ); | 113 | setSorting( TRUE ); |
114 | setSelectionMode( NoSelection ); | 114 | setSelectionMode( NoSelection ); |
115 | 115 | ||
116 | setLeftMargin( 0 ); | 116 | setLeftMargin( 0 ); |
117 | verticalHeader()->hide(); | 117 | verticalHeader()->hide(); |
118 | 118 | ||
119 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 119 | connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ), |
120 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 120 | this, SLOT( slotClicked(int,int,int,const QPoint&) ) ); |
121 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 121 | connect((QTable*)this, SIGNAL( pressed(int,int,int,const QPoint&) ), |
122 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 122 | this, SLOT( slotPressed(int,int,int,const QPoint&) ) ); |
123 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 123 | connect((QTable*)this, SIGNAL(valueChanged(int,int) ), |
124 | this, SLOT( slotValueChanged(int, int) ) ); | 124 | this, SLOT( slotValueChanged(int,int) ) ); |
125 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 125 | connect((QTable*)this, SIGNAL(currentChanged(int,int) ), |
126 | this, SLOT( slotCurrentChanged(int, int) ) ); | 126 | this, SLOT( slotCurrentChanged(int,int) ) ); |
127 | 127 | ||
128 | m_menuTimer = new QTimer( this ); | 128 | m_menuTimer = new QTimer( this ); |
129 | connect( m_menuTimer, SIGNAL(timeout()), | 129 | connect( m_menuTimer, SIGNAL(timeout()), |
130 | this, SLOT(slotShowMenu()) ); | 130 | this, SLOT(slotShowMenu()) ); |
131 | 131 | ||
132 | /* now let's init the config */ | 132 | /* now let's init the config */ |
133 | initConfig(); | 133 | initConfig(); |
134 | 134 | ||
135 | 135 | ||
136 | m_enablePaint = true; | 136 | m_enablePaint = true; |
137 | setUpdatesEnabled( true ); | 137 | setUpdatesEnabled( true ); |
138 | viewport()->setUpdatesEnabled( true ); | 138 | viewport()->setUpdatesEnabled( true ); |
139 | viewport()->update(); | 139 | viewport()->update(); |
140 | setSortOrder( 0 ); | 140 | setSortOrder( 0 ); |
141 | setAscending( TRUE ); | 141 | setAscending( TRUE ); |
142 | m_first = true; | 142 | m_first = true; |
143 | 143 | ||
144 | 144 | ||
145 | } | 145 | } |
146 | /* a new day has started | 146 | /* a new day has started |
147 | * update the day | 147 | * update the day |
148 | */ | 148 | */ |
149 | void TableView::newDay() { | 149 | void TableView::newDay() { |
150 | clear(); | 150 | clear(); |
151 | updateView(); | 151 | updateView(); |
152 | } | 152 | } |
153 | TableView::~TableView() { | 153 | TableView::~TableView() { |
154 | Config config( "todo" ); | 154 | Config config( "todo" ); |
155 | config.setGroup( "Options" ); | 155 | config.setGroup( "Options" ); |
156 | for (int i = 0; i < numCols(); i++ ) | 156 | for (int i = 0; i < numCols(); i++ ) |
157 | config.writeEntry("Width"+QString::number(i), columnWidth(i) ); | 157 | config.writeEntry("Width"+QString::number(i), columnWidth(i) ); |
158 | } | 158 | } |
159 | void TableView::slotShowMenu() { | 159 | void TableView::slotShowMenu() { |
160 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); | 160 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); |
161 | menu->exec(QCursor::pos() ); | 161 | menu->exec(QCursor::pos() ); |
162 | delete menu; | 162 | delete menu; |
163 | } | 163 | } |
164 | QString TableView::type() const { | 164 | QString TableView::type() const { |
165 | return QString::fromLatin1( tr("Table View") ); | 165 | return QString::fromLatin1( tr("Table View") ); |
166 | } | 166 | } |
167 | int TableView::current() { | 167 | int TableView::current() { |
168 | if (numRows() == 0 ) return 0; | 168 | if (numRows() == 0 ) return 0; |
169 | int uid = sorted().uidAt(currentRow() ); | 169 | int uid = sorted().uidAt(currentRow() ); |
170 | 170 | ||
171 | return uid; | 171 | return uid; |
172 | } | 172 | } |
173 | int TableView::next() { | 173 | int TableView::next() { |
174 | if ( numRows() == 0 ) return 0; | 174 | if ( numRows() == 0 ) return 0; |
175 | if ( currentRow() + 1 >= numRows() ) return 0; | 175 | if ( currentRow() + 1 >= numRows() ) return 0; |
176 | setCurrentCell( currentRow() +1, currentColumn() ); | 176 | setCurrentCell( currentRow() +1, currentColumn() ); |
177 | return sorted().uidAt( currentRow() ); | 177 | return sorted().uidAt( currentRow() ); |
178 | } | 178 | } |
179 | int TableView::prev() { | 179 | int TableView::prev() { |
180 | if ( numRows() == 0 ) return 0; | 180 | if ( numRows() == 0 ) return 0; |
181 | if ( currentRow() - 1 < 0 ) return 0; | 181 | if ( currentRow() - 1 < 0 ) return 0; |
182 | setCurrentCell( currentRow() -1, currentColumn() ); | 182 | setCurrentCell( currentRow() -1, currentColumn() ); |
183 | return sorted().uidAt( currentRow() ); | 183 | return sorted().uidAt( currentRow() ); |
184 | 184 | ||
185 | } | 185 | } |
186 | QString TableView::currentRepresentation() { | 186 | QString TableView::currentRepresentation() { |
187 | OPimTodo to = sorted()[currentRow()]; | 187 | OPimTodo to = sorted()[currentRow()]; |
188 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | 188 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; |
189 | } | 189 | } |
190 | /* show overdue */ | 190 | /* show overdue */ |
191 | void TableView::showOverDue( bool ) { | 191 | void TableView::showOverDue( bool ) { |
192 | clear(); | 192 | clear(); |
193 | updateView(); | 193 | updateView(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void TableView::updateView( ) { | 196 | void TableView::updateView( ) { |
197 | qWarning("update view"); | 197 | qWarning("update view"); |
198 | m_row = false; | 198 | m_row = false; |
199 | static int id; | 199 | static int id; |
200 | id = startTimer(4000 ); | 200 | id = startTimer(4000 ); |
201 | /* FIXME we want one page to be read! | 201 | /* FIXME we want one page to be read! |
202 | * | 202 | * |
203 | * Calculate that screensize | 203 | * Calculate that screensize |
204 | */ | 204 | */ |
205 | todoWindow()->setReadAhead( 4 ); | 205 | todoWindow()->setReadAhead( 4 ); |
206 | sort(); | 206 | sort(); |
207 | OPimTodoAccess::List::Iterator it, end; | 207 | OPimTodoAccess::List::Iterator it, end; |
208 | it = sorted().begin(); | 208 | it = sorted().begin(); |
209 | end = sorted().end(); | 209 | end = sorted().end(); |
210 | 210 | ||
211 | qWarning("setTodos"); | 211 | qWarning("setTodos"); |
212 | QTime time; | 212 | QTime time; |
213 | time.start(); | 213 | time.start(); |
214 | m_enablePaint = false; | 214 | m_enablePaint = false; |
215 | setUpdatesEnabled( false ); | 215 | setUpdatesEnabled( false ); |
216 | viewport()->setUpdatesEnabled( false ); | 216 | viewport()->setUpdatesEnabled( false ); |
217 | 217 | ||
218 | setNumRows( it.count() ); | 218 | setNumRows( it.count() ); |
219 | if ( it.count() == 0 ) | 219 | if ( it.count() == 0 ) |
220 | killTimer(id); | 220 | killTimer(id); |
221 | 221 | ||
222 | // int elc = time.elapsed(); | 222 | // int elc = time.elapsed(); |
223 | setUpdatesEnabled( true ); | 223 | setUpdatesEnabled( true ); |
224 | viewport()->setUpdatesEnabled( true ); | 224 | viewport()->setUpdatesEnabled( true ); |
225 | viewport()->update(); | 225 | viewport()->update(); |
226 | 226 | ||
227 | m_enablePaint = true; | 227 | m_enablePaint = true; |
228 | // int el = time.elapsed(); | 228 | // int el = time.elapsed(); |
229 | } | 229 | } |
230 | void TableView::setTodo( int, const OPimTodo&) { | 230 | void TableView::setTodo( int, const OPimTodo&) { |
231 | sort(); | 231 | sort(); |
232 | 232 | ||
233 | /* repaint */ | 233 | /* repaint */ |
234 | repaint(); | 234 | repaint(); |
235 | } | 235 | } |
236 | void TableView::addEvent( const OPimTodo&) { | 236 | void TableView::addEvent( const OPimTodo&) { |
237 | 237 | ||
238 | /* fix problems of not showing the 'Haken' */ | 238 | /* fix problems of not showing the 'Haken' */ |
239 | updateView(); | 239 | updateView(); |
240 | } | 240 | } |
241 | /* | 241 | /* |
242 | * find the event | 242 | * find the event |
243 | * and then replace the complete row | 243 | * and then replace the complete row |
244 | */ | 244 | */ |
245 | void TableView::replaceEvent( const OPimTodo& ev) { | 245 | void TableView::replaceEvent( const OPimTodo& ev) { |
246 | addEvent( ev ); | 246 | addEvent( ev ); |
247 | } | 247 | } |
248 | /* | 248 | /* |
249 | * re aligning table can be slow too | 249 | * re aligning table can be slow too |
250 | * FIXME: look what performs better | 250 | * FIXME: look what performs better |
251 | * either this or the old align table | 251 | * either this or the old align table |
252 | */ | 252 | */ |
253 | void TableView::removeEvent( int ) { | 253 | void TableView::removeEvent( int ) { |
254 | updateView(); | 254 | updateView(); |
255 | } | 255 | } |
256 | void TableView::setShowCompleted( bool b) { | 256 | void TableView::setShowCompleted( bool b) { |
257 | qWarning("Show Completed %d" , b ); | 257 | qWarning("Show Completed %d" , b ); |
258 | updateView(); | 258 | updateView(); |
259 | } | 259 | } |
260 | void TableView::setShowDeadline( bool b ) { | 260 | void TableView::setShowDeadline( bool b ) { |
261 | qWarning( "Show DeadLine %d" , b ); | 261 | qWarning( "Show DeadLine %d" , b ); |
262 | if ( b ) | 262 | if ( b ) |
263 | showColumn( 3 ); | 263 | showColumn( 3 ); |
264 | else | 264 | else |
265 | hideColumn( 3 ); | 265 | hideColumn( 3 ); |
266 | 266 | ||
267 | // Try to intelligently size columns | 267 | // Try to intelligently size columns |
268 | // TODO - would use width() below, but doesn't have valid value at time of c'tor | 268 | // TODO - would use width() below, but doesn't have valid value at time of c'tor |
269 | int col2width = 238; | 269 | int col2width = 238; |
270 | int width = m_pic_completed.width(); | 270 | int width = m_pic_completed.width(); |
271 | setColumnWidth( 0, width ); | 271 | setColumnWidth( 0, width ); |
272 | col2width -= width; | 272 | col2width -= width; |
273 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; | 273 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; |
274 | setColumnWidth( 1, width ); | 274 | setColumnWidth( 1, width ); |
275 | col2width -= width; | 275 | col2width -= width; |
276 | if ( b ) { | 276 | if ( b ) { |
277 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; | 277 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; |
278 | setColumnWidth( 3, width ); | 278 | setColumnWidth( 3, width ); |
279 | col2width -= width; | 279 | col2width -= width; |
280 | } | 280 | } |
281 | setColumnWidth( 2, col2width ); | 281 | setColumnWidth( 2, col2width ); |
282 | } | 282 | } |
283 | void TableView::setShowCategory( const QString& str) { | 283 | void TableView::setShowCategory( const QString& str) { |
284 | qWarning("setShowCategory"); | 284 | qWarning("setShowCategory"); |
285 | if ( str != m_oleCat || m_first ) | 285 | if ( str != m_oleCat || m_first ) |
286 | updateView(); | 286 | updateView(); |
287 | 287 | ||
288 | m_oleCat = str; | 288 | m_oleCat = str; |
289 | m_first = false; | 289 | m_first = false; |
290 | 290 | ||
291 | } | 291 | } |
292 | void TableView::clear() { | 292 | void TableView::clear() { |
293 | setNumRows(0); | 293 | setNumRows(0); |
294 | } | 294 | } |
295 | void TableView::slotClicked(int row, int col, int, | 295 | void TableView::slotClicked(int row, int col, int, |
296 | const QPoint& point) { | 296 | const QPoint& point) { |
297 | if ( m_editorWidget.cellWidget() ) { | 297 | if ( m_editorWidget.cellWidget() ) { |
298 | //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); | 298 | //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); |
299 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), | 299 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), |
300 | true, true ); | 300 | true, true ); |
301 | m_editorWidget.releaseCellWidget(); | 301 | m_editorWidget.releaseCellWidget(); |
302 | } | 302 | } |
303 | 303 | ||
304 | if ( !cellGeometry(row, col ).contains(point ) ) | 304 | if ( !cellGeometry(row, col ).contains(point ) ) |
305 | return; | 305 | return; |
306 | 306 | ||
307 | int ui= sorted().uidAt( row ); | 307 | int ui= sorted().uidAt( row ); |
308 | 308 | ||
309 | 309 | ||
310 | switch( col ) { | 310 | switch( col ) { |
311 | case 0:{ | 311 | case 0:{ |
312 | int x = point.x() -columnPos( col ); | 312 | int x = point.x() -columnPos( col ); |
313 | int y = point.y() -rowPos( row ); | 313 | int y = point.y() -rowPos( row ); |
314 | int w = columnWidth( col ); | 314 | int w = columnWidth( col ); |
315 | int h = rowHeight( row ); | 315 | int h = rowHeight( row ); |
316 | if ( x >= ( w - BoxSize ) / 2 && | 316 | if ( x >= ( w - BoxSize ) / 2 && |
317 | x <= ( w - BoxSize ) / 2 + BoxSize && | 317 | x <= ( w - BoxSize ) / 2 + BoxSize && |
318 | y >= ( h - BoxSize ) / 2 && | 318 | y >= ( h - BoxSize ) / 2 && |
diff --git a/core/pim/todo/taskeditoralarms.cpp b/core/pim/todo/taskeditoralarms.cpp index 930c94e..a512fb0 100644 --- a/core/pim/todo/taskeditoralarms.cpp +++ b/core/pim/todo/taskeditoralarms.cpp | |||
@@ -1,232 +1,232 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: 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 | 21 | -_. . . )=. = General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 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 "taskeditoralarms.h" | 29 | #include "taskeditoralarms.h" |
30 | 30 | ||
31 | #include <opie2/opimnotifymanager.h> | 31 | #include <opie2/opimnotifymanager.h> |
32 | #include <opie2/otimepicker.h> | 32 | #include <opie2/otimepicker.h> |
33 | 33 | ||
34 | #include <qpe/datebookmonth.h> | 34 | #include <qpe/datebookmonth.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | 36 | ||
37 | #include <qlistview.h> | 37 | #include <qlistview.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | 39 | ||
40 | 40 | ||
41 | class AlarmItem : public QListViewItem { | 41 | class AlarmItem : public QListViewItem { |
42 | public: | 42 | public: |
43 | AlarmItem( QListView*, const OPimAlarm& ); | 43 | AlarmItem( QListView*, const OPimAlarm& ); |
44 | ~AlarmItem(); | 44 | ~AlarmItem(); |
45 | 45 | ||
46 | OPimAlarm alarm()const; | 46 | OPimAlarm alarm()const; |
47 | void setAlarm( const OPimAlarm& ); | 47 | void setAlarm( const OPimAlarm& ); |
48 | private: | 48 | private: |
49 | QDateTime m_dt; | 49 | QDateTime m_dt; |
50 | int m_type; | 50 | int m_type; |
51 | }; | 51 | }; |
52 | AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt) | 52 | AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt) |
53 | : QListViewItem(view) { | 53 | : QListViewItem(view) { |
54 | setAlarm( dt ); | 54 | setAlarm( dt ); |
55 | } | 55 | } |
56 | void AlarmItem::setAlarm( const OPimAlarm& dt ) { | 56 | void AlarmItem::setAlarm( const OPimAlarm& dt ) { |
57 | m_dt = dt.dateTime(); | 57 | m_dt = dt.dateTime(); |
58 | m_type = dt.sound(); | 58 | m_type = dt.sound(); |
59 | setText( 0, TimeString::dateString( m_dt.date() ) ); | 59 | setText( 0, TimeString::dateString( m_dt.date() ) ); |
60 | setText( 1, TimeString::timeString( m_dt.time() ) ); | 60 | setText( 1, TimeString::timeString( m_dt.time() ) ); |
61 | setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") ); | 61 | setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") ); |
62 | } | 62 | } |
63 | AlarmItem::~AlarmItem() { | 63 | AlarmItem::~AlarmItem() { |
64 | } | 64 | } |
65 | OPimAlarm AlarmItem::alarm()const{ | 65 | OPimAlarm AlarmItem::alarm()const{ |
66 | OPimAlarm al( m_type, m_dt ); | 66 | OPimAlarm al( m_type, m_dt ); |
67 | 67 | ||
68 | return al; | 68 | return al; |
69 | } | 69 | } |
70 | 70 | ||
71 | TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl ) | 71 | TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl ) |
72 | : QWidget( parent, name, fl ) | 72 | : QWidget( parent, name, fl ) |
73 | { | 73 | { |
74 | m_date = m_type = m_time = 0; | 74 | m_date = m_type = m_time = 0; |
75 | QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 ); | 75 | QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 ); |
76 | 76 | ||
77 | lstAlarms = new QListView( this ); | 77 | lstAlarms = new QListView( this ); |
78 | lstAlarms->addColumn( tr("Date") ); | 78 | lstAlarms->addColumn( tr("Date") ); |
79 | lstAlarms->addColumn( tr("Time") ); | 79 | lstAlarms->addColumn( tr("Time") ); |
80 | lstAlarms->addColumn( tr("Type") ); | 80 | lstAlarms->addColumn( tr("Type") ); |
81 | 81 | ||
82 | connect( lstAlarms, SIGNAL(clicked ( QListViewItem *, const QPoint &, int ) ), | 82 | connect( lstAlarms, SIGNAL(clicked(QListViewItem*,const QPoint&,int) ), |
83 | this, SLOT(inlineEdit(QListViewItem*, const QPoint&, int ) ) ); | 83 | this, SLOT(inlineEdit(QListViewItem*,const QPoint&,int) ) ); |
84 | 84 | ||
85 | layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 ); | 85 | layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 ); |
86 | 86 | ||
87 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this ); | 87 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this ); |
88 | //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 88 | //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
89 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) ); | 89 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) ); |
90 | layout->addWidget( btn, 1, 0 ); | 90 | layout->addWidget( btn, 1, 0 ); |
91 | /* use when we've reminders too */ | 91 | /* use when we've reminders too */ |
92 | #if 0 | 92 | #if 0 |
93 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this ); | 93 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this ); |
94 | //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 94 | //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
95 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) ); | 95 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) ); |
96 | layout->addWidget( btn, 1, 1 ); | 96 | layout->addWidget( btn, 1, 1 ); |
97 | #endif | 97 | #endif |
98 | 98 | ||
99 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); | 99 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); |
100 | //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 100 | //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
101 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) ); | 101 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) ); |
102 | layout->addWidget( btn, 1, 2 ); | 102 | layout->addWidget( btn, 1, 2 ); |
103 | } | 103 | } |
104 | 104 | ||
105 | TaskEditorAlarms::~TaskEditorAlarms(){ | 105 | TaskEditorAlarms::~TaskEditorAlarms(){ |
106 | } | 106 | } |
107 | 107 | ||
108 | void TaskEditorAlarms::slotNew(){ | 108 | void TaskEditorAlarms::slotNew(){ |
109 | (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) ); | 109 | (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) ); |
110 | } | 110 | } |
111 | 111 | ||
112 | void TaskEditorAlarms::slotEdit(){ | 112 | void TaskEditorAlarms::slotEdit(){ |
113 | } | 113 | } |
114 | 114 | ||
115 | void TaskEditorAlarms::slotDelete(){ | 115 | void TaskEditorAlarms::slotDelete(){ |
116 | QListViewItem* item = lstAlarms->currentItem(); | 116 | QListViewItem* item = lstAlarms->currentItem(); |
117 | if (!item) return; | 117 | if (!item) return; |
118 | 118 | ||
119 | lstAlarms->takeItem( item ); delete item; | 119 | lstAlarms->takeItem( item ); delete item; |
120 | 120 | ||
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | void TaskEditorAlarms::load( const OPimTodo& todo) { | 124 | void TaskEditorAlarms::load( const OPimTodo& todo) { |
125 | lstAlarms->clear(); | 125 | lstAlarms->clear(); |
126 | if (!todo.hasNotifiers() ) return; | 126 | if (!todo.hasNotifiers() ) return; |
127 | 127 | ||
128 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); | 128 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); |
129 | 129 | ||
130 | if (als.isEmpty() ) return; | 130 | if (als.isEmpty() ) return; |
131 | 131 | ||
132 | OPimNotifyManager::Alarms::Iterator it = als.begin(); | 132 | OPimNotifyManager::Alarms::Iterator it = als.begin(); |
133 | for ( ; it != als.end(); ++it ) | 133 | for ( ; it != als.end(); ++it ) |
134 | (void)new AlarmItem( lstAlarms, (*it) ); | 134 | (void)new AlarmItem( lstAlarms, (*it) ); |
135 | 135 | ||
136 | 136 | ||
137 | } | 137 | } |
138 | void TaskEditorAlarms::save( OPimTodo& todo ) { | 138 | void TaskEditorAlarms::save( OPimTodo& todo ) { |
139 | if (lstAlarms->childCount() <= 0 ) return; | 139 | if (lstAlarms->childCount() <= 0 ) return; |
140 | 140 | ||
141 | OPimNotifyManager::Alarms alarms; | 141 | OPimNotifyManager::Alarms alarms; |
142 | 142 | ||
143 | for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) { | 143 | for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) { |
144 | AlarmItem *alItem = static_cast<AlarmItem*>(item); | 144 | AlarmItem *alItem = static_cast<AlarmItem*>(item); |
145 | alarms.append( alItem->alarm() ); | 145 | alarms.append( alItem->alarm() ); |
146 | } | 146 | } |
147 | 147 | ||
148 | OPimNotifyManager& manager = todo.notifiers(); | 148 | OPimNotifyManager& manager = todo.notifiers(); |
149 | manager.setAlarms( alarms ); | 149 | manager.setAlarms( alarms ); |
150 | } | 150 | } |
151 | void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) { | 151 | void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) { |
152 | if (!alarm) return; | 152 | if (!alarm) return; |
153 | 153 | ||
154 | AlarmItem* item = static_cast<AlarmItem*>(alarm); | 154 | AlarmItem* item = static_cast<AlarmItem*>(alarm); |
155 | switch( col ) { | 155 | switch( col ) { |
156 | // date | 156 | // date |
157 | case 0: | 157 | case 0: |
158 | return inlineSetDate( item, p ); | 158 | return inlineSetDate( item, p ); |
159 | // time | 159 | // time |
160 | case 1: | 160 | case 1: |
161 | return inlineSetTime( item ); | 161 | return inlineSetTime( item ); |
162 | // type | 162 | // type |
163 | case 2: | 163 | case 2: |
164 | return inlineSetType( item, p ); | 164 | return inlineSetType( item, p ); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) { | 167 | void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) { |
168 | QPopupMenu* pop = popup( 0 ); | 168 | QPopupMenu* pop = popup( 0 ); |
169 | m_dbMonth->setDate( item->alarm().dateTime().date() ); | 169 | m_dbMonth->setDate( item->alarm().dateTime().date() ); |
170 | pop->exec(p); | 170 | pop->exec(p); |
171 | 171 | ||
172 | OPimAlarm al = item->alarm(); | 172 | OPimAlarm al = item->alarm(); |
173 | QDateTime dt = al.dateTime(); | 173 | QDateTime dt = al.dateTime(); |
174 | dt.setDate( m_dbMonth->selectedDate() ); | 174 | dt.setDate( m_dbMonth->selectedDate() ); |
175 | al.setDateTime( dt ); | 175 | al.setDateTime( dt ); |
176 | item->setAlarm( al ); | 176 | item->setAlarm( al ); |
177 | } | 177 | } |
178 | void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) { | 178 | void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) { |
179 | int type; | 179 | int type; |
180 | QPopupMenu* pop = popup( 2 ); | 180 | QPopupMenu* pop = popup( 2 ); |
181 | switch( pop->exec(p) ) { | 181 | switch( pop->exec(p) ) { |
182 | case 10: | 182 | case 10: |
183 | type = 1; | 183 | type = 1; |
184 | break; | 184 | break; |
185 | case 20: | 185 | case 20: |
186 | default: | 186 | default: |
187 | type = 0; | 187 | type = 0; |
188 | } | 188 | } |
189 | OPimAlarm al = item->alarm(); | 189 | OPimAlarm al = item->alarm(); |
190 | al.setSound( type ); | 190 | al.setSound( type ); |
191 | item->setAlarm( al ); | 191 | item->setAlarm( al ); |
192 | } | 192 | } |
193 | void TaskEditorAlarms::inlineSetTime( AlarmItem* item ) { | 193 | void TaskEditorAlarms::inlineSetTime( AlarmItem* item ) { |
194 | OPimAlarm al = item->alarm(); | 194 | OPimAlarm al = item->alarm(); |
195 | QDateTime dt = al.dateTime(); | 195 | QDateTime dt = al.dateTime(); |
196 | 196 | ||
197 | OTimePickerDialog dialog; | 197 | OTimePickerDialog dialog; |
198 | dialog.setTime( dt.time() ); | 198 | dialog.setTime( dt.time() ); |
199 | if ( dialog.exec() == QDialog::Accepted ) { | 199 | if ( dialog.exec() == QDialog::Accepted ) { |
200 | dt.setTime( dialog.time() ); | 200 | dt.setTime( dialog.time() ); |
201 | al.setDateTime( dt ); | 201 | al.setDateTime( dt ); |
202 | item->setAlarm( al ); | 202 | item->setAlarm( al ); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | QPopupMenu* TaskEditorAlarms::popup( int column ) { | 205 | QPopupMenu* TaskEditorAlarms::popup( int column ) { |
206 | QPopupMenu* pop = 0; | 206 | QPopupMenu* pop = 0; |
207 | switch( column ) { | 207 | switch( column ) { |
208 | case 0:{ | 208 | case 0:{ |
209 | if (!m_date) { | 209 | if (!m_date) { |
210 | m_date = new QPopupMenu(this); | 210 | m_date = new QPopupMenu(this); |
211 | m_dbMonth = new DateBookMonth(m_date, 0, TRUE); | 211 | m_dbMonth = new DateBookMonth(m_date, 0, TRUE); |
212 | m_date->insertItem(m_dbMonth); | 212 | m_date->insertItem(m_dbMonth); |
213 | } | 213 | } |
214 | pop = m_date; | 214 | pop = m_date; |
215 | } | 215 | } |
216 | break; | 216 | break; |
217 | case 1: | 217 | case 1: |
218 | break; | 218 | break; |
219 | case 2:{ | 219 | case 2:{ |
220 | if (!m_type) { | 220 | if (!m_type) { |
221 | m_type = new QPopupMenu(this); | 221 | m_type = new QPopupMenu(this); |
222 | m_type->insertItem( QObject::tr("loud"), 10 ); | 222 | m_type->insertItem( QObject::tr("loud"), 10 ); |
223 | m_type->insertItem( QObject::tr("silent"), 20 ); | 223 | m_type->insertItem( QObject::tr("silent"), 20 ); |
224 | } | 224 | } |
225 | pop = m_type; | 225 | pop = m_type; |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | default: | 228 | default: |
229 | break; | 229 | break; |
230 | } | 230 | } |
231 | return pop; | 231 | return pop; |
232 | } | 232 | } |
diff --git a/core/pim/todo/taskeditorstatus.cpp b/core/pim/todo/taskeditorstatus.cpp index 367dd58..16351e0 100644 --- a/core/pim/todo/taskeditorstatus.cpp +++ b/core/pim/todo/taskeditorstatus.cpp | |||
@@ -1,302 +1,302 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: 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 | 21 | -_. . . )=. = General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 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 "taskeditorstatus.h" | 29 | #include "taskeditorstatus.h" |
30 | 30 | ||
31 | #include <opie2/opimmaintainer.h> | 31 | #include <opie2/opimmaintainer.h> |
32 | #include <opie2/opimstate.h> | 32 | #include <opie2/opimstate.h> |
33 | 33 | ||
34 | #include <qpe/datebookmonth.h> | 34 | #include <qpe/datebookmonth.h> |
35 | 35 | ||
36 | #include <qcheckbox.h> | 36 | #include <qcheckbox.h> |
37 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
41 | 41 | ||
42 | // FIXME add the hack slots instead of setPopup!!!! | 42 | // FIXME add the hack slots instead of setPopup!!!! |
43 | // drw you shouldn't have removed them | 43 | // drw you shouldn't have removed them |
44 | 44 | ||
45 | TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags fl ) | 45 | TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags fl ) |
46 | : QWidget( parent, name, fl ) | 46 | : QWidget( parent, name, fl ) |
47 | { | 47 | { |
48 | QDate curDate = QDate::currentDate(); | 48 | QDate curDate = QDate::currentDate(); |
49 | m_start = m_comp = m_due = curDate; | 49 | m_start = m_comp = m_due = curDate; |
50 | QString curDateStr = TimeString::longDateString( curDate ); | 50 | QString curDateStr = TimeString::longDateString( curDate ); |
51 | 51 | ||
52 | QVBoxLayout *vb = new QVBoxLayout( this ); | 52 | QVBoxLayout *vb = new QVBoxLayout( this ); |
53 | 53 | ||
54 | QScrollView *sv = new QScrollView( this ); | 54 | QScrollView *sv = new QScrollView( this ); |
55 | vb->addWidget( sv ); | 55 | vb->addWidget( sv ); |
56 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 56 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
57 | sv->setFrameStyle( QFrame::NoFrame ); | 57 | sv->setFrameStyle( QFrame::NoFrame ); |
58 | 58 | ||
59 | QWidget *container = new QWidget( sv->viewport() ); | 59 | QWidget *container = new QWidget( sv->viewport() ); |
60 | sv->addChild( container ); | 60 | sv->addChild( container ); |
61 | 61 | ||
62 | QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 ); | 62 | QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 ); |
63 | 63 | ||
64 | // Status | 64 | // Status |
65 | QLabel *label = new QLabel( tr( "Status:" ), container ); | 65 | QLabel *label = new QLabel( tr( "Status:" ), container ); |
66 | layout->addWidget( label, 0, 0 ); | 66 | layout->addWidget( label, 0, 0 ); |
67 | QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) ); | 67 | QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) ); |
68 | cmbStatus = new QComboBox( FALSE, container ); | 68 | cmbStatus = new QComboBox( FALSE, container ); |
69 | cmbStatus->insertItem( tr( "Started" ) ); | 69 | cmbStatus->insertItem( tr( "Started" ) ); |
70 | cmbStatus->insertItem( tr( "Postponed" ) ); | 70 | cmbStatus->insertItem( tr( "Postponed" ) ); |
71 | cmbStatus->insertItem( tr( "Finished" ) ); | 71 | cmbStatus->insertItem( tr( "Finished" ) ); |
72 | cmbStatus->insertItem( tr( "Not started" ) ); | 72 | cmbStatus->insertItem( tr( "Not started" ) ); |
73 | layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 ); | 73 | layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 ); |
74 | QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) ); | 74 | QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) ); |
75 | 75 | ||
76 | // Progress | 76 | // Progress |
77 | label = new QLabel( tr( "Progress:" ), container ); | 77 | label = new QLabel( tr( "Progress:" ), container ); |
78 | layout->addWidget( label, 1, 0 ); | 78 | layout->addWidget( label, 1, 0 ); |
79 | QWhatsThis::add( label, tr( "Select progress made on this task here." ) ); | 79 | QWhatsThis::add( label, tr( "Select progress made on this task here." ) ); |
80 | cmbProgress = new QComboBox( FALSE, container ); | 80 | cmbProgress = new QComboBox( FALSE, container ); |
81 | cmbProgress->insertItem( tr( "0 %" ) ); | 81 | cmbProgress->insertItem( tr( "0 %" ) ); |
82 | cmbProgress->insertItem( tr( "20 %" ) ); | 82 | cmbProgress->insertItem( tr( "20 %" ) ); |
83 | cmbProgress->insertItem( tr( "40 %" ) ); | 83 | cmbProgress->insertItem( tr( "40 %" ) ); |
84 | cmbProgress->insertItem( tr( "60 %" ) ); | 84 | cmbProgress->insertItem( tr( "60 %" ) ); |
85 | cmbProgress->insertItem( tr( "80 %" ) ); | 85 | cmbProgress->insertItem( tr( "80 %" ) ); |
86 | cmbProgress->insertItem( tr( "100 %" ) ); | 86 | cmbProgress->insertItem( tr( "100 %" ) ); |
87 | layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 ); | 87 | layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 ); |
88 | QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) ); | 88 | QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) ); |
89 | 89 | ||
90 | // Start date | 90 | // Start date |
91 | ckbStart = new QCheckBox( tr( "Start Date:" ), container ); | 91 | ckbStart = new QCheckBox( tr( "Start Date:" ), container ); |
92 | layout->addWidget( ckbStart, 2, 0 ); | 92 | layout->addWidget( ckbStart, 2, 0 ); |
93 | QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) ); | 93 | QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) ); |
94 | connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) ); | 94 | connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) ); |
95 | btnStart = new QPushButton( curDateStr, container ); | 95 | btnStart = new QPushButton( curDateStr, container ); |
96 | btnStart->setEnabled( FALSE ); | 96 | btnStart->setEnabled( FALSE ); |
97 | layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 ); | 97 | layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 ); |
98 | QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) ); | 98 | QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) ); |
99 | QPopupMenu *popup = new QPopupMenu( this ); | 99 | QPopupMenu *popup = new QPopupMenu( this ); |
100 | m_startBook = new DateBookMonth( popup, 0, TRUE ); | 100 | m_startBook = new DateBookMonth( popup, 0, TRUE ); |
101 | popup->insertItem( m_startBook ); | 101 | popup->insertItem( m_startBook ); |
102 | btnStart->setPopup( popup ); | 102 | btnStart->setPopup( popup ); |
103 | connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ), | 103 | connect( m_startBook, SIGNAL( dateClicked(int,int,int) ), |
104 | this, SLOT( slotStartChanged( int, int, int ) ) ); | 104 | this, SLOT( slotStartChanged(int,int,int) ) ); |
105 | 105 | ||
106 | // Due date | 106 | // Due date |
107 | ckbDue = new QCheckBox( tr( "Due Date:" ), container ); | 107 | ckbDue = new QCheckBox( tr( "Due Date:" ), container ); |
108 | layout->addWidget( ckbDue, 3, 0 ); | 108 | layout->addWidget( ckbDue, 3, 0 ); |
109 | QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) ); | 109 | QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) ); |
110 | connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) ); | 110 | connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) ); |
111 | btnDue = new QPushButton( curDateStr, container ); | 111 | btnDue = new QPushButton( curDateStr, container ); |
112 | btnDue->setEnabled( FALSE ); | 112 | btnDue->setEnabled( FALSE ); |
113 | layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 ); | 113 | layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 ); |
114 | QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) ); | 114 | QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) ); |
115 | popup = new QPopupMenu( this ); | 115 | popup = new QPopupMenu( this ); |
116 | m_dueBook = new DateBookMonth( popup, 0, TRUE ); | 116 | m_dueBook = new DateBookMonth( popup, 0, TRUE ); |
117 | popup->insertItem( m_dueBook ); | 117 | popup->insertItem( m_dueBook ); |
118 | btnDue->setPopup( popup ); | 118 | btnDue->setPopup( popup ); |
119 | connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ), | 119 | connect( m_dueBook, SIGNAL( dateClicked(int,int,int) ), |
120 | this, SLOT( slotDueChanged( int, int, int ) ) ); | 120 | this, SLOT( slotDueChanged(int,int,int) ) ); |
121 | 121 | ||
122 | // Completed | 122 | // Completed |
123 | ckbComp = new QCheckBox( tr( "Completed:" ), container ); | 123 | ckbComp = new QCheckBox( tr( "Completed:" ), container ); |
124 | layout->addWidget( ckbComp, 4, 0 ); | 124 | layout->addWidget( ckbComp, 4, 0 ); |
125 | QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) ); | 125 | QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) ); |
126 | connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) ); | 126 | connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) ); |
127 | btnComp = new QPushButton( curDateStr, container ); | 127 | btnComp = new QPushButton( curDateStr, container ); |
128 | btnComp->setEnabled( FALSE ); | 128 | btnComp->setEnabled( FALSE ); |
129 | layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 ); | 129 | layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 ); |
130 | QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) ); | 130 | QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) ); |
131 | popup = new QPopupMenu( this ); | 131 | popup = new QPopupMenu( this ); |
132 | m_compBook = new DateBookMonth( popup, 0, TRUE ); | 132 | m_compBook = new DateBookMonth( popup, 0, TRUE ); |
133 | popup->insertItem( m_compBook ); | 133 | popup->insertItem( m_compBook ); |
134 | btnComp->setPopup( popup ); | 134 | btnComp->setPopup( popup ); |
135 | connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ), | 135 | connect( m_compBook, SIGNAL( dateClicked(int,int,int) ), |
136 | this, SLOT( slotCompChanged( int, int, int ) ) ); | 136 | this, SLOT( slotCompChanged(int,int,int) ) ); |
137 | 137 | ||
138 | QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); | 138 | QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); |
139 | layout->addItem( spacer, 5, 0 ); | 139 | layout->addItem( spacer, 5, 0 ); |
140 | 140 | ||
141 | // Maintainer mode | 141 | // Maintainer mode |
142 | #if 0 | 142 | #if 0 |
143 | label = new QLabel( tr( "Maintainer Mode:" ), container ); | 143 | label = new QLabel( tr( "Maintainer Mode:" ), container ); |
144 | layout->addWidget( label, 6, 0 ); | 144 | layout->addWidget( label, 6, 0 ); |
145 | QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) ); | 145 | QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) ); |
146 | cmbMaintMode = new QComboBox( FALSE, container ); | 146 | cmbMaintMode = new QComboBox( FALSE, container ); |
147 | cmbMaintMode->insertItem( tr( "Nothing" ) ); | 147 | cmbMaintMode->insertItem( tr( "Nothing" ) ); |
148 | cmbMaintMode->insertItem( tr( "Responsible" ) ); | 148 | cmbMaintMode->insertItem( tr( "Responsible" ) ); |
149 | cmbMaintMode->insertItem( tr( "Done By" ) ); | 149 | cmbMaintMode->insertItem( tr( "Done By" ) ); |
150 | cmbMaintMode->insertItem( tr( "Coordinating" ) ); | 150 | cmbMaintMode->insertItem( tr( "Coordinating" ) ); |
151 | // layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 ); | 151 | // layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 ); |
152 | QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) ); | 152 | QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) ); |
153 | 153 | ||
154 | // Maintainer | 154 | // Maintainer |
155 | label = new QLabel( tr( "Maintainer:" ), container ); | 155 | label = new QLabel( tr( "Maintainer:" ), container ); |
156 | layout->addWidget( label, 7, 0 ); | 156 | layout->addWidget( label, 7, 0 ); |
157 | QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) ); | 157 | QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) ); |
158 | txtMaintainer = new QLabel( tr( "test" ), container ); | 158 | txtMaintainer = new QLabel( tr( "test" ), container ); |
159 | txtMaintainer->setTextFormat( QLabel::RichText ); | 159 | txtMaintainer->setTextFormat( QLabel::RichText ); |
160 | layout->addWidget( txtMaintainer, 7, 1 ); | 160 | layout->addWidget( txtMaintainer, 7, 1 ); |
161 | QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) ); | 161 | QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) ); |
162 | tbtMaintainer = new QToolButton( container ); | 162 | tbtMaintainer = new QToolButton( container ); |
163 | tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) ); | 163 | tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) ); |
164 | // layout->addWidget( tbtMaintainer, 7, 2 ); | 164 | // layout->addWidget( tbtMaintainer, 7, 2 ); |
165 | QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) ); | 165 | QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) ); |
166 | #endif | 166 | #endif |
167 | } | 167 | } |
168 | 168 | ||
169 | TaskEditorStatus::~TaskEditorStatus() | 169 | TaskEditorStatus::~TaskEditorStatus() |
170 | { | 170 | { |
171 | } | 171 | } |
172 | 172 | ||
173 | void TaskEditorStatus::load( const OPimTodo &todo ) | 173 | void TaskEditorStatus::load( const OPimTodo &todo ) |
174 | { | 174 | { |
175 | QDate date = QDate::currentDate(); | 175 | QDate date = QDate::currentDate(); |
176 | QString str = TimeString::longDateString( date ); | 176 | QString str = TimeString::longDateString( date ); |
177 | 177 | ||
178 | // Status | 178 | // Status |
179 | int state = todo.hasState()? todo.state().state() : OPimState::NotStarted; | 179 | int state = todo.hasState()? todo.state().state() : OPimState::NotStarted; |
180 | if ( state == OPimState::Undefined ) | 180 | if ( state == OPimState::Undefined ) |
181 | state = OPimState::NotStarted; | 181 | state = OPimState::NotStarted; |
182 | cmbStatus->setCurrentItem( state ); | 182 | cmbStatus->setCurrentItem( state ); |
183 | 183 | ||
184 | // Progress | 184 | // Progress |
185 | cmbProgress->setCurrentItem( todo.progress() / 20 ); | 185 | cmbProgress->setCurrentItem( todo.progress() / 20 ); |
186 | 186 | ||
187 | // Start date | 187 | // Start date |
188 | ckbStart->setChecked( todo.hasStartDate() ); | 188 | ckbStart->setChecked( todo.hasStartDate() ); |
189 | btnStart->setEnabled( todo.hasStartDate() ); | 189 | btnStart->setEnabled( todo.hasStartDate() ); |
190 | if ( todo.hasStartDate() ) | 190 | if ( todo.hasStartDate() ) |
191 | { | 191 | { |
192 | m_start = todo.startDate(); | 192 | m_start = todo.startDate(); |
193 | btnStart->setText( TimeString::longDateString( m_start ) ); | 193 | btnStart->setText( TimeString::longDateString( m_start ) ); |
194 | } | 194 | } |
195 | else | 195 | else |
196 | btnStart->setText( str ); | 196 | btnStart->setText( str ); |
197 | 197 | ||
198 | // Due date | 198 | // Due date |
199 | ckbDue->setChecked( todo.hasDueDate() ); | 199 | ckbDue->setChecked( todo.hasDueDate() ); |
200 | btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); | 200 | btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); |
201 | btnDue->setEnabled( todo.hasDueDate() ); | 201 | btnDue->setEnabled( todo.hasDueDate() ); |
202 | m_due = todo.dueDate(); | 202 | m_due = todo.dueDate(); |
203 | 203 | ||
204 | // Completed | 204 | // Completed |
205 | ckbComp->setChecked( todo.isCompleted() ); | 205 | ckbComp->setChecked( todo.isCompleted() ); |
206 | btnComp->setEnabled( todo.hasCompletedDate() ); | 206 | btnComp->setEnabled( todo.hasCompletedDate() ); |
207 | if ( todo.hasCompletedDate() ) | 207 | if ( todo.hasCompletedDate() ) |
208 | { | 208 | { |
209 | m_comp = todo.completedDate(); | 209 | m_comp = todo.completedDate(); |
210 | btnComp->setText( TimeString::longDateString( m_comp ) ); | 210 | btnComp->setText( TimeString::longDateString( m_comp ) ); |
211 | } | 211 | } |
212 | else | 212 | else |
213 | btnComp->setText( str ); | 213 | btnComp->setText( str ); |
214 | 214 | ||
215 | // Maintainer Mode | 215 | // Maintainer Mode |
216 | #if 0 | 216 | #if 0 |
217 | state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing; | 217 | state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing; |
218 | if ( state == OPimMaintainer::Undefined ) | 218 | if ( state == OPimMaintainer::Undefined ) |
219 | state = OPimMaintainer::Nothing; | 219 | state = OPimMaintainer::Nothing; |
220 | cmbMaintMode->setCurrentItem( state ); | 220 | cmbMaintMode->setCurrentItem( state ); |
221 | #endif | 221 | #endif |
222 | // Maintainer - not implemented yet | 222 | // Maintainer - not implemented yet |
223 | } | 223 | } |
224 | 224 | ||
225 | void TaskEditorStatus::save( OPimTodo &todo ) | 225 | void TaskEditorStatus::save( OPimTodo &todo ) |
226 | { | 226 | { |
227 | QDate inval; | 227 | QDate inval; |
228 | 228 | ||
229 | // Status | 229 | // Status |
230 | todo.setState( OPimState( cmbStatus->currentItem() ) ); | 230 | todo.setState( OPimState( cmbStatus->currentItem() ) ); |
231 | 231 | ||
232 | // Progress | 232 | // Progress |
233 | todo.setProgress( cmbProgress->currentItem() * 20 ); | 233 | todo.setProgress( cmbProgress->currentItem() * 20 ); |
234 | 234 | ||
235 | // Start date | 235 | // Start date |
236 | if ( ckbStart->isChecked() ) | 236 | if ( ckbStart->isChecked() ) |
237 | { | 237 | { |
238 | todo.setStartDate( m_start ); | 238 | todo.setStartDate( m_start ); |
239 | } | 239 | } |
240 | else | 240 | else |
241 | todo.setStartDate( inval ); | 241 | todo.setStartDate( inval ); |
242 | 242 | ||
243 | // Due date | 243 | // Due date |
244 | if ( ckbDue->isChecked() ) | 244 | if ( ckbDue->isChecked() ) |
245 | { | 245 | { |
246 | todo.setDueDate( m_due ); | 246 | todo.setDueDate( m_due ); |
247 | todo.setHasDueDate( true ); | 247 | todo.setHasDueDate( true ); |
248 | } | 248 | } |
249 | else | 249 | else |
250 | todo.setHasDueDate( false ); | 250 | todo.setHasDueDate( false ); |
251 | 251 | ||
252 | // Completed | 252 | // Completed |
253 | todo.setCompleted( ckbComp->isChecked() ); | 253 | todo.setCompleted( ckbComp->isChecked() ); |
254 | if ( ckbComp->isChecked() ) | 254 | if ( ckbComp->isChecked() ) |
255 | { | 255 | { |
256 | todo.setCompletedDate( m_comp ); | 256 | todo.setCompletedDate( m_comp ); |
257 | } | 257 | } |
258 | else | 258 | else |
259 | todo.setCompletedDate( inval ); | 259 | todo.setCompletedDate( inval ); |
260 | 260 | ||
261 | #if 0 | 261 | #if 0 |
262 | // Maintainer mode - not implemented yet | 262 | // Maintainer mode - not implemented yet |
263 | 263 | ||
264 | // Maintainer | 264 | // Maintainer |
265 | /* TODO - resolve name to uid.....*/ | 265 | /* TODO - resolve name to uid.....*/ |
266 | todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) ); | 266 | todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) ); |
267 | #endif | 267 | #endif |
268 | } | 268 | } |
269 | 269 | ||
270 | void TaskEditorStatus::slotStartChecked() | 270 | void TaskEditorStatus::slotStartChecked() |
271 | { | 271 | { |
272 | btnStart->setEnabled( ckbStart->isChecked() ); | 272 | btnStart->setEnabled( ckbStart->isChecked() ); |
273 | } | 273 | } |
274 | 274 | ||
275 | void TaskEditorStatus::slotCompChecked() | 275 | void TaskEditorStatus::slotCompChecked() |
276 | { | 276 | { |
277 | btnComp->setEnabled( ckbComp->isChecked() ); | 277 | btnComp->setEnabled( ckbComp->isChecked() ); |
278 | } | 278 | } |
279 | 279 | ||
280 | void TaskEditorStatus::slotDueChecked() | 280 | void TaskEditorStatus::slotDueChecked() |
281 | { | 281 | { |
282 | btnDue->setEnabled( ckbDue->isChecked() ); | 282 | btnDue->setEnabled( ckbDue->isChecked() ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void TaskEditorStatus::slotStartChanged(int y, int m, int d) | 285 | void TaskEditorStatus::slotStartChanged(int y, int m, int d) |
286 | { | 286 | { |
287 | m_start.setYMD( y, m, d ); | 287 | m_start.setYMD( y, m, d ); |
288 | btnStart->setText( TimeString::longDateString( m_start ) ); | 288 | btnStart->setText( TimeString::longDateString( m_start ) ); |
289 | } | 289 | } |
290 | 290 | ||
291 | void TaskEditorStatus::slotCompChanged(int y, int m, int d) | 291 | void TaskEditorStatus::slotCompChanged(int y, int m, int d) |
292 | { | 292 | { |
293 | m_comp.setYMD( y, m, d ); | 293 | m_comp.setYMD( y, m, d ); |
294 | btnComp->setText( TimeString::longDateString( m_comp ) ); | 294 | btnComp->setText( TimeString::longDateString( m_comp ) ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void TaskEditorStatus::slotDueChanged(int y, int m, int d) | 297 | void TaskEditorStatus::slotDueChanged(int y, int m, int d) |
298 | { | 298 | { |
299 | m_due.setYMD( y, m, d ); | 299 | m_due.setYMD( y, m, d ); |
300 | btnDue->setText( TimeString::longDateString( m_due ) ); | 300 | btnDue->setText( TimeString::longDateString( m_due ) ); |
301 | emit dueDateChanged( m_due ); | 301 | emit dueDateChanged( m_due ); |
302 | } | 302 | } |
diff --git a/core/qws/qcopbridge.cpp b/core/qws/qcopbridge.cpp index c0c52e8..4fd0807 100644 --- a/core/qws/qcopbridge.cpp +++ b/core/qws/qcopbridge.cpp | |||
@@ -1,270 +1,270 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qcopbridge.h" | 21 | #include "qcopbridge.h" |
22 | #include "transferserver.h" | 22 | #include "transferserver.h" |
23 | 23 | ||
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/version.h> | 26 | #include <qpe/version.h> |
27 | 27 | ||
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #ifdef QWS | 29 | #ifdef QWS |
30 | #include <qcopchannel_qws.h> | 30 | #include <qcopchannel_qws.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #define _XOPEN_SOURCE | 33 | #define _XOPEN_SOURCE |
34 | #include <pwd.h> | 34 | #include <pwd.h> |
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | #if defined(_OS_LINUX_) | 38 | #if defined(_OS_LINUX_) |
39 | #include <shadow.h> | 39 | #include <shadow.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | //#define INSECURE | 42 | //#define INSECURE |
43 | 43 | ||
44 | const int block_size = 51200; | 44 | const int block_size = 51200; |
45 | 45 | ||
46 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent , | 46 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent , |
47 | const char* name ) | 47 | const char* name ) |
48 | : QServerSocket( port, 1, parent, name ), | 48 | : QServerSocket( port, 1, parent, name ), |
49 | desktopChannel( 0 ), | 49 | desktopChannel( 0 ), |
50 | cardChannel( 0 ) | 50 | cardChannel( 0 ) |
51 | { | 51 | { |
52 | if ( !ok() ) | 52 | if ( !ok() ) |
53 | qWarning( "Failed to bind to port %d", port ); | 53 | qWarning( "Failed to bind to port %d", port ); |
54 | else { | 54 | else { |
55 | #ifndef QT_NO_COP | 55 | #ifndef QT_NO_COP |
56 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 56 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
57 | connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 57 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
58 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 58 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
59 | cardChannel = new QCopChannel( "QPE/Card", this ); | 59 | cardChannel = new QCopChannel( "QPE/Card", this ); |
60 | connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 60 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
61 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 61 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
62 | #endif | 62 | #endif |
63 | } | 63 | } |
64 | sendSync = FALSE; | 64 | sendSync = FALSE; |
65 | } | 65 | } |
66 | 66 | ||
67 | QCopBridge::~QCopBridge() | 67 | QCopBridge::~QCopBridge() |
68 | { | 68 | { |
69 | #ifndef QT_NO_COP | 69 | #ifndef QT_NO_COP |
70 | delete desktopChannel; | 70 | delete desktopChannel; |
71 | #endif | 71 | #endif |
72 | } | 72 | } |
73 | 73 | ||
74 | void QCopBridge::newConnection( int socket ) | 74 | void QCopBridge::newConnection( int socket ) |
75 | { | 75 | { |
76 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); | 76 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); |
77 | openConnections.append( pi ); | 77 | openConnections.append( pi ); |
78 | connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( connectionClosed( QCopBridgePI *) ) ); | 78 | connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( connectionClosed(QCopBridgePI*) ) ); |
79 | #ifndef QT_NO_COP | 79 | #ifndef QT_NO_COP |
80 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 80 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | if ( sendSync ) { | 83 | if ( sendSync ) { |
84 | pi ->startSync(); | 84 | pi ->startSync(); |
85 | sendSync = FALSE; | 85 | sendSync = FALSE; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) | 89 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) |
90 | { | 90 | { |
91 | openConnections.remove( pi ); | 91 | openConnections.remove( pi ); |
92 | if ( openConnections.count() == 0 ) { | 92 | if ( openConnections.count() == 0 ) { |
93 | #ifndef QT_NO_COP | 93 | #ifndef QT_NO_COP |
94 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 94 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
95 | #endif | 95 | #endif |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void QCopBridge::closeOpenConnections() | 99 | void QCopBridge::closeOpenConnections() |
100 | { | 100 | { |
101 | QCopBridgePI *pi; | 101 | QCopBridgePI *pi; |
102 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 102 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
103 | pi->close(); | 103 | pi->close(); |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) | 107 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) |
108 | { | 108 | { |
109 | command.stripWhiteSpace(); | 109 | command.stripWhiteSpace(); |
110 | 110 | ||
111 | int paren = command.find( "(" ); | 111 | int paren = command.find( "(" ); |
112 | if ( paren <= 0 ) { | 112 | if ( paren <= 0 ) { |
113 | qDebug("DesktopMessage: bad qcop syntax"); | 113 | qDebug("DesktopMessage: bad qcop syntax"); |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | 116 | ||
117 | QString params = command.mid( paren + 1 ); | 117 | QString params = command.mid( paren + 1 ); |
118 | if ( params[params.length()-1] != ')' ) { | 118 | if ( params[params.length()-1] != ')' ) { |
119 | qDebug("DesktopMessage: bad qcop syntax"); | 119 | qDebug("DesktopMessage: bad qcop syntax"); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | 122 | ||
123 | params.truncate( params.length()-1 ); | 123 | params.truncate( params.length()-1 ); |
124 | 124 | ||
125 | QStringList paramList = QStringList::split( ",", params ); | 125 | QStringList paramList = QStringList::split( ",", params ); |
126 | QString data; | 126 | QString data; |
127 | if ( paramList.count() ) { | 127 | if ( paramList.count() ) { |
128 | QDataStream stream( args, IO_ReadOnly ); | 128 | QDataStream stream( args, IO_ReadOnly ); |
129 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | 129 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { |
130 | QString str; | 130 | QString str; |
131 | if ( *it == "QString" ) { | 131 | if ( *it == "QString" ) { |
132 | stream >> str; | 132 | stream >> str; |
133 | } else if ( *it == "QCString" ) { | 133 | } else if ( *it == "QCString" ) { |
134 | QCString cstr; | 134 | QCString cstr; |
135 | stream >> cstr; | 135 | stream >> cstr; |
136 | str = QString::fromLocal8Bit( cstr ); | 136 | str = QString::fromLocal8Bit( cstr ); |
137 | } else if ( *it == "int" ) { | 137 | } else if ( *it == "int" ) { |
138 | int i; | 138 | int i; |
139 | stream >> i; | 139 | stream >> i; |
140 | str = QString::number( i ); | 140 | str = QString::number( i ); |
141 | } else if ( *it == "bool" ) { | 141 | } else if ( *it == "bool" ) { |
142 | int i; | 142 | int i; |
143 | stream >> i; | 143 | stream >> i; |
144 | str = QString::number( i ); | 144 | str = QString::number( i ); |
145 | } else { | 145 | } else { |
146 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); | 146 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); |
147 | return; | 147 | return; |
148 | } | 148 | } |
149 | QString estr; | 149 | QString estr; |
150 | for (int i=0; i<(int)str.length(); i++) { | 150 | for (int i=0; i<(int)str.length(); i++) { |
151 | QChar ch = str[i]; | 151 | QChar ch = str[i]; |
152 | if ( ch.row() ) | 152 | if ( ch.row() ) |
153 | goto quick; | 153 | goto quick; |
154 | switch (ch.cell()) { | 154 | switch (ch.cell()) { |
155 | case '&': | 155 | case '&': |
156 | estr.append( "&" ); | 156 | estr.append( "&" ); |
157 | break; | 157 | break; |
158 | case ' ': | 158 | case ' ': |
159 | estr.append( "&0x20;" ); | 159 | estr.append( "&0x20;" ); |
160 | break; | 160 | break; |
161 | case '\n': | 161 | case '\n': |
162 | estr.append( "&0x0d;" ); | 162 | estr.append( "&0x0d;" ); |
163 | break; | 163 | break; |
164 | case '\r': | 164 | case '\r': |
165 | estr.append( "&0x0a;" ); | 165 | estr.append( "&0x0a;" ); |
166 | break; | 166 | break; |
167 | default: quick: | 167 | default: quick: |
168 | estr.append(ch); | 168 | estr.append(ch); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | data += " " + estr; | 171 | data += " " + estr; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | QString sendCommand = QString(command.data()) + data; | 174 | QString sendCommand = QString(command.data()) + data; |
175 | // send the command to all open connections | 175 | // send the command to all open connections |
176 | if ( command == "startSync()" ) { | 176 | if ( command == "startSync()" ) { |
177 | // we need to buffer it a bit | 177 | // we need to buffer it a bit |
178 | sendSync = TRUE; | 178 | sendSync = TRUE; |
179 | startTimer( 20000 ); | 179 | startTimer( 20000 ); |
180 | } | 180 | } |
181 | 181 | ||
182 | QCopBridgePI *pi; | 182 | QCopBridgePI *pi; |
183 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | 183 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { |
184 | pi->sendDesktopMessage( sendCommand ); | 184 | pi->sendDesktopMessage( sendCommand ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void QCopBridge::timerEvent( QTimerEvent * ) | 188 | void QCopBridge::timerEvent( QTimerEvent * ) |
189 | { | 189 | { |
190 | sendSync = FALSE; | 190 | sendSync = FALSE; |
191 | killTimers(); | 191 | killTimers(); |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
195 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent , const char* name ) | 195 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent , const char* name ) |
196 | : QSocket( parent, name ) | 196 | : QSocket( parent, name ) |
197 | { | 197 | { |
198 | setSocket( socket ); | 198 | setSocket( socket ); |
199 | 199 | ||
200 | peerport = peerPort(); | 200 | peerport = peerPort(); |
201 | peeraddress = peerAddress(); | 201 | peeraddress = peerAddress(); |
202 | 202 | ||
203 | #ifndef INSECURE | 203 | #ifndef INSECURE |
204 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { | 204 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { |
205 | state = Forbidden; | 205 | state = Forbidden; |
206 | startTimer( 0 ); | 206 | startTimer( 0 ); |
207 | } else | 207 | } else |
208 | #endif | 208 | #endif |
209 | { | 209 | { |
210 | state = Connected; | 210 | state = Connected; |
211 | sendSync = FALSE; | 211 | sendSync = FALSE; |
212 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 212 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
213 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 213 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
214 | 214 | ||
215 | QString intro="220 Qtopia "; | 215 | QString intro="220 Qtopia "; |
216 | intro += QPE_VERSION; intro += ";"; | 216 | intro += QPE_VERSION; intro += ";"; |
217 | intro += "challenge="; intro += SyncAuthentication::serverId(); intro += ";"; | 217 | intro += "challenge="; intro += SyncAuthentication::serverId(); intro += ";"; |
218 | intro += "loginname="; intro += SyncAuthentication::loginName(); intro += ";"; | 218 | intro += "loginname="; intro += SyncAuthentication::loginName(); intro += ";"; |
219 | intro += "displayname="; intro += SyncAuthentication::ownerName(); intro += ";"; | 219 | intro += "displayname="; intro += SyncAuthentication::ownerName(); intro += ";"; |
220 | send( intro ); | 220 | send( intro ); |
221 | state = Wait_USER; | 221 | state = Wait_USER; |
222 | 222 | ||
223 | // idle timer to close connections when not used anymore | 223 | // idle timer to close connections when not used anymore |
224 | startTimer( 60000 ); | 224 | startTimer( 60000 ); |
225 | connected = TRUE; | 225 | connected = TRUE; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | QCopBridgePI::~QCopBridgePI() | 230 | QCopBridgePI::~QCopBridgePI() |
231 | { | 231 | { |
232 | 232 | ||
233 | } | 233 | } |
234 | 234 | ||
235 | void QCopBridgePI::connectionClosed() | 235 | void QCopBridgePI::connectionClosed() |
236 | { | 236 | { |
237 | emit connectionClosed( this ); | 237 | emit connectionClosed( this ); |
238 | // qDebug( "Debug: Connection closed" ); | 238 | // qDebug( "Debug: Connection closed" ); |
239 | delete this; | 239 | delete this; |
240 | } | 240 | } |
241 | 241 | ||
242 | void QCopBridgePI::sendDesktopMessage( const QString &msg ) | 242 | void QCopBridgePI::sendDesktopMessage( const QString &msg ) |
243 | { | 243 | { |
244 | QString str = "CALL QPE/Desktop " + msg; | 244 | QString str = "CALL QPE/Desktop " + msg; |
245 | send ( str ); | 245 | send ( str ); |
246 | } | 246 | } |
247 | 247 | ||
248 | 248 | ||
249 | void QCopBridgePI::send( const QString& msg ) | 249 | void QCopBridgePI::send( const QString& msg ) |
250 | { | 250 | { |
251 | QTextStream os( this ); | 251 | QTextStream os( this ); |
252 | os << msg << endl; | 252 | os << msg << endl; |
253 | //qDebug( "sending qcop message: %s", msg.latin1() ); | 253 | //qDebug( "sending qcop message: %s", msg.latin1() ); |
254 | } | 254 | } |
255 | 255 | ||
256 | void QCopBridgePI::read() | 256 | void QCopBridgePI::read() |
257 | { | 257 | { |
258 | while ( canReadLine() ) | 258 | while ( canReadLine() ) |
259 | process( readLine().stripWhiteSpace() ); | 259 | process( readLine().stripWhiteSpace() ); |
260 | } | 260 | } |
261 | 261 | ||
262 | void QCopBridgePI::process( const QString& message ) | 262 | void QCopBridgePI::process( const QString& message ) |
263 | { | 263 | { |
264 | //qDebug( "Command: %s", message.latin1() ); | 264 | //qDebug( "Command: %s", message.latin1() ); |
265 | 265 | ||
266 | // split message using "," as separator | 266 | // split message using "," as separator |
267 | QStringList msg = QStringList::split( " ", message ); | 267 | QStringList msg = QStringList::split( " ", message ); |
268 | if ( msg.isEmpty() ) return; | 268 | if ( msg.isEmpty() ) return; |
269 | 269 | ||
270 | // command token | 270 | // command token |
diff --git a/core/qws/transferserver.cpp b/core/qws/transferserver.cpp index 30bf438..daf63ec 100644 --- a/core/qws/transferserver.cpp +++ b/core/qws/transferserver.cpp | |||
@@ -105,397 +105,397 @@ QString UidGen::uuid() | |||
105 | } | 105 | } |
106 | #elif defined(_OS_LINUX_) | 106 | #elif defined(_OS_LINUX_) |
107 | /* | 107 | /* |
108 | * linux got a /proc/sys/kernel/random/uuid file | 108 | * linux got a /proc/sys/kernel/random/uuid file |
109 | * it'll generate the uuids for us | 109 | * it'll generate the uuids for us |
110 | */ | 110 | */ |
111 | QString UidGen::uuid() | 111 | QString UidGen::uuid() |
112 | { | 112 | { |
113 | QFile file( "/proc/sys/kernel/random/uuid" ); | 113 | QFile file( "/proc/sys/kernel/random/uuid" ); |
114 | if (!file.open(IO_ReadOnly ) ) | 114 | if (!file.open(IO_ReadOnly ) ) |
115 | return QString::null; | 115 | return QString::null; |
116 | 116 | ||
117 | QTextStream stream(&file); | 117 | QTextStream stream(&file); |
118 | 118 | ||
119 | return "{" + stream.read().stripWhiteSpace() + "}"; | 119 | return "{" + stream.read().stripWhiteSpace() + "}"; |
120 | } | 120 | } |
121 | #else | 121 | #else |
122 | QString UidGen::uuid() | 122 | QString UidGen::uuid() |
123 | { | 123 | { |
124 | uuid_t uuid; | 124 | uuid_t uuid; |
125 | ::uuid_generate( uuid ); | 125 | ::uuid_generate( uuid ); |
126 | return QUUid( uuid ).toString(); | 126 | return QUUid( uuid ).toString(); |
127 | } | 127 | } |
128 | #endif | 128 | #endif |
129 | } | 129 | } |
130 | 130 | ||
131 | QString SyncAuthentication::serverId() | 131 | QString SyncAuthentication::serverId() |
132 | { | 132 | { |
133 | Config cfg("Security"); | 133 | Config cfg("Security"); |
134 | cfg.setGroup("Sync"); | 134 | cfg.setGroup("Sync"); |
135 | QString r = cfg.readEntry("serverid"); | 135 | QString r = cfg.readEntry("serverid"); |
136 | if ( r.isEmpty() ) { | 136 | if ( r.isEmpty() ) { |
137 | UidGen gen; | 137 | UidGen gen; |
138 | r = gen.uuid(); | 138 | r = gen.uuid(); |
139 | cfg.writeEntry("serverid", r ); | 139 | cfg.writeEntry("serverid", r ); |
140 | } | 140 | } |
141 | return r; | 141 | return r; |
142 | } | 142 | } |
143 | 143 | ||
144 | QString SyncAuthentication::ownerName() | 144 | QString SyncAuthentication::ownerName() |
145 | { | 145 | { |
146 | QString vfilename = Global::applicationFileName("addressbook", | 146 | QString vfilename = Global::applicationFileName("addressbook", |
147 | "businesscard.vcf"); | 147 | "businesscard.vcf"); |
148 | if (QFile::exists(vfilename)) { | 148 | if (QFile::exists(vfilename)) { |
149 | Contact c; | 149 | Contact c; |
150 | c = Contact::readVCard( vfilename )[0]; | 150 | c = Contact::readVCard( vfilename )[0]; |
151 | return c.fullName(); | 151 | return c.fullName(); |
152 | } | 152 | } |
153 | 153 | ||
154 | return ""; | 154 | return ""; |
155 | } | 155 | } |
156 | 156 | ||
157 | QString SyncAuthentication::loginName() | 157 | QString SyncAuthentication::loginName() |
158 | { | 158 | { |
159 | struct passwd *pw; | 159 | struct passwd *pw; |
160 | pw = getpwuid( geteuid() ); | 160 | pw = getpwuid( geteuid() ); |
161 | return QString::fromLocal8Bit( pw->pw_name ); | 161 | return QString::fromLocal8Bit( pw->pw_name ); |
162 | } | 162 | } |
163 | 163 | ||
164 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) | 164 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) |
165 | { | 165 | { |
166 | Config cfg("Security"); | 166 | Config cfg("Security"); |
167 | cfg.setGroup("Sync"); | 167 | cfg.setGroup("Sync"); |
168 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); | 168 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); |
169 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); | 169 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); |
170 | 170 | ||
171 | // QHostAddress allowed; | 171 | // QHostAddress allowed; |
172 | // allowed.setAddress(allowedstr); | 172 | // allowed.setAddress(allowedstr); |
173 | // uint auth_peer = allowed.ip4Addr(); | 173 | // uint auth_peer = allowed.ip4Addr(); |
174 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); | 174 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); |
175 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined | 175 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined |
176 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); | 176 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); |
177 | return (peeraddress.ip4Addr() & mask) == auth_peer; | 177 | return (peeraddress.ip4Addr() & mask) == auth_peer; |
178 | } | 178 | } |
179 | 179 | ||
180 | bool SyncAuthentication::checkUser( const QString& user ) | 180 | bool SyncAuthentication::checkUser( const QString& user ) |
181 | { | 181 | { |
182 | if ( user.isEmpty() ) | 182 | if ( user.isEmpty() ) |
183 | return FALSE; | 183 | return FALSE; |
184 | QString euser = loginName(); | 184 | QString euser = loginName(); |
185 | return user == euser; | 185 | return user == euser; |
186 | } | 186 | } |
187 | 187 | ||
188 | bool SyncAuthentication::checkPassword( const QString& password ) | 188 | bool SyncAuthentication::checkPassword( const QString& password ) |
189 | { | 189 | { |
190 | #ifdef ALLOW_UNIX_USER_FTP | 190 | #ifdef ALLOW_UNIX_USER_FTP |
191 | // First, check system password... | 191 | // First, check system password... |
192 | 192 | ||
193 | struct passwd *pw = 0; | 193 | struct passwd *pw = 0; |
194 | struct spwd *spw = 0; | 194 | struct spwd *spw = 0; |
195 | 195 | ||
196 | pw = getpwuid( geteuid() ); | 196 | pw = getpwuid( geteuid() ); |
197 | spw = getspnam( pw->pw_name ); | 197 | spw = getspnam( pw->pw_name ); |
198 | 198 | ||
199 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 199 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
200 | if ( cpwd == "x" && spw ) | 200 | if ( cpwd == "x" && spw ) |
201 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 201 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
202 | 202 | ||
203 | // Note: some systems use more than crypt for passwords. | 203 | // Note: some systems use more than crypt for passwords. |
204 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 204 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
205 | if ( cpwd == cpassword ) | 205 | if ( cpwd == cpassword ) |
206 | return TRUE; | 206 | return TRUE; |
207 | #endif | 207 | #endif |
208 | 208 | ||
209 | static int lastdenial = 0; | 209 | static int lastdenial = 0; |
210 | static int denials = 0; | 210 | static int denials = 0; |
211 | int now = time(0); | 211 | int now = time(0); |
212 | 212 | ||
213 | // Detect old Qtopia Desktop (no password) | 213 | // Detect old Qtopia Desktop (no password) |
214 | if ( password.isEmpty() ) { | 214 | if ( password.isEmpty() ) { |
215 | if ( denials < 1 || now > lastdenial + 600 ) { | 215 | if ( denials < 1 || now > lastdenial + 600 ) { |
216 | QMessageBox::warning( 0, tr("Sync Connection"), | 216 | QMessageBox::warning( 0, tr("Sync Connection"), |
217 | tr("<p>An unauthorized system is requesting access to this device." | 217 | tr("<p>An unauthorized system is requesting access to this device." |
218 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " | 218 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " |
219 | "please upgrade."), | 219 | "please upgrade."), |
220 | tr("Deny") ); | 220 | tr("Deny") ); |
221 | denials++; | 221 | denials++; |
222 | lastdenial = now; | 222 | lastdenial = now; |
223 | } | 223 | } |
224 | return FALSE; | 224 | return FALSE; |
225 | } | 225 | } |
226 | 226 | ||
227 | // Second, check sync password... | 227 | // Second, check sync password... |
228 | QString pass = password.left(6); | 228 | QString pass = password.left(6); |
229 | /* old QtopiaDesktops are sending | 229 | /* old QtopiaDesktops are sending |
230 | * rootme newer versions got a Qtopia | 230 | * rootme newer versions got a Qtopia |
231 | * prefixed. Qtopia prefix will suceed | 231 | * prefixed. Qtopia prefix will suceed |
232 | * until the sync software syncs up | 232 | * until the sync software syncs up |
233 | * FIXME | 233 | * FIXME |
234 | */ | 234 | */ |
235 | if ( pass == "rootme" || pass == "Qtopia") { | 235 | if ( pass == "rootme" || pass == "Qtopia") { |
236 | 236 | ||
237 | QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); | 237 | QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); |
238 | Config cfg("Security"); | 238 | Config cfg("Security"); |
239 | cfg.setGroup("Sync"); | 239 | cfg.setGroup("Sync"); |
240 | QString pwds = cfg.readEntry("Passwords"); | 240 | QString pwds = cfg.readEntry("Passwords"); |
241 | if ( QStringList::split(QChar(' '), pwds).contains(cpassword) ) | 241 | if ( QStringList::split(QChar(' '), pwds).contains(cpassword) ) |
242 | return TRUE; | 242 | return TRUE; |
243 | 243 | ||
244 | // Unrecognized system. Be careful... | 244 | // Unrecognized system. Be careful... |
245 | 245 | ||
246 | if ( (denials > 2 && now < lastdenial + 600) | 246 | if ( (denials > 2 && now < lastdenial + 600) |
247 | || QMessageBox::warning(0, tr("Sync Connection"), | 247 | || QMessageBox::warning(0, tr("Sync Connection"), |
248 | tr("<p>An unrecognized system is requesting access to this device." | 248 | tr("<p>An unrecognized system is requesting access to this device." |
249 | "<p>If you have just initiated a Sync for the first time, this is normal."), | 249 | "<p>If you have just initiated a Sync for the first time, this is normal."), |
250 | tr("Allow"), tr("Deny"), 0, 1, 1 ) == 1 ) { | 250 | tr("Allow"), tr("Deny"), 0, 1, 1 ) == 1 ) { |
251 | denials++; | 251 | denials++; |
252 | lastdenial = now; | 252 | lastdenial = now; |
253 | return FALSE; | 253 | return FALSE; |
254 | } | 254 | } |
255 | else { | 255 | else { |
256 | denials = 0; | 256 | denials = 0; |
257 | cfg.writeEntry("Passwords", pwds + " " + cpassword); | 257 | cfg.writeEntry("Passwords", pwds + " " + cpassword); |
258 | return TRUE; | 258 | return TRUE; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | return FALSE; | 262 | return FALSE; |
263 | } | 263 | } |
264 | 264 | ||
265 | ServerPI::ServerPI( int socket, QObject *parent , const char* name ) | 265 | ServerPI::ServerPI( int socket, QObject *parent , const char* name ) |
266 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) | 266 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) |
267 | { | 267 | { |
268 | state = Connected; | 268 | state = Connected; |
269 | 269 | ||
270 | setSocket( socket ); | 270 | setSocket( socket ); |
271 | 271 | ||
272 | peerport = peerPort(); | 272 | peerport = peerPort(); |
273 | peeraddress = peerAddress(); | 273 | peeraddress = peerAddress(); |
274 | 274 | ||
275 | #ifndef INSECURE | 275 | #ifndef INSECURE |
276 | 276 | ||
277 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { | 277 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { |
278 | state = Forbidden; | 278 | state = Forbidden; |
279 | startTimer( 0 ); | 279 | startTimer( 0 ); |
280 | } | 280 | } |
281 | else | 281 | else |
282 | #endif | 282 | #endif |
283 | { | 283 | { |
284 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 284 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
285 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 285 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
286 | 286 | ||
287 | passiv = FALSE; | 287 | passiv = FALSE; |
288 | for ( int i = 0; i < 4; i++ ) | 288 | for ( int i = 0; i < 4; i++ ) |
289 | wait[i] = FALSE; | 289 | wait[i] = FALSE; |
290 | 290 | ||
291 | send( "220 Qtopia " QPE_VERSION " FTP Server" ); | 291 | send( "220 Qtopia " QPE_VERSION " FTP Server" ); |
292 | state = Wait_USER; | 292 | state = Wait_USER; |
293 | 293 | ||
294 | dtp = new ServerDTP( this ); | 294 | dtp = new ServerDTP( this ); |
295 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); | 295 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); |
296 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); | 296 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); |
297 | connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); | 297 | connect( dtp, SIGNAL( error(int) ), SLOT( dtpError(int) ) ); |
298 | 298 | ||
299 | 299 | ||
300 | directory = QDir::currentDirPath(); | 300 | directory = QDir::currentDirPath(); |
301 | 301 | ||
302 | static int p = 1024; | 302 | static int p = 1024; |
303 | 303 | ||
304 | while ( !serversocket || !serversocket->ok() ) { | 304 | while ( !serversocket || !serversocket->ok() ) { |
305 | delete serversocket; | 305 | delete serversocket; |
306 | serversocket = new ServerSocket( ++p, this ); | 306 | serversocket = new ServerSocket( ++p, this ); |
307 | } | 307 | } |
308 | connect( serversocket, SIGNAL( newIncomming( int ) ), | 308 | connect( serversocket, SIGNAL( newIncomming(int) ), |
309 | SLOT( newConnection( int ) ) ); | 309 | SLOT( newConnection(int) ) ); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | ServerPI::~ServerPI() | 313 | ServerPI::~ServerPI() |
314 | { | 314 | { |
315 | } | 315 | } |
316 | 316 | ||
317 | void ServerPI::connectionClosed() | 317 | void ServerPI::connectionClosed() |
318 | { | 318 | { |
319 | // qDebug( "Debug: Connection closed" ); | 319 | // qDebug( "Debug: Connection closed" ); |
320 | delete this; | 320 | delete this; |
321 | } | 321 | } |
322 | 322 | ||
323 | void ServerPI::send( const QString& msg ) | 323 | void ServerPI::send( const QString& msg ) |
324 | { | 324 | { |
325 | QTextStream os( this ); | 325 | QTextStream os( this ); |
326 | os << msg << endl; | 326 | os << msg << endl; |
327 | //qDebug( "Reply: %s", msg.latin1() ); | 327 | //qDebug( "Reply: %s", msg.latin1() ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void ServerPI::read() | 330 | void ServerPI::read() |
331 | { | 331 | { |
332 | while ( canReadLine() ) | 332 | while ( canReadLine() ) |
333 | process( readLine().stripWhiteSpace() ); | 333 | process( readLine().stripWhiteSpace() ); |
334 | } | 334 | } |
335 | 335 | ||
336 | bool ServerPI::checkReadFile( const QString& file ) | 336 | bool ServerPI::checkReadFile( const QString& file ) |
337 | { | 337 | { |
338 | QString filename; | 338 | QString filename; |
339 | 339 | ||
340 | if ( file[0] != "/" ) | 340 | if ( file[0] != "/" ) |
341 | filename = directory.path() + "/" + file; | 341 | filename = directory.path() + "/" + file; |
342 | else | 342 | else |
343 | filename = file; | 343 | filename = file; |
344 | 344 | ||
345 | QFileInfo fi( filename ); | 345 | QFileInfo fi( filename ); |
346 | return ( fi.exists() && fi.isReadable() ); | 346 | return ( fi.exists() && fi.isReadable() ); |
347 | } | 347 | } |
348 | 348 | ||
349 | bool ServerPI::checkWriteFile( const QString& file ) | 349 | bool ServerPI::checkWriteFile( const QString& file ) |
350 | { | 350 | { |
351 | QString filename; | 351 | QString filename; |
352 | 352 | ||
353 | if ( file[0] != "/" ) | 353 | if ( file[0] != "/" ) |
354 | filename = directory.path() + "/" + file; | 354 | filename = directory.path() + "/" + file; |
355 | else | 355 | else |
356 | filename = file; | 356 | filename = file; |
357 | 357 | ||
358 | QFileInfo fi( filename ); | 358 | QFileInfo fi( filename ); |
359 | 359 | ||
360 | if ( fi.exists() ) | 360 | if ( fi.exists() ) |
361 | if ( !QFile( filename ).remove() ) | 361 | if ( !QFile( filename ).remove() ) |
362 | return FALSE; | 362 | return FALSE; |
363 | return TRUE; | 363 | return TRUE; |
364 | } | 364 | } |
365 | 365 | ||
366 | void ServerPI::process( const QString& message ) | 366 | void ServerPI::process( const QString& message ) |
367 | { | 367 | { |
368 | //qDebug( "Command: %s", message.latin1() ); | 368 | //qDebug( "Command: %s", message.latin1() ); |
369 | 369 | ||
370 | // split message using "," as separator | 370 | // split message using "," as separator |
371 | QStringList msg = QStringList::split( " ", message ); | 371 | QStringList msg = QStringList::split( " ", message ); |
372 | if ( msg.isEmpty() ) | 372 | if ( msg.isEmpty() ) |
373 | return ; | 373 | return ; |
374 | 374 | ||
375 | // command token | 375 | // command token |
376 | QString cmd = msg[0].upper(); | 376 | QString cmd = msg[0].upper(); |
377 | 377 | ||
378 | // argument token | 378 | // argument token |
379 | QString arg; | 379 | QString arg; |
380 | if ( msg.count() >= 2 ) | 380 | if ( msg.count() >= 2 ) |
381 | arg = msg[1]; | 381 | arg = msg[1]; |
382 | 382 | ||
383 | // full argument string | 383 | // full argument string |
384 | QString args; | 384 | QString args; |
385 | if ( msg.count() >= 2 ) { | 385 | if ( msg.count() >= 2 ) { |
386 | QStringList copy( msg ); | 386 | QStringList copy( msg ); |
387 | // FIXME: for Qt3 | 387 | // FIXME: for Qt3 |
388 | // copy.pop_front() | 388 | // copy.pop_front() |
389 | copy.remove( copy.begin() ); | 389 | copy.remove( copy.begin() ); |
390 | args = copy.join( " " ); | 390 | args = copy.join( " " ); |
391 | } | 391 | } |
392 | 392 | ||
393 | //qDebug( "args: %s", args.latin1() ); | 393 | //qDebug( "args: %s", args.latin1() ); |
394 | 394 | ||
395 | // we always respond to QUIT, regardless of state | 395 | // we always respond to QUIT, regardless of state |
396 | if ( cmd == "QUIT" ) { | 396 | if ( cmd == "QUIT" ) { |
397 | send( "211 Good bye!" ); | 397 | send( "211 Good bye!" ); |
398 | delete this; | 398 | delete this; |
399 | return ; | 399 | return ; |
400 | } | 400 | } |
401 | 401 | ||
402 | // connected to client | 402 | // connected to client |
403 | if ( Connected == state ) | 403 | if ( Connected == state ) |
404 | return ; | 404 | return ; |
405 | 405 | ||
406 | // waiting for user name | 406 | // waiting for user name |
407 | if ( Wait_USER == state ) { | 407 | if ( Wait_USER == state ) { |
408 | 408 | ||
409 | if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { | 409 | if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { |
410 | send( "530 Please login with USER and PASS" ); | 410 | send( "530 Please login with USER and PASS" ); |
411 | return ; | 411 | return ; |
412 | } | 412 | } |
413 | send( "331 User name ok, need password" ); | 413 | send( "331 User name ok, need password" ); |
414 | state = Wait_PASS; | 414 | state = Wait_PASS; |
415 | return ; | 415 | return ; |
416 | } | 416 | } |
417 | 417 | ||
418 | // waiting for password | 418 | // waiting for password |
419 | if ( Wait_PASS == state ) { | 419 | if ( Wait_PASS == state ) { |
420 | 420 | ||
421 | if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { | 421 | if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { |
422 | send( "530 Please login with USER and PASS" ); | 422 | send( "530 Please login with USER and PASS" ); |
423 | return ; | 423 | return ; |
424 | } | 424 | } |
425 | send( "230 User logged in, proceed" ); | 425 | send( "230 User logged in, proceed" ); |
426 | state = Ready; | 426 | state = Ready; |
427 | return ; | 427 | return ; |
428 | } | 428 | } |
429 | 429 | ||
430 | // ACCESS CONTROL COMMANDS | 430 | // ACCESS CONTROL COMMANDS |
431 | 431 | ||
432 | 432 | ||
433 | // account (ACCT) | 433 | // account (ACCT) |
434 | if ( cmd == "ACCT" ) { | 434 | if ( cmd == "ACCT" ) { |
435 | // even wu-ftp does not support it | 435 | // even wu-ftp does not support it |
436 | send( "502 Command not implemented" ); | 436 | send( "502 Command not implemented" ); |
437 | } | 437 | } |
438 | 438 | ||
439 | // change working directory (CWD) | 439 | // change working directory (CWD) |
440 | else if ( cmd == "CWD" ) { | 440 | else if ( cmd == "CWD" ) { |
441 | 441 | ||
442 | if ( !args.isEmpty() ) { | 442 | if ( !args.isEmpty() ) { |
443 | if ( directory.cd( args, TRUE ) ) | 443 | if ( directory.cd( args, TRUE ) ) |
444 | send( "250 Requested file action okay, completed" ); | 444 | send( "250 Requested file action okay, completed" ); |
445 | else | 445 | else |
446 | send( "550 Requested action not taken" ); | 446 | send( "550 Requested action not taken" ); |
447 | } | 447 | } |
448 | else | 448 | else |
449 | send( "500 Syntax error, command unrecognized" ); | 449 | send( "500 Syntax error, command unrecognized" ); |
450 | } | 450 | } |
451 | 451 | ||
452 | // change to parent directory (CDUP) | 452 | // change to parent directory (CDUP) |
453 | else if ( cmd == "CDUP" ) { | 453 | else if ( cmd == "CDUP" ) { |
454 | if ( directory.cdUp() ) | 454 | if ( directory.cdUp() ) |
455 | send( "250 Requested file action okay, completed" ); | 455 | send( "250 Requested file action okay, completed" ); |
456 | else | 456 | else |
457 | send( "550 Requested action not taken" ); | 457 | send( "550 Requested action not taken" ); |
458 | } | 458 | } |
459 | 459 | ||
460 | // structure mount (SMNT) | 460 | // structure mount (SMNT) |
461 | else if ( cmd == "SMNT" ) { | 461 | else if ( cmd == "SMNT" ) { |
462 | // even wu-ftp does not support it | 462 | // even wu-ftp does not support it |
463 | send( "502 Command not implemented" ); | 463 | send( "502 Command not implemented" ); |
464 | } | 464 | } |
465 | 465 | ||
466 | // reinitialize (REIN) | 466 | // reinitialize (REIN) |
467 | else if ( cmd == "REIN" ) { | 467 | else if ( cmd == "REIN" ) { |
468 | // even wu-ftp does not support it | 468 | // even wu-ftp does not support it |
469 | send( "502 Command not implemented" ); | 469 | send( "502 Command not implemented" ); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | // TRANSFER PARAMETER COMMANDS | 473 | // TRANSFER PARAMETER COMMANDS |
474 | 474 | ||
475 | 475 | ||
476 | // data port (PORT) | 476 | // data port (PORT) |
477 | else if ( cmd == "PORT" ) { | 477 | else if ( cmd == "PORT" ) { |
478 | if ( parsePort( arg ) ) | 478 | if ( parsePort( arg ) ) |
479 | send( "200 Command okay" ); | 479 | send( "200 Command okay" ); |
480 | else | 480 | else |
481 | send( "500 Syntax error, command unrecognized" ); | 481 | send( "500 Syntax error, command unrecognized" ); |
482 | } | 482 | } |
483 | 483 | ||
484 | // passive (PASV) | 484 | // passive (PASV) |
485 | else if ( cmd == "PASV" ) { | 485 | else if ( cmd == "PASV" ) { |
486 | passiv = TRUE; | 486 | passiv = TRUE; |
487 | send( "227 Entering Passive Mode (" | 487 | send( "227 Entering Passive Mode (" |
488 | + address().toString().replace( QRegExp( "\\." ), "," ) + "," | 488 | + address().toString().replace( QRegExp( "\\." ), "," ) + "," |
489 | + QString::number( ( serversocket->port() ) >> 8 ) + "," | 489 | + QString::number( ( serversocket->port() ) >> 8 ) + "," |
490 | + QString::number( ( serversocket->port() ) & 0xFF ) + ")" ); | 490 | + QString::number( ( serversocket->port() ) & 0xFF ) + ")" ); |
491 | } | 491 | } |
492 | 492 | ||
493 | // representation type (TYPE) | 493 | // representation type (TYPE) |
494 | else if ( cmd == "TYPE" ) { | 494 | else if ( cmd == "TYPE" ) { |
495 | if ( arg.upper() == "A" || arg.upper() == "I" ) | 495 | if ( arg.upper() == "A" || arg.upper() == "I" ) |
496 | send( "200 Command okay" ); | 496 | send( "200 Command okay" ); |
497 | else | 497 | else |
498 | send( "504 Command not implemented for that parameter" ); | 498 | send( "504 Command not implemented for that parameter" ); |
499 | } | 499 | } |
500 | 500 | ||
501 | // file structure (STRU) | 501 | // file structure (STRU) |
@@ -857,579 +857,579 @@ bool ServerPI::sendList( const QString& arg ) | |||
857 | 857 | ||
858 | ts << "total " << QString::number( total / 1024 ) << endl; | 858 | ts << "total " << QString::number( total / 1024 ) << endl; |
859 | 859 | ||
860 | it.toFirst(); | 860 | it.toFirst(); |
861 | while ( ( info = it.current() ) ) { | 861 | while ( ( info = it.current() ) ) { |
862 | if ( info->fileName() == "." || info->fileName() == ".." ) { | 862 | if ( info->fileName() == "." || info->fileName() == ".." ) { |
863 | ++it; | 863 | ++it; |
864 | continue; | 864 | continue; |
865 | } | 865 | } |
866 | ts << fileListing( info ) << endl; | 866 | ts << fileListing( info ) << endl; |
867 | ++it; | 867 | ++it; |
868 | } | 868 | } |
869 | } | 869 | } |
870 | 870 | ||
871 | if ( passiv ) { | 871 | if ( passiv ) { |
872 | waitarray = buffer.buffer(); | 872 | waitarray = buffer.buffer(); |
873 | wait[SendByteArray] = TRUE; | 873 | wait[SendByteArray] = TRUE; |
874 | if ( waitsocket ) | 874 | if ( waitsocket ) |
875 | newConnection( waitsocket ); | 875 | newConnection( waitsocket ); |
876 | } | 876 | } |
877 | else | 877 | else |
878 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); | 878 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); |
879 | return TRUE; | 879 | return TRUE; |
880 | } | 880 | } |
881 | 881 | ||
882 | QString ServerPI::fileListing( QFileInfo *info ) | 882 | QString ServerPI::fileListing( QFileInfo *info ) |
883 | { | 883 | { |
884 | if ( !info ) | 884 | if ( !info ) |
885 | return QString::null; | 885 | return QString::null; |
886 | QString s; | 886 | QString s; |
887 | 887 | ||
888 | // type char | 888 | // type char |
889 | if ( info->isDir() ) | 889 | if ( info->isDir() ) |
890 | s += "d"; | 890 | s += "d"; |
891 | else if ( info->isSymLink() ) | 891 | else if ( info->isSymLink() ) |
892 | s += "l"; | 892 | s += "l"; |
893 | else | 893 | else |
894 | s += "-"; | 894 | s += "-"; |
895 | 895 | ||
896 | // permisson string | 896 | // permisson string |
897 | s += permissionString( info ) + " "; | 897 | s += permissionString( info ) + " "; |
898 | 898 | ||
899 | // number of hardlinks | 899 | // number of hardlinks |
900 | int subdirs = 1; | 900 | int subdirs = 1; |
901 | 901 | ||
902 | if ( info->isDir() ) | 902 | if ( info->isDir() ) |
903 | subdirs = 2; | 903 | subdirs = 2; |
904 | // FIXME : this is to slow | 904 | // FIXME : this is to slow |
905 | //if ( info->isDir() ) | 905 | //if ( info->isDir() ) |
906 | //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); | 906 | //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); |
907 | 907 | ||
908 | s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; | 908 | s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; |
909 | 909 | ||
910 | // owner | 910 | // owner |
911 | s += info->owner().leftJustify( 8, ' ', TRUE ) + " "; | 911 | s += info->owner().leftJustify( 8, ' ', TRUE ) + " "; |
912 | 912 | ||
913 | // group | 913 | // group |
914 | s += info->group().leftJustify( 8, ' ', TRUE ) + " "; | 914 | s += info->group().leftJustify( 8, ' ', TRUE ) + " "; |
915 | 915 | ||
916 | // file size in bytes | 916 | // file size in bytes |
917 | s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; | 917 | s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; |
918 | 918 | ||
919 | // last modified date | 919 | // last modified date |
920 | QDate date = info->lastModified().date(); | 920 | QDate date = info->lastModified().date(); |
921 | QTime time = info->lastModified().time(); | 921 | QTime time = info->lastModified().time(); |
922 | s += date.monthName( date.month() ) + " " | 922 | s += date.monthName( date.month() ) + " " |
923 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " | 923 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " |
924 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" | 924 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" |
925 | + QString::number( time.minute() ).rightJustify( 2, '0', TRUE ) + " "; | 925 | + QString::number( time.minute() ).rightJustify( 2, '0', TRUE ) + " "; |
926 | 926 | ||
927 | // file name | 927 | // file name |
928 | s += info->fileName(); | 928 | s += info->fileName(); |
929 | 929 | ||
930 | return s; | 930 | return s; |
931 | } | 931 | } |
932 | 932 | ||
933 | QString ServerPI::permissionString( QFileInfo *info ) | 933 | QString ServerPI::permissionString( QFileInfo *info ) |
934 | { | 934 | { |
935 | if ( !info ) | 935 | if ( !info ) |
936 | return QString( "---------" ); | 936 | return QString( "---------" ); |
937 | QString s; | 937 | QString s; |
938 | 938 | ||
939 | // user | 939 | // user |
940 | if ( info->permission( QFileInfo::ReadUser ) ) | 940 | if ( info->permission( QFileInfo::ReadUser ) ) |
941 | s += "r"; | 941 | s += "r"; |
942 | else | 942 | else |
943 | s += "-"; | 943 | s += "-"; |
944 | if ( info->permission( QFileInfo::WriteUser ) ) | 944 | if ( info->permission( QFileInfo::WriteUser ) ) |
945 | s += "w"; | 945 | s += "w"; |
946 | else | 946 | else |
947 | s += "-"; | 947 | s += "-"; |
948 | if ( info->permission( QFileInfo::ExeUser ) ) | 948 | if ( info->permission( QFileInfo::ExeUser ) ) |
949 | s += "x"; | 949 | s += "x"; |
950 | else | 950 | else |
951 | s += "-"; | 951 | s += "-"; |
952 | 952 | ||
953 | // group | 953 | // group |
954 | if ( info->permission( QFileInfo::ReadGroup ) ) | 954 | if ( info->permission( QFileInfo::ReadGroup ) ) |
955 | s += "r"; | 955 | s += "r"; |
956 | else | 956 | else |
957 | s += "-"; | 957 | s += "-"; |
958 | if ( info->permission( QFileInfo::WriteGroup ) ) | 958 | if ( info->permission( QFileInfo::WriteGroup ) ) |
959 | s += "w"; | 959 | s += "w"; |
960 | else | 960 | else |
961 | s += "-"; | 961 | s += "-"; |
962 | if ( info->permission( QFileInfo::ExeGroup ) ) | 962 | if ( info->permission( QFileInfo::ExeGroup ) ) |
963 | s += "x"; | 963 | s += "x"; |
964 | else | 964 | else |
965 | s += "-"; | 965 | s += "-"; |
966 | 966 | ||
967 | // exec | 967 | // exec |
968 | if ( info->permission( QFileInfo::ReadOther ) ) | 968 | if ( info->permission( QFileInfo::ReadOther ) ) |
969 | s += "r"; | 969 | s += "r"; |
970 | else | 970 | else |
971 | s += "-"; | 971 | s += "-"; |
972 | if ( info->permission( QFileInfo::WriteOther ) ) | 972 | if ( info->permission( QFileInfo::WriteOther ) ) |
973 | s += "w"; | 973 | s += "w"; |
974 | else | 974 | else |
975 | s += "-"; | 975 | s += "-"; |
976 | if ( info->permission( QFileInfo::ExeOther ) ) | 976 | if ( info->permission( QFileInfo::ExeOther ) ) |
977 | s += "x"; | 977 | s += "x"; |
978 | else | 978 | else |
979 | s += "-"; | 979 | s += "-"; |
980 | 980 | ||
981 | return s; | 981 | return s; |
982 | } | 982 | } |
983 | 983 | ||
984 | void ServerPI::newConnection( int socket ) | 984 | void ServerPI::newConnection( int socket ) |
985 | { | 985 | { |
986 | //qDebug( "New incomming connection" ); | 986 | //qDebug( "New incomming connection" ); |
987 | 987 | ||
988 | if ( !passiv ) | 988 | if ( !passiv ) |
989 | return ; | 989 | return ; |
990 | 990 | ||
991 | if ( wait[SendFile] ) { | 991 | if ( wait[SendFile] ) { |
992 | QStringList targets; | 992 | QStringList targets; |
993 | if ( backupRestoreGzip( waitfile, targets ) ) | 993 | if ( backupRestoreGzip( waitfile, targets ) ) |
994 | dtp->sendGzipFile( waitfile, targets ); | 994 | dtp->sendGzipFile( waitfile, targets ); |
995 | else | 995 | else |
996 | dtp->sendFile( waitfile ); | 996 | dtp->sendFile( waitfile ); |
997 | dtp->setSocket( socket ); | 997 | dtp->setSocket( socket ); |
998 | } | 998 | } |
999 | else if ( wait[RetrieveFile] ) { | 999 | else if ( wait[RetrieveFile] ) { |
1000 | qDebug("check retrieve file"); | 1000 | qDebug("check retrieve file"); |
1001 | if ( backupRestoreGzip( waitfile ) ) | 1001 | if ( backupRestoreGzip( waitfile ) ) |
1002 | dtp->retrieveGzipFile( waitfile ); | 1002 | dtp->retrieveGzipFile( waitfile ); |
1003 | else | 1003 | else |
1004 | dtp->retrieveFile( waitfile ); | 1004 | dtp->retrieveFile( waitfile ); |
1005 | dtp->setSocket( socket ); | 1005 | dtp->setSocket( socket ); |
1006 | } | 1006 | } |
1007 | else if ( wait[SendByteArray] ) { | 1007 | else if ( wait[SendByteArray] ) { |
1008 | dtp->sendByteArray( waitarray ); | 1008 | dtp->sendByteArray( waitarray ); |
1009 | dtp->setSocket( socket ); | 1009 | dtp->setSocket( socket ); |
1010 | } | 1010 | } |
1011 | else if ( wait[RetrieveByteArray] ) { | 1011 | else if ( wait[RetrieveByteArray] ) { |
1012 | qDebug("retrieve byte array"); | 1012 | qDebug("retrieve byte array"); |
1013 | dtp->retrieveByteArray(); | 1013 | dtp->retrieveByteArray(); |
1014 | dtp->setSocket( socket ); | 1014 | dtp->setSocket( socket ); |
1015 | } | 1015 | } |
1016 | else | 1016 | else |
1017 | waitsocket = socket; | 1017 | waitsocket = socket; |
1018 | 1018 | ||
1019 | for ( int i = 0; i < 4; i++ ) | 1019 | for ( int i = 0; i < 4; i++ ) |
1020 | wait[i] = FALSE; | 1020 | wait[i] = FALSE; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | QString ServerPI::absFilePath( const QString& file ) | 1023 | QString ServerPI::absFilePath( const QString& file ) |
1024 | { | 1024 | { |
1025 | if ( file.isEmpty() ) | 1025 | if ( file.isEmpty() ) |
1026 | return file; | 1026 | return file; |
1027 | 1027 | ||
1028 | QString filepath( file ); | 1028 | QString filepath( file ); |
1029 | if ( file[0] != "/" ) | 1029 | if ( file[0] != "/" ) |
1030 | filepath = directory.path() + "/" + file; | 1030 | filepath = directory.path() + "/" + file; |
1031 | 1031 | ||
1032 | return filepath; | 1032 | return filepath; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | 1035 | ||
1036 | void ServerPI::timerEvent( QTimerEvent * ) | 1036 | void ServerPI::timerEvent( QTimerEvent * ) |
1037 | { | 1037 | { |
1038 | connectionClosed(); | 1038 | connectionClosed(); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | 1041 | ||
1042 | ServerDTP::ServerDTP( QObject *parent, const char* name) | 1042 | ServerDTP::ServerDTP( QObject *parent, const char* name) |
1043 | : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), | 1043 | : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), |
1044 | retrieveTargzProc( 0 ), gzipProc( 0 ) | 1044 | retrieveTargzProc( 0 ), gzipProc( 0 ) |
1045 | { | 1045 | { |
1046 | 1046 | ||
1047 | connect( this, SIGNAL( connected() ), SLOT( connected() ) ); | 1047 | connect( this, SIGNAL( connected() ), SLOT( connected() ) ); |
1048 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 1048 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
1049 | connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) ); | 1049 | connect( this, SIGNAL( bytesWritten(int) ), SLOT( bytesWritten(int) ) ); |
1050 | connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); | 1050 | connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); |
1051 | 1051 | ||
1052 | gzipProc = new OProcess( this, "gzipProc" ); | 1052 | gzipProc = new OProcess( this, "gzipProc" ); |
1053 | 1053 | ||
1054 | createTargzProc = new OProcess( QString("tar"), this, "createTargzProc"); | 1054 | createTargzProc = new OProcess( QString("tar"), this, "createTargzProc"); |
1055 | createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); | 1055 | createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); |
1056 | connect( createTargzProc, SIGNAL( processExited(OProcess *) ), SLOT( targzDone() ) ); | 1056 | connect( createTargzProc, SIGNAL( processExited(OProcess*) ), SLOT( targzDone() ) ); |
1057 | 1057 | ||
1058 | QStringList args = "tar"; | 1058 | QStringList args = "tar"; |
1059 | args += "-xv"; | 1059 | args += "-xv"; |
1060 | retrieveTargzProc = new OProcess( args, this, "retrieveTargzProc" ); | 1060 | retrieveTargzProc = new OProcess( args, this, "retrieveTargzProc" ); |
1061 | retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); | 1061 | retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); |
1062 | connect( retrieveTargzProc, SIGNAL( processExited(OProcess *) ), | 1062 | connect( retrieveTargzProc, SIGNAL( processExited(OProcess*) ), |
1063 | SIGNAL( completed() ) ); | 1063 | SIGNAL( completed() ) ); |
1064 | connect( retrieveTargzProc, SIGNAL( processExited(OProcess *) ), | 1064 | connect( retrieveTargzProc, SIGNAL( processExited(OProcess*) ), |
1065 | SLOT( extractTarDone() ) ); | 1065 | SLOT( extractTarDone() ) ); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | ServerDTP::~ServerDTP() | 1068 | ServerDTP::~ServerDTP() |
1069 | { | 1069 | { |
1070 | buf.close(); | 1070 | buf.close(); |
1071 | file.close(); | 1071 | file.close(); |
1072 | createTargzProc->kill(); | 1072 | createTargzProc->kill(); |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | void ServerDTP::extractTarDone() | 1075 | void ServerDTP::extractTarDone() |
1076 | { | 1076 | { |
1077 | qDebug("extract done"); | 1077 | qDebug("extract done"); |
1078 | #ifndef QT_NO_COP | 1078 | #ifndef QT_NO_COP |
1079 | 1079 | ||
1080 | QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); | 1080 | QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); |
1081 | e << file.name(); | 1081 | e << file.name(); |
1082 | #endif | 1082 | #endif |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | void ServerDTP::connected() | 1085 | void ServerDTP::connected() |
1086 | { | 1086 | { |
1087 | // send file mode | 1087 | // send file mode |
1088 | switch ( mode ) { | 1088 | switch ( mode ) { |
1089 | case SendFile : | 1089 | case SendFile : |
1090 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { | 1090 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { |
1091 | emit failed(); | 1091 | emit failed(); |
1092 | mode = Idle; | 1092 | mode = Idle; |
1093 | return ; | 1093 | return ; |
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); | 1096 | //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); |
1097 | 1097 | ||
1098 | bytes_written = 0; | 1098 | bytes_written = 0; |
1099 | if ( file.size() == 0 ) { | 1099 | if ( file.size() == 0 ) { |
1100 | //make sure it doesn't hang on empty files | 1100 | //make sure it doesn't hang on empty files |
1101 | file.close(); | 1101 | file.close(); |
1102 | emit completed(); | 1102 | emit completed(); |
1103 | mode = Idle; | 1103 | mode = Idle; |
1104 | } | 1104 | } |
1105 | else { | 1105 | else { |
1106 | 1106 | ||
1107 | if ( !file.atEnd() ) { | 1107 | if ( !file.atEnd() ) { |
1108 | QCString s; | 1108 | QCString s; |
1109 | s.resize( block_size ); | 1109 | s.resize( block_size ); |
1110 | int bytes = file.readBlock( s.data(), block_size ); | 1110 | int bytes = file.readBlock( s.data(), block_size ); |
1111 | writeBlock( s.data(), bytes ); | 1111 | writeBlock( s.data(), bytes ); |
1112 | } | 1112 | } |
1113 | } | 1113 | } |
1114 | break; | 1114 | break; |
1115 | case SendGzipFile: | 1115 | case SendGzipFile: |
1116 | if ( createTargzProc->isRunning() ) { | 1116 | if ( createTargzProc->isRunning() ) { |
1117 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY | 1117 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY |
1118 | qWarning("Previous tar --gzip process is still running; killing it..."); | 1118 | qWarning("Previous tar --gzip process is still running; killing it..."); |
1119 | createTargzProc->kill(); | 1119 | createTargzProc->kill(); |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | bytes_written = 0; | 1122 | bytes_written = 0; |
1123 | qDebug("==>start send tar process"); | 1123 | qDebug("==>start send tar process"); |
1124 | if ( !createTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdout) ) | 1124 | if ( !createTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdout) ) |
1125 | qWarning("Error starting %s or %s", | 1125 | qWarning("Error starting %s or %s", |
1126 | createTargzProc->args()[0].data(), | 1126 | createTargzProc->args()[0].data(), |
1127 | gzipProc->args()[0].data()); | 1127 | gzipProc->args()[0].data()); |
1128 | break; | 1128 | break; |
1129 | case SendBuffer: | 1129 | case SendBuffer: |
1130 | if ( !buf.open( IO_ReadOnly) ) { | 1130 | if ( !buf.open( IO_ReadOnly) ) { |
1131 | emit failed(); | 1131 | emit failed(); |
1132 | mode = Idle; | 1132 | mode = Idle; |
1133 | return ; | 1133 | return ; |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | // qDebug( "Debug: Sending byte array" ); | 1136 | // qDebug( "Debug: Sending byte array" ); |
1137 | bytes_written = 0; | 1137 | bytes_written = 0; |
1138 | while ( !buf.atEnd() ) | 1138 | while ( !buf.atEnd() ) |
1139 | putch( buf.getch() ); | 1139 | putch( buf.getch() ); |
1140 | buf.close(); | 1140 | buf.close(); |
1141 | break; | 1141 | break; |
1142 | case RetrieveFile: | 1142 | case RetrieveFile: |
1143 | // retrieve file mode | 1143 | // retrieve file mode |
1144 | if ( file.exists() && !file.remove() ) { | 1144 | if ( file.exists() && !file.remove() ) { |
1145 | emit failed(); | 1145 | emit failed(); |
1146 | mode = Idle; | 1146 | mode = Idle; |
1147 | return ; | 1147 | return ; |
1148 | } | 1148 | } |
1149 | 1149 | ||
1150 | if ( !file.open( IO_WriteOnly) ) { | 1150 | if ( !file.open( IO_WriteOnly) ) { |
1151 | emit failed(); | 1151 | emit failed(); |
1152 | mode = Idle; | 1152 | mode = Idle; |
1153 | return ; | 1153 | return ; |
1154 | } | 1154 | } |
1155 | // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); | 1155 | // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); |
1156 | break; | 1156 | break; |
1157 | case RetrieveGzipFile: | 1157 | case RetrieveGzipFile: |
1158 | qDebug("=-> starting tar process to receive .tgz file"); | 1158 | qDebug("=-> starting tar process to receive .tgz file"); |
1159 | break; | 1159 | break; |
1160 | case RetrieveBuffer: | 1160 | case RetrieveBuffer: |
1161 | // retrieve buffer mode | 1161 | // retrieve buffer mode |
1162 | if ( !buf.open( IO_WriteOnly) ) { | 1162 | if ( !buf.open( IO_WriteOnly) ) { |
1163 | emit failed(); | 1163 | emit failed(); |
1164 | mode = Idle; | 1164 | mode = Idle; |
1165 | return ; | 1165 | return ; |
1166 | } | 1166 | } |
1167 | // qDebug( "Debug: Retrieving byte array" ); | 1167 | // qDebug( "Debug: Retrieving byte array" ); |
1168 | break; | 1168 | break; |
1169 | case Idle: | 1169 | case Idle: |
1170 | qDebug("connection established but mode set to Idle; BUG!"); | 1170 | qDebug("connection established but mode set to Idle; BUG!"); |
1171 | break; | 1171 | break; |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | void ServerDTP::connectionClosed() | 1175 | void ServerDTP::connectionClosed() |
1176 | { | 1176 | { |
1177 | //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); | 1177 | //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); |
1178 | 1178 | ||
1179 | // send file mode | 1179 | // send file mode |
1180 | if ( SendFile == mode ) { | 1180 | if ( SendFile == mode ) { |
1181 | if ( bytes_written == file.size() ) | 1181 | if ( bytes_written == file.size() ) |
1182 | emit completed(); | 1182 | emit completed(); |
1183 | else | 1183 | else |
1184 | emit failed(); | 1184 | emit failed(); |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | // send buffer mode | 1187 | // send buffer mode |
1188 | else if ( SendBuffer == mode ) { | 1188 | else if ( SendBuffer == mode ) { |
1189 | if ( bytes_written == buf.size() ) | 1189 | if ( bytes_written == buf.size() ) |
1190 | emit completed(); | 1190 | emit completed(); |
1191 | else | 1191 | else |
1192 | emit failed(); | 1192 | emit failed(); |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | // retrieve file mode | 1195 | // retrieve file mode |
1196 | else if ( RetrieveFile == mode ) { | 1196 | else if ( RetrieveFile == mode ) { |
1197 | file.close(); | 1197 | file.close(); |
1198 | emit completed(); | 1198 | emit completed(); |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | else if ( RetrieveGzipFile == mode ) { | 1201 | else if ( RetrieveGzipFile == mode ) { |
1202 | qDebug("Done writing ungzip file; closing input"); | 1202 | qDebug("Done writing ungzip file; closing input"); |
1203 | gzipProc->flushStdin(); | 1203 | gzipProc->flushStdin(); |
1204 | gzipProc->closeStdin(); | 1204 | gzipProc->closeStdin(); |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | // retrieve buffer mode | 1207 | // retrieve buffer mode |
1208 | else if ( RetrieveBuffer == mode ) { | 1208 | else if ( RetrieveBuffer == mode ) { |
1209 | buf.close(); | 1209 | buf.close(); |
1210 | emit completed(); | 1210 | emit completed(); |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | mode = Idle; | 1213 | mode = Idle; |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | void ServerDTP::bytesWritten( int bytes ) | 1216 | void ServerDTP::bytesWritten( int bytes ) |
1217 | { | 1217 | { |
1218 | bytes_written += bytes; | 1218 | bytes_written += bytes; |
1219 | 1219 | ||
1220 | // send file mode | 1220 | // send file mode |
1221 | if ( SendFile == mode ) { | 1221 | if ( SendFile == mode ) { |
1222 | 1222 | ||
1223 | if ( bytes_written == file.size() ) { | 1223 | if ( bytes_written == file.size() ) { |
1224 | // qDebug( "Debug: Sending complete: %d bytes", file.size() ); | 1224 | // qDebug( "Debug: Sending complete: %d bytes", file.size() ); |
1225 | file.close(); | 1225 | file.close(); |
1226 | emit completed(); | 1226 | emit completed(); |
1227 | mode = Idle; | 1227 | mode = Idle; |
1228 | } | 1228 | } |
1229 | else if ( !file.atEnd() ) { | 1229 | else if ( !file.atEnd() ) { |
1230 | QCString s; | 1230 | QCString s; |
1231 | s.resize( block_size ); | 1231 | s.resize( block_size ); |
1232 | int bytes = file.readBlock( s.data(), block_size ); | 1232 | int bytes = file.readBlock( s.data(), block_size ); |
1233 | writeBlock( s.data(), bytes ); | 1233 | writeBlock( s.data(), bytes ); |
1234 | } | 1234 | } |
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | // send buffer mode | 1237 | // send buffer mode |
1238 | if ( SendBuffer == mode ) { | 1238 | if ( SendBuffer == mode ) { |
1239 | 1239 | ||
1240 | if ( bytes_written == buf.size() ) { | 1240 | if ( bytes_written == buf.size() ) { |
1241 | // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); | 1241 | // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); |
1242 | emit completed(); | 1242 | emit completed(); |
1243 | mode = Idle; | 1243 | mode = Idle; |
1244 | } | 1244 | } |
1245 | } | 1245 | } |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | void ServerDTP::readyRead() | 1248 | void ServerDTP::readyRead() |
1249 | { | 1249 | { |
1250 | // retrieve file mode | 1250 | // retrieve file mode |
1251 | if ( RetrieveFile == mode ) { | 1251 | if ( RetrieveFile == mode ) { |
1252 | QCString s; | 1252 | QCString s; |
1253 | s.resize( bytesAvailable() ); | 1253 | s.resize( bytesAvailable() ); |
1254 | readBlock( s.data(), bytesAvailable() ); | 1254 | readBlock( s.data(), bytesAvailable() ); |
1255 | file.writeBlock( s.data(), s.size() ); | 1255 | file.writeBlock( s.data(), s.size() ); |
1256 | } | 1256 | } |
1257 | else if ( RetrieveGzipFile == mode ) { | 1257 | else if ( RetrieveGzipFile == mode ) { |
1258 | if ( !gzipProc->isRunning() ) | 1258 | if ( !gzipProc->isRunning() ) |
1259 | gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout )); | 1259 | gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout )); |
1260 | 1260 | ||
1261 | QByteArray s; | 1261 | QByteArray s; |
1262 | s.resize( bytesAvailable() ); | 1262 | s.resize( bytesAvailable() ); |
1263 | readBlock( s.data(), bytesAvailable() ); | 1263 | readBlock( s.data(), bytesAvailable() ); |
1264 | gzipProc->writeStdin( s.data(), s.size() ); | 1264 | gzipProc->writeStdin( s.data(), s.size() ); |
1265 | qDebug("wrote %d bytes to ungzip ", s.size() ); | 1265 | qDebug("wrote %d bytes to ungzip ", s.size() ); |
1266 | } | 1266 | } |
1267 | // retrieve buffer mode | 1267 | // retrieve buffer mode |
1268 | else if ( RetrieveBuffer == mode ) { | 1268 | else if ( RetrieveBuffer == mode ) { |
1269 | QCString s; | 1269 | QCString s; |
1270 | s.resize( bytesAvailable() ); | 1270 | s.resize( bytesAvailable() ); |
1271 | readBlock( s.data(), bytesAvailable() ); | 1271 | readBlock( s.data(), bytesAvailable() ); |
1272 | buf.writeBlock( s.data(), s.size() ); | 1272 | buf.writeBlock( s.data(), s.size() ); |
1273 | } | 1273 | } |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | void ServerDTP::writeTargzBlock(OProcess *, char *buffer, int buflen) | 1276 | void ServerDTP::writeTargzBlock(OProcess *, char *buffer, int buflen) |
1277 | { | 1277 | { |
1278 | writeBlock( buffer, buflen ); | 1278 | writeBlock( buffer, buflen ); |
1279 | qDebug("writeTargzBlock %d", buflen); | 1279 | qDebug("writeTargzBlock %d", buflen); |
1280 | if ( !createTargzProc->isRunning() ) { | 1280 | if ( !createTargzProc->isRunning() ) { |
1281 | qDebug("tar and gzip done"); | 1281 | qDebug("tar and gzip done"); |
1282 | emit completed(); | 1282 | emit completed(); |
1283 | mode = Idle; | 1283 | mode = Idle; |
1284 | disconnect( gzipProc, SIGNAL( receivedStdout(OProcess *, char *, int ) ), | 1284 | disconnect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), |
1285 | this, SLOT( writeTargzBlock(OProcess *, char *, int) ) ); | 1285 | this, SLOT( writeTargzBlock(OProcess*,char*,int) ) ); |
1286 | } | 1286 | } |
1287 | } | 1287 | } |
1288 | 1288 | ||
1289 | void ServerDTP::targzDone() | 1289 | void ServerDTP::targzDone() |
1290 | { | 1290 | { |
1291 | //qDebug("targz done"); | 1291 | //qDebug("targz done"); |
1292 | disconnect( createTargzProc, SIGNAL( receivedStdout(OProcess *, char *, int) ), | 1292 | disconnect( createTargzProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), |
1293 | this, SLOT( gzipTarBlock(OProcess *, char *, int) ) ); | 1293 | this, SLOT( gzipTarBlock(OProcess*,char*,int) ) ); |
1294 | gzipProc->closeStdin(); | 1294 | gzipProc->closeStdin(); |
1295 | } | 1295 | } |
1296 | 1296 | ||
1297 | void ServerDTP::gzipTarBlock(OProcess *, char *buffer, int buflen) | 1297 | void ServerDTP::gzipTarBlock(OProcess *, char *buffer, int buflen) |
1298 | { | 1298 | { |
1299 | //qDebug("gzipTarBlock"); | 1299 | //qDebug("gzipTarBlock"); |
1300 | if ( !gzipProc->isRunning() ) { | 1300 | if ( !gzipProc->isRunning() ) { |
1301 | //qDebug("auto start gzip proc"); | 1301 | //qDebug("auto start gzip proc"); |
1302 | gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout )); | 1302 | gzipProc->start(OProcess::NotifyOnExit, (OProcess::Communication) ( OProcess::Stdin | OProcess::Stdout )); |
1303 | } | 1303 | } |
1304 | gzipProc->writeStdin( buffer, buflen ); | 1304 | gzipProc->writeStdin( buffer, buflen ); |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) | 1307 | void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) |
1308 | { | 1308 | { |
1309 | file.setName( fn ); | 1309 | file.setName( fn ); |
1310 | mode = SendFile; | 1310 | mode = SendFile; |
1311 | connectToHost( host.toString(), port ); | 1311 | connectToHost( host.toString(), port ); |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | void ServerDTP::sendFile( const QString fn ) | 1314 | void ServerDTP::sendFile( const QString fn ) |
1315 | { | 1315 | { |
1316 | file.setName( fn ); | 1316 | file.setName( fn ); |
1317 | mode = SendFile; | 1317 | mode = SendFile; |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | void ServerDTP::sendGzipFile( const QString &fn, | 1320 | void ServerDTP::sendGzipFile( const QString &fn, |
1321 | const QStringList &archiveTargets, | 1321 | const QStringList &archiveTargets, |
1322 | const QHostAddress& host, Q_UINT16 port ) | 1322 | const QHostAddress& host, Q_UINT16 port ) |
1323 | { | 1323 | { |
1324 | sendGzipFile( fn, archiveTargets ); | 1324 | sendGzipFile( fn, archiveTargets ); |
1325 | connectToHost( host.toString(), port ); | 1325 | connectToHost( host.toString(), port ); |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | void ServerDTP::sendGzipFile( const QString &fn, | 1328 | void ServerDTP::sendGzipFile( const QString &fn, |
1329 | const QStringList &archiveTargets ) | 1329 | const QStringList &archiveTargets ) |
1330 | { | 1330 | { |
1331 | mode = SendGzipFile; | 1331 | mode = SendGzipFile; |
1332 | file.setName( fn ); | 1332 | file.setName( fn ); |
1333 | 1333 | ||
1334 | QStringList args = "tar"; | 1334 | QStringList args = "tar"; |
1335 | args += "-cv"; | 1335 | args += "-cv"; |
1336 | args += archiveTargets; | 1336 | args += archiveTargets; |
1337 | qDebug("sendGzipFile %s", args.join(" ").latin1() ); | 1337 | qDebug("sendGzipFile %s", args.join(" ").latin1() ); |
1338 | createTargzProc->clearArguments( ); | 1338 | createTargzProc->clearArguments( ); |
1339 | *createTargzProc << args; | 1339 | *createTargzProc << args; |
1340 | connect( createTargzProc, | 1340 | connect( createTargzProc, |
1341 | SIGNAL( receivedStdout(OProcess *, char *, int) ), SLOT( gzipTarBlock(OProcess *, char *, int) ) ); | 1341 | SIGNAL( receivedStdout(OProcess*,char*,int) ), SLOT( gzipTarBlock(OProcess*,char*,int) ) ); |
1342 | 1342 | ||
1343 | gzipProc->clearArguments( ); | 1343 | gzipProc->clearArguments( ); |
1344 | *gzipProc << "gzip"; | 1344 | *gzipProc << "gzip"; |
1345 | connect( gzipProc, SIGNAL( receivedStdout(OProcess *, char *, int) ), | 1345 | connect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), |
1346 | SLOT( writeTargzBlock(OProcess *, char *, int) ) ); | 1346 | SLOT( writeTargzBlock(OProcess*,char*,int) ) ); |
1347 | } | 1347 | } |
1348 | 1348 | ||
1349 | void ServerDTP::gunzipDone() | 1349 | void ServerDTP::gunzipDone() |
1350 | { | 1350 | { |
1351 | qDebug("gunzipDone"); | 1351 | qDebug("gunzipDone"); |
1352 | disconnect( gzipProc, SIGNAL( processExited() ), | 1352 | disconnect( gzipProc, SIGNAL( processExited() ), |
1353 | this, SLOT( gunzipDone() ) ); | 1353 | this, SLOT( gunzipDone() ) ); |
1354 | retrieveTargzProc->closeStdin(); | 1354 | retrieveTargzProc->closeStdin(); |
1355 | disconnect( gzipProc, SIGNAL( receivedStdout(OProcess *, char *, int) ), | 1355 | disconnect( gzipProc, SIGNAL( receivedStdout(OProcess*,char*,int) ), |
1356 | this, SLOT( tarExtractBlock(OProcess *, char *, int) ) ); | 1356 | this, SLOT( tarExtractBlock(OProcess*,char*,int) ) ); |
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | void ServerDTP::tarExtractBlock(OProcess *, char *buffer, int buflen) | 1359 | void ServerDTP::tarExtractBlock(OProcess *, char *buffer, int buflen) |
1360 | { | 1360 | { |
1361 | qDebug("tarExtractBlock"); | 1361 | qDebug("tarExtractBlock"); |
1362 | if ( !retrieveTargzProc->isRunning() ) { | 1362 | if ( !retrieveTargzProc->isRunning() ) { |
1363 | qDebug("auto start ungzip proc"); | 1363 | qDebug("auto start ungzip proc"); |
1364 | if ( !retrieveTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdin) ) | 1364 | if ( !retrieveTargzProc->start(OProcess::NotifyOnExit, OProcess::Stdin) ) |
1365 | qWarning(" failed to start tar -x process"); | 1365 | qWarning(" failed to start tar -x process"); |
1366 | } | 1366 | } |
1367 | retrieveTargzProc->writeStdin( buffer, buflen ); | 1367 | retrieveTargzProc->writeStdin( buffer, buflen ); |
1368 | } | 1368 | } |
1369 | 1369 | ||
1370 | 1370 | ||
1371 | void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) | 1371 | void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) |
1372 | { | 1372 | { |
1373 | file.setName( fn ); | 1373 | file.setName( fn ); |
1374 | mode = RetrieveFile; | 1374 | mode = RetrieveFile; |
1375 | connectToHost( host.toString(), port ); | 1375 | connectToHost( host.toString(), port ); |
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | void ServerDTP::retrieveFile( const QString fn ) | 1378 | void ServerDTP::retrieveFile( const QString fn ) |
1379 | { | 1379 | { |
1380 | file.setName( fn ); | 1380 | file.setName( fn ); |
1381 | mode = RetrieveFile; | 1381 | mode = RetrieveFile; |
1382 | } | 1382 | } |
1383 | 1383 | ||
1384 | void ServerDTP::retrieveGzipFile( const QString &fn ) | 1384 | void ServerDTP::retrieveGzipFile( const QString &fn ) |
1385 | { | 1385 | { |
1386 | qDebug("retrieveGzipFile %s", fn.latin1()); | 1386 | qDebug("retrieveGzipFile %s", fn.latin1()); |
1387 | file.setName( fn ); | 1387 | file.setName( fn ); |
1388 | mode = RetrieveGzipFile; | 1388 | mode = RetrieveGzipFile; |
1389 | 1389 | ||
1390 | gzipProc->clearArguments(); | 1390 | gzipProc->clearArguments(); |
1391 | *gzipProc << "gunzip"; | 1391 | *gzipProc << "gunzip"; |
1392 | connect( gzipProc, SIGNAL( readyReadStdout() ), | 1392 | connect( gzipProc, SIGNAL( readyReadStdout() ), |
1393 | SLOT( tarExtractBlock() ) ); | 1393 | SLOT( tarExtractBlock() ) ); |
1394 | connect( gzipProc, SIGNAL( processExited() ), | 1394 | connect( gzipProc, SIGNAL( processExited() ), |
1395 | SLOT( gunzipDone() ) ); | 1395 | SLOT( gunzipDone() ) ); |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | void ServerDTP::retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ) | 1398 | void ServerDTP::retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ) |
1399 | { | 1399 | { |
1400 | retrieveGzipFile( fn ); | 1400 | retrieveGzipFile( fn ); |
1401 | connectToHost( host.toString(), port ); | 1401 | connectToHost( host.toString(), port ); |
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | void ServerDTP::sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port ) | 1404 | void ServerDTP::sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port ) |
1405 | { | 1405 | { |
1406 | buf.setBuffer( array ); | 1406 | buf.setBuffer( array ); |
1407 | mode = SendBuffer; | 1407 | mode = SendBuffer; |
1408 | connectToHost( host.toString(), port ); | 1408 | connectToHost( host.toString(), port ); |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | void ServerDTP::sendByteArray( const QByteArray& array ) | 1411 | void ServerDTP::sendByteArray( const QByteArray& array ) |
1412 | { | 1412 | { |
1413 | buf.setBuffer( array ); | 1413 | buf.setBuffer( array ); |
1414 | mode = SendBuffer; | 1414 | mode = SendBuffer; |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | void ServerDTP::retrieveByteArray( const QHostAddress& host, Q_UINT16 port ) | 1417 | void ServerDTP::retrieveByteArray( const QHostAddress& host, Q_UINT16 port ) |
1418 | { | 1418 | { |
1419 | buf.setBuffer( QByteArray() ); | 1419 | buf.setBuffer( QByteArray() ); |
1420 | mode = RetrieveBuffer; | 1420 | mode = RetrieveBuffer; |
1421 | connectToHost( host.toString(), port ); | 1421 | connectToHost( host.toString(), port ); |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | void ServerDTP::retrieveByteArray() | 1424 | void ServerDTP::retrieveByteArray() |
1425 | { | 1425 | { |
1426 | buf.setBuffer( QByteArray() ); | 1426 | buf.setBuffer( QByteArray() ); |
1427 | mode = RetrieveBuffer; | 1427 | mode = RetrieveBuffer; |
1428 | } | 1428 | } |
1429 | 1429 | ||
1430 | void ServerDTP::setSocket( int socket ) | 1430 | void ServerDTP::setSocket( int socket ) |
1431 | { | 1431 | { |
1432 | QSocket::setSocket( socket ); | 1432 | QSocket::setSocket( socket ); |
1433 | connected(); | 1433 | connected(); |
1434 | } | 1434 | } |
1435 | 1435 | ||
diff --git a/core/settings/button/buttonsettings.cpp b/core/settings/button/buttonsettings.cpp index 141e0f6..d80e496 100644 --- a/core/settings/button/buttonsettings.cpp +++ b/core/settings/button/buttonsettings.cpp | |||
@@ -1,254 +1,254 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | 31 | ||
32 | 32 | ||
33 | #include <opie/odevice.h> | 33 | #include <opie/odevice.h> |
34 | 34 | ||
35 | #include "buttonsettings.h" | 35 | #include "buttonsettings.h" |
36 | #include "buttonutils.h" | 36 | #include "buttonutils.h" |
37 | #include "remapdlg.h" | 37 | #include "remapdlg.h" |
38 | 38 | ||
39 | using namespace Opie; | 39 | using namespace Opie; |
40 | 40 | ||
41 | struct buttoninfo { | 41 | struct buttoninfo { |
42 | const ODeviceButton *m_button; | 42 | const ODeviceButton *m_button; |
43 | int m_index; | 43 | int m_index; |
44 | 44 | ||
45 | OQCopMessage m_pmsg; | 45 | OQCopMessage m_pmsg; |
46 | QLabel *m_picon; | 46 | QLabel *m_picon; |
47 | QLabel *m_plabel; | 47 | QLabel *m_plabel; |
48 | 48 | ||
49 | OQCopMessage m_hmsg; | 49 | OQCopMessage m_hmsg; |
50 | QLabel *m_hicon; | 50 | QLabel *m_hicon; |
51 | QLabel *m_hlabel; | 51 | QLabel *m_hlabel; |
52 | 52 | ||
53 | bool m_pdirty : 1; | 53 | bool m_pdirty : 1; |
54 | bool m_hdirty : 1; | 54 | bool m_hdirty : 1; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | 57 | ||
58 | ButtonSettings::ButtonSettings ( QWidget *parent , const char *name, bool modal, WFlags f ) | 58 | ButtonSettings::ButtonSettings ( QWidget *parent , const char *name, bool modal, WFlags f ) |
59 | : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) | 59 | : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) |
60 | { | 60 | { |
61 | const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); | 61 | const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); |
62 | (void) ButtonUtils::inst ( ); // initialise | 62 | (void) ButtonUtils::inst ( ); // initialise |
63 | 63 | ||
64 | setCaption ( tr( "Button Settings" )); | 64 | setCaption ( tr( "Button Settings" )); |
65 | 65 | ||
66 | QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); | 66 | QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); |
67 | 67 | ||
68 | QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); | 68 | QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); |
69 | toplay-> addWidget ( l ); | 69 | toplay-> addWidget ( l ); |
70 | 70 | ||
71 | QGridLayout *lay = new QGridLayout ( toplay ); | 71 | QGridLayout *lay = new QGridLayout ( toplay ); |
72 | lay-> setMargin ( 0 ); | 72 | lay-> setMargin ( 0 ); |
73 | lay-> setColStretch ( 0, 0 ); | 73 | lay-> setColStretch ( 0, 0 ); |
74 | lay-> setColStretch ( 1, 0 ); | 74 | lay-> setColStretch ( 1, 0 ); |
75 | lay-> setColStretch ( 2, 0 ); | 75 | lay-> setColStretch ( 2, 0 ); |
76 | lay-> setColStretch ( 3, 10 ); | 76 | lay-> setColStretch ( 3, 10 ); |
77 | 77 | ||
78 | m_infos. setAutoDelete ( true ); | 78 | m_infos. setAutoDelete ( true ); |
79 | 79 | ||
80 | int i = 1; | 80 | int i = 1; |
81 | int index = 0; | 81 | int index = 0; |
82 | for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { | 82 | for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { |
83 | if ( it != buttons. begin ( )) { | 83 | if ( it != buttons. begin ( )) { |
84 | QFrame *f = new QFrame ( this ); | 84 | QFrame *f = new QFrame ( this ); |
85 | f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); | 85 | f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); |
86 | lay-> addMultiCellWidget ( f, i, i, 0, 3 ); | 86 | lay-> addMultiCellWidget ( f, i, i, 0, 3 ); |
87 | i++; | 87 | i++; |
88 | } | 88 | } |
89 | 89 | ||
90 | buttoninfo *bi = new buttoninfo ( ); | 90 | buttoninfo *bi = new buttoninfo ( ); |
91 | bi-> m_button = &(*it); | 91 | bi-> m_button = &(*it); |
92 | bi-> m_index = index++; | 92 | bi-> m_index = index++; |
93 | bi-> m_pmsg = (*it). pressedAction ( ); | 93 | bi-> m_pmsg = (*it). pressedAction ( ); |
94 | bi-> m_hmsg = (*it). heldAction ( ); | 94 | bi-> m_hmsg = (*it). heldAction ( ); |
95 | bi-> m_pdirty = false; | 95 | bi-> m_pdirty = false; |
96 | bi-> m_hdirty = false; | 96 | bi-> m_hdirty = false; |
97 | 97 | ||
98 | l = new QLabel ( this ); | 98 | l = new QLabel ( this ); |
99 | l-> setPixmap (( *it ). pixmap ( )); | 99 | l-> setPixmap (( *it ). pixmap ( )); |
100 | 100 | ||
101 | lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); | 101 | lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); |
102 | 102 | ||
103 | l = new QLabel ( tr( "Press:" ), this ); | 103 | l = new QLabel ( tr( "Press:" ), this ); |
104 | lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); | 104 | lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); |
105 | l = new QLabel ( tr( "Hold:" ), this ); | 105 | l = new QLabel ( tr( "Hold:" ), this ); |
106 | lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); | 106 | lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); |
107 | 107 | ||
108 | l = new QLabel ( this ); | 108 | l = new QLabel ( this ); |
109 | l-> setFixedSize ( 16, 16 ); | 109 | l-> setFixedSize ( 16, 16 ); |
110 | lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); | 110 | lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); |
111 | bi-> m_picon = l; | 111 | bi-> m_picon = l; |
112 | 112 | ||
113 | l = new QLabel ( this ); | 113 | l = new QLabel ( this ); |
114 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); | 114 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); |
115 | lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); | 115 | lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); |
116 | bi-> m_plabel = l; | 116 | bi-> m_plabel = l; |
117 | 117 | ||
118 | l = new QLabel ( this ); | 118 | l = new QLabel ( this ); |
119 | l-> setFixedSize ( 16, 16 ); | 119 | l-> setFixedSize ( 16, 16 ); |
120 | lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); | 120 | lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); |
121 | bi-> m_hicon = l; | 121 | bi-> m_hicon = l; |
122 | 122 | ||
123 | l = new QLabel ( this ); | 123 | l = new QLabel ( this ); |
124 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); | 124 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); |
125 | lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); | 125 | lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); |
126 | bi-> m_hlabel = l; | 126 | bi-> m_hlabel = l; |
127 | 127 | ||
128 | i += 2; | 128 | i += 2; |
129 | 129 | ||
130 | m_infos. append ( bi ); | 130 | m_infos. append ( bi ); |
131 | } | 131 | } |
132 | 132 | ||
133 | toplay-> addStretch ( 10 ); | 133 | toplay-> addStretch ( 10 ); |
134 | 134 | ||
135 | m_last_button = 0; | 135 | m_last_button = 0; |
136 | m_lock = false; | 136 | m_lock = false; |
137 | 137 | ||
138 | m_timer = new QTimer ( this ); | 138 | m_timer = new QTimer ( this ); |
139 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( ))); | 139 | connect ( m_timer, SIGNAL( timeout()), this, SLOT( keyTimeout())); |
140 | 140 | ||
141 | updateLabels ( ); | 141 | updateLabels ( ); |
142 | 142 | ||
143 | QPEApplication::grabKeyboard ( ); | 143 | QPEApplication::grabKeyboard ( ); |
144 | } | 144 | } |
145 | 145 | ||
146 | ButtonSettings::~ButtonSettings ( ) | 146 | ButtonSettings::~ButtonSettings ( ) |
147 | { | 147 | { |
148 | QPEApplication::ungrabKeyboard ( ); | 148 | QPEApplication::ungrabKeyboard ( ); |
149 | } | 149 | } |
150 | 150 | ||
151 | void ButtonSettings::updateLabels ( ) | 151 | void ButtonSettings::updateLabels ( ) |
152 | { | 152 | { |
153 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 153 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
154 | qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); | 154 | qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); |
155 | 155 | ||
156 | (*it)-> m_picon-> setPixmap ( cip. m_icon ); | 156 | (*it)-> m_picon-> setPixmap ( cip. m_icon ); |
157 | (*it)-> m_plabel-> setText ( cip. m_name ); | 157 | (*it)-> m_plabel-> setText ( cip. m_name ); |
158 | 158 | ||
159 | qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); | 159 | qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); |
160 | 160 | ||
161 | (*it)-> m_hicon-> setPixmap ( cih. m_icon ); | 161 | (*it)-> m_hicon-> setPixmap ( cih. m_icon ); |
162 | (*it)-> m_hlabel-> setText ( cih. m_name ); | 162 | (*it)-> m_hlabel-> setText ( cih. m_name ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) | 166 | buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) |
167 | { | 167 | { |
168 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 168 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
169 | if ((*it)-> m_button-> keycode ( ) == key ) | 169 | if ((*it)-> m_button-> keycode ( ) == key ) |
170 | return *it; | 170 | return *it; |
171 | } | 171 | } |
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
174 | 174 | ||
175 | void ButtonSettings::keyPressEvent ( QKeyEvent *e ) | 175 | void ButtonSettings::keyPressEvent ( QKeyEvent *e ) |
176 | { | 176 | { |
177 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); | 177 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); |
178 | 178 | ||
179 | if ( bi && !e-> isAutoRepeat ( )) { | 179 | if ( bi && !e-> isAutoRepeat ( )) { |
180 | m_timer-> stop ( ); | 180 | m_timer-> stop ( ); |
181 | m_last_button = bi; | 181 | m_last_button = bi; |
182 | m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); | 182 | m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); |
183 | } | 183 | } |
184 | else | 184 | else |
185 | QDialog::keyPressEvent ( e ); | 185 | QDialog::keyPressEvent ( e ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) | 188 | void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) |
189 | { | 189 | { |
190 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); | 190 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); |
191 | 191 | ||
192 | if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { | 192 | if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { |
193 | m_timer-> stop ( ); | 193 | m_timer-> stop ( ); |
194 | edit ( bi, false ); | 194 | edit ( bi, false ); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | QDialog::keyReleaseEvent ( e ); | 197 | QDialog::keyReleaseEvent ( e ); |
198 | } | 198 | } |
199 | 199 | ||
200 | void ButtonSettings::keyTimeout ( ) | 200 | void ButtonSettings::keyTimeout ( ) |
201 | { | 201 | { |
202 | if ( m_last_button ) { | 202 | if ( m_last_button ) { |
203 | edit ( m_last_button, true ); | 203 | edit ( m_last_button, true ); |
204 | m_last_button = false; | 204 | m_last_button = false; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void ButtonSettings::edit ( buttoninfo *bi, bool hold ) | 208 | void ButtonSettings::edit ( buttoninfo *bi, bool hold ) |
209 | { | 209 | { |
210 | 210 | ||
211 | if ( m_lock ) | 211 | if ( m_lock ) |
212 | return; | 212 | return; |
213 | m_lock = true; | 213 | m_lock = true; |
214 | 214 | ||
215 | RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); | 215 | RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); |
216 | 216 | ||
217 | if ( QPEApplication::execDialog ( d ) == QDialog::Accepted ) { | 217 | if ( QPEApplication::execDialog ( d ) == QDialog::Accepted ) { |
218 | 218 | ||
219 | 219 | ||
220 | if ( hold ) { | 220 | if ( hold ) { |
221 | bi-> m_hmsg = d-> message ( ); | 221 | bi-> m_hmsg = d-> message ( ); |
222 | bi-> m_hdirty = true; | 222 | bi-> m_hdirty = true; |
223 | } | 223 | } |
224 | else { | 224 | else { |
225 | bi-> m_pmsg = d-> message ( ); | 225 | bi-> m_pmsg = d-> message ( ); |
226 | bi-> m_pdirty = true; | 226 | bi-> m_pdirty = true; |
227 | } | 227 | } |
228 | 228 | ||
229 | updateLabels ( ); | 229 | updateLabels ( ); |
230 | } | 230 | } |
231 | 231 | ||
232 | delete d; | 232 | delete d; |
233 | 233 | ||
234 | m_lock = false; | 234 | m_lock = false; |
235 | } | 235 | } |
236 | 236 | ||
237 | void ButtonSettings::accept ( ) | 237 | void ButtonSettings::accept ( ) |
238 | { | 238 | { |
239 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 239 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
240 | buttoninfo *bi = *it; | 240 | buttoninfo *bi = *it; |
241 | 241 | ||
242 | if ( bi-> m_pdirty ) | 242 | if ( bi-> m_pdirty ) |
243 | ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg ); | 243 | ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg ); |
244 | if ( bi-> m_hdirty ) | 244 | if ( bi-> m_hdirty ) |
245 | ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg ); | 245 | ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg ); |
246 | } | 246 | } |
247 | QDialog::accept ( ); | 247 | QDialog::accept ( ); |
248 | } | 248 | } |
249 | 249 | ||
250 | void ButtonSettings::done ( int r ) | 250 | void ButtonSettings::done ( int r ) |
251 | { | 251 | { |
252 | QDialog::done ( r ); | 252 | QDialog::done ( r ); |
253 | close ( ); | 253 | close ( ); |
254 | } | 254 | } |
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp index 7dabe68..121173a 100644 --- a/core/settings/button/remapdlg.cpp +++ b/core/settings/button/remapdlg.cpp | |||
@@ -1,155 +1,155 @@ | |||
1 | #include <qlistview.h> | 1 | #include <qlistview.h> |
2 | #include <qcombobox.h> | 2 | #include <qcombobox.h> |
3 | #include <qtimer.h> | 3 | #include <qtimer.h> |
4 | 4 | ||
5 | #include "remapdlg.h" | 5 | #include "remapdlg.h" |
6 | #include "buttonutils.h" | 6 | #include "buttonutils.h" |
7 | 7 | ||
8 | using namespace Opie; | 8 | using namespace Opie; |
9 | 9 | ||
10 | class NoSortItem : public QListViewItem { | 10 | class NoSortItem : public QListViewItem { |
11 | public: | 11 | public: |
12 | NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) | 12 | NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) |
13 | : QListViewItem ( lv, str, s1, s2 ) | 13 | : QListViewItem ( lv, str, s1, s2 ) |
14 | { | 14 | { |
15 | m_key = QString ( QChar ( 'a' + pos )); | 15 | m_key = QString ( QChar ( 'a' + pos )); |
16 | m_def = false; | 16 | m_def = false; |
17 | } | 17 | } |
18 | 18 | ||
19 | void setDefault ( bool b ) | 19 | void setDefault ( bool b ) |
20 | { | 20 | { |
21 | m_def = b; | 21 | m_def = b; |
22 | } | 22 | } |
23 | 23 | ||
24 | virtual QString key ( int /*column*/, bool /*ascending*/ ) const | 24 | virtual QString key ( int /*column*/, bool /*ascending*/ ) const |
25 | { | 25 | { |
26 | return m_key; | 26 | return m_key; |
27 | } | 27 | } |
28 | 28 | ||
29 | virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) | 29 | virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) |
30 | { | 30 | { |
31 | if ( m_def ) { | 31 | if ( m_def ) { |
32 | QFont f ( listView ( )-> font ( )); | 32 | QFont f ( listView ( )-> font ( )); |
33 | f. setBold ( true ); | 33 | f. setBold ( true ); |
34 | p-> setFont ( f ); | 34 | p-> setFont ( f ); |
35 | } | 35 | } |
36 | QListViewItem::paintCell ( p, cg, column, width, align ); | 36 | QListViewItem::paintCell ( p, cg, column, width, align ); |
37 | } | 37 | } |
38 | 38 | ||
39 | private: | 39 | private: |
40 | QString m_key; | 40 | QString m_key; |
41 | bool m_def; | 41 | bool m_def; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | 44 | ||
45 | RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) | 45 | RemapDlg::RemapDlg ( const Opie::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) |
46 | : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) | 46 | : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) |
47 | { | 47 | { |
48 | setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); | 48 | setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); |
49 | 49 | ||
50 | m_current = 0; | 50 | m_current = 0; |
51 | 51 | ||
52 | static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; | 52 | static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; |
53 | w_channel-> insertStrList ((const char **) def_channels ); | 53 | w_channel-> insertStrList ((const char **) def_channels ); |
54 | 54 | ||
55 | m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); | 55 | m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); |
56 | m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); | 56 | m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); |
57 | 57 | ||
58 | m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); | 58 | m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); |
59 | m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); | 59 | m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); |
60 | ((NoSortItem *) m_map_preset )-> setDefault ( true ); | 60 | ((NoSortItem *) m_map_preset )-> setDefault ( true ); |
61 | 61 | ||
62 | if (m_msg. channel ( ) == "ignore") | 62 | if (m_msg. channel ( ) == "ignore") |
63 | { | 63 | { |
64 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); | 64 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); |
65 | 65 | ||
66 | m_current = m_map_none; | 66 | m_current = m_map_none; |
67 | } | 67 | } |
68 | else | 68 | else |
69 | { | 69 | { |
70 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); | 70 | m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); |
71 | m_current = m_map_custom; | 71 | m_current = m_map_custom; |
72 | } | 72 | } |
73 | 73 | ||
74 | QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); | 74 | QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); |
75 | ButtonUtils::inst ( )-> insertActions ( it ); | 75 | ButtonUtils::inst ( )-> insertActions ( it ); |
76 | it-> setOpen ( true ); | 76 | it-> setOpen ( true ); |
77 | 77 | ||
78 | m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); | 78 | m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); |
79 | 79 | ||
80 | w_list-> setCurrentItem ( m_current ); | 80 | w_list-> setCurrentItem ( m_current ); |
81 | 81 | ||
82 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); | 82 | QTimer::singleShot ( 0, this, SLOT( delayedInit())); |
83 | } | 83 | } |
84 | 84 | ||
85 | RemapDlg::~RemapDlg ( ) | 85 | RemapDlg::~RemapDlg ( ) |
86 | { | 86 | { |
87 | } | 87 | } |
88 | 88 | ||
89 | void RemapDlg::delayedInit ( ) | 89 | void RemapDlg::delayedInit ( ) |
90 | { | 90 | { |
91 | bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); | 91 | bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); |
92 | w_list-> viewport ( )-> setUpdatesEnabled ( false ); | 92 | w_list-> viewport ( )-> setUpdatesEnabled ( false ); |
93 | 93 | ||
94 | ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); | 94 | ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); |
95 | 95 | ||
96 | w_list-> viewport ( )-> setUpdatesEnabled ( b ); | 96 | w_list-> viewport ( )-> setUpdatesEnabled ( b ); |
97 | 97 | ||
98 | m_map_show-> repaint ( ); | 98 | m_map_show-> repaint ( ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void RemapDlg::itemChanged ( QListViewItem *it ) | 101 | void RemapDlg::itemChanged ( QListViewItem *it ) |
102 | { | 102 | { |
103 | bool enabled = false; | 103 | bool enabled = false; |
104 | OQCopMessage m; | 104 | OQCopMessage m; |
105 | 105 | ||
106 | m_current = it; | 106 | m_current = it; |
107 | 107 | ||
108 | if ( it == m_map_none ) | 108 | if ( it == m_map_none ) |
109 | { | 109 | { |
110 | m_msg = m = OQCopMessage ( "ignore", 0 ); | 110 | m_msg = m = OQCopMessage ( "ignore", 0 ); |
111 | qDebug ("***ignoring"); | 111 | qDebug ("***ignoring"); |
112 | } | 112 | } |
113 | else if ( it == m_map_preset ) | 113 | else if ( it == m_map_preset ) |
114 | { | 114 | { |
115 | m_msg = m = m_msg_preset; | 115 | m_msg = m = m_msg_preset; |
116 | qDebug ("***Preset"); | 116 | qDebug ("***Preset"); |
117 | } | 117 | } |
118 | else if ( it && !it-> childCount ( ) ) | 118 | else if ( it && !it-> childCount ( ) ) |
119 | { | 119 | { |
120 | qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); | 120 | qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); |
121 | enabled = ( it == m_map_custom ); | 121 | enabled = ( it == m_map_custom ); |
122 | m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); | 122 | m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); |
123 | } | 123 | } |
124 | 124 | ||
125 | w_channel-> setEnabled ( enabled ); | 125 | w_channel-> setEnabled ( enabled ); |
126 | w_message-> setEnabled ( enabled ); | 126 | w_message-> setEnabled ( enabled ); |
127 | 127 | ||
128 | w_channel-> setEditText ( m. channel ( )); | 128 | w_channel-> setEditText ( m. channel ( )); |
129 | //hack for if user has typed in a message, such as 'suspend()' | 129 | //hack for if user has typed in a message, such as 'suspend()' |
130 | //so raise() is always present | 130 | //so raise() is always present |
131 | if(m. message ( ) != "raise()") | 131 | if(m. message ( ) != "raise()") |
132 | w_message->insertItem("raise()"); | 132 | w_message->insertItem("raise()"); |
133 | w_message-> setEditText ( m. message ( )); | 133 | w_message-> setEditText ( m. message ( )); |
134 | } | 134 | } |
135 | 135 | ||
136 | void RemapDlg::textChanged ( const QString &str ) | 136 | void RemapDlg::textChanged ( const QString &str ) |
137 | { | 137 | { |
138 | if ( !m_current ) | 138 | if ( !m_current ) |
139 | return; | 139 | return; |
140 | 140 | ||
141 | QComboBox *which = (QComboBox *) sender ( ); | 141 | QComboBox *which = (QComboBox *) sender ( ); |
142 | 142 | ||
143 | if ( which == w_channel ) | 143 | if ( which == w_channel ) |
144 | m_current-> setText ( 1, str ); | 144 | m_current-> setText ( 1, str ); |
145 | else if ( which == w_message ) | 145 | else if ( which == w_message ) |
146 | m_current-> setText ( 2, str ); | 146 | m_current-> setText ( 2, str ); |
147 | } | 147 | } |
148 | 148 | ||
149 | OQCopMessage RemapDlg::message ( ) | 149 | OQCopMessage RemapDlg::message ( ) |
150 | { | 150 | { |
151 | //make sure to update message if typed in | 151 | //make sure to update message if typed in |
152 | itemChanged(w_list->currentItem()); | 152 | itemChanged(w_list->currentItem()); |
153 | return m_msg; | 153 | return m_msg; |
154 | } | 154 | } |
155 | 155 | ||
diff --git a/core/settings/citytime/citytime.cpp b/core/settings/citytime/citytime.cpp index e7f0c46..721285d 100644 --- a/core/settings/citytime/citytime.cpp +++ b/core/settings/citytime/citytime.cpp | |||
@@ -1,279 +1,279 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // changes by Maximilian Reiss <harlekin@handhelds.org> | 21 | // changes by Maximilian Reiss <harlekin@handhelds.org> |
22 | 22 | ||
23 | #include "zonemap.h" | 23 | #include "zonemap.h" |
24 | #include "citytime.h" | 24 | #include "citytime.h" |
25 | 25 | ||
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/tzselect.h> | 28 | #include <qpe/tzselect.h> |
29 | #if !defined(QT_NO_COP) | 29 | #if !defined(QT_NO_COP) |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qtoolbutton.h> | 35 | #include <qtoolbutton.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | 37 | ||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | 39 | ||
40 | CityTime::CityTime( QWidget *parent, const char* name, | 40 | CityTime::CityTime( QWidget *parent, const char* name, |
41 | WFlags fl ) | 41 | WFlags fl ) |
42 | : CityTimeBase( parent, name, fl ), | 42 | : CityTimeBase( parent, name, fl ), |
43 | strRealTz(0), | 43 | strRealTz(0), |
44 | bAdded(false) | 44 | bAdded(false) |
45 | { | 45 | { |
46 | Config config( "qpe" ); | 46 | Config config( "qpe" ); |
47 | config.setGroup( "Time" ); | 47 | config.setGroup( "Time" ); |
48 | bWhichClock = config.readBoolEntry( "AMPM", TRUE ); | 48 | bWhichClock = config.readBoolEntry( "AMPM", TRUE ); |
49 | qDebug( QString("%1").arg(bWhichClock) ); | 49 | qDebug( QString("%1").arg(bWhichClock) ); |
50 | frmMap->changeClock( bWhichClock ); | 50 | frmMap->changeClock( bWhichClock ); |
51 | 51 | ||
52 | char *pEnv; | 52 | char *pEnv; |
53 | pEnv = NULL; | 53 | pEnv = NULL; |
54 | pEnv = getenv("TZ"); | 54 | pEnv = getenv("TZ"); |
55 | if ( pEnv ) | 55 | if ( pEnv ) |
56 | strRealTz = pEnv; | 56 | strRealTz = pEnv; |
57 | pEnv = NULL; | 57 | pEnv = NULL; |
58 | pEnv = getenv("HOME"); | 58 | pEnv = getenv("HOME"); |
59 | if ( pEnv ) | 59 | if ( pEnv ) |
60 | strHome = pEnv; | 60 | strHome = pEnv; |
61 | // append the labels to their respective lists... | 61 | // append the labels to their respective lists... |
62 | listCities.setAutoDelete( true ); | 62 | listCities.setAutoDelete( true ); |
63 | listTimes.setAutoDelete( true ); | 63 | listTimes.setAutoDelete( true ); |
64 | 64 | ||
65 | listCities.append( cmdCity1 ); | 65 | listCities.append( cmdCity1 ); |
66 | listCities.append( cmdCity2 ); | 66 | listCities.append( cmdCity2 ); |
67 | listCities.append( cmdCity3 ); | 67 | listCities.append( cmdCity3 ); |
68 | 68 | ||
69 | listTimes.append( lblCTime1 ); | 69 | listTimes.append( lblCTime1 ); |
70 | listTimes.append( lblCTime2 ); | 70 | listTimes.append( lblCTime2 ); |
71 | listTimes.append( lblCTime3 ); | 71 | listTimes.append( lblCTime3 ); |
72 | 72 | ||
73 | 73 | ||
74 | // kludgy way of getting the screen size so we don't have to depend | 74 | // kludgy way of getting the screen size so we don't have to depend |
75 | // on a resize event... | 75 | // on a resize event... |
76 | QWidget *d = QApplication::desktop(); | 76 | QWidget *d = QApplication::desktop(); |
77 | if ( d->width() < d->height() ) { | 77 | if ( d->width() < d->height() ) { |
78 | // append for that 4 down look | 78 | // append for that 4 down look |
79 | listCities.append( cmdCity4 ); | 79 | listCities.append( cmdCity4 ); |
80 | listCities.append( cmdCity5 ); | 80 | listCities.append( cmdCity5 ); |
81 | listCities.append( cmdCity6 ); | 81 | listCities.append( cmdCity6 ); |
82 | listTimes.append( lblCTime4 ); | 82 | listTimes.append( lblCTime4 ); |
83 | listTimes.append( lblCTime5 ); | 83 | listTimes.append( lblCTime5 ); |
84 | listTimes.append( lblCTime6 ); | 84 | listTimes.append( lblCTime6 ); |
85 | lblCTime7->hide(); | 85 | lblCTime7->hide(); |
86 | lblCTime8->hide(); | 86 | lblCTime8->hide(); |
87 | lblCTime9->hide(); | 87 | lblCTime9->hide(); |
88 | cmdCity7->hide(); | 88 | cmdCity7->hide(); |
89 | cmdCity8->hide(); | 89 | cmdCity8->hide(); |
90 | cmdCity9->hide(); | 90 | cmdCity9->hide(); |
91 | } else { | 91 | } else { |
92 | listCities.append( cmdCity7 ); | 92 | listCities.append( cmdCity7 ); |
93 | listCities.append( cmdCity8 ); | 93 | listCities.append( cmdCity8 ); |
94 | listCities.append( cmdCity9 ); | 94 | listCities.append( cmdCity9 ); |
95 | listTimes.append( lblCTime7 ); | 95 | listTimes.append( lblCTime7 ); |
96 | listTimes.append( lblCTime8 ); | 96 | listTimes.append( lblCTime8 ); |
97 | listTimes.append( lblCTime9 ); | 97 | listTimes.append( lblCTime9 ); |
98 | lblCTime4->hide(); | 98 | lblCTime4->hide(); |
99 | lblCTime5->hide(); | 99 | lblCTime5->hide(); |
100 | lblCTime6->hide(); | 100 | lblCTime6->hide(); |
101 | cmdCity4->hide(); | 101 | cmdCity4->hide(); |
102 | cmdCity5->hide(); | 102 | cmdCity5->hide(); |
103 | cmdCity6->hide(); | 103 | cmdCity6->hide(); |
104 | } | 104 | } |
105 | 105 | ||
106 | selWidget = frmMap->selectionWidget( this ); | 106 | selWidget = frmMap->selectionWidget( this ); |
107 | selWidget->hide(); | 107 | selWidget->hide(); |
108 | CityTimeBaseLayout->addWidget( selWidget ); | 108 | CityTimeBaseLayout->addWidget( selWidget ); |
109 | bAdded = true; | 109 | bAdded = true; |
110 | readInTimes(); | 110 | readInTimes(); |
111 | changed = FALSE; | 111 | changed = FALSE; |
112 | QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), | 112 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), |
113 | this, SLOT( changeClock( bool ) ) ); | 113 | this, SLOT( changeClock(bool) ) ); |
114 | // now start the timer so we can update the time quickly every second | 114 | // now start the timer so we can update the time quickly every second |
115 | timerEvent( 0 ); | 115 | timerEvent( 0 ); |
116 | } | 116 | } |
117 | 117 | ||
118 | CityTime::~CityTime() | 118 | CityTime::~CityTime() |
119 | { | 119 | { |
120 | if ( changed ) { | 120 | if ( changed ) { |
121 | Config cfg("CityTime"); | 121 | Config cfg("CityTime"); |
122 | cfg.setGroup("TimeZones"); | 122 | cfg.setGroup("TimeZones"); |
123 | QListIterator<QToolButton> itCity( listCities ); | 123 | QListIterator<QToolButton> itCity( listCities ); |
124 | int i; | 124 | int i; |
125 | bool realTzWritten = FALSE; | 125 | bool realTzWritten = FALSE; |
126 | for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) { | 126 | for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) { |
127 | if ( !strCityTz[i].isNull() ) { | 127 | if ( !strCityTz[i].isNull() ) { |
128 | cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]); | 128 | cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]); |
129 | cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text()); | 129 | cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text()); |
130 | if ( strCityTz[i] == strRealTz ) | 130 | if ( strCityTz[i] == strRealTz ) |
131 | realTzWritten = TRUE; | 131 | realTzWritten = TRUE; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | if ( realTzWritten ) { | 134 | if ( realTzWritten ) { |
135 | cfg.removeEntry("Zone"+QString::number(CITIES)); | 135 | cfg.removeEntry("Zone"+QString::number(CITIES)); |
136 | cfg.removeEntry("ZoneName"+QString::number(CITIES)); | 136 | cfg.removeEntry("ZoneName"+QString::number(CITIES)); |
137 | } else { | 137 | } else { |
138 | cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz); | 138 | cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz); |
139 | if ( nameRealTz.isEmpty() ) { | 139 | if ( nameRealTz.isEmpty() ) { |
140 | int i = strRealTz.find( '/' ); | 140 | int i = strRealTz.find( '/' ); |
141 | nameRealTz = strRealTz.mid( i+1 ); | 141 | nameRealTz = strRealTz.mid( i+1 ); |
142 | } | 142 | } |
143 | cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz); | 143 | cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz); |
144 | } | 144 | } |
145 | QCopEnvelope ( "QPE/System", "timeZoneListChange()" ); | 145 | QCopEnvelope ( "QPE/System", "timeZoneListChange()" ); |
146 | 146 | ||
147 | changed = FALSE; | 147 | changed = FALSE; |
148 | } | 148 | } |
149 | // restore the timezone, just in case we messed with it and | 149 | // restore the timezone, just in case we messed with it and |
150 | // are destroyed at an inoppurtune moment | 150 | // are destroyed at an inoppurtune moment |
151 | if ( !strRealTz.isNull() ) { | 151 | if ( !strRealTz.isNull() ) { |
152 | // this should be checked, but there is not much that can done at this | 152 | // this should be checked, but there is not much that can done at this |
153 | //point if it fails | 153 | //point if it fails |
154 | setenv( "TZ", strRealTz, true ); | 154 | setenv( "TZ", strRealTz, true ); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void CityTime::timerEvent( QTimerEvent *e ) | 158 | void CityTime::timerEvent( QTimerEvent *e ) |
159 | { | 159 | { |
160 | if ( e ) | 160 | if ( e ) |
161 | killTimer( timerId ); | 161 | killTimer( timerId ); |
162 | // change the time again!! | 162 | // change the time again!! |
163 | showTime(); | 163 | showTime(); |
164 | int ms = 1000 - QTime::currentTime().msec(); | 164 | int ms = 1000 - QTime::currentTime().msec(); |
165 | timerId = startTimer( ms ); | 165 | timerId = startTimer( ms ); |
166 | } | 166 | } |
167 | 167 | ||
168 | void CityTime::mousePressEvent( QMouseEvent * ) | 168 | void CityTime::mousePressEvent( QMouseEvent * ) |
169 | { | 169 | { |
170 | // DEBUG enable this to get a look at the zone information DEBUG | 170 | // DEBUG enable this to get a look at the zone information DEBUG |
171 | // frmMap->showZones(); | 171 | // frmMap->showZones(); |
172 | } | 172 | } |
173 | 173 | ||
174 | void CityTime::showTime( void ) | 174 | void CityTime::showTime( void ) |
175 | { | 175 | { |
176 | int i; | 176 | int i; |
177 | QListIterator<QLabel> itTime(listTimes); | 177 | QListIterator<QLabel> itTime(listTimes); |
178 | 178 | ||
179 | // traverse the list... | 179 | // traverse the list... |
180 | for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) { | 180 | for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) { |
181 | if ( !strCityTz[i].isNull() ) { | 181 | if ( !strCityTz[i].isNull() ) { |
182 | if ( setenv( "TZ", strCityTz[i], true ) == 0 ) { | 182 | if ( setenv( "TZ", strCityTz[i], true ) == 0 ) { |
183 | itTime.current()->setText( TimeString::shortTime( bWhichClock ) ); | 183 | itTime.current()->setText( TimeString::shortTime( bWhichClock ) ); |
184 | } else { | 184 | } else { |
185 | QMessageBox::critical( this, tr( "Time Changing" ), | 185 | QMessageBox::critical( this, tr( "Time Changing" ), |
186 | tr( "There was a problem setting timezone %1" ) | 186 | tr( "There was a problem setting timezone %1" ) |
187 | .arg( QString::number( i + 1 ) ) ); | 187 | .arg( QString::number( i + 1 ) ) ); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | } | 190 | } |
191 | // done playing around... put it all back | 191 | // done playing around... put it all back |
192 | unsetenv( "TZ" ); | 192 | unsetenv( "TZ" ); |
193 | if ( !strRealTz.isNull() ) { | 193 | if ( !strRealTz.isNull() ) { |
194 | if ( setenv( "TZ", strRealTz, true ) != 0 ) { | 194 | if ( setenv( "TZ", strRealTz, true ) != 0 ) { |
195 | QMessageBox::critical( this, tr( "Restore Time Zone" ), | 195 | QMessageBox::critical( this, tr( "Restore Time Zone" ), |
196 | tr( "There was a problem setting your timezone." | 196 | tr( "There was a problem setting your timezone." |
197 | "Your time may be wrong now..." ) ); | 197 | "Your time may be wrong now..." ) ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | void CityTime::beginNewTz() | 202 | void CityTime::beginNewTz() |
203 | { | 203 | { |
204 | buttonWidget->hide(); | 204 | buttonWidget->hide(); |
205 | frmMap->setFocus(); | 205 | frmMap->setFocus(); |
206 | selWidget->show(); | 206 | selWidget->show(); |
207 | // CityTimeBaseLayout->addWidget( selWidget ); | 207 | // CityTimeBaseLayout->addWidget( selWidget ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void CityTime::slotNewTz( const QString & strNewCountry, | 210 | void CityTime::slotNewTz( const QString & strNewCountry, |
211 | const QString & strNewCity ) | 211 | const QString & strNewCity ) |
212 | { | 212 | { |
213 | // determine what to do based on what putton is pressed... | 213 | // determine what to do based on what putton is pressed... |
214 | QListIterator<QToolButton> itCity(listCities); | 214 | QListIterator<QToolButton> itCity(listCities); |
215 | int i; | 215 | int i; |
216 | // go through the list and make adjustments based on which button is on | 216 | // go through the list and make adjustments based on which button is on |
217 | for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) { | 217 | for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) { |
218 | QToolButton *cmdTmp = itCity.current(); | 218 | QToolButton *cmdTmp = itCity.current(); |
219 | if ( cmdTmp->isOn() ) { | 219 | if ( cmdTmp->isOn() ) { |
220 | strCityTz[i] = strNewCountry + strNewCity; | 220 | strCityTz[i] = strNewCountry + strNewCity; |
221 | QString s = strNewCity; | 221 | QString s = strNewCity; |
222 | cmdTmp->setText( s.replace( QRegExp("_"), " " ) ); | 222 | cmdTmp->setText( s.replace( QRegExp("_"), " " ) ); |
223 | cmdTmp->toggle(); | 223 | cmdTmp->toggle(); |
224 | // we can actually break, since there is only one button | 224 | // we can actually break, since there is only one button |
225 | // that is ever pressed! | 225 | // that is ever pressed! |
226 | changed = TRUE; | 226 | changed = TRUE; |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | showTime(); | 230 | showTime(); |
231 | buttonWidget->show(); | 231 | buttonWidget->show(); |
232 | selWidget->hide(); | 232 | selWidget->hide(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void CityTime::readInTimes( void ) | 235 | void CityTime::readInTimes( void ) |
236 | { | 236 | { |
237 | Config cfg("CityTime"); | 237 | Config cfg("CityTime"); |
238 | cfg.setGroup("TimeZones"); | 238 | cfg.setGroup("TimeZones"); |
239 | QListIterator<QToolButton> itCity( listCities ); | 239 | QListIterator<QToolButton> itCity( listCities ); |
240 | int i=0; | 240 | int i=0; |
241 | nameRealTz = QString::null; | 241 | nameRealTz = QString::null; |
242 | QString zn; | 242 | QString zn; |
243 | for ( ; i < CITIES ; i++ ) { | 243 | for ( ; i < CITIES ; i++ ) { |
244 | zn = cfg.readEntry("Zone"+QString::number(i), QString::null); | 244 | zn = cfg.readEntry("Zone"+QString::number(i), QString::null); |
245 | if ( zn.isNull() ) | 245 | if ( zn.isNull() ) |
246 | break; | 246 | break; |
247 | QString nm = cfg.readEntry("ZoneName"+QString::number(i)); | 247 | QString nm = cfg.readEntry("ZoneName"+QString::number(i)); |
248 | strCityTz[i] = zn; | 248 | strCityTz[i] = zn; |
249 | itCity.current()->setText(nm); | 249 | itCity.current()->setText(nm); |
250 | if ( zn == strRealTz ) | 250 | if ( zn == strRealTz ) |
251 | nameRealTz = nm; | 251 | nameRealTz = nm; |
252 | ++itCity; | 252 | ++itCity; |
253 | } | 253 | } |
254 | if ( i == 0 ) { | 254 | if ( i == 0 ) { |
255 | // write in our own in a shameless self promotion and some humor | 255 | // write in our own in a shameless self promotion and some humor |
256 | QStringList list = timezoneDefaults(); | 256 | QStringList list = timezoneDefaults(); |
257 | int i; | 257 | int i; |
258 | QStringList::Iterator it = list.begin(); | 258 | QStringList::Iterator it = list.begin(); |
259 | for ( i = 0, itCity.toFirst(); i < CITIES && itCity.current(); | 259 | for ( i = 0, itCity.toFirst(); i < CITIES && itCity.current(); |
260 | i++, ++itCity ) { | 260 | i++, ++itCity ) { |
261 | strCityTz[i] = *it++; | 261 | strCityTz[i] = *it++; |
262 | itCity.current()->setText( *it++ ); | 262 | itCity.current()->setText( *it++ ); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | if ( nameRealTz.isEmpty() ) { | 265 | if ( nameRealTz.isEmpty() ) { |
266 | //remember the current time zone even if we don't have room | 266 | //remember the current time zone even if we don't have room |
267 | //to show it. | 267 | //to show it. |
268 | zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null); | 268 | zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null); |
269 | if ( zn == strRealTz ) | 269 | if ( zn == strRealTz ) |
270 | nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES)); | 270 | nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES)); |
271 | i++; | 271 | i++; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | void CityTime::changeClock( bool newClock ) | 275 | void CityTime::changeClock( bool newClock ) |
276 | { | 276 | { |
277 | bWhichClock = newClock; | 277 | bWhichClock = newClock; |
278 | showTime(); | 278 | showTime(); |
279 | } | 279 | } |
diff --git a/core/settings/citytime/citytimebase.cpp b/core/settings/citytime/citytimebase.cpp index a3483cc..323929b 100644 --- a/core/settings/citytime/citytimebase.cpp +++ b/core/settings/citytime/citytimebase.cpp | |||
@@ -41,371 +41,371 @@ CityTimeBase::CityTimeBase( QWidget* parent, const char* name, WFlags ) | |||
41 | cmdCity7_font.setBold( TRUE ); | 41 | cmdCity7_font.setBold( TRUE ); |
42 | cmdCity7->setFont( cmdCity7_font ); | 42 | cmdCity7->setFont( cmdCity7_font ); |
43 | cmdCity7->setFocusPolicy( QToolButton::TabFocus ); | 43 | cmdCity7->setFocusPolicy( QToolButton::TabFocus ); |
44 | cmdCity7->setText( tr( "" ) ); | 44 | cmdCity7->setText( tr( "" ) ); |
45 | cmdCity7->setToggleButton( TRUE ); | 45 | cmdCity7->setToggleButton( TRUE ); |
46 | cmdCity7->setToggleButton( TRUE ); | 46 | cmdCity7->setToggleButton( TRUE ); |
47 | 47 | ||
48 | Layout2->addWidget( cmdCity7, 0, 2 ); | 48 | Layout2->addWidget( cmdCity7, 0, 2 ); |
49 | 49 | ||
50 | lblCTime9 = new QLabel( buttonWidget, "lblCTime9" ); | 50 | lblCTime9 = new QLabel( buttonWidget, "lblCTime9" ); |
51 | lblCTime9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime9->sizePolicy().hasHeightForWidth() ) ); | 51 | lblCTime9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime9->sizePolicy().hasHeightForWidth() ) ); |
52 | QFont lblCTime9_font( lblCTime9->font() ); | 52 | QFont lblCTime9_font( lblCTime9->font() ); |
53 | lblCTime9_font.setPointSize( 10 ); | 53 | lblCTime9_font.setPointSize( 10 ); |
54 | lblCTime9->setFont( lblCTime9_font ); | 54 | lblCTime9->setFont( lblCTime9_font ); |
55 | lblCTime9->setText( tr( "" ) ); | 55 | lblCTime9->setText( tr( "" ) ); |
56 | lblCTime9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 56 | lblCTime9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
57 | 57 | ||
58 | Layout2->addWidget( lblCTime9, 2, 3 ); | 58 | Layout2->addWidget( lblCTime9, 2, 3 ); |
59 | 59 | ||
60 | cmdCity8 = new QToolButton( buttonWidget, "cmdCity8" ); | 60 | cmdCity8 = new QToolButton( buttonWidget, "cmdCity8" ); |
61 | cmdCity8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity8->sizePolicy().hasHeightForWidth() ) ); | 61 | cmdCity8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity8->sizePolicy().hasHeightForWidth() ) ); |
62 | QFont cmdCity8_font( cmdCity8->font() ); | 62 | QFont cmdCity8_font( cmdCity8->font() ); |
63 | cmdCity8_font.setBold( TRUE ); | 63 | cmdCity8_font.setBold( TRUE ); |
64 | cmdCity8->setFont( cmdCity8_font ); | 64 | cmdCity8->setFont( cmdCity8_font ); |
65 | cmdCity8->setFocusPolicy( QToolButton::TabFocus ); | 65 | cmdCity8->setFocusPolicy( QToolButton::TabFocus ); |
66 | cmdCity8->setText( tr( "" ) ); | 66 | cmdCity8->setText( tr( "" ) ); |
67 | cmdCity8->setToggleButton( TRUE ); | 67 | cmdCity8->setToggleButton( TRUE ); |
68 | cmdCity8->setToggleButton( TRUE ); | 68 | cmdCity8->setToggleButton( TRUE ); |
69 | 69 | ||
70 | Layout2->addWidget( cmdCity8, 1, 2 ); | 70 | Layout2->addWidget( cmdCity8, 1, 2 ); |
71 | 71 | ||
72 | cmdCity2 = new QToolButton( buttonWidget, "cmdCity2" ); | 72 | cmdCity2 = new QToolButton( buttonWidget, "cmdCity2" ); |
73 | QFont cmdCity2_font( cmdCity2->font() ); | 73 | QFont cmdCity2_font( cmdCity2->font() ); |
74 | cmdCity2_font.setBold( TRUE ); | 74 | cmdCity2_font.setBold( TRUE ); |
75 | cmdCity2->setFont( cmdCity2_font ); | 75 | cmdCity2->setFont( cmdCity2_font ); |
76 | cmdCity2->setFocusPolicy( QToolButton::TabFocus ); | 76 | cmdCity2->setFocusPolicy( QToolButton::TabFocus ); |
77 | cmdCity2->setText( tr( "" ) ); | 77 | cmdCity2->setText( tr( "" ) ); |
78 | cmdCity2->setToggleButton( TRUE ); | 78 | cmdCity2->setToggleButton( TRUE ); |
79 | cmdCity2->setToggleButton( TRUE ); | 79 | cmdCity2->setToggleButton( TRUE ); |
80 | 80 | ||
81 | Layout2->addWidget( cmdCity2, 1, 0 ); | 81 | Layout2->addWidget( cmdCity2, 1, 0 ); |
82 | 82 | ||
83 | lblCTime6 = new QLabel( buttonWidget, "lblCTime6" ); | 83 | lblCTime6 = new QLabel( buttonWidget, "lblCTime6" ); |
84 | QFont lblCTime6_font( lblCTime6->font() ); | 84 | QFont lblCTime6_font( lblCTime6->font() ); |
85 | lblCTime6_font.setPointSize( 10 ); | 85 | lblCTime6_font.setPointSize( 10 ); |
86 | lblCTime6->setFont( lblCTime6_font ); | 86 | lblCTime6->setFont( lblCTime6_font ); |
87 | lblCTime6->setText( tr( "" ) ); | 87 | lblCTime6->setText( tr( "" ) ); |
88 | lblCTime6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 88 | lblCTime6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
89 | 89 | ||
90 | Layout2->addWidget( lblCTime6, 5, 1 ); | 90 | Layout2->addWidget( lblCTime6, 5, 1 ); |
91 | 91 | ||
92 | cmdCity6 = new QToolButton( buttonWidget, "cmdCity6" ); | 92 | cmdCity6 = new QToolButton( buttonWidget, "cmdCity6" ); |
93 | cmdCity6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity6->sizePolicy().hasHeightForWidth() ) ); | 93 | cmdCity6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity6->sizePolicy().hasHeightForWidth() ) ); |
94 | QFont cmdCity6_font( cmdCity6->font() ); | 94 | QFont cmdCity6_font( cmdCity6->font() ); |
95 | cmdCity6_font.setBold( TRUE ); | 95 | cmdCity6_font.setBold( TRUE ); |
96 | cmdCity6->setFont( cmdCity6_font ); | 96 | cmdCity6->setFont( cmdCity6_font ); |
97 | cmdCity6->setFocusPolicy( QToolButton::TabFocus ); | 97 | cmdCity6->setFocusPolicy( QToolButton::TabFocus ); |
98 | cmdCity6->setText( tr( "" ) ); | 98 | cmdCity6->setText( tr( "" ) ); |
99 | cmdCity6->setToggleButton( TRUE ); | 99 | cmdCity6->setToggleButton( TRUE ); |
100 | cmdCity6->setToggleButton( TRUE ); | 100 | cmdCity6->setToggleButton( TRUE ); |
101 | 101 | ||
102 | Layout2->addWidget( cmdCity6, 5, 0 ); | 102 | Layout2->addWidget( cmdCity6, 5, 0 ); |
103 | 103 | ||
104 | cmdCity4 = new QToolButton( buttonWidget, "cmdCity4" ); | 104 | cmdCity4 = new QToolButton( buttonWidget, "cmdCity4" ); |
105 | cmdCity4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity4->sizePolicy().hasHeightForWidth() ) ); | 105 | cmdCity4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity4->sizePolicy().hasHeightForWidth() ) ); |
106 | QFont cmdCity4_font( cmdCity4->font() ); | 106 | QFont cmdCity4_font( cmdCity4->font() ); |
107 | cmdCity4_font.setBold( TRUE ); | 107 | cmdCity4_font.setBold( TRUE ); |
108 | cmdCity4->setFont( cmdCity4_font ); | 108 | cmdCity4->setFont( cmdCity4_font ); |
109 | cmdCity4->setFocusPolicy( QToolButton::TabFocus ); | 109 | cmdCity4->setFocusPolicy( QToolButton::TabFocus ); |
110 | cmdCity4->setText( tr( "" ) ); | 110 | cmdCity4->setText( tr( "" ) ); |
111 | cmdCity4->setToggleButton( TRUE ); | 111 | cmdCity4->setToggleButton( TRUE ); |
112 | cmdCity4->setToggleButton( TRUE ); | 112 | cmdCity4->setToggleButton( TRUE ); |
113 | 113 | ||
114 | Layout2->addWidget( cmdCity4, 3, 0 ); | 114 | Layout2->addWidget( cmdCity4, 3, 0 ); |
115 | 115 | ||
116 | lblCTime5 = new QLabel( buttonWidget, "lblCTime5" ); | 116 | lblCTime5 = new QLabel( buttonWidget, "lblCTime5" ); |
117 | QFont lblCTime5_font( lblCTime5->font() ); | 117 | QFont lblCTime5_font( lblCTime5->font() ); |
118 | lblCTime5_font.setPointSize( 10 ); | 118 | lblCTime5_font.setPointSize( 10 ); |
119 | lblCTime5->setFont( lblCTime5_font ); | 119 | lblCTime5->setFont( lblCTime5_font ); |
120 | lblCTime5->setText( tr( "" ) ); | 120 | lblCTime5->setText( tr( "" ) ); |
121 | lblCTime5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 121 | lblCTime5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
122 | 122 | ||
123 | Layout2->addWidget( lblCTime5, 4, 1 ); | 123 | Layout2->addWidget( lblCTime5, 4, 1 ); |
124 | 124 | ||
125 | lblCTime2 = new QLabel( buttonWidget, "lblCTime2" ); | 125 | lblCTime2 = new QLabel( buttonWidget, "lblCTime2" ); |
126 | lblCTime2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime2->sizePolicy().hasHeightForWidth() ) ); | 126 | lblCTime2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime2->sizePolicy().hasHeightForWidth() ) ); |
127 | QFont lblCTime2_font( lblCTime2->font() ); | 127 | QFont lblCTime2_font( lblCTime2->font() ); |
128 | lblCTime2_font.setPointSize( 10 ); | 128 | lblCTime2_font.setPointSize( 10 ); |
129 | lblCTime2->setFont( lblCTime2_font ); | 129 | lblCTime2->setFont( lblCTime2_font ); |
130 | lblCTime2->setText( tr( "" ) ); | 130 | lblCTime2->setText( tr( "" ) ); |
131 | lblCTime2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 131 | lblCTime2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
132 | 132 | ||
133 | Layout2->addWidget( lblCTime2, 1, 1 ); | 133 | Layout2->addWidget( lblCTime2, 1, 1 ); |
134 | 134 | ||
135 | lblCTime1 = new QLabel( buttonWidget, "lblCTime1" ); | 135 | lblCTime1 = new QLabel( buttonWidget, "lblCTime1" ); |
136 | lblCTime1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime1->sizePolicy().hasHeightForWidth() ) ); | 136 | lblCTime1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime1->sizePolicy().hasHeightForWidth() ) ); |
137 | QFont lblCTime1_font( lblCTime1->font() ); | 137 | QFont lblCTime1_font( lblCTime1->font() ); |
138 | lblCTime1_font.setPointSize( 10 ); | 138 | lblCTime1_font.setPointSize( 10 ); |
139 | lblCTime1->setFont( lblCTime1_font ); | 139 | lblCTime1->setFont( lblCTime1_font ); |
140 | lblCTime1->setText( tr( "" ) ); | 140 | lblCTime1->setText( tr( "" ) ); |
141 | lblCTime1->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 141 | lblCTime1->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
142 | 142 | ||
143 | Layout2->addWidget( lblCTime1, 0, 1 ); | 143 | Layout2->addWidget( lblCTime1, 0, 1 ); |
144 | 144 | ||
145 | cmdCity3 = new QToolButton( buttonWidget, "cmdCity3" ); | 145 | cmdCity3 = new QToolButton( buttonWidget, "cmdCity3" ); |
146 | cmdCity3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity3->sizePolicy().hasHeightForWidth() ) ); | 146 | cmdCity3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity3->sizePolicy().hasHeightForWidth() ) ); |
147 | QFont cmdCity3_font( cmdCity3->font() ); | 147 | QFont cmdCity3_font( cmdCity3->font() ); |
148 | cmdCity3_font.setBold( TRUE ); | 148 | cmdCity3_font.setBold( TRUE ); |
149 | cmdCity3->setFont( cmdCity3_font ); | 149 | cmdCity3->setFont( cmdCity3_font ); |
150 | cmdCity3->setFocusPolicy( QToolButton::TabFocus ); | 150 | cmdCity3->setFocusPolicy( QToolButton::TabFocus ); |
151 | cmdCity3->setText( tr( "" ) ); | 151 | cmdCity3->setText( tr( "" ) ); |
152 | cmdCity3->setToggleButton( TRUE ); | 152 | cmdCity3->setToggleButton( TRUE ); |
153 | cmdCity3->setToggleButton( TRUE ); | 153 | cmdCity3->setToggleButton( TRUE ); |
154 | 154 | ||
155 | Layout2->addWidget( cmdCity3, 2, 0 ); | 155 | Layout2->addWidget( cmdCity3, 2, 0 ); |
156 | 156 | ||
157 | lblCTime8 = new QLabel( buttonWidget, "lblCTime8" ); | 157 | lblCTime8 = new QLabel( buttonWidget, "lblCTime8" ); |
158 | lblCTime8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime8->sizePolicy().hasHeightForWidth() ) ); | 158 | lblCTime8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime8->sizePolicy().hasHeightForWidth() ) ); |
159 | QFont lblCTime8_font( lblCTime8->font() ); | 159 | QFont lblCTime8_font( lblCTime8->font() ); |
160 | lblCTime8_font.setPointSize( 10 ); | 160 | lblCTime8_font.setPointSize( 10 ); |
161 | lblCTime8->setFont( lblCTime8_font ); | 161 | lblCTime8->setFont( lblCTime8_font ); |
162 | lblCTime8->setText( tr( "" ) ); | 162 | lblCTime8->setText( tr( "" ) ); |
163 | lblCTime8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 163 | lblCTime8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
164 | 164 | ||
165 | Layout2->addWidget( lblCTime8, 1, 3 ); | 165 | Layout2->addWidget( lblCTime8, 1, 3 ); |
166 | 166 | ||
167 | cmdCity1 = new QToolButton( buttonWidget, "cmdCity1" ); | 167 | cmdCity1 = new QToolButton( buttonWidget, "cmdCity1" ); |
168 | cmdCity1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity1->sizePolicy().hasHeightForWidth() ) ); | 168 | cmdCity1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity1->sizePolicy().hasHeightForWidth() ) ); |
169 | QFont cmdCity1_font( cmdCity1->font() ); | 169 | QFont cmdCity1_font( cmdCity1->font() ); |
170 | cmdCity1_font.setBold( TRUE ); | 170 | cmdCity1_font.setBold( TRUE ); |
171 | cmdCity1->setFont( cmdCity1_font ); | 171 | cmdCity1->setFont( cmdCity1_font ); |
172 | cmdCity1->setFocusPolicy( QToolButton::TabFocus ); | 172 | cmdCity1->setFocusPolicy( QToolButton::TabFocus ); |
173 | cmdCity1->setText( tr( "" ) ); | 173 | cmdCity1->setText( tr( "" ) ); |
174 | cmdCity1->setToggleButton( TRUE ); | 174 | cmdCity1->setToggleButton( TRUE ); |
175 | cmdCity1->setToggleButton( TRUE ); | 175 | cmdCity1->setToggleButton( TRUE ); |
176 | 176 | ||
177 | Layout2->addWidget( cmdCity1, 0, 0 ); | 177 | Layout2->addWidget( cmdCity1, 0, 0 ); |
178 | 178 | ||
179 | lblCTime7 = new QLabel( buttonWidget, "lblCTime7" ); | 179 | lblCTime7 = new QLabel( buttonWidget, "lblCTime7" ); |
180 | lblCTime7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime7->sizePolicy().hasHeightForWidth() ) ); | 180 | lblCTime7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime7->sizePolicy().hasHeightForWidth() ) ); |
181 | QFont lblCTime7_font( lblCTime7->font() ); | 181 | QFont lblCTime7_font( lblCTime7->font() ); |
182 | lblCTime7_font.setPointSize( 10 ); | 182 | lblCTime7_font.setPointSize( 10 ); |
183 | lblCTime7->setFont( lblCTime7_font ); | 183 | lblCTime7->setFont( lblCTime7_font ); |
184 | lblCTime7->setText( tr( "" ) ); | 184 | lblCTime7->setText( tr( "" ) ); |
185 | lblCTime7->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 185 | lblCTime7->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
186 | 186 | ||
187 | Layout2->addWidget( lblCTime7, 0, 3 ); | 187 | Layout2->addWidget( lblCTime7, 0, 3 ); |
188 | 188 | ||
189 | lblCTime4 = new QLabel( buttonWidget, "lblCTime4" ); | 189 | lblCTime4 = new QLabel( buttonWidget, "lblCTime4" ); |
190 | QFont lblCTime4_font( lblCTime4->font() ); | 190 | QFont lblCTime4_font( lblCTime4->font() ); |
191 | lblCTime4_font.setPointSize( 10 ); | 191 | lblCTime4_font.setPointSize( 10 ); |
192 | lblCTime4->setFont( lblCTime4_font ); | 192 | lblCTime4->setFont( lblCTime4_font ); |
193 | lblCTime4->setText( tr( "" ) ); | 193 | lblCTime4->setText( tr( "" ) ); |
194 | lblCTime4->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 194 | lblCTime4->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
195 | 195 | ||
196 | Layout2->addWidget( lblCTime4, 3, 1 ); | 196 | Layout2->addWidget( lblCTime4, 3, 1 ); |
197 | 197 | ||
198 | cmdCity5 = new QToolButton( buttonWidget, "cmdCity5" ); | 198 | cmdCity5 = new QToolButton( buttonWidget, "cmdCity5" ); |
199 | cmdCity5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity5->sizePolicy().hasHeightForWidth() ) ); | 199 | cmdCity5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity5->sizePolicy().hasHeightForWidth() ) ); |
200 | QFont cmdCity5_font( cmdCity5->font() ); | 200 | QFont cmdCity5_font( cmdCity5->font() ); |
201 | cmdCity5_font.setBold( TRUE ); | 201 | cmdCity5_font.setBold( TRUE ); |
202 | cmdCity5->setFont( cmdCity5_font ); | 202 | cmdCity5->setFont( cmdCity5_font ); |
203 | cmdCity5->setFocusPolicy( QToolButton::TabFocus ); | 203 | cmdCity5->setFocusPolicy( QToolButton::TabFocus ); |
204 | cmdCity5->setText( tr( "" ) ); | 204 | cmdCity5->setText( tr( "" ) ); |
205 | cmdCity5->setToggleButton( TRUE ); | 205 | cmdCity5->setToggleButton( TRUE ); |
206 | cmdCity5->setToggleButton( TRUE ); | 206 | cmdCity5->setToggleButton( TRUE ); |
207 | 207 | ||
208 | Layout2->addWidget( cmdCity5, 4, 0 ); | 208 | Layout2->addWidget( cmdCity5, 4, 0 ); |
209 | 209 | ||
210 | lblCTime3 = new QLabel( buttonWidget, "lblCTime3" ); | 210 | lblCTime3 = new QLabel( buttonWidget, "lblCTime3" ); |
211 | QFont lblCTime3_font( lblCTime3->font() ); | 211 | QFont lblCTime3_font( lblCTime3->font() ); |
212 | lblCTime3_font.setPointSize( 10 ); | 212 | lblCTime3_font.setPointSize( 10 ); |
213 | lblCTime3->setFont( lblCTime3_font ); | 213 | lblCTime3->setFont( lblCTime3_font ); |
214 | lblCTime3->setText( tr( "" ) ); | 214 | lblCTime3->setText( tr( "" ) ); |
215 | lblCTime3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 215 | lblCTime3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
216 | 216 | ||
217 | Layout2->addWidget( lblCTime3, 2, 1 ); | 217 | Layout2->addWidget( lblCTime3, 2, 1 ); |
218 | 218 | ||
219 | cmdCity9 = new QToolButton( buttonWidget, "cmdCity9" ); | 219 | cmdCity9 = new QToolButton( buttonWidget, "cmdCity9" ); |
220 | cmdCity9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity9->sizePolicy().hasHeightForWidth() ) ); | 220 | cmdCity9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity9->sizePolicy().hasHeightForWidth() ) ); |
221 | QFont cmdCity9_font( cmdCity9->font() ); | 221 | QFont cmdCity9_font( cmdCity9->font() ); |
222 | cmdCity9_font.setBold( TRUE ); | 222 | cmdCity9_font.setBold( TRUE ); |
223 | cmdCity9->setFont( cmdCity9_font ); | 223 | cmdCity9->setFont( cmdCity9_font ); |
224 | cmdCity9->setFocusPolicy( QToolButton::TabFocus ); | 224 | cmdCity9->setFocusPolicy( QToolButton::TabFocus ); |
225 | cmdCity9->setText( tr( "" ) ); | 225 | cmdCity9->setText( tr( "" ) ); |
226 | cmdCity9->setToggleButton( TRUE ); | 226 | cmdCity9->setToggleButton( TRUE ); |
227 | cmdCity9->setToggleButton( TRUE ); | 227 | cmdCity9->setToggleButton( TRUE ); |
228 | 228 | ||
229 | Layout2->addWidget( cmdCity9, 2, 2 ); | 229 | Layout2->addWidget( cmdCity9, 2, 2 ); |
230 | CityTimeBaseLayout->addWidget( buttonWidget ); | 230 | CityTimeBaseLayout->addWidget( buttonWidget ); |
231 | 231 | ||
232 | // signals and slots connections | 232 | // signals and slots connections |
233 | connect( frmMap, SIGNAL( signalTz(const QString &, const QString &) ), this, SLOT( slotNewTz(const QString &, const QString &) ) ); | 233 | connect( frmMap, SIGNAL( signalTz(const QString&,const QString&) ), this, SLOT( slotNewTz(const QString&,const QString&) ) ); |
234 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 234 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
235 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 235 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
236 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 236 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
237 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 237 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
238 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 238 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
239 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 239 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
240 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 240 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
241 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 241 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
242 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 242 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
243 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 243 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
244 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 244 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
245 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 245 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
246 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 246 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
247 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 247 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
248 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 248 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
249 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 249 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
250 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 250 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
251 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 251 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
252 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 252 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
253 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 253 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
254 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 254 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
255 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 255 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
256 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 256 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
257 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 257 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
258 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 258 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
259 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 259 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
260 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 260 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
261 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 261 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
262 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 262 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
263 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 263 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
264 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 264 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
265 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 265 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
266 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 266 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
267 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 267 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
268 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 268 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
269 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 269 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
270 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 270 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
271 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 271 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
272 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 272 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
273 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 273 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
274 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 274 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
275 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 275 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
276 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 276 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
277 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 277 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
278 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 278 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
279 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 279 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
280 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 280 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
281 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 281 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
282 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 282 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
283 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 283 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
284 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 284 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
285 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 285 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
286 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 286 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
287 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 287 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
288 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 288 | connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
289 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 289 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
290 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 290 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
291 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); | 291 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); |
292 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); | 292 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); |
293 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); | 293 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); |
294 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); | 294 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); |
295 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); | 295 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); |
296 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); | 296 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); |
297 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); | 297 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); |
298 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 298 | connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
299 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 299 | connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
300 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 300 | connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
301 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 301 | connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
302 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 302 | connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
303 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 303 | connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
304 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); | 304 | connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); |
305 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); | 305 | connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); |
306 | connect( cmdCity1, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 306 | connect( cmdCity1, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
307 | connect( cmdCity2, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 307 | connect( cmdCity2, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
308 | connect( cmdCity7, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 308 | connect( cmdCity7, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
309 | connect( cmdCity3, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 309 | connect( cmdCity3, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
310 | connect( cmdCity4, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 310 | connect( cmdCity4, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
311 | connect( cmdCity5, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 311 | connect( cmdCity5, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
312 | connect( cmdCity6, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 312 | connect( cmdCity6, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
313 | connect( cmdCity8, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 313 | connect( cmdCity8, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
314 | connect( cmdCity9, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); | 314 | connect( cmdCity9, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); |
315 | 315 | ||
316 | // tab order | 316 | // tab order |
317 | setTabOrder( cmdCity1, cmdCity2 ); | 317 | setTabOrder( cmdCity1, cmdCity2 ); |
318 | setTabOrder( cmdCity2, cmdCity3 ); | 318 | setTabOrder( cmdCity2, cmdCity3 ); |
319 | setTabOrder( cmdCity3, cmdCity4 ); | 319 | setTabOrder( cmdCity3, cmdCity4 ); |
320 | setTabOrder( cmdCity4, cmdCity5 ); | 320 | setTabOrder( cmdCity4, cmdCity5 ); |
321 | setTabOrder( cmdCity5, cmdCity6 ); | 321 | setTabOrder( cmdCity5, cmdCity6 ); |
322 | setTabOrder( cmdCity6, cmdCity7 ); | 322 | setTabOrder( cmdCity6, cmdCity7 ); |
323 | setTabOrder( cmdCity7, cmdCity8 ); | 323 | setTabOrder( cmdCity7, cmdCity8 ); |
324 | setTabOrder( cmdCity8, cmdCity9 ); | 324 | setTabOrder( cmdCity8, cmdCity9 ); |
325 | setTabOrder( cmdCity9, frmMap ); | 325 | setTabOrder( cmdCity9, frmMap ); |
326 | } | 326 | } |
327 | 327 | ||
328 | /* | 328 | /* |
329 | * Destroys the object and frees any allocated resources | 329 | * Destroys the object and frees any allocated resources |
330 | */ | 330 | */ |
331 | CityTimeBase::~CityTimeBase() | 331 | CityTimeBase::~CityTimeBase() |
332 | { | 332 | { |
333 | // no need to delete child widgets, Qt does it all for us | 333 | // no need to delete child widgets, Qt does it all for us |
334 | } | 334 | } |
335 | 335 | ||
336 | /* | 336 | /* |
337 | * Main event handler. Reimplemented to handle application | 337 | * Main event handler. Reimplemented to handle application |
338 | * font changes | 338 | * font changes |
339 | */ | 339 | */ |
340 | bool CityTimeBase::event( QEvent* ev ) | 340 | bool CityTimeBase::event( QEvent* ev ) |
341 | { | 341 | { |
342 | bool ret = QWidget::event( ev ); | 342 | bool ret = QWidget::event( ev ); |
343 | if ( ev->type() == QEvent::ApplicationFontChange ) { | 343 | if ( ev->type() == QEvent::ApplicationFontChange ) { |
344 | QFont cmdCity7_font( cmdCity7->font() ); | 344 | QFont cmdCity7_font( cmdCity7->font() ); |
345 | cmdCity7_font.setBold( TRUE ); | 345 | cmdCity7_font.setBold( TRUE ); |
346 | cmdCity7->setFont( cmdCity7_font ); | 346 | cmdCity7->setFont( cmdCity7_font ); |
347 | QFont lblCTime9_font( lblCTime9->font() ); | 347 | QFont lblCTime9_font( lblCTime9->font() ); |
348 | lblCTime9_font.setPointSize( 10 ); | 348 | lblCTime9_font.setPointSize( 10 ); |
349 | lblCTime9->setFont( lblCTime9_font ); | 349 | lblCTime9->setFont( lblCTime9_font ); |
350 | QFont cmdCity8_font( cmdCity8->font() ); | 350 | QFont cmdCity8_font( cmdCity8->font() ); |
351 | cmdCity8_font.setBold( TRUE ); | 351 | cmdCity8_font.setBold( TRUE ); |
352 | cmdCity8->setFont( cmdCity8_font ); | 352 | cmdCity8->setFont( cmdCity8_font ); |
353 | QFont cmdCity2_font( cmdCity2->font() ); | 353 | QFont cmdCity2_font( cmdCity2->font() ); |
354 | cmdCity2_font.setBold( TRUE ); | 354 | cmdCity2_font.setBold( TRUE ); |
355 | cmdCity2->setFont( cmdCity2_font ); | 355 | cmdCity2->setFont( cmdCity2_font ); |
356 | QFont lblCTime6_font( lblCTime6->font() ); | 356 | QFont lblCTime6_font( lblCTime6->font() ); |
357 | lblCTime6_font.setPointSize( 10 ); | 357 | lblCTime6_font.setPointSize( 10 ); |
358 | lblCTime6->setFont( lblCTime6_font ); | 358 | lblCTime6->setFont( lblCTime6_font ); |
359 | QFont cmdCity6_font( cmdCity6->font() ); | 359 | QFont cmdCity6_font( cmdCity6->font() ); |
360 | cmdCity6_font.setBold( TRUE ); | 360 | cmdCity6_font.setBold( TRUE ); |
361 | cmdCity6->setFont( cmdCity6_font ); | 361 | cmdCity6->setFont( cmdCity6_font ); |
362 | QFont cmdCity4_font( cmdCity4->font() ); | 362 | QFont cmdCity4_font( cmdCity4->font() ); |
363 | cmdCity4_font.setBold( TRUE ); | 363 | cmdCity4_font.setBold( TRUE ); |
364 | cmdCity4->setFont( cmdCity4_font ); | 364 | cmdCity4->setFont( cmdCity4_font ); |
365 | QFont lblCTime5_font( lblCTime5->font() ); | 365 | QFont lblCTime5_font( lblCTime5->font() ); |
366 | lblCTime5_font.setPointSize( 10 ); | 366 | lblCTime5_font.setPointSize( 10 ); |
367 | lblCTime5->setFont( lblCTime5_font ); | 367 | lblCTime5->setFont( lblCTime5_font ); |
368 | QFont lblCTime2_font( lblCTime2->font() ); | 368 | QFont lblCTime2_font( lblCTime2->font() ); |
369 | lblCTime2_font.setPointSize( 10 ); | 369 | lblCTime2_font.setPointSize( 10 ); |
370 | lblCTime2->setFont( lblCTime2_font ); | 370 | lblCTime2->setFont( lblCTime2_font ); |
371 | QFont lblCTime1_font( lblCTime1->font() ); | 371 | QFont lblCTime1_font( lblCTime1->font() ); |
372 | lblCTime1_font.setPointSize( 10 ); | 372 | lblCTime1_font.setPointSize( 10 ); |
373 | lblCTime1->setFont( lblCTime1_font ); | 373 | lblCTime1->setFont( lblCTime1_font ); |
374 | QFont cmdCity3_font( cmdCity3->font() ); | 374 | QFont cmdCity3_font( cmdCity3->font() ); |
375 | cmdCity3_font.setBold( TRUE ); | 375 | cmdCity3_font.setBold( TRUE ); |
376 | cmdCity3->setFont( cmdCity3_font ); | 376 | cmdCity3->setFont( cmdCity3_font ); |
377 | QFont lblCTime8_font( lblCTime8->font() ); | 377 | QFont lblCTime8_font( lblCTime8->font() ); |
378 | lblCTime8_font.setPointSize( 10 ); | 378 | lblCTime8_font.setPointSize( 10 ); |
379 | lblCTime8->setFont( lblCTime8_font ); | 379 | lblCTime8->setFont( lblCTime8_font ); |
380 | QFont cmdCity1_font( cmdCity1->font() ); | 380 | QFont cmdCity1_font( cmdCity1->font() ); |
381 | cmdCity1_font.setBold( TRUE ); | 381 | cmdCity1_font.setBold( TRUE ); |
382 | cmdCity1->setFont( cmdCity1_font ); | 382 | cmdCity1->setFont( cmdCity1_font ); |
383 | QFont lblCTime7_font( lblCTime7->font() ); | 383 | QFont lblCTime7_font( lblCTime7->font() ); |
384 | lblCTime7_font.setPointSize( 10 ); | 384 | lblCTime7_font.setPointSize( 10 ); |
385 | lblCTime7->setFont( lblCTime7_font ); | 385 | lblCTime7->setFont( lblCTime7_font ); |
386 | QFont lblCTime4_font( lblCTime4->font() ); | 386 | QFont lblCTime4_font( lblCTime4->font() ); |
387 | lblCTime4_font.setPointSize( 10 ); | 387 | lblCTime4_font.setPointSize( 10 ); |
388 | lblCTime4->setFont( lblCTime4_font ); | 388 | lblCTime4->setFont( lblCTime4_font ); |
389 | QFont cmdCity5_font( cmdCity5->font() ); | 389 | QFont cmdCity5_font( cmdCity5->font() ); |
390 | cmdCity5_font.setBold( TRUE ); | 390 | cmdCity5_font.setBold( TRUE ); |
391 | cmdCity5->setFont( cmdCity5_font ); | 391 | cmdCity5->setFont( cmdCity5_font ); |
392 | QFont lblCTime3_font( lblCTime3->font() ); | 392 | QFont lblCTime3_font( lblCTime3->font() ); |
393 | lblCTime3_font.setPointSize( 10 ); | 393 | lblCTime3_font.setPointSize( 10 ); |
394 | lblCTime3->setFont( lblCTime3_font ); | 394 | lblCTime3->setFont( lblCTime3_font ); |
395 | QFont cmdCity9_font( cmdCity9->font() ); | 395 | QFont cmdCity9_font( cmdCity9->font() ); |
396 | cmdCity9_font.setBold( TRUE ); | 396 | cmdCity9_font.setBold( TRUE ); |
397 | cmdCity9->setFont( cmdCity9_font ); | 397 | cmdCity9->setFont( cmdCity9_font ); |
398 | } | 398 | } |
399 | return ret; | 399 | return ret; |
400 | } | 400 | } |
401 | 401 | ||
402 | void CityTimeBase::beginNewTz() | 402 | void CityTimeBase::beginNewTz() |
403 | { | 403 | { |
404 | qWarning( "CityTimeBase::beginNewTz(): Not implemented yet!" ); | 404 | qWarning( "CityTimeBase::beginNewTz(): Not implemented yet!" ); |
405 | } | 405 | } |
406 | 406 | ||
407 | void CityTimeBase::slotNewTz(const QString &, const QString &) | 407 | void CityTimeBase::slotNewTz(const QString &, const QString &) |
408 | { | 408 | { |
409 | qWarning( "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" ); | 409 | qWarning( "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" ); |
410 | } | 410 | } |
411 | 411 | ||
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp index b83da59..b6843d2 100644 --- a/core/settings/citytime/zonemap.cpp +++ b/core/settings/citytime/zonemap.cpp | |||
@@ -1,697 +1,697 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // changes by Maximilian Reiss <harlekin@handhelds.org> | 21 | // changes by Maximilian Reiss <harlekin@handhelds.org> |
22 | 22 | ||
23 | #include "sun.h" | 23 | #include "sun.h" |
24 | #include "zonemap.h" | 24 | #include "zonemap.h" |
25 | 25 | ||
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qhbox.h> | 36 | #include <qhbox.h> |
37 | #include <qlistview.h> | 37 | #include <qlistview.h> |
38 | #include <qwhatsthis.h> | 38 | #include <qwhatsthis.h> |
39 | 39 | ||
40 | #include <limits.h> | 40 | #include <limits.h> |
41 | 41 | ||
42 | // the map file... | 42 | // the map file... |
43 | static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab"; | 43 | static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab"; |
44 | static const char strMAP[] = "citytime/simple_grid_400"; | 44 | static const char strMAP[] = "citytime/simple_grid_400"; |
45 | 45 | ||
46 | // the maximum distance we'll allow the pointer to be away from a city | 46 | // the maximum distance we'll allow the pointer to be away from a city |
47 | // and still show the city's time | 47 | // and still show the city's time |
48 | static const int iTHRESHOLD = 50000; | 48 | static const int iTHRESHOLD = 50000; |
49 | 49 | ||
50 | // The label offset (how far away from pointer) | 50 | // The label offset (how far away from pointer) |
51 | static const int iLABELOFFSET = 8; | 51 | static const int iLABELOFFSET = 8; |
52 | 52 | ||
53 | // the size of the dot to draw, and where to start it | 53 | // the size of the dot to draw, and where to start it |
54 | static const int iCITYSIZE = 3; | 54 | static const int iCITYSIZE = 3; |
55 | const int iCITYOFFSET = 2; | 55 | const int iCITYOFFSET = 2; |
56 | 56 | ||
57 | // the darkening function | 57 | // the darkening function |
58 | static inline void darken( QImage *pImage, int start, int stop, int row ); | 58 | static inline void darken( QImage *pImage, int start, int stop, int row ); |
59 | static void dayNight( QImage *pImage ); | 59 | static void dayNight( QImage *pImage ); |
60 | 60 | ||
61 | ZoneField::ZoneField( const QString& strLine ) | 61 | ZoneField::ZoneField( const QString& strLine ) |
62 | { | 62 | { |
63 | // make a bunch of RegExp's to match the data from the line | 63 | // make a bunch of RegExp's to match the data from the line |
64 | QRegExp regCoord( "[-+][0-9]+" );// the latitude | 64 | QRegExp regCoord( "[-+][0-9]+" );// the latitude |
65 | QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) | 65 | QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) |
66 | QRegExp regCity( "[A-Za-z_-]*" ); // the city | 66 | QRegExp regCity( "[A-Za-z_-]*" ); // the city |
67 | 67 | ||
68 | int iStart, | 68 | int iStart, |
69 | iStop, | 69 | iStop, |
70 | iLen, | 70 | iLen, |
71 | tmp; | 71 | tmp; |
72 | QString strTmp; | 72 | QString strTmp; |
73 | // we should be able to assume that the country code is always the first | 73 | // we should be able to assume that the country code is always the first |
74 | // two chars, so just grap them and let it go... | 74 | // two chars, so just grap them and let it go... |
75 | strCountryCode = strLine.left( 2 ); | 75 | strCountryCode = strLine.left( 2 ); |
76 | iStart = regCoord.match( strLine, 0, &iLen ); | 76 | iStart = regCoord.match( strLine, 0, &iLen ); |
77 | if ( iStart >= 0 ) { | 77 | if ( iStart >= 0 ) { |
78 | strTmp = strLine.mid( iStart, iLen ); | 78 | strTmp = strLine.mid( iStart, iLen ); |
79 | tmp = strTmp.toInt(); | 79 | tmp = strTmp.toInt(); |
80 | // okay, there are two versions of the format, make a decision based on | 80 | // okay, there are two versions of the format, make a decision based on |
81 | // the size... | 81 | // the size... |
82 | // Oh BTW, we are storing everything in seconds! | 82 | // Oh BTW, we are storing everything in seconds! |
83 | if ( iLen < 7 ) { | 83 | if ( iLen < 7 ) { |
84 | _y = tmp / 100; | 84 | _y = tmp / 100; |
85 | _y *= 60; | 85 | _y *= 60; |
86 | _y += tmp % 100; | 86 | _y += tmp % 100; |
87 | _y *= 60; | 87 | _y *= 60; |
88 | } else { | 88 | } else { |
89 | _y = tmp / 10000; | 89 | _y = tmp / 10000; |
90 | _y *= 60; | 90 | _y *= 60; |
91 | tmp %= 10000; | 91 | tmp %= 10000; |
92 | _y += tmp / 100; | 92 | _y += tmp / 100; |
93 | _y *= 60; | 93 | _y *= 60; |
94 | tmp %= 100; | 94 | tmp %= 100; |
95 | _y += tmp; | 95 | _y += tmp; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | iStart = regCoord.match( strLine, iStart + iLen, &iLen ); | 98 | iStart = regCoord.match( strLine, iStart + iLen, &iLen ); |
99 | if ( iStart >= 0 ) { | 99 | if ( iStart >= 0 ) { |
100 | strTmp = strLine.mid( iStart, iLen ); | 100 | strTmp = strLine.mid( iStart, iLen ); |
101 | tmp = strTmp.toInt(); | 101 | tmp = strTmp.toInt(); |
102 | if ( iLen < 8 ) { | 102 | if ( iLen < 8 ) { |
103 | _x = tmp / 100; | 103 | _x = tmp / 100; |
104 | _x *= 60; | 104 | _x *= 60; |
105 | _x += tmp % 100; | 105 | _x += tmp % 100; |
106 | _x *= 60; | 106 | _x *= 60; |
107 | } else { | 107 | } else { |
108 | _x = tmp / 10000; | 108 | _x = tmp / 10000; |
109 | _x *= 60; | 109 | _x *= 60; |
110 | tmp %= 10000; | 110 | tmp %= 10000; |
111 | _x += tmp / 100; | 111 | _x += tmp / 100; |
112 | _x *= 60; | 112 | _x *= 60; |
113 | tmp %= 100; | 113 | tmp %= 100; |
114 | _x += tmp; | 114 | _x += tmp; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | iStart = regCountry.match( strLine, 0, &iLen ); | 117 | iStart = regCountry.match( strLine, 0, &iLen ); |
118 | // help with the shortcoming in 2.x regexp... | 118 | // help with the shortcoming in 2.x regexp... |
119 | iStop = strLine.findRev( '/' ); | 119 | iStop = strLine.findRev( '/' ); |
120 | if ( iStart >= 0 ) { | 120 | if ( iStart >= 0 ) { |
121 | iLen = (iStop - iStart) + 1; | 121 | iLen = (iStop - iStart) + 1; |
122 | strCountry = strLine.mid( iStart, iLen ); | 122 | strCountry = strLine.mid( iStart, iLen ); |
123 | } | 123 | } |
124 | // now match the city... | 124 | // now match the city... |
125 | iStart = regCity.match( strLine, iStart + iLen, &iLen ); | 125 | iStart = regCity.match( strLine, iStart + iLen, &iLen ); |
126 | if ( iStart >= 0 ) { | 126 | if ( iStart >= 0 ) { |
127 | strCity = strLine.mid( iStart, iLen ); | 127 | strCity = strLine.mid( iStart, iLen ); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | void ZoneField::showStructure( void ) const | 131 | void ZoneField::showStructure( void ) const |
132 | { | 132 | { |
133 | qDebug( "Country: %s", strCountry.latin1() ); | 133 | qDebug( "Country: %s", strCountry.latin1() ); |
134 | qDebug( "City: %s", strCity.latin1() ); | 134 | qDebug( "City: %s", strCity.latin1() ); |
135 | qDebug( "x: %d", _x ); | 135 | qDebug( "x: %d", _x ); |
136 | qDebug( "y: %d\n", _y ); | 136 | qDebug( "y: %d\n", _y ); |
137 | } | 137 | } |
138 | 138 | ||
139 | ZoneMap::ZoneMap( QWidget *parent, const char* name ) | 139 | ZoneMap::ZoneMap( QWidget *parent, const char* name ) |
140 | : QScrollView( parent, name ), | 140 | : QScrollView( parent, name ), |
141 | pLast( 0 ), | 141 | pLast( 0 ), |
142 | pRepaint( 0 ), | 142 | pRepaint( 0 ), |
143 | ox( 0 ), | 143 | ox( 0 ), |
144 | oy( 0 ), | 144 | oy( 0 ), |
145 | drawableW( -1 ), | 145 | drawableW( -1 ), |
146 | drawableH( -1 ), | 146 | drawableH( -1 ), |
147 | bZoom( FALSE ), | 147 | bZoom( FALSE ), |
148 | bIllum( TRUE ), | 148 | bIllum( TRUE ), |
149 | cursor( 0 ) | 149 | cursor( 0 ) |
150 | { | 150 | { |
151 | viewport()->setFocusPolicy( StrongFocus ); | 151 | viewport()->setFocusPolicy( StrongFocus ); |
152 | 152 | ||
153 | // set mouse tracking so we can use the mouse move event | 153 | // set mouse tracking so we can use the mouse move event |
154 | zones.setAutoDelete( true ); | 154 | zones.setAutoDelete( true ); |
155 | // get the map loaded | 155 | // get the map loaded |
156 | // just set the current image to point | 156 | // just set the current image to point |
157 | pixCurr = new QPixmap(); | 157 | pixCurr = new QPixmap(); |
158 | 158 | ||
159 | QPixmap pixZoom = Resource::loadPixmap( "mag" ); | 159 | QPixmap pixZoom = Resource::loadPixmap( "mag" ); |
160 | 160 | ||
161 | cmdZoom = new QToolButton( this, "Zoom command" ); | 161 | cmdZoom = new QToolButton( this, "Zoom command" ); |
162 | cmdZoom->setPixmap( pixZoom ); | 162 | cmdZoom->setPixmap( pixZoom ); |
163 | cmdZoom->setToggleButton( true ); | 163 | cmdZoom->setToggleButton( true ); |
164 | 164 | ||
165 | cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, | 165 | cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, |
166 | (QSizePolicy::SizeType)0, | 166 | (QSizePolicy::SizeType)0, |
167 | cmdZoom->sizePolicy().hasHeightForWidth() ) ); | 167 | cmdZoom->sizePolicy().hasHeightForWidth() ) ); |
168 | cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); | 168 | cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); |
169 | // probably don't need this, but just in case... | 169 | // probably don't need this, but just in case... |
170 | cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); | 170 | cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); |
171 | 171 | ||
172 | 172 | ||
173 | lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); | 173 | lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); |
174 | lblCity->setMinimumSize( lblCity->sizeHint() ); | 174 | lblCity->setMinimumSize( lblCity->sizeHint() ); |
175 | lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); | 175 | lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); |
176 | lblCity->setBackgroundColor( yellow ); | 176 | lblCity->setBackgroundColor( yellow ); |
177 | lblCity->hide(); | 177 | lblCity->hide(); |
178 | 178 | ||
179 | // A timer to make sure the label gets hidden | 179 | // A timer to make sure the label gets hidden |
180 | tHide = new QTimer( this, "Label Timer" ); | 180 | tHide = new QTimer( this, "Label Timer" ); |
181 | QObject::connect( tHide, SIGNAL( timeout() ), | 181 | QObject::connect( tHide, SIGNAL( timeout() ), |
182 | lblCity, SLOT( hide() ) ); | 182 | lblCity, SLOT( hide() ) ); |
183 | QObject::connect( tHide, SIGNAL( timeout() ), | 183 | QObject::connect( tHide, SIGNAL( timeout() ), |
184 | this, SLOT( slotRedraw() ) ); | 184 | this, SLOT( slotRedraw() ) ); |
185 | QTimer *tUpdate = new QTimer( this, "Update Timer" ); | 185 | QTimer *tUpdate = new QTimer( this, "Update Timer" ); |
186 | QObject::connect( tUpdate, SIGNAL( timeout() ), | 186 | QObject::connect( tUpdate, SIGNAL( timeout() ), |
187 | this, SLOT( slotUpdate() ) ); | 187 | this, SLOT( slotUpdate() ) ); |
188 | QObject::connect( qApp, SIGNAL( timeChanged() ), | 188 | QObject::connect( qApp, SIGNAL( timeChanged() ), |
189 | this, SLOT( slotUpdate() ) ); | 189 | this, SLOT( slotUpdate() ) ); |
190 | QObject::connect( cmdZoom, SIGNAL( toggled( bool ) ), | 190 | QObject::connect( cmdZoom, SIGNAL( toggled(bool) ), |
191 | this, SLOT( slotZoom( bool ) ) ); | 191 | this, SLOT( slotZoom(bool) ) ); |
192 | QObject::connect( &norm, SIGNAL( signalNewPoint( const QPoint& ) ), | 192 | QObject::connect( &norm, SIGNAL( signalNewPoint(const QPoint&) ), |
193 | this, SLOT( slotFindCity( const QPoint& ) ) ); | 193 | this, SLOT( slotFindCity(const QPoint&) ) ); |
194 | QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), | 194 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), |
195 | this, SLOT( changeClock( bool ) ) ); | 195 | this, SLOT( changeClock(bool) ) ); |
196 | // update the sun's movement every 5 minutes | 196 | // update the sun's movement every 5 minutes |
197 | tUpdate->start( 5 * 60 * 1000 ); | 197 | tUpdate->start( 5 * 60 * 1000 ); |
198 | // May as well read in the timezone information too... | 198 | // May as well read in the timezone information too... |
199 | readZones(); | 199 | readZones(); |
200 | } | 200 | } |
201 | 201 | ||
202 | ZoneMap::~ZoneMap() | 202 | ZoneMap::~ZoneMap() |
203 | { | 203 | { |
204 | } | 204 | } |
205 | 205 | ||
206 | void ZoneMap::readZones( void ) | 206 | void ZoneMap::readZones( void ) |
207 | { | 207 | { |
208 | QFile fZone( strZONEINFO ); | 208 | QFile fZone( strZONEINFO ); |
209 | if ( !fZone.open( IO_ReadOnly ) ) { | 209 | if ( !fZone.open( IO_ReadOnly ) ) { |
210 | QMessageBox::warning (this, | 210 | QMessageBox::warning (this, |
211 | tr( "Unable to Find Timezone Info" ), | 211 | tr( "Unable to Find Timezone Info" ), |
212 | tr( "<p>Unable to find any timezone information in %1" ) | 212 | tr( "<p>Unable to find any timezone information in %1" ) |
213 | .arg( strZONEINFO )); | 213 | .arg( strZONEINFO )); |
214 | exit(-1); | 214 | exit(-1); |
215 | } else { | 215 | } else { |
216 | QTextStream tZone( &fZone ); | 216 | QTextStream tZone( &fZone ); |
217 | while ( !tZone.atEnd() ) { | 217 | while ( !tZone.atEnd() ) { |
218 | QString strLine = tZone.readLine(); | 218 | QString strLine = tZone.readLine(); |
219 | // only pass on lines that aren't comments | 219 | // only pass on lines that aren't comments |
220 | if ( strLine[0] != '#' ) { | 220 | if ( strLine[0] != '#' ) { |
221 | zones.append( new ZoneField( strLine ) ); | 221 | zones.append( new ZoneField( strLine ) ); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | fZone.close(); | 224 | fZone.close(); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) | 228 | void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) |
229 | { | 229 | { |
230 | // add the mouse event into the normalizer, and get the average, | 230 | // add the mouse event into the normalizer, and get the average, |
231 | // pass it along | 231 | // pass it along |
232 | slotRedraw(); | 232 | slotRedraw(); |
233 | norm.start(); | 233 | norm.start(); |
234 | norm.addEvent( event->pos() ); | 234 | norm.addEvent( event->pos() ); |
235 | } | 235 | } |
236 | 236 | ||
237 | void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event ) | 237 | void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event ) |
238 | { | 238 | { |
239 | norm.addEvent( event->pos() ); | 239 | norm.addEvent( event->pos() ); |
240 | } | 240 | } |
241 | 241 | ||
242 | void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* ) | 242 | void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* ) |
243 | { | 243 | { |
244 | // get the averaged points in case a timeout hasn't occurred, | 244 | // get the averaged points in case a timeout hasn't occurred, |
245 | // more for "mouse clicks" | 245 | // more for "mouse clicks" |
246 | norm.stop(); | 246 | norm.stop(); |
247 | if ( pLast != NULL ) { | 247 | if ( pLast != NULL ) { |
248 | emit signalTz( pLast->country(), pLast->city() ); | 248 | emit signalTz( pLast->country(), pLast->city() ); |
249 | pLast = NULL; | 249 | pLast = NULL; |
250 | } | 250 | } |
251 | tHide->start( 2000, true ); | 251 | tHide->start( 2000, true ); |
252 | } | 252 | } |
253 | 253 | ||
254 | void ZoneMap::keyPressEvent( QKeyEvent *ke ) | 254 | void ZoneMap::keyPressEvent( QKeyEvent *ke ) |
255 | { | 255 | { |
256 | switch ( ke->key() ) { | 256 | switch ( ke->key() ) { |
257 | case Key_Left: | 257 | case Key_Left: |
258 | case Key_Right: | 258 | case Key_Right: |
259 | case Key_Up: | 259 | case Key_Up: |
260 | case Key_Down: { | 260 | case Key_Down: { |
261 | tHide->stop(); | 261 | tHide->stop(); |
262 | if ( !cursor ) | 262 | if ( !cursor ) |
263 | slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 ); | 263 | slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 ); |
264 | ZoneField *city = findCityNear( cursor, ke->key() ); | 264 | ZoneField *city = findCityNear( cursor, ke->key() ); |
265 | if ( city ) { | 265 | if ( city ) { |
266 | cursor = city; | 266 | cursor = city; |
267 | int tmpx, tmpy; | 267 | int tmpx, tmpy; |
268 | zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy ); | 268 | zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy ); |
269 | ensureVisible( tmpx, tmpy ); | 269 | ensureVisible( tmpx, tmpy ); |
270 | showCity( cursor ); | 270 | showCity( cursor ); |
271 | tHide->start( 3000, true ); | 271 | tHide->start( 3000, true ); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | break; | 274 | break; |
275 | 275 | ||
276 | case Key_Space: | 276 | case Key_Space: |
277 | case Key_Enter: | 277 | case Key_Enter: |
278 | case Key_Return: | 278 | case Key_Return: |
279 | if ( cursor ) { | 279 | if ( cursor ) { |
280 | emit signalTz( cursor->country(), cursor->city() ); | 280 | emit signalTz( cursor->country(), cursor->city() ); |
281 | tHide->start( 0, true ); | 281 | tHide->start( 0, true ); |
282 | } | 282 | } |
283 | break; | 283 | break; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | ZoneField *ZoneMap::findCityNear( ZoneField *city, int key ) | 287 | ZoneField *ZoneMap::findCityNear( ZoneField *city, int key ) |
288 | { | 288 | { |
289 | ZoneField *pZone; | 289 | ZoneField *pZone; |
290 | ZoneField *pClosest = 0; | 290 | ZoneField *pClosest = 0; |
291 | long ddist = LONG_MAX; | 291 | long ddist = LONG_MAX; |
292 | 292 | ||
293 | QListIterator<ZoneField> it( zones ); | 293 | QListIterator<ZoneField> it( zones ); |
294 | for (; it.current(); ++it) { | 294 | for (; it.current(); ++it) { |
295 | pZone = it.current(); | 295 | pZone = it.current(); |
296 | long dx = (pZone->x() - city->x())/100; | 296 | long dx = (pZone->x() - city->x())/100; |
297 | long dy = (pZone->y() - city->y())/100; | 297 | long dy = (pZone->y() - city->y())/100; |
298 | switch ( key ) { | 298 | switch ( key ) { |
299 | case Key_Right: | 299 | case Key_Right: |
300 | case Key_Left: | 300 | case Key_Left: |
301 | if ( key == Key_Left ) | 301 | if ( key == Key_Left ) |
302 | dx = -dx; | 302 | dx = -dx; |
303 | if ( dx > 0 ) { | 303 | if ( dx > 0 ) { |
304 | long dist = QABS(dy)*4 + dx; | 304 | long dist = QABS(dy)*4 + dx; |
305 | if ( dist < ddist ) { | 305 | if ( dist < ddist ) { |
306 | ddist = dist; | 306 | ddist = dist; |
307 | pClosest = pZone; | 307 | pClosest = pZone; |
308 | } | 308 | } |
309 | } | 309 | } |
310 | break; | 310 | break; |
311 | case Key_Down: | 311 | case Key_Down: |
312 | case Key_Up: | 312 | case Key_Up: |
313 | if ( key == Key_Down ) | 313 | if ( key == Key_Down ) |
314 | dy = -dy; | 314 | dy = -dy; |
315 | if ( dy > 0 ) { | 315 | if ( dy > 0 ) { |
316 | long dist = QABS(dx)*4 + dy; | 316 | long dist = QABS(dx)*4 + dy; |
317 | if ( dist < ddist ) { | 317 | if ( dist < ddist ) { |
318 | ddist = dist; | 318 | ddist = dist; |
319 | pClosest = pZone; | 319 | pClosest = pZone; |
320 | } | 320 | } |
321 | } | 321 | } |
322 | break; | 322 | break; |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | return pClosest; | 326 | return pClosest; |
327 | } | 327 | } |
328 | 328 | ||
329 | void ZoneMap::slotFindCity( const QPoint &pos ) | 329 | void ZoneMap::slotFindCity( const QPoint &pos ) |
330 | { | 330 | { |
331 | lblCity->hide(); | 331 | lblCity->hide(); |
332 | // given coordinates on the screen find the closest city and display the | 332 | // given coordinates on the screen find the closest city and display the |
333 | // label close to it | 333 | // label close to it |
334 | int tmpx, tmpy, x, y; | 334 | int tmpx, tmpy, x, y; |
335 | long lDistance, | 335 | long lDistance, |
336 | lClosest; | 336 | lClosest; |
337 | ZoneField *pZone, | 337 | ZoneField *pZone, |
338 | *pClosest; | 338 | *pClosest; |
339 | 339 | ||
340 | if ( tHide->isActive() ) { | 340 | if ( tHide->isActive() ) { |
341 | tHide->stop(); | 341 | tHide->stop(); |
342 | } | 342 | } |
343 | viewportToContents(pos.x(), pos.y(), tmpx, tmpy); | 343 | viewportToContents(pos.x(), pos.y(), tmpx, tmpy); |
344 | winToZone( tmpx, tmpy, x, y ); | 344 | winToZone( tmpx, tmpy, x, y ); |
345 | // Find city alogorithim: start out at an (near) infinite distance away and | 345 | // Find city alogorithim: start out at an (near) infinite distance away and |
346 | // then find the closest city, (similar to the Z-buffer technique, I guess) | 346 | // then find the closest city, (similar to the Z-buffer technique, I guess) |
347 | // the only problem is that this is all done with doubles, but I don't know | 347 | // the only problem is that this is all done with doubles, but I don't know |
348 | // another way to do it at the moment. Another problem is a linked list is | 348 | // another way to do it at the moment. Another problem is a linked list is |
349 | // used obviously something indexed would help | 349 | // used obviously something indexed would help |
350 | QListIterator<ZoneField> it( zones ); | 350 | QListIterator<ZoneField> it( zones ); |
351 | pClosest = 0; | 351 | pClosest = 0; |
352 | lClosest = LONG_MAX; | 352 | lClosest = LONG_MAX; |
353 | for (; it.current(); ++it) { | 353 | for (; it.current(); ++it) { |
354 | pZone = it.current(); | 354 | pZone = it.current(); |
355 | // use the manhattenLength, a good enough of an appoximation here | 355 | // use the manhattenLength, a good enough of an appoximation here |
356 | lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() ); | 356 | lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() ); |
357 | // first to zero wins! | 357 | // first to zero wins! |
358 | if ( lDistance < lClosest ) { | 358 | if ( lDistance < lClosest ) { |
359 | lClosest = lDistance; | 359 | lClosest = lDistance; |
360 | pClosest = pZone; | 360 | pClosest = pZone; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | // Okay, we found the closest city, but it might still be too far away. | 364 | // Okay, we found the closest city, but it might still be too far away. |
365 | if ( lClosest <= iTHRESHOLD ) { | 365 | if ( lClosest <= iTHRESHOLD ) { |
366 | showCity( pClosest ); | 366 | showCity( pClosest ); |
367 | cursor = pClosest; | 367 | cursor = pClosest; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | void ZoneMap::showCity( ZoneField *city ) | 371 | void ZoneMap::showCity( ZoneField *city ) |
372 | { | 372 | { |
373 | pLast = city; | 373 | pLast = city; |
374 | // we'll use city and country a couple of times, get them to save some | 374 | // we'll use city and country a couple of times, get them to save some |
375 | // time | 375 | // time |
376 | QString strCity = pLast->city(); | 376 | QString strCity = pLast->city(); |
377 | QString strCountry = pLast->country(); | 377 | QString strCountry = pLast->country(); |
378 | // Display the time at this location by setting the environment timezone | 378 | // Display the time at this location by setting the environment timezone |
379 | // getting the current time [there] and then swapping back the variable | 379 | // getting the current time [there] and then swapping back the variable |
380 | // so no one notices... | 380 | // so no one notices... |
381 | QString strSave; | 381 | QString strSave; |
382 | char *p = getenv( "TZ" ); | 382 | char *p = getenv( "TZ" ); |
383 | if ( p ) { | 383 | if ( p ) { |
384 | strSave = p; | 384 | strSave = p; |
385 | } | 385 | } |
386 | // set the timezone :) | 386 | // set the timezone :) |
387 | setenv( "TZ", strCountry + strCity, true ); | 387 | setenv( "TZ", strCountry + strCity, true ); |
388 | lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" + | 388 | lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" + |
389 | TimeString::shortTime( ampm ) ); | 389 | TimeString::shortTime( ampm ) ); |
390 | lblCity->setMinimumSize( lblCity->sizeHint() ); | 390 | lblCity->setMinimumSize( lblCity->sizeHint() ); |
391 | // undue our damage... | 391 | // undue our damage... |
392 | unsetenv( "TZ" ); | 392 | unsetenv( "TZ" ); |
393 | if ( p ) | 393 | if ( p ) |
394 | setenv( "TZ", strSave, true ); | 394 | setenv( "TZ", strSave, true ); |
395 | // Now decide where to move the label, x & y can be reused | 395 | // Now decide where to move the label, x & y can be reused |
396 | int tmpx, tmpy, x, y; | 396 | int tmpx, tmpy, x, y; |
397 | zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy ); | 397 | zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy ); |
398 | contentsToViewport(tmpx, tmpy, x, y); | 398 | contentsToViewport(tmpx, tmpy, x, y); |
399 | if ( lblCity->width() > drawableW - x ) { | 399 | if ( lblCity->width() > drawableW - x ) { |
400 | // oops... try putting it on the right | 400 | // oops... try putting it on the right |
401 | x = x - lblCity->width() - iLABELOFFSET; | 401 | x = x - lblCity->width() - iLABELOFFSET; |
402 | } else { | 402 | } else { |
403 | // the default... | 403 | // the default... |
404 | x += iLABELOFFSET; | 404 | x += iLABELOFFSET; |
405 | } | 405 | } |
406 | if ( lblCity->height() > drawableH - y ) { | 406 | if ( lblCity->height() > drawableH - y ) { |
407 | // move it up... | 407 | // move it up... |
408 | y = y - lblCity->height() - iLABELOFFSET; | 408 | y = y - lblCity->height() - iLABELOFFSET; |
409 | } else if ( y < 0 ) { | 409 | } else if ( y < 0 ) { |
410 | // the city is actually off the screen... | 410 | // the city is actually off the screen... |
411 | // this only happens on the a zoom when you are near the top, | 411 | // this only happens on the a zoom when you are near the top, |
412 | // a quick workaround.. | 412 | // a quick workaround.. |
413 | y = iLABELOFFSET; | 413 | y = iLABELOFFSET; |
414 | } else { | 414 | } else { |
415 | // the default | 415 | // the default |
416 | y += iLABELOFFSET; | 416 | y += iLABELOFFSET; |
417 | } | 417 | } |
418 | 418 | ||
419 | // draw in the city and the label | 419 | // draw in the city and the label |
420 | if ( pRepaint ) { | 420 | if ( pRepaint ) { |
421 | int repx, | 421 | int repx, |
422 | repy; | 422 | repy; |
423 | zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); | 423 | zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); |
424 | updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, | 424 | updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, |
425 | iCITYSIZE, iCITYSIZE ); | 425 | iCITYSIZE, iCITYSIZE ); |
426 | } | 426 | } |
427 | updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, | 427 | updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, |
428 | iCITYSIZE ); | 428 | iCITYSIZE ); |
429 | pRepaint = pLast; | 429 | pRepaint = pLast; |
430 | 430 | ||
431 | lblCity->move( x, y ); | 431 | lblCity->move( x, y ); |
432 | lblCity->show(); | 432 | lblCity->show(); |
433 | } | 433 | } |
434 | 434 | ||
435 | void ZoneMap::resizeEvent( QResizeEvent *e ) | 435 | void ZoneMap::resizeEvent( QResizeEvent *e ) |
436 | { | 436 | { |
437 | // keep the zoom button down in the corner | 437 | // keep the zoom button down in the corner |
438 | QSize _size = e->size(); | 438 | QSize _size = e->size(); |
439 | cmdZoom->move( _size.width() - cmdZoom->width(), | 439 | cmdZoom->move( _size.width() - cmdZoom->width(), |
440 | _size.height() - cmdZoom->height() ); | 440 | _size.height() - cmdZoom->height() ); |
441 | if ( !bZoom ) { | 441 | if ( !bZoom ) { |
442 | drawableW = width() - 2 * frameWidth(); | 442 | drawableW = width() - 2 * frameWidth(); |
443 | drawableH = height() - 2 * frameWidth(); | 443 | drawableH = height() - 2 * frameWidth(); |
444 | makeMap( drawableW, drawableH ); | 444 | makeMap( drawableW, drawableH ); |
445 | resizeContents( drawableW, drawableH ); | 445 | resizeContents( drawableW, drawableH ); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | void ZoneMap::showZones( void ) const | 449 | void ZoneMap::showZones( void ) const |
450 | { | 450 | { |
451 | // go through the zones in the list and just display the values... | 451 | // go through the zones in the list and just display the values... |
452 | QListIterator<ZoneField> itZone( zones ); | 452 | QListIterator<ZoneField> itZone( zones ); |
453 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | 453 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { |
454 | ZoneField *pZone = itZone.current(); | 454 | ZoneField *pZone = itZone.current(); |
455 | pZone->showStructure(); | 455 | pZone->showStructure(); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | QWidget* ZoneMap::selectionWidget( QWidget *parent) { | 460 | QWidget* ZoneMap::selectionWidget( QWidget *parent) { |
461 | 461 | ||
462 | QWidget *returnWidget = new QWidget( parent ); | 462 | QWidget *returnWidget = new QWidget( parent ); |
463 | 463 | ||
464 | QVBoxLayout *layout = new QVBoxLayout( returnWidget ); | 464 | QVBoxLayout *layout = new QVBoxLayout( returnWidget ); |
465 | QHBox *hBox = new QHBox( returnWidget ); | 465 | QHBox *hBox = new QHBox( returnWidget ); |
466 | QListView *continentView = new QListView( hBox ); | 466 | QListView *continentView = new QListView( hBox ); |
467 | continentView->addColumn( tr("Continent") ); | 467 | continentView->addColumn( tr("Continent") ); |
468 | QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); | 468 | QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); |
469 | connect ( continentView, SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( slotGetCities( QListViewItem * ) ) ); | 469 | connect ( continentView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotGetCities(QListViewItem*) ) ); |
470 | 470 | ||
471 | QStringList continentList; | 471 | QStringList continentList; |
472 | QListIterator<ZoneField> itZone( zones ); | 472 | QListIterator<ZoneField> itZone( zones ); |
473 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | 473 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { |
474 | ZoneField *pZone = itZone.current(); | 474 | ZoneField *pZone = itZone.current(); |
475 | if ( continentList.contains( pZone->country() ) == 0 ) { | 475 | if ( continentList.contains( pZone->country() ) == 0 ) { |
476 | QString name; | 476 | QString name; |
477 | QListViewItem *item; | 477 | QListViewItem *item; |
478 | if ( !(pZone->country().length() > 24) ) { | 478 | if ( !(pZone->country().length() > 24) ) { |
479 | name = pZone->country().left(pZone->country().length()-1 ); | 479 | name = pZone->country().left(pZone->country().length()-1 ); |
480 | } else { | 480 | } else { |
481 | name = pZone->country().left( 24 ); | 481 | name = pZone->country().left( 24 ); |
482 | } | 482 | } |
483 | item = new QListViewItem( continentView, name, pZone->country() ); | 483 | item = new QListViewItem( continentView, name, pZone->country() ); |
484 | continentList.append( pZone->country() ); | 484 | continentList.append( pZone->country() ); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | cityView = new QListView( hBox ); | 488 | cityView = new QListView( hBox ); |
489 | cityView->addColumn( tr("City") ); | 489 | cityView->addColumn( tr("City") ); |
490 | 490 | ||
491 | layout->addWidget( hBox ); | 491 | layout->addWidget( hBox ); |
492 | return returnWidget; | 492 | return returnWidget; |
493 | } | 493 | } |
494 | 494 | ||
495 | void ZoneMap::slotGetCities( QListViewItem * contItem) { | 495 | void ZoneMap::slotGetCities( QListViewItem * contItem) { |
496 | 496 | ||
497 | cityView->clear(); | 497 | cityView->clear(); |
498 | selectedCont = contItem->text( 1 ); | 498 | selectedCont = contItem->text( 1 ); |
499 | QListIterator<ZoneField> itZone( zones ); | 499 | QListIterator<ZoneField> itZone( zones ); |
500 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | 500 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { |
501 | ZoneField *pZone = itZone.current(); | 501 | ZoneField *pZone = itZone.current(); |
502 | if ( pZone->country() == contItem->text( 1 ) ) { | 502 | if ( pZone->country() == contItem->text( 1 ) ) { |
503 | QListViewItem *item; | 503 | QListViewItem *item; |
504 | item = new QListViewItem( cityView, pZone->city() ); | 504 | item = new QListViewItem( cityView, pZone->city() ); |
505 | connect ( cityView, SIGNAL( clicked ( QListViewItem* ) ), this, SLOT( slotCitySelected( QListViewItem* ) ) ); | 505 | connect ( cityView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotCitySelected(QListViewItem*) ) ); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { | 510 | void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { |
511 | if ( cityItem ) { | 511 | if ( cityItem ) { |
512 | emit signalTz( selectedCont, cityItem->text( 0 ) ); | 512 | emit signalTz( selectedCont, cityItem->text( 0 ) ); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | void ZoneMap::drawCities( QPainter *p ) | 516 | void ZoneMap::drawCities( QPainter *p ) |
517 | { | 517 | { |
518 | int x, y, j; | 518 | int x, y, j; |
519 | // draw in the cities | 519 | // draw in the cities |
520 | // for testing only as when you put it | 520 | // for testing only as when you put it |
521 | // on the small screen it looks awful and not to mention useless | 521 | // on the small screen it looks awful and not to mention useless |
522 | p->setPen( red ); | 522 | p->setPen( red ); |
523 | QListIterator<ZoneField> itZone( zones ); | 523 | QListIterator<ZoneField> itZone( zones ); |
524 | for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { | 524 | for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { |
525 | ZoneField *pZone = itZone.current(); | 525 | ZoneField *pZone = itZone.current(); |
526 | zoneToWin( pZone->x(), pZone->y(), x, y ); | 526 | zoneToWin( pZone->x(), pZone->y(), x, y ); |
527 | if ( x > wImg ) | 527 | if ( x > wImg ) |
528 | x = x - wImg; | 528 | x = x - wImg; |
529 | p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); | 529 | p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | static void dayNight(QImage *pImage) | 533 | static void dayNight(QImage *pImage) |
534 | { | 534 | { |
535 | // create a mask the functions from sun.h | 535 | // create a mask the functions from sun.h |
536 | double dJulian, | 536 | double dJulian, |
537 | dSunRad, | 537 | dSunRad, |
538 | dSunDecl, | 538 | dSunDecl, |
539 | dSunRadius, | 539 | dSunRadius, |
540 | dSunLong; | 540 | dSunLong; |
541 | int wImage = pImage->width(), | 541 | int wImage = pImage->width(), |
542 | hImage = pImage->height(), | 542 | hImage = pImage->height(), |
543 | iStart, | 543 | iStart, |
544 | iStop, | 544 | iStop, |
545 | iMid, | 545 | iMid, |
546 | relw, | 546 | relw, |
547 | i; | 547 | i; |
548 | short wtab[ wImage ]; | 548 | short wtab[ wImage ]; |
549 | time_t tCurrent; | 549 | time_t tCurrent; |
550 | struct tm *pTm; | 550 | struct tm *pTm; |
551 | 551 | ||
552 | // get the position of the sun bassed on our current time... | 552 | // get the position of the sun bassed on our current time... |
553 | tCurrent = time( NULL ); | 553 | tCurrent = time( NULL ); |
554 | pTm = gmtime( &tCurrent ); | 554 | pTm = gmtime( &tCurrent ); |
555 | dJulian = jtime( pTm ); | 555 | dJulian = jtime( pTm ); |
556 | sunpos( dJulian, 0, &dSunRad, &dSunDecl, &dSunRadius, &dSunLong ); | 556 | sunpos( dJulian, 0, &dSunRad, &dSunDecl, &dSunRadius, &dSunLong ); |
557 | 557 | ||
558 | // now get the projected illumination | 558 | // now get the projected illumination |
559 | projillum( wtab, wImage, hImage, dSunDecl ); | 559 | projillum( wtab, wImage, hImage, dSunDecl ); |
560 | relw = wImage - int( wImage * 0.0275 ); | 560 | relw = wImage - int( wImage * 0.0275 ); |
561 | 561 | ||
562 | // draw the map, keeping in mind that we may go too far off the map... | 562 | // draw the map, keeping in mind that we may go too far off the map... |
563 | iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 ); | 563 | iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 ); |
564 | 564 | ||
565 | for ( i = 0; i < hImage; i++ ) { | 565 | for ( i = 0; i < hImage; i++ ) { |
566 | if ( wtab[i] > 0 ) { | 566 | if ( wtab[i] > 0 ) { |
567 | iStart = iMid - wtab[i]; | 567 | iStart = iMid - wtab[i]; |
568 | iStop = iMid + wtab[i]; | 568 | iStop = iMid + wtab[i]; |
569 | if ( iStart < 0 ) { | 569 | if ( iStart < 0 ) { |
570 | darken( pImage, iStop, wImage + iStart, i ); | 570 | darken( pImage, iStop, wImage + iStart, i ); |
571 | } else if ( iStop > wImage ) { | 571 | } else if ( iStop > wImage ) { |
572 | darken( pImage, iStop - wImage, iStart, i ); | 572 | darken( pImage, iStop - wImage, iStart, i ); |
573 | } else { | 573 | } else { |
574 | darken( pImage, 0, iStart, i ); | 574 | darken( pImage, 0, iStart, i ); |
575 | darken( pImage, iStop, wImage, i ); | 575 | darken( pImage, iStop, wImage, i ); |
576 | } | 576 | } |
577 | } else { | 577 | } else { |
578 | darken( pImage, 0, wImage, i ); | 578 | darken( pImage, 0, wImage, i ); |
579 | } | 579 | } |
580 | } | 580 | } |
581 | } | 581 | } |
582 | 582 | ||
583 | static inline void darken( QImage *pImage, int start, int stop, int row ) | 583 | static inline void darken( QImage *pImage, int start, int stop, int row ) |
584 | { | 584 | { |
585 | int colors, | 585 | int colors, |
586 | j; | 586 | j; |
587 | uchar *p; | 587 | uchar *p; |
588 | 588 | ||
589 | // assume that the image is similar to the one we have... | 589 | // assume that the image is similar to the one we have... |
590 | colors = pImage->numColors() / 2; | 590 | colors = pImage->numColors() / 2; |
591 | 591 | ||
592 | p = pImage->scanLine( row ); | 592 | p = pImage->scanLine( row ); |
593 | for ( j = start; j <= stop; j++ ) { | 593 | for ( j = start; j <= stop; j++ ) { |
594 | if ( p[j] < colors ) | 594 | if ( p[j] < colors ) |
595 | p[j] += colors; | 595 | p[j] += colors; |
596 | } | 596 | } |
597 | } | 597 | } |
598 | 598 | ||
599 | void ZoneMap::makeMap( int w, int h ) | 599 | void ZoneMap::makeMap( int w, int h ) |
600 | { | 600 | { |
601 | QImage imgOrig = Resource::loadImage( strMAP ); | 601 | QImage imgOrig = Resource::loadImage( strMAP ); |
602 | if ( imgOrig.isNull() ) { | 602 | if ( imgOrig.isNull() ) { |
603 | QMessageBox::warning( this, | 603 | QMessageBox::warning( this, |
604 | tr( "Couldn't Find Map" ), | 604 | tr( "Couldn't Find Map" ), |
605 | tr( "<p>Couldn't load map: %1, exiting") | 605 | tr( "<p>Couldn't load map: %1, exiting") |
606 | .arg( strMAP ) ); | 606 | .arg( strMAP ) ); |
607 | exit(-1); | 607 | exit(-1); |
608 | } | 608 | } |
609 | 609 | ||
610 | // set up the color table for darkening... | 610 | // set up the color table for darkening... |
611 | imgOrig = imgOrig.convertDepth( 8 ); | 611 | imgOrig = imgOrig.convertDepth( 8 ); |
612 | int numColors = imgOrig.numColors(); | 612 | int numColors = imgOrig.numColors(); |
613 | // double the colors | 613 | // double the colors |
614 | imgOrig.setNumColors( 2 * numColors ); | 614 | imgOrig.setNumColors( 2 * numColors ); |
615 | // darken the new ones... | 615 | // darken the new ones... |
616 | for ( int i = 0; i < numColors; i++ ) { | 616 | for ( int i = 0; i < numColors; i++ ) { |
617 | QRgb rgb = imgOrig.color( i ); | 617 | QRgb rgb = imgOrig.color( i ); |
618 | imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3, | 618 | imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3, |
619 | 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) ); | 619 | 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) ); |
620 | } | 620 | } |
621 | 621 | ||
622 | // else go one with making the map... | 622 | // else go one with making the map... |
623 | if ( bIllum ) { | 623 | if ( bIllum ) { |
624 | // do a daylight mask | 624 | // do a daylight mask |
625 | dayNight(&imgOrig); | 625 | dayNight(&imgOrig); |
626 | } | 626 | } |
627 | // redo the width and height | 627 | // redo the width and height |
628 | wImg = w; | 628 | wImg = w; |
629 | hImg = h; | 629 | hImg = h; |
630 | ox = ( wImg / 2 ) - int( wImg * 0.0275 ); | 630 | ox = ( wImg / 2 ) - int( wImg * 0.0275 ); |
631 | oy = hImg / 2; | 631 | oy = hImg / 2; |
632 | pixCurr->convertFromImage( imgOrig.smoothScale(w, h), | 632 | pixCurr->convertFromImage( imgOrig.smoothScale(w, h), |
633 | QPixmap::ThresholdDither ); | 633 | QPixmap::ThresholdDither ); |
634 | } | 634 | } |
635 | 635 | ||
636 | void ZoneMap::drawCity( QPainter *p, const ZoneField *pCity ) | 636 | void ZoneMap::drawCity( QPainter *p, const ZoneField *pCity ) |
637 | { | 637 | { |
638 | int x, | 638 | int x, |
639 | y; | 639 | y; |
640 | 640 | ||
641 | p->setPen( red ); | 641 | p->setPen( red ); |
642 | zoneToWin( pCity->x(), pCity->y(), x, y ); | 642 | zoneToWin( pCity->x(), pCity->y(), x, y ); |
643 | p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE ); | 643 | p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE ); |
644 | } | 644 | } |
645 | 645 | ||
646 | void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) | 646 | void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) |
647 | { | 647 | { |
648 | // if there is a need to resize, then do it... | 648 | // if there is a need to resize, then do it... |
649 | // get our drawable area | 649 | // get our drawable area |
650 | drawableW = width() - 2 * frameWidth(); | 650 | drawableW = width() - 2 * frameWidth(); |
651 | drawableH = height() - 2 * frameWidth(); | 651 | drawableH = height() - 2 * frameWidth(); |
652 | 652 | ||
653 | int pixmapW = pixCurr->width(), | 653 | int pixmapW = pixCurr->width(), |
654 | pixmapH = pixCurr->height(); | 654 | pixmapH = pixCurr->height(); |
655 | if ( !bZoom && ( ( pixmapW != drawableW ) || | 655 | if ( !bZoom && ( ( pixmapW != drawableW ) || |
656 | ( pixmapH != drawableH) ) ) { | 656 | ( pixmapH != drawableH) ) ) { |
657 | makeMap( drawableW, drawableH ); | 657 | makeMap( drawableW, drawableH ); |
658 | } | 658 | } |
659 | 659 | ||
660 | // taken from the scrollview example... | 660 | // taken from the scrollview example... |
661 | int rowheight = pixCurr->height(); | 661 | int rowheight = pixCurr->height(); |
662 | int toprow = cy / rowheight; | 662 | int toprow = cy / rowheight; |
663 | int bottomrow = ( cy + ch + rowheight - 1 ) / rowheight; | 663 | int bottomrow = ( cy + ch + rowheight - 1 ) / rowheight; |
664 | int colwidth = pixCurr->width(); | 664 | int colwidth = pixCurr->width(); |
665 | int leftcol= cx / colwidth; | 665 | int leftcol= cx / colwidth; |
666 | int rightcol= ( cx + cw + colwidth - 1 ) / colwidth; | 666 | int rightcol= ( cx + cw + colwidth - 1 ) / colwidth; |
667 | for ( int r = toprow; r <= bottomrow; r++ ) { | 667 | for ( int r = toprow; r <= bottomrow; r++ ) { |
668 | int py = r * rowheight; | 668 | int py = r * rowheight; |
669 | for ( int c = leftcol; c <= rightcol; c++ ) { | 669 | for ( int c = leftcol; c <= rightcol; c++ ) { |
670 | int px = c * colwidth; | 670 | int px = c * colwidth; |
671 | p->drawPixmap( px, py, *pixCurr ); | 671 | p->drawPixmap( px, py, *pixCurr ); |
672 | } | 672 | } |
673 | } | 673 | } |
674 | 674 | ||
675 | // Draw that city! | 675 | // Draw that city! |
676 | if ( pLast ) | 676 | if ( pLast ) |
677 | drawCity( p, pLast ); | 677 | drawCity( p, pLast ); |
678 | } | 678 | } |
679 | 679 | ||
680 | void ZoneMap::slotZoom( bool setZoom ) | 680 | void ZoneMap::slotZoom( bool setZoom ) |
681 | { | 681 | { |
682 | bZoom = setZoom; | 682 | bZoom = setZoom; |
683 | if ( bZoom ) { | 683 | if ( bZoom ) { |
684 | makeMap( 2 * wImg , 2 * hImg ); | 684 | makeMap( 2 * wImg , 2 * hImg ); |
685 | resizeContents( wImg, hImg ); | 685 | resizeContents( wImg, hImg ); |
686 | } else { | 686 | } else { |
687 | makeMap( drawableW, drawableH ); | 687 | makeMap( drawableW, drawableH ); |
688 | resizeContents( drawableW, drawableH ); | 688 | resizeContents( drawableW, drawableH ); |
689 | } | 689 | } |
690 | } | 690 | } |
691 | 691 | ||
692 | void ZoneMap::slotIllum( bool setIllum ) | 692 | void ZoneMap::slotIllum( bool setIllum ) |
693 | { | 693 | { |
694 | bIllum = !setIllum; | 694 | bIllum = !setIllum; |
695 | // make the map... | 695 | // make the map... |
696 | makeMap( pixCurr->width(), pixCurr->height() ); | 696 | makeMap( pixCurr->width(), pixCurr->height() ); |
697 | updateContents( 0, 0, wImg, hImg ); | 697 | updateContents( 0, 0, wImg, hImg ); |
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp index dc8e993..2b64c47 100644 --- a/core/settings/launcher/menusettings.cpp +++ b/core/settings/launcher/menusettings.cpp | |||
@@ -1,178 +1,178 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
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 "menusettings.h" | 29 | #include "menusettings.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/qlibrary.h> | 32 | #include <qpe/qlibrary.h> |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/menuappletinterface.h> | 34 | #include <qpe/menuappletinterface.h> |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qlistview.h> | 38 | #include <qlistview.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qheader.h> | 40 | #include <qheader.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qwhatsthis.h> | 43 | #include <qwhatsthis.h> |
44 | 44 | ||
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | 46 | ||
47 | 47 | ||
48 | MenuSettings::MenuSettings ( QWidget *parent, const char *name ) | 48 | MenuSettings::MenuSettings ( QWidget *parent, const char *name ) |
49 | : QWidget ( parent, name ) | 49 | : QWidget ( parent, name ) |
50 | { | 50 | { |
51 | m_applets_changed = false; | 51 | m_applets_changed = false; |
52 | 52 | ||
53 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); | 53 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); |
54 | 54 | ||
55 | QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this ); | 55 | QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this ); |
56 | lay-> addWidget ( l ); | 56 | lay-> addWidget ( l ); |
57 | 57 | ||
58 | m_list = new QListView ( this ); | 58 | m_list = new QListView ( this ); |
59 | m_list-> addColumn ( "foobar" ); | 59 | m_list-> addColumn ( "foobar" ); |
60 | m_list-> header ( )-> hide ( ); | 60 | m_list-> header ( )-> hide ( ); |
61 | 61 | ||
62 | lay-> addWidget ( m_list ); | 62 | lay-> addWidget ( m_list ); |
63 | 63 | ||
64 | m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); | 64 | m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); |
65 | lay-> addWidget ( m_menutabs ); | 65 | lay-> addWidget ( m_menutabs ); |
66 | 66 | ||
67 | m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this ); | 67 | m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this ); |
68 | lay-> addWidget ( m_menusubpopup ); | 68 | lay-> addWidget ( m_menusubpopup ); |
69 | 69 | ||
70 | QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); | 70 | QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); |
71 | QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." )); | 71 | QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." )); |
72 | 72 | ||
73 | connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); | 73 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); |
74 | 74 | ||
75 | init ( ); | 75 | init ( ); |
76 | } | 76 | } |
77 | 77 | ||
78 | void MenuSettings::init ( ) | 78 | void MenuSettings::init ( ) |
79 | { | 79 | { |
80 | Config cfg ( "StartMenu" ); | 80 | Config cfg ( "StartMenu" ); |
81 | cfg. setGroup ( "Applets" ); | 81 | cfg. setGroup ( "Applets" ); |
82 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); | 82 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); |
83 | 83 | ||
84 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; | 84 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; |
85 | #ifdef Q_OS_MACX | 85 | #ifdef Q_OS_MACX |
86 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); | 86 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); |
87 | #else | 87 | #else |
88 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); | 88 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); |
89 | #endif /* Q_OS_MACX */ | 89 | #endif /* Q_OS_MACX */ |
90 | 90 | ||
91 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { | 91 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { |
92 | QString name; | 92 | QString name; |
93 | QPixmap icon; | 93 | QPixmap icon; |
94 | MenuAppletInterface *iface = 0; | 94 | MenuAppletInterface *iface = 0; |
95 | 95 | ||
96 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 96 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
97 | lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); | 97 | lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); |
98 | if ( iface ) { | 98 | if ( iface ) { |
99 | QString lang = getenv( "LANG" ); | 99 | QString lang = getenv( "LANG" ); |
100 | QTranslator *trans = new QTranslator ( qApp ); | 100 | QTranslator *trans = new QTranslator ( qApp ); |
101 | QString type = (*it). left ((*it). find (".")); | 101 | QString type = (*it). left ((*it). find (".")); |
102 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; | 102 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; |
103 | if ( trans-> load ( tfn )) | 103 | if ( trans-> load ( tfn )) |
104 | qApp-> installTranslator ( trans ); | 104 | qApp-> installTranslator ( trans ); |
105 | else | 105 | else |
106 | delete trans; | 106 | delete trans; |
107 | name = iface-> name ( ); | 107 | name = iface-> name ( ); |
108 | icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); | 108 | icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); |
109 | iface-> release ( ); | 109 | iface-> release ( ); |
110 | lib-> unload ( ); | 110 | lib-> unload ( ); |
111 | 111 | ||
112 | QCheckListItem *item; | 112 | QCheckListItem *item; |
113 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); | 113 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); |
114 | if ( !icon. isNull ( )) | 114 | if ( !icon. isNull ( )) |
115 | item-> setPixmap ( 0, icon ); | 115 | item-> setPixmap ( 0, icon ); |
116 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); | 116 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); |
117 | m_applets [*it] = item; | 117 | m_applets [*it] = item; |
118 | } else { | 118 | } else { |
119 | delete lib; | 119 | delete lib; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | cfg. setGroup ( "Menu" ); | 123 | cfg. setGroup ( "Menu" ); |
124 | m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); | 124 | m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); |
125 | m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); | 125 | m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); |
126 | m_menusubpopup->setEnabled( m_menutabs->isChecked() ); | 126 | m_menusubpopup->setEnabled( m_menutabs->isChecked() ); |
127 | connect( m_menutabs, SIGNAL( stateChanged( int ) ), m_menusubpopup, SLOT( setEnabled( bool ) ) ); | 127 | connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) ); |
128 | 128 | ||
129 | } | 129 | } |
130 | 130 | ||
131 | void MenuSettings::appletChanged() | 131 | void MenuSettings::appletChanged() |
132 | { | 132 | { |
133 | m_applets_changed = true; | 133 | m_applets_changed = true; |
134 | } | 134 | } |
135 | 135 | ||
136 | void MenuSettings::accept ( ) | 136 | void MenuSettings::accept ( ) |
137 | { | 137 | { |
138 | bool apps_changed = false; | 138 | bool apps_changed = false; |
139 | 139 | ||
140 | Config cfg ( "StartMenu" ); | 140 | Config cfg ( "StartMenu" ); |
141 | cfg. setGroup ( "Applets" ); | 141 | cfg. setGroup ( "Applets" ); |
142 | if ( m_applets_changed ) { | 142 | if ( m_applets_changed ) { |
143 | QStringList exclude; | 143 | QStringList exclude; |
144 | QMap <QString, QCheckListItem *>::Iterator it; | 144 | QMap <QString, QCheckListItem *>::Iterator it; |
145 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { | 145 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { |
146 | if ( !(*it)-> isOn ( )) | 146 | if ( !(*it)-> isOn ( )) |
147 | exclude << it. key ( ); | 147 | exclude << it. key ( ); |
148 | } | 148 | } |
149 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); | 149 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); |
150 | } | 150 | } |
151 | cfg. writeEntry ( "SafeMode", false ); | 151 | cfg. writeEntry ( "SafeMode", false ); |
152 | 152 | ||
153 | cfg. setGroup ( "Menu" ); | 153 | cfg. setGroup ( "Menu" ); |
154 | 154 | ||
155 | if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { | 155 | if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { |
156 | apps_changed = true; | 156 | apps_changed = true; |
157 | cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); | 157 | cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); |
158 | } | 158 | } |
159 | 159 | ||
160 | if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) { | 160 | if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) { |
161 | apps_changed = true; | 161 | apps_changed = true; |
162 | cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( )); | 162 | cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( )); |
163 | } | 163 | } |
164 | 164 | ||
165 | cfg. write ( ); | 165 | cfg. write ( ); |
166 | 166 | ||
167 | if ( m_applets_changed ) { | 167 | if ( m_applets_changed ) { |
168 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); | 168 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); |
169 | m_applets_changed = false; | 169 | m_applets_changed = false; |
170 | } | 170 | } |
171 | if ( apps_changed ) { | 171 | if ( apps_changed ) { |
172 | // currently use reloadApplets() since reloadApps is now used exclusive for server | 172 | // currently use reloadApplets() since reloadApps is now used exclusive for server |
173 | // to refresh the tabs. But what we want here is also a refresh of the startmenu entries | 173 | // to refresh the tabs. But what we want here is also a refresh of the startmenu entries |
174 | QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); | 174 | QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); |
175 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); | 175 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
diff --git a/core/settings/launcher/tabdialog.cpp b/core/settings/launcher/tabdialog.cpp index f79ad40..c0d1cf2 100644 --- a/core/settings/launcher/tabdialog.cpp +++ b/core/settings/launcher/tabdialog.cpp | |||
@@ -130,384 +130,384 @@ public: | |||
130 | painter. drawLine ( 0, i*3, width()-1, i*3 ); | 130 | painter. drawLine ( 0, i*3, width()-1, i*3 ); |
131 | painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); | 131 | painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); |
132 | painter. setPen ( colorGroup().background().light(105) ); | 132 | painter. setPen ( colorGroup().background().light(105) ); |
133 | painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); | 133 | painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); |
134 | } | 134 | } |
135 | painter.end ( ); | 135 | painter.end ( ); |
136 | setBackgroundPixmap ( bg ); | 136 | setBackgroundPixmap ( bg ); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | 139 | ||
140 | case TabConfig::SolidColor: { | 140 | case TabConfig::SolidColor: { |
141 | setBackgroundPixmap ( QPixmap ( )); | 141 | setBackgroundPixmap ( QPixmap ( )); |
142 | if ( val. isEmpty ( )) | 142 | if ( val. isEmpty ( )) |
143 | setBackgroundColor ( colorGroup ( ). base ( )); | 143 | setBackgroundColor ( colorGroup ( ). base ( )); |
144 | else | 144 | else |
145 | setBackgroundColor ( val ); | 145 | setBackgroundColor ( val ); |
146 | break; | 146 | break; |
147 | } | 147 | } |
148 | 148 | ||
149 | case TabConfig::Image: { | 149 | case TabConfig::Image: { |
150 | qDebug( "Loading image: %s", val.latin1() ); | 150 | qDebug( "Loading image: %s", val.latin1() ); |
151 | QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val )); | 151 | QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val )); |
152 | if ( bg. isNull ( )) { | 152 | if ( bg. isNull ( )) { |
153 | QImageIO imgio; | 153 | QImageIO imgio; |
154 | imgio. setFileName ( val ); | 154 | imgio. setFileName ( val ); |
155 | QSize ds = qApp-> desktop ( )-> size ( ); | 155 | QSize ds = qApp-> desktop ( )-> size ( ); |
156 | QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr | 156 | QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr |
157 | imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( )); | 157 | imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( )); |
158 | imgio. read ( ); | 158 | imgio. read ( ); |
159 | bg = imgio. image ( ); | 159 | bg = imgio. image ( ); |
160 | } | 160 | } |
161 | setBackgroundPixmap ( bg ); | 161 | setBackgroundPixmap ( bg ); |
162 | break; | 162 | break; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | m_bgtype = t; | 165 | m_bgtype = t; |
166 | viewport ( )-> update ( ); | 166 | viewport ( )-> update ( ); |
167 | } | 167 | } |
168 | 168 | ||
169 | void setTextColor ( const QColor &tc ) | 169 | void setTextColor ( const QColor &tc ) |
170 | { | 170 | { |
171 | m_textcolor = tc; | 171 | m_textcolor = tc; |
172 | QColorGroup cg = colorGroup ( ); | 172 | QColorGroup cg = colorGroup ( ); |
173 | cg. setColor ( QColorGroup::Text, tc ); | 173 | cg. setColor ( QColorGroup::Text, tc ); |
174 | setPalette ( QPalette ( cg, cg, cg )); | 174 | setPalette ( QPalette ( cg, cg, cg )); |
175 | viewport ( )-> update ( ); | 175 | viewport ( )-> update ( ); |
176 | } | 176 | } |
177 | 177 | ||
178 | void setViewFont ( const QFont &f ) | 178 | void setViewFont ( const QFont &f ) |
179 | { | 179 | { |
180 | setFont ( f ); | 180 | setFont ( f ); |
181 | } | 181 | } |
182 | 182 | ||
183 | void setItemTextPos ( ItemTextPos pos ) | 183 | void setItemTextPos ( ItemTextPos pos ) |
184 | { | 184 | { |
185 | calculateGrid ( pos ); | 185 | calculateGrid ( pos ); |
186 | QIconView::setItemTextPos( pos ); | 186 | QIconView::setItemTextPos( pos ); |
187 | } | 187 | } |
188 | 188 | ||
189 | void calculateGrid ( ItemTextPos pos ) | 189 | void calculateGrid ( ItemTextPos pos ) |
190 | { | 190 | { |
191 | int dw = QApplication::desktop ( )-> width ( ); | 191 | int dw = QApplication::desktop ( )-> width ( ); |
192 | int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); | 192 | int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); |
193 | if ( pos == Bottom ) { | 193 | if ( pos == Bottom ) { |
194 | int cols = 3; | 194 | int cols = 3; |
195 | if ( viewerWidth <= 200 ) | 195 | if ( viewerWidth <= 200 ) |
196 | cols = 2; | 196 | cols = 2; |
197 | else if ( viewerWidth >= 400 ) | 197 | else if ( viewerWidth >= 400 ) |
198 | cols = viewerWidth/96; | 198 | cols = viewerWidth/96; |
199 | setSpacing ( 4 ); | 199 | setSpacing ( 4 ); |
200 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); | 200 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); |
201 | setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); | 201 | setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); |
202 | } | 202 | } |
203 | else { | 203 | else { |
204 | int cols = 2; | 204 | int cols = 2; |
205 | if ( viewerWidth < 150 ) | 205 | if ( viewerWidth < 150 ) |
206 | cols = 1; | 206 | cols = 1; |
207 | else if ( viewerWidth >= 400 ) | 207 | else if ( viewerWidth >= 400 ) |
208 | cols = viewerWidth / 150; | 208 | cols = viewerWidth / 150; |
209 | setSpacing ( 2 ); | 209 | setSpacing ( 2 ); |
210 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); | 210 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); |
211 | setGridY ( fontMetrics ( ). height ( ) + 2 ); | 211 | setGridY ( fontMetrics ( ). height ( ) + 2 ); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | void paletteChange( const QPalette &p ) | 215 | void paletteChange( const QPalette &p ) |
216 | { | 216 | { |
217 | static bool excllock = false; | 217 | static bool excllock = false; |
218 | 218 | ||
219 | if ( excllock ) | 219 | if ( excllock ) |
220 | return; | 220 | return; |
221 | excllock = true; | 221 | excllock = true; |
222 | 222 | ||
223 | unsetPalette ( ); | 223 | unsetPalette ( ); |
224 | QIconView::paletteChange ( p ); | 224 | QIconView::paletteChange ( p ); |
225 | if ( m_bgtype == TabConfig::Ruled ) | 225 | if ( m_bgtype == TabConfig::Ruled ) |
226 | setBackgroundType ( TabConfig::Ruled, QString::null ); | 226 | setBackgroundType ( TabConfig::Ruled, QString::null ); |
227 | QColorGroup cg = colorGroup ( ); | 227 | QColorGroup cg = colorGroup ( ); |
228 | cg.setColor ( QColorGroup::Text, m_textcolor ); | 228 | cg.setColor ( QColorGroup::Text, m_textcolor ); |
229 | setPalette ( QPalette ( cg, cg, cg )); | 229 | setPalette ( QPalette ( cg, cg, cg )); |
230 | 230 | ||
231 | excllock = false; | 231 | excllock = false; |
232 | } | 232 | } |
233 | 233 | ||
234 | void setBackgroundPixmap ( const QPixmap &pm ) | 234 | void setBackgroundPixmap ( const QPixmap &pm ) |
235 | { | 235 | { |
236 | m_bgpix = pm; | 236 | m_bgpix = pm; |
237 | } | 237 | } |
238 | 238 | ||
239 | void setBackgroundColor ( const QColor &c ) | 239 | void setBackgroundColor ( const QColor &c ) |
240 | { | 240 | { |
241 | m_bgcolor = c; | 241 | m_bgcolor = c; |
242 | } | 242 | } |
243 | 243 | ||
244 | void drawBackground ( QPainter *p, const QRect &r ) | 244 | void drawBackground ( QPainter *p, const QRect &r ) |
245 | { | 245 | { |
246 | if ( !m_bgpix. isNull ( )) { | 246 | if ( !m_bgpix. isNull ( )) { |
247 | p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), | 247 | p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), |
248 | ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); | 248 | ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); |
249 | } | 249 | } |
250 | else | 250 | else |
251 | p-> fillRect ( r, m_bgcolor ); | 251 | p-> fillRect ( r, m_bgcolor ); |
252 | } | 252 | } |
253 | 253 | ||
254 | private: | 254 | private: |
255 | QColor m_textcolor; | 255 | QColor m_textcolor; |
256 | QColor m_bgcolor; | 256 | QColor m_bgcolor; |
257 | QPixmap m_bgpix; | 257 | QPixmap m_bgpix; |
258 | TabConfig::BackgroundType m_bgtype; | 258 | TabConfig::BackgroundType m_bgtype; |
259 | }; | 259 | }; |
260 | 260 | ||
261 | 261 | ||
262 | 262 | ||
263 | TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) | 263 | TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) |
264 | : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) | 264 | : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) |
265 | { | 265 | { |
266 | setCaption ( tr( "Edit Tab" )); | 266 | setCaption ( tr( "Edit Tab" )); |
267 | 267 | ||
268 | QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); | 268 | QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); |
269 | 269 | ||
270 | OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 270 | OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
271 | QWidget *bgtab; | 271 | QWidget *bgtab; |
272 | 272 | ||
273 | tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); | 273 | tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); |
274 | tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); | 274 | tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); |
275 | tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); | 275 | tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); |
276 | 276 | ||
277 | tw-> setCurrentTab ( bgtab ); | 277 | tw-> setCurrentTab ( bgtab ); |
278 | 278 | ||
279 | QWidget *sample = new QVBox ( this ); | 279 | QWidget *sample = new QVBox ( this ); |
280 | QTabBar *tb = new QTabBar ( sample ); | 280 | QTabBar *tb = new QTabBar ( sample ); |
281 | QString name ( tr( "Previewing %1" ). arg ( tabname )); | 281 | QString name ( tr( "Previewing %1" ). arg ( tabname )); |
282 | 282 | ||
283 | tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); | 283 | tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); |
284 | 284 | ||
285 | m_sample = new SampleView ( sample ); | 285 | m_sample = new SampleView ( sample ); |
286 | 286 | ||
287 | lay-> addWidget ( tw, 10 ); | 287 | lay-> addWidget ( tw, 10 ); |
288 | lay-> addWidget ( sample, 1 ); | 288 | lay-> addWidget ( sample, 1 ); |
289 | 289 | ||
290 | m_iconsize-> setButton ( tc. m_view ); | 290 | m_iconsize-> setButton ( tc. m_view ); |
291 | iconSizeClicked ( tc. m_view ); | 291 | iconSizeClicked ( tc. m_view ); |
292 | //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); | 292 | //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); |
293 | iconColorClicked ( m_iconcolor-> color ( )); | 293 | iconColorClicked ( m_iconcolor-> color ( )); |
294 | m_bgtype-> setButton ( tc. m_bg_type ); | 294 | m_bgtype-> setButton ( tc. m_bg_type ); |
295 | //m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); | 295 | //m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); |
296 | m_bgimage = tc. m_bg_image; | 296 | m_bgimage = tc. m_bg_image; |
297 | bgTypeClicked ( tc. m_bg_type ); | 297 | bgTypeClicked ( tc. m_bg_type ); |
298 | m_fontuse-> setChecked ( tc. m_font_use ); | 298 | m_fontuse-> setChecked ( tc. m_font_use ); |
299 | m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); | 299 | m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); |
300 | m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); | 300 | m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); |
301 | fontClicked ( m_fontselect-> selectedFont ( )); | 301 | fontClicked ( m_fontselect-> selectedFont ( )); |
302 | 302 | ||
303 | QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); | 303 | QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | TabDialog::~TabDialog ( ) | 307 | TabDialog::~TabDialog ( ) |
308 | { | 308 | { |
309 | } | 309 | } |
310 | 310 | ||
311 | QWidget *TabDialog::createFontTab ( QWidget *parent ) | 311 | QWidget *TabDialog::createFontTab ( QWidget *parent ) |
312 | { | 312 | { |
313 | QWidget *tab = new QWidget ( parent, "FontTab" ); | 313 | QWidget *tab = new QWidget ( parent, "FontTab" ); |
314 | QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); | 314 | QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); |
315 | 315 | ||
316 | m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); | 316 | m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); |
317 | vertLayout-> addWidget ( m_fontuse ); | 317 | vertLayout-> addWidget ( m_fontuse ); |
318 | 318 | ||
319 | m_fontselect = new OFontSelector ( false, tab, "fontsel" ); | 319 | m_fontselect = new OFontSelector ( false, tab, "fontsel" ); |
320 | vertLayout-> addWidget ( m_fontselect ); | 320 | vertLayout-> addWidget ( m_fontselect ); |
321 | 321 | ||
322 | connect ( m_fontuse, SIGNAL( toggled ( bool )), m_fontselect, SLOT( setEnabled ( bool ))); | 322 | connect ( m_fontuse, SIGNAL( toggled(bool)), m_fontselect, SLOT( setEnabled(bool))); |
323 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 323 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), |
324 | this, SLOT( fontClicked ( const QFont & ))); | 324 | this, SLOT( fontClicked(const QFont&))); |
325 | 325 | ||
326 | return tab; | 326 | return tab; |
327 | } | 327 | } |
328 | 328 | ||
329 | QWidget *TabDialog::createBgTab ( QWidget *parent ) | 329 | QWidget *TabDialog::createBgTab ( QWidget *parent ) |
330 | { | 330 | { |
331 | QWidget *tab = new QWidget( parent, "BgTab" ); | 331 | QWidget *tab = new QWidget( parent, "BgTab" ); |
332 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 332 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
333 | 333 | ||
334 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 334 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); |
335 | gridLayout-> setColStretch ( 1, 10 ); | 335 | gridLayout-> setColStretch ( 1, 10 ); |
336 | 336 | ||
337 | QLabel* label = new QLabel( tr( "Type:" ), tab ); | 337 | QLabel* label = new QLabel( tr( "Type:" ), tab ); |
338 | gridLayout-> addWidget ( label, 0, 0 ); | 338 | gridLayout-> addWidget ( label, 0, 0 ); |
339 | m_bgtype = new QButtonGroup( tab, "buttongroup" ); | 339 | m_bgtype = new QButtonGroup( tab, "buttongroup" ); |
340 | m_bgtype-> hide ( ); | 340 | m_bgtype-> hide ( ); |
341 | m_bgtype-> setExclusive ( true ); | 341 | m_bgtype-> setExclusive ( true ); |
342 | 342 | ||
343 | QRadioButton *rb; | 343 | QRadioButton *rb; |
344 | rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); | 344 | rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); |
345 | m_bgtype-> insert ( rb, TabConfig::Ruled ); | 345 | m_bgtype-> insert ( rb, TabConfig::Ruled ); |
346 | gridLayout-> addWidget( rb, 0, 1 ); | 346 | gridLayout-> addWidget( rb, 0, 1 ); |
347 | 347 | ||
348 | QHBoxLayout *hb = new QHBoxLayout ( ); | 348 | QHBoxLayout *hb = new QHBoxLayout ( ); |
349 | hb-> setSpacing ( 3 ); | 349 | hb-> setSpacing ( 3 ); |
350 | 350 | ||
351 | rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); | 351 | rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); |
352 | m_bgtype-> insert ( rb, TabConfig::SolidColor ); | 352 | m_bgtype-> insert ( rb, TabConfig::SolidColor ); |
353 | hb-> addWidget ( rb ); | 353 | hb-> addWidget ( rb ); |
354 | hb-> addSpacing ( 10 ); | 354 | hb-> addSpacing ( 10 ); |
355 | 355 | ||
356 | m_solidcolor = new OColorButton ( tab, QColor ( m_tc. m_bg_color ) ); | 356 | m_solidcolor = new OColorButton ( tab, QColor ( m_tc. m_bg_color ) ); |
357 | connect ( m_solidcolor, SIGNAL( colorSelected ( const QColor & )), this, SLOT( bgColorClicked ( const QColor & ))); | 357 | connect ( m_solidcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( bgColorClicked(const QColor&))); |
358 | hb-> addWidget ( m_solidcolor ); | 358 | hb-> addWidget ( m_solidcolor ); |
359 | hb-> addStretch ( 10 ); | 359 | hb-> addStretch ( 10 ); |
360 | 360 | ||
361 | gridLayout-> addLayout ( hb, 1, 1 ); | 361 | gridLayout-> addLayout ( hb, 1, 1 ); |
362 | 362 | ||
363 | hb = new QHBoxLayout ( ); | 363 | hb = new QHBoxLayout ( ); |
364 | hb-> setSpacing ( 3 ); | 364 | hb-> setSpacing ( 3 ); |
365 | 365 | ||
366 | rb = new QRadioButton( tr( "Image" ), tab, "image" ); | 366 | rb = new QRadioButton( tr( "Image" ), tab, "image" ); |
367 | m_bgtype-> insert ( rb, TabConfig::Image ); | 367 | m_bgtype-> insert ( rb, TabConfig::Image ); |
368 | hb-> addWidget( rb ); | 368 | hb-> addWidget( rb ); |
369 | hb-> addSpacing ( 10 ); | 369 | hb-> addSpacing ( 10 ); |
370 | 370 | ||
371 | m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); | 371 | m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); |
372 | connect ( m_imagebrowse, SIGNAL( clicked ( )), this, SLOT( bgImageClicked ( ))); | 372 | connect ( m_imagebrowse, SIGNAL( clicked()), this, SLOT( bgImageClicked())); |
373 | hb-> addWidget ( m_imagebrowse ); | 373 | hb-> addWidget ( m_imagebrowse ); |
374 | hb-> addStretch ( 10 ); | 374 | hb-> addStretch ( 10 ); |
375 | 375 | ||
376 | gridLayout-> addLayout ( hb, 2, 1 ); | 376 | gridLayout-> addLayout ( hb, 2, 1 ); |
377 | 377 | ||
378 | QPushButton *p = new QPushButton ( tr( "Default" ), tab ); | 378 | QPushButton *p = new QPushButton ( tr( "Default" ), tab ); |
379 | connect ( p, SIGNAL( clicked ( )), this, SLOT( bgDefaultClicked ( ))); | 379 | connect ( p, SIGNAL( clicked()), this, SLOT( bgDefaultClicked())); |
380 | gridLayout-> addWidget ( p, 3, 1 ); | 380 | gridLayout-> addWidget ( p, 3, 1 ); |
381 | 381 | ||
382 | connect ( m_bgtype, SIGNAL( clicked ( int )), this, SLOT( bgTypeClicked ( int ))); | 382 | connect ( m_bgtype, SIGNAL( clicked(int)), this, SLOT( bgTypeClicked(int))); |
383 | 383 | ||
384 | vertLayout-> addStretch ( 10 ); | 384 | vertLayout-> addStretch ( 10 ); |
385 | 385 | ||
386 | return tab; | 386 | return tab; |
387 | } | 387 | } |
388 | 388 | ||
389 | QWidget *TabDialog::createIconTab ( QWidget *parent ) | 389 | QWidget *TabDialog::createIconTab ( QWidget *parent ) |
390 | { | 390 | { |
391 | QWidget *tab = new QWidget( parent, "IconTab" ); | 391 | QWidget *tab = new QWidget( parent, "IconTab" ); |
392 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 392 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
393 | 393 | ||
394 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 394 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); |
395 | gridLayout-> setColStretch ( 1, 10 ); | 395 | gridLayout-> setColStretch ( 1, 10 ); |
396 | 396 | ||
397 | QLabel* label = new QLabel( tr( "Size:" ), tab ); | 397 | QLabel* label = new QLabel( tr( "Size:" ), tab ); |
398 | gridLayout-> addWidget ( label, 0, 0 ); | 398 | gridLayout-> addWidget ( label, 0, 0 ); |
399 | m_iconsize = new QButtonGroup( tab, "buttongroup" ); | 399 | m_iconsize = new QButtonGroup( tab, "buttongroup" ); |
400 | m_iconsize-> hide ( ); | 400 | m_iconsize-> hide ( ); |
401 | m_iconsize-> setExclusive ( true ); | 401 | m_iconsize-> setExclusive ( true ); |
402 | 402 | ||
403 | QRadioButton *rb; | 403 | QRadioButton *rb; |
404 | rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); | 404 | rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); |
405 | m_iconsize-> insert ( rb, TabConfig::List ); | 405 | m_iconsize-> insert ( rb, TabConfig::List ); |
406 | gridLayout-> addWidget( rb, 0, 1 ); | 406 | gridLayout-> addWidget( rb, 0, 1 ); |
407 | 407 | ||
408 | rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); | 408 | rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); |
409 | m_iconsize-> insert ( rb, TabConfig::Icon ); | 409 | m_iconsize-> insert ( rb, TabConfig::Icon ); |
410 | gridLayout-> addWidget( rb, 1, 1 ); | 410 | gridLayout-> addWidget( rb, 1, 1 ); |
411 | 411 | ||
412 | connect ( m_iconsize, SIGNAL( clicked ( int )), this, SLOT( iconSizeClicked ( int ))); | 412 | connect ( m_iconsize, SIGNAL( clicked(int)), this, SLOT( iconSizeClicked(int))); |
413 | 413 | ||
414 | //vertLayout-> addSpacing ( 8 ); | 414 | //vertLayout-> addSpacing ( 8 ); |
415 | 415 | ||
416 | //gridLayout = new QGridLayout ( vertLayout ); | 416 | //gridLayout = new QGridLayout ( vertLayout ); |
417 | gridLayout-> addRowSpacing ( 2, 8 ); | 417 | gridLayout-> addRowSpacing ( 2, 8 ); |
418 | 418 | ||
419 | label = new QLabel ( tr( "Color:" ), tab ); | 419 | label = new QLabel ( tr( "Color:" ), tab ); |
420 | gridLayout-> addWidget ( label, 3, 0 ); | 420 | gridLayout-> addWidget ( label, 3, 0 ); |
421 | 421 | ||
422 | m_iconcolor = new OColorButton ( tab, QColor ( m_tc. m_text_color ) ); | 422 | m_iconcolor = new OColorButton ( tab, QColor ( m_tc. m_text_color ) ); |
423 | connect ( m_iconcolor, SIGNAL( colorSelected ( const QColor & )), this, SLOT( iconColorClicked ( const QColor & ))); | 423 | connect ( m_iconcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( iconColorClicked(const QColor&))); |
424 | gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft ); | 424 | gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft ); |
425 | 425 | ||
426 | vertLayout-> addStretch ( 10 ); | 426 | vertLayout-> addStretch ( 10 ); |
427 | 427 | ||
428 | return tab; | 428 | return tab; |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | void TabDialog::iconSizeClicked ( int s ) | 432 | void TabDialog::iconSizeClicked ( int s ) |
433 | { | 433 | { |
434 | m_sample-> setViewMode ((TabConfig::ViewMode) s ); | 434 | m_sample-> setViewMode ((TabConfig::ViewMode) s ); |
435 | } | 435 | } |
436 | 436 | ||
437 | void TabDialog::fontClicked ( const QFont &f ) | 437 | void TabDialog::fontClicked ( const QFont &f ) |
438 | { | 438 | { |
439 | m_sample-> setViewFont ( f ); | 439 | m_sample-> setViewFont ( f ); |
440 | } | 440 | } |
441 | 441 | ||
442 | void TabDialog::bgTypeClicked ( int t ) | 442 | void TabDialog::bgTypeClicked ( int t ) |
443 | { | 443 | { |
444 | QString s; | 444 | QString s; |
445 | 445 | ||
446 | if ( m_bgtype-> id ( m_bgtype-> selected ( )) != t ) | 446 | if ( m_bgtype-> id ( m_bgtype-> selected ( )) != t ) |
447 | m_bgtype-> setButton ( t ); | 447 | m_bgtype-> setButton ( t ); |
448 | 448 | ||
449 | m_solidcolor-> setEnabled ( t == TabConfig::SolidColor ); | 449 | m_solidcolor-> setEnabled ( t == TabConfig::SolidColor ); |
450 | m_imagebrowse-> setEnabled ( t == TabConfig::Image ); | 450 | m_imagebrowse-> setEnabled ( t == TabConfig::Image ); |
451 | 451 | ||
452 | if ( t == TabConfig::SolidColor ) | 452 | if ( t == TabConfig::SolidColor ) |
453 | s = m_solidcolor-> color ( ). name ( ); | 453 | s = m_solidcolor-> color ( ). name ( ); |
454 | else if ( t == TabConfig::Image ) | 454 | else if ( t == TabConfig::Image ) |
455 | s = Resource::findPixmap ( m_bgimage ); | 455 | s = Resource::findPixmap ( m_bgimage ); |
456 | 456 | ||
457 | m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s ); | 457 | m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s ); |
458 | } | 458 | } |
459 | 459 | ||
460 | void TabDialog::bgColorClicked ( const QColor & ) | 460 | void TabDialog::bgColorClicked ( const QColor & ) |
461 | { | 461 | { |
462 | bgTypeClicked ( TabConfig::SolidColor ); | 462 | bgTypeClicked ( TabConfig::SolidColor ); |
463 | } | 463 | } |
464 | 464 | ||
465 | void TabDialog::iconColorClicked ( const QColor &col ) | 465 | void TabDialog::iconColorClicked ( const QColor &col ) |
466 | { | 466 | { |
467 | m_sample-> setTextColor ( col ); | 467 | m_sample-> setTextColor ( col ); |
468 | } | 468 | } |
469 | 469 | ||
470 | void TabDialog::bgImageClicked ( ) | 470 | void TabDialog::bgImageClicked ( ) |
471 | { | 471 | { |
472 | // ### use OFileSelector here ### | 472 | // ### use OFileSelector here ### |
473 | // this is just a quick c&p from the old appearance app | 473 | // this is just a quick c&p from the old appearance app |
474 | 474 | ||
475 | MimeTypes types; | 475 | MimeTypes types; |
476 | QStringList list; | 476 | QStringList list; |
477 | list << "image/*"; | 477 | list << "image/*"; |
478 | types. insert ( "Images", list ); | 478 | types. insert ( "Images", list ); |
479 | 479 | ||
480 | QString file = OFileDialog::getOpenFileName ( 1, "/", QString::null, types ); | 480 | QString file = OFileDialog::getOpenFileName ( 1, "/", QString::null, types ); |
481 | if ( !file. isEmpty ( )) { | 481 | if ( !file. isEmpty ( )) { |
482 | m_bgimage = DocLnk ( file ). file ( ); | 482 | m_bgimage = DocLnk ( file ). file ( ); |
483 | bgTypeClicked ( TabConfig::Image ); | 483 | bgTypeClicked ( TabConfig::Image ); |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | void TabDialog::bgDefaultClicked ( ) | 487 | void TabDialog::bgDefaultClicked ( ) |
488 | { | 488 | { |
489 | m_bgimage = "launcher/opie-background"; | 489 | m_bgimage = "launcher/opie-background"; |
490 | bgTypeClicked ( TabConfig::Image ); | 490 | bgTypeClicked ( TabConfig::Image ); |
491 | } | 491 | } |
492 | 492 | ||
493 | void TabDialog::accept ( ) | 493 | void TabDialog::accept ( ) |
494 | { | 494 | { |
495 | m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); | 495 | m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); |
496 | m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); | 496 | m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); |
497 | m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); | 497 | m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); |
498 | m_tc. m_bg_image = m_bgimage; | 498 | m_tc. m_bg_image = m_bgimage; |
499 | m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); | 499 | m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); |
500 | 500 | ||
501 | m_tc. m_font_use = m_fontuse-> isChecked ( ); | 501 | m_tc. m_font_use = m_fontuse-> isChecked ( ); |
502 | 502 | ||
503 | if ( m_tc. m_font_use ) { | 503 | if ( m_tc. m_font_use ) { |
504 | QFont f = m_fontselect-> selectedFont ( ); | 504 | QFont f = m_fontselect-> selectedFont ( ); |
505 | 505 | ||
506 | m_tc. m_font_family = f. family ( ); | 506 | m_tc. m_font_family = f. family ( ); |
507 | m_tc. m_font_size = f. pointSize ( ); | 507 | m_tc. m_font_size = f. pointSize ( ); |
508 | m_tc. m_font_weight = f. weight ( ); | 508 | m_tc. m_font_weight = f. weight ( ); |
509 | m_tc. m_font_italic = f. italic ( ); | 509 | m_tc. m_font_italic = f. italic ( ); |
510 | } | 510 | } |
511 | 511 | ||
512 | QDialog::accept ( ); | 512 | QDialog::accept ( ); |
513 | } | 513 | } |
diff --git a/core/settings/launcher/tabssettings.cpp b/core/settings/launcher/tabssettings.cpp index 17a1609..e5a7087 100644 --- a/core/settings/launcher/tabssettings.cpp +++ b/core/settings/launcher/tabssettings.cpp | |||
@@ -1,269 +1,269 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "tabssettings.h" | 28 | #include "tabssettings.h" |
29 | 29 | ||
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/mimetype.h> | 32 | #include <qpe/mimetype.h> |
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | 36 | ||
37 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qwhatsthis.h> | 41 | #include <qwhatsthis.h> |
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | 43 | ||
44 | #include "tabdialog.h" | 44 | #include "tabdialog.h" |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | 48 | ||
49 | 49 | ||
50 | #define GLOBALID ".global." | 50 | #define GLOBALID ".global." |
51 | 51 | ||
52 | 52 | ||
53 | TabsSettings::TabsSettings ( QWidget *parent, const char *name ) | 53 | TabsSettings::TabsSettings ( QWidget *parent, const char *name ) |
54 | : QWidget ( parent, name ) | 54 | : QWidget ( parent, name ) |
55 | { | 55 | { |
56 | QGridLayout *lay = new QGridLayout ( this, 0, 0, 4, 4 ); | 56 | QGridLayout *lay = new QGridLayout ( this, 0, 0, 4, 4 ); |
57 | 57 | ||
58 | QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this ); | 58 | QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this ); |
59 | lay-> addMultiCellWidget ( l, 0, 0, 0, 1 ); | 59 | lay-> addMultiCellWidget ( l, 0, 0, 0, 1 ); |
60 | 60 | ||
61 | m_list = new QListBox ( this ); | 61 | m_list = new QListBox ( this ); |
62 | lay-> addMultiCellWidget ( m_list, 1, 4, 0, 0 ); | 62 | lay-> addMultiCellWidget ( m_list, 1, 4, 0, 0 ); |
63 | 63 | ||
64 | QWhatsThis::add ( m_list, tr( "foobar" )); | 64 | QWhatsThis::add ( m_list, tr( "foobar" )); |
65 | 65 | ||
66 | QPushButton *p1, *p2, *p3; | 66 | QPushButton *p1, *p2, *p3; |
67 | p1 = new QPushButton ( tr( "New" ), this ); | 67 | p1 = new QPushButton ( tr( "New" ), this ); |
68 | lay-> addWidget ( p1, 1, 1 ); | 68 | lay-> addWidget ( p1, 1, 1 ); |
69 | connect ( p1, SIGNAL( clicked ( )), this, SLOT( newClicked ( ))); | 69 | connect ( p1, SIGNAL( clicked()), this, SLOT( newClicked())); |
70 | 70 | ||
71 | p2 = new QPushButton ( tr( "Edit" ), this ); | 71 | p2 = new QPushButton ( tr( "Edit" ), this ); |
72 | lay-> addWidget ( p2, 2, 1 ); | 72 | lay-> addWidget ( p2, 2, 1 ); |
73 | connect ( p2, SIGNAL( clicked ( )), this, SLOT( editClicked ( ))); | 73 | connect ( p2, SIGNAL( clicked()), this, SLOT( editClicked())); |
74 | 74 | ||
75 | p3 = new QPushButton ( tr( "Delete" ), this ); | 75 | p3 = new QPushButton ( tr( "Delete" ), this ); |
76 | lay-> addWidget ( p3, 3, 1 ); | 76 | lay-> addWidget ( p3, 3, 1 ); |
77 | connect ( p3, SIGNAL( clicked ( )), this, SLOT( deleteClicked ( ))); | 77 | connect ( p3, SIGNAL( clicked()), this, SLOT( deleteClicked())); |
78 | 78 | ||
79 | lay-> setRowStretch ( 4, 10 ); | 79 | lay-> setRowStretch ( 4, 10 ); |
80 | 80 | ||
81 | m_bigbusy = new QCheckBox( tr( "Enable big busy indicator" ), this ); | 81 | m_bigbusy = new QCheckBox( tr( "Enable big busy indicator" ), this ); |
82 | lay-> addMultiCellWidget ( m_bigbusy, 5, 5, 0, 1 ); | 82 | lay-> addMultiCellWidget ( m_bigbusy, 5, 5, 0, 1 ); |
83 | 83 | ||
84 | m_busyani = new QCheckBox ( tr( "Enable animated busy indicator" ), this ); | 84 | m_busyani = new QCheckBox ( tr( "Enable animated busy indicator" ), this ); |
85 | lay-> addMultiCellWidget ( m_busyani, 6, 6, 0, 1 ); | 85 | lay-> addMultiCellWidget ( m_busyani, 6, 6, 0, 1 ); |
86 | 86 | ||
87 | p1-> setEnabled ( false ); | 87 | p1-> setEnabled ( false ); |
88 | p3-> setEnabled ( false ); | 88 | p3-> setEnabled ( false ); |
89 | 89 | ||
90 | init ( ); | 90 | init ( ); |
91 | 91 | ||
92 | QWhatsThis::add ( m_list, tr( "Select the Launcher Tab you want to edit or delete." )); | 92 | QWhatsThis::add ( m_list, tr( "Select the Launcher Tab you want to edit or delete." )); |
93 | QWhatsThis::add ( p1, tr( "Adds a new Tab to the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); | 93 | QWhatsThis::add ( p1, tr( "Adds a new Tab to the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); |
94 | QWhatsThis::add ( p2, tr( "Opens a new dialog to customize the select Tab." )); | 94 | QWhatsThis::add ( p2, tr( "Opens a new dialog to customize the select Tab." )); |
95 | QWhatsThis::add ( p3, tr( "Deletes a Tab from the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); | 95 | QWhatsThis::add ( p3, tr( "Deletes a Tab from the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); |
96 | QWhatsThis::add ( m_bigbusy, tr( "Activate this, if you want a big busy indicator in the middle of the screen instead of the one in taskbar." )); | 96 | QWhatsThis::add ( m_bigbusy, tr( "Activate this, if you want a big busy indicator in the middle of the screen instead of the one in taskbar." )); |
97 | QWhatsThis::add ( m_busyani, tr( "Activate this, if you want an animatedbusy indicator for starting applications in the Launcher." )); | 97 | QWhatsThis::add ( m_busyani, tr( "Activate this, if you want an animatedbusy indicator for starting applications in the Launcher." )); |
98 | } | 98 | } |
99 | 99 | ||
100 | void TabsSettings::init ( ) | 100 | void TabsSettings::init ( ) |
101 | { | 101 | { |
102 | AppLnkSet rootFolder( MimeType::appsFolderName ( )); | 102 | AppLnkSet rootFolder( MimeType::appsFolderName ( )); |
103 | QStringList types = rootFolder. types ( ); | 103 | QStringList types = rootFolder. types ( ); |
104 | 104 | ||
105 | m_list-> insertItem ( tr( "All Tabs" )); | 105 | m_list-> insertItem ( tr( "All Tabs" )); |
106 | m_ids << GLOBALID; | 106 | m_ids << GLOBALID; |
107 | 107 | ||
108 | for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { | 108 | for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { |
109 | m_list-> insertItem ( rootFolder. typePixmap ( *it ), rootFolder. typeName ( *it )); | 109 | m_list-> insertItem ( rootFolder. typePixmap ( *it ), rootFolder. typeName ( *it )); |
110 | m_ids << *it; | 110 | m_ids << *it; |
111 | } | 111 | } |
112 | QImage img ( Resource::loadImage ( "DocsIcon" )); | 112 | QImage img ( Resource::loadImage ( "DocsIcon" )); |
113 | QPixmap pix; | 113 | QPixmap pix; |
114 | pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( )); | 114 | pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( )); |
115 | m_list-> insertItem ( pix, tr( "Documents" )); | 115 | m_list-> insertItem ( pix, tr( "Documents" )); |
116 | m_ids += "Documents"; // No tr | 116 | m_ids += "Documents"; // No tr |
117 | 117 | ||
118 | Config cfg ( "Launcher" ); | 118 | Config cfg ( "Launcher" ); |
119 | 119 | ||
120 | readTabSettings ( cfg ); | 120 | readTabSettings ( cfg ); |
121 | 121 | ||
122 | cfg. setGroup ( "GUI" ); | 122 | cfg. setGroup ( "GUI" ); |
123 | m_busyani-> setChecked ( cfg. readEntry ( "BusyType" ). lower ( ) == "animated" ); | 123 | m_busyani-> setChecked ( cfg. readEntry ( "BusyType" ). lower ( ) == "animated" ); |
124 | m_bigbusy->setChecked( cfg. readBoolEntry ( "BigBusy" ) ); | 124 | m_bigbusy->setChecked( cfg. readBoolEntry ( "BigBusy" ) ); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void TabsSettings::readTabSettings ( Config &cfg ) | 128 | void TabsSettings::readTabSettings ( Config &cfg ) |
129 | { | 129 | { |
130 | QString grp ( "Tab %1" ); // No tr | 130 | QString grp ( "Tab %1" ); // No tr |
131 | m_tabs. clear ( ); | 131 | m_tabs. clear ( ); |
132 | 132 | ||
133 | TabConfig global_def; | 133 | TabConfig global_def; |
134 | global_def. m_view = TabConfig::Icon; | 134 | global_def. m_view = TabConfig::Icon; |
135 | global_def. m_bg_type = TabConfig::Ruled; | 135 | global_def. m_bg_type = TabConfig::Ruled; |
136 | global_def. m_bg_image = "launcher/opie-background"; | 136 | global_def. m_bg_image = "launcher/opie-background"; |
137 | global_def. m_bg_color = colorGroup ( ). color ( QColorGroup::Base ). name ( ); | 137 | global_def. m_bg_color = colorGroup ( ). color ( QColorGroup::Base ). name ( ); |
138 | global_def. m_text_color = colorGroup ( ). color ( QColorGroup::Text ). name ( ); | 138 | global_def. m_text_color = colorGroup ( ). color ( QColorGroup::Text ). name ( ); |
139 | global_def. m_font_use = false; | 139 | global_def. m_font_use = false; |
140 | global_def. m_font_family = font ( ). family ( ); | 140 | global_def. m_font_family = font ( ). family ( ); |
141 | global_def. m_font_size = font ( ). pointSize ( ); | 141 | global_def. m_font_size = font ( ). pointSize ( ); |
142 | global_def. m_font_weight = 50; | 142 | global_def. m_font_weight = 50; |
143 | global_def. m_font_italic = false; | 143 | global_def. m_font_italic = false; |
144 | global_def. m_changed = false; | 144 | global_def. m_changed = false; |
145 | 145 | ||
146 | 146 | ||
147 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 147 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
148 | TabConfig tc = ( it != m_ids. begin ( )) ? m_tabs [GLOBALID] : global_def; | 148 | TabConfig tc = ( it != m_ids. begin ( )) ? m_tabs [GLOBALID] : global_def; |
149 | 149 | ||
150 | cfg. setGroup ( grp. arg ( *it )); | 150 | cfg. setGroup ( grp. arg ( *it )); |
151 | 151 | ||
152 | QString view = cfg. readEntry ( "View" ); | 152 | QString view = cfg. readEntry ( "View" ); |
153 | if ( view == "Icon" ) // No tr | 153 | if ( view == "Icon" ) // No tr |
154 | tc. m_view = TabConfig::Icon; | 154 | tc. m_view = TabConfig::Icon; |
155 | if ( view == "List" ) // No tr | 155 | if ( view == "List" ) // No tr |
156 | tc. m_view = TabConfig::List; | 156 | tc. m_view = TabConfig::List; |
157 | 157 | ||
158 | QString bgType = cfg. readEntry ( "BackgroundType" ); | 158 | QString bgType = cfg. readEntry ( "BackgroundType" ); |
159 | if ( bgType == "Image" ) | 159 | if ( bgType == "Image" ) |
160 | tc. m_bg_type = TabConfig::Image; | 160 | tc. m_bg_type = TabConfig::Image; |
161 | else if ( bgType == "SolidColor" ) | 161 | else if ( bgType == "SolidColor" ) |
162 | tc. m_bg_type = TabConfig::SolidColor; | 162 | tc. m_bg_type = TabConfig::SolidColor; |
163 | else if ( bgType == "Image" ) // No tr | 163 | else if ( bgType == "Image" ) // No tr |
164 | tc. m_bg_type = TabConfig::Image; | 164 | tc. m_bg_type = TabConfig::Image; |
165 | 165 | ||
166 | tc. m_bg_image = cfg. readEntry ( "BackgroundImage", tc. m_bg_image ); | 166 | tc. m_bg_image = cfg. readEntry ( "BackgroundImage", tc. m_bg_image ); |
167 | tc. m_bg_color = cfg. readEntry ( "BackgroundColor", tc. m_bg_color ); | 167 | tc. m_bg_color = cfg. readEntry ( "BackgroundColor", tc. m_bg_color ); |
168 | tc. m_text_color = cfg. readEntry ( "TextColor", tc. m_text_color ); | 168 | tc. m_text_color = cfg. readEntry ( "TextColor", tc. m_text_color ); |
169 | QStringList f = cfg. readListEntry ( "Font", ',' ); | 169 | QStringList f = cfg. readListEntry ( "Font", ',' ); |
170 | if ( f. count ( ) == 4 ) { | 170 | if ( f. count ( ) == 4 ) { |
171 | tc. m_font_use = true; | 171 | tc. m_font_use = true; |
172 | tc. m_font_family = f [0]; | 172 | tc. m_font_family = f [0]; |
173 | tc. m_font_size = f [1]. toInt ( ); | 173 | tc. m_font_size = f [1]. toInt ( ); |
174 | tc. m_font_weight = f [2]. toInt ( ); | 174 | tc. m_font_weight = f [2]. toInt ( ); |
175 | tc. m_font_italic = ( f [3]. toInt ( )); | 175 | tc. m_font_italic = ( f [3]. toInt ( )); |
176 | } | 176 | } |
177 | m_tabs [*it] = tc; | 177 | m_tabs [*it] = tc; |
178 | } | 178 | } |
179 | 179 | ||
180 | // if all tabs have the same config, then initialize the GLOBALID tab to these values | 180 | // if all tabs have the same config, then initialize the GLOBALID tab to these values |
181 | 181 | ||
182 | TabConfig *first = 0; | 182 | TabConfig *first = 0; |
183 | bool same = true; | 183 | bool same = true; |
184 | 184 | ||
185 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 185 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
186 | if ( *it == GLOBALID ) | 186 | if ( *it == GLOBALID ) |
187 | continue; | 187 | continue; |
188 | else if ( !first ) | 188 | else if ( !first ) |
189 | first = &m_tabs [*it]; | 189 | first = &m_tabs [*it]; |
190 | else | 190 | else |
191 | same &= ( *first == m_tabs [*it] ); | 191 | same &= ( *first == m_tabs [*it] ); |
192 | } | 192 | } |
193 | if ( same ) { | 193 | if ( same ) { |
194 | m_tabs [GLOBALID] = *first; | 194 | m_tabs [GLOBALID] = *first; |
195 | m_tabs [GLOBALID]. m_changed = true; | 195 | m_tabs [GLOBALID]. m_changed = true; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | void TabsSettings::accept ( ) | 200 | void TabsSettings::accept ( ) |
201 | { | 201 | { |
202 | Config cfg ( "Launcher" ); | 202 | Config cfg ( "Launcher" ); |
203 | 203 | ||
204 | // Launcher Tab | 204 | // Launcher Tab |
205 | QString grp ( "Tab %1" ); // No tr | 205 | QString grp ( "Tab %1" ); // No tr |
206 | 206 | ||
207 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 207 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
208 | TabConfig &tc = m_tabs [*it]; | 208 | TabConfig &tc = m_tabs [*it]; |
209 | 209 | ||
210 | if ( !tc. m_changed ) | 210 | if ( !tc. m_changed ) |
211 | continue; | 211 | continue; |
212 | 212 | ||
213 | cfg. setGroup ( grp. arg ( *it )); | 213 | cfg. setGroup ( grp. arg ( *it )); |
214 | switch ( tc. m_view ) { | 214 | switch ( tc. m_view ) { |
215 | case TabConfig::Icon: | 215 | case TabConfig::Icon: |
216 | cfg.writeEntry ( "View", "Icon" ); | 216 | cfg.writeEntry ( "View", "Icon" ); |
217 | break; | 217 | break; |
218 | case TabConfig::List: | 218 | case TabConfig::List: |
219 | cfg.writeEntry ( "View", "List" ); | 219 | cfg.writeEntry ( "View", "List" ); |
220 | break; | 220 | break; |
221 | } | 221 | } |
222 | 222 | ||
223 | QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" ); | 223 | QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" ); |
224 | e << *it << tc. m_view; | 224 | e << *it << tc. m_view; |
225 | 225 | ||
226 | cfg. writeEntry ( "BackgroundImage", tc. m_bg_image ); | 226 | cfg. writeEntry ( "BackgroundImage", tc. m_bg_image ); |
227 | cfg. writeEntry ( "BackgroundColor", tc. m_bg_color ); | 227 | cfg. writeEntry ( "BackgroundColor", tc. m_bg_color ); |
228 | cfg. writeEntry ( "TextColor", tc. m_text_color ); | 228 | cfg. writeEntry ( "TextColor", tc. m_text_color ); |
229 | 229 | ||
230 | if ( tc. m_font_use ) { | 230 | if ( tc. m_font_use ) { |
231 | QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" ); | 231 | QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" ); |
232 | cfg. writeEntry ( "Font", f ); | 232 | cfg. writeEntry ( "Font", f ); |
233 | } | 233 | } |
234 | else | 234 | else |
235 | cfg. removeEntry ( "Font" ); | 235 | cfg. removeEntry ( "Font" ); |
236 | 236 | ||
237 | QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); | 237 | QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); |
238 | 238 | ||
239 | switch ( tc. m_bg_type ) { | 239 | switch ( tc. m_bg_type ) { |
240 | case TabConfig::Ruled: | 240 | case TabConfig::Ruled: |
241 | cfg.writeEntry( "BackgroundType", "Ruled" ); | 241 | cfg.writeEntry( "BackgroundType", "Ruled" ); |
242 | be << *it << tc. m_bg_type << QString(""); | 242 | be << *it << tc. m_bg_type << QString(""); |
243 | break; | 243 | break; |
244 | case TabConfig::SolidColor: | 244 | case TabConfig::SolidColor: |
245 | cfg.writeEntry( "BackgroundType", "SolidColor" ); | 245 | cfg.writeEntry( "BackgroundType", "SolidColor" ); |
246 | be << *it << tc. m_bg_type << tc. m_bg_color; | 246 | be << *it << tc. m_bg_type << tc. m_bg_color; |
247 | break; | 247 | break; |
248 | case TabConfig::Image: | 248 | case TabConfig::Image: |
249 | cfg.writeEntry( "BackgroundType", "Image" ); | 249 | cfg.writeEntry( "BackgroundType", "Image" ); |
250 | be << *it << tc. m_bg_type << tc. m_bg_image; | 250 | be << *it << tc. m_bg_type << tc. m_bg_image; |
251 | break; | 251 | break; |
252 | } | 252 | } |
253 | 253 | ||
254 | QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); | 254 | QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); |
255 | te << *it << tc. m_text_color; | 255 | te << *it << tc. m_text_color; |
256 | 256 | ||
257 | QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); | 257 | QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); |
258 | fe << *it; | 258 | fe << *it; |
259 | fe << ( tc. m_font_use ? tc. m_font_family : QString::null ); | 259 | fe << ( tc. m_font_use ? tc. m_font_family : QString::null ); |
260 | fe << tc. m_font_size; | 260 | fe << tc. m_font_size; |
261 | fe << tc. m_font_weight; | 261 | fe << tc. m_font_weight; |
262 | fe << ( tc. m_font_italic ? 1 : 0 ); | 262 | fe << ( tc. m_font_italic ? 1 : 0 ); |
263 | 263 | ||
264 | tc. m_changed = false; | 264 | tc. m_changed = false; |
265 | } | 265 | } |
266 | cfg. setGroup ( "GUI" ); | 266 | cfg. setGroup ( "GUI" ); |
267 | QString busytype = QString ( m_busyani-> isChecked ( ) ? "Animated" : "" ); | 267 | QString busytype = QString ( m_busyani-> isChecked ( ) ? "Animated" : "" ); |
268 | cfg. writeEntry ( "BusyType", busytype ); | 268 | cfg. writeEntry ( "BusyType", busytype ); |
269 | 269 | ||
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp index badb98f..43886c9 100644 --- a/core/settings/launcher/taskbarsettings.cpp +++ b/core/settings/launcher/taskbarsettings.cpp | |||
@@ -1,172 +1,172 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
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 "taskbarsettings.h" | 29 | #include "taskbarsettings.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/qlibrary.h> | 32 | #include <qpe/qlibrary.h> |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/taskbarappletinterface.h> | 34 | #include <qpe/taskbarappletinterface.h> |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qlistview.h> | 38 | #include <qlistview.h> |
39 | #include <qheader.h> | 39 | #include <qheader.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qwhatsthis.h> | 42 | #include <qwhatsthis.h> |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | 45 | ||
46 | 46 | ||
47 | TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) | 47 | TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) |
48 | : QWidget ( parent, name ) | 48 | : QWidget ( parent, name ) |
49 | { | 49 | { |
50 | m_applets_changed = false; | 50 | m_applets_changed = false; |
51 | 51 | ||
52 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); | 52 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); |
53 | 53 | ||
54 | QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); | 54 | QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); |
55 | lay-> addWidget ( l ); | 55 | lay-> addWidget ( l ); |
56 | 56 | ||
57 | m_list = new QListView ( this ); | 57 | m_list = new QListView ( this ); |
58 | m_list-> addColumn ( "foobar" ); | 58 | m_list-> addColumn ( "foobar" ); |
59 | m_list-> header ( )-> hide ( ); | 59 | m_list-> header ( )-> hide ( ); |
60 | 60 | ||
61 | lay-> addWidget ( m_list ); | 61 | lay-> addWidget ( m_list ); |
62 | 62 | ||
63 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); | 63 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); |
64 | 64 | ||
65 | connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); | 65 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); |
66 | 66 | ||
67 | init ( ); | 67 | init ( ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void TaskbarSettings::init ( ) | 70 | void TaskbarSettings::init ( ) |
71 | { | 71 | { |
72 | Config cfg ( "Taskbar" ); | 72 | Config cfg ( "Taskbar" ); |
73 | cfg. setGroup ( "Applets" ); | 73 | cfg. setGroup ( "Applets" ); |
74 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); | 74 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); |
75 | 75 | ||
76 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; | 76 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; |
77 | #ifdef Q_OS_MACX | 77 | #ifdef Q_OS_MACX |
78 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); | 78 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); |
79 | #else | 79 | #else |
80 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); | 80 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); |
81 | #endif /* Q_OS_MACX */ | 81 | #endif /* Q_OS_MACX */ |
82 | 82 | ||
83 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { | 83 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { |
84 | QString name; | 84 | QString name; |
85 | QPixmap icon; | 85 | QPixmap icon; |
86 | TaskbarNamedAppletInterface *iface = 0; | 86 | TaskbarNamedAppletInterface *iface = 0; |
87 | 87 | ||
88 | qWarning("Load applet: %s", (*it).latin1() ); | 88 | qWarning("Load applet: %s", (*it).latin1() ); |
89 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 89 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
90 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); | 90 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); |
91 | qWarning("<1>"); | 91 | qWarning("<1>"); |
92 | if ( iface ) { | 92 | if ( iface ) { |
93 | qWarning("<2>"); | 93 | qWarning("<2>"); |
94 | QString lang = getenv( "LANG" ); | 94 | QString lang = getenv( "LANG" ); |
95 | QTranslator *trans = new QTranslator ( qApp ); | 95 | QTranslator *trans = new QTranslator ( qApp ); |
96 | QString type = (*it). left ((*it). find (".")); | 96 | QString type = (*it). left ((*it). find (".")); |
97 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; | 97 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; |
98 | if ( trans-> load ( tfn )) | 98 | if ( trans-> load ( tfn )) |
99 | qApp-> installTranslator ( trans ); | 99 | qApp-> installTranslator ( trans ); |
100 | else | 100 | else |
101 | delete trans; | 101 | delete trans; |
102 | name = iface-> name ( ); | 102 | name = iface-> name ( ); |
103 | icon = iface-> icon ( ); | 103 | icon = iface-> icon ( ); |
104 | iface-> release ( ); | 104 | iface-> release ( ); |
105 | } | 105 | } |
106 | qWarning("<3>"); | 106 | qWarning("<3>"); |
107 | if ( !iface ) { | 107 | if ( !iface ) { |
108 | qWarning("<4>"); | 108 | qWarning("<4>"); |
109 | lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); | 109 | lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); |
110 | 110 | ||
111 | if ( iface ) { | 111 | if ( iface ) { |
112 | qWarning("<5>"); | 112 | qWarning("<5>"); |
113 | name = (*it). mid ( 3 ); | 113 | name = (*it). mid ( 3 ); |
114 | qWarning("Found applet: %s", name.latin1() ); | 114 | qWarning("Found applet: %s", name.latin1() ); |
115 | #ifdef Q_OS_MACX | 115 | #ifdef Q_OS_MACX |
116 | int sep = name. find( ".dylib" ); | 116 | int sep = name. find( ".dylib" ); |
117 | #else | 117 | #else |
118 | int sep = name. find( ".so" ); | 118 | int sep = name. find( ".so" ); |
119 | #endif /* Q_OS_MACX */ | 119 | #endif /* Q_OS_MACX */ |
120 | if ( sep > 0 ) | 120 | if ( sep > 0 ) |
121 | name. truncate ( sep ); | 121 | name. truncate ( sep ); |
122 | sep = name. find ( "applet" ); | 122 | sep = name. find ( "applet" ); |
123 | if ( sep == (int) name.length ( ) - 6 ) | 123 | if ( sep == (int) name.length ( ) - 6 ) |
124 | name. truncate ( sep ); | 124 | name. truncate ( sep ); |
125 | name[0] = name[0]. upper ( ); | 125 | name[0] = name[0]. upper ( ); |
126 | iface-> release ( ); | 126 | iface-> release ( ); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | qWarning("<6>"); | 129 | qWarning("<6>"); |
130 | 130 | ||
131 | if ( iface ) { | 131 | if ( iface ) { |
132 | qWarning("<7>"); | 132 | qWarning("<7>"); |
133 | QCheckListItem *item; | 133 | QCheckListItem *item; |
134 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); | 134 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); |
135 | if ( !icon. isNull ( )) | 135 | if ( !icon. isNull ( )) |
136 | item-> setPixmap ( 0, icon ); | 136 | item-> setPixmap ( 0, icon ); |
137 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); | 137 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); |
138 | m_applets [*it] = item; | 138 | m_applets [*it] = item; |
139 | } | 139 | } |
140 | lib-> unload ( ); | 140 | lib-> unload ( ); |
141 | delete lib; | 141 | delete lib; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void TaskbarSettings::appletChanged() | 145 | void TaskbarSettings::appletChanged() |
146 | { | 146 | { |
147 | m_applets_changed = true; | 147 | m_applets_changed = true; |
148 | } | 148 | } |
149 | 149 | ||
150 | void TaskbarSettings::accept ( ) | 150 | void TaskbarSettings::accept ( ) |
151 | { | 151 | { |
152 | Config cfg ( "Taskbar" ); | 152 | Config cfg ( "Taskbar" ); |
153 | cfg. setGroup ( "Applets" ); | 153 | cfg. setGroup ( "Applets" ); |
154 | 154 | ||
155 | if ( m_applets_changed ) { | 155 | if ( m_applets_changed ) { |
156 | QStringList exclude; | 156 | QStringList exclude; |
157 | QMap <QString, QCheckListItem *>::Iterator it; | 157 | QMap <QString, QCheckListItem *>::Iterator it; |
158 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { | 158 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { |
159 | if ( !(*it)-> isOn ( )) | 159 | if ( !(*it)-> isOn ( )) |
160 | exclude << it. key ( ); | 160 | exclude << it. key ( ); |
161 | } | 161 | } |
162 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); | 162 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); |
163 | } | 163 | } |
164 | cfg. writeEntry ( "SafeMode", false ); | 164 | cfg. writeEntry ( "SafeMode", false ); |
165 | cfg. write ( ); | 165 | cfg. write ( ); |
166 | 166 | ||
167 | if ( m_applets_changed ) { | 167 | if ( m_applets_changed ) { |
168 | QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); | 168 | QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); |
169 | m_applets_changed = false; | 169 | m_applets_changed = false; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index 4baff8e..ce45836 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp | |||
@@ -1,313 +1,313 @@ | |||
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 | 36 | ||
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qslider.h> | 40 | #include <qslider.h> |
41 | #include <qspinbox.h> | 41 | #include <qspinbox.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qgroupbox.h> | 43 | #include <qgroupbox.h> |
44 | #include <qcombobox.h> | 44 | #include <qcombobox.h> |
45 | 45 | ||
46 | #include <opie/odevice.h> | 46 | #include <opie/odevice.h> |
47 | 47 | ||
48 | #include "sensor.h" | 48 | #include "sensor.h" |
49 | 49 | ||
50 | using namespace Opie; | 50 | using namespace Opie; |
51 | 51 | ||
52 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | 52 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) |
53 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) | 53 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) |
54 | { | 54 | { |
55 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); | 55 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); |
56 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); | 56 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); |
57 | 57 | ||
58 | // check whether to show the light sensor stuff | 58 | // check whether to show the light sensor stuff |
59 | 59 | ||
60 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { | 60 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { |
61 | auto_brightness-> hide ( ); | 61 | auto_brightness-> hide ( ); |
62 | CalibrateLightSensor-> hide ( ); | 62 | CalibrateLightSensor-> hide ( ); |
63 | auto_brightness_ac-> hide ( ); | 63 | auto_brightness_ac-> hide ( ); |
64 | CalibrateLightSensor_ac-> hide ( ); | 64 | CalibrateLightSensor_ac-> hide ( ); |
65 | } | 65 | } |
66 | 66 | ||
67 | // check whether to show the contrast stuff | 67 | // check whether to show the contrast stuff |
68 | 68 | ||
69 | if (m_cres) { | 69 | if (m_cres) { |
70 | GroupLight->setTitle(tr("Backlight && Contrast")); | 70 | GroupLight->setTitle(tr("Backlight && Contrast")); |
71 | GroupLight_ac->setTitle(GroupLight->title()); | 71 | GroupLight_ac->setTitle(GroupLight->title()); |
72 | } else { | 72 | } else { |
73 | contrast->hide(); | 73 | contrast->hide(); |
74 | contrast_ac->hide(); | 74 | contrast_ac->hide(); |
75 | } | 75 | } |
76 | 76 | ||
77 | // check whether to show the cpu frequency stuff | 77 | // check whether to show the cpu frequency stuff |
78 | 78 | ||
79 | QStrList freq = ODevice::inst()->allowedCpuFrequencies(); | 79 | QStrList freq = ODevice::inst()->allowedCpuFrequencies(); |
80 | if ( freq.count() ) { | 80 | if ( freq.count() ) { |
81 | frequency->insertStrList( freq ); | 81 | frequency->insertStrList( freq ); |
82 | frequency_ac->insertStrList( freq ); | 82 | frequency_ac->insertStrList( freq ); |
83 | } else { | 83 | } else { |
84 | frequencyLabel->hide(); | 84 | frequencyLabel->hide(); |
85 | frequency->hide(); | 85 | frequency->hide(); |
86 | frequencyLabel_ac->hide(); | 86 | frequencyLabel_ac->hide(); |
87 | frequency_ac->hide(); | 87 | frequency_ac->hide(); |
88 | } | 88 | } |
89 | 89 | ||
90 | // check whether to show the hinge action stuff | 90 | // check whether to show the hinge action stuff |
91 | 91 | ||
92 | if ( !ODevice::inst()->hasHingeSensor() ) { | 92 | if ( !ODevice::inst()->hasHingeSensor() ) { |
93 | closeHingeLabel->hide(); | 93 | closeHingeLabel->hide(); |
94 | closeHingeAction->hide(); | 94 | closeHingeAction->hide(); |
95 | closeHingeLabel_ac->hide(); | 95 | closeHingeLabel_ac->hide(); |
96 | closeHingeAction_ac->hide(); | 96 | closeHingeAction_ac->hide(); |
97 | } | 97 | } |
98 | 98 | ||
99 | Config config ( "apm" ); | 99 | Config config ( "apm" ); |
100 | config. setGroup ( "Battery" ); | 100 | config. setGroup ( "Battery" ); |
101 | 101 | ||
102 | // battery spinboxes | 102 | // battery spinboxes |
103 | interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); | 103 | interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); |
104 | interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); | 104 | interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); |
105 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); | 105 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); |
106 | 106 | ||
107 | // battery check and slider | 107 | // battery check and slider |
108 | LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 108 | LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
109 | 109 | ||
110 | // CPU frequency | 110 | // CPU frequency |
111 | frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); | 111 | frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); |
112 | 112 | ||
113 | // hinge action | 113 | // hinge action |
114 | closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); | 114 | closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); |
115 | 115 | ||
116 | int bright = config. readNumEntry ( "Brightness", 127 ); | 116 | int bright = config. readNumEntry ( "Brightness", 127 ); |
117 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); | 117 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); |
118 | brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); | 118 | brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
119 | brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); | 119 | brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); |
120 | brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); | 120 | brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); |
121 | brightness-> setValue ( bright ); | 121 | brightness-> setValue ( bright ); |
122 | 122 | ||
123 | if (m_cres) { | 123 | if (m_cres) { |
124 | contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); | 124 | contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
125 | contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); | 125 | contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); |
126 | contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); | 126 | contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); |
127 | contrast-> setValue ( contr ); | 127 | contrast-> setValue ( contr ); |
128 | } | 128 | } |
129 | 129 | ||
130 | // light sensor | 130 | // light sensor |
131 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 131 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
132 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); | 132 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); |
133 | 133 | ||
134 | config. setGroup ( "AC" ); | 134 | config. setGroup ( "AC" ); |
135 | 135 | ||
136 | // ac spinboxes | 136 | // ac spinboxes |
137 | interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); | 137 | interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); |
138 | interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); | 138 | interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); |
139 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); | 139 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); |
140 | 140 | ||
141 | // ac check and slider | 141 | // ac check and slider |
142 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 142 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
143 | 143 | ||
144 | // CPU frequency | 144 | // CPU frequency |
145 | frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); | 145 | frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); |
146 | 146 | ||
147 | // hinge action | 147 | // hinge action |
148 | closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); | 148 | closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); |
149 | 149 | ||
150 | bright = config. readNumEntry ( "Brightness", 255 ); | 150 | bright = config. readNumEntry ( "Brightness", 255 ); |
151 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); | 151 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
152 | brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); | 152 | brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); |
153 | brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); | 153 | brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); |
154 | brightness_ac-> setValue ( bright ); | 154 | brightness_ac-> setValue ( bright ); |
155 | 155 | ||
156 | if (m_cres) { | 156 | if (m_cres) { |
157 | contr = config. readNumEntry ( "Contrast", 127); | 157 | contr = config. readNumEntry ( "Contrast", 127); |
158 | contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); | 158 | contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
159 | contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); | 159 | contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); |
160 | contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); | 160 | contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); |
161 | contrast_ac-> setValue ( contr ); | 161 | contrast_ac-> setValue ( contr ); |
162 | } | 162 | } |
163 | 163 | ||
164 | // light sensor | 164 | // light sensor |
165 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 165 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
166 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); | 166 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); |
167 | 167 | ||
168 | // warnings | 168 | // warnings |
169 | config. setGroup ( "Warnings" ); | 169 | config. setGroup ( "Warnings" ); |
170 | warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); | 170 | warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); |
171 | lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); | 171 | lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); |
172 | criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); | 172 | criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); |
173 | 173 | ||
174 | m_resettimer = new QTimer ( this ); | 174 | m_resettimer = new QTimer ( this ); |
175 | connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); | 175 | connect ( m_resettimer, SIGNAL( timeout()), this, SLOT( resetBacklight())); |
176 | 176 | ||
177 | if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { | 177 | if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { |
178 | tabs-> setCurrentPage ( 0 ); | 178 | tabs-> setCurrentPage ( 0 ); |
179 | } | 179 | } |
180 | else { | 180 | else { |
181 | tabs-> setCurrentPage ( 1 ); | 181 | tabs-> setCurrentPage ( 1 ); |
182 | } | 182 | } |
183 | 183 | ||
184 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 184 | connect ( brightness, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int))); |
185 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 185 | connect ( brightness_ac, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int))); |
186 | if (m_cres) { | 186 | if (m_cres) { |
187 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 187 | connect ( contrast, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int))); |
188 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 188 | connect ( contrast_ac, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int))); |
189 | } | 189 | } |
190 | connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); | 190 | connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); |
191 | connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); | 191 | connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); |
192 | connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); | 192 | connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); |
193 | connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); | 193 | connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); |
194 | } | 194 | } |
195 | 195 | ||
196 | LightSettings::~LightSettings ( ) | 196 | LightSettings::~LightSettings ( ) |
197 | { | 197 | { |
198 | } | 198 | } |
199 | 199 | ||
200 | void LightSettings::calibrateSensor ( ) | 200 | void LightSettings::calibrateSensor ( ) |
201 | { | 201 | { |
202 | Sensor *s = new Sensor ( m_sensordata, this ); | 202 | Sensor *s = new Sensor ( m_sensordata, this ); |
203 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); | 203 | connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int))); |
204 | QPEApplication::execDialog( s ); | 204 | QPEApplication::execDialog( s ); |
205 | delete s; | 205 | delete s; |
206 | } | 206 | } |
207 | 207 | ||
208 | void LightSettings::calibrateSensorAC ( ) | 208 | void LightSettings::calibrateSensorAC ( ) |
209 | { | 209 | { |
210 | Sensor *s = new Sensor ( m_sensordata_ac, this ); | 210 | Sensor *s = new Sensor ( m_sensordata_ac, this ); |
211 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); | 211 | connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int))); |
212 | QPEApplication::execDialog ( s ); | 212 | QPEApplication::execDialog ( s ); |
213 | delete s; | 213 | delete s; |
214 | } | 214 | } |
215 | 215 | ||
216 | void LightSettings::setBacklight ( int bright ) | 216 | void LightSettings::setBacklight ( int bright ) |
217 | { | 217 | { |
218 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); | 218 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); |
219 | e << bright; | 219 | e << bright; |
220 | 220 | ||
221 | if ( bright != -1 ) { | 221 | if ( bright != -1 ) { |
222 | m_resettimer-> stop ( ); | 222 | m_resettimer-> stop ( ); |
223 | m_resettimer-> start ( 4000, true ); | 223 | m_resettimer-> start ( 4000, true ); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | void LightSettings::setContrast ( int contr ) | 227 | void LightSettings::setContrast ( int contr ) |
228 | { | 228 | { |
229 | if (contr == -1) contr = m_oldcontrast; | 229 | if (contr == -1) contr = m_oldcontrast; |
230 | ODevice::inst ( )-> setDisplayContrast(contr); | 230 | ODevice::inst ( )-> setDisplayContrast(contr); |
231 | } | 231 | } |
232 | 232 | ||
233 | void LightSettings::setFrequency ( int index ) | 233 | void LightSettings::setFrequency ( int index ) |
234 | { | 234 | { |
235 | qWarning("LightSettings::setFrequency(%d)", index); | 235 | qWarning("LightSettings::setFrequency(%d)", index); |
236 | ODevice::inst ( )-> setCurrentCpuFrequency(index); | 236 | ODevice::inst ( )-> setCurrentCpuFrequency(index); |
237 | } | 237 | } |
238 | 238 | ||
239 | void LightSettings::resetBacklight ( ) | 239 | void LightSettings::resetBacklight ( ) |
240 | { | 240 | { |
241 | setBacklight ( -1 ); | 241 | setBacklight ( -1 ); |
242 | setContrast ( -1 ); | 242 | setContrast ( -1 ); |
243 | } | 243 | } |
244 | 244 | ||
245 | void LightSettings::setCloseHingeAction ( int index ) | 245 | void LightSettings::setCloseHingeAction ( int index ) |
246 | { | 246 | { |
247 | qWarning("LightSettings::setCloseHingeStatus(%d)", index); | 247 | qWarning("LightSettings::setCloseHingeStatus(%d)", index); |
248 | } | 248 | } |
249 | 249 | ||
250 | void LightSettings::accept ( ) | 250 | void LightSettings::accept ( ) |
251 | { | 251 | { |
252 | Config config ( "apm" ); | 252 | Config config ( "apm" ); |
253 | 253 | ||
254 | // bat | 254 | // bat |
255 | config. setGroup ( "Battery" ); | 255 | config. setGroup ( "Battery" ); |
256 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); | 256 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); |
257 | config. writeEntry ( "Dim", interval_dim-> value ( )); | 257 | config. writeEntry ( "Dim", interval_dim-> value ( )); |
258 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); | 258 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); |
259 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); | 259 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); |
260 | config. writeEntry ( "Brightness", brightness-> value () ); | 260 | config. writeEntry ( "Brightness", brightness-> value () ); |
261 | if (m_cres) | 261 | if (m_cres) |
262 | config. writeEntry ( "Contrast", contrast-> value () ); | 262 | config. writeEntry ( "Contrast", contrast-> value () ); |
263 | config. writeEntry ( "Freq", frequency->currentItem() ); | 263 | config. writeEntry ( "Freq", frequency->currentItem() ); |
264 | config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); | 264 | config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); |
265 | 265 | ||
266 | // ac | 266 | // ac |
267 | config. setGroup ( "AC" ); | 267 | config. setGroup ( "AC" ); |
268 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); | 268 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); |
269 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); | 269 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); |
270 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); | 270 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); |
271 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); | 271 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); |
272 | config. writeEntry ( "Brightness", brightness_ac-> value () ); | 272 | config. writeEntry ( "Brightness", brightness_ac-> value () ); |
273 | if (m_cres) | 273 | if (m_cres) |
274 | config. writeEntry ( "Contrast", contrast_ac-> value () ); | 274 | config. writeEntry ( "Contrast", contrast_ac-> value () ); |
275 | config. writeEntry ( "Freq", frequency_ac->currentItem() ); | 275 | config. writeEntry ( "Freq", frequency_ac->currentItem() ); |
276 | config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); | 276 | config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); |
277 | 277 | ||
278 | // only make light sensor stuff appear if the unit has a sensor | 278 | // only make light sensor stuff appear if the unit has a sensor |
279 | if ( ODevice::inst ( )-> hasLightSensor ( )) { | 279 | if ( ODevice::inst ( )-> hasLightSensor ( )) { |
280 | config. setGroup ( "Battery" ); | 280 | config. setGroup ( "Battery" ); |
281 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); | 281 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); |
282 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); | 282 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); |
283 | config. setGroup ( "AC" ); | 283 | config. setGroup ( "AC" ); |
284 | config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); | 284 | config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); |
285 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); | 285 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); |
286 | } | 286 | } |
287 | 287 | ||
288 | // advanced | 288 | // advanced |
289 | config. setGroup ( "Warnings" ); | 289 | config. setGroup ( "Warnings" ); |
290 | config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); | 290 | config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); |
291 | config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); | 291 | config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); |
292 | config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); | 292 | config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); |
293 | config. write ( ); | 293 | config. write ( ); |
294 | 294 | ||
295 | // notify the launcher | 295 | // notify the launcher |
296 | { | 296 | { |
297 | QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); | 297 | QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); |
298 | } | 298 | } |
299 | { | 299 | { |
300 | QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); | 300 | QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); |
301 | e << -1; | 301 | e << -1; |
302 | } | 302 | } |
303 | LightSettingsBase::accept ( ); | 303 | LightSettingsBase::accept ( ); |
304 | } | 304 | } |
305 | 305 | ||
306 | void LightSettings::done ( int r ) | 306 | void LightSettings::done ( int r ) |
307 | { | 307 | { |
308 | m_resettimer-> stop ( ); | 308 | m_resettimer-> stop ( ); |
309 | resetBacklight ( ); | 309 | resetBacklight ( ); |
310 | 310 | ||
311 | LightSettingsBase::done ( r ); | 311 | LightSettingsBase::done ( r ); |
312 | close ( ); | 312 | close ( ); |
313 | } | 313 | } |
diff --git a/core/settings/light-and-power/sensor.cpp b/core/settings/light-and-power/sensor.cpp index 41de851..013e655 100644 --- a/core/settings/light-and-power/sensor.cpp +++ b/core/settings/light-and-power/sensor.cpp | |||
@@ -1,102 +1,102 @@ | |||
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 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qslider.h> | 29 | #include <qslider.h> |
30 | #include <qspinbox.h> | 30 | #include <qspinbox.h> |
31 | 31 | ||
32 | #include <opie/odevice.h> | 32 | #include <opie/odevice.h> |
33 | 33 | ||
34 | using namespace Opie; | 34 | using namespace Opie; |
35 | 35 | ||
36 | #include "calibration.h" | 36 | #include "calibration.h" |
37 | #include "sensor.h" | 37 | #include "sensor.h" |
38 | 38 | ||
39 | Sensor::Sensor ( QStringList ¶ms, QWidget *parent, const char *name ) | 39 | Sensor::Sensor ( QStringList ¶ms, QWidget *parent, const char *name ) |
40 | : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params ) | 40 | : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params ) |
41 | { | 41 | { |
42 | int steps = 12; | 42 | int steps = 12; |
43 | int inter = 2; | 43 | int inter = 2; |
44 | 44 | ||
45 | int smin = 40; | 45 | int smin = 40; |
46 | int smax = 215; | 46 | int smax = 215; |
47 | int lmin = 1; | 47 | int lmin = 1; |
48 | int lmax = 255; | 48 | int lmax = 255; |
49 | 49 | ||
50 | switch ( params. count ( )) { | 50 | switch ( params. count ( )) { |
51 | case 6: lmax = params [5]. toInt ( ); | 51 | case 6: lmax = params [5]. toInt ( ); |
52 | case 5: lmin = params [4]. toInt ( ); | 52 | case 5: lmin = params [4]. toInt ( ); |
53 | case 4: smax = params [3]. toInt ( ); | 53 | case 4: smax = params [3]. toInt ( ); |
54 | case 3: smin = params [2]. toInt ( ); | 54 | case 3: smin = params [2]. toInt ( ); |
55 | case 2: steps = params [1]. toInt ( ); | 55 | case 2: steps = params [1]. toInt ( ); |
56 | case 1: inter = params [0]. toInt ( ) / 1000; | 56 | case 1: inter = params [0]. toInt ( ) / 1000; |
57 | } | 57 | } |
58 | 58 | ||
59 | int xscale = ODevice::inst ( )-> lightSensorResolution ( ); | 59 | int xscale = ODevice::inst ( )-> lightSensorResolution ( ); |
60 | int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); | 60 | int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); |
61 | 61 | ||
62 | QVBoxLayout *lay = new QVBoxLayout ( frame ); | 62 | QVBoxLayout *lay = new QVBoxLayout ( frame ); |
63 | lay-> setMargin ( 2 ); | 63 | lay-> setMargin ( 2 ); |
64 | m_calib = new Calibration ( frame ); | 64 | m_calib = new Calibration ( frame ); |
65 | lay-> add ( m_calib ); | 65 | lay-> add ( m_calib ); |
66 | 66 | ||
67 | m_calib-> setScale ( QSize ( xscale, yscale )); | 67 | m_calib-> setScale ( QSize ( xscale, yscale )); |
68 | m_calib-> setLineSteps ( steps ); | 68 | m_calib-> setLineSteps ( steps ); |
69 | m_calib-> setInterval ( inter ); | 69 | m_calib-> setInterval ( inter ); |
70 | m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 )); | 70 | m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 )); |
71 | m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 )); | 71 | m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 )); |
72 | 72 | ||
73 | interval-> setValue ( inter ); | 73 | interval-> setValue ( inter ); |
74 | linesteps-> setValue ( steps ); | 74 | linesteps-> setValue ( steps ); |
75 | 75 | ||
76 | connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int ))); | 76 | connect ( interval, SIGNAL( valueChanged(int)), m_calib, SLOT( setInterval(int))); |
77 | connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int ))); | 77 | connect ( linesteps, SIGNAL( valueChanged(int)), m_calib, SLOT( setLineSteps(int))); |
78 | 78 | ||
79 | connect ( m_calib, SIGNAL( startPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & ))); | 79 | connect ( m_calib, SIGNAL( startPointChanged(const QPoint&)), this, SLOT( pointDrag(const QPoint&))); |
80 | connect ( m_calib, SIGNAL( endPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & ))); | 80 | connect ( m_calib, SIGNAL( endPointChanged(const QPoint&)), this, SLOT( pointDrag(const QPoint&))); |
81 | } | 81 | } |
82 | 82 | ||
83 | void Sensor::accept ( ) | 83 | void Sensor::accept ( ) |
84 | { | 84 | { |
85 | int xscale = ODevice::inst ( )-> lightSensorResolution ( ); | 85 | int xscale = ODevice::inst ( )-> lightSensorResolution ( ); |
86 | int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); | 86 | int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); |
87 | 87 | ||
88 | m_params. clear ( ); | 88 | m_params. clear ( ); |
89 | m_params << QString::number ( m_calib-> interval ( ) * 1000 ) | 89 | m_params << QString::number ( m_calib-> interval ( ) * 1000 ) |
90 | << QString::number ( m_calib-> lineSteps ( )) | 90 | << QString::number ( m_calib-> lineSteps ( )) |
91 | << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale ) | 91 | << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale ) |
92 | << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale ) | 92 | << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale ) |
93 | << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale ) | 93 | << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale ) |
94 | << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale ); | 94 | << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale ); |
95 | 95 | ||
96 | QDialog::accept ( ); | 96 | QDialog::accept ( ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void Sensor::pointDrag ( const QPoint &p ) | 99 | void Sensor::pointDrag ( const QPoint &p ) |
100 | { | 100 | { |
101 | emit viewBacklight ( p. y ( )); | 101 | emit viewBacklight ( p. y ( )); |
102 | } | 102 | } |
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp index cc411fd..1d6774c 100644 --- a/core/tools/quicklauncher/main.cpp +++ b/core/tools/quicklauncher/main.cpp | |||
@@ -1,265 +1,265 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpainter.h> | 21 | #include <qpainter.h> |
22 | #include <qstrlist.h> | 22 | #include <qstrlist.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qguardedptr.h> | 24 | #include <qguardedptr.h> |
25 | #include <qcopchannel_qws.h> | 25 | #include <qcopchannel_qws.h> |
26 | #define QTOPIA_INTERNAL_INITAPP | 26 | #define QTOPIA_INTERNAL_INITAPP |
27 | 27 | ||
28 | #ifdef private | 28 | #ifdef private |
29 | # undef private | 29 | # undef private |
30 | #endif | 30 | #endif |
31 | #define private public | 31 | #define private public |
32 | #include <qtopia/qpeapplication.h> | 32 | #include <qtopia/qpeapplication.h> |
33 | #undef private | 33 | #undef private |
34 | #include <stdio.h> | 34 | #include <stdio.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <sys/types.h> | 36 | #include <sys/types.h> |
37 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | 39 | ||
40 | #include "dropins.h" | 40 | #include "dropins.h" |
41 | 41 | ||
42 | static QPEApplication *app = 0; | 42 | static QPEApplication *app = 0; |
43 | static PluginLoader *loader = 0; | 43 | static PluginLoader *loader = 0; |
44 | static ApplicationInterface *appIface = 0; | 44 | static ApplicationInterface *appIface = 0; |
45 | static QGuardedPtr<QWidget> mainWindow; | 45 | static QGuardedPtr<QWidget> mainWindow; |
46 | 46 | ||
47 | #ifdef _OS_LINUX_ | 47 | #ifdef _OS_LINUX_ |
48 | static char **argv0 = 0; | 48 | static char **argv0 = 0; |
49 | static int argv_lth; | 49 | static int argv_lth; |
50 | extern char **environ; | 50 | extern char **environ; |
51 | #ifndef SPT_BUFSIZE | 51 | #ifndef SPT_BUFSIZE |
52 | #define SPT_BUFSIZE 2048 | 52 | #define SPT_BUFSIZE 2048 |
53 | #endif | 53 | #endif |
54 | #include <stdarg.h> | 54 | #include <stdarg.h> |
55 | void setproctitle (const char *fmt,...) { | 55 | void setproctitle (const char *fmt,...) { |
56 | int i; | 56 | int i; |
57 | char buf[SPT_BUFSIZE]; | 57 | char buf[SPT_BUFSIZE]; |
58 | va_list ap; | 58 | va_list ap; |
59 | 59 | ||
60 | if (!argv0) | 60 | if (!argv0) |
61 | return; | 61 | return; |
62 | 62 | ||
63 | va_start(ap, fmt); | 63 | va_start(ap, fmt); |
64 | (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); | 64 | (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); |
65 | va_end(ap); | 65 | va_end(ap); |
66 | 66 | ||
67 | i = strlen (buf); | 67 | i = strlen (buf); |
68 | if (i > argv_lth - 2) { | 68 | if (i > argv_lth - 2) { |
69 | i = argv_lth - 2; | 69 | i = argv_lth - 2; |
70 | buf[i] = '\0'; | 70 | buf[i] = '\0'; |
71 | } | 71 | } |
72 | memset(argv0[0], '\0', argv_lth); /* clear the memory area */ | 72 | memset(argv0[0], '\0', argv_lth); /* clear the memory area */ |
73 | (void) strcpy (argv0[0], buf); | 73 | (void) strcpy (argv0[0], buf); |
74 | 74 | ||
75 | argv0[1] = NULL; | 75 | argv0[1] = NULL; |
76 | } | 76 | } |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | 79 | ||
80 | class QuickLauncher : public QObject | 80 | class QuickLauncher : public QObject |
81 | { | 81 | { |
82 | Q_OBJECT | 82 | Q_OBJECT |
83 | public: | 83 | public: |
84 | QuickLauncher() : QObject() | 84 | QuickLauncher() : QObject() |
85 | { | 85 | { |
86 | QCString ch("QPE/QuickLauncher-"); | 86 | QCString ch("QPE/QuickLauncher-"); |
87 | ch += QString::number(getpid()); | 87 | ch += QString::number(getpid()); |
88 | qlChannel = new QCopChannel( ch, this); | 88 | qlChannel = new QCopChannel( ch, this); |
89 | connect( qlChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 89 | connect( qlChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
90 | this, SLOT(message(const QCString&, const QByteArray&)) ); | 90 | this, SLOT(message(const QCString&,const QByteArray&)) ); |
91 | } | 91 | } |
92 | 92 | ||
93 | static void exec( int /*argc*/, char **argv ) | 93 | static void exec( int /*argc*/, char **argv ) |
94 | { | 94 | { |
95 | QString appName = argv[0]; | 95 | QString appName = argv[0]; |
96 | int sep = appName.findRev( '/' ); | 96 | int sep = appName.findRev( '/' ); |
97 | if ( sep > 0 ) | 97 | if ( sep > 0 ) |
98 | appName = appName.mid( sep+1 ); | 98 | appName = appName.mid( sep+1 ); |
99 | 99 | ||
100 | appIface = 0; | 100 | appIface = 0; |
101 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { | 101 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { |
102 | mainWindow = appIface->createMainWindow( appName ); | 102 | mainWindow = appIface->createMainWindow( appName ); |
103 | } | 103 | } |
104 | if ( mainWindow ) { | 104 | if ( mainWindow ) { |
105 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { | 105 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { |
106 | app->showMainDocumentWidget( mainWindow ); | 106 | app->showMainDocumentWidget( mainWindow ); |
107 | } else { | 107 | } else { |
108 | app->showMainWidget( mainWindow ); | 108 | app->showMainWidget( mainWindow ); |
109 | } | 109 | } |
110 | } else { | 110 | } else { |
111 | qWarning( "Could not create application main window" ); | 111 | qWarning( "Could not create application main window" ); |
112 | exit(-1); | 112 | exit(-1); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | private slots: | 116 | private slots: |
117 | void message(const QCString &msg, const QByteArray & data) | 117 | void message(const QCString &msg, const QByteArray & data) |
118 | { | 118 | { |
119 | QStrList argList; | 119 | QStrList argList; |
120 | 120 | ||
121 | if ( msg == "execute(QStrList)" ) { | 121 | if ( msg == "execute(QStrList)" ) { |
122 | delete qlChannel; | 122 | delete qlChannel; |
123 | QDataStream stream( data, IO_ReadOnly ); | 123 | QDataStream stream( data, IO_ReadOnly ); |
124 | QStrList argList; | 124 | QStrList argList; |
125 | stream >> argList; | 125 | stream >> argList; |
126 | qDebug( "QuickLauncher execute: %s", argList.at(0) ); | 126 | qDebug( "QuickLauncher execute: %s", argList.at(0) ); |
127 | doQuickLaunch( argList ); | 127 | doQuickLaunch( argList ); |
128 | delete this; | 128 | delete this; |
129 | } else if ( msg == "execute(QString)" ) { | 129 | } else if ( msg == "execute(QString)" ) { |
130 | delete qlChannel; | 130 | delete qlChannel; |
131 | QDataStream stream( data, IO_ReadOnly ); | 131 | QDataStream stream( data, IO_ReadOnly ); |
132 | QString arg; | 132 | QString arg; |
133 | stream >> arg; | 133 | stream >> arg; |
134 | qDebug( "QuickLauncher execute: %s", arg.latin1() ); | 134 | qDebug( "QuickLauncher execute: %s", arg.latin1() ); |
135 | QStrList argList; | 135 | QStrList argList; |
136 | argList.append( arg.utf8() ); | 136 | argList.append( arg.utf8() ); |
137 | doQuickLaunch( argList ); | 137 | doQuickLaunch( argList ); |
138 | delete this; | 138 | delete this; |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | private: | 142 | private: |
143 | void doQuickLaunch( QStrList &argList ) | 143 | void doQuickLaunch( QStrList &argList ) |
144 | { | 144 | { |
145 | static int myargc = argList.count(); | 145 | static int myargc = argList.count(); |
146 | static char **myargv = new char *[myargc + 1]; | 146 | static char **myargv = new char *[myargc + 1]; |
147 | for ( int j = 0; j < myargc; j++ ) { | 147 | for ( int j = 0; j < myargc; j++ ) { |
148 | myargv[j] = new char [strlen(argList.at(j))+1]; | 148 | myargv[j] = new char [strlen(argList.at(j))+1]; |
149 | strcpy( myargv[j], argList.at(j) ); | 149 | strcpy( myargv[j], argList.at(j) ); |
150 | } | 150 | } |
151 | myargv[myargc] = NULL; | 151 | myargv[myargc] = NULL; |
152 | #ifdef _OS_LINUX_ | 152 | #ifdef _OS_LINUX_ |
153 | // Change name of process | 153 | // Change name of process |
154 | setproctitle(myargv[0]); | 154 | setproctitle(myargv[0]); |
155 | #endif | 155 | #endif |
156 | 156 | ||
157 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); | 157 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); |
158 | app->exit_loop(); | 158 | app->exit_loop(); |
159 | app->initApp( myargc, myargv ); | 159 | app->initApp( myargc, myargv ); |
160 | exec( myargc, myargv ); | 160 | exec( myargc, myargv ); |
161 | } | 161 | } |
162 | 162 | ||
163 | private: | 163 | private: |
164 | QCopChannel *qlChannel; | 164 | QCopChannel *qlChannel; |
165 | }; | 165 | }; |
166 | 166 | ||
167 | int main( int argc, char** argv ) | 167 | int main( int argc, char** argv ) |
168 | { | 168 | { |
169 | app = new QPEApplication( argc, argv ); | 169 | app = new QPEApplication( argc, argv ); |
170 | 170 | ||
171 | loader = new PluginLoader( "application" ); | 171 | loader = new PluginLoader( "application" ); |
172 | 172 | ||
173 | unsetenv( "LD_BIND_NOW" ); | 173 | unsetenv( "LD_BIND_NOW" ); |
174 | 174 | ||
175 | QCString arg0 = argv[0]; | 175 | QCString arg0 = argv[0]; |
176 | int sep = arg0.findRev( '/' ); | 176 | int sep = arg0.findRev( '/' ); |
177 | if ( sep > 0 ) | 177 | if ( sep > 0 ) |
178 | arg0 = arg0.mid( sep+1 ); | 178 | arg0 = arg0.mid( sep+1 ); |
179 | if ( arg0 != "quicklauncher" ) { | 179 | if ( arg0 != "quicklauncher" ) { |
180 | qDebug( "QuickLauncher invoked as: %s", arg0.data() ); | 180 | qDebug( "QuickLauncher invoked as: %s", arg0.data() ); |
181 | QuickLauncher::exec( argc, argv ); | 181 | QuickLauncher::exec( argc, argv ); |
182 | } else { | 182 | } else { |
183 | #ifdef _OS_LINUX_ | 183 | #ifdef _OS_LINUX_ |
184 | // Setup to change proc title | 184 | // Setup to change proc title |
185 | int i; | 185 | int i; |
186 | char **envp = environ; | 186 | char **envp = environ; |
187 | /* Move the environment so we can reuse the memory. | 187 | /* Move the environment so we can reuse the memory. |
188 | * (Code borrowed from sendmail.) */ | 188 | * (Code borrowed from sendmail.) */ |
189 | for (i = 0; envp[i] != NULL; i++) | 189 | for (i = 0; envp[i] != NULL; i++) |
190 | continue; | 190 | continue; |
191 | environ = (char **) malloc(sizeof(char *) * (i + 1)); | 191 | environ = (char **) malloc(sizeof(char *) * (i + 1)); |
192 | if (environ == NULL) | 192 | if (environ == NULL) |
193 | return -1; | 193 | return -1; |
194 | for (i = 0; envp[i] != NULL; i++) | 194 | for (i = 0; envp[i] != NULL; i++) |
195 | if ((environ[i] = strdup(envp[i])) == NULL) | 195 | if ((environ[i] = strdup(envp[i])) == NULL) |
196 | return -1; | 196 | return -1; |
197 | environ[i] = NULL; | 197 | environ[i] = NULL; |
198 | 198 | ||
199 | argv0 = argv; | 199 | argv0 = argv; |
200 | if (i > 0) | 200 | if (i > 0) |
201 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; | 201 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; |
202 | else | 202 | else |
203 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; | 203 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; |
204 | #endif | 204 | #endif |
205 | (void)new QuickLauncher(); | 205 | (void)new QuickLauncher(); |
206 | qDebug( "QuickLauncher running" ); | 206 | qDebug( "QuickLauncher running" ); |
207 | // Pre-load default fonts | 207 | // Pre-load default fonts |
208 | QFontMetrics fm( QApplication::font() ); | 208 | QFontMetrics fm( QApplication::font() ); |
209 | fm.ascent(); // causes font load. | 209 | fm.ascent(); // causes font load. |
210 | QFont f( QApplication::font() ); | 210 | QFont f( QApplication::font() ); |
211 | f.setWeight( QFont::Bold ); | 211 | f.setWeight( QFont::Bold ); |
212 | QFontMetrics fmb( f ); | 212 | QFontMetrics fmb( f ); |
213 | fmb.ascent(); // causes font load. | 213 | fmb.ascent(); // causes font load. |
214 | 214 | ||
215 | // Each of the following force internal structures/internal | 215 | // Each of the following force internal structures/internal |
216 | // initialization to be performed. This may mean allocating | 216 | // initialization to be performed. This may mean allocating |
217 | // memory that is not needed by all applications. | 217 | // memory that is not needed by all applications. |
218 | #if 0 | 218 | #if 0 |
219 | TimeZone::current().isValid(); // popuplate timezone cache | 219 | TimeZone::current().isValid(); // popuplate timezone cache |
220 | TimeString::currentDateFormat(); // create internal structures | 220 | TimeString::currentDateFormat(); // create internal structures |
221 | TimeString::currentAMPM(); | 221 | TimeString::currentAMPM(); |
222 | #endif | 222 | #endif |
223 | Resource::loadIconSet("new"); // do internal init | 223 | Resource::loadIconSet("new"); // do internal init |
224 | 224 | ||
225 | /* make sure libopie gets lined in */ | 225 | /* make sure libopie gets lined in */ |
226 | { | 226 | { |
227 | OWait item; | 227 | OWait item; |
228 | } | 228 | } |
229 | 229 | ||
230 | // Create a widget to force initialization of title bar images, etc. | 230 | // Create a widget to force initialization of title bar images, etc. |
231 | QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); | 231 | QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); |
232 | QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); | 232 | QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); |
233 | w->setGeometry( -100, -100, 10, 10 ); | 233 | w->setGeometry( -100, -100, 10, 10 ); |
234 | w->show(); | 234 | w->show(); |
235 | QTimer::singleShot( 0, w, SLOT(close()) ); | 235 | QTimer::singleShot( 0, w, SLOT(close()) ); |
236 | 236 | ||
237 | app->enter_loop(); | 237 | app->enter_loop(); |
238 | } | 238 | } |
239 | 239 | ||
240 | int rv = app->exec(); | 240 | int rv = app->exec(); |
241 | 241 | ||
242 | if ( mainWindow ) | 242 | if ( mainWindow ) |
243 | delete (QWidget*)mainWindow; | 243 | delete (QWidget*)mainWindow; |
244 | 244 | ||
245 | delete app; | 245 | delete app; |
246 | if ( appIface ) | 246 | if ( appIface ) |
247 | loader->releaseInterface( appIface ); | 247 | loader->releaseInterface( appIface ); |
248 | delete loader; | 248 | delete loader; |
249 | // Neither QLibrary nor my Dropin is a QObject and they don't depend | 249 | // Neither QLibrary nor my Dropin is a QObject and they don't depend |
250 | // on a qApp so we destroy QWidget::destroyMapper() without | 250 | // on a qApp so we destroy QWidget::destroyMapper() without |
251 | // crashing the app | 251 | // crashing the app |
252 | // | 252 | // |
253 | // The problem is there are some 'static' resources not freed | 253 | // The problem is there are some 'static' resources not freed |
254 | // in the apps and on destructing these objects are not available | 254 | // in the apps and on destructing these objects are not available |
255 | // anymore. In future fix up the apps but for now | 255 | // anymore. In future fix up the apps but for now |
256 | // we just skip deletion and hope things go well -zecke | 256 | // we just skip deletion and hope things go well -zecke |
257 | // delete app; | 257 | // delete app; |
258 | // hack instead -zecke | 258 | // hack instead -zecke |
259 | // delete app->pidChannel; | 259 | // delete app->pidChannel; |
260 | // app->pidChannel = 0; | 260 | // app->pidChannel = 0; |
261 | 261 | ||
262 | return rv; | 262 | return rv; |
263 | } | 263 | } |
264 | 264 | ||
265 | #include "main.moc" | 265 | #include "main.moc" |