author | zecke <zecke> | 2002-06-23 14:19:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-23 14:19:13 (UTC) |
commit | ce9178fb13908eca5b7835e785fc0914a5022615 (patch) (unidiff) | |
tree | d848ef07fb25ba6c21d3729140c4e3be9d69f6f6 | |
parent | 3b02ead2254e59159db948d2a0980892eeb14ed8 (diff) | |
download | opie-ce9178fb13908eca5b7835e785fc0914a5022615.zip opie-ce9178fb13908eca5b7835e785fc0914a5022615.tar.gz opie-ce9178fb13908eca5b7835e785fc0914a5022615.tar.bz2 |
Simon thanks for the patch. Some clean ups. Patch provided by tronical
OAOAOAOAOAOAOAOAOAOAOAOAOBOBCVS: noncore/tools/remote/dvdgroupconf.cpp
29 files changed, 51 insertions, 48 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 3dd9f54..93bc97a 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,281 +1,281 @@ | |||
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 | 19 | ||
20 | #include "cardmon.h" | 20 | #include "cardmon.h" |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | 23 | ||
24 | #include <qcopchannel_qws.h> | 24 | #include <qcopchannel_qws.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | 30 | ||
31 | #include <stdio.h> | 31 | #include <stdio.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <string.h> | 34 | #include <string.h> |
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | 36 | ||
37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 37 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
38 | #include <sys/vfs.h> | 38 | #include <sys/vfs.h> |
39 | #include <mntent.h> | 39 | #include <mntent.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), | 42 | CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), |
43 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { | 43 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { |
44 | 44 | ||
45 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 45 | QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
46 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 46 | connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
47 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 47 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
48 | 48 | ||
49 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); | 49 | QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); |
50 | connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 50 | connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
51 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 51 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
52 | 52 | ||
53 | setFixedSize( pm.size() ); | 53 | setFixedSize( pm.size() ); |
54 | getStatusPcmcia(TRUE); | 54 | getStatusPcmcia(TRUE); |
55 | getStatusSd(TRUE); | 55 | getStatusSd(TRUE); |
56 | repaint(FALSE); | 56 | repaint(FALSE); |
57 | popUpMenu = 0; | 57 | popUpMenu = 0; |
58 | popUpMenuTimer = 0; | 58 | popUpMenuTimer = 0; |
59 | } | 59 | } |
60 | 60 | ||
61 | CardMonitor::~CardMonitor() { | 61 | CardMonitor::~CardMonitor() { |
62 | } | 62 | } |
63 | 63 | ||
64 | void CardMonitor::popUp(QString message) { | 64 | void CardMonitor::popUp(QString message) { |
65 | if ( ! popUpMenu ) { | 65 | if ( ! popUpMenu ) { |
66 | popUpMenu = new QPopupMenu(); | 66 | popUpMenu = new QPopupMenu(); |
67 | } | 67 | } |
68 | popUpMenu->clear(); | 68 | popUpMenu->clear(); |
69 | popUpMenu->insertItem( message, 0 ); | 69 | popUpMenu->insertItem( message, 0 ); |
70 | 70 | ||
71 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 71 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
72 | QSize s = popUpMenu->sizeHint ( ); | 72 | QSize s = popUpMenu->sizeHint ( ); |
73 | popUpMenu->popup( QPoint ( | 73 | popUpMenu->popup( QPoint ( |
74 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 74 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
75 | p. y ( ) - s. height ( ) ), 0); | 75 | p. y ( ) - s. height ( ) ), 0); |
76 | 76 | ||
77 | if ( ! popUpMenuTimer ) { | 77 | if ( ! popUpMenuTimer ) { |
78 | popUpMenuTimer = new QTimer( this ); | 78 | popUpMenuTimer = new QTimer( this ); |
79 | connect( popUpMenuTimer, SIGNAL(timeout()), this, SLOT(popUpTimeout()) ); | 79 | connect( popUpMenuTimer, SIGNAL(timeout()), this, SLOT(popUpTimeout()) ); |
80 | } | 80 | } |
81 | timerEvent(0); | 81 | timerEvent(0); |
82 | popUpMenuTimer->start( 2000 ); | 82 | popUpMenuTimer->start( 2000 ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void CardMonitor::popUpTimeout() { | 85 | void CardMonitor::popUpTimeout() { |
86 | popUpMenu->hide(); | 86 | popUpMenu->hide(); |
87 | popUpMenuTimer->stop(); | 87 | popUpMenuTimer->stop(); |
88 | } | 88 | } |
89 | 89 | ||
90 | void CardMonitor::mousePressEvent( QMouseEvent * ) { | 90 | void CardMonitor::mousePressEvent( QMouseEvent * ) { |
91 | QPopupMenu *menu = new QPopupMenu(); | 91 | QPopupMenu *menu = new QPopupMenu(); |
92 | QString cmd; | 92 | QString cmd; |
93 | int err=0; | 93 | int err=0; |
94 | 94 | ||
95 | if ( cardInSd ) { | 95 | if ( cardInSd ) { |
96 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); | 96 | menu->insertItem( tr("Eject SD/MMC card"), 0 ); |
97 | } | 97 | } |
98 | 98 | ||
99 | if ( cardInPcmcia0 ) { | 99 | if ( cardInPcmcia0 ) { |
100 | menu->insertItem( tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); | 100 | menu->insertItem( tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); |
101 | } | 101 | } |
102 | 102 | ||
103 | if ( cardInPcmcia1 ) { | 103 | if ( cardInPcmcia1 ) { |
104 | menu->insertItem( tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); | 104 | menu->insertItem( tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); |
105 | } | 105 | } |
106 | 106 | ||
107 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 107 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
108 | QSize s = menu->sizeHint ( ); | 108 | QSize s = menu->sizeHint ( ); |
109 | int opt = menu->exec( QPoint ( | 109 | int opt = menu->exec( QPoint ( |
110 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 110 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
111 | p. y ( ) - s. height ( ) ), 0); | 111 | p. y ( ) - s. height ( ) ), 0); |
112 | 112 | ||
113 | if ( opt == 1 ) { | 113 | if ( opt == 1 ) { |
114 | 114 | ||
115 | cmd = "/sbin/cardctl eject 0"; | 115 | cmd = "/sbin/cardctl eject 0"; |
116 | err = system( (const char *) cmd ); | 116 | err = system( (const char *) cmd ); |
117 | if ( ( err == 127 ) || ( err < 0 ) ) { | 117 | if ( ( err == 127 ) || ( err < 0 ) ) { |
118 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); | 118 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); |
119 | popUp( tr("CF/PCMCIA card eject failed!")); | 119 | popUp( tr("CF/PCMCIA card eject failed!")); |
120 | } | 120 | } |
121 | } else if ( opt == 0 ) { | 121 | } else if ( opt == 0 ) { |
122 | cmd = "/etc/sdcontrol compeject"; | 122 | cmd = "/etc/sdcontrol compeject"; |
123 | err = system( (const char *) cmd ); | 123 | err = system( (const char *) cmd ); |
124 | if ( ( err != 0 ) ) { | 124 | if ( ( err != 0 ) ) { |
125 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); | 125 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); |
126 | popUp( tr("SD/MMC card eject failed!")); | 126 | popUp( tr("SD/MMC card eject failed!")); |
127 | } | 127 | } |
128 | } else if ( opt == 2 ) { | 128 | } else if ( opt == 2 ) { |
129 | cmd = "/sbin/cardctl eject 1"; | 129 | cmd = "/sbin/cardctl eject 1"; |
130 | err = system( (const char *) cmd ); | 130 | err = system( (const char *) cmd ); |
131 | if ( ( err == 127 ) || ( err < 0 ) ) { | 131 | if ( ( err == 127 ) || ( err < 0 ) ) { |
132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); | 132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); |
133 | popUp( tr("CF/PCMCIA card eject failed!")); | 133 | popUp( tr("CF/PCMCIA card eject failed!")); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | delete menu; | 137 | delete menu; |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { | 141 | void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { |
142 | if ( msg == "stabChanged()" ) { | 142 | if ( msg == "stabChanged()" ) { |
143 | // qDebug("Pcmcia: stabchanged"); | 143 | // qDebug("Pcmcia: stabchanged"); |
144 | if ( getStatusPcmcia() ) { | 144 | if ( getStatusPcmcia() ) { |
145 | repaint(FALSE); | 145 | repaint(FALSE); |
146 | } | 146 | } |
147 | } else if ( msg == "mtabChanged()" ) { | 147 | } else if ( msg == "mtabChanged()" ) { |
148 | // qDebug("Pcmcia: mtabchanged"); | 148 | // qDebug("Pcmcia: mtabchanged"); |
149 | if ( getStatusSd() ) { | 149 | if ( getStatusSd() ) { |
150 | repaint(FALSE); | 150 | repaint(FALSE); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) { | 155 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { |
156 | 156 | ||
157 | bool cardWas0 = cardInPcmcia0; // remember last state | 157 | bool cardWas0 = cardInPcmcia0; // remember last state |
158 | bool cardWas1 = cardInPcmcia1; | 158 | bool cardWas1 = cardInPcmcia1; |
159 | 159 | ||
160 | QString fileName; | 160 | QString fileName; |
161 | 161 | ||
162 | // one of these 3 files should exist | 162 | // one of these 3 files should exist |
163 | if (QFile::exists("/var/run/stab")) { | 163 | if (QFile::exists("/var/run/stab")) { |
164 | fileName = "/var/run/stab"; | 164 | fileName = "/var/run/stab"; |
165 | } else if (QFile::exists("/var/state/pcmcia/stab")) { | 165 | } else if (QFile::exists("/var/state/pcmcia/stab")) { |
166 | fileName="/var/state/pcmcia/stab"; | 166 | fileName="/var/state/pcmcia/stab"; |
167 | } else { | 167 | } else { |
168 | fileName="/var/lib/pcmcia/stab"; | 168 | fileName="/var/lib/pcmcia/stab"; |
169 | } | 169 | } |
170 | 170 | ||
171 | QFile f(fileName); | 171 | QFile f(fileName); |
172 | 172 | ||
173 | if ( f.open(IO_ReadOnly) ) { | 173 | if ( f.open(IO_ReadOnly) ) { |
174 | QStringList list; | 174 | QStringList list; |
175 | QTextStream stream ( &f); | 175 | QTextStream stream ( &f); |
176 | QString streamIn; | 176 | QString streamIn; |
177 | streamIn = stream.read(); | 177 | streamIn = stream.read(); |
178 | list = QStringList::split("\n", streamIn); | 178 | list = QStringList::split("\n", streamIn); |
179 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 179 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
180 | if( (*line).startsWith("Socket 0:") ){ | 180 | if( (*line).startsWith("Socket 0:") ){ |
181 | if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){ | 181 | if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){ |
182 | cardInPcmcia0 = FALSE; | 182 | cardInPcmcia0 = FALSE; |
183 | } else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){ | 183 | } else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){ |
184 | cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); | 184 | cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); |
185 | cardInPcmcia0Name.stripWhiteSpace(); | 185 | cardInPcmcia0Name.stripWhiteSpace(); |
186 | cardInPcmcia0 = TRUE; | 186 | cardInPcmcia0 = TRUE; |
187 | show(); | 187 | show(); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | if( (*line).startsWith("Socket 1:") ){ | 190 | if( (*line).startsWith("Socket 1:") ){ |
191 | if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ | 191 | if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ |
192 | cardInPcmcia1 = FALSE; | 192 | cardInPcmcia1 = FALSE; |
193 | } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ | 193 | } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ |
194 | cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); | 194 | cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); |
195 | cardInPcmcia1Name.stripWhiteSpace(); | 195 | cardInPcmcia1Name.stripWhiteSpace(); |
196 | cardInPcmcia1 = TRUE; | 196 | cardInPcmcia1 = TRUE; |
197 | show(); | 197 | show(); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | // no file found | 202 | // no file found |
203 | qDebug("no file found"); | 203 | qDebug("no file found"); |
204 | cardInPcmcia0 = FALSE; | 204 | cardInPcmcia0 = FALSE; |
205 | cardInPcmcia1 = FALSE; | 205 | cardInPcmcia1 = FALSE; |
206 | return FALSE; | 206 | return FALSE; |
207 | 207 | ||
208 | } | 208 | } |
209 | 209 | ||
210 | if(!cardInPcmcia0 && !cardInPcmcia1) { | 210 | if(!cardInPcmcia0 && !cardInPcmcia1) { |
211 | qDebug("Pcmcia: no cards"); | 211 | qDebug("Pcmcia: no cards"); |
212 | } | 212 | } |
213 | 213 | ||
214 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { | 214 | if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { |
215 | QString text = ""; | 215 | QString text = ""; |
216 | if(cardWas0 != cardInPcmcia0) { | 216 | if(cardWas0 != cardInPcmcia0) { |
217 | if(cardInPcmcia0) { text += tr("New card: "); } | 217 | if(cardInPcmcia0) { text += tr("New card: "); } |
218 | else { text += tr("Ejected: "); } | 218 | else { text += tr("Ejected: "); } |
219 | text += cardInPcmcia0Name; | 219 | text += cardInPcmcia0Name; |
220 | } | 220 | } |
221 | if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) { | 221 | if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) { |
222 | text += "\n"; | 222 | text += "\n"; |
223 | } | 223 | } |
224 | if(cardWas1 != cardInPcmcia1) { | 224 | if(cardWas1 != cardInPcmcia1) { |
225 | if(cardInPcmcia1) { text += tr("New card: "); } | 225 | if(cardInPcmcia1) { text += tr("New card: "); } |
226 | else { text += tr("Ejected: "); } | 226 | else { text += tr("Ejected: "); } |
227 | text += cardInPcmcia1Name; | 227 | text += cardInPcmcia1Name; |
228 | } | 228 | } |
229 | popUp( text ); | 229 | popUp( text ); |
230 | } | 230 | } |
231 | 231 | ||
232 | f.close(); | 232 | f.close(); |
233 | 233 | ||
234 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); | 234 | return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | bool CardMonitor::getStatusSd( int showPopUp = FALSE ) { | 238 | bool CardMonitor::getStatusSd( int showPopUp ) { |
239 | 239 | ||
240 | bool cardWas=cardInSd; // remember last state | 240 | bool cardWas=cardInSd; // remember last state |
241 | cardInSd=false; | 241 | cardInSd=false; |
242 | 242 | ||
243 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 243 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
244 | struct mntent *me; | 244 | struct mntent *me; |
245 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 245 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
246 | 246 | ||
247 | if ( mntfp ) { | 247 | if ( mntfp ) { |
248 | while ( (me = getmntent( mntfp )) != 0 ) { | 248 | while ( (me = getmntent( mntfp )) != 0 ) { |
249 | QString fs = me->mnt_fsname; | 249 | QString fs = me->mnt_fsname; |
250 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { | 250 | if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { |
251 | cardInSd=true; | 251 | cardInSd=true; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | endmntent( mntfp ); | 254 | endmntent( mntfp ); |
255 | } | 255 | } |
256 | if(!showPopUp && cardWas != cardInSd) { | 256 | if(!showPopUp && cardWas != cardInSd) { |
257 | QString text = ""; | 257 | QString text = ""; |
258 | if(cardInSd) { text += "SD Inserted"; } | 258 | if(cardInSd) { text += "SD Inserted"; } |
259 | else { text += "SD Removed"; } | 259 | else { text += "SD Removed"; } |
260 | popUp( text ); | 260 | popUp( text ); |
261 | } | 261 | } |
262 | 262 | ||
263 | #else | 263 | #else |
264 | #error "Not on Linux" | 264 | #error "Not on Linux" |
265 | #endif | 265 | #endif |
266 | return ((cardWas == cardInSd) ? FALSE : TRUE); | 266 | return ((cardWas == cardInSd) ? FALSE : TRUE); |
267 | } | 267 | } |
268 | 268 | ||
269 | void CardMonitor::paintEvent( QPaintEvent * ) { | 269 | void CardMonitor::paintEvent( QPaintEvent * ) { |
270 | QPainter p( this ); | 270 | QPainter p( this ); |
271 | 271 | ||
272 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 272 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { |
273 | p.drawPixmap( 0, 0, pm ); | 273 | p.drawPixmap( 0, 0, pm ); |
274 | show(); | 274 | show(); |
275 | } else { | 275 | } else { |
276 | p.eraseRect( rect() ); | 276 | p.eraseRect( rect() ); |
277 | hide(); | 277 | hide(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index b29ee62..4278f46 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -1,629 +1,630 @@ | |||
1 | /************************************************************************************ | 1 | /************************************************************************************ |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | ************************************************************************************/ | 11 | ************************************************************************************/ |
12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> | 12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> |
13 | /* | 13 | /* |
14 | * $Id$ | 14 | * $Id$ |
15 | */ | 15 | */ |
16 | // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> | 16 | // Sun 03-17-2002 L.J.Potter <ljp@llornkcor.com> |
17 | #include <sys/utsname.h> | 17 | #include <sys/utsname.h> |
18 | #include <sys/time.h> | 18 | #include <sys/time.h> |
19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
20 | #include <unistd.h> | 20 | #include <unistd.h> |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <sys/stat.h> | 22 | #include <sys/stat.h> |
23 | #include <fcntl.h> | 23 | #include <fcntl.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
25 | #include <linux/soundcard.h> | 25 | #include <linux/soundcard.h> |
26 | 26 | ||
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | 30 | ||
31 | typedef struct _waveheader { | 31 | typedef struct _waveheader { |
32 | u_long main_chunk; /* 'RIFF' */ | 32 | u_long main_chunk; /* 'RIFF' */ |
33 | u_long length; /* filelen */ | 33 | u_long length; /* filelen */ |
34 | u_long chunk_type; /* 'WAVE' */ | 34 | u_long chunk_type; /* 'WAVE' */ |
35 | u_long sub_chunk; /* 'fmt ' */ | 35 | u_long sub_chunk; /* 'fmt ' */ |
36 | u_long sc_len; /* length of sub_chunk, =16 | 36 | u_long sc_len; /* length of sub_chunk, =16 |
37 | (chunckSize) format len */ | 37 | (chunckSize) format len */ |
38 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 38 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
39 | 39 | ||
40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 40 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 41 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 42 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ | 43 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ |
44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 44 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
45 | 45 | ||
46 | u_long data_chunk; /* 'data' */ | 46 | u_long data_chunk; /* 'data' */ |
47 | 47 | ||
48 | u_long data_length;/* samplecount */ | 48 | u_long data_length;/* samplecount */ |
49 | } WaveHeader; | 49 | } WaveHeader; |
50 | 50 | ||
51 | #define RIFF 0x46464952 | 51 | #define RIFF 0x46464952 |
52 | #define WAVE 0x45564157 | 52 | #define WAVE 0x45564157 |
53 | #define FMT 0x20746D66 | 53 | #define FMT 0x20746D66 |
54 | #define DATA 0x61746164 | 54 | #define DATA 0x61746164 |
55 | #define PCM_CODE 1 | 55 | #define PCM_CODE 1 |
56 | #define WAVE_MONO 1 | 56 | #define WAVE_MONO 1 |
57 | #define WAVE_STEREO 2 | 57 | #define WAVE_STEREO 2 |
58 | 58 | ||
59 | #include "vmemo.h" | 59 | #include "vmemo.h" |
60 | 60 | ||
61 | #include <qpe/qpeapplication.h> | 61 | #include <qpe/qpeapplication.h> |
62 | #include <qpe/resource.h> | 62 | #include <qpe/resource.h> |
63 | #include <qpe/config.h> | 63 | #include <qpe/config.h> |
64 | 64 | ||
65 | #include <qpainter.h> | 65 | #include <qpainter.h> |
66 | #include <qdatetime.h> | 66 | #include <qdatetime.h> |
67 | #include <qregexp.h> | 67 | #include <qregexp.h> |
68 | #include <qsound.h> | 68 | #include <qsound.h> |
69 | #include <qfile.h> | 69 | #include <qfile.h> |
70 | #include <qmessagebox.h> | 70 | #include <qmessagebox.h> |
71 | 71 | ||
72 | int seq = 0; | 72 | int seq = 0; |
73 | 73 | ||
74 | /* XPM */ | 74 | /* XPM */ |
75 | static char * vmemo_xpm[] = { | 75 | static char * vmemo_xpm[] = { |
76 | "16 16 102 2", | 76 | "16 16 102 2", |
77 | " c None", | 77 | " c None", |
78 | ". c #60636A", | 78 | ". c #60636A", |
79 | "+ c #6E6E72", | 79 | "+ c #6E6E72", |
80 | "@ c #68696E", | 80 | "@ c #68696E", |
81 | "# c #4D525C", | 81 | "# c #4D525C", |
82 | "$ c #6B6C70", | 82 | "$ c #6B6C70", |
83 | "% c #E3E3E8", | 83 | "% c #E3E3E8", |
84 | "& c #EEEEF2", | 84 | "& c #EEEEF2", |
85 | "* c #EAEAEF", | 85 | "* c #EAEAEF", |
86 | "= c #CACAD0", | 86 | "= c #CACAD0", |
87 | "- c #474A51", | 87 | "- c #474A51", |
88 | "; c #171819", | 88 | "; c #171819", |
89 | "> c #9B9B9F", | 89 | "> c #9B9B9F", |
90 | ", c #EBEBF0", | 90 | ", c #EBEBF0", |
91 | "' c #F4F4F7", | 91 | "' c #F4F4F7", |
92 | ") c #F1F1F5", | 92 | ") c #F1F1F5", |
93 | "! c #DEDEE4", | 93 | "! c #DEDEE4", |
94 | "~ c #57575C", | 94 | "~ c #57575C", |
95 | "{ c #010101", | 95 | "{ c #010101", |
96 | "] c #A2A2A6", | 96 | "] c #A2A2A6", |
97 | "^ c #747477", | 97 | "^ c #747477", |
98 | "/ c #B5B5B8", | 98 | "/ c #B5B5B8", |
99 | "( c #AEAEB2", | 99 | "( c #AEAEB2", |
100 | "_ c #69696D", | 100 | "_ c #69696D", |
101 | ": c #525256", | 101 | ": c #525256", |
102 | "< c #181C24", | 102 | "< c #181C24", |
103 | "[ c #97979B", | 103 | "[ c #97979B", |
104 | "} c #A7A7AC", | 104 | "} c #A7A7AC", |
105 | "| c #B0B0B4", | 105 | "| c #B0B0B4", |
106 | "1 c #C8C8D1", | 106 | "1 c #C8C8D1", |
107 | "2 c #75757B", | 107 | "2 c #75757B", |
108 | "3 c #46464A", | 108 | "3 c #46464A", |
109 | "4 c #494A4F", | 109 | "4 c #494A4F", |
110 | "5 c #323234", | 110 | "5 c #323234", |
111 | "6 c #909095", | 111 | "6 c #909095", |
112 | "7 c #39393B", | 112 | "7 c #39393B", |
113 | "8 c #757578", | 113 | "8 c #757578", |
114 | "9 c #87878E", | 114 | "9 c #87878E", |
115 | "0 c #222224", | 115 | "0 c #222224", |
116 | "a c #414144", | 116 | "a c #414144", |
117 | "b c #6A6A6E", | 117 | "b c #6A6A6E", |
118 | "c c #020C16", | 118 | "c c #020C16", |
119 | "d c #6B6B6F", | 119 | "d c #6B6B6F", |
120 | "e c #68686D", | 120 | "e c #68686D", |
121 | "f c #5B5B60", | 121 | "f c #5B5B60", |
122 | "g c #8A8A8F", | 122 | "g c #8A8A8F", |
123 | "h c #6B6B6E", | 123 | "h c #6B6B6E", |
124 | "i c #ADADB2", | 124 | "i c #ADADB2", |
125 | "j c #828289", | 125 | "j c #828289", |
126 | "k c #3E3E41", | 126 | "k c #3E3E41", |
127 | "l c #CFCFD7", | 127 | "l c #CFCFD7", |
128 | "m c #4C4C50", | 128 | "m c #4C4C50", |
129 | "n c #000000", | 129 | "n c #000000", |
130 | "o c #66666A", | 130 | "o c #66666A", |
131 | "p c #505054", | 131 | "p c #505054", |
132 | "q c #838388", | 132 | "q c #838388", |
133 | "r c #A1A1A7", | 133 | "r c #A1A1A7", |
134 | "s c #A9A9AE", | 134 | "s c #A9A9AE", |
135 | "t c #A8A8B0", | 135 | "t c #A8A8B0", |
136 | "u c #5E5E63", | 136 | "u c #5E5E63", |
137 | "v c #3A3A3E", | 137 | "v c #3A3A3E", |
138 | "w c #BDBDC6", | 138 | "w c #BDBDC6", |
139 | "x c #59595E", | 139 | "x c #59595E", |
140 | "y c #76767C", | 140 | "y c #76767C", |
141 | "z c #373738", | 141 | "z c #373738", |
142 | "A c #717174", | 142 | "A c #717174", |
143 | "B c #727278", | 143 | "B c #727278", |
144 | "C c #1C1C1E", | 144 | "C c #1C1C1E", |
145 | "D c #3C3C3F", | 145 | "D c #3C3C3F", |
146 | "E c #ADADB6", | 146 | "E c #ADADB6", |
147 | "F c #54555A", | 147 | "F c #54555A", |
148 | "G c #8B8C94", | 148 | "G c #8B8C94", |
149 | "H c #5A5A5F", | 149 | "H c #5A5A5F", |
150 | "I c #BBBBC3", | 150 | "I c #BBBBC3", |
151 | "J c #C4C4CB", | 151 | "J c #C4C4CB", |
152 | "K c #909098", | 152 | "K c #909098", |
153 | "L c #737379", | 153 | "L c #737379", |
154 | "M c #343437", | 154 | "M c #343437", |
155 | "N c #8F8F98", | 155 | "N c #8F8F98", |
156 | "O c #000407", | 156 | "O c #000407", |
157 | "P c #2D3137", | 157 | "P c #2D3137", |
158 | "Q c #B0B1BC", | 158 | "Q c #B0B1BC", |
159 | "R c #3B3C40", | 159 | "R c #3B3C40", |
160 | "S c #6E6E74", | 160 | "S c #6E6E74", |
161 | "T c #95959C", | 161 | "T c #95959C", |
162 | "U c #74747A", | 162 | "U c #74747A", |
163 | "V c #1D1D1E", | 163 | "V c #1D1D1E", |
164 | "W c #91929A", | 164 | "W c #91929A", |
165 | "X c #42444A", | 165 | "X c #42444A", |
166 | "Y c #22282E", | 166 | "Y c #22282E", |
167 | "Z c #B0B2BC", | 167 | "Z c #B0B2BC", |
168 | "` c #898A90", | 168 | "` c #898A90", |
169 | " . c #65656A", | 169 | " . c #65656A", |
170 | ".. c #999AA2", | 170 | ".. c #999AA2", |
171 | "+. c #52535A", | 171 | "+. c #52535A", |
172 | "@. c #151B21", | 172 | "@. c #151B21", |
173 | "#. c #515257", | 173 | "#. c #515257", |
174 | "$. c #B5B5BE", | 174 | "$. c #B5B5BE", |
175 | "%. c #616167", | 175 | "%. c #616167", |
176 | "&. c #1A1D22", | 176 | "&. c #1A1D22", |
177 | "*. c #000713", | 177 | "*. c #000713", |
178 | "=. c #1F1F21", | 178 | "=. c #1F1F21", |
179 | " ", | 179 | " ", |
180 | " . + @ # ", | 180 | " . + @ # ", |
181 | " $ % & * = - ", | 181 | " $ % & * = - ", |
182 | " ; > , ' ) ! ~ ", | 182 | " ; > , ' ) ! ~ ", |
183 | " { ] ^ / ( _ : ", | 183 | " { ] ^ / ( _ : ", |
184 | " < [ } | 1 2 3 ", | 184 | " < [ } | 1 2 3 ", |
185 | " 4 5 6 7 8 9 0 a b c ", | 185 | " 4 5 6 7 8 9 0 a b c ", |
186 | " d e f g h i j 3 k l m n ", | 186 | " d e f g h i j 3 k l m n ", |
187 | " o p q r s t u v w n ", | 187 | " o p q r s t u v w n ", |
188 | " o x y z A B C D E n ", | 188 | " o x y z A B C D E n ", |
189 | " F G H I J K L M N O ", | 189 | " F G H I J K L M N O ", |
190 | " P Q R S T U V W X ", | 190 | " P Q R S T U V W X ", |
191 | " Y Z ` b ...+. ", | 191 | " Y Z ` b ...+. ", |
192 | " @.#.$.%.&. ", | 192 | " @.#.$.%.&. ", |
193 | " *.B =. ", | 193 | " *.B =. ", |
194 | " n n n n n n n n n "}; | 194 | " n n n n n n n n n "}; |
195 | 195 | ||
196 | 196 | ||
197 | VMemo::VMemo( QWidget *parent, const char *_name ) | 197 | VMemo::VMemo( QWidget *parent, const char *_name ) |
198 | : QWidget( parent, _name ) | 198 | : QWidget( parent, _name ) |
199 | { | 199 | { |
200 | setFixedHeight( 18 ); | 200 | setFixedHeight( 18 ); |
201 | setFixedWidth( 14 ); | 201 | setFixedWidth( 14 ); |
202 | 202 | ||
203 | recording = FALSE; | 203 | recording = FALSE; |
204 | 204 | ||
205 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 205 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
206 | if (uname(&name) != -1) { | 206 | if (uname(&name) != -1) { |
207 | QString release=name.release; | 207 | QString release=name.release; |
208 | Config vmCfg("Vmemo"); | 208 | Config vmCfg("Vmemo"); |
209 | vmCfg.setGroup("Defaults"); | 209 | vmCfg.setGroup("Defaults"); |
210 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 210 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
211 | 211 | ||
212 | qDebug("toggleKey %d", toggleKey); | 212 | qDebug("toggleKey %d", toggleKey); |
213 | 213 | ||
214 | if(release.find("embedix",0,TRUE) !=-1) | 214 | if(release.find("embedix",0,TRUE) !=-1) |
215 | systemZaurus=TRUE; | 215 | systemZaurus=TRUE; |
216 | else | 216 | else |
217 | systemZaurus=FALSE; | 217 | systemZaurus=FALSE; |
218 | 218 | ||
219 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 219 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
220 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 220 | connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
221 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 221 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
222 | 222 | ||
223 | if( toggleKey != -1 ) { | 223 | if( toggleKey != -1 ) { |
224 | // QPEApplication::grabKeyboard(); | 224 | // QPEApplication::grabKeyboard(); |
225 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); | 225 | QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); |
226 | // e << 4096; // Key_Escape | 226 | // e << 4096; // Key_Escape |
227 | // e << Key_F5; //4148 | 227 | // e << Key_F5; //4148 |
228 | e << toggleKey; | 228 | e << toggleKey; |
229 | e << QString("QPE/VMemo"); | 229 | e << QString("QPE/VMemo"); |
230 | e << QString("toggleRecord()"); | 230 | e << QString("toggleRecord()"); |
231 | } | 231 | } |
232 | // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) | 232 | // if( vmCfg.readNumEntry("hideIcon",0) == 1 || toggleKey > 0) |
233 | // hide(); | 233 | // hide(); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | VMemo::~VMemo() | 237 | VMemo::~VMemo() |
238 | { | 238 | { |
239 | } | 239 | } |
240 | 240 | ||
241 | void VMemo::receive( const QCString &msg, const QByteArray &data ) | 241 | void VMemo::receive( const QCString &msg, const QByteArray &data ) |
242 | { | 242 | { |
243 | QDataStream stream( data, IO_ReadOnly ); | 243 | QDataStream stream( data, IO_ReadOnly ); |
244 | if (msg == "toggleRecord()") { | 244 | if (msg == "toggleRecord()") { |
245 | if (recording) { | 245 | if (recording) { |
246 | fromToggle = TRUE; | 246 | fromToggle = TRUE; |
247 | stopRecording(); | 247 | stopRecording(); |
248 | } else { | 248 | } else { |
249 | fromToggle = TRUE; | 249 | fromToggle = TRUE; |
250 | startRecording(); | 250 | startRecording(); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | void VMemo::paintEvent( QPaintEvent* ) | 255 | void VMemo::paintEvent( QPaintEvent* ) |
256 | { | 256 | { |
257 | QPainter p(this); | 257 | QPainter p(this); |
258 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 258 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
259 | } | 259 | } |
260 | 260 | ||
261 | void VMemo::mousePressEvent( QMouseEvent * ) | 261 | void VMemo::mousePressEvent( QMouseEvent * ) |
262 | { | 262 | { |
263 | startRecording(); | 263 | startRecording(); |
264 | } | 264 | } |
265 | 265 | ||
266 | void VMemo::mouseReleaseEvent( QMouseEvent * ) | 266 | void VMemo::mouseReleaseEvent( QMouseEvent * ) |
267 | { | 267 | { |
268 | stopRecording(); | 268 | stopRecording(); |
269 | } | 269 | } |
270 | 270 | ||
271 | bool VMemo::startRecording() { | 271 | bool VMemo::startRecording() { |
272 | 272 | ||
273 | if ( recording) | 273 | if ( recording) |
274 | return FALSE;; | 274 | return FALSE;; |
275 | 275 | ||
276 | Config config( "Vmemo" ); | 276 | Config config( "Vmemo" ); |
277 | config.setGroup( "System" ); | 277 | config.setGroup( "System" ); |
278 | 278 | ||
279 | useAlerts = config.readBoolEntry("Alert"); | 279 | useAlerts = config.readBoolEntry("Alert"); |
280 | if(useAlerts) { | 280 | if(useAlerts) { |
281 | 281 | ||
282 | msgLabel = new QLabel( 0, "alertLabel" ); | 282 | msgLabel = new QLabel( 0, "alertLabel" ); |
283 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 283 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
284 | msgLabel->show(); | 284 | msgLabel->show(); |
285 | } | 285 | } |
286 | 286 | ||
287 | // if(useAlerts) | 287 | // if(useAlerts) |
288 | // QMessageBox::message("VMemo","Really Record?");//) ==1) | 288 | // QMessageBox::message("VMemo","Really Record?");//) ==1) |
289 | // return; | 289 | // return; |
290 | // } else { | 290 | // } else { |
291 | // if (!systemZaurus ) | 291 | // if (!systemZaurus ) |
292 | // QSound::play(Resource::findSound("vmemob")); | 292 | // QSound::play(Resource::findSound("vmemob")); |
293 | // } | 293 | // } |
294 | qDebug("Start recording engines"); | 294 | qDebug("Start recording engines"); |
295 | recording = TRUE; | 295 | recording = TRUE; |
296 | 296 | ||
297 | if (openDSP() == -1) { | 297 | if (openDSP() == -1) { |
298 | // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); | 298 | // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); |
299 | // delete msgLabel; | 299 | // delete msgLabel; |
300 | recording = FALSE; | 300 | recording = FALSE; |
301 | return FALSE; | 301 | return FALSE; |
302 | } | 302 | } |
303 | 303 | ||
304 | config.setGroup("Defaults"); | 304 | config.setGroup("Defaults"); |
305 | 305 | ||
306 | QDateTime dt = QDateTime::currentDateTime(); | 306 | QDateTime dt = QDateTime::currentDateTime(); |
307 | 307 | ||
308 | QString fName; | 308 | QString fName; |
309 | config.setGroup( "System" ); | 309 | config.setGroup( "System" ); |
310 | fName = QPEApplication::documentDir() ; | 310 | fName = QPEApplication::documentDir() ; |
311 | fileName = config.readEntry("RecLocation", fName); | 311 | fileName = config.readEntry("RecLocation", fName); |
312 | 312 | ||
313 | int s; | 313 | int s; |
314 | s=fileName.find(':'); | 314 | s=fileName.find(':'); |
315 | if(s) | 315 | if(s) |
316 | fileName=fileName.right(fileName.length()-s-2); | 316 | fileName=fileName.right(fileName.length()-s-2); |
317 | qDebug("filename will be "+fileName); | 317 | qDebug("filename will be "+fileName); |
318 | if( fileName.left(1).find('/') == -1) | 318 | if( fileName.left(1).find('/') == -1) |
319 | fileName="/"+fileName; | 319 | fileName="/"+fileName; |
320 | if( fileName.right(1).find('/') == -1) | 320 | if( fileName.right(1).find('/') == -1) |
321 | fileName+="/"; | 321 | fileName+="/"; |
322 | fName = "vm_"+ dt.toString()+ ".wav"; | 322 | fName = "vm_"+ dt.toString()+ ".wav"; |
323 | 323 | ||
324 | fileName+=fName; | 324 | fileName+=fName; |
325 | qDebug("filename is "+fileName); | 325 | qDebug("filename is "+fileName); |
326 | // No spaces in the filename | 326 | // No spaces in the filename |
327 | fileName.replace(QRegExp("'"),""); | 327 | fileName.replace(QRegExp("'"),""); |
328 | fileName.replace(QRegExp(" "),"_"); | 328 | fileName.replace(QRegExp(" "),"_"); |
329 | fileName.replace(QRegExp(":"),"."); | 329 | fileName.replace(QRegExp(":"),"."); |
330 | fileName.replace(QRegExp(","),""); | 330 | fileName.replace(QRegExp(","),""); |
331 | 331 | ||
332 | if(openWAV(fileName.latin1()) == -1) { | 332 | if(openWAV(fileName.latin1()) == -1) { |
333 | // QString err("Could not open the output file\n"); | 333 | // QString err("Could not open the output file\n"); |
334 | // err += fileName; | 334 | // err += fileName; |
335 | // QMessageBox::critical(0, "vmemo", err, "Abort"); | 335 | // QMessageBox::critical(0, "vmemo", err, "Abort"); |
336 | close(dsp); | 336 | close(dsp); |
337 | return FALSE; | 337 | return FALSE; |
338 | } | 338 | } |
339 | 339 | ||
340 | QArray<int> cats(1); | 340 | QArray<int> cats(1); |
341 | cats[0] = config.readNumEntry("Category", 0); | 341 | cats[0] = config.readNumEntry("Category", 0); |
342 | 342 | ||
343 | QString dlName("vm_"); | 343 | QString dlName("vm_"); |
344 | dlName += dt.toString(); | 344 | dlName += dt.toString(); |
345 | DocLnk l; | 345 | DocLnk l; |
346 | l.setFile(fileName); | 346 | l.setFile(fileName); |
347 | l.setName(dlName); | 347 | l.setName(dlName); |
348 | l.setType("audio/x-wav"); | 348 | l.setType("audio/x-wav"); |
349 | l.setCategories(cats); | 349 | l.setCategories(cats); |
350 | l.writeLink(); | 350 | l.writeLink(); |
351 | 351 | ||
352 | 352 | ||
353 | record(); | 353 | record(); |
354 | // delete msgLabel; | 354 | // delete msgLabel; |
355 | return TRUE; | 355 | return TRUE; |
356 | } | 356 | } |
357 | 357 | ||
358 | void VMemo::stopRecording() { | 358 | void VMemo::stopRecording() { |
359 | recording = FALSE; | 359 | recording = FALSE; |
360 | if(useAlerts) | 360 | if(useAlerts) |
361 | if( msgLabel) delete msgLabel; | 361 | if( msgLabel) delete msgLabel; |
362 | } | 362 | } |
363 | 363 | ||
364 | int VMemo::openDSP() | 364 | int VMemo::openDSP() |
365 | { | 365 | { |
366 | Config cfg("Vmemo"); | 366 | Config cfg("Vmemo"); |
367 | cfg.setGroup("Record"); | 367 | cfg.setGroup("Record"); |
368 | 368 | ||
369 | speed = cfg.readNumEntry("SampleRate", 22050); | 369 | speed = cfg.readNumEntry("SampleRate", 22050); |
370 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 370 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
371 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 371 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
372 | format = AFMT_S16_LE; | 372 | format = AFMT_S16_LE; |
373 | resolution = 16; | 373 | resolution = 16; |
374 | } else { | 374 | } else { |
375 | format = AFMT_U8; | 375 | format = AFMT_U8; |
376 | resolution = 8; | 376 | resolution = 8; |
377 | } | 377 | } |
378 | 378 | ||
379 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 379 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
380 | 380 | ||
381 | if(systemZaurus) { | 381 | if(systemZaurus) { |
382 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 | 382 | dsp = open("/dev/dsp1", O_RDWR); //Zaurus needs /dev/dsp1 |
383 | channels=1; //zaurus has one input channel | 383 | channels=1; //zaurus has one input channel |
384 | } else { | 384 | } else { |
385 | dsp = open("/dev/dsp", O_RDWR); | 385 | dsp = open("/dev/dsp", O_RDWR); |
386 | } | 386 | } |
387 | 387 | ||
388 | if(dsp == -1) { | 388 | if(dsp == -1) { |
389 | perror("open(\"/dev/dsp\")"); | 389 | perror("open(\"/dev/dsp\")"); |
390 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 390 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
391 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 391 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
392 | return -1; | 392 | return -1; |
393 | } | 393 | } |
394 | 394 | ||
395 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 395 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
396 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 396 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
397 | return -1; | 397 | return -1; |
398 | } | 398 | } |
399 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 399 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
400 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 400 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
401 | return -1; | 401 | return -1; |
402 | } | 402 | } |
403 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 403 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
404 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 404 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
405 | return -1; | 405 | return -1; |
406 | } | 406 | } |
407 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 407 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
408 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 408 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
409 | return -1; | 409 | return -1; |
410 | } | 410 | } |
411 | 411 | ||
412 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 412 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
413 | 413 | ||
414 | return 1; | 414 | return 1; |
415 | } | 415 | } |
416 | 416 | ||
417 | int VMemo::openWAV(const char *filename) | 417 | int VMemo::openWAV(const char *filename) |
418 | { | 418 | { |
419 | track.setName(filename); | 419 | track.setName(filename); |
420 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 420 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
421 | errorMsg=filename; | 421 | errorMsg=filename; |
422 | return -1; | 422 | return -1; |
423 | } | 423 | } |
424 | 424 | ||
425 | wav=track.handle(); | 425 | wav=track.handle(); |
426 | 426 | ||
427 | WaveHeader wh; | 427 | WaveHeader wh; |
428 | 428 | ||
429 | wh.main_chunk = RIFF; | 429 | wh.main_chunk = RIFF; |
430 | wh.length=0; | 430 | wh.length=0; |
431 | wh.chunk_type = WAVE; | 431 | wh.chunk_type = WAVE; |
432 | wh.sub_chunk = FMT; | 432 | wh.sub_chunk = FMT; |
433 | wh.sc_len = 16; | 433 | wh.sc_len = 16; |
434 | wh.format = PCM_CODE; | 434 | wh.format = PCM_CODE; |
435 | wh.modus = channels; | 435 | wh.modus = channels; |
436 | wh.sample_fq = speed; | 436 | wh.sample_fq = speed; |
437 | wh.byte_p_sec = speed * channels * resolution/8; | 437 | wh.byte_p_sec = speed * channels * resolution/8; |
438 | wh.byte_p_spl = channels * (resolution / 8); | 438 | wh.byte_p_spl = channels * (resolution / 8); |
439 | wh.bit_p_spl = resolution; | 439 | wh.bit_p_spl = resolution; |
440 | wh.data_chunk = DATA; | 440 | wh.data_chunk = DATA; |
441 | wh.data_length= 0; | 441 | wh.data_length= 0; |
442 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" | 442 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" |
443 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); | 443 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); |
444 | write (wav, &wh, sizeof(WaveHeader)); | 444 | write (wav, &wh, sizeof(WaveHeader)); |
445 | 445 | ||
446 | return 1; | 446 | return 1; |
447 | } | 447 | } |
448 | 448 | ||
449 | void VMemo::record(void) | 449 | void VMemo::record(void) |
450 | { | 450 | { |
451 | int length=0, result, value; | 451 | int length=0, result, value; |
452 | QString msg; | 452 | QString msg; |
453 | msg.sprintf("Recording format %d", format); | 453 | msg.sprintf("Recording format %d", format); |
454 | qDebug(msg); | 454 | qDebug(msg); |
455 | 455 | ||
456 | if(systemZaurus) { | 456 | if(systemZaurus) { |
457 | 457 | ||
458 | msg.sprintf("Recording format zaurus"); | 458 | msg.sprintf("Recording format zaurus"); |
459 | qDebug(msg); | 459 | qDebug(msg); |
460 | signed short sound[512], monoBuffer[512]; | 460 | signed short sound[512], monoBuffer[512]; |
461 | 461 | ||
462 | if(format==AFMT_S16_LE) { | 462 | if(format==AFMT_S16_LE) { |
463 | 463 | ||
464 | 464 | ||
465 | 465 | ||
466 | while(recording) { | 466 | while(recording) { |
467 | 467 | ||
468 | result = read(dsp, sound, 512); // 8192 | 468 | result = read(dsp, sound, 512); // 8192 |
469 | int j=0; | 469 | int j=0; |
470 | 470 | ||
471 | // if(systemZaurus) { | 471 | // if(systemZaurus) { |
472 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 472 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
473 | monoBuffer[i] = sound[i]; | 473 | monoBuffer[i] = sound[i]; |
474 | } | 474 | } |
475 | 475 | ||
476 | length+=write(wav, monoBuffer, result); | 476 | length+=write(wav, monoBuffer, result); |
477 | if(length<0) | 477 | if(length<0) |
478 | recording=false; | 478 | recording=false; |
479 | 479 | ||
480 | // } else { //ipaq /stereo inputs | 480 | // } else { //ipaq /stereo inputs |
481 | 481 | ||
482 | 482 | ||
483 | // for (int i = 0; i < result; i+=2) { | 483 | // for (int i = 0; i < result; i+=2) { |
484 | // monoBuffer[j] = sound[i]; | 484 | // monoBuffer[j] = sound[i]; |
485 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 485 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; |
486 | 486 | ||
487 | // j++; | 487 | // j++; |
488 | // } | 488 | // } |
489 | 489 | ||
490 | // length+=write(wav, monoBuffer, result); | 490 | // length+=write(wav, monoBuffer, result); |
491 | // if(length<0) | 491 | // if(length<0) |
492 | // recording=false; | 492 | // recording=false; |
493 | // // length+=write(wav, monoBuffer, result/2); | 493 | // // length+=write(wav, monoBuffer, result/2); |
494 | // } | 494 | // } |
495 | qApp->processEvents(); | 495 | qApp->processEvents(); |
496 | // printf("%d\r",length); | 496 | // printf("%d\r",length); |
497 | // fflush(stdout); | 497 | // fflush(stdout); |
498 | } | 498 | } |
499 | 499 | ||
500 | } else { //AFMT_U8 | 500 | } else { //AFMT_U8 |
501 | // 8bit unsigned | 501 | // 8bit unsigned |
502 | unsigned short sound[512], monoBuffer[512]; | 502 | unsigned short sound[512], monoBuffer[512]; |
503 | while(recording) { | 503 | while(recording) { |
504 | result = read(dsp, sound, 512); // 8192 | 504 | result = read(dsp, sound, 512); // 8192 |
505 | int j=0; | 505 | int j=0; |
506 | 506 | ||
507 | // if(systemZaurus) { | 507 | // if(systemZaurus) { |
508 | 508 | ||
509 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 509 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
510 | monoBuffer[i] = sound[i]; | 510 | monoBuffer[i] = sound[i]; |
511 | } | 511 | } |
512 | 512 | ||
513 | length+=write(wav, monoBuffer, result); | 513 | length+=write(wav, monoBuffer, result); |
514 | 514 | ||
515 | // } else { //ipaq /stereo inputs | 515 | // } else { //ipaq /stereo inputs |
516 | 516 | ||
517 | // for (int i = 0; i < result; i+=2) { | 517 | // for (int i = 0; i < result; i+=2) { |
518 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 518 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; |
519 | // j++; | 519 | // j++; |
520 | // } | 520 | // } |
521 | 521 | ||
522 | // length+=write(wav, monoBuffer, result/2); | 522 | // length+=write(wav, monoBuffer, result/2); |
523 | 523 | ||
524 | // if(length<0) | 524 | // if(length<0) |
525 | // recording=false; | 525 | // recording=false; |
526 | 526 | ||
527 | // } | 527 | // } |
528 | length += result; | 528 | length += result; |
529 | // printf("%d\r",length); | 529 | // printf("%d\r",length); |
530 | // fflush(stdout); | 530 | // fflush(stdout); |
531 | } | 531 | } |
532 | 532 | ||
533 | qApp->processEvents(); | 533 | qApp->processEvents(); |
534 | } | 534 | } |
535 | 535 | ||
536 | } else { // 16 bit only capabilities | 536 | } else { // 16 bit only capabilities |
537 | 537 | ||
538 | 538 | ||
539 | msg.sprintf("Recording format other"); | 539 | msg.sprintf("Recording format other"); |
540 | qDebug(msg); | 540 | qDebug(msg); |
541 | 541 | ||
542 | signed short sound[512], monoBuffer[512]; | 542 | signed short sound[512], monoBuffer[512]; |
543 | 543 | ||
544 | while(recording) { | 544 | while(recording) { |
545 | 545 | ||
546 | result = read(dsp, sound, 512); // 8192 | 546 | result = read(dsp, sound, 512); // 8192 |
547 | 547 | ||
548 | write(wav, sound, result); | 548 | write(wav, sound, result); |
549 | length += result; | 549 | length += result; |
550 | if(length<0) { | 550 | if(length<0) { |
551 | 551 | ||
552 | recording=false; | 552 | recording=false; |
553 | perror("dev/dsp's is a lookin' messy"); | 553 | perror("dev/dsp's is a lookin' messy"); |
554 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 554 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
555 | } | 555 | } |
556 | // printf("%d\r",length); | 556 | // printf("%d\r",length); |
557 | // fflush(stdout); | 557 | // fflush(stdout); |
558 | qApp->processEvents(); | 558 | qApp->processEvents(); |
559 | } | 559 | } |
560 | // qDebug("file has length of %d lasting %d seconds", | 560 | // qDebug("file has length of %d lasting %d seconds", |
561 | // length, (( length / speed) / channels) / 2 ); | 561 | // length, (( length / speed) / channels) / 2 ); |
562 | // medialplayer states wrong length in secs | 562 | // medialplayer states wrong length in secs |
563 | } | 563 | } |
564 | 564 | ||
565 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// | 565 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// |
566 | 566 | ||
567 | value = length+36; | 567 | value = length+36; |
568 | 568 | ||
569 | lseek(wav, 4, SEEK_SET); | 569 | lseek(wav, 4, SEEK_SET); |
570 | write(wav, &value, 4); | 570 | write(wav, &value, 4); |
571 | lseek(wav, 40, SEEK_SET); | 571 | lseek(wav, 40, SEEK_SET); |
572 | 572 | ||
573 | write(wav, &length, 4); | 573 | write(wav, &length, 4); |
574 | 574 | ||
575 | track.close(); | 575 | track.close(); |
576 | qDebug("Tracvk closed"); | 576 | qDebug("Tracvk closed"); |
577 | 577 | ||
578 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 578 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
579 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 579 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
580 | 580 | ||
581 | ::close(dsp); | 581 | ::close(dsp); |
582 | fileName = fileName.left(fileName.length()-4); | 582 | fileName = fileName.left(fileName.length()-4); |
583 | // if(useAlerts) | 583 | // if(useAlerts) |
584 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 584 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
585 | qDebug("done recording "+fileName); | 585 | qDebug("done recording "+fileName); |
586 | QSound::play(Resource::findSound("vmemoe")); | 586 | QSound::play(Resource::findSound("vmemoe")); |
587 | 587 | ||
588 | Config cfg("qpe"); | 588 | Config cfg("qpe"); |
589 | cfg.setGroup("Volume"); | 589 | cfg.setGroup("Volume"); |
590 | QString foo = cfg.readEntry("Mute","TRUE"); | 590 | QString foo = cfg.readEntry("Mute","TRUE"); |
591 | if(foo.find("TRUE",0,TRUE) != -1) | 591 | if(foo.find("TRUE",0,TRUE) != -1) |
592 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 592 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
593 | 593 | ||
594 | } | 594 | } |
595 | 595 | ||
596 | int VMemo::setToggleButton(int tog) { | 596 | int VMemo::setToggleButton(int tog) { |
597 | 597 | ||
598 | for( int i=0; i < 10;i++) { | 598 | for( int i=0; i < 10;i++) { |
599 | switch (tog) { | 599 | switch (tog) { |
600 | case 0: | 600 | case 0: |
601 | return -1; | 601 | return -1; |
602 | break; | 602 | break; |
603 | case 1: | 603 | case 1: |
604 | return 0; | 604 | return 0; |
605 | break; | 605 | break; |
606 | case 2: | 606 | case 2: |
607 | return Key_Escape; | 607 | return Key_Escape; |
608 | break; | 608 | break; |
609 | case 3: | 609 | case 3: |
610 | return Key_Space; | 610 | return Key_Space; |
611 | break; | 611 | break; |
612 | case 4: | 612 | case 4: |
613 | return Key_F12; | 613 | return Key_F12; |
614 | break; | 614 | break; |
615 | case 5: | 615 | case 5: |
616 | return Key_F9; | 616 | return Key_F9; |
617 | break; | 617 | break; |
618 | case 6: | 618 | case 6: |
619 | return Key_F10; | 619 | return Key_F10; |
620 | break; | 620 | break; |
621 | case 7: | 621 | case 7: |
622 | return Key_F11; | 622 | return Key_F11; |
623 | break; | 623 | break; |
624 | case 8: | 624 | case 8: |
625 | return Key_F13; | 625 | return Key_F13; |
626 | break; | 626 | break; |
627 | }; | 627 | }; |
628 | } | 628 | } |
629 | return -1; | ||
629 | } | 630 | } |
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 8299b3d..7a67ab2 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,1134 +1,1134 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qabstractlayout.h> | 7 | #include <qabstractlayout.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | #include <qpainter.h> | 12 | #include <qpainter.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qwidgetstack.h> | 14 | #include <qwidgetstack.h> |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <qfile.h> | 17 | #include <qfile.h> |
18 | #include <qfileinfo.h> | 18 | #include <qfileinfo.h> |
19 | #include <qtimer.h> | 19 | #include <qtimer.h> |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | #include <qpe/fileselector.h> | 23 | #include <qpe/fileselector.h> |
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/mimetype.h> | 25 | #include <qpe/mimetype.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/storage.h> | 27 | #include <qpe/storage.h> |
28 | 28 | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | 32 | ||
33 | #include "ofileselector.h" | 33 | #include "ofileselector.h" |
34 | 34 | ||
35 | 35 | ||
36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
37 | 37 | ||
38 | namespace { | 38 | namespace { |
39 | int indexByString( const QComboBox *box, const QString &str ){ | 39 | int indexByString( const QComboBox *box, const QString &str ){ |
40 | int index= 0; | 40 | int index= 0; |
41 | for(int i= 0; i < box->count(); i++ ){ | 41 | for(int i= 0; i < box->count(); i++ ){ |
42 | if( str == box->text(i ) ){ | 42 | if( str == box->text(i ) ){ |
43 | index= i; | 43 | index= i; |
44 | break; | 44 | break; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | return index; | 47 | return index; |
48 | } | 48 | } |
49 | class OFileSelectorItem : public QListViewItem { | 49 | class OFileSelectorItem : public QListViewItem { |
50 | public: | 50 | public: |
51 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 51 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
52 | const QString &date, const QString &size, const QString &mDir, | 52 | const QString &date, const QString &size, const QString &mDir, |
53 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 53 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
54 | setPixmap(0, pixmap ); | 54 | setPixmap(0, pixmap ); |
55 | setText(1, path ); | 55 | setText(1, path ); |
56 | setText(2, size ); | 56 | setText(2, size ); |
57 | setText(3, date ); | 57 | setText(3, date ); |
58 | //setText(4, mDir ); | 58 | //setText(4, mDir ); |
59 | m_dir = mDir; | 59 | m_dir = mDir; |
60 | dir = isDir; | 60 | dir = isDir; |
61 | mLocked = isLocked; | 61 | mLocked = isLocked; |
62 | } | 62 | } |
63 | bool isLocked() const{ | 63 | bool isLocked() const{ |
64 | return mLocked; | 64 | return mLocked; |
65 | } | 65 | } |
66 | QString directory()const{ | 66 | QString directory()const{ |
67 | return m_dir; | 67 | return m_dir; |
68 | } | 68 | } |
69 | bool isDir()const{ | 69 | bool isDir()const{ |
70 | return dir; | 70 | return dir; |
71 | } | 71 | } |
72 | QString path()const{ | 72 | QString path()const{ |
73 | return text(1 ); | 73 | return text(1 ); |
74 | } | 74 | } |
75 | QString key(int id, bool )const { | 75 | QString key(int id, bool )const { |
76 | QString ke; | 76 | QString ke; |
77 | if( id == 0 || id == 1 ){ // name | 77 | if( id == 0 || id == 1 ){ // name |
78 | if( dir ){ | 78 | if( dir ){ |
79 | ke.append("0" ); | 79 | ke.append("0" ); |
80 | ke.append( text(1) ); | 80 | ke.append( text(1) ); |
81 | }else{ | 81 | }else{ |
82 | ke.append("1" ); | 82 | ke.append("1" ); |
83 | ke.append( text(1) ); | 83 | ke.append( text(1) ); |
84 | } | 84 | } |
85 | }else if( id == 2 ){ // size | 85 | }else if( id == 2 ){ // size |
86 | return text(2); | 86 | return text(2); |
87 | }else if( id == 3 ){ // date | 87 | }else if( id == 3 ){ // date |
88 | return text(3); | 88 | return text(3); |
89 | } | 89 | } |
90 | return ke; | 90 | return ke; |
91 | }; | 91 | }; |
92 | private: | 92 | private: |
93 | bool mLocked:1; | 93 | bool mLocked:1; |
94 | bool dir:1; | 94 | bool dir:1; |
95 | QString m_dir; | 95 | QString m_dir; |
96 | }; | 96 | }; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
101 | const QString &dirName, | 101 | const QString &dirName, |
102 | const QString &fileName, | 102 | const QString &fileName, |
103 | const QStringList &mimeTypes ) | 103 | const QStringList &mimeTypes ) |
104 | : QWidget( wid, "OFileSelector") | 104 | : QWidget( wid, "OFileSelector") |
105 | { | 105 | { |
106 | m_mimetypes = mimeTypes; | 106 | m_mimetypes = mimeTypes; |
107 | initVars(); | 107 | initVars(); |
108 | m_mode = mode; | 108 | m_mode = mode; |
109 | m_selector = selector; | 109 | m_selector = selector; |
110 | m_currentDir = dirName; | 110 | m_currentDir = dirName; |
111 | init(); | 111 | init(); |
112 | QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | 112 | QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); |
113 | } | 113 | } |
114 | 114 | ||
115 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 115 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
116 | const char *name, bool newVisible = TRUE, | 116 | const char *name, bool newVisible, |
117 | bool closeVisible = FALSE ) | 117 | bool closeVisible ) |
118 | : QWidget( parent, name ) | 118 | : QWidget( parent, name ) |
119 | { | 119 | { |
120 | m_mimetypes = QStringList::split(";", mimeFilter ); | 120 | m_mimetypes = QStringList::split(";", mimeFilter ); |
121 | initVars(); | 121 | initVars(); |
122 | m_currentDir = QPEApplication::documentDir(); | 122 | m_currentDir = QPEApplication::documentDir(); |
123 | m_mode = OPEN; | 123 | m_mode = OPEN; |
124 | m_selector = NORMAL; | 124 | m_selector = NORMAL; |
125 | m_shClose = closeVisible; | 125 | m_shClose = closeVisible; |
126 | m_shNew = newVisible; | 126 | m_shNew = newVisible; |
127 | m_shLne = false; | 127 | m_shLne = false; |
128 | m_shPerm = false; | 128 | m_shPerm = false; |
129 | m_shYesNo = false; | 129 | m_shYesNo = false; |
130 | init(); | 130 | init(); |
131 | 131 | ||
132 | 132 | ||
133 | } | 133 | } |
134 | 134 | ||
135 | OFileSelector::~OFileSelector() | 135 | OFileSelector::~OFileSelector() |
136 | { | 136 | { |
137 | 137 | ||
138 | } | 138 | } |
139 | 139 | ||
140 | void OFileSelector::setNewVisible( bool visible ) | 140 | void OFileSelector::setNewVisible( bool visible ) |
141 | { | 141 | { |
142 | m_shNew = visible; | 142 | m_shNew = visible; |
143 | if( m_selector == NORMAL ){ | 143 | if( m_selector == NORMAL ){ |
144 | delete m_select; | 144 | delete m_select; |
145 | // we need to initialize but keep the selected mimetype | 145 | // we need to initialize but keep the selected mimetype |
146 | QString mime = m_mimeCheck == 0 ? QString::null : m_mimeCheck->currentText() ; | 146 | QString mime = m_mimeCheck == 0 ? QString::null : m_mimeCheck->currentText() ; |
147 | m_select = new FileSelector( m_autoMime ? mime : m_mimetypes.join(";") , | 147 | m_select = new FileSelector( m_autoMime ? mime : m_mimetypes.join(";") , |
148 | m_stack, "fileselector", | 148 | m_stack, "fileselector", |
149 | m_shNew, m_shClose); | 149 | m_shNew, m_shClose); |
150 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 150 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
151 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 151 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
152 | //connect to close me and other signals as well | 152 | //connect to close me and other signals as well |
153 | m_stack->addWidget( m_select, NORMAL ); | 153 | m_stack->addWidget( m_select, NORMAL ); |
154 | }else{ | 154 | }else{ |
155 | m_new->show(); | 155 | m_new->show(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | void OFileSelector::setCloseVisible( bool visible ) | 158 | void OFileSelector::setCloseVisible( bool visible ) |
159 | { | 159 | { |
160 | m_shClose = visible; | 160 | m_shClose = visible; |
161 | if( m_selector == NORMAL ){ | 161 | if( m_selector == NORMAL ){ |
162 | setNewVisible( m_shNew ); // yeah baby | 162 | setNewVisible( m_shNew ); // yeah baby |
163 | }else{ | 163 | }else{ |
164 | m_close->show(); | 164 | m_close->show(); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | void OFileSelector::reread() | 167 | void OFileSelector::reread() |
168 | { | 168 | { |
169 | if( m_selector == NORMAL ){ | 169 | if( m_selector == NORMAL ){ |
170 | setNewVisible( m_shNew ); // make it a initializeSelector | 170 | setNewVisible( m_shNew ); // make it a initializeSelector |
171 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 171 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
172 | reparse(); | 172 | reparse(); |
173 | //}else{ | 173 | //}else{ |
174 | //; | 174 | //; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | const DocLnk *OFileSelector::selected() | 178 | const DocLnk *OFileSelector::selected() |
179 | { | 179 | { |
180 | if( m_selector == NORMAL ){ | 180 | if( m_selector == NORMAL ){ |
181 | return m_select->selected(); | 181 | return m_select->selected(); |
182 | }else{ | 182 | }else{ |
183 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 183 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
184 | return lnk; | 184 | return lnk; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void OFileSelector::setYesCancelVisible( bool show ) | 188 | void OFileSelector::setYesCancelVisible( bool show ) |
189 | { | 189 | { |
190 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 190 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
191 | m_shYesNo = show; | 191 | m_shYesNo = show; |
192 | if( m_shYesNo ) | 192 | if( m_shYesNo ) |
193 | m_boxOk->show(); | 193 | m_boxOk->show(); |
194 | else | 194 | else |
195 | m_boxOk->hide(); | 195 | m_boxOk->hide(); |
196 | 196 | ||
197 | } | 197 | } |
198 | void OFileSelector::setToolbarVisible( bool show ) | 198 | void OFileSelector::setToolbarVisible( bool show ) |
199 | { | 199 | { |
200 | m_shTool = show; | 200 | m_shTool = show; |
201 | initializeListView(); // FIXME see above waste of memory | 201 | initializeListView(); // FIXME see above waste of memory |
202 | if(!m_shTool ){ | 202 | if(!m_shTool ){ |
203 | m_location->hide(); | 203 | m_location->hide(); |
204 | m_up->hide(); | 204 | m_up->hide(); |
205 | m_homeButton->hide(); | 205 | m_homeButton->hide(); |
206 | m_docButton->hide(); | 206 | m_docButton->hide(); |
207 | }else{ | 207 | }else{ |
208 | m_location->show(); | 208 | m_location->show(); |
209 | m_up->show(); | 209 | m_up->show(); |
210 | m_homeButton->show(); | 210 | m_homeButton->show(); |
211 | m_docButton->show(); | 211 | m_docButton->show(); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | void OFileSelector::setPermissionBarVisible( bool show ) | 214 | void OFileSelector::setPermissionBarVisible( bool show ) |
215 | { | 215 | { |
216 | m_shPerm = show; | 216 | m_shPerm = show; |
217 | initializePerm(); | 217 | initializePerm(); |
218 | if( m_shPerm ) | 218 | if( m_shPerm ) |
219 | m_checkPerm->show(); | 219 | m_checkPerm->show(); |
220 | else | 220 | else |
221 | m_checkPerm->hide(); | 221 | m_checkPerm->hide(); |
222 | } | 222 | } |
223 | void OFileSelector::setLineEditVisible( bool show ) | 223 | void OFileSelector::setLineEditVisible( bool show ) |
224 | { | 224 | { |
225 | if( show ){ | 225 | if( show ){ |
226 | initializeName(); | 226 | initializeName(); |
227 | m_boxName->show(); | 227 | m_boxName->show(); |
228 | }else{ | 228 | }else{ |
229 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go | 229 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go |
230 | m_boxName->hide(); | 230 | m_boxName->hide(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | m_shLne = show; | 233 | m_shLne = show; |
234 | } | 234 | } |
235 | 235 | ||
236 | void OFileSelector::setChooserVisible( bool show ) | 236 | void OFileSelector::setChooserVisible( bool show ) |
237 | { | 237 | { |
238 | m_shChooser = show; | 238 | m_shChooser = show; |
239 | initializeChooser(); | 239 | initializeChooser(); |
240 | if( m_shChooser ){ | 240 | if( m_shChooser ){ |
241 | m_boxView->hide(); | 241 | m_boxView->hide(); |
242 | }else{ | 242 | }else{ |
243 | m_boxView->show(); | 243 | m_boxView->show(); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | QCheckBox* OFileSelector::permissionCheckbox() | 247 | QCheckBox* OFileSelector::permissionCheckbox() |
248 | { | 248 | { |
249 | if( m_selector == NORMAL ) | 249 | if( m_selector == NORMAL ) |
250 | return 0l; | 250 | return 0l; |
251 | else | 251 | else |
252 | return m_checkPerm; | 252 | return m_checkPerm; |
253 | } | 253 | } |
254 | bool OFileSelector::setPermission()const | 254 | bool OFileSelector::setPermission()const |
255 | { | 255 | { |
256 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 256 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
257 | } | 257 | } |
258 | void OFileSelector::setPermissionChecked( bool check ) | 258 | void OFileSelector::setPermissionChecked( bool check ) |
259 | { | 259 | { |
260 | if( m_checkPerm ) | 260 | if( m_checkPerm ) |
261 | m_checkPerm->setChecked( check ); | 261 | m_checkPerm->setChecked( check ); |
262 | } | 262 | } |
263 | 263 | ||
264 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 264 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
265 | { | 265 | { |
266 | m_mode = mode; | 266 | m_mode = mode; |
267 | if( m_selector == NORMAL ) | 267 | if( m_selector == NORMAL ) |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | void OFileSelector::setShowDirs(bool ) | 270 | void OFileSelector::setShowDirs(bool ) |
271 | { | 271 | { |
272 | m_dir = true; | 272 | m_dir = true; |
273 | reparse(); | 273 | reparse(); |
274 | } | 274 | } |
275 | void OFileSelector::setCaseSensetive(bool caSe ) | 275 | void OFileSelector::setCaseSensetive(bool caSe ) |
276 | { | 276 | { |
277 | m_case = caSe; | 277 | m_case = caSe; |
278 | reparse(); | 278 | reparse(); |
279 | } | 279 | } |
280 | void OFileSelector::setShowFiles(bool show ) | 280 | void OFileSelector::setShowFiles(bool show ) |
281 | { | 281 | { |
282 | m_files = show; | 282 | m_files = show; |
283 | reparse(); | 283 | reparse(); |
284 | } | 284 | } |
285 | /// | 285 | /// |
286 | bool OFileSelector::cd(const QString &path ) | 286 | bool OFileSelector::cd(const QString &path ) |
287 | { | 287 | { |
288 | m_currentDir = path; | 288 | m_currentDir = path; |
289 | reparse(); | 289 | reparse(); |
290 | return true; | 290 | return true; |
291 | } | 291 | } |
292 | void OFileSelector::setSelector(int mode ) | 292 | void OFileSelector::setSelector(int mode ) |
293 | { | 293 | { |
294 | QString text; | 294 | QString text; |
295 | switch( mode ){ | 295 | switch( mode ){ |
296 | case NORMAL: | 296 | case NORMAL: |
297 | text = tr("Documents"); | 297 | text = tr("Documents"); |
298 | break; | 298 | break; |
299 | case EXTENDED: | 299 | case EXTENDED: |
300 | text = tr("Files"); | 300 | text = tr("Files"); |
301 | break; | 301 | break; |
302 | case EXTENDED_ALL: | 302 | case EXTENDED_ALL: |
303 | text = tr("All Files"); | 303 | text = tr("All Files"); |
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | slotViewCheck( text ); | 306 | slotViewCheck( text ); |
307 | } | 307 | } |
308 | 308 | ||
309 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) | 309 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) |
310 | { | 310 | { |
311 | m_custom = popup; | 311 | m_custom = popup; |
312 | m_showPopup = true; | 312 | m_showPopup = true; |
313 | } | 313 | } |
314 | 314 | ||
315 | //void OFileSelector::updateL | 315 | //void OFileSelector::updateL |
316 | 316 | ||
317 | QString OFileSelector::selectedName() const | 317 | QString OFileSelector::selectedName() const |
318 | { | 318 | { |
319 | QString name; | 319 | QString name; |
320 | if( m_selector == NORMAL ){ | 320 | if( m_selector == NORMAL ){ |
321 | const DocLnk *lnk = m_select->selected(); | 321 | const DocLnk *lnk = m_select->selected(); |
322 | name = lnk->file(); | 322 | name = lnk->file(); |
323 | delete lnk; | 323 | delete lnk; |
324 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 324 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
325 | QListViewItem *item = m_View->currentItem(); | 325 | QListViewItem *item = m_View->currentItem(); |
326 | if( item != 0 ) | 326 | if( item != 0 ) |
327 | name = m_currentDir + "/" + item->text( 1 ); | 327 | name = m_currentDir + "/" + item->text( 1 ); |
328 | }else { // installed view | 328 | }else { // installed view |
329 | ; | 329 | ; |
330 | } | 330 | } |
331 | return name; | 331 | return name; |
332 | } | 332 | } |
333 | QStringList OFileSelector::selectedNames()const | 333 | QStringList OFileSelector::selectedNames()const |
334 | { | 334 | { |
335 | QStringList list; | 335 | QStringList list; |
336 | if( m_selector == NORMAL ){ | 336 | if( m_selector == NORMAL ){ |
337 | list << selectedName(); | 337 | list << selectedName(); |
338 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 338 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
339 | list << selectedName(); // FIXME implement multiple Selections | 339 | list << selectedName(); // FIXME implement multiple Selections |
340 | } | 340 | } |
341 | return list; | 341 | return list; |
342 | } | 342 | } |
343 | /** If mode is set to the Dir selection this will return the selected path. | 343 | /** If mode is set to the Dir selection this will return the selected path. |
344 | * | 344 | * |
345 | * | 345 | * |
346 | */ | 346 | */ |
347 | QString OFileSelector::selectedPath()const | 347 | QString OFileSelector::selectedPath()const |
348 | { | 348 | { |
349 | QString path; | 349 | QString path; |
350 | if( m_selector == NORMAL ){ | 350 | if( m_selector == NORMAL ){ |
351 | path = QPEApplication::documentDir(); | 351 | path = QPEApplication::documentDir(); |
352 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 352 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
353 | ; | 353 | ; |
354 | } | 354 | } |
355 | return path; | 355 | return path; |
356 | } | 356 | } |
357 | QStringList OFileSelector::selectedPaths() const | 357 | QStringList OFileSelector::selectedPaths() const |
358 | { | 358 | { |
359 | QStringList list; | 359 | QStringList list; |
360 | list << selectedPath(); | 360 | list << selectedPath(); |
361 | return list; | 361 | return list; |
362 | } | 362 | } |
363 | QString OFileSelector::directory()const | 363 | QString OFileSelector::directory()const |
364 | { | 364 | { |
365 | if( m_selector == NORMAL ) | 365 | if( m_selector == NORMAL ) |
366 | return QPEApplication::documentDir(); | 366 | return QPEApplication::documentDir(); |
367 | 367 | ||
368 | return QDir(m_currentDir).absPath(); | 368 | return QDir(m_currentDir).absPath(); |
369 | } | 369 | } |
370 | 370 | ||
371 | int OFileSelector::fileCount() | 371 | int OFileSelector::fileCount() |
372 | { | 372 | { |
373 | int count; | 373 | int count; |
374 | switch( m_selector ){ | 374 | switch( m_selector ){ |
375 | case NORMAL: | 375 | case NORMAL: |
376 | count = m_select->fileCount(); | 376 | count = m_select->fileCount(); |
377 | break; | 377 | break; |
378 | //case CUSTOM: | 378 | //case CUSTOM: |
379 | case EXTENDED: | 379 | case EXTENDED: |
380 | case EXTENDED_ALL: | 380 | case EXTENDED_ALL: |
381 | default: | 381 | default: |
382 | count = m_View->childCount(); | 382 | count = m_View->childCount(); |
383 | break; | 383 | break; |
384 | } | 384 | } |
385 | return count; | 385 | return count; |
386 | } | 386 | } |
387 | DocLnk OFileSelector::selectedDocument() const | 387 | DocLnk OFileSelector::selectedDocument() const |
388 | { | 388 | { |
389 | DocLnk lnk; | 389 | DocLnk lnk; |
390 | switch( m_selector ){ | 390 | switch( m_selector ){ |
391 | case NORMAL:{ | 391 | case NORMAL:{ |
392 | const DocLnk *lnk2 = m_select->selected(); | 392 | const DocLnk *lnk2 = m_select->selected(); |
393 | lnk = DocLnk(*lnk2 ); // copy | 393 | lnk = DocLnk(*lnk2 ); // copy |
394 | delete lnk2; | 394 | delete lnk2; |
395 | break; | 395 | break; |
396 | } | 396 | } |
397 | case EXTENDED: | 397 | case EXTENDED: |
398 | case EXTENDED_ALL: | 398 | case EXTENDED_ALL: |
399 | default: | 399 | default: |
400 | lnk = DocLnk( selectedName() ); // new DocLnk | 400 | lnk = DocLnk( selectedName() ); // new DocLnk |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | return lnk; | 403 | return lnk; |
404 | } | 404 | } |
405 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 405 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
406 | { | 406 | { |
407 | QValueList<DocLnk> docs; | 407 | QValueList<DocLnk> docs; |
408 | docs.append( selectedDocument() ); | 408 | docs.append( selectedDocument() ); |
409 | return docs; | 409 | return docs; |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | // slots internal | 413 | // slots internal |
414 | 414 | ||
415 | void OFileSelector::slotOk() | 415 | void OFileSelector::slotOk() |
416 | { | 416 | { |
417 | emit ok(); | 417 | emit ok(); |
418 | } | 418 | } |
419 | void OFileSelector::slotCancel() | 419 | void OFileSelector::slotCancel() |
420 | { | 420 | { |
421 | emit cancel(); | 421 | emit cancel(); |
422 | } | 422 | } |
423 | void OFileSelector::slotViewCheck(const QString &sel) | 423 | void OFileSelector::slotViewCheck(const QString &sel) |
424 | { | 424 | { |
425 | if( sel == tr("Documents" ) ){ | 425 | if( sel == tr("Documents" ) ){ |
426 | if( m_select == 0 ){ | 426 | if( m_select == 0 ){ |
427 | // autMime? fix cause now we use All and not the current | 427 | // autMime? fix cause now we use All and not the current |
428 | m_select = new FileSelector(m_autoMime ? QString::null : m_mimetypes.join(";"), | 428 | m_select = new FileSelector(m_autoMime ? QString::null : m_mimetypes.join(";"), |
429 | m_stack, "fileselector", | 429 | m_stack, "fileselector", |
430 | FALSE, FALSE); | 430 | FALSE, FALSE); |
431 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 431 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
432 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 432 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
433 | //connect to close me and other signals as well | 433 | //connect to close me and other signals as well |
434 | 434 | ||
435 | m_stack->addWidget( m_select, NORMAL ); | 435 | m_stack->addWidget( m_select, NORMAL ); |
436 | } | 436 | } |
437 | m_stack->raiseWidget( NORMAL ); | 437 | m_stack->raiseWidget( NORMAL ); |
438 | m_selector = NORMAL; | 438 | m_selector = NORMAL; |
439 | }else if( sel == tr("Files") ){ | 439 | }else if( sel == tr("Files") ){ |
440 | m_selector = EXTENDED; | 440 | m_selector = EXTENDED; |
441 | initializeListView(); | 441 | initializeListView(); |
442 | reparse(); | 442 | reparse(); |
443 | m_stack->raiseWidget( EXTENDED ); | 443 | m_stack->raiseWidget( EXTENDED ); |
444 | }else if( sel == tr("All Files") ){ | 444 | }else if( sel == tr("All Files") ){ |
445 | m_selector = EXTENDED_ALL; | 445 | m_selector = EXTENDED_ALL; |
446 | initializeListView(); | 446 | initializeListView(); |
447 | reparse(); | 447 | reparse(); |
448 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter | 448 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter |
449 | } | 449 | } |
450 | } | 450 | } |
451 | void OFileSelector::slotMimeCheck(const QString &mime) | 451 | void OFileSelector::slotMimeCheck(const QString &mime) |
452 | { | 452 | { |
453 | if( m_selector == NORMAL ){ | 453 | if( m_selector == NORMAL ){ |
454 | if( m_autoMime ){ | 454 | if( m_autoMime ){ |
455 | delete m_select; | 455 | delete m_select; |
456 | m_select = new FileSelector( mime == tr("All") ? QString::null : mime, | 456 | m_select = new FileSelector( mime == tr("All") ? QString::null : mime, |
457 | m_stack, "fileselector", | 457 | m_stack, "fileselector", |
458 | FALSE, FALSE); | 458 | FALSE, FALSE); |
459 | 459 | ||
460 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 460 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
461 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 461 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
462 | //connect to close me and other signals as well | 462 | //connect to close me and other signals as well |
463 | m_stack->addWidget( m_select, NORMAL ); | 463 | m_stack->addWidget( m_select, NORMAL ); |
464 | m_stack->raiseWidget( NORMAL ); | 464 | m_stack->raiseWidget( NORMAL ); |
465 | updateMimes(); | 465 | updateMimes(); |
466 | m_mimeCheck->clear(); | 466 | m_mimeCheck->clear(); |
467 | m_mimeCheck->insertStringList(m_mimetypes ); | 467 | m_mimeCheck->insertStringList(m_mimetypes ); |
468 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 468 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
469 | } | 469 | } |
470 | }else{ // others | 470 | }else{ // others |
471 | qWarning("Mime %s", mime.latin1() ); | 471 | qWarning("Mime %s", mime.latin1() ); |
472 | if(m_shChooser ){ | 472 | if(m_shChooser ){ |
473 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 473 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
474 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 474 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
475 | } | 475 | } |
476 | reparse(); | 476 | reparse(); |
477 | } | 477 | } |
478 | 478 | ||
479 | } | 479 | } |
480 | void OFileSelector::slotLocationActivated(const QString &file) | 480 | void OFileSelector::slotLocationActivated(const QString &file) |
481 | { | 481 | { |
482 | cd(file.left(file.find("<-",0,TRUE))); | 482 | cd(file.left(file.find("<-",0,TRUE))); |
483 | reparse(); | 483 | reparse(); |
484 | } | 484 | } |
485 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 485 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
486 | { | 486 | { |
487 | QStringList pathList; | 487 | QStringList pathList; |
488 | bool underDog = FALSE; | 488 | bool underDog = FALSE; |
489 | for(int i=0;i<count;i++) { | 489 | for(int i=0;i<count;i++) { |
490 | pathList << m_location->text(i); | 490 | pathList << m_location->text(i); |
491 | if( m_location->text(i) == currentPath) | 491 | if( m_location->text(i) == currentPath) |
492 | underDog = TRUE; | 492 | underDog = TRUE; |
493 | } | 493 | } |
494 | if( !underDog) { | 494 | if( !underDog) { |
495 | m_location->clear(); | 495 | m_location->clear(); |
496 | if( currentPath.left(2)=="//") | 496 | if( currentPath.left(2)=="//") |
497 | pathList.append( currentPath.right(currentPath.length()-1) ); | 497 | pathList.append( currentPath.right(currentPath.length()-1) ); |
498 | else | 498 | else |
499 | pathList.append( currentPath ); | 499 | pathList.append( currentPath ); |
500 | m_location->insertStringList( pathList,-1); | 500 | m_location->insertStringList( pathList,-1); |
501 | } | 501 | } |
502 | } | 502 | } |
503 | void OFileSelector::locationComboChanged() | 503 | void OFileSelector::locationComboChanged() |
504 | { | 504 | { |
505 | cd( m_location->lineEdit()->text()); | 505 | cd( m_location->lineEdit()->text()); |
506 | reparse(); | 506 | reparse(); |
507 | } | 507 | } |
508 | void OFileSelector::init() | 508 | void OFileSelector::init() |
509 | { | 509 | { |
510 | m_lay = new QVBoxLayout( this ); | 510 | m_lay = new QVBoxLayout( this ); |
511 | m_lay->setSpacing(0 ); | 511 | m_lay->setSpacing(0 ); |
512 | 512 | ||
513 | m_stack = new QWidgetStack( this ); | 513 | m_stack = new QWidgetStack( this ); |
514 | if( m_selector == NORMAL ){ | 514 | if( m_selector == NORMAL ){ |
515 | m_select = new FileSelector(m_autoMime ? QString::null : m_mimetypes.join(";"), | 515 | m_select = new FileSelector(m_autoMime ? QString::null : m_mimetypes.join(";"), |
516 | m_stack, "fileselector", | 516 | m_stack, "fileselector", |
517 | FALSE, FALSE); | 517 | FALSE, FALSE); |
518 | 518 | ||
519 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 519 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
520 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 520 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
521 | //connect to close me and other signals as well | 521 | //connect to close me and other signals as well |
522 | 522 | ||
523 | m_stack->addWidget( m_select, NORMAL ); | 523 | m_stack->addWidget( m_select, NORMAL ); |
524 | m_stack->raiseWidget( NORMAL ); | 524 | m_stack->raiseWidget( NORMAL ); |
525 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | 525 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL |
526 | // and initializeListview will take care of those | 526 | // and initializeListview will take care of those |
527 | // toolbar get's generade in initializeListView | 527 | // toolbar get's generade in initializeListView |
528 | initializeListView( ); // will raise the widget as well | 528 | initializeListView( ); // will raise the widget as well |
529 | } | 529 | } |
530 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | 530 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch |
531 | 531 | ||
532 | if( m_shLne ) // the LineEdit with the current FileName | 532 | if( m_shLne ) // the LineEdit with the current FileName |
533 | initializeName(); | 533 | initializeName(); |
534 | 534 | ||
535 | if( m_shPerm ) // the Permission QCheckBox | 535 | if( m_shPerm ) // the Permission QCheckBox |
536 | initializePerm(); | 536 | initializePerm(); |
537 | 537 | ||
538 | if( m_shChooser ) // the Chooser for the view and Mimetypes | 538 | if( m_shChooser ) // the Chooser for the view and Mimetypes |
539 | initializeChooser(); | 539 | initializeChooser(); |
540 | 540 | ||
541 | if( m_shYesNo ) // the Yes No button row | 541 | if( m_shYesNo ) // the Yes No button row |
542 | initializeYes( ); | 542 | initializeYes( ); |
543 | } | 543 | } |
544 | void OFileSelector::updateMimes() | 544 | void OFileSelector::updateMimes() |
545 | { | 545 | { |
546 | if( m_autoMime ){ | 546 | if( m_autoMime ){ |
547 | m_mimetypes.clear(); | 547 | m_mimetypes.clear(); |
548 | m_mimetypes.append( tr("All") ); | 548 | m_mimetypes.append( tr("All") ); |
549 | if( m_selector == NORMAL ){ | 549 | if( m_selector == NORMAL ){ |
550 | DocLnkSet set; | 550 | DocLnkSet set; |
551 | Global::findDocuments(&set, QString::null ); | 551 | Global::findDocuments(&set, QString::null ); |
552 | QListIterator<DocLnk> dit( set.children() ); | 552 | QListIterator<DocLnk> dit( set.children() ); |
553 | for( ; dit.current(); ++dit ){ | 553 | for( ; dit.current(); ++dit ){ |
554 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 554 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
555 | m_mimetypes.append( (*dit)->type() ); | 555 | m_mimetypes.append( (*dit)->type() ); |
556 | } | 556 | } |
557 | }// else done in reparse | 557 | }// else done in reparse |
558 | } | 558 | } |
559 | } | 559 | } |
560 | void OFileSelector::initVars() | 560 | void OFileSelector::initVars() |
561 | { | 561 | { |
562 | if( m_mimetypes.isEmpty() ) | 562 | if( m_mimetypes.isEmpty() ) |
563 | m_autoMime = true; | 563 | m_autoMime = true; |
564 | else | 564 | else |
565 | m_autoMime = false; | 565 | m_autoMime = false; |
566 | m_shClose = false; | 566 | m_shClose = false; |
567 | m_shNew = false; | 567 | m_shNew = false; |
568 | m_shTool = true; | 568 | m_shTool = true; |
569 | m_shPerm = false; | 569 | m_shPerm = false; |
570 | m_shLne = true; | 570 | m_shLne = true; |
571 | m_shChooser = true; | 571 | m_shChooser = true; |
572 | m_shYesNo = true; | 572 | m_shYesNo = true; |
573 | m_case = false; | 573 | m_case = false; |
574 | m_dir = true; | 574 | m_dir = true; |
575 | m_files = true; | 575 | m_files = true; |
576 | m_showPopup = false; | 576 | m_showPopup = false; |
577 | if(m_pixmaps == 0 ) // init the pixmaps | 577 | if(m_pixmaps == 0 ) // init the pixmaps |
578 | initPics(); | 578 | initPics(); |
579 | 579 | ||
580 | // pointers | 580 | // pointers |
581 | m_location = 0; | 581 | m_location = 0; |
582 | m_mimeCheck = 0; | 582 | m_mimeCheck = 0; |
583 | m_viewCheck = 0; | 583 | m_viewCheck = 0; |
584 | m_homeButton = 0; | 584 | m_homeButton = 0; |
585 | m_docButton = 0; | 585 | m_docButton = 0; |
586 | m_hideButton = 0; | 586 | m_hideButton = 0; |
587 | m_ok = 0; | 587 | m_ok = 0; |
588 | m_cancel = 0; | 588 | m_cancel = 0; |
589 | m_reread = 0; | 589 | m_reread = 0; |
590 | m_up = 0; | 590 | m_up = 0; |
591 | m_View = 0; | 591 | m_View = 0; |
592 | m_checkPerm = 0; | 592 | m_checkPerm = 0; |
593 | m_pseudo = 0; | 593 | m_pseudo = 0; |
594 | m_pseudoLayout = 0; | 594 | m_pseudoLayout = 0; |
595 | m_select = 0; | 595 | m_select = 0; |
596 | m_stack = 0; | 596 | m_stack = 0; |
597 | m_lay = 0; | 597 | m_lay = 0; |
598 | m_Oselector = 0; | 598 | m_Oselector = 0; |
599 | m_boxToolbar = 0; | 599 | m_boxToolbar = 0; |
600 | m_boxOk = 0; | 600 | m_boxOk = 0; |
601 | m_boxName = 0; | 601 | m_boxName = 0; |
602 | m_boxView = 0; | 602 | m_boxView = 0; |
603 | m_custom = 0; | 603 | m_custom = 0; |
604 | m_edit = 0; | 604 | m_edit = 0; |
605 | m_fnLabel = 0; | 605 | m_fnLabel = 0; |
606 | m_new = 0; | 606 | m_new = 0; |
607 | m_close = 0; | 607 | m_close = 0; |
608 | } | 608 | } |
609 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) | 609 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) |
610 | { | 610 | { |
611 | if(!m_files) | 611 | if(!m_files) |
612 | return; | 612 | return; |
613 | // if( !compliesMime(info->absFilePath(), mime ) ) | 613 | // if( !compliesMime(info->absFilePath(), mime ) ) |
614 | // return; | 614 | // return; |
615 | MimeType type( info->absFilePath() ); | 615 | MimeType type( info->absFilePath() ); |
616 | if( mime != tr("All") && type.id() != mime ) | 616 | if( mime != tr("All") && type.id() != mime ) |
617 | return; | 617 | return; |
618 | QPixmap pix = type.pixmap(); | 618 | QPixmap pix = type.pixmap(); |
619 | QString dir; | 619 | QString dir; |
620 | QString name; | 620 | QString name; |
621 | bool locked; | 621 | bool locked; |
622 | if( pix.isNull() ) | 622 | if( pix.isNull() ) |
623 | pix = Resource::loadPixmap( "UnknownDocument-14"); | 623 | pix = Resource::loadPixmap( "UnknownDocument-14"); |
624 | dir = info->dirPath( true ); | 624 | dir = info->dirPath( true ); |
625 | if( symlink ) | 625 | if( symlink ) |
626 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | 626 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); |
627 | else { | 627 | else { |
628 | name = info->fileName(); | 628 | name = info->fileName(); |
629 | if( ( m_mode == OPEN && !info->isReadable() )|| | 629 | if( ( m_mode == OPEN && !info->isReadable() )|| |
630 | ( m_mode == SAVE && !info->isWritable() ) ){ | 630 | ( m_mode == SAVE && !info->isWritable() ) ){ |
631 | 631 | ||
632 | locked = true; pix = Resource::loadPixmap("locked"); | 632 | locked = true; pix = Resource::loadPixmap("locked"); |
633 | } | 633 | } |
634 | } | 634 | } |
635 | new OFileSelectorItem( m_View, pix, name, | 635 | new OFileSelectorItem( m_View, pix, name, |
636 | info->lastModified().toString(), | 636 | info->lastModified().toString(), |
637 | QString::number( info->size() ), | 637 | QString::number( info->size() ), |
638 | dir, locked ); | 638 | dir, locked ); |
639 | } | 639 | } |
640 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 640 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
641 | { | 641 | { |
642 | if(!m_dir) | 642 | if(!m_dir) |
643 | return; | 643 | return; |
644 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ | 644 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ |
645 | bool locked = false; | 645 | bool locked = false; |
646 | QString name; | 646 | QString name; |
647 | QPixmap pix; | 647 | QPixmap pix; |
648 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 648 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
649 | locked = true; | 649 | locked = true; |
650 | if( symlink ) | 650 | if( symlink ) |
651 | pix = (*m_pixmaps)["symlinkedlocked"]; | 651 | pix = (*m_pixmaps)["symlinkedlocked"]; |
652 | else | 652 | else |
653 | pix = Resource::loadPixmap("lockedfolder"); | 653 | pix = Resource::loadPixmap("lockedfolder"); |
654 | }else { // readable | 654 | }else { // readable |
655 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; | 655 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; |
656 | } | 656 | } |
657 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | 657 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; |
658 | new OFileSelectorItem( m_View, pix, name, | 658 | new OFileSelectorItem( m_View, pix, name, |
659 | info->lastModified().toString(), | 659 | info->lastModified().toString(), |
660 | QString::number( info->size() ), | 660 | QString::number( info->size() ), |
661 | info->dirPath( true ), locked, | 661 | info->dirPath( true ), locked, |
662 | true ); | 662 | true ); |
663 | 663 | ||
664 | }// else CUSTOM View | 664 | }// else CUSTOM View |
665 | } | 665 | } |
666 | void OFileSelector::delItems() | 666 | void OFileSelector::delItems() |
667 | { | 667 | { |
668 | 668 | ||
669 | } | 669 | } |
670 | void OFileSelector::initializeName() | 670 | void OFileSelector::initializeName() |
671 | { | 671 | { |
672 | /** Name Layout Line | 672 | /** Name Layout Line |
673 | * This is the Layout line arranged in | 673 | * This is the Layout line arranged in |
674 | * horizontal way each components | 674 | * horizontal way each components |
675 | * are next to each other | 675 | * are next to each other |
676 | * but we will only do this if | 676 | * but we will only do this if |
677 | * we didn't initialize a while ago. | 677 | * we didn't initialize a while ago. |
678 | */ | 678 | */ |
679 | if( m_boxName == 0 ){ | 679 | if( m_boxName == 0 ){ |
680 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 680 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
681 | m_fnLabel = new QLabel( m_boxName ); | 681 | m_fnLabel = new QLabel( m_boxName ); |
682 | m_fnLabel->setText( tr("Name:") ); | 682 | m_fnLabel->setText( tr("Name:") ); |
683 | m_edit = new QLineEdit( m_boxName ); | 683 | m_edit = new QLineEdit( m_boxName ); |
684 | //m_boxName->addWidget( m_fnLabel ); | 684 | //m_boxName->addWidget( m_fnLabel ); |
685 | m_boxName->setMargin( 5 ); | 685 | m_boxName->setMargin( 5 ); |
686 | m_boxName->setSpacing( 8 ); | 686 | m_boxName->setSpacing( 8 ); |
687 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | 687 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor |
688 | 688 | ||
689 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | 689 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout |
690 | }// else we already initialized | 690 | }// else we already initialized |
691 | // maybe show the components? | 691 | // maybe show the components? |
692 | // | 692 | // |
693 | } | 693 | } |
694 | void OFileSelector::initializeYes() | 694 | void OFileSelector::initializeYes() |
695 | { | 695 | { |
696 | /** The Save Cancel bar | 696 | /** The Save Cancel bar |
697 | * | 697 | * |
698 | */ | 698 | */ |
699 | if( m_boxOk == 0 ){ | 699 | if( m_boxOk == 0 ){ |
700 | m_boxOk = new QHBox( this ); | 700 | m_boxOk = new QHBox( this ); |
701 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | 701 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); |
702 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | 702 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); |
703 | 703 | ||
704 | //m_boxOk->addWidget( m_ok ); | 704 | //m_boxOk->addWidget( m_ok ); |
705 | //m_boxOk->addWidget( m_cancel ); | 705 | //m_boxOk->addWidget( m_cancel ); |
706 | m_boxOk->setMargin( 5 ); | 706 | m_boxOk->setMargin( 5 ); |
707 | m_boxOk->setSpacing( 10 ); | 707 | m_boxOk->setSpacing( 10 ); |
708 | m_lay->addWidget( m_boxOk, 0 ); | 708 | m_lay->addWidget( m_boxOk, 0 ); |
709 | 709 | ||
710 | connect( m_ok, SIGNAL( clicked() ), | 710 | connect( m_ok, SIGNAL( clicked() ), |
711 | this, SLOT(slotOk() ) ); | 711 | this, SLOT(slotOk() ) ); |
712 | connect( m_cancel, SIGNAL( clicked() ), | 712 | connect( m_cancel, SIGNAL( clicked() ), |
713 | this, SLOT( slotCancel() ) ); | 713 | this, SLOT( slotCancel() ) ); |
714 | } | 714 | } |
715 | } | 715 | } |
716 | void OFileSelector::initializeChooser() | 716 | void OFileSelector::initializeChooser() |
717 | { | 717 | { |
718 | if( m_boxView == 0 ){ | 718 | if( m_boxView == 0 ){ |
719 | m_boxView = new QHBox( this ); | 719 | m_boxView = new QHBox( this ); |
720 | m_viewCheck = new QComboBox( m_boxView, "view check"); | 720 | m_viewCheck = new QComboBox( m_boxView, "view check"); |
721 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | 721 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); |
722 | m_boxView->setSpacing( 8 ); | 722 | m_boxView->setSpacing( 8 ); |
723 | m_lay->addWidget(m_boxView, 0 ); | 723 | m_lay->addWidget(m_boxView, 0 ); |
724 | 724 | ||
725 | m_viewCheck->insertItem( tr("Documents") ); | 725 | m_viewCheck->insertItem( tr("Documents") ); |
726 | m_viewCheck->insertItem( tr("Files") ); | 726 | m_viewCheck->insertItem( tr("Files") ); |
727 | m_viewCheck->insertItem( tr("All Files") ); | 727 | m_viewCheck->insertItem( tr("All Files") ); |
728 | if(!m_autoMime ) | 728 | if(!m_autoMime ) |
729 | m_mimeCheck->insertItem(m_mimetypes.join(",") ); | 729 | m_mimeCheck->insertItem(m_mimetypes.join(",") ); |
730 | else{ | 730 | else{ |
731 | updateMimes(); | 731 | updateMimes(); |
732 | m_mimeCheck->insertStringList( m_mimetypes ); | 732 | m_mimeCheck->insertStringList( m_mimetypes ); |
733 | } | 733 | } |
734 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 734 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
735 | this, SLOT( slotViewCheck(const QString & ) ) ); | 735 | this, SLOT( slotViewCheck(const QString & ) ) ); |
736 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 736 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
737 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 737 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
738 | } | 738 | } |
739 | } | 739 | } |
740 | void OFileSelector::initializeListView() | 740 | void OFileSelector::initializeListView() |
741 | { | 741 | { |
742 | if( m_pseudo == 0 ){ | 742 | if( m_pseudo == 0 ){ |
743 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); | 743 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); |
744 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | 744 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); |
745 | // toolbar | 745 | // toolbar |
746 | m_boxToolbar = new QHBox( m_pseudo ); | 746 | m_boxToolbar = new QHBox( m_pseudo ); |
747 | m_boxToolbar->setSpacing(0 ); // next to each other please | 747 | m_boxToolbar->setSpacing(0 ); // next to each other please |
748 | 748 | ||
749 | // toolbar members | 749 | // toolbar members |
750 | { | 750 | { |
751 | // location QComboBox | 751 | // location QComboBox |
752 | m_location = new QComboBox( m_boxToolbar ); | 752 | m_location = new QComboBox( m_boxToolbar ); |
753 | m_location->setEditable( TRUE ); | 753 | m_location->setEditable( TRUE ); |
754 | m_location->setDuplicatesEnabled( FALSE ); | 754 | m_location->setDuplicatesEnabled( FALSE ); |
755 | connect( m_location, SIGNAL(activated(const QString &) ), | 755 | connect( m_location, SIGNAL(activated(const QString &) ), |
756 | this, SLOT( slotLocationActivated(const QString &) ) ); | 756 | this, SLOT( slotLocationActivated(const QString &) ) ); |
757 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), | 757 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), |
758 | this, SLOT(locationComboChanged() ) ); | 758 | this, SLOT(locationComboChanged() ) ); |
759 | // UP Button | 759 | // UP Button |
760 | m_up = new QPushButton(Resource::loadIconSet("up"),"", | 760 | m_up = new QPushButton(Resource::loadIconSet("up"),"", |
761 | m_boxToolbar,"cdUpButton"); | 761 | m_boxToolbar,"cdUpButton"); |
762 | m_up->setFixedSize( QSize( 20, 20 ) ); | 762 | m_up->setFixedSize( QSize( 20, 20 ) ); |
763 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 763 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); |
764 | m_up->setFlat(TRUE); | 764 | m_up->setFlat(TRUE); |
765 | 765 | ||
766 | // Home Button | 766 | // Home Button |
767 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , | 767 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , |
768 | "", m_boxToolbar); | 768 | "", m_boxToolbar); |
769 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | 769 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); |
770 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 770 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); |
771 | m_homeButton->setFlat(TRUE); | 771 | m_homeButton->setFlat(TRUE); |
772 | // Documents Button | 772 | // Documents Button |
773 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", | 773 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", |
774 | m_boxToolbar,"docsButton"); | 774 | m_boxToolbar,"docsButton"); |
775 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | 775 | m_docButton->setFixedSize( QSize( 20, 20 ) ); |
776 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 776 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); |
777 | m_docButton->setFlat(TRUE); | 777 | m_docButton->setFlat(TRUE); |
778 | 778 | ||
779 | // Close button | 779 | // Close button |
780 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 780 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
781 | m_boxToolbar ); | 781 | m_boxToolbar ); |
782 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 782 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
783 | m_close->setFixedSize( 20, 20 ); | 783 | m_close->setFixedSize( 20, 20 ); |
784 | 784 | ||
785 | m_boxToolbar->setFixedHeight( 20 ); | 785 | m_boxToolbar->setFixedHeight( 20 ); |
786 | m_pseudoLayout->addWidget(m_boxToolbar ); | 786 | m_pseudoLayout->addWidget(m_boxToolbar ); |
787 | 787 | ||
788 | // let;s fill the Location ComboBox | 788 | // let;s fill the Location ComboBox |
789 | StorageInfo storage; | 789 | StorageInfo storage; |
790 | const QList<FileSystem> &fs = storage.fileSystems(); | 790 | const QList<FileSystem> &fs = storage.fileSystems(); |
791 | QListIterator<FileSystem> it ( fs ); | 791 | QListIterator<FileSystem> it ( fs ); |
792 | for( ; it.current(); ++it ){ | 792 | for( ; it.current(); ++it ){ |
793 | const QString disk = (*it)->name(); | 793 | const QString disk = (*it)->name(); |
794 | const QString path = (*it)->path(); | 794 | const QString path = (*it)->path(); |
795 | m_location->insertItem(path+ "<-"+disk ); | 795 | m_location->insertItem(path+ "<-"+disk ); |
796 | } | 796 | } |
797 | int count = m_location->count(); | 797 | int count = m_location->count(); |
798 | m_location->insertItem( m_currentDir ); | 798 | m_location->insertItem( m_currentDir ); |
799 | m_location->setCurrentItem( count ); | 799 | m_location->setCurrentItem( count ); |
800 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it | 800 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it |
801 | if( !m_shTool ){ | 801 | if( !m_shTool ){ |
802 | m_location->hide( ); | 802 | m_location->hide( ); |
803 | m_up->hide( ); | 803 | m_up->hide( ); |
804 | m_homeButton->hide( ); | 804 | m_homeButton->hide( ); |
805 | m_docButton->hide( ); | 805 | m_docButton->hide( ); |
806 | } | 806 | } |
807 | if(!m_shClose ) | 807 | if(!m_shClose ) |
808 | m_close->hide(); | 808 | m_close->hide(); |
809 | if(!m_shNew) | 809 | if(!m_shNew) |
810 | m_close->hide(); | 810 | m_close->hide(); |
811 | 811 | ||
812 | } // off toolbar | 812 | } // off toolbar |
813 | // the Main ListView | 813 | // the Main ListView |
814 | // make a QWidgetStack first so Views can share the Toolbar | 814 | // make a QWidgetStack first so Views can share the Toolbar |
815 | m_View = new QListView( m_pseudo, "Extended view"); | 815 | m_View = new QListView( m_pseudo, "Extended view"); |
816 | QPEApplication::setStylusOperation( m_View->viewport(), | 816 | QPEApplication::setStylusOperation( m_View->viewport(), |
817 | QPEApplication::RightOnHold); | 817 | QPEApplication::RightOnHold); |
818 | m_View->addColumn(" " ); | 818 | m_View->addColumn(" " ); |
819 | m_View->addColumn(tr("Name"), 135 ); | 819 | m_View->addColumn(tr("Name"), 135 ); |
820 | m_View->addColumn(tr("Size"), -1 ); | 820 | m_View->addColumn(tr("Size"), -1 ); |
821 | m_View->addColumn(tr("Date"), 60 ); | 821 | m_View->addColumn(tr("Date"), 60 ); |
822 | m_View->addColumn(tr("Mime Type"), -1 ); | 822 | m_View->addColumn(tr("Mime Type"), -1 ); |
823 | QHeader *header = m_View->header(); | 823 | QHeader *header = m_View->header(); |
824 | header->hide(); | 824 | header->hide(); |
825 | m_View->setSorting( 1 ); | 825 | m_View->setSorting( 1 ); |
826 | m_View->setAllColumnsShowFocus( TRUE ); | 826 | m_View->setAllColumnsShowFocus( TRUE ); |
827 | 827 | ||
828 | connect(m_View, SIGNAL(selectionChanged() ), | 828 | connect(m_View, SIGNAL(selectionChanged() ), |
829 | this, SLOT(slotSelectionChanged() ) ); | 829 | this, SLOT(slotSelectionChanged() ) ); |
830 | 830 | ||
831 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | 831 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), |
832 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 832 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); |
833 | 833 | ||
834 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 834 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
835 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 835 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
836 | 836 | ||
837 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 837 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
838 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 838 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
839 | 839 | ||
840 | m_pseudoLayout->addWidget( m_View, 288 ); | 840 | m_pseudoLayout->addWidget( m_View, 288 ); |
841 | m_stack->addWidget( m_pseudo, EXTENDED ); | 841 | m_stack->addWidget( m_pseudo, EXTENDED ); |
842 | } | 842 | } |
843 | } | 843 | } |
844 | void OFileSelector::initializePerm() | 844 | void OFileSelector::initializePerm() |
845 | { | 845 | { |
846 | if( m_checkPerm == 0 ){ | 846 | if( m_checkPerm == 0 ){ |
847 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); | 847 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); |
848 | m_checkPerm->setChecked( false ); | 848 | m_checkPerm->setChecked( false ); |
849 | m_lay->addWidget( m_checkPerm ); | 849 | m_lay->addWidget( m_checkPerm ); |
850 | 850 | ||
851 | } | 851 | } |
852 | } | 852 | } |
853 | void OFileSelector::initPics() | 853 | void OFileSelector::initPics() |
854 | { | 854 | { |
855 | m_pixmaps = new QMap<QString,QPixmap>; | 855 | m_pixmaps = new QMap<QString,QPixmap>; |
856 | QPixmap pm = Resource::loadPixmap( "folder" ); | 856 | QPixmap pm = Resource::loadPixmap( "folder" ); |
857 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 857 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
858 | QPainter painter( &pm ); | 858 | QPainter painter( &pm ); |
859 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 859 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
860 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 860 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
861 | m_pixmaps->insert("dirsymlink", pm ); | 861 | m_pixmaps->insert("dirsymlink", pm ); |
862 | 862 | ||
863 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 863 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
864 | QPainter pen(&pm2 ); | 864 | QPainter pen(&pm2 ); |
865 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 865 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
866 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 866 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
867 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 867 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
868 | } | 868 | } |
869 | // if a mime complies with the m_mimeCheck->currentItem | 869 | // if a mime complies with the m_mimeCheck->currentItem |
870 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 870 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
871 | { | 871 | { |
872 | if( mime == "All" ) | 872 | if( mime == "All" ) |
873 | return true; | 873 | return true; |
874 | MimeType type( path ); | 874 | MimeType type( path ); |
875 | if( type.id() == mime ) | 875 | if( type.id() == mime ) |
876 | return true; | 876 | return true; |
877 | return false; | 877 | return false; |
878 | } | 878 | } |
879 | 879 | ||
880 | void OFileSelector::slotFileSelected( const QString &string ) | 880 | void OFileSelector::slotFileSelected( const QString &string ) |
881 | { | 881 | { |
882 | if( m_shLne ) | 882 | if( m_shLne ) |
883 | m_edit->setText( string ); | 883 | m_edit->setText( string ); |
884 | emit fileSelected( string ); | 884 | emit fileSelected( string ); |
885 | } | 885 | } |
886 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 886 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
887 | { | 887 | { |
888 | slotFileSelected( lnk.name() ); | 888 | slotFileSelected( lnk.name() ); |
889 | // emit fileSelected( lnk ); | 889 | // emit fileSelected( lnk ); |
890 | } | 890 | } |
891 | void OFileSelector::slotSelectionChanged() | 891 | void OFileSelector::slotSelectionChanged() |
892 | { | 892 | { |
893 | 893 | ||
894 | } | 894 | } |
895 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) | 895 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) |
896 | { | 896 | { |
897 | if( item == 0 ) | 897 | if( item == 0 ) |
898 | return; | 898 | return; |
899 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 899 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
900 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | 900 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) |
901 | if(!sel->isDir() ){ | 901 | if(!sel->isDir() ){ |
902 | if( m_shLne ) | 902 | if( m_shLne ) |
903 | m_edit->setText( sel->text(1) ); | 903 | m_edit->setText( sel->text(1) ); |
904 | } | 904 | } |
905 | } | 905 | } |
906 | } | 906 | } |
907 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) | 907 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) |
908 | { | 908 | { |
909 | if ( item == 0 ) | 909 | if ( item == 0 ) |
910 | return; | 910 | return; |
911 | 911 | ||
912 | if( button != Qt::LeftButton ) | 912 | if( button != Qt::LeftButton ) |
913 | return; | 913 | return; |
914 | 914 | ||
915 | switch( m_selector ){ | 915 | switch( m_selector ){ |
916 | default: | 916 | default: |
917 | break; | 917 | break; |
918 | case EXTENDED: // fall through | 918 | case EXTENDED: // fall through |
919 | case EXTENDED_ALL:{ | 919 | case EXTENDED_ALL:{ |
920 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 920 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
921 | if(!sel->isLocked() ){ | 921 | if(!sel->isLocked() ){ |
922 | QStringList str = QStringList::split("->", sel->text(1) ); | 922 | QStringList str = QStringList::split("->", sel->text(1) ); |
923 | if( sel->isDir() ){ | 923 | if( sel->isDir() ){ |
924 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 924 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
925 | // if MODE Dir m_shLne set the Text | 925 | // if MODE Dir m_shLne set the Text |
926 | }else{ | 926 | }else{ |
927 | if( m_shLne ) | 927 | if( m_shLne ) |
928 | m_edit->setText( str[0].stripWhiteSpace() ); | 928 | m_edit->setText( str[0].stripWhiteSpace() ); |
929 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 929 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
930 | } | 930 | } |
931 | } | 931 | } |
932 | break; | 932 | break; |
933 | } | 933 | } |
934 | } | 934 | } |
935 | } | 935 | } |
936 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 936 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
937 | { | 937 | { |
938 | if( item == 0 ) | 938 | if( item == 0 ) |
939 | return; | 939 | return; |
940 | 940 | ||
941 | if( button != Qt::RightButton ) | 941 | if( button != Qt::RightButton ) |
942 | return; | 942 | return; |
943 | slotContextMenu( item ); | 943 | slotContextMenu( item ); |
944 | } | 944 | } |
945 | void OFileSelector::slotContextMenu( QListViewItem *item) | 945 | void OFileSelector::slotContextMenu( QListViewItem *item) |
946 | { | 946 | { |
947 | 947 | ||
948 | } | 948 | } |
949 | void OFileSelector::slotChangedDir() | 949 | void OFileSelector::slotChangedDir() |
950 | { | 950 | { |
951 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 951 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
952 | if(sel->isDir() ){ | 952 | if(sel->isDir() ){ |
953 | QStringList str = QStringList::split("->", sel->text(1) ); | 953 | QStringList str = QStringList::split("->", sel->text(1) ); |
954 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 954 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
955 | } | 955 | } |
956 | } | 956 | } |
957 | void OFileSelector::slotOpen() | 957 | void OFileSelector::slotOpen() |
958 | { | 958 | { |
959 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 959 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
960 | if(!sel->isDir() ){ | 960 | if(!sel->isDir() ){ |
961 | QStringList str = QStringList::split("->", sel->text(1) ); | 961 | QStringList str = QStringList::split("->", sel->text(1) ); |
962 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); | 962 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); |
963 | } | 963 | } |
964 | } | 964 | } |
965 | void OFileSelector::slotRescan() | 965 | void OFileSelector::slotRescan() |
966 | { | 966 | { |
967 | 967 | ||
968 | } | 968 | } |
969 | void OFileSelector::slotRename() | 969 | void OFileSelector::slotRename() |
970 | { | 970 | { |
971 | reparse(); | 971 | reparse(); |
972 | } | 972 | } |
973 | void OFileSelector::slotDelete() | 973 | void OFileSelector::slotDelete() |
974 | { | 974 | { |
975 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 975 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
976 | QStringList list = QStringList::split("->", sel->text(1) ); | 976 | QStringList list = QStringList::split("->", sel->text(1) ); |
977 | if( sel->isDir() ){ | 977 | if( sel->isDir() ){ |
978 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | 978 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry |
979 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | 979 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
980 | tr("Yes"),tr("No"),0,1,1) ) { | 980 | tr("Yes"),tr("No"),0,1,1) ) { |
981 | case 0: | 981 | case 0: |
982 | ::system(str.utf8().data() ); | 982 | ::system(str.utf8().data() ); |
983 | break; | 983 | break; |
984 | } | 984 | } |
985 | } else { | 985 | } else { |
986 | QFile::remove( list[0] ); | 986 | QFile::remove( list[0] ); |
987 | } | 987 | } |
988 | m_View->takeItem( sel ); | 988 | m_View->takeItem( sel ); |
989 | delete sel; | 989 | delete sel; |
990 | } | 990 | } |
991 | void OFileSelector::cdUP() | 991 | void OFileSelector::cdUP() |
992 | { | 992 | { |
993 | QDir dir( m_currentDir ); | 993 | QDir dir( m_currentDir ); |
994 | dir.cdUp(); | 994 | dir.cdUp(); |
995 | if(dir.exists() ){ | 995 | if(dir.exists() ){ |
996 | m_currentDir = dir.absPath(); | 996 | m_currentDir = dir.absPath(); |
997 | reparse(); | 997 | reparse(); |
998 | int count = m_location->count(); | 998 | int count = m_location->count(); |
999 | slotInsertLocationPath( m_currentDir, count); | 999 | slotInsertLocationPath( m_currentDir, count); |
1000 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | 1000 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); |
1001 | //this wont work in all instances | 1001 | //this wont work in all instances |
1002 | // FIXME | 1002 | // FIXME |
1003 | } | 1003 | } |
1004 | } | 1004 | } |
1005 | void OFileSelector::slotHome() | 1005 | void OFileSelector::slotHome() |
1006 | { | 1006 | { |
1007 | cd(QDir::homeDirPath() ); | 1007 | cd(QDir::homeDirPath() ); |
1008 | } | 1008 | } |
1009 | void OFileSelector::slotDoc() | 1009 | void OFileSelector::slotDoc() |
1010 | { | 1010 | { |
1011 | cd(QPEApplication::documentDir() ); | 1011 | cd(QPEApplication::documentDir() ); |
1012 | } | 1012 | } |
1013 | void OFileSelector::slotNavigate( ) | 1013 | void OFileSelector::slotNavigate( ) |
1014 | { | 1014 | { |
1015 | 1015 | ||
1016 | } | 1016 | } |
1017 | // fill the View with life | 1017 | // fill the View with life |
1018 | void OFileSelector::reparse() | 1018 | void OFileSelector::reparse() |
1019 | { | 1019 | { |
1020 | if( m_selector == NORMAL ) | 1020 | if( m_selector == NORMAL ) |
1021 | return; | 1021 | return; |
1022 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) | 1022 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) |
1023 | m_View->clear(); | 1023 | m_View->clear(); |
1024 | else // custom view | 1024 | else // custom view |
1025 | ; // currentView()->clear(); | 1025 | ; // currentView()->clear(); |
1026 | if( m_shChooser) | 1026 | if( m_shChooser) |
1027 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | 1027 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); |
1028 | 1028 | ||
1029 | QString currentMimeType; | 1029 | QString currentMimeType; |
1030 | // let's update the mimetype | 1030 | // let's update the mimetype |
1031 | if( m_autoMime ){ | 1031 | if( m_autoMime ){ |
1032 | m_mimetypes.clear(); | 1032 | m_mimetypes.clear(); |
1033 | // ok we can change mimetype so we need to be able to give a selection | 1033 | // ok we can change mimetype so we need to be able to give a selection |
1034 | if( m_shChooser ) { | 1034 | if( m_shChooser ) { |
1035 | currentMimeType = m_mimeCheck->currentText(); | 1035 | currentMimeType = m_mimeCheck->currentText(); |
1036 | m_mimeCheck->clear(); | 1036 | m_mimeCheck->clear(); |
1037 | 1037 | ||
1038 | // let's find possible mimetypes | 1038 | // let's find possible mimetypes |
1039 | QDir dir( m_currentDir ); | 1039 | QDir dir( m_currentDir ); |
1040 | dir.setFilter( QDir::Files | QDir::Readable ); | 1040 | dir.setFilter( QDir::Files | QDir::Readable ); |
1041 | dir.setSorting( QDir::Size ); | 1041 | dir.setSorting( QDir::Size ); |
1042 | const QFileInfoList *list = dir.entryInfoList(); | 1042 | const QFileInfoList *list = dir.entryInfoList(); |
1043 | QFileInfoListIterator it( *list ); | 1043 | QFileInfoListIterator it( *list ); |
1044 | QFileInfo *fi; | 1044 | QFileInfo *fi; |
1045 | while( (fi=it.current() ) ) { | 1045 | while( (fi=it.current() ) ) { |
1046 | if( fi->extension() == QString::fromLatin1("desktop") ){ | 1046 | if( fi->extension() == QString::fromLatin1("desktop") ){ |
1047 | ++it; | 1047 | ++it; |
1048 | continue; | 1048 | continue; |
1049 | } | 1049 | } |
1050 | MimeType type( fi->absFilePath() ); | 1050 | MimeType type( fi->absFilePath() ); |
1051 | if( !m_mimetypes.contains( type.id() ) ){ | 1051 | if( !m_mimetypes.contains( type.id() ) ){ |
1052 | //qWarning("Type %s", type.id().latin1() ); | 1052 | //qWarning("Type %s", type.id().latin1() ); |
1053 | m_mimetypes.append( type.id() ); | 1053 | m_mimetypes.append( type.id() ); |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | ++it; | 1056 | ++it; |
1057 | } | 1057 | } |
1058 | // add them to the chooser | 1058 | // add them to the chooser |
1059 | m_mimeCheck->insertItem( tr("All") ); | 1059 | m_mimeCheck->insertItem( tr("All") ); |
1060 | m_mimeCheck->insertStringList( m_mimetypes ); | 1060 | m_mimeCheck->insertStringList( m_mimetypes ); |
1061 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 1061 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
1062 | currentMimeType = m_mimeCheck->currentText(); | 1062 | currentMimeType = m_mimeCheck->currentText(); |
1063 | } | 1063 | } |
1064 | }else { // no autoMime | 1064 | }else { // no autoMime |
1065 | currentMimeType = m_mimetypes.join(";"); | 1065 | currentMimeType = m_mimetypes.join(";"); |
1066 | if( m_shChooser ){ | 1066 | if( m_shChooser ){ |
1067 | m_mimeCheck->clear(); | 1067 | m_mimeCheck->clear(); |
1068 | m_mimeCheck->insertItem(m_mimetypes.join(",") ); | 1068 | m_mimeCheck->insertItem(m_mimetypes.join(",") ); |
1069 | } | 1069 | } |
1070 | } | 1070 | } |
1071 | // now we got our mimetypes we can add the files | 1071 | // now we got our mimetypes we can add the files |
1072 | 1072 | ||
1073 | QDir dir( m_currentDir ); | 1073 | QDir dir( m_currentDir ); |
1074 | 1074 | ||
1075 | int sort; | 1075 | int sort; |
1076 | if ( m_case ) | 1076 | if ( m_case ) |
1077 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); | 1077 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); |
1078 | else | 1078 | else |
1079 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); | 1079 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); |
1080 | dir.setSorting( sort ); | 1080 | dir.setSorting( sort ); |
1081 | 1081 | ||
1082 | int filter; | 1082 | int filter; |
1083 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ | 1083 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ |
1084 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 1084 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
1085 | }else | 1085 | }else |
1086 | filter = QDir::Files | QDir::Dirs | QDir::All; | 1086 | filter = QDir::Files | QDir::Dirs | QDir::All; |
1087 | dir.setFilter( filter ); | 1087 | dir.setFilter( filter ); |
1088 | 1088 | ||
1089 | // now go through all files | 1089 | // now go through all files |
1090 | const QFileInfoList *list = dir.entryInfoList(); | 1090 | const QFileInfoList *list = dir.entryInfoList(); |
1091 | QFileInfoListIterator it( *list ); | 1091 | QFileInfoListIterator it( *list ); |
1092 | QFileInfo *fi; | 1092 | QFileInfo *fi; |
1093 | while( (fi=it.current() ) ){ | 1093 | while( (fi=it.current() ) ){ |
1094 | //qWarning("True and only" ); | 1094 | //qWarning("True and only" ); |
1095 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 1095 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
1096 | //qWarning(".. or ." ); | 1096 | //qWarning(".. or ." ); |
1097 | ++it; | 1097 | ++it; |
1098 | continue; | 1098 | continue; |
1099 | } | 1099 | } |
1100 | if( fi->isSymLink() ){ | 1100 | if( fi->isSymLink() ){ |
1101 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 1101 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
1102 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | 1102 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos |
1103 | QFileInfo info( file ); | 1103 | QFileInfo info( file ); |
1104 | if( !info.exists() ){ | 1104 | if( !info.exists() ){ |
1105 | addSymlink( currentMimeType, fi, TRUE ); | 1105 | addSymlink( currentMimeType, fi, TRUE ); |
1106 | break; | 1106 | break; |
1107 | }else if( info.isDir() ){ | 1107 | }else if( info.isDir() ){ |
1108 | addDir( currentMimeType, fi, TRUE ); | 1108 | addDir( currentMimeType, fi, TRUE ); |
1109 | break; | 1109 | break; |
1110 | }else if( info.isFile() ){ | 1110 | }else if( info.isFile() ){ |
1111 | addFile( currentMimeType, fi, TRUE ); | 1111 | addFile( currentMimeType, fi, TRUE ); |
1112 | break; | 1112 | break; |
1113 | }else if( info.isSymLink() ){ | 1113 | }else if( info.isSymLink() ){ |
1114 | file = info.dirPath(true ) + "/" + info.readLink() ; | 1114 | file = info.dirPath(true ) + "/" + info.readLink() ; |
1115 | break; | 1115 | break; |
1116 | }else if( i == 4){ | 1116 | }else if( i == 4){ |
1117 | addSymlink( currentMimeType, fi ); | 1117 | addSymlink( currentMimeType, fi ); |
1118 | } | 1118 | } |
1119 | } // off for loop | 1119 | } // off for loop |
1120 | }else if( fi->isDir() ){ | 1120 | }else if( fi->isDir() ){ |
1121 | addDir( currentMimeType, fi ); | 1121 | addDir( currentMimeType, fi ); |
1122 | }else if( fi->isFile() ){ | 1122 | }else if( fi->isFile() ){ |
1123 | addFile( currentMimeType, fi ); | 1123 | addFile( currentMimeType, fi ); |
1124 | } | 1124 | } |
1125 | //qWarning( "%s", fi->fileName().latin1() ); | 1125 | //qWarning( "%s", fi->fileName().latin1() ); |
1126 | ++it; | 1126 | ++it; |
1127 | } // of while loop | 1127 | } // of while loop |
1128 | m_View->sort(); | 1128 | m_View->sort(); |
1129 | if( m_shTool ){ | 1129 | if( m_shTool ){ |
1130 | m_location->insertItem( m_currentDir ); | 1130 | m_location->insertItem( m_currentDir ); |
1131 | 1131 | ||
1132 | } | 1132 | } |
1133 | // reenable painting and updates | 1133 | // reenable painting and updates |
1134 | } | 1134 | } |
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 293c391..8f2b9c9 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -1,1348 +1,1348 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | opieftp.cpp | 2 | opieftp.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | //#define DEVELOPERS_VERSION | 12 | //#define DEVELOPERS_VERSION |
13 | 13 | ||
14 | #include "opieftp.h" | 14 | #include "opieftp.h" |
15 | 15 | ||
16 | extern "C" { | 16 | extern "C" { |
17 | #include "ftplib.h" | 17 | #include "ftplib.h" |
18 | } | 18 | } |
19 | 19 | ||
20 | #include "inputDialog.h" | 20 | #include "inputDialog.h" |
21 | 21 | ||
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/mimetype.h> | 28 | #include <qpe/mimetype.h> |
29 | #include <qpe/qpemessagebox.h> | 29 | #include <qpe/qpemessagebox.h> |
30 | 30 | ||
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qpopupmenu.h> | 40 | #include <qpopupmenu.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qprogressbar.h> | 44 | #include <qprogressbar.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qtabwidget.h> | 46 | #include <qtabwidget.h> |
47 | #include <qwidget.h> | 47 | #include <qwidget.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qimage.h> | 49 | #include <qimage.h> |
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
53 | #include <qregexp.h> | 53 | #include <qregexp.h> |
54 | 54 | ||
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | 57 | ||
58 | 58 | ||
59 | QProgressBar *ProgressBar; | 59 | QProgressBar *ProgressBar; |
60 | static netbuf *conn=NULL; | 60 | static netbuf *conn=NULL; |
61 | 61 | ||
62 | static int log_progress(netbuf *ctl, int xfered, void *arg) | 62 | static int log_progress(netbuf *ctl, int xfered, void *arg) |
63 | { | 63 | { |
64 | int fsz = *(int *)arg; | 64 | int fsz = *(int *)arg; |
65 | int pct = (xfered * 100) / fsz; | 65 | int pct = (xfered * 100) / fsz; |
66 | // printf("%3d%%\r", pct); | 66 | // printf("%3d%%\r", pct); |
67 | // fflush(stdout); | 67 | // fflush(stdout); |
68 | ProgressBar->setProgress(xfered); | 68 | ProgressBar->setProgress(xfered); |
69 | qApp->processEvents(); | 69 | qApp->processEvents(); |
70 | return 1; | 70 | return 1; |
71 | } | 71 | } |
72 | 72 | ||
73 | OpieFtp::OpieFtp( ) | 73 | OpieFtp::OpieFtp( ) |
74 | : QMainWindow( ) | 74 | : QMainWindow( ) |
75 | { | 75 | { |
76 | setCaption( tr( "OpieFtp" ) ); | 76 | setCaption( tr( "OpieFtp" ) ); |
77 | 77 | ||
78 | QGridLayout *layout = new QGridLayout( this ); | 78 | QGridLayout *layout = new QGridLayout( this ); |
79 | layout->setSpacing( 2); | 79 | layout->setSpacing( 2); |
80 | layout->setMargin( 2); | 80 | layout->setMargin( 2); |
81 | 81 | ||
82 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 82 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
83 | 83 | ||
84 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 84 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
85 | // QPEToolBar *menuBar = new QPEToolBar(this); | 85 | // QPEToolBar *menuBar = new QPEToolBar(this); |
86 | // menuBar->setHorizontalStretchable( TRUE ); | 86 | // menuBar->setHorizontalStretchable( TRUE ); |
87 | 87 | ||
88 | connectionMenu = new QPopupMenu( this ); | 88 | connectionMenu = new QPopupMenu( this ); |
89 | localMenu = new QPopupMenu( this ); | 89 | localMenu = new QPopupMenu( this ); |
90 | remoteMenu = new QPopupMenu( this ); | 90 | remoteMenu = new QPopupMenu( this ); |
91 | tabMenu = new QPopupMenu( this ); | 91 | tabMenu = new QPopupMenu( this ); |
92 | 92 | ||
93 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); | 93 | layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); |
94 | 94 | ||
95 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 95 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
96 | menuBar->insertItem( tr( "Local" ), localMenu); | 96 | menuBar->insertItem( tr( "Local" ), localMenu); |
97 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 97 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
98 | menuBar->insertItem( tr( "View" ), tabMenu); | 98 | menuBar->insertItem( tr( "View" ), tabMenu); |
99 | 99 | ||
100 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 100 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
101 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 101 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
102 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 102 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
103 | 103 | ||
104 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 104 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
105 | localMenu->insertSeparator(); | 105 | localMenu->insertSeparator(); |
106 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 106 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
107 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 107 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
108 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 108 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
109 | localMenu->insertSeparator(); | 109 | localMenu->insertSeparator(); |
110 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 110 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
111 | localMenu->setCheckable(TRUE); | 111 | localMenu->setCheckable(TRUE); |
112 | 112 | ||
113 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 113 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
114 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 114 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
115 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 115 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
116 | remoteMenu->insertSeparator(); | 116 | remoteMenu->insertSeparator(); |
117 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 117 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
118 | 118 | ||
119 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 119 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
120 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 120 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
121 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 121 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
122 | tabMenu->insertSeparator(); | 122 | tabMenu->insertSeparator(); |
123 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 123 | tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
124 | tabMenu->setCheckable(TRUE); | 124 | tabMenu->setCheckable(TRUE); |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); | 128 | cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); |
129 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); | 129 | cdUpButton ->setFixedSize( QSize( 20, 20 ) ); |
130 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); | 130 | connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); |
131 | cdUpButton ->setFlat(TRUE); | 131 | cdUpButton ->setFlat(TRUE); |
132 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); | 132 | layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); |
133 | cdUpButton->hide(); | 133 | cdUpButton->hide(); |
134 | 134 | ||
135 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 135 | // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
136 | // docButton->setFixedSize( QSize( 20, 20 ) ); | 136 | // docButton->setFixedSize( QSize( 20, 20 ) ); |
137 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 137 | // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
138 | // docButton->setFlat(TRUE); | 138 | // docButton->setFlat(TRUE); |
139 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 139 | // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
140 | 140 | ||
141 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 141 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
142 | homeButton->setFixedSize( QSize( 20, 20 ) ); | 142 | homeButton->setFixedSize( QSize( 20, 20 ) ); |
143 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 143 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
144 | homeButton->setFlat(TRUE); | 144 | homeButton->setFlat(TRUE); |
145 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); | 145 | layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); |
146 | homeButton->hide(); | 146 | homeButton->hide(); |
147 | 147 | ||
148 | TabWidget = new QTabWidget( this, "TabWidget" ); | 148 | TabWidget = new QTabWidget( this, "TabWidget" ); |
149 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); | 149 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); |
150 | 150 | ||
151 | // TabWidget->setTabShape(QTabWidget::Triangular); | 151 | // TabWidget->setTabShape(QTabWidget::Triangular); |
152 | 152 | ||
153 | tab = new QWidget( TabWidget, "tab" ); | 153 | tab = new QWidget( TabWidget, "tab" ); |
154 | tabLayout = new QGridLayout( tab ); | 154 | tabLayout = new QGridLayout( tab ); |
155 | tabLayout->setSpacing( 2); | 155 | tabLayout->setSpacing( 2); |
156 | tabLayout->setMargin( 2); | 156 | tabLayout->setMargin( 2); |
157 | 157 | ||
158 | Local_View = new QListView( tab, "Local_View" ); | 158 | Local_View = new QListView( tab, "Local_View" ); |
159 | // Local_View->setResizePolicy( QListView::AutoOneFit ); | 159 | // Local_View->setResizePolicy( QListView::AutoOneFit ); |
160 | Local_View->addColumn( tr("File"),150); | 160 | Local_View->addColumn( tr("File"),150); |
161 | Local_View->addColumn( tr("Date"),-1); | 161 | Local_View->addColumn( tr("Date"),-1); |
162 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 162 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
163 | Local_View->addColumn( tr("Size"),-1); | 163 | Local_View->addColumn( tr("Size"),-1); |
164 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 164 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
165 | Local_View->setAllColumnsShowFocus(TRUE); | 165 | Local_View->setAllColumnsShowFocus(TRUE); |
166 | 166 | ||
167 | Local_View->setMultiSelection( TRUE); | 167 | Local_View->setMultiSelection( TRUE); |
168 | Local_View->setSelectionMode(QListView::Extended); | 168 | Local_View->setSelectionMode(QListView::Extended); |
169 | Local_View->setFocusPolicy(QWidget::ClickFocus); | 169 | Local_View->setFocusPolicy(QWidget::ClickFocus); |
170 | 170 | ||
171 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 171 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
172 | 172 | ||
173 | tabLayout->addWidget( Local_View, 0, 0 ); | 173 | tabLayout->addWidget( Local_View, 0, 0 ); |
174 | 174 | ||
175 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 175 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
176 | this,SLOT( localListClicked(QListViewItem *)) ); | 176 | this,SLOT( localListClicked(QListViewItem *)) ); |
177 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 177 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
178 | // this,SLOT( localListClicked(QListViewItem *)) ); | 178 | // this,SLOT( localListClicked(QListViewItem *)) ); |
179 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 179 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
180 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 180 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
181 | 181 | ||
182 | TabWidget->insertTab( tab, tr( "Local" ) ); | 182 | TabWidget->insertTab( tab, tr( "Local" ) ); |
183 | 183 | ||
184 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 184 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
185 | tabLayout_2 = new QGridLayout( tab_2 ); | 185 | tabLayout_2 = new QGridLayout( tab_2 ); |
186 | tabLayout_2->setSpacing( 2); | 186 | tabLayout_2->setSpacing( 2); |
187 | tabLayout_2->setMargin( 2); | 187 | tabLayout_2->setMargin( 2); |
188 | 188 | ||
189 | Remote_View = new QListView( tab_2, "Remote_View" ); | 189 | Remote_View = new QListView( tab_2, "Remote_View" ); |
190 | Remote_View->addColumn( tr("File"),150); | 190 | Remote_View->addColumn( tr("File"),150); |
191 | Remote_View->addColumn( tr("Date"),-1); | 191 | Remote_View->addColumn( tr("Date"),-1); |
192 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 192 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
193 | Remote_View->addColumn( tr("Size"),-1); | 193 | Remote_View->addColumn( tr("Size"),-1); |
194 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 194 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
195 | Remote_View->addColumn( tr("Dir"),-1); | 195 | Remote_View->addColumn( tr("Dir"),-1); |
196 | Remote_View->setColumnAlignment(4,QListView::AlignRight); | 196 | Remote_View->setColumnAlignment(4,QListView::AlignRight); |
197 | Remote_View->setAllColumnsShowFocus(TRUE); | 197 | Remote_View->setAllColumnsShowFocus(TRUE); |
198 | 198 | ||
199 | Remote_View->setMultiSelection( FALSE); | 199 | Remote_View->setMultiSelection( FALSE); |
200 | Remote_View->setSelectionMode(QListView::Extended); | 200 | Remote_View->setSelectionMode(QListView::Extended); |
201 | Remote_View->setFocusPolicy(QWidget::ClickFocus); | 201 | Remote_View->setFocusPolicy(QWidget::ClickFocus); |
202 | 202 | ||
203 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 203 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
204 | 204 | ||
205 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 205 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
206 | this,SLOT( remoteListClicked(QListViewItem *)) ); | 206 | this,SLOT( remoteListClicked(QListViewItem *)) ); |
207 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 207 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
208 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); | 208 | this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); |
209 | 209 | ||
210 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 210 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
211 | 211 | ||
212 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); | 212 | TabWidget->insertTab( tab_2, tr( "Remote" ) ); |
213 | 213 | ||
214 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 214 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
215 | tabLayout_3 = new QGridLayout( tab_3 ); | 215 | tabLayout_3 = new QGridLayout( tab_3 ); |
216 | tabLayout_3->setSpacing( 2); | 216 | tabLayout_3->setSpacing( 2); |
217 | tabLayout_3->setMargin( 2); | 217 | tabLayout_3->setMargin( 2); |
218 | 218 | ||
219 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); | 219 | TextLabel1 = new QLabel( tab_3, "TextLabel1" ); |
220 | TextLabel1->setText( tr( "Username" ) ); | 220 | TextLabel1->setText( tr( "Username" ) ); |
221 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 221 | tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
222 | 222 | ||
223 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); | 223 | UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); |
224 | UsernameComboBox->setEditable(TRUE); | 224 | UsernameComboBox->setEditable(TRUE); |
225 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); | 225 | tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); |
226 | 226 | ||
227 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 227 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
228 | TextLabel2->setText( tr( "Password" ) ); | 228 | TextLabel2->setText( tr( "Password" ) ); |
229 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); | 229 | tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); |
230 | 230 | ||
231 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); | 231 | PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); |
232 | PasswordEdit->setEchoMode(QLineEdit::Password); | 232 | PasswordEdit->setEchoMode(QLineEdit::Password); |
233 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); | 233 | tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); |
234 | 234 | ||
235 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); | 235 | TextLabel3 = new QLabel( tab_3, "TextLabel3" ); |
236 | TextLabel3->setText( tr( "Remote server" ) ); | 236 | TextLabel3->setText( tr( "Remote server" ) ); |
237 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 237 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
238 | 238 | ||
239 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 239 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
240 | ServerComboBox->setEditable(TRUE); | 240 | ServerComboBox->setEditable(TRUE); |
241 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 241 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
242 | 242 | ||
243 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); | 243 | connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); |
244 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); | 244 | connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); |
245 | 245 | ||
246 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 246 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
247 | TextLabel5->setText( tr( "Remote path" ) ); | 247 | TextLabel5->setText( tr( "Remote path" ) ); |
248 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 248 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
249 | 249 | ||
250 | 250 | ||
251 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 251 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
252 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | 252 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); |
253 | 253 | ||
254 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 254 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
255 | TextLabel4->setText( tr( "Port" ) ); | 255 | TextLabel4->setText( tr( "Port" ) ); |
256 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 256 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
257 | 257 | ||
258 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 258 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
259 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 259 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
260 | PortSpinBox->setMaxValue(32786); | 260 | PortSpinBox->setMaxValue(32786); |
261 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 261 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
262 | 262 | ||
263 | QPushButton *deleteServerBtn; | 263 | QPushButton *deleteServerBtn; |
264 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); | 264 | deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); |
265 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); | 265 | tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); |
266 | 266 | ||
267 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); | 267 | connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); |
268 | 268 | ||
269 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); | 269 | connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); |
270 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); | 270 | tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); |
271 | connectServerBtn->setToggleButton(TRUE); | 271 | connectServerBtn->setToggleButton(TRUE); |
272 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); | 272 | connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); |
273 | 273 | ||
274 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 274 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
275 | tabLayout_3->addItem( spacer, 5, 0 ); | 275 | tabLayout_3->addItem( spacer, 5, 0 ); |
276 | 276 | ||
277 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 277 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
278 | 278 | ||
279 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 279 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
280 | this,SLOT(tabChanged(QWidget*))); | 280 | this,SLOT(tabChanged(QWidget*))); |
281 | 281 | ||
282 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 282 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
283 | currentDir.setPath( QDir::currentDirPath()); | 283 | currentDir.setPath( QDir::currentDirPath()); |
284 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 284 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
285 | 285 | ||
286 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 286 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
287 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); | 287 | layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); |
288 | 288 | ||
289 | currentPathCombo->setEditable(TRUE); | 289 | currentPathCombo->setEditable(TRUE); |
290 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 290 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
291 | 291 | ||
292 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 292 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
293 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 293 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
294 | 294 | ||
295 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 295 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
296 | this,SLOT(currentPathComboChanged())); | 296 | this,SLOT(currentPathComboChanged())); |
297 | 297 | ||
298 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 298 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
299 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); | 299 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); |
300 | 300 | ||
301 | fillCombos(); | 301 | fillCombos(); |
302 | 302 | ||
303 | filterStr="*"; | 303 | filterStr="*"; |
304 | b=FALSE; | 304 | b=FALSE; |
305 | populateLocalView(); | 305 | populateLocalView(); |
306 | qDebug("read COnfig"); | 306 | qDebug("read COnfig"); |
307 | readConfig(); | 307 | readConfig(); |
308 | qDebug("Set current item"); | 308 | qDebug("Set current item"); |
309 | ServerComboBox->setCurrentItem(currentServerConfig); | 309 | ServerComboBox->setCurrentItem(currentServerConfig); |
310 | 310 | ||
311 | TabWidget->setCurrentPage(2); | 311 | TabWidget->setCurrentPage(2); |
312 | } | 312 | } |
313 | 313 | ||
314 | OpieFtp::~OpieFtp() | 314 | OpieFtp::~OpieFtp() |
315 | { | 315 | { |
316 | } | 316 | } |
317 | 317 | ||
318 | void OpieFtp::cleanUp() | 318 | void OpieFtp::cleanUp() |
319 | { | 319 | { |
320 | if(conn) | 320 | if(conn) |
321 | FtpQuit(conn); | 321 | FtpQuit(conn); |
322 | QString sfile=QDir::homeDirPath(); | 322 | QString sfile=QDir::homeDirPath(); |
323 | if(sfile.right(1) != "/") | 323 | if(sfile.right(1) != "/") |
324 | sfile+="/._temp"; | 324 | sfile+="/._temp"; |
325 | else | 325 | else |
326 | sfile+="._temp"; | 326 | sfile+="._temp"; |
327 | QFile file( sfile); | 327 | QFile file( sfile); |
328 | if(file.exists()) | 328 | if(file.exists()) |
329 | file.remove(); | 329 | file.remove(); |
330 | exit(0); | 330 | exit(0); |
331 | } | 331 | } |
332 | 332 | ||
333 | void OpieFtp::tabChanged(QWidget *w) | 333 | void OpieFtp::tabChanged(QWidget *w) |
334 | { | 334 | { |
335 | if (TabWidget->currentPageIndex() == 0) { | 335 | if (TabWidget->currentPageIndex() == 0) { |
336 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 336 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
337 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); | 337 | tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); |
338 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 338 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
339 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 339 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
340 | if(cdUpButton->isHidden()) | 340 | if(cdUpButton->isHidden()) |
341 | cdUpButton->show(); | 341 | cdUpButton->show(); |
342 | if(homeButton->isHidden()) | 342 | if(homeButton->isHidden()) |
343 | homeButton->show(); | 343 | homeButton->show(); |
344 | 344 | ||
345 | } | 345 | } |
346 | if (TabWidget->currentPageIndex() == 1) { | 346 | if (TabWidget->currentPageIndex() == 1) { |
347 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 347 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
348 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); | 348 | tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); |
349 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 349 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
350 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); | 350 | tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); |
351 | if(cdUpButton->isHidden()) | 351 | if(cdUpButton->isHidden()) |
352 | cdUpButton->show(); | 352 | cdUpButton->show(); |
353 | homeButton->hide(); | 353 | homeButton->hide(); |
354 | 354 | ||
355 | } | 355 | } |
356 | if (TabWidget->currentPageIndex() == 2) { | 356 | if (TabWidget->currentPageIndex() == 2) { |
357 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); | 357 | tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); |
358 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); | 358 | tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); |
359 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); | 359 | tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); |
360 | cdUpButton->hide(); | 360 | cdUpButton->hide(); |
361 | homeButton->hide(); | 361 | homeButton->hide(); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | void OpieFtp::newConnection() | 365 | void OpieFtp::newConnection() |
366 | { | 366 | { |
367 | UsernameComboBox->lineEdit()->setText(""); | 367 | UsernameComboBox->lineEdit()->setText(""); |
368 | PasswordEdit->setText( "" ); | 368 | PasswordEdit->setText( "" ); |
369 | ServerComboBox->lineEdit()->setText( ""); | 369 | ServerComboBox->lineEdit()->setText( ""); |
370 | remotePath->setText( currentRemoteDir = "/"); | 370 | remotePath->setText( currentRemoteDir = "/"); |
371 | PortSpinBox->setValue( 21); | 371 | PortSpinBox->setValue( 21); |
372 | TabWidget->setCurrentPage(2); | 372 | TabWidget->setCurrentPage(2); |
373 | } | 373 | } |
374 | 374 | ||
375 | void OpieFtp::serverComboEdited(const QString & edit) | 375 | void OpieFtp::serverComboEdited(const QString & edit) |
376 | { | 376 | { |
377 | if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { | 377 | if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { |
378 | qDebug("ServerComboEdited"); | 378 | qDebug("ServerComboEdited"); |
379 | currentServerConfig = -1; | 379 | currentServerConfig = -1; |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | void OpieFtp::connectorBtnToggled(bool On) | 383 | void OpieFtp::connectorBtnToggled(bool On) |
384 | { | 384 | { |
385 | if(On) { | 385 | if(On) { |
386 | connector(); | 386 | connector(); |
387 | } else { | 387 | } else { |
388 | disConnector(); | 388 | disConnector(); |
389 | } | 389 | } |
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void OpieFtp::connector() | 393 | void OpieFtp::connector() |
394 | { | 394 | { |
395 | // QCopEnvelope ( "QPE/System", "busy()" ); | 395 | // QCopEnvelope ( "QPE/System", "busy()" ); |
396 | // qApp->processEvents(); | 396 | // qApp->processEvents(); |
397 | currentRemoteDir=remotePath->text(); | 397 | currentRemoteDir=remotePath->text(); |
398 | if(ServerComboBox->currentText().isEmpty()) { | 398 | if(ServerComboBox->currentText().isEmpty()) { |
399 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); | 399 | QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); |
400 | TabWidget->setCurrentPage(2); | 400 | TabWidget->setCurrentPage(2); |
401 | ServerComboBox->setFocus(); | 401 | ServerComboBox->setFocus(); |
402 | connectServerBtn->setOn(FALSE); | 402 | connectServerBtn->setOn(FALSE); |
403 | connectServerBtn->setText( tr("Connect")); | 403 | connectServerBtn->setText( tr("Connect")); |
404 | return; | 404 | return; |
405 | } | 405 | } |
406 | FtpInit(); | 406 | FtpInit(); |
407 | TabWidget->setCurrentPage(1); | 407 | TabWidget->setCurrentPage(1); |
408 | QString ftp_host = ServerComboBox->currentText(); | 408 | QString ftp_host = ServerComboBox->currentText(); |
409 | QString ftp_user = UsernameComboBox->currentText(); | 409 | QString ftp_user = UsernameComboBox->currentText(); |
410 | QString ftp_pass = PasswordEdit->text(); | 410 | QString ftp_pass = PasswordEdit->text(); |
411 | QString port=PortSpinBox->cleanText(); | 411 | QString port=PortSpinBox->cleanText(); |
412 | port.stripWhiteSpace(); | 412 | port.stripWhiteSpace(); |
413 | 413 | ||
414 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) | 414 | if(ftp_host.find("ftp://",0, TRUE) != -1 ) |
415 | ftp_host=ftp_host.right(ftp_host.length()-6); | 415 | ftp_host=ftp_host.right(ftp_host.length()-6); |
416 | ftp_host+=":"+port; | 416 | ftp_host+=":"+port; |
417 | if (!FtpConnect( ftp_host.latin1(), &conn)) { | 417 | if (!FtpConnect( ftp_host.latin1(), &conn)) { |
418 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); | 418 | QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); |
419 | connectServerBtn->setOn(FALSE); | 419 | connectServerBtn->setOn(FALSE); |
420 | connectServerBtn->setText( tr("Connect")); | 420 | connectServerBtn->setText( tr("Connect")); |
421 | return ; | 421 | return ; |
422 | } | 422 | } |
423 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { | 423 | if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { |
424 | QString msg; | 424 | QString msg; |
425 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); | 425 | msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); |
426 | msg.replace(QRegExp(":"),"\n"); | 426 | msg.replace(QRegExp(":"),"\n"); |
427 | QMessageBox::message(tr("Note"),msg); | 427 | QMessageBox::message(tr("Note"),msg); |
428 | if(conn) | 428 | if(conn) |
429 | FtpQuit(conn); | 429 | FtpQuit(conn); |
430 | connectServerBtn->setOn(FALSE); | 430 | connectServerBtn->setOn(FALSE); |
431 | connectServerBtn->setText( tr("Connect")); | 431 | connectServerBtn->setText( tr("Connect")); |
432 | return ; | 432 | return ; |
433 | } | 433 | } |
434 | remoteDirList("/") ; | 434 | remoteDirList("/") ; |
435 | setCaption(ftp_host); | 435 | setCaption(ftp_host); |
436 | if( currentServerConfig == -1) | 436 | if( currentServerConfig == -1) |
437 | writeConfig(); | 437 | writeConfig(); |
438 | connectServerBtn->setText( tr("Disconnect")); | 438 | connectServerBtn->setText( tr("Disconnect")); |
439 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 439 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
440 | } | 440 | } |
441 | 441 | ||
442 | void OpieFtp::disConnector() | 442 | void OpieFtp::disConnector() |
443 | { | 443 | { |
444 | if(conn) | 444 | if(conn) |
445 | FtpQuit(conn); | 445 | FtpQuit(conn); |
446 | setCaption("OpieFtp"); | 446 | setCaption("OpieFtp"); |
447 | currentRemoteDir="/"; | 447 | currentRemoteDir="/"; |
448 | Remote_View->clear(); | 448 | Remote_View->clear(); |
449 | connectServerBtn->setText( tr("Connect")); | 449 | connectServerBtn->setText( tr("Connect")); |
450 | connectServerBtn->setOn(FALSE); | 450 | connectServerBtn->setOn(FALSE); |
451 | setCaption("OpieFtp"); | 451 | setCaption("OpieFtp"); |
452 | } | 452 | } |
453 | 453 | ||
454 | void OpieFtp::localUpload() | 454 | void OpieFtp::localUpload() |
455 | { | 455 | { |
456 | int fsz; | 456 | int fsz; |
457 | // QCopEnvelope ( "QPE/System", "busy()" ); | 457 | // QCopEnvelope ( "QPE/System", "busy()" ); |
458 | // qApp->processEvents(); | 458 | // qApp->processEvents(); |
459 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 459 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
460 | QListViewItemIterator it( Local_View ); | 460 | QListViewItemIterator it( Local_View ); |
461 | for ( ; it.current(); ++it ) { | 461 | for ( ; it.current(); ++it ) { |
462 | if ( it.current()->isSelected() ) { | 462 | if ( it.current()->isSelected() ) { |
463 | QString strItem = it.current()->text(0); | 463 | QString strItem = it.current()->text(0); |
464 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 464 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
465 | QString remoteFile= currentRemoteDir+strItem; | 465 | QString remoteFile= currentRemoteDir+strItem; |
466 | QFileInfo fi(localFile); | 466 | QFileInfo fi(localFile); |
467 | if( !fi.isDir()) { | 467 | if( !fi.isDir()) { |
468 | fsz=fi.size(); | 468 | fsz=fi.size(); |
469 | ProgressBar->setTotalSteps(fsz); | 469 | ProgressBar->setTotalSteps(fsz); |
470 | 470 | ||
471 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 471 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
472 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 472 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
473 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 473 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
474 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 474 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
475 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 475 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
476 | 476 | ||
477 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 477 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
478 | QString msg; | 478 | QString msg; |
479 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); | 479 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); |
480 | msg.replace(QRegExp(":"),"\n"); | 480 | msg.replace(QRegExp(":"),"\n"); |
481 | QMessageBox::message(tr("Note"),msg); | 481 | QMessageBox::message(tr("Note"),msg); |
482 | } | 482 | } |
483 | } else { | 483 | } else { |
484 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 484 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
485 | } | 485 | } |
486 | ProgressBar->reset(); | 486 | ProgressBar->reset(); |
487 | nullifyCallBack(); | 487 | nullifyCallBack(); |
488 | it.current()->setSelected(FALSE); | 488 | it.current()->setSelected(FALSE); |
489 | } //end currentSelected | 489 | } //end currentSelected |
490 | } | 490 | } |
491 | for ( ; it.current(); ++it ) { | 491 | for ( ; it.current(); ++it ) { |
492 | Local_View->clearSelection(); | 492 | Local_View->clearSelection(); |
493 | } | 493 | } |
494 | Local_View->clearFocus(); | 494 | Local_View->clearFocus(); |
495 | TabWidget->setCurrentPage(1); | 495 | TabWidget->setCurrentPage(1); |
496 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 496 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
497 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 497 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void OpieFtp::nullifyCallBack() | 500 | void OpieFtp::nullifyCallBack() |
501 | { | 501 | { |
502 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 502 | FtpOptions(FTPLIB_CALLBACK, 0, conn); |
503 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | 503 | FtpOptions(FTPLIB_IDLETIME, 0, conn); |
504 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | 504 | FtpOptions(FTPLIB_CALLBACKARG, 0, conn); |
505 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | 505 | FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn); |
506 | } | 506 | } |
507 | 507 | ||
508 | void OpieFtp::remoteDownload() | 508 | void OpieFtp::remoteDownload() |
509 | { | 509 | { |
510 | // qApp->processEvents(); | 510 | // qApp->processEvents(); |
511 | int fsz; | 511 | int fsz; |
512 | // QCopEnvelope ( "QPE/System", "busy()" ); | 512 | // QCopEnvelope ( "QPE/System", "busy()" ); |
513 | 513 | ||
514 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 514 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
515 | QListViewItemIterator it( Remote_View ); | 515 | QListViewItemIterator it( Remote_View ); |
516 | for ( ; it.current(); ++it ) { | 516 | for ( ; it.current(); ++it ) { |
517 | if ( it.current()->isSelected() ) { | 517 | if ( it.current()->isSelected() ) { |
518 | QString strItem = it.current()->text(0); | 518 | QString strItem = it.current()->text(0); |
519 | // strItem=strItem.right(strItem.length()-1); | 519 | // strItem=strItem.right(strItem.length()-1); |
520 | QString localFile = currentDir.canonicalPath(); | 520 | QString localFile = currentDir.canonicalPath(); |
521 | if(localFile.right(1).find("/",0,TRUE) == -1) | 521 | if(localFile.right(1).find("/",0,TRUE) == -1) |
522 | localFile += "/"; | 522 | localFile += "/"; |
523 | localFile += strItem; | 523 | localFile += strItem; |
524 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 524 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
525 | QString remoteFile= currentRemoteDir+strItem; | 525 | QString remoteFile= currentRemoteDir+strItem; |
526 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 526 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
527 | fsz = 0; | 527 | fsz = 0; |
528 | QString temp; | 528 | QString temp; |
529 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 529 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
530 | 530 | ||
531 | ProgressBar->setTotalSteps(fsz); | 531 | ProgressBar->setTotalSteps(fsz); |
532 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 532 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
533 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 533 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
534 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 534 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
535 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 535 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
536 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 536 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
537 | 537 | ||
538 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 538 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
539 | QString msg; | 539 | QString msg; |
540 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 540 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
541 | msg.replace(QRegExp(":"),"\n"); | 541 | msg.replace(QRegExp(":"),"\n"); |
542 | QMessageBox::message(tr("Note"),msg); | 542 | QMessageBox::message(tr("Note"),msg); |
543 | } | 543 | } |
544 | ProgressBar->reset(); | 544 | ProgressBar->reset(); |
545 | nullifyCallBack(); | 545 | nullifyCallBack(); |
546 | it.current()->setSelected(FALSE); | 546 | it.current()->setSelected(FALSE); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | for ( ; it.current(); ++it ) { | 549 | for ( ; it.current(); ++it ) { |
550 | Remote_View->clearSelection(); | 550 | Remote_View->clearSelection(); |
551 | } | 551 | } |
552 | Remote_View->setFocus(); | 552 | Remote_View->setFocus(); |
553 | TabWidget->setCurrentPage(0); | 553 | TabWidget->setCurrentPage(0); |
554 | populateLocalView(); | 554 | populateLocalView(); |
555 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 555 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
556 | } | 556 | } |
557 | 557 | ||
558 | bool OpieFtp::remoteDirList(const QString &dir) | 558 | bool OpieFtp::remoteDirList(const QString &dir) |
559 | { | 559 | { |
560 | QString tmp = QDir::homeDirPath(); | 560 | QString tmp = QDir::homeDirPath(); |
561 | if(tmp.right(1) != "/") | 561 | if(tmp.right(1) != "/") |
562 | tmp+="/._temp"; | 562 | tmp+="/._temp"; |
563 | else | 563 | else |
564 | tmp+="._temp"; | 564 | tmp+="._temp"; |
565 | // qDebug("Listing remote dir "+tmp); | 565 | // qDebug("Listing remote dir "+tmp); |
566 | // QCopEnvelope ( "QPE/System", "busy()" ); | 566 | // QCopEnvelope ( "QPE/System", "busy()" ); |
567 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 567 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
568 | QString msg; | 568 | QString msg; |
569 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 569 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
570 | msg.replace(QRegExp(":"),"\n"); | 570 | msg.replace(QRegExp(":"),"\n"); |
571 | QMessageBox::message(tr("Note"),msg); | 571 | QMessageBox::message(tr("Note"),msg); |
572 | return false; | 572 | return false; |
573 | } | 573 | } |
574 | populateRemoteView() ; | 574 | populateRemoteView() ; |
575 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 575 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
576 | return true; | 576 | return true; |
577 | } | 577 | } |
578 | 578 | ||
579 | bool OpieFtp::remoteChDir(const QString &dir) | 579 | bool OpieFtp::remoteChDir(const QString &dir) |
580 | { | 580 | { |
581 | // QCopEnvelope ( "QPE/System", "busy()" ); | 581 | // QCopEnvelope ( "QPE/System", "busy()" ); |
582 | if (!FtpChdir( dir.latin1(), conn )) { | 582 | if (!FtpChdir( dir.latin1(), conn )) { |
583 | QString msg; | 583 | QString msg; |
584 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 584 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
585 | msg.replace(QRegExp(":"),"\n"); | 585 | msg.replace(QRegExp(":"),"\n"); |
586 | QMessageBox::message(tr("Note"),msg); | 586 | QMessageBox::message(tr("Note"),msg); |
587 | // qDebug(msg); | 587 | // qDebug(msg); |
588 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 588 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
589 | return FALSE; | 589 | return FALSE; |
590 | } | 590 | } |
591 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 591 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
592 | return TRUE; | 592 | return TRUE; |
593 | } | 593 | } |
594 | 594 | ||
595 | void OpieFtp::populateLocalView() | 595 | void OpieFtp::populateLocalView() |
596 | { | 596 | { |
597 | Local_View->clear(); | 597 | Local_View->clear(); |
598 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 598 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
599 | currentDir.setMatchAllDirs(TRUE); | 599 | currentDir.setMatchAllDirs(TRUE); |
600 | currentDir.setNameFilter(filterStr); | 600 | currentDir.setNameFilter(filterStr); |
601 | QString fileL, fileS, fileDate; | 601 | QString fileL, fileS, fileDate; |
602 | bool isDir=FALSE; | 602 | bool isDir=FALSE; |
603 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 603 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
604 | QFileInfoListIterator it(*list); | 604 | QFileInfoListIterator it(*list); |
605 | QFileInfo *fi; | 605 | QFileInfo *fi; |
606 | while ( (fi=it.current()) ) { | 606 | while ( (fi=it.current()) ) { |
607 | if (fi->isSymLink() ){ | 607 | if (fi->isSymLink() ){ |
608 | QString symLink=fi->readLink(); | 608 | QString symLink=fi->readLink(); |
609 | // qDebug("Symlink detected "+symLink); | 609 | // qDebug("Symlink detected "+symLink); |
610 | QFileInfo sym( symLink); | 610 | QFileInfo sym( symLink); |
611 | fileS.sprintf( "%10li", sym.size() ); | 611 | fileS.sprintf( "%10li", sym.size() ); |
612 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 612 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
613 | fileDate = sym.lastModified().toString(); | 613 | fileDate = sym.lastModified().toString(); |
614 | } else { | 614 | } else { |
615 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 615 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
616 | fileS.sprintf( "%10li", fi->size() ); | 616 | fileS.sprintf( "%10li", fi->size() ); |
617 | fileL.sprintf( "%s",fi->fileName().data() ); | 617 | fileL.sprintf( "%s",fi->fileName().data() ); |
618 | fileDate= fi->lastModified().toString(); | 618 | fileDate= fi->lastModified().toString(); |
619 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 619 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
620 | fileL+="/"; | 620 | fileL+="/"; |
621 | isDir=TRUE; | 621 | isDir=TRUE; |
622 | // qDebug( fileL); | 622 | // qDebug( fileL); |
623 | } | 623 | } |
624 | } | 624 | } |
625 | if(fileL !="./" && fi->exists()) { | 625 | if(fileL !="./" && fi->exists()) { |
626 | item= new QListViewItem( Local_View,fileL, fileDate, fileS ); | 626 | item= new QListViewItem( Local_View,fileL, fileDate, fileS ); |
627 | QPixmap pm; | 627 | QPixmap pm; |
628 | 628 | ||
629 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 629 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
630 | if( !QDir( fi->filePath() ).isReadable()) | 630 | if( !QDir( fi->filePath() ).isReadable()) |
631 | pm = Resource::loadPixmap( "lockedfolder" ); | 631 | pm = Resource::loadPixmap( "lockedfolder" ); |
632 | else | 632 | else |
633 | pm= Resource::loadPixmap( "folder" ); | 633 | pm= Resource::loadPixmap( "folder" ); |
634 | item->setPixmap( 0,pm ); | 634 | item->setPixmap( 0,pm ); |
635 | } else { | 635 | } else { |
636 | if( !fi->isReadable() ) | 636 | if( !fi->isReadable() ) |
637 | pm = Resource::loadPixmap( "locked" ); | 637 | pm = Resource::loadPixmap( "locked" ); |
638 | else { | 638 | else { |
639 | MimeType mt(fi->filePath()); | 639 | MimeType mt(fi->filePath()); |
640 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 640 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
641 | if(pm.isNull()) | 641 | if(pm.isNull()) |
642 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 642 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
643 | item->setPixmap( 0,pm); | 643 | item->setPixmap( 0,pm); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | if( fileL.find("->",0,TRUE) != -1) { | 646 | if( fileL.find("->",0,TRUE) != -1) { |
647 | // overlay link image | 647 | // overlay link image |
648 | pm= Resource::loadPixmap( "folder" ); | 648 | pm= Resource::loadPixmap( "folder" ); |
649 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 649 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
650 | QPainter painter( &pm ); | 650 | QPainter painter( &pm ); |
651 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 651 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
652 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 652 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
653 | item->setPixmap( 0, pm); | 653 | item->setPixmap( 0, pm); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | isDir=FALSE; | 656 | isDir=FALSE; |
657 | ++it; | 657 | ++it; |
658 | } | 658 | } |
659 | Local_View->setSorting( 3,FALSE); | 659 | Local_View->setSorting( 3,FALSE); |
660 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 660 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
661 | fillCombo( (const QString &)currentDir); | 661 | fillCombo( (const QString &)currentDir); |
662 | } | 662 | } |
663 | 663 | ||
664 | bool OpieFtp::populateRemoteView( ) | 664 | bool OpieFtp::populateRemoteView( ) |
665 | { | 665 | { |
666 | // qDebug("populate remoteview"); | 666 | // qDebug("populate remoteview"); |
667 | QString sfile=QDir::homeDirPath(); | 667 | QString sfile=QDir::homeDirPath(); |
668 | if(sfile.right(1) != "/") | 668 | if(sfile.right(1) != "/") |
669 | sfile+="/._temp"; | 669 | sfile+="/._temp"; |
670 | else | 670 | else |
671 | sfile+="._temp"; | 671 | sfile+="._temp"; |
672 | QFile file( sfile); | 672 | QFile file( sfile); |
673 | Remote_View->clear(); | 673 | Remote_View->clear(); |
674 | QString s, File_Name; | 674 | QString s, File_Name; |
675 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 675 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
676 | QString fileL, fileS, fileDate; | 676 | QString fileL, fileS, fileDate; |
677 | if ( file.open(IO_ReadOnly)) { | 677 | if ( file.open(IO_ReadOnly)) { |
678 | QTextStream t( &file ); // use a text stream | 678 | QTextStream t( &file ); // use a text stream |
679 | while ( !t.eof()) { | 679 | while ( !t.eof()) { |
680 | s = t.readLine(); | 680 | s = t.readLine(); |
681 | fileL = s.right(s.length()-55); | 681 | fileL = s.right(s.length()-55); |
682 | fileL = fileL.stripWhiteSpace(); | 682 | fileL = fileL.stripWhiteSpace(); |
683 | if(s.left(1) == "d") | 683 | if(s.left(1) == "d") |
684 | fileL = fileL+"/"; | 684 | fileL = fileL+"/"; |
685 | // fileL = "/"+fileL+"/"; | 685 | // fileL = "/"+fileL+"/"; |
686 | fileS = s.mid( 30, 42-30); | 686 | fileS = s.mid( 30, 42-30); |
687 | fileS = fileS.stripWhiteSpace(); | 687 | fileS = fileS.stripWhiteSpace(); |
688 | fileDate = s.mid( 42, 55-42); | 688 | fileDate = s.mid( 42, 55-42); |
689 | fileDate = fileDate.stripWhiteSpace(); | 689 | fileDate = fileDate.stripWhiteSpace(); |
690 | if(fileL.find("total",0,TRUE) == -1) { | 690 | if(fileL.find("total",0,TRUE) == -1) { |
691 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 691 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
692 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); | 692 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); |
693 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 693 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
694 | // if(itemDir) | 694 | // if(itemDir) |
695 | item->moveItem(itemDir); | 695 | item->moveItem(itemDir); |
696 | itemDir=item; | 696 | itemDir=item; |
697 | } else { | 697 | } else { |
698 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); | 698 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); |
699 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 699 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
700 | // if(itemFile) | 700 | // if(itemFile) |
701 | item->moveItem(itemDir); | 701 | item->moveItem(itemDir); |
702 | item->moveItem(itemFile); | 702 | item->moveItem(itemFile); |
703 | itemFile=item; | 703 | itemFile=item; |
704 | } | 704 | } |
705 | } | 705 | } |
706 | } | 706 | } |
707 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 707 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
708 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 708 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
709 | file.close(); | 709 | file.close(); |
710 | if( file.exists()) | 710 | if( file.exists()) |
711 | file. remove(); | 711 | file. remove(); |
712 | } else | 712 | } else |
713 | qDebug("temp file not opened successfullly "+sfile); | 713 | qDebug("temp file not opened successfullly "+sfile); |
714 | Remote_View->setSorting( 4,TRUE); | 714 | Remote_View->setSorting( 4,TRUE); |
715 | return true; | 715 | return true; |
716 | } | 716 | } |
717 | 717 | ||
718 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 718 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
719 | { | 719 | { |
720 | if( selectedItem) { | 720 | if( selectedItem) { |
721 | // QCopEnvelope ( "QPE/System", "busy()" ); | 721 | // QCopEnvelope ( "QPE/System", "busy()" ); |
722 | QString oldRemoteCurrentDir = currentRemoteDir; | 722 | QString oldRemoteCurrentDir = currentRemoteDir; |
723 | QString strItem=selectedItem->text(0); | 723 | QString strItem=selectedItem->text(0); |
724 | strItem=strItem.simplifyWhiteSpace(); | 724 | strItem=strItem.simplifyWhiteSpace(); |
725 | if(strItem == "../") { // the user wants to go ^ | 725 | if(strItem == "../") { // the user wants to go ^ |
726 | if( FtpCDUp( conn) == 0) { | 726 | if( FtpCDUp( conn) == 0) { |
727 | QString msg; | 727 | QString msg; |
728 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 728 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
729 | msg.replace(QRegExp(":"),"\n"); | 729 | msg.replace(QRegExp(":"),"\n"); |
730 | QMessageBox::message(tr("Note"),msg); | 730 | QMessageBox::message(tr("Note"),msg); |
731 | // qDebug(msg); | 731 | // qDebug(msg); |
732 | } | 732 | } |
733 | char path[256]; | 733 | char path[256]; |
734 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 734 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
735 | QString msg; | 735 | QString msg; |
736 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 736 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
737 | msg.replace(QRegExp(":"),"\n"); | 737 | msg.replace(QRegExp(":"),"\n"); |
738 | QMessageBox::message(tr("Note"),msg); | 738 | QMessageBox::message(tr("Note"),msg); |
739 | // qDebug(msg); | 739 | // qDebug(msg); |
740 | } | 740 | } |
741 | currentRemoteDir=path; | 741 | currentRemoteDir=path; |
742 | } else { | 742 | } else { |
743 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 743 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
744 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 744 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
745 | strItem = strItem.stripWhiteSpace(); | 745 | strItem = strItem.stripWhiteSpace(); |
746 | currentRemoteDir = strItem; | 746 | currentRemoteDir = strItem; |
747 | if( !remoteChDir( (const QString &)strItem)) { | 747 | if( !remoteChDir( (const QString &)strItem)) { |
748 | currentRemoteDir = oldRemoteCurrentDir; | 748 | currentRemoteDir = oldRemoteCurrentDir; |
749 | strItem=""; | 749 | strItem=""; |
750 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 750 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
751 | } | 751 | } |
752 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 752 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
753 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 753 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
754 | currentRemoteDir = oldRemoteCurrentDir; | 754 | currentRemoteDir = oldRemoteCurrentDir; |
755 | strItem=""; | 755 | strItem=""; |
756 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 756 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
757 | 757 | ||
758 | } else { | 758 | } else { |
759 | currentRemoteDir = currentRemoteDir+strItem; | 759 | currentRemoteDir = currentRemoteDir+strItem; |
760 | } | 760 | } |
761 | } else { | 761 | } else { |
762 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 762 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
763 | return; | 763 | return; |
764 | } | 764 | } |
765 | } | 765 | } |
766 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 766 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
767 | if(currentRemoteDir.right(1) !="/") | 767 | if(currentRemoteDir.right(1) !="/") |
768 | currentRemoteDir +="/"; | 768 | currentRemoteDir +="/"; |
769 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 769 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
770 | fillRemoteCombo( (const QString &)currentRemoteDir); | 770 | fillRemoteCombo( (const QString &)currentRemoteDir); |
771 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 771 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
772 | } | 772 | } |
773 | } | 773 | } |
774 | 774 | ||
775 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 775 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
776 | { | 776 | { |
777 | if(selectedItem!= NULL) { | 777 | if(selectedItem!= NULL) { |
778 | 778 | ||
779 | QString strItem=selectedItem->text(0); | 779 | QString strItem=selectedItem->text(0); |
780 | QString strSize=selectedItem->text(1); | 780 | QString strSize=selectedItem->text(1); |
781 | strSize=strSize.stripWhiteSpace(); | 781 | strSize=strSize.stripWhiteSpace(); |
782 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 782 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
783 | // is symlink | 783 | // is symlink |
784 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 784 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
785 | if(QDir(strItem2).exists() ) { | 785 | if(QDir(strItem2).exists() ) { |
786 | currentDir.cd(strItem2, TRUE); | 786 | currentDir.cd(strItem2, TRUE); |
787 | populateLocalView(); | 787 | populateLocalView(); |
788 | } | 788 | } |
789 | } else { // not a symlink | 789 | } else { // not a symlink |
790 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 790 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
791 | 791 | ||
792 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 792 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
793 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 793 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
794 | currentDir.cd(strItem,FALSE); | 794 | currentDir.cd(strItem,FALSE); |
795 | populateLocalView(); | 795 | populateLocalView(); |
796 | } else { | 796 | } else { |
797 | currentDir.cdUp(); | 797 | currentDir.cdUp(); |
798 | populateLocalView(); | 798 | populateLocalView(); |
799 | } | 799 | } |
800 | if(QDir(strItem).exists()){ | 800 | if(QDir(strItem).exists()){ |
801 | currentDir.cd(strItem, TRUE); | 801 | currentDir.cd(strItem, TRUE); |
802 | populateLocalView(); | 802 | populateLocalView(); |
803 | } | 803 | } |
804 | } else { | 804 | } else { |
805 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 805 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
806 | if( QFile::exists(strItem ) ) { | 806 | if( QFile::exists(strItem ) ) { |
807 | // qDebug("upload "+strItem); | 807 | // qDebug("upload "+strItem); |
808 | return; | 808 | return; |
809 | } | 809 | } |
810 | } //end not symlink | 810 | } //end not symlink |
811 | chdir(strItem.latin1()); | 811 | chdir(strItem.latin1()); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | void OpieFtp::doLocalCd() | 816 | void OpieFtp::doLocalCd() |
817 | { | 817 | { |
818 | localListClicked( Local_View->currentItem()); | 818 | localListClicked( Local_View->currentItem()); |
819 | } | 819 | } |
820 | 820 | ||
821 | void OpieFtp:: doRemoteCd() | 821 | void OpieFtp:: doRemoteCd() |
822 | { | 822 | { |
823 | remoteListClicked( Remote_View->currentItem()); | 823 | remoteListClicked( Remote_View->currentItem()); |
824 | 824 | ||
825 | } | 825 | } |
826 | 826 | ||
827 | void OpieFtp::showHidden() | 827 | void OpieFtp::showHidden() |
828 | { | 828 | { |
829 | if (!b) { | 829 | if (!b) { |
830 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 830 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
831 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 831 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
832 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 832 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
833 | b=TRUE; | 833 | b=TRUE; |
834 | 834 | ||
835 | } else { | 835 | } else { |
836 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 836 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
837 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 837 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
838 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 838 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
839 | b=FALSE; | 839 | b=FALSE; |
840 | } | 840 | } |
841 | populateLocalView(); | 841 | populateLocalView(); |
842 | } | 842 | } |
843 | 843 | ||
844 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 844 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
845 | { | 845 | { |
846 | // if(item) | 846 | // if(item) |
847 | if (mouse == 2) { | 847 | if (mouse == 2) { |
848 | showLocalMenu(item); | 848 | showLocalMenu(item); |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 852 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
853 | { | 853 | { |
854 | if(mouse == 2) { | 854 | if(mouse == 2) { |
855 | showRemoteMenu(item); | 855 | showRemoteMenu(item); |
856 | } | 856 | } |
857 | } | 857 | } |
858 | 858 | ||
859 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 859 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
860 | { | 860 | { |
861 | QPopupMenu * m;// = new QPopupMenu( Local_View ); | 861 | QPopupMenu * m;// = new QPopupMenu( Local_View ); |
862 | m = new QPopupMenu(this); | 862 | m = new QPopupMenu(this); |
863 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) | 863 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) |
864 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 864 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
865 | else | 865 | else |
866 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 866 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
867 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 867 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
868 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); | 868 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); |
869 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 869 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
870 | m->insertSeparator(); | 870 | m->insertSeparator(); |
871 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 871 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
872 | m->exec( QCursor::pos() ); | 872 | m->exec( QCursor::pos() ); |
873 | delete m; | 873 | delete m; |
874 | } | 874 | } |
875 | 875 | ||
876 | void OpieFtp::showLocalMenu(QListViewItem * item) | 876 | void OpieFtp::showLocalMenu(QListViewItem * item) |
877 | { | 877 | { |
878 | 878 | ||
879 | QPopupMenu *m; | 879 | QPopupMenu *m; |
880 | m = new QPopupMenu( this); | 880 | m = new QPopupMenu( this); |
881 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 881 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
882 | m->insertSeparator(); | 882 | m->insertSeparator(); |
883 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 883 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
884 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 884 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
885 | else | 885 | else |
886 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 886 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
887 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 887 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
888 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); | 888 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); |
889 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 889 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
890 | m->insertSeparator(); | 890 | m->insertSeparator(); |
891 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 891 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
892 | m->setCheckable(TRUE); | 892 | m->setCheckable(TRUE); |
893 | if (b) | 893 | if (b) |
894 | m->setItemChecked(m->idAt(0),TRUE); | 894 | m->setItemChecked(m->idAt(0),TRUE); |
895 | else | 895 | else |
896 | m->setItemChecked(m->idAt(0),FALSE); | 896 | m->setItemChecked(m->idAt(0),FALSE); |
897 | 897 | ||
898 | m->exec( QCursor::pos() ); | 898 | m->exec( QCursor::pos() ); |
899 | delete m; | 899 | delete m; |
900 | } | 900 | } |
901 | 901 | ||
902 | void OpieFtp::localMakDir() | 902 | void OpieFtp::localMakDir() |
903 | { | 903 | { |
904 | InputDialog *fileDlg; | 904 | InputDialog *fileDlg; |
905 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 905 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
906 | fileDlg->exec(); | 906 | fileDlg->exec(); |
907 | if( fileDlg->result() == 1 ) { | 907 | if( fileDlg->result() == 1 ) { |
908 | QString filename = fileDlg->LineEdit1->text(); | 908 | QString filename = fileDlg->LineEdit1->text(); |
909 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 909 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
910 | } | 910 | } |
911 | populateLocalView(); | 911 | populateLocalView(); |
912 | } | 912 | } |
913 | 913 | ||
914 | void OpieFtp::localDelete() | 914 | void OpieFtp::localDelete() |
915 | { | 915 | { |
916 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 916 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
917 | QListViewItemIterator it( Local_View ); | 917 | QListViewItemIterator it( Local_View ); |
918 | for ( ; it.current(); ++it ) { | 918 | for ( ; it.current(); ++it ) { |
919 | if ( it.current()->isSelected() ) { | 919 | if ( it.current()->isSelected() ) { |
920 | QString f = it.current()->text(0); | 920 | QString f = it.current()->text(0); |
921 | it.current()->setSelected(FALSE); | 921 | it.current()->setSelected(FALSE); |
922 | 922 | ||
923 | // QString f = Local_View->currentItem()->text(0); | 923 | // QString f = Local_View->currentItem()->text(0); |
924 | if(QDir(f).exists() ) { | 924 | if(QDir(f).exists() ) { |
925 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 925 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
926 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 926 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { |
927 | case 0: { | 927 | case 0: { |
928 | f=currentDir.canonicalPath()+"/"+f; | 928 | f=currentDir.canonicalPath()+"/"+f; |
929 | QString cmd="rmdir "+f; | 929 | QString cmd="rmdir "+f; |
930 | system( cmd.latin1()); | 930 | system( cmd.latin1()); |
931 | } | 931 | } |
932 | break; | 932 | break; |
933 | case 1: | 933 | case 1: |
934 | // exit | 934 | // exit |
935 | break; | 935 | break; |
936 | }; | 936 | }; |
937 | 937 | ||
938 | } else { | 938 | } else { |
939 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 939 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
940 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 940 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
941 | case 0: { | 941 | case 0: { |
942 | f=currentDir.canonicalPath()+"/"+f; | 942 | f=currentDir.canonicalPath()+"/"+f; |
943 | QString cmd="rm "+f; | 943 | QString cmd="rm "+f; |
944 | system( cmd.latin1()); | 944 | system( cmd.latin1()); |
945 | } | 945 | } |
946 | break; | 946 | break; |
947 | case 1: | 947 | case 1: |
948 | // exit | 948 | // exit |
949 | break; | 949 | break; |
950 | }; | 950 | }; |
951 | } | 951 | } |
952 | } | 952 | } |
953 | } | 953 | } |
954 | populateLocalView(); | 954 | populateLocalView(); |
955 | 955 | ||
956 | } | 956 | } |
957 | 957 | ||
958 | void OpieFtp::remoteMakDir() | 958 | void OpieFtp::remoteMakDir() |
959 | { | 959 | { |
960 | InputDialog *fileDlg; | 960 | InputDialog *fileDlg; |
961 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 961 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
962 | fileDlg->exec(); | 962 | fileDlg->exec(); |
963 | if( fileDlg->result() == 1 ) { | 963 | if( fileDlg->result() == 1 ) { |
964 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 964 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
965 | QString tmp=currentRemoteDir+filename; | 965 | QString tmp=currentRemoteDir+filename; |
966 | // QCopEnvelope ( "QPE/System", "busy()" ); | 966 | // QCopEnvelope ( "QPE/System", "busy()" ); |
967 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 967 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
968 | QString msg; | 968 | QString msg; |
969 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); | 969 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); |
970 | msg.replace(QRegExp(":"),"\n"); | 970 | msg.replace(QRegExp(":"),"\n"); |
971 | QMessageBox::message(tr("Note"),msg); | 971 | QMessageBox::message(tr("Note"),msg); |
972 | } | 972 | } |
973 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 973 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
974 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 974 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
975 | } | 975 | } |
976 | } | 976 | } |
977 | 977 | ||
978 | void OpieFtp::remoteDelete() | 978 | void OpieFtp::remoteDelete() |
979 | { | 979 | { |
980 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 980 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
981 | QListViewItemIterator it( Remote_View ); | 981 | QListViewItemIterator it( Remote_View ); |
982 | for ( ; it.current(); ++it ) { | 982 | for ( ; it.current(); ++it ) { |
983 | if ( it.current()->isSelected() ) { | 983 | if ( it.current()->isSelected() ) { |
984 | QString f = it.current()->text(0); | 984 | QString f = it.current()->text(0); |
985 | // QString f = Remote_View->currentItem()->text(0); | 985 | // QString f = Remote_View->currentItem()->text(0); |
986 | // QCopEnvelope ( "QPE/System", "busy()" ); | 986 | // QCopEnvelope ( "QPE/System", "busy()" ); |
987 | if( f.right(1) =="/") { | 987 | if( f.right(1) =="/") { |
988 | QString path= currentRemoteDir+f; | 988 | QString path= currentRemoteDir+f; |
989 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 989 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
990 | ,tr("Yes"),tr("No"),0,0,1) ) { | 990 | ,tr("Yes"),tr("No"),0,0,1) ) { |
991 | case 0: { | 991 | case 0: { |
992 | f=currentDir.canonicalPath()+"/"+f; | 992 | f=currentDir.canonicalPath()+"/"+f; |
993 | if(FtpRmdir( path.latin1(), conn) ==0) { | 993 | if(FtpRmdir( path.latin1(), conn) ==0) { |
994 | QString msg; | 994 | QString msg; |
995 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); | 995 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); |
996 | msg.replace(QRegExp(":"),"\n"); | 996 | msg.replace(QRegExp(":"),"\n"); |
997 | QMessageBox::message(tr("Note"),msg); | 997 | QMessageBox::message(tr("Note"),msg); |
998 | } | 998 | } |
999 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 999 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1000 | } | 1000 | } |
1001 | break; | 1001 | break; |
1002 | }; | 1002 | }; |
1003 | } else { | 1003 | } else { |
1004 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1004 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1005 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1005 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1006 | case 0: { | 1006 | case 0: { |
1007 | QString path= currentRemoteDir+f; | 1007 | QString path= currentRemoteDir+f; |
1008 | if(FtpDelete( path.latin1(), conn)==0) { | 1008 | if(FtpDelete( path.latin1(), conn)==0) { |
1009 | QString msg; | 1009 | QString msg; |
1010 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 1010 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
1011 | msg.replace(QRegExp(":"),"\n"); | 1011 | msg.replace(QRegExp(":"),"\n"); |
1012 | QMessageBox::message(tr("Note"),msg); | 1012 | QMessageBox::message(tr("Note"),msg); |
1013 | } | 1013 | } |
1014 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1014 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1015 | } | 1015 | } |
1016 | break; | 1016 | break; |
1017 | }; | 1017 | }; |
1018 | } | 1018 | } |
1019 | } | 1019 | } |
1020 | } | 1020 | } |
1021 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1021 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | void OpieFtp::remoteRename() | 1024 | void OpieFtp::remoteRename() |
1025 | { | 1025 | { |
1026 | QString curFile = Remote_View->currentItem()->text(0); | 1026 | QString curFile = Remote_View->currentItem()->text(0); |
1027 | InputDialog *fileDlg; | 1027 | InputDialog *fileDlg; |
1028 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1028 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1029 | fileDlg->setTextEdit((const QString &)curFile); | 1029 | fileDlg->setTextEdit((const QString &)curFile); |
1030 | fileDlg->exec(); | 1030 | fileDlg->exec(); |
1031 | if( fileDlg->result() == 1 ) { | 1031 | if( fileDlg->result() == 1 ) { |
1032 | QString oldName = currentRemoteDir +"/"+ curFile; | 1032 | QString oldName = currentRemoteDir +"/"+ curFile; |
1033 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 1033 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
1034 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1034 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1035 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 1035 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
1036 | QString msg; | 1036 | QString msg; |
1037 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 1037 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
1038 | msg.replace(QRegExp(":"),"\n"); | 1038 | msg.replace(QRegExp(":"),"\n"); |
1039 | QMessageBox::message(tr("Note"),msg); | 1039 | QMessageBox::message(tr("Note"),msg); |
1040 | } | 1040 | } |
1041 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1041 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1042 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1042 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | void OpieFtp::localRename() | 1046 | void OpieFtp::localRename() |
1047 | { | 1047 | { |
1048 | QString curFile = Local_View->currentItem()->text(0); | 1048 | QString curFile = Local_View->currentItem()->text(0); |
1049 | InputDialog *fileDlg; | 1049 | InputDialog *fileDlg; |
1050 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1050 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1051 | fileDlg->setTextEdit((const QString &)curFile); | 1051 | fileDlg->setTextEdit((const QString &)curFile); |
1052 | fileDlg->exec(); | 1052 | fileDlg->exec(); |
1053 | if( fileDlg->result() == 1 ) { | 1053 | if( fileDlg->result() == 1 ) { |
1054 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 1054 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
1055 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 1055 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
1056 | if( rename(oldname.latin1(), newName.latin1())== -1) | 1056 | if( rename(oldname.latin1(), newName.latin1())== -1) |
1057 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1057 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1058 | } | 1058 | } |
1059 | populateLocalView(); | 1059 | populateLocalView(); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { | 1062 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { |
1063 | if (TabWidget->currentPageIndex() == 0) { | 1063 | if (TabWidget->currentPageIndex() == 0) { |
1064 | chdir( currentPath.latin1() ); | 1064 | chdir( currentPath.latin1() ); |
1065 | currentDir.cd( currentPath, TRUE); | 1065 | currentDir.cd( currentPath, TRUE); |
1066 | populateLocalView(); | 1066 | populateLocalView(); |
1067 | update(); | 1067 | update(); |
1068 | } else { | 1068 | } else { |
1069 | // chdir( currentPath.latin1() ); | 1069 | // chdir( currentPath.latin1() ); |
1070 | // currentDir.cd( currentPath, TRUE); | 1070 | // currentDir.cd( currentPath, TRUE); |
1071 | // populateList(); | 1071 | // populateList(); |
1072 | // update(); | 1072 | // update(); |
1073 | 1073 | ||
1074 | } | 1074 | } |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1077 | void OpieFtp::fillCombo(const QString ¤tPath) { |
1078 | 1078 | ||
1079 | currentPathCombo->lineEdit()->setText(currentPath); | 1079 | currentPathCombo->lineEdit()->setText(currentPath); |
1080 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1080 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1081 | currentPathCombo->clear(); | 1081 | currentPathCombo->clear(); |
1082 | localDirPathStringList.prepend(currentPath ); | 1082 | localDirPathStringList.prepend(currentPath ); |
1083 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1083 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1084 | } | 1084 | } |
1085 | currentPathCombo->lineEdit()->setText(currentPath); | 1085 | currentPathCombo->lineEdit()->setText(currentPath); |
1086 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1086 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1087 | currentPathCombo->clear(); | 1087 | currentPathCombo->clear(); |
1088 | remoteDirPathStringList.prepend(currentPath ); | 1088 | remoteDirPathStringList.prepend(currentPath ); |
1089 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1089 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1090 | } | 1090 | } |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1093 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
1094 | 1094 | ||
1095 | currentPathCombo->lineEdit()->setText(currentPath); | 1095 | currentPathCombo->lineEdit()->setText(currentPath); |
1096 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1096 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1097 | currentPathCombo->clear(); | 1097 | currentPathCombo->clear(); |
1098 | remoteDirPathStringList.prepend(currentPath ); | 1098 | remoteDirPathStringList.prepend(currentPath ); |
1099 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1099 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1100 | } | 1100 | } |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | void OpieFtp::currentPathComboChanged() | 1103 | void OpieFtp::currentPathComboChanged() |
1104 | { | 1104 | { |
1105 | QString oldRemoteCurrentDir = currentRemoteDir; | 1105 | QString oldRemoteCurrentDir = currentRemoteDir; |
1106 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1106 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
1107 | if (TabWidget->currentPageIndex() == 0) { | 1107 | if (TabWidget->currentPageIndex() == 0) { |
1108 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1108 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1109 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1109 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1110 | populateLocalView(); | 1110 | populateLocalView(); |
1111 | } else { | 1111 | } else { |
1112 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1112 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1113 | } | 1113 | } |
1114 | } | 1114 | } |
1115 | if (TabWidget->currentPageIndex() == 1) { | 1115 | if (TabWidget->currentPageIndex() == 1) { |
1116 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1116 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1117 | if(currentRemoteDir.right(1) !="/") { | 1117 | if(currentRemoteDir.right(1) !="/") { |
1118 | currentRemoteDir = currentRemoteDir +"/"; | 1118 | currentRemoteDir = currentRemoteDir +"/"; |
1119 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1119 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1120 | } | 1120 | } |
1121 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1121 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1122 | currentRemoteDir = oldRemoteCurrentDir; | 1122 | currentRemoteDir = oldRemoteCurrentDir; |
1123 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1123 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | remoteDirList( (const QString &)currentRemoteDir); | 1126 | remoteDirList( (const QString &)currentRemoteDir); |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | void OpieFtp::switchToLocalTab() | 1130 | void OpieFtp::switchToLocalTab() |
1131 | { | 1131 | { |
1132 | TabWidget->setCurrentPage(0); | 1132 | TabWidget->setCurrentPage(0); |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | void OpieFtp::switchToRemoteTab() | 1135 | void OpieFtp::switchToRemoteTab() |
1136 | { | 1136 | { |
1137 | TabWidget->setCurrentPage(1); | 1137 | TabWidget->setCurrentPage(1); |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | void OpieFtp::switchToConfigTab() | 1140 | void OpieFtp::switchToConfigTab() |
1141 | { | 1141 | { |
1142 | TabWidget->setCurrentPage(2); | 1142 | TabWidget->setCurrentPage(2); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | void OpieFtp::readConfig() | 1145 | void OpieFtp::readConfig() |
1146 | { | 1146 | { |
1147 | fillCombos(); | 1147 | fillCombos(); |
1148 | Config cfg("opieftp"); | 1148 | Config cfg("opieftp"); |
1149 | cfg.setGroup("Server"); | 1149 | cfg.setGroup("Server"); |
1150 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1150 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1151 | 1151 | ||
1152 | // qDebug("Reading %d", currentServerConfig); | 1152 | // qDebug("Reading %d", currentServerConfig); |
1153 | serverComboSelected( currentServerConfig); | 1153 | serverComboSelected( currentServerConfig); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void OpieFtp::writeConfig() | 1156 | void OpieFtp::writeConfig() |
1157 | { | 1157 | { |
1158 | Config cfg("opieftp"); | 1158 | Config cfg("opieftp"); |
1159 | cfg.setGroup("Server"); | 1159 | cfg.setGroup("Server"); |
1160 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1160 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1161 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1161 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1162 | if( currentServerConfig == -1) { | 1162 | if( currentServerConfig == -1) { |
1163 | for (int i = 1; i <= numberOfEntries; i++) { | 1163 | for (int i = 1; i <= numberOfEntries; i++) { |
1164 | temp.setNum(i); | 1164 | temp.setNum(i); |
1165 | cfg.setGroup("Server"); | 1165 | cfg.setGroup("Server"); |
1166 | QString tempStr = cfg.readEntry( temp,""); | 1166 | QString tempStr = cfg.readEntry( temp,""); |
1167 | } | 1167 | } |
1168 | temp.setNum( numberOfEntries + 1); | 1168 | temp.setNum( numberOfEntries + 1); |
1169 | cfg.setGroup("Server"); | 1169 | cfg.setGroup("Server"); |
1170 | remoteServerStr = cfg.readEntry( temp,""); | 1170 | remoteServerStr = cfg.readEntry( temp,""); |
1171 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1171 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1172 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1172 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1173 | 1173 | ||
1174 | temp.setNum(numberOfEntries+1); | 1174 | temp.setNum(numberOfEntries+1); |
1175 | cfg.setGroup("Server"); | 1175 | cfg.setGroup("Server"); |
1176 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1176 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1177 | cfg.writeEntry("currentServer", numberOfEntries+1); | 1177 | cfg.writeEntry("currentServer", numberOfEntries+1); |
1178 | cfg.setGroup(temp); | 1178 | cfg.setGroup(temp); |
1179 | cfg.writeEntry("RemotePath", remotePath->text()); | 1179 | cfg.writeEntry("RemotePath", remotePath->text()); |
1180 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1180 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1181 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1181 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1182 | cfg.setGroup("Server"); | 1182 | cfg.setGroup("Server"); |
1183 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1183 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1184 | 1184 | ||
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void OpieFtp::fillCombos() | 1188 | void OpieFtp::fillCombos() |
1189 | { | 1189 | { |
1190 | Config cfg("opieftp"); | 1190 | Config cfg("opieftp"); |
1191 | cfg.setGroup("Server"); | 1191 | cfg.setGroup("Server"); |
1192 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1192 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1193 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1193 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1194 | for (int i = 1; i <= numberOfEntries; i++) { | 1194 | for (int i = 1; i <= numberOfEntries; i++) { |
1195 | temp.setNum(i); | 1195 | temp.setNum(i); |
1196 | qDebug(temp); | 1196 | qDebug(temp); |
1197 | cfg.setGroup("Server"); | 1197 | cfg.setGroup("Server"); |
1198 | remoteServerStr = cfg.readEntry( temp,""); | 1198 | remoteServerStr = cfg.readEntry( temp,""); |
1199 | qDebug( remoteServerStr); | 1199 | qDebug( remoteServerStr); |
1200 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1200 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1201 | port = remoteServerStr.right( divider - 1); | 1201 | port = remoteServerStr.right( divider - 1); |
1202 | bool ok; | 1202 | bool ok; |
1203 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1203 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1204 | 1204 | ||
1205 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1205 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1206 | qDebug( remoteServerStr); | 1206 | qDebug( remoteServerStr); |
1207 | ServerComboBox->insertItem( remoteServerStr ); | 1207 | ServerComboBox->insertItem( remoteServerStr ); |
1208 | // cfg.setGroup(temp); | 1208 | // cfg.setGroup(temp); |
1209 | 1209 | ||
1210 | // remotePathStr = cfg.readEntry(remoteServer,""); | 1210 | // remotePathStr = cfg.readEntry(remoteServer,""); |
1211 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | 1211 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); |
1212 | // port = remoteServer.right( divider+1); | 1212 | // port = remoteServer.right( divider+1); |
1213 | // PortSpinBox->setValue( port); | 1213 | // PortSpinBox->setValue( port); |
1214 | 1214 | ||
1215 | // remoteServer = remoteServer.left(divider - 1); | 1215 | // remoteServer = remoteServer.left(divider - 1); |
1216 | // remotePath->setText( remotePathStr); | 1216 | // remotePath->setText( remotePathStr); |
1217 | 1217 | ||
1218 | // username = cfg.readEntry(temp); | 1218 | // username = cfg.readEntry(temp); |
1219 | // UsernameComboBox->insertItem(username); | 1219 | // UsernameComboBox->insertItem(username); |
1220 | // password = cfg.readEntryCrypt(username,""); | 1220 | // password = cfg.readEntryCrypt(username,""); |
1221 | // PasswordEdit->setText(password); | 1221 | // PasswordEdit->setText(password); |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | 1225 | ||
1226 | void OpieFtp::serverComboSelected(int index) | 1226 | void OpieFtp::serverComboSelected(int index) |
1227 | { | 1227 | { |
1228 | currentServerConfig = index; | 1228 | currentServerConfig = index; |
1229 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1229 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1230 | // remoteServerStr = ServerComboBox->text(index); | 1230 | // remoteServerStr = ServerComboBox->text(index); |
1231 | Config cfg("opieftp"); | 1231 | Config cfg("opieftp"); |
1232 | cfg.setGroup("Server"); | 1232 | cfg.setGroup("Server"); |
1233 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1233 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1234 | 1234 | ||
1235 | temp.setNum(index); | 1235 | temp.setNum(index); |
1236 | remoteServerStr = cfg.readEntry( temp,""); | 1236 | remoteServerStr = cfg.readEntry( temp,""); |
1237 | qDebug("Group" +temp); | 1237 | qDebug("Group" +temp); |
1238 | cfg.setGroup(temp); | 1238 | cfg.setGroup(temp); |
1239 | // qDebug(temp); | 1239 | // qDebug(temp); |
1240 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1240 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1241 | port = remoteServerStr.right( divider - 1); | 1241 | port = remoteServerStr.right( divider - 1); |
1242 | bool ok; | 1242 | bool ok; |
1243 | int portInt = port.toInt(&ok,10); | 1243 | int portInt = port.toInt(&ok,10); |
1244 | if( portInt == 0) portInt = 21; | 1244 | if( portInt == 0) portInt = 21; |
1245 | 1245 | ||
1246 | PortSpinBox->setValue( portInt); | 1246 | PortSpinBox->setValue( portInt); |
1247 | 1247 | ||
1248 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1248 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1249 | 1249 | ||
1250 | username = cfg.readEntry("Username", "anonymous"); | 1250 | username = cfg.readEntry("Username", "anonymous"); |
1251 | UsernameComboBox->lineEdit()->setText(username); | 1251 | UsernameComboBox->lineEdit()->setText(username); |
1252 | qDebug(username); | 1252 | qDebug(username); |
1253 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | 1253 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); |
1254 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1254 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1255 | // UsernameComboBox | 1255 | // UsernameComboBox |
1256 | // PasswordEdit | 1256 | // PasswordEdit |
1257 | 1257 | ||
1258 | cfg.setGroup("Server"); | 1258 | cfg.setGroup("Server"); |
1259 | temp.sprintf("%d",currentServerConfig); | 1259 | temp.sprintf("%d",currentServerConfig); |
1260 | cfg.writeEntry("currentServer", temp); | 1260 | cfg.writeEntry("currentServer", temp); |
1261 | update(); | 1261 | update(); |
1262 | } | 1262 | } |
1263 | // UsernameComboBox->lineEdit()->setText("root"); | 1263 | // UsernameComboBox->lineEdit()->setText("root"); |
1264 | // PasswordEdit->setText( tr( "" ) ); | 1264 | // PasswordEdit->setText( tr( "" ) ); |
1265 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 1265 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
1266 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 1266 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
1267 | // PortSpinBox->setValue( 4242); | 1267 | // PortSpinBox->setValue( 4242); |
1268 | 1268 | ||
1269 | void OpieFtp::deleteServer() | 1269 | void OpieFtp::deleteServer() |
1270 | { | 1270 | { |
1271 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1271 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1272 | remoteServerStr = ServerComboBox->currentText( ); | 1272 | remoteServerStr = ServerComboBox->currentText( ); |
1273 | username = UsernameComboBox->currentText(); | 1273 | username = UsernameComboBox->currentText(); |
1274 | Config cfg("opieftp"); | 1274 | Config cfg("opieftp"); |
1275 | cfg.setGroup("Server"); | 1275 | cfg.setGroup("Server"); |
1276 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1276 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1277 | for (int i = 0; i <= numberOfEntries; i++) { | 1277 | for (int i = 0; i <= numberOfEntries; i++) { |
1278 | temp.setNum(i+1); | 1278 | temp.setNum(i+1); |
1279 | cfg.setGroup("Server"); | 1279 | cfg.setGroup("Server"); |
1280 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 | 1280 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 |
1281 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 | 1281 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 |
1282 | && !remoteServerStr.isEmpty()) { | 1282 | && !remoteServerStr.isEmpty()) { |
1283 | qDebug(temp); | 1283 | qDebug(temp); |
1284 | } | 1284 | } |
1285 | } | 1285 | } |
1286 | } | 1286 | } |
1287 | 1287 | ||
1288 | void OpieFtp::upDir() | 1288 | void OpieFtp::upDir() |
1289 | { | 1289 | { |
1290 | if (TabWidget->currentPageIndex() == 0) { | 1290 | if (TabWidget->currentPageIndex() == 0) { |
1291 | QString current = currentDir.canonicalPath(); | 1291 | QString current = currentDir.canonicalPath(); |
1292 | QDir dir(current); | 1292 | QDir dir(current); |
1293 | dir.cdUp(); | 1293 | dir.cdUp(); |
1294 | current = dir.canonicalPath(); | 1294 | current = dir.canonicalPath(); |
1295 | chdir( current.latin1() ); | 1295 | chdir( current.latin1() ); |
1296 | currentDir.cd( current, TRUE); | 1296 | currentDir.cd( current, TRUE); |
1297 | populateLocalView(); | 1297 | populateLocalView(); |
1298 | update(); | 1298 | update(); |
1299 | } else { | 1299 | } else { |
1300 | if( FtpCDUp( conn) == 0) { | 1300 | if( FtpCDUp( conn) == 0) { |
1301 | QString msg; | 1301 | QString msg; |
1302 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 1302 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
1303 | msg.replace(QRegExp(":"),"\n"); | 1303 | msg.replace(QRegExp(":"),"\n"); |
1304 | QMessageBox::message(tr("Note"),msg); | 1304 | QMessageBox::message(tr("Note"),msg); |
1305 | // qDebug(msg); | 1305 | // qDebug(msg); |
1306 | } | 1306 | } |
1307 | char path[256]; | 1307 | char path[256]; |
1308 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 1308 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
1309 | QString msg; | 1309 | QString msg; |
1310 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 1310 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
1311 | msg.replace(QRegExp(":"),"\n"); | 1311 | msg.replace(QRegExp(":"),"\n"); |
1312 | QMessageBox::message(tr("Note"),msg); | 1312 | QMessageBox::message(tr("Note"),msg); |
1313 | // qDebug(msg); | 1313 | // qDebug(msg); |
1314 | } | 1314 | } |
1315 | currentRemoteDir=path; | 1315 | currentRemoteDir=path; |
1316 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1316 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1317 | if(currentRemoteDir.right(1) !="/") | 1317 | if(currentRemoteDir.right(1) !="/") |
1318 | currentRemoteDir +="/"; | 1318 | currentRemoteDir +="/"; |
1319 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 1319 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
1320 | fillRemoteCombo( (const QString &)currentRemoteDir); | 1320 | fillRemoteCombo( (const QString &)currentRemoteDir); |
1321 | 1321 | ||
1322 | } | 1322 | } |
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | void OpieFtp::docButtonPushed() { | 1325 | void OpieFtp::docButtonPushed() { |
1326 | QString current = QPEApplication::documentDir(); | 1326 | QString current = QPEApplication::documentDir(); |
1327 | chdir( current.latin1() ); | 1327 | chdir( current.latin1() ); |
1328 | currentDir.cd( current, TRUE); | 1328 | currentDir.cd( current, TRUE); |
1329 | populateLocalView(); | 1329 | populateLocalView(); |
1330 | update(); | 1330 | update(); |
1331 | 1331 | ||
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | void OpieFtp::homeButtonPushed() { | 1334 | void OpieFtp::homeButtonPushed() { |
1335 | QString current = QDir::homeDirPath(); | 1335 | QString current = QDir::homeDirPath(); |
1336 | chdir( current.latin1() ); | 1336 | chdir( current.latin1() ); |
1337 | currentDir.cd( current, TRUE); | 1337 | currentDir.cd( current, TRUE); |
1338 | populateLocalView(); | 1338 | populateLocalView(); |
1339 | update(); | 1339 | update(); |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | void OpieFtp::doAbout() { | 1342 | void OpieFtp::doAbout() { |
1343 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" | 1343 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" |
1344 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1344 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1345 | "and uses ftplib copyright 1996-2000\n" | 1345 | "and uses ftplib copyright 1996-2000\n" |
1346 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" | 1346 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" |
1347 | "and is licensed by the GPL"); | 1347 | "and is licensed by the GPL"); |
1348 | } | 1348 | } |
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp index b490072..672548f 100644 --- a/noncore/settings/sound/soundsettings.cpp +++ b/noncore/settings/sound/soundsettings.cpp | |||
@@ -1,250 +1,250 @@ | |||
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 "soundsettings.h" | 21 | #include "soundsettings.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | 27 | ||
28 | #include <qapplication.h> | 28 | #include <qapplication.h> |
29 | #include <qslider.h> | 29 | #include <qslider.h> |
30 | #include <qcheckbox.h> | 30 | #include <qcheckbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | 33 | ||
34 | #include <sys/utsname.h> | 34 | #include <sys/utsname.h> |
35 | #include <sys/time.h> | 35 | #include <sys/time.h> |
36 | #include <sys/types.h> | 36 | #include <sys/types.h> |
37 | #include <unistd.h> | 37 | #include <unistd.h> |
38 | #include <stdio.h> | 38 | #include <stdio.h> |
39 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
40 | 40 | ||
41 | SoundSettings::SoundSettings( QWidget* parent, const char* name, WFlags fl ) | 41 | SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) |
42 | : SoundSettingsBase( parent, name, TRUE, fl ) | 42 | : SoundSettingsBase( parent, objname, TRUE, fl ) |
43 | { | 43 | { |
44 | keyReset=FALSE; | 44 | keyReset=FALSE; |
45 | 45 | ||
46 | Config config( "qpe"); | 46 | Config config( "qpe"); |
47 | config.setGroup( "Volume" ); | 47 | config.setGroup( "Volume" ); |
48 | volume->setValue(100-config.readNumEntry("VolumePercent")); | 48 | volume->setValue(100-config.readNumEntry("VolumePercent")); |
49 | mic->setValue(100-config.readNumEntry("Mic")); | 49 | mic->setValue(100-config.readNumEntry("Mic")); |
50 | // touchsound->setChecked(config.readBoolEntry("TouchSound")); | 50 | // touchsound->setChecked(config.readBoolEntry("TouchSound")); |
51 | // keysound->setChecked(config.readBoolEntry("KeySound")); | 51 | // keysound->setChecked(config.readBoolEntry("KeySound")); |
52 | Config cfg("Vmemo"); | 52 | Config cfg("Vmemo"); |
53 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 53 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
54 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); | 54 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); |
55 | 55 | ||
56 | cfg.setGroup("Record"); | 56 | cfg.setGroup("Record"); |
57 | int rate=config.readNumEntry("SampleRate", 22050); | 57 | int rate=config.readNumEntry("SampleRate", 22050); |
58 | if(rate == 8000) | 58 | if(rate == 8000) |
59 | sampleRate->setCurrentItem(0); | 59 | sampleRate->setCurrentItem(0); |
60 | else if(rate == 11025) | 60 | else if(rate == 11025) |
61 | sampleRate->setCurrentItem(1); | 61 | sampleRate->setCurrentItem(1); |
62 | else if(rate == 22050) | 62 | else if(rate == 22050) |
63 | sampleRate->setCurrentItem(2); | 63 | sampleRate->setCurrentItem(2); |
64 | else if(rate == 33075) | 64 | else if(rate == 33075) |
65 | sampleRate->setCurrentItem(3); | 65 | sampleRate->setCurrentItem(3); |
66 | else if(rate==44100) | 66 | else if(rate==44100) |
67 | sampleRate->setCurrentItem(4); | 67 | sampleRate->setCurrentItem(4); |
68 | 68 | ||
69 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); //TODO hide if zaurus- mono only | 69 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); //TODO hide if zaurus- mono only |
70 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 70 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
71 | if (uname(&name) != -1) { | 71 | if (uname(&name) != -1) { |
72 | QString release=name.release; | 72 | QString release=name.release; |
73 | 73 | ||
74 | if( release.find("embedix",0,TRUE) !=-1) | 74 | if( release.find("embedix",0,TRUE) !=-1) |
75 | stereoCheckBox->hide(); | 75 | stereoCheckBox->hide(); |
76 | } | 76 | } |
77 | // else | 77 | // else |
78 | // stereoCheckBox->hide(); | 78 | // stereoCheckBox->hide(); |
79 | 79 | ||
80 | 80 | ||
81 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); | 81 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); |
82 | 82 | ||
83 | cfg.setGroup("Defaults"); | 83 | cfg.setGroup("Defaults"); |
84 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); | 84 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); |
85 | 85 | ||
86 | updateStorageCombo(); | 86 | updateStorageCombo(); |
87 | 87 | ||
88 | connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int))); | 88 | connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int))); |
89 | connect(mic, SIGNAL(valueChanged(int)), this, SLOT(setMic(int))); | 89 | connect(mic, SIGNAL(valueChanged(int)), this, SLOT(setMic(int))); |
90 | connect(qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 90 | connect(qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
91 | connect(qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); | 91 | connect(qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); |
92 | connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &))); | 92 | connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &))); |
93 | connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT(setKeyButton(const QString &))); | 93 | connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT(setKeyButton(const QString &))); |
94 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 94 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
95 | } | 95 | } |
96 | 96 | ||
97 | // void SoundSettings::reject() | 97 | // void SoundSettings::reject() |
98 | // { | 98 | // { |
99 | // qDebug("reject"); | 99 | // qDebug("reject"); |
100 | // Config config( "qpe"); | 100 | // Config config( "qpe"); |
101 | // config.setGroup( "Volume"); | 101 | // config.setGroup( "Volume"); |
102 | 102 | ||
103 | // setVolume(100-config.readNumEntry("VolumePercent")); | 103 | // setVolume(100-config.readNumEntry("VolumePercent")); |
104 | // setMic(100-config.readNumEntry("Mic")); | 104 | // setMic(100-config.readNumEntry("Mic")); |
105 | 105 | ||
106 | // // config.setGroup("Record"); | 106 | // // config.setGroup("Record"); |
107 | // // int rate=config.readNumEntry("SampleRate", 11025); | 107 | // // int rate=config.readNumEntry("SampleRate", 11025); |
108 | // // if(rate == 11025) | 108 | // // if(rate == 11025) |
109 | // // sampleRate->setCurrentItem(0); | 109 | // // sampleRate->setCurrentItem(0); |
110 | // // else if(rate == 22050) | 110 | // // else if(rate == 22050) |
111 | // // sampleRate->setCurrentItem(1); | 111 | // // sampleRate->setCurrentItem(1); |
112 | // // else if(rate == 32000) | 112 | // // else if(rate == 32000) |
113 | // // sampleRate->setCurrentItem(2); | 113 | // // sampleRate->setCurrentItem(2); |
114 | // // else if(rate==44100) | 114 | // // else if(rate==44100) |
115 | // // sampleRate->setCurrentItem(3); | 115 | // // sampleRate->setCurrentItem(3); |
116 | // // stereoCheckBox->setChecked(config.readNumEntry("Stereo", 0)); | 116 | // // stereoCheckBox->setChecked(config.readNumEntry("Stereo", 0)); |
117 | // // sixteenBitCheckBox->setChecked(config.readNumEntry("SixteenBit", 0)); | 117 | // // sixteenBitCheckBox->setChecked(config.readNumEntry("SixteenBit", 0)); |
118 | // qDebug("QDialog::reject();"); | 118 | // qDebug("QDialog::reject();"); |
119 | // ::exit(-1); | 119 | // ::exit(-1); |
120 | // } | 120 | // } |
121 | 121 | ||
122 | // void SoundSettings::accept() | 122 | // void SoundSettings::accept() |
123 | // { | 123 | // { |
124 | // qDebug("accept"); | 124 | // qDebug("accept"); |
125 | // Config config( "qpe" ); | 125 | // Config config( "qpe" ); |
126 | // config.setGroup( "Volume" ); | 126 | // config.setGroup( "Volume" ); |
127 | // config.writeEntry("VolumePercent",100-volume->value()); | 127 | // config.writeEntry("VolumePercent",100-volume->value()); |
128 | // config.writeEntry("Mic",100-mic->value()); | 128 | // config.writeEntry("Mic",100-mic->value()); |
129 | // // config.writeEntry("TouchSound",touchsound->isChecked()); | 129 | // // config.writeEntry("TouchSound",touchsound->isChecked()); |
130 | // // config.writeEntry("KeySound",keysound->isChecked()); | 130 | // // config.writeEntry("KeySound",keysound->isChecked()); |
131 | 131 | ||
132 | // Config cfg("Vmemo"); | 132 | // Config cfg("Vmemo"); |
133 | // cfg.writeEntry("Alert",AlertCheckBox->isChecked()); | 133 | // cfg.writeEntry("Alert",AlertCheckBox->isChecked()); |
134 | // setVolume(volume->value()); | 134 | // setVolume(volume->value()); |
135 | // setMic(mic->value()); | 135 | // setMic(mic->value()); |
136 | 136 | ||
137 | // cfg.setGroup("Record"); | 137 | // cfg.setGroup("Record"); |
138 | // cfg.writeEntry("SampleRate",sampleRate->currentText()); | 138 | // cfg.writeEntry("SampleRate",sampleRate->currentText()); |
139 | // cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); | 139 | // cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); |
140 | // cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); | 140 | // cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); |
141 | // // Config cfg( "VMemo" ); | 141 | // // Config cfg( "VMemo" ); |
142 | // // cfg.setGroup( "Defaults" ); | 142 | // // cfg.setGroup( "Defaults" ); |
143 | // // cfg.writeEntry( "hideIcon", HideIcon_CheckBox->isChecked()); | 143 | // // cfg.writeEntry( "hideIcon", HideIcon_CheckBox->isChecked()); |
144 | // qDebug("QDialog::accept();"); | 144 | // qDebug("QDialog::accept();"); |
145 | // ::exit(0); | 145 | // ::exit(0); |
146 | // } | 146 | // } |
147 | 147 | ||
148 | void SoundSettings::setVolume(int v) | 148 | void SoundSettings::setVolume(int v) |
149 | { | 149 | { |
150 | Config config( "qpe" ); | 150 | Config config( "qpe" ); |
151 | config.setGroup( "Volume" ); | 151 | config.setGroup( "Volume" ); |
152 | config.writeEntry("VolumePercent",100-v); | 152 | config.writeEntry("VolumePercent",100-v); |
153 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 153 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
154 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; | 154 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; |
155 | #endif | 155 | #endif |
156 | } | 156 | } |
157 | 157 | ||
158 | void SoundSettings::setMic(int m) | 158 | void SoundSettings::setMic(int m) |
159 | { | 159 | { |
160 | Config config( "qpe" ); | 160 | Config config( "qpe" ); |
161 | config.setGroup( "Volume" ); | 161 | config.setGroup( "Volume" ); |
162 | config.writeEntry("Mic",100-m); | 162 | config.writeEntry("Mic",100-m); |
163 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 163 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
164 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << FALSE; | 164 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << FALSE; |
165 | #endif | 165 | #endif |
166 | } | 166 | } |
167 | 167 | ||
168 | void SoundSettings::volumeChanged( bool ) | 168 | void SoundSettings::volumeChanged( bool ) |
169 | { | 169 | { |
170 | Config config( "qpe" ); | 170 | Config config( "qpe" ); |
171 | config.setGroup( "Volume" ); | 171 | config.setGroup( "Volume" ); |
172 | volume->setValue(100-config.readNumEntry("VolumePercent")); | 172 | volume->setValue(100-config.readNumEntry("VolumePercent")); |
173 | } | 173 | } |
174 | 174 | ||
175 | void SoundSettings::micChanged( bool ) | 175 | void SoundSettings::micChanged( bool ) |
176 | { | 176 | { |
177 | Config config( "qpe" ); | 177 | Config config( "qpe" ); |
178 | config.setGroup( "Volume" ); | 178 | config.setGroup( "Volume" ); |
179 | mic->setValue(100-config.readNumEntry("Mic")); | 179 | mic->setValue(100-config.readNumEntry("Mic")); |
180 | } | 180 | } |
181 | 181 | ||
182 | void SoundSettings::updateStorageCombo() { | 182 | void SoundSettings::updateStorageCombo() { |
183 | 183 | ||
184 | Config config( "Vmemo" ); | 184 | Config config( "Vmemo" ); |
185 | config.setGroup( "System" ); | 185 | config.setGroup( "System" ); |
186 | QString loc = config.readEntry("RecLocation","/"); | 186 | QString loc = config.readEntry("RecLocation","/"); |
187 | int i=0; | 187 | int i=0; |
188 | int set=0; | 188 | int set=0; |
189 | StorageInfo storageInfo; | 189 | StorageInfo storageInfo; |
190 | QString sName, sPath; | 190 | QString sName, sPath; |
191 | QStringList list; | 191 | QStringList list; |
192 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 192 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
193 | QListIterator<FileSystem> it ( fs ); | 193 | QListIterator<FileSystem> it ( fs ); |
194 | for( ; it.current(); ++it ){ | 194 | for( ; it.current(); ++it ){ |
195 | const QString name = (*it)->name(); | 195 | const QString name = (*it)->name(); |
196 | const QString path = (*it)->path(); | 196 | const QString path = (*it)->path(); |
197 | qDebug("storage name "+name +" storage path is "+path); | 197 | qDebug("storage name "+name +" storage path is "+path); |
198 | list << name + ": " +path; | 198 | list << name + ": " +path; |
199 | if( loc.find( path,0,TRUE) != -1) | 199 | if( loc.find( path,0,TRUE) != -1) |
200 | set = i; | 200 | set = i; |
201 | // if(dit.current()->file().find(path) != -1 ) storage=name; | 201 | // if(dit.current()->file().find(path) != -1 ) storage=name; |
202 | i++; | 202 | i++; |
203 | } | 203 | } |
204 | LocationComboBox->insertStringList(list); | 204 | LocationComboBox->insertStringList(list); |
205 | qDebug("set item %d", set); | 205 | qDebug("set item %d", set); |
206 | LocationComboBox->setCurrentItem(set); | 206 | LocationComboBox->setCurrentItem(set); |
207 | } | 207 | } |
208 | 208 | ||
209 | void SoundSettings::setLocation(const QString & string) { | 209 | void SoundSettings::setLocation(const QString & string) { |
210 | Config config( "Vmemo" ); | 210 | Config config( "Vmemo" ); |
211 | config.setGroup( "System" ); | 211 | config.setGroup( "System" ); |
212 | config.writeEntry("RecLocation",string); | 212 | config.writeEntry("RecLocation",string); |
213 | qDebug("set location "+string); | 213 | qDebug("set location "+string); |
214 | config.write(); | 214 | config.write(); |
215 | } | 215 | } |
216 | 216 | ||
217 | void SoundSettings::cleanUp() { | 217 | void SoundSettings::cleanUp() { |
218 | qDebug("cleanup"); | 218 | qDebug("cleanup"); |
219 | Config config( "qpe" ); | 219 | Config config( "qpe" ); |
220 | config.setGroup( "Volume" ); | 220 | config.setGroup( "Volume" ); |
221 | config.writeEntry("VolumePercent",100-volume->value()); | 221 | config.writeEntry("VolumePercent",100-volume->value()); |
222 | config.writeEntry("Mic",100-mic->value()); | 222 | config.writeEntry("Mic",100-mic->value()); |
223 | // config.writeEntry("TouchSound",touchsound->isChecked()); | 223 | // config.writeEntry("TouchSound",touchsound->isChecked()); |
224 | // config.writeEntry("KeySound",keysound->isChecked()); | 224 | // config.writeEntry("KeySound",keysound->isChecked()); |
225 | 225 | ||
226 | Config cfg("Vmemo"); | 226 | Config cfg("Vmemo"); |
227 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); | 227 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); |
228 | setVolume(volume->value()); | 228 | setVolume(volume->value()); |
229 | setMic(mic->value()); | 229 | setMic(mic->value()); |
230 | 230 | ||
231 | cfg.setGroup("Record"); | 231 | cfg.setGroup("Record"); |
232 | cfg.writeEntry("SampleRate",sampleRate->currentText()); | 232 | cfg.writeEntry("SampleRate",sampleRate->currentText()); |
233 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); | 233 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); |
234 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); | 234 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); |
235 | 235 | ||
236 | if(keyReset) QCopEnvelope ("QPE/System", "restart()"); | 236 | if(keyReset) QCopEnvelope ("QPE/System", "restart()"); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | void SoundSettings::setKeyButton(const QString &name) { | 240 | void SoundSettings::setKeyButton(const QString &name) { |
241 | Config cfg("Vmemo"); | 241 | Config cfg("Vmemo"); |
242 | cfg.setGroup("Defaults"); | 242 | cfg.setGroup("Defaults"); |
243 | cfg.writeEntry( "toggleKey", keyComboBox->currentItem() ); | 243 | cfg.writeEntry( "toggleKey", keyComboBox->currentItem() ); |
244 | keyReset = TRUE; | 244 | keyReset = TRUE; |
245 | cfg.write(); | 245 | cfg.write(); |
246 | } | 246 | } |
247 | 247 | ||
248 | void SoundSettings::updateLocationCombo() { | 248 | void SoundSettings::updateLocationCombo() { |
249 | 249 | ||
250 | } | 250 | } |
diff --git a/noncore/tools/opie-sh/fviewer.cpp b/noncore/tools/opie-sh/fviewer.cpp index 882c72c..6f8f054 100644 --- a/noncore/tools/opie-sh/fviewer.cpp +++ b/noncore/tools/opie-sh/fviewer.cpp | |||
@@ -1,59 +1,59 @@ | |||
1 | /* | 1 | /* |
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | 2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | #include "fviewer.h" | 16 | #include "fviewer.h" |
17 | 17 | ||
18 | FViewer::FViewer(QString icon, QString filename, QString title, QWidget *parent=0, const char*name=0):QWidget(parent, name) | 18 | FViewer::FViewer(QString icon, QString filename, QString title, QWidget *parent, const char*name):QWidget(parent, name) |
19 | { | 19 | { |
20 | QVBoxLayout *layout = new QVBoxLayout(this); | 20 | QVBoxLayout *layout = new QVBoxLayout(this); |
21 | 21 | ||
22 | setIcon(Resource::loadPixmap("opie-sh")); | 22 | setIcon(Resource::loadPixmap("opie-sh")); |
23 | 23 | ||
24 | textView = new QTextBrowser(this, "textview"); | 24 | textView = new QTextBrowser(this, "textview"); |
25 | layout->addWidget(textView); | 25 | layout->addWidget(textView); |
26 | 26 | ||
27 | QString string; | 27 | QString string; |
28 | 28 | ||
29 | if(title.isNull()) | 29 | if(title.isNull()) |
30 | { | 30 | { |
31 | setCaption(filename); | 31 | setCaption(filename); |
32 | } | 32 | } |
33 | else | 33 | else |
34 | { | 34 | { |
35 | setCaption(title); | 35 | setCaption(title); |
36 | } | 36 | } |
37 | 37 | ||
38 | file = new QFile(); | 38 | file = new QFile(); |
39 | 39 | ||
40 | if(!filename.isNull()) | 40 | if(!filename.isNull()) |
41 | { | 41 | { |
42 | file->setName(filename); | 42 | file->setName(filename); |
43 | file->open(IO_ReadOnly); | 43 | file->open(IO_ReadOnly); |
44 | } | 44 | } |
45 | else | 45 | else |
46 | { | 46 | { |
47 | file->open(IO_ReadOnly, 0); | 47 | file->open(IO_ReadOnly, 0); |
48 | } | 48 | } |
49 | 49 | ||
50 | stream = new QTextStream(file); | 50 | stream = new QTextStream(file); |
51 | 51 | ||
52 | string = stream->read(); | 52 | string = stream->read(); |
53 | textView->mimeSourceFactory()->setFilePath(QDir::currentDirPath()+"/"); | 53 | textView->mimeSourceFactory()->setFilePath(QDir::currentDirPath()+"/"); |
54 | textView->setText(string, QDir::currentDirPath()+"/"); | 54 | textView->setText(string, QDir::currentDirPath()+"/"); |
55 | printf("%s\n", QDir::currentDirPath().latin1()); | 55 | printf("%s\n", QDir::currentDirPath().latin1()); |
56 | file->close(); | 56 | file->close(); |
57 | 57 | ||
58 | } | 58 | } |
59 | 59 | ||
diff --git a/noncore/tools/opie-sh/inputdialog.cpp b/noncore/tools/opie-sh/inputdialog.cpp index 0780def..1c4e688 100644 --- a/noncore/tools/opie-sh/inputdialog.cpp +++ b/noncore/tools/opie-sh/inputdialog.cpp | |||
@@ -1,117 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | 2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | #include "inputdialog.h" | 16 | #include "inputdialog.h" |
17 | 17 | ||
18 | InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent=0, const char *name=0, bool modal=true, WFlags f=0):QDialog(parent, name, modal, f) | 18 | InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent, const char *name, bool modal, WFlags f):QDialog(parent, name, modal, f) |
19 | { | 19 | { |
20 | type = newtype; | 20 | type = newtype; |
21 | QHBoxLayout *layout = new QHBoxLayout(this); | 21 | QHBoxLayout *layout = new QHBoxLayout(this); |
22 | layout->addStrut(32); | 22 | layout->addStrut(32); |
23 | QLabel *label = new QLabel(labelString, this, "label"); | 23 | QLabel *label = new QLabel(labelString, this, "label"); |
24 | setCaption(title); | 24 | setCaption(title); |
25 | int x, y; | 25 | int x, y; |
26 | 26 | ||
27 | layout->addSpacing(5); | 27 | layout->addSpacing(5); |
28 | layout->addWidget(label); | 28 | layout->addWidget(label); |
29 | layout->addSpacing(5); | 29 | layout->addSpacing(5); |
30 | 30 | ||
31 | switch(type) | 31 | switch(type) |
32 | { | 32 | { |
33 | case 0: | 33 | case 0: |
34 | lineEdit = new QLineEdit(this, "line edit"); | 34 | lineEdit = new QLineEdit(this, "line edit"); |
35 | layout->addWidget(lineEdit); | 35 | layout->addWidget(lineEdit); |
36 | break; | 36 | break; |
37 | case 1: | 37 | case 1: |
38 | comboBox = new QComboBox(edit, this, "combo box"); | 38 | comboBox = new QComboBox(edit, this, "combo box"); |
39 | layout->addWidget(comboBox); | 39 | layout->addWidget(comboBox); |
40 | if(!filename.isNull()) | 40 | if(!filename.isNull()) |
41 | { | 41 | { |
42 | QFile file(filename); | 42 | QFile file(filename); |
43 | file.open(IO_ReadOnly); | 43 | file.open(IO_ReadOnly); |
44 | QTextStream stream(&file); | 44 | QTextStream stream(&file); |
45 | QString string = stream.read(); | 45 | QString string = stream.read(); |
46 | 46 | ||
47 | comboBox->insertStringList(QStringList::split('\n', string)); | 47 | comboBox->insertStringList(QStringList::split('\n', string)); |
48 | } | 48 | } |
49 | else | 49 | else |
50 | { | 50 | { |
51 | QFile file; | 51 | QFile file; |
52 | file.open(IO_ReadOnly, 0); | 52 | file.open(IO_ReadOnly, 0); |
53 | QTextStream stream(&file); | 53 | QTextStream stream(&file); |
54 | QString string = stream.read(); | 54 | QString string = stream.read(); |
55 | 55 | ||
56 | comboBox->insertStringList(QStringList::split('\n', string)); | 56 | comboBox->insertStringList(QStringList::split('\n', string)); |
57 | } | 57 | } |
58 | break; | 58 | break; |
59 | case 2: | 59 | case 2: |
60 | listBox = new QListBox(this, "list box"); | 60 | listBox = new QListBox(this, "list box"); |
61 | listBox->setSelectionMode(QListBox::Multi); | 61 | listBox->setSelectionMode(QListBox::Multi); |
62 | layout->addWidget(listBox); | 62 | layout->addWidget(listBox); |
63 | if(!filename.isNull()) | 63 | if(!filename.isNull()) |
64 | { | 64 | { |
65 | QFile file(filename); | 65 | QFile file(filename); |
66 | file.open(IO_ReadOnly); | 66 | file.open(IO_ReadOnly); |
67 | QTextStream stream(&file); | 67 | QTextStream stream(&file); |
68 | QString string = stream.read(); | 68 | QString string = stream.read(); |
69 | 69 | ||
70 | listBox->insertStringList(QStringList::split('\n', string)); | 70 | listBox->insertStringList(QStringList::split('\n', string)); |
71 | } | 71 | } |
72 | else | 72 | else |
73 | { | 73 | { |
74 | QFile file; | 74 | QFile file; |
75 | file.open(IO_ReadOnly, 0); | 75 | file.open(IO_ReadOnly, 0); |
76 | QTextStream stream(&file); | 76 | QTextStream stream(&file); |
77 | QString string = stream.read(); | 77 | QString string = stream.read(); |
78 | 78 | ||
79 | listBox->insertStringList(QStringList::split('\n', string)); | 79 | listBox->insertStringList(QStringList::split('\n', string)); |
80 | } | 80 | } |
81 | break; | 81 | break; |
82 | } | 82 | } |
83 | layout->addSpacing(5); | 83 | layout->addSpacing(5); |
84 | 84 | ||
85 | x=(w/2)-(width()/2); | 85 | x=(w/2)-(width()/2); |
86 | y=(h/2)-(height()/2); | 86 | y=(h/2)-(height()/2); |
87 | 87 | ||
88 | move(x,y); | 88 | move(x,y); |
89 | } | 89 | } |
90 | 90 | ||
91 | QString InputDialog::getString() | 91 | QString InputDialog::getString() |
92 | { | 92 | { |
93 | switch (type) | 93 | switch (type) |
94 | { | 94 | { |
95 | case 0: | 95 | case 0: |
96 | return ((QLineEdit *)child("line edit"))->text(); | 96 | return ((QLineEdit *)child("line edit"))->text(); |
97 | break; | 97 | break; |
98 | case 1: | 98 | case 1: |
99 | return ((QComboBox *)child("combo box"))->currentText(); | 99 | return ((QComboBox *)child("combo box"))->currentText(); |
100 | break; | 100 | break; |
101 | case 2: | 101 | case 2: |
102 | QString string; | 102 | QString string; |
103 | int i; | 103 | int i; |
104 | for(i = 0; i < listBox->count(); i++) | 104 | for(i = 0; i < listBox->count(); i++) |
105 | { | 105 | { |
106 | if(listBox->isSelected(i)) | 106 | if(listBox->isSelected(i)) |
107 | { | 107 | { |
108 | string+=listBox->text(i)+'\n'; | 108 | string+=listBox->text(i)+'\n'; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | if(string[string.length()-1] == '\n') | 111 | if(string[string.length()-1] == '\n') |
112 | { | 112 | { |
113 | string.truncate(string.length()-1); | 113 | string.truncate(string.length()-1); |
114 | } | 114 | } |
115 | return string; | 115 | return string; |
116 | } | 116 | } |
117 | return QString::null; | ||
117 | } | 118 | } |
diff --git a/noncore/tools/opie-sh/mbox.cpp b/noncore/tools/opie-sh/mbox.cpp index cb3ea1b..04b397d 100644 --- a/noncore/tools/opie-sh/mbox.cpp +++ b/noncore/tools/opie-sh/mbox.cpp | |||
@@ -1,90 +1,90 @@ | |||
1 | /* | 1 | /* |
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | 2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "mbox.h" | 17 | #include "mbox.h" |
18 | 18 | ||
19 | MBox::MBox(int w, int h, int type, QString title, QString message, QString *btext0 = 0, QString *btext1= 0, QString *btext2 = 0, QWidget *parent=0, const char*name=0, bool modal=true, WFlags f=0):QDialog(parent, name, modal, f) | 19 | MBox::MBox(int w, int h, int type, QString title, QString message, QString *btext0, QString *btext1, QString *btext2, QWidget *parent, const char*name, bool modal, WFlags f):QDialog(parent, name, modal, f) |
20 | { | 20 | { |
21 | QVBoxLayout *layout = new QVBoxLayout(this); | 21 | QVBoxLayout *layout = new QVBoxLayout(this); |
22 | 22 | ||
23 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); | 23 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); |
24 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); | 24 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); |
25 | 25 | ||
26 | int x, y; | 26 | int x, y; |
27 | 27 | ||
28 | layout->addLayout(hlayout1); | 28 | layout->addLayout(hlayout1); |
29 | layout->addLayout(hlayout2); | 29 | layout->addLayout(hlayout2); |
30 | 30 | ||
31 | setCaption(title); | 31 | setCaption(title); |
32 | 32 | ||
33 | QLabel *image = new QLabel(this, "image"); | 33 | QLabel *image = new QLabel(this, "image"); |
34 | QLabel *text = new QLabel(message, this, "text"); | 34 | QLabel *text = new QLabel(message, this, "text"); |
35 | 35 | ||
36 | switch (type) | 36 | switch (type) |
37 | { | 37 | { |
38 | case 0: | 38 | case 0: |
39 | image->setPixmap(Resource::loadPixmap("opie-sh/info")); | 39 | image->setPixmap(Resource::loadPixmap("opie-sh/info")); |
40 | break; | 40 | break; |
41 | case 1: | 41 | case 1: |
42 | image->setPixmap(Resource::loadPixmap("opie-sh/warning")); | 42 | image->setPixmap(Resource::loadPixmap("opie-sh/warning")); |
43 | break; | 43 | break; |
44 | case 2: | 44 | case 2: |
45 | image->setPixmap(Resource::loadPixmap("opie-sh/error")); | 45 | image->setPixmap(Resource::loadPixmap("opie-sh/error")); |
46 | break; | 46 | break; |
47 | } | 47 | } |
48 | 48 | ||
49 | hlayout1->addWidget(image); | 49 | hlayout1->addWidget(image); |
50 | hlayout1->addSpacing(5); | 50 | hlayout1->addSpacing(5); |
51 | hlayout1->addWidget(text); | 51 | hlayout1->addWidget(text); |
52 | 52 | ||
53 | if(!btext0->isNull()) | 53 | if(!btext0->isNull()) |
54 | { | 54 | { |
55 | QPushButton *button0 = new QPushButton((const QString)*btext0, this, "button0"); | 55 | QPushButton *button0 = new QPushButton((const QString)*btext0, this, "button0"); |
56 | hlayout2->addSpacing(5); | 56 | hlayout2->addSpacing(5); |
57 | hlayout2->addWidget(button0); | 57 | hlayout2->addWidget(button0); |
58 | hlayout2->addSpacing(5); | 58 | hlayout2->addSpacing(5); |
59 | connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); | 59 | connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); |
60 | } | 60 | } |
61 | else | 61 | else |
62 | { | 62 | { |
63 | QPushButton *button0 = new QPushButton("Ok", this, "button0"); | 63 | QPushButton *button0 = new QPushButton("Ok", this, "button0"); |
64 | hlayout2->addSpacing(5); | 64 | hlayout2->addSpacing(5); |
65 | hlayout2->addWidget(button0); | 65 | hlayout2->addWidget(button0); |
66 | hlayout2->addSpacing(5); | 66 | hlayout2->addSpacing(5); |
67 | connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); | 67 | connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); |
68 | } | 68 | } |
69 | 69 | ||
70 | if(!btext1->isNull()) | 70 | if(!btext1->isNull()) |
71 | { | 71 | { |
72 | QPushButton *button1 = new QPushButton((const QString)*btext1, this, "button1"); | 72 | QPushButton *button1 = new QPushButton((const QString)*btext1, this, "button1"); |
73 | hlayout2->addWidget(button1); | 73 | hlayout2->addWidget(button1); |
74 | hlayout2->addSpacing(5); | 74 | hlayout2->addSpacing(5); |
75 | connect(button1, SIGNAL(clicked()), this, SLOT(b1pressed()) ); | 75 | connect(button1, SIGNAL(clicked()), this, SLOT(b1pressed()) ); |
76 | } | 76 | } |
77 | 77 | ||
78 | if(!btext2->isNull()) | 78 | if(!btext2->isNull()) |
79 | { | 79 | { |
80 | QPushButton *button2 = new QPushButton((const QString)*btext2, this, "button2"); | 80 | QPushButton *button2 = new QPushButton((const QString)*btext2, this, "button2"); |
81 | hlayout2->addWidget(button2); | 81 | hlayout2->addWidget(button2); |
82 | hlayout2->addSpacing(5); | 82 | hlayout2->addSpacing(5); |
83 | connect(button2, SIGNAL(clicked()), this, SLOT(b2pressed()) ); | 83 | connect(button2, SIGNAL(clicked()), this, SLOT(b2pressed()) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | x=(w/2)-(width()/2); | 86 | x=(w/2)-(width()/2); |
87 | y=(h/2)-(height()/2); | 87 | y=(h/2)-(height()/2); |
88 | 88 | ||
89 | move(x, y); | 89 | move(x, y); |
90 | } | 90 | } |
diff --git a/noncore/tools/opie-sh/opie-sh.cpp b/noncore/tools/opie-sh/opie-sh.cpp index e898cb1..96b4b93 100644 --- a/noncore/tools/opie-sh/opie-sh.cpp +++ b/noncore/tools/opie-sh/opie-sh.cpp | |||
@@ -1,277 +1,278 @@ | |||
1 | /* | 1 | /* |
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | 2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <qstring.h> | 17 | #include <qstring.h> |
18 | #include <qstringlist.h> | 18 | #include <qstringlist.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | 22 | ||
23 | #include <stdio.h> | 23 | #include <stdio.h> |
24 | 24 | ||
25 | #include "mbox.h" | 25 | #include "mbox.h" |
26 | #include "fviewer.h" | 26 | #include "fviewer.h" |
27 | #include "inputdialog.h" | 27 | #include "inputdialog.h" |
28 | 28 | ||
29 | int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) | 29 | int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) |
30 | { | 30 | { |
31 | int i, type=0; | 31 | int i, type=0; |
32 | QString button0Text, button1Text, button2Text, string, title; | 32 | QString button0Text, button1Text, button2Text, string, title; |
33 | bool full=true; | 33 | bool full=true; |
34 | 34 | ||
35 | for(i=0; i<argc; i++) | 35 | for(i=0; i<argc; i++) |
36 | { | 36 | { |
37 | if(args[i] == "-t") | 37 | if(args[i] == "-t") |
38 | { | 38 | { |
39 | title = args[i+1]; | 39 | title = args[i+1]; |
40 | } | 40 | } |
41 | 41 | ||
42 | if(args[i] == "-M") | 42 | if(args[i] == "-M") |
43 | { | 43 | { |
44 | string = args[i+1]; | 44 | string = args[i+1]; |
45 | } | 45 | } |
46 | 46 | ||
47 | if(args[i] == "-0") | 47 | if(args[i] == "-0") |
48 | { | 48 | { |
49 | button0Text = args[i+1]; | 49 | button0Text = args[i+1]; |
50 | } | 50 | } |
51 | 51 | ||
52 | if(args[i] == "-1") | 52 | if(args[i] == "-1") |
53 | { | 53 | { |
54 | button1Text = args[i+1]; | 54 | button1Text = args[i+1]; |
55 | } | 55 | } |
56 | 56 | ||
57 | if(args[i] == "-2") | 57 | if(args[i] == "-2") |
58 | { | 58 | { |
59 | button2Text = args[i+1]; | 59 | button2Text = args[i+1]; |
60 | } | 60 | } |
61 | 61 | ||
62 | if(args[i] == "-I") | 62 | if(args[i] == "-I") |
63 | { | 63 | { |
64 | type=0; | 64 | type=0; |
65 | } | 65 | } |
66 | 66 | ||
67 | if(args[i] == "-w") | 67 | if(args[i] == "-w") |
68 | { | 68 | { |
69 | type = 1; | 69 | type = 1; |
70 | } | 70 | } |
71 | 71 | ||
72 | if(args[i] == "-e") | 72 | if(args[i] == "-e") |
73 | { | 73 | { |
74 | type = 2; | 74 | type = 2; |
75 | } | 75 | } |
76 | 76 | ||
77 | if(args[i] == "-g") | 77 | if(args[i] == "-g") |
78 | { | 78 | { |
79 | full = false; | 79 | full = false; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox"); | 83 | MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox"); |
84 | if(full) | 84 | if(full) |
85 | { | 85 | { |
86 | w->setCaption(title); | 86 | w->setCaption(title); |
87 | w->showMaximized(); | 87 | w->showMaximized(); |
88 | } | 88 | } |
89 | //mbox->show(); | 89 | //mbox->show(); |
90 | switch(mbox->exec() ) | 90 | switch(mbox->exec() ) |
91 | { | 91 | { |
92 | case 0: | 92 | case 0: |
93 | return -1; | 93 | return -1; |
94 | case 1: | 94 | case 1: |
95 | return -1; | 95 | return -1; |
96 | case 2: | 96 | case 2: |
97 | return 0; | 97 | return 0; |
98 | case 3: | 98 | case 3: |
99 | return 1; | 99 | return 1; |
100 | case 4: | 100 | case 4: |
101 | return 2; | 101 | return 2; |
102 | default: return -1; | ||
102 | } | 103 | } |
103 | } | 104 | } |
104 | 105 | ||
105 | void printusage() | 106 | void printusage() |
106 | { | 107 | { |
107 | printf("Usage instructions for Opie-sh\n"); | 108 | printf("Usage instructions for Opie-sh\n"); |
108 | printf("Usage: opie-sh [dialog type] [type specific options]\n"); | 109 | printf("Usage: opie-sh [dialog type] [type specific options]\n"); |
109 | printf("Types:\n"); | 110 | printf("Types:\n"); |
110 | printf(" -m Message Box\n"); | 111 | printf(" -m Message Box\n"); |
111 | printf(" -f [filename] View file [Default = stdin]\n"); | 112 | printf(" -f [filename] View file [Default = stdin]\n"); |
112 | printf(" -i Input dialog\n"); | 113 | printf(" -i Input dialog\n"); |
113 | printf(" -h --help These instructions\n"); | 114 | printf(" -h --help These instructions\n"); |
114 | printf(" -t [title] The window/dialog title\n"); | 115 | printf(" -t [title] The window/dialog title\n"); |
115 | printf("Message box options:\n"); | 116 | printf("Message box options:\n"); |
116 | printf(" -M [message] The message to display\n"); | 117 | printf(" -M [message] The message to display\n"); |
117 | printf(" -I Use information icon\n"); | 118 | printf(" -I Use information icon\n"); |
118 | printf(" -w Use the warning icon\n"); | 119 | printf(" -w Use the warning icon\n"); |
119 | printf(" -e Use the error icon\n"); | 120 | printf(" -e Use the error icon\n"); |
120 | printf(" -0 [text] First button text [Default = OK]\n"); | 121 | printf(" -0 [text] First button text [Default = OK]\n"); |
121 | printf(" -1 [text] Second button text\n"); | 122 | printf(" -1 [text] Second button text\n"); |
122 | printf(" -2 [text] Third button text\n"); | 123 | printf(" -2 [text] Third button text\n"); |
123 | printf(" -g Disable fullscreen\n"); | 124 | printf(" -g Disable fullscreen\n"); |
124 | printf("Input Dialog options:\n"); | 125 | printf("Input Dialog options:\n"); |
125 | printf(" -s A single line of input (output to console)\n"); | 126 | printf(" -s A single line of input (output to console)\n"); |
126 | printf(" -l List input (newline separated list read in from file)\n"); | 127 | printf(" -l List input (newline separated list read in from file)\n"); |
127 | printf(" -b A list box, enabling multiple selections (input same as -l)\n"); | 128 | printf(" -b A list box, enabling multiple selections (input same as -l)\n"); |
128 | printf(" -L [label] The label for the input field\n"); | 129 | printf(" -L [label] The label for the input field\n"); |
129 | printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n"); | 130 | printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n"); |
130 | printf(" -E Makes list input editable\n"); | 131 | printf(" -E Makes list input editable\n"); |
131 | printf(" -g Disable fullscreen\n\0"); | 132 | printf(" -g Disable fullscreen\n"); |
132 | } | 133 | } |
133 | 134 | ||
134 | int fileviewer(QPEApplication *a, int argc, QStringList args) | 135 | int fileviewer(QPEApplication *a, int argc, QStringList args) |
135 | { | 136 | { |
136 | int i; | 137 | int i; |
137 | QString filename, title, icon; | 138 | QString filename, title, icon; |
138 | bool update=false; | 139 | bool update=false; |
139 | 140 | ||
140 | for(i=0; i < argc; i++) | 141 | for(i=0; i < argc; i++) |
141 | { | 142 | { |
142 | if(args[i] == "-f") | 143 | if(args[i] == "-f") |
143 | { | 144 | { |
144 | if(args[i+1][0] != '-') | 145 | if(args[i+1][0] != '-') |
145 | { | 146 | { |
146 | filename = args[i+1]; | 147 | filename = args[i+1]; |
147 | } | 148 | } |
148 | } | 149 | } |
149 | 150 | ||
150 | if(args[i] == "-I") | 151 | if(args[i] == "-I") |
151 | { | 152 | { |
152 | icon=args[i+1]; | 153 | icon=args[i+1]; |
153 | } | 154 | } |
154 | 155 | ||
155 | if(args[i] == "-t") | 156 | if(args[i] == "-t") |
156 | { | 157 | { |
157 | title = args[i+1]; | 158 | title = args[i+1]; |
158 | } | 159 | } |
159 | } | 160 | } |
160 | FViewer *fview = new FViewer(icon, filename, title, 0, (QString) "fileviewer"); | 161 | FViewer *fview = new FViewer(icon, filename, title, 0, (QString) "fileviewer"); |
161 | a->setMainWidget(fview); | 162 | a->setMainWidget(fview); |
162 | fview->showMaximized(); | 163 | fview->showMaximized(); |
163 | return a->exec(); | 164 | return a->exec(); |
164 | } | 165 | } |
165 | 166 | ||
166 | int input(int wi, int h, QWidget *w, int argc, QStringList args) | 167 | int input(int wi, int h, QWidget *w, int argc, QStringList args) |
167 | { | 168 | { |
168 | int i, type = 0; | 169 | int i, type = 0; |
169 | QString title, label, filename; | 170 | QString title, label, filename; |
170 | bool edit=false, full=true; | 171 | bool edit=false, full=true; |
171 | 172 | ||
172 | for(i=0; i < argc; i++) | 173 | for(i=0; i < argc; i++) |
173 | { | 174 | { |
174 | if(args[i] == "-s") | 175 | if(args[i] == "-s") |
175 | { | 176 | { |
176 | type = 0; | 177 | type = 0; |
177 | } | 178 | } |
178 | 179 | ||
179 | if(args[i] == "-l") | 180 | if(args[i] == "-l") |
180 | { | 181 | { |
181 | type = 1; | 182 | type = 1; |
182 | } | 183 | } |
183 | 184 | ||
184 | if(args[i] == "-b") | 185 | if(args[i] == "-b") |
185 | { | 186 | { |
186 | type = 2; | 187 | type = 2; |
187 | } | 188 | } |
188 | 189 | ||
189 | if(args[i] == "-t") | 190 | if(args[i] == "-t") |
190 | { | 191 | { |
191 | title = args[i+1]; | 192 | title = args[i+1]; |
192 | } | 193 | } |
193 | 194 | ||
194 | if(args[i] == "-L") | 195 | if(args[i] == "-L") |
195 | { | 196 | { |
196 | label = args[i+1]; | 197 | label = args[i+1]; |
197 | } | 198 | } |
198 | 199 | ||
199 | if(args[i] == "-F") | 200 | if(args[i] == "-F") |
200 | { | 201 | { |
201 | if(args[i+1][0] != '-') | 202 | if(args[i+1][0] != '-') |
202 | { | 203 | { |
203 | filename = args[i+1]; | 204 | filename = args[i+1]; |
204 | } | 205 | } |
205 | } | 206 | } |
206 | 207 | ||
207 | if(args[i] =="-E") | 208 | if(args[i] =="-E") |
208 | { | 209 | { |
209 | edit = true; | 210 | edit = true; |
210 | } | 211 | } |
211 | 212 | ||
212 | if(args[i] == "-g") | 213 | if(args[i] == "-g") |
213 | { | 214 | { |
214 | full = false; | 215 | full = false; |
215 | } | 216 | } |
216 | } | 217 | } |
217 | InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w); | 218 | InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w); |
218 | if(full) | 219 | if(full) |
219 | { | 220 | { |
220 | w->setCaption(title); | 221 | w->setCaption(title); |
221 | w->showMaximized(); | 222 | w->showMaximized(); |
222 | } | 223 | } |
223 | if( id->exec() == 1) | 224 | if( id->exec() == 1) |
224 | { | 225 | { |
225 | printf("%s\n", id->getString().latin1()); | 226 | printf("%s\n", id->getString().latin1()); |
226 | return 0; | 227 | return 0; |
227 | } | 228 | } |
228 | else | 229 | else |
229 | { | 230 | { |
230 | return -1; | 231 | return -1; |
231 | } | 232 | } |
232 | } | 233 | } |
233 | 234 | ||
234 | int main(int argc, char **argv) | 235 | int main(int argc, char **argv) |
235 | { | 236 | { |
236 | int i; | 237 | int i; |
237 | QStringList args; | 238 | QStringList args; |
238 | QPEApplication a(argc, argv); | 239 | QPEApplication a(argc, argv); |
239 | QWidget w; | 240 | QWidget w; |
240 | a.setMainWidget(&w); | 241 | a.setMainWidget(&w); |
241 | QWidget *d = a.desktop(); | 242 | QWidget *d = a.desktop(); |
242 | int width=d->width(); | 243 | int width=d->width(); |
243 | int height=d->height(); | 244 | int height=d->height(); |
244 | 245 | ||
245 | for(i=0; i < argc; i++) | 246 | for(i=0; i < argc; i++) |
246 | { | 247 | { |
247 | args += argv[i]; | 248 | args += argv[i]; |
248 | } | 249 | } |
249 | 250 | ||
250 | for(i=0; i < argc; i++) | 251 | for(i=0; i < argc; i++) |
251 | { | 252 | { |
252 | if(args[i] == "-m") | 253 | if(args[i] == "-m") |
253 | { | 254 | { |
254 | return myMessageBox(width, height, &w, argc, args); | 255 | return myMessageBox(width, height, &w, argc, args); |
255 | } | 256 | } |
256 | 257 | ||
257 | if(args[i] == "-f") | 258 | if(args[i] == "-f") |
258 | { | 259 | { |
259 | return fileviewer(&a, argc, args); | 260 | return fileviewer(&a, argc, args); |
260 | } | 261 | } |
261 | 262 | ||
262 | if(args[i] == "-i") | 263 | if(args[i] == "-i") |
263 | { | 264 | { |
264 | return input(width, height, &w, argc, args); | 265 | return input(width, height, &w, argc, args); |
265 | } | 266 | } |
266 | 267 | ||
267 | if(args[i] == "-h" || args[i] =="--help") | 268 | if(args[i] == "-h" || args[i] =="--help") |
268 | { | 269 | { |
269 | printusage(); | 270 | printusage(); |
270 | return -1; | 271 | return -1; |
271 | } | 272 | } |
272 | } | 273 | } |
273 | 274 | ||
274 | printusage(); | 275 | printusage(); |
275 | return -1; | 276 | return -1; |
276 | } | 277 | } |
277 | 278 | ||
diff --git a/noncore/tools/remote/buttondialog.cpp b/noncore/tools/remote/buttondialog.cpp index 7479e85..6ea4801 100644 --- a/noncore/tools/remote/buttondialog.cpp +++ b/noncore/tools/remote/buttondialog.cpp | |||
@@ -1,293 +1,293 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "buttondialog.h" | 17 | #include "buttondialog.h" |
18 | 18 | ||
19 | ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent=0, const char*name=0, bool modal=FALSE, WFlags f=0):QDialog(parent, name, modal, f) | 19 | ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent, const char*name, bool modal, WFlags f):QDialog(parent, name, modal, f) |
20 | { | 20 | { |
21 | setCaption(tr(buttonName)); | 21 | setCaption(tr(buttonName)); |
22 | 22 | ||
23 | QVBoxLayout *layout = new QVBoxLayout(this); | 23 | QVBoxLayout *layout = new QVBoxLayout(this); |
24 | 24 | ||
25 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); | 25 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); |
26 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); | 26 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); |
27 | QHBoxLayout *hlayout3 = new QHBoxLayout(this); | 27 | QHBoxLayout *hlayout3 = new QHBoxLayout(this); |
28 | 28 | ||
29 | layout->addSpacing(5); | 29 | layout->addSpacing(5); |
30 | layout->addLayout(hlayout1); | 30 | layout->addLayout(hlayout1); |
31 | layout->addSpacing(5); | 31 | layout->addSpacing(5); |
32 | layout->addLayout(hlayout2); | 32 | layout->addLayout(hlayout2); |
33 | layout->addSpacing(5); | 33 | layout->addSpacing(5); |
34 | layout->addLayout(hlayout3); | 34 | layout->addLayout(hlayout3); |
35 | layout->addSpacing(5); | 35 | layout->addSpacing(5); |
36 | 36 | ||
37 | remote = new QComboBox(false, this, "remote"); | 37 | remote = new QComboBox(false, this, "remote"); |
38 | QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel"); | 38 | QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel"); |
39 | hlayout1->addSpacing(5); | 39 | hlayout1->addSpacing(5); |
40 | hlayout1->addWidget(remoteLabel); | 40 | hlayout1->addWidget(remoteLabel); |
41 | hlayout1->addSpacing(5); | 41 | hlayout1->addSpacing(5); |
42 | hlayout1->addWidget(remote); | 42 | hlayout1->addWidget(remote); |
43 | hlayout1->addSpacing(5); | 43 | hlayout1->addSpacing(5); |
44 | remote->insertItem("Remote "); | 44 | remote->insertItem("Remote "); |
45 | remote->insertStringList(getRemotes()); | 45 | remote->insertStringList(getRemotes()); |
46 | connect(remote, SIGNAL(activated(const QString &)), this, SLOT(remoteSelected(const QString&)) ); | 46 | connect(remote, SIGNAL(activated(const QString &)), this, SLOT(remoteSelected(const QString&)) ); |
47 | 47 | ||
48 | button = new QComboBox(false, this, "button"); | 48 | button = new QComboBox(false, this, "button"); |
49 | QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel"); | 49 | QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel"); |
50 | hlayout2->addSpacing(5); | 50 | hlayout2->addSpacing(5); |
51 | hlayout2->addWidget(buttonLabel); | 51 | hlayout2->addWidget(buttonLabel); |
52 | hlayout2->addSpacing(5); | 52 | hlayout2->addSpacing(5); |
53 | hlayout2->addWidget(button); | 53 | hlayout2->addWidget(button); |
54 | hlayout2->addSpacing(5); | 54 | hlayout2->addSpacing(5); |
55 | button->insertItem("Button "); | 55 | button->insertItem("Button "); |
56 | connect(button, SIGNAL(activated(const QString &)), this, SLOT(buttonSelected(const QString&)) ); | 56 | connect(button, SIGNAL(activated(const QString &)), this, SLOT(buttonSelected(const QString&)) ); |
57 | 57 | ||
58 | label = new QLineEdit(this, "label"); | 58 | label = new QLineEdit(this, "label"); |
59 | label->setText(buttonName); | 59 | label->setText(buttonName); |
60 | QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel"); | 60 | QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel"); |
61 | hlayout3->addSpacing(5); | 61 | hlayout3->addSpacing(5); |
62 | hlayout3->addWidget(labelLabel); | 62 | hlayout3->addWidget(labelLabel); |
63 | hlayout3->addSpacing(5); | 63 | hlayout3->addSpacing(5); |
64 | hlayout3->addWidget(label); | 64 | hlayout3->addWidget(label); |
65 | hlayout3->addSpacing(5); | 65 | hlayout3->addSpacing(5); |
66 | } | 66 | } |
67 | 67 | ||
68 | void ButtonDialog::remoteSelected(const QString &string) | 68 | void ButtonDialog::remoteSelected(const QString &string) |
69 | { | 69 | { |
70 | button->insertStringList(getButtons(string.latin1()) ); | 70 | button->insertStringList(getButtons(string.latin1()) ); |
71 | list="SEND_ONCE"; | 71 | list="SEND_ONCE"; |
72 | list+=string; | 72 | list+=string; |
73 | } | 73 | } |
74 | 74 | ||
75 | void ButtonDialog::buttonSelected(const QString &string) | 75 | void ButtonDialog::buttonSelected(const QString &string) |
76 | { | 76 | { |
77 | list+=string; | 77 | list+=string; |
78 | } | 78 | } |
79 | 79 | ||
80 | QStringList ButtonDialog::getList() | 80 | QStringList ButtonDialog::getList() |
81 | { | 81 | { |
82 | return list; | 82 | return list; |
83 | } | 83 | } |
84 | 84 | ||
85 | QString ButtonDialog::getLabel() | 85 | QString ButtonDialog::getLabel() |
86 | { | 86 | { |
87 | return label->text(); | 87 | return label->text(); |
88 | } | 88 | } |
89 | 89 | ||
90 | QStringList ButtonDialog::getRemotes() | 90 | QStringList ButtonDialog::getRemotes() |
91 | { | 91 | { |
92 | const char write_buffer[] = "LIST\n"; | 92 | const char write_buffer[] = "LIST\n"; |
93 | const char *readbuffer; | 93 | const char *readbuffer; |
94 | int i, numlines; | 94 | int i, numlines; |
95 | QStringList list; | 95 | QStringList list; |
96 | 96 | ||
97 | addr.sun_family=AF_UNIX; | 97 | addr.sun_family=AF_UNIX; |
98 | strcpy(addr.sun_path,"/dev/lircd"); | 98 | strcpy(addr.sun_path,"/dev/lircd"); |
99 | 99 | ||
100 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 100 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
101 | if(fd == -1) | 101 | if(fd == -1) |
102 | { | 102 | { |
103 | QMessageBox *mb = new QMessageBox("Error!", | 103 | QMessageBox *mb = new QMessageBox("Error!", |
104 | "couldnt connect to socket", | 104 | "couldnt connect to socket", |
105 | QMessageBox::NoIcon, | 105 | QMessageBox::NoIcon, |
106 | QMessageBox::Ok, | 106 | QMessageBox::Ok, |
107 | QMessageBox::NoButton, | 107 | QMessageBox::NoButton, |
108 | QMessageBox::NoButton); | 108 | QMessageBox::NoButton); |
109 | mb->exec(); | 109 | mb->exec(); |
110 | perror("ButtonDialog::GetRemotes"); | 110 | perror("ButtonDialog::GetRemotes"); |
111 | return NULL; | 111 | return NULL; |
112 | } | 112 | } |
113 | 113 | ||
114 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) | 114 | if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) |
115 | { | 115 | { |
116 | QMessageBox *mb = new QMessageBox("Error!", | 116 | QMessageBox *mb = new QMessageBox("Error!", |
117 | "couldnt connect to socket", | 117 | "couldnt connect to socket", |
118 | QMessageBox::NoIcon, | 118 | QMessageBox::NoIcon, |
119 | QMessageBox::Ok, | 119 | QMessageBox::Ok, |
120 | QMessageBox::NoButton, | 120 | QMessageBox::NoButton, |
121 | QMessageBox::NoButton); | 121 | QMessageBox::NoButton); |
122 | mb->exec(); | 122 | mb->exec(); |
123 | perror("ButtonDialog::GetRemotes"); | 123 | perror("ButtonDialog::GetRemotes"); |
124 | return NULL; | 124 | return NULL; |
125 | } | 125 | } |
126 | 126 | ||
127 | write(fd, write_buffer, strlen(write_buffer)); | 127 | write(fd, write_buffer, strlen(write_buffer)); |
128 | 128 | ||
129 | for(i=0; i<5; i++) | 129 | for(i=0; i<5; i++) |
130 | { | 130 | { |
131 | printf("%d\n", i); | 131 | printf("%d\n", i); |
132 | readbuffer = readPacket(); | 132 | readbuffer = readPacket(); |
133 | printf("%s", readbuffer); | 133 | printf("%s", readbuffer); |
134 | printf("%d\n", i); | 134 | printf("%d\n", i); |
135 | } | 135 | } |
136 | 136 | ||
137 | numlines = atoi(readbuffer); | 137 | numlines = atoi(readbuffer); |
138 | 138 | ||
139 | for(i=0; i<numlines; i++) | 139 | for(i=0; i<numlines; i++) |
140 | { | 140 | { |
141 | list+=readPacket(); | 141 | list+=readPacket(); |
142 | } | 142 | } |
143 | 143 | ||
144 | if(strcasecmp(readPacket(), "END") != 0) | 144 | if(strcasecmp(readPacket(), "END") != 0) |
145 | { | 145 | { |
146 | QMessageBox *mb = new QMessageBox("Error!", | 146 | QMessageBox *mb = new QMessageBox("Error!", |
147 | "bad packet", | 147 | "bad packet", |
148 | QMessageBox::NoIcon, | 148 | QMessageBox::NoIcon, |
149 | QMessageBox::Ok, | 149 | QMessageBox::Ok, |
150 | QMessageBox::NoButton, | 150 | QMessageBox::NoButton, |
151 | QMessageBox::NoButton); | 151 | QMessageBox::NoButton); |
152 | mb->exec(); | 152 | mb->exec(); |
153 | perror("ButtonDialog::GetRemotes"); | 153 | perror("ButtonDialog::GetRemotes"); |
154 | return NULL; | 154 | return NULL; |
155 | } | 155 | } |
156 | 156 | ||
157 | std::close(fd); | 157 | ::close(fd); |
158 | return list; | 158 | return list; |
159 | } | 159 | } |
160 | 160 | ||
161 | QStringList ButtonDialog::getButtons(const char *remoteName) | 161 | QStringList ButtonDialog::getButtons(const char *remoteName) |
162 | { | 162 | { |
163 | QString write_buffer = "LIST "; | 163 | QString write_buffer = "LIST "; |
164 | const char *readbuffer; | 164 | const char *readbuffer; |
165 | int i, j, numlines; | 165 | int i, j, numlines; |
166 | QStringList list; | 166 | QStringList list; |
167 | QString string; | 167 | QString string; |
168 | 168 | ||
169 | write_buffer += remoteName; | 169 | write_buffer += remoteName; |
170 | write_buffer += '\n'; | 170 | write_buffer += '\n'; |
171 | 171 | ||
172 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 172 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
173 | if(fd == -1) | 173 | if(fd == -1) |
174 | { | 174 | { |
175 | QMessageBox *mb = new QMessageBox("Error!", | 175 | QMessageBox *mb = new QMessageBox("Error!", |
176 | "couldnt connect to socket", | 176 | "couldnt connect to socket", |
177 | QMessageBox::NoIcon, | 177 | QMessageBox::NoIcon, |
178 | QMessageBox::Ok, | 178 | QMessageBox::Ok, |
179 | QMessageBox::NoButton, | 179 | QMessageBox::NoButton, |
180 | QMessageBox::NoButton); | 180 | QMessageBox::NoButton); |
181 | mb->exec(); | 181 | mb->exec(); |
182 | perror("ButtonDialog::GetButtons"); | 182 | perror("ButtonDialog::GetButtons"); |
183 | return NULL; | 183 | return NULL; |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) | 187 | if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) |
188 | { | 188 | { |
189 | QMessageBox *mb = new QMessageBox("Error!", | 189 | QMessageBox *mb = new QMessageBox("Error!", |
190 | "couldnt connect to socket", | 190 | "couldnt connect to socket", |
191 | QMessageBox::NoIcon, | 191 | QMessageBox::NoIcon, |
192 | QMessageBox::Ok, | 192 | QMessageBox::Ok, |
193 | QMessageBox::NoButton, | 193 | QMessageBox::NoButton, |
194 | QMessageBox::NoButton); | 194 | QMessageBox::NoButton); |
195 | mb->exec(); | 195 | mb->exec(); |
196 | perror("ButtonDialog::GetButtons"); | 196 | perror("ButtonDialog::GetButtons"); |
197 | return NULL; | 197 | return NULL; |
198 | } | 198 | } |
199 | 199 | ||
200 | write(fd, write_buffer.latin1(), strlen(write_buffer) ); | 200 | write(fd, write_buffer.latin1(), strlen(write_buffer) ); |
201 | 201 | ||
202 | for(i=0; i<5; i++) | 202 | for(i=0; i<5; i++) |
203 | { | 203 | { |
204 | readbuffer = readPacket(); | 204 | readbuffer = readPacket(); |
205 | } | 205 | } |
206 | 206 | ||
207 | numlines = atoi(readbuffer); | 207 | numlines = atoi(readbuffer); |
208 | 208 | ||
209 | for(i=0; i<numlines; i++) | 209 | for(i=0; i<numlines; i++) |
210 | { | 210 | { |
211 | list+=readPacket(); | 211 | list+=readPacket(); |
212 | for(j=0; j<list[i].length(); j++) | 212 | for(j=0; j<list[i].length(); j++) |
213 | { | 213 | { |
214 | if(list[i][j] == ' ') | 214 | if(list[i][j] == ' ') |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | list[i].remove(0, j+1); | 217 | list[i].remove(0, j+1); |
218 | } | 218 | } |
219 | 219 | ||
220 | if(strcasecmp(readPacket(), "END") != 0) | 220 | if(strcasecmp(readPacket(), "END") != 0) |
221 | { | 221 | { |
222 | QMessageBox *mb = new QMessageBox("Error!", | 222 | QMessageBox *mb = new QMessageBox("Error!", |
223 | "bad packet", | 223 | "bad packet", |
224 | QMessageBox::NoIcon, | 224 | QMessageBox::NoIcon, |
225 | QMessageBox::Ok, | 225 | QMessageBox::Ok, |
226 | QMessageBox::NoButton, | 226 | QMessageBox::NoButton, |
227 | QMessageBox::NoButton); | 227 | QMessageBox::NoButton); |
228 | mb->exec(); | 228 | mb->exec(); |
229 | perror("ButtonDialog::GetButtons"); | 229 | perror("ButtonDialog::GetButtons"); |
230 | return NULL; | 230 | return NULL; |
231 | } | 231 | } |
232 | 232 | ||
233 | std::close(fd); | 233 | ::close(fd); |
234 | return list; | 234 | return list; |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | //this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html | 238 | //this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html |
239 | const char *ButtonDialog::readPacket() | 239 | const char *ButtonDialog::readPacket() |
240 | { | 240 | { |
241 | static char buffer[PACKET_SIZE+1]=""; | 241 | static char buffer[PACKET_SIZE+1]=""; |
242 | char *end; | 242 | char *end; |
243 | static int ptr=0,end_len=0; | 243 | static int ptr=0,end_len=0; |
244 | ssize_t ret; | 244 | ssize_t ret; |
245 | timeout = 0; | 245 | timeout = 0; |
246 | 246 | ||
247 | if(ptr>0) | 247 | if(ptr>0) |
248 | { | 248 | { |
249 | memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); | 249 | memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); |
250 | ptr=strlen(buffer); | 250 | ptr=strlen(buffer); |
251 | end=strchr(buffer,'\n'); | 251 | end=strchr(buffer,'\n'); |
252 | } | 252 | } |
253 | else | 253 | else |
254 | { | 254 | { |
255 | end=NULL; | 255 | end=NULL; |
256 | } | 256 | } |
257 | alarm(TIMEOUT); | 257 | alarm(TIMEOUT); |
258 | while(end==NULL) | 258 | while(end==NULL) |
259 | { | 259 | { |
260 | if(PACKET_SIZE<=ptr) | 260 | if(PACKET_SIZE<=ptr) |
261 | { | 261 | { |
262 | fprintf(stderr,"bad packet\n"); | 262 | fprintf(stderr,"bad packet\n"); |
263 | ptr=0; | 263 | ptr=0; |
264 | return(NULL); | 264 | return(NULL); |
265 | } | 265 | } |
266 | ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); | 266 | ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); |
267 | 267 | ||
268 | if(ret<=0 || timeout) | 268 | if(ret<=0 || timeout) |
269 | { | 269 | { |
270 | if(timeout) | 270 | if(timeout) |
271 | { | 271 | { |
272 | fprintf(stderr,"timeout\n"); | 272 | fprintf(stderr,"timeout\n"); |
273 | } | 273 | } |
274 | else | 274 | else |
275 | { | 275 | { |
276 | alarm(0); | 276 | alarm(0); |
277 | } | 277 | } |
278 | ptr=0; | 278 | ptr=0; |
279 | return(NULL); | 279 | return(NULL); |
280 | } | 280 | } |
281 | buffer[ptr+ret]=0; | 281 | buffer[ptr+ret]=0; |
282 | ptr=strlen(buffer); | 282 | ptr=strlen(buffer); |
283 | end=strchr(buffer,'\n'); | 283 | end=strchr(buffer,'\n'); |
284 | } | 284 | } |
285 | alarm(0);timeout=0; | 285 | alarm(0);timeout=0; |
286 | 286 | ||
287 | end[0]=0; | 287 | end[0]=0; |
288 | ptr=strlen(buffer)+1; | 288 | ptr=strlen(buffer)+1; |
289 | //# ifdef DEBUG | 289 | //# ifdef DEBUG |
290 | //printf("buffer: -%s-\n",buffer); | 290 | //printf("buffer: -%s-\n",buffer); |
291 | //# endif | 291 | //# endif |
292 | return(buffer); | 292 | return(buffer); |
293 | } | 293 | } |
diff --git a/noncore/tools/remote/channelgroup.cpp b/noncore/tools/remote/channelgroup.cpp index 9f90284..7c33674 100644 --- a/noncore/tools/remote/channelgroup.cpp +++ b/noncore/tools/remote/channelgroup.cpp | |||
@@ -1,100 +1,100 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "channelgroup.h" | 17 | #include "channelgroup.h" |
18 | 18 | ||
19 | ChannelGroup::ChannelGroup(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | ChannelGroup::ChannelGroup(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | QGridLayout *layout = new QGridLayout(this); | 21 | QGridLayout *layout = new QGridLayout(this); |
22 | QVBoxLayout *volLayout = new QVBoxLayout(this); | 22 | QVBoxLayout *volLayout = new QVBoxLayout(this); |
23 | QVBoxLayout *chanLayout = new QVBoxLayout(this); | 23 | QVBoxLayout *chanLayout = new QVBoxLayout(this); |
24 | 24 | ||
25 | layout->addRowSpacing(1,1); | 25 | layout->addRowSpacing(1,1); |
26 | layout->addRowSpacing(3,1); | 26 | layout->addRowSpacing(3,1); |
27 | layout->addRowSpacing(5,1); | 27 | layout->addRowSpacing(5,1); |
28 | 28 | ||
29 | layout->addColSpacing(1,1); | 29 | layout->addColSpacing(1,1); |
30 | layout->addColSpacing(3,1); | 30 | layout->addColSpacing(3,1); |
31 | layout->addColSpacing(5,1); | 31 | layout->addColSpacing(5,1); |
32 | layout->addColSpacing(7,1); | 32 | layout->addColSpacing(7,1); |
33 | 33 | ||
34 | QPushButton *one = new QPushButton("1", this, "one"); | 34 | QPushButton *one = new QPushButton("1", this, "one"); |
35 | layout->addWidget(one, 0, 2, 0); | 35 | layout->addWidget(one, 0, 2, 0); |
36 | connect(one, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 36 | connect(one, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
37 | 37 | ||
38 | QPushButton *two = new QPushButton("2", this, "two"); | 38 | QPushButton *two = new QPushButton("2", this, "two"); |
39 | layout->addWidget(two, 0, 4, 0); | 39 | layout->addWidget(two, 0, 4, 0); |
40 | connect(two, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 40 | connect(two, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
41 | 41 | ||
42 | QPushButton *three = new QPushButton("3", this, "three"); | 42 | QPushButton *three = new QPushButton("3", this, "three"); |
43 | layout->addWidget(three, 0, 6, 0); | 43 | layout->addWidget(three, 0, 6, 0); |
44 | connect(three, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 44 | connect(three, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
45 | 45 | ||
46 | QPushButton *four = new QPushButton("4", this, "four"); | 46 | QPushButton *four = new QPushButton("4", this, "four"); |
47 | layout->addWidget(four, 2, 2, 0); | 47 | layout->addWidget(four, 2, 2, 0); |
48 | connect(four, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 48 | connect(four, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
49 | 49 | ||
50 | QPushButton *five = new QPushButton("5", this, "five"); | 50 | QPushButton *five = new QPushButton("5", this, "five"); |
51 | layout->addWidget(five, 2, 4, 0); | 51 | layout->addWidget(five, 2, 4, 0); |
52 | connect(five, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 52 | connect(five, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
53 | 53 | ||
54 | QPushButton *six = new QPushButton("6", this, "six"); | 54 | QPushButton *six = new QPushButton("6", this, "six"); |
55 | layout->addWidget(six, 2, 6, 0); | 55 | layout->addWidget(six, 2, 6, 0); |
56 | connect(six, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 56 | connect(six, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
57 | 57 | ||
58 | QPushButton *seven = new QPushButton("7", this, "seven"); | 58 | QPushButton *seven = new QPushButton("7", this, "seven"); |
59 | layout->addWidget(seven, 4, 2, 0); | 59 | layout->addWidget(seven, 4, 2, 0); |
60 | connect(seven, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 60 | connect(seven, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
61 | 61 | ||
62 | QPushButton *eight = new QPushButton("8", this, "eight"); | 62 | QPushButton *eight = new QPushButton("8", this, "eight"); |
63 | layout->addWidget(eight, 4, 4, 0); | 63 | layout->addWidget(eight, 4, 4, 0); |
64 | connect(eight, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 64 | connect(eight, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
65 | 65 | ||
66 | QPushButton *nine = new QPushButton("9", this, "nine"); | 66 | QPushButton *nine = new QPushButton("9", this, "nine"); |
67 | layout->addWidget(nine, 4, 6, 0); | 67 | layout->addWidget(nine, 4, 6, 0); |
68 | connect(nine, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 68 | connect(nine, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
69 | 69 | ||
70 | QPushButton *zero = new QPushButton("0", this, "zero"); | 70 | QPushButton *zero = new QPushButton("0", this, "zero"); |
71 | layout->addWidget(zero, 6, 4, 0); | 71 | layout->addWidget(zero, 6, 4, 0); |
72 | connect(zero, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 72 | connect(zero, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
73 | 73 | ||
74 | layout->addMultiCellLayout(volLayout, 0, 6, 0, 0, 0); | 74 | layout->addMultiCellLayout(volLayout, 0, 6, 0, 0, 0); |
75 | layout->addMultiCellLayout(chanLayout, 0, 6, 8, 8, 0); | 75 | layout->addMultiCellLayout(chanLayout, 0, 6, 8, 8, 0); |
76 | 76 | ||
77 | QPushButton *volUp = new QPushButton("+", this, "volUp"); | 77 | QPushButton *volUp = new QPushButton("+", this, "volUp"); |
78 | volLayout->addWidget(volUp, 1, 0); | 78 | volLayout->addWidget(volUp, 1, 0); |
79 | connect(volUp, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 79 | connect(volUp, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
80 | 80 | ||
81 | QLabel *volLabel = new QLabel("Volume ", this, "volLabel"); | 81 | QLabel *volLabel = new QLabel("Volume ", this, "volLabel"); |
82 | volLayout->addWidget(volLabel, 0, 0); | 82 | volLayout->addWidget(volLabel, 0, 0); |
83 | 83 | ||
84 | QPushButton *volDown = new QPushButton("-", this, "volDown"); | 84 | QPushButton *volDown = new QPushButton("-", this, "volDown"); |
85 | volLayout->addWidget(volDown, 1, 0); | 85 | volLayout->addWidget(volDown, 1, 0); |
86 | connect(volDown, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 86 | connect(volDown, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
87 | 87 | ||
88 | 88 | ||
89 | QPushButton *chanUp = new QPushButton("+", this, "chanUp"); | 89 | QPushButton *chanUp = new QPushButton("+", this, "chanUp"); |
90 | chanLayout->addWidget(chanUp, 1, 0); | 90 | chanLayout->addWidget(chanUp, 1, 0); |
91 | connect(chanUp, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 91 | connect(chanUp, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
92 | 92 | ||
93 | QLabel *chanLabel = new QLabel("Channel", this, "chanLabel"); | 93 | QLabel *chanLabel = new QLabel("Channel", this, "chanLabel"); |
94 | chanLayout->addWidget(chanLabel, 0, 0); | 94 | chanLayout->addWidget(chanLabel, 0, 0); |
95 | 95 | ||
96 | QPushButton *chanDown = new QPushButton("-", this, "chanDown"); | 96 | QPushButton *chanDown = new QPushButton("-", this, "chanDown"); |
97 | chanLayout->addWidget(chanDown, 1, 0); | 97 | chanLayout->addWidget(chanDown, 1, 0); |
98 | connect(chanDown, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 98 | connect(chanDown, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
99 | 99 | ||
100 | } | 100 | } |
diff --git a/noncore/tools/remote/channelgroupconf.cpp b/noncore/tools/remote/channelgroupconf.cpp index 2d98115..e39121e 100644 --- a/noncore/tools/remote/channelgroupconf.cpp +++ b/noncore/tools/remote/channelgroupconf.cpp | |||
@@ -1,100 +1,100 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "channelgroupconf.h" | 17 | #include "channelgroupconf.h" |
18 | 18 | ||
19 | ChannelGroupConf::ChannelGroupConf(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | ChannelGroupConf::ChannelGroupConf(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | QGridLayout *layout = new QGridLayout(this); | 21 | QGridLayout *layout = new QGridLayout(this); |
22 | QVBoxLayout *volLayout = new QVBoxLayout(this); | 22 | QVBoxLayout *volLayout = new QVBoxLayout(this); |
23 | QVBoxLayout *chanLayout = new QVBoxLayout(this); | 23 | QVBoxLayout *chanLayout = new QVBoxLayout(this); |
24 | 24 | ||
25 | layout->addRowSpacing(1,5); | 25 | layout->addRowSpacing(1,5); |
26 | layout->addRowSpacing(3,5); | 26 | layout->addRowSpacing(3,5); |
27 | layout->addRowSpacing(5,5); | 27 | layout->addRowSpacing(5,5); |
28 | 28 | ||
29 | layout->addColSpacing(1,1); | 29 | layout->addColSpacing(1,1); |
30 | layout->addColSpacing(3,1); | 30 | layout->addColSpacing(3,1); |
31 | layout->addColSpacing(5,1); | 31 | layout->addColSpacing(5,1); |
32 | layout->addColSpacing(7,1); | 32 | layout->addColSpacing(7,1); |
33 | 33 | ||
34 | QPushButton *one = new QPushButton("1", this, "one"); | 34 | QPushButton *one = new QPushButton("1", this, "one"); |
35 | layout->addWidget(one, 0, 2, 0); | 35 | layout->addWidget(one, 0, 2, 0); |
36 | connect(one, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 36 | connect(one, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
37 | 37 | ||
38 | QPushButton *two = new QPushButton("2", this, "two"); | 38 | QPushButton *two = new QPushButton("2", this, "two"); |
39 | layout->addWidget(two, 0, 4, 0); | 39 | layout->addWidget(two, 0, 4, 0); |
40 | connect(two, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 40 | connect(two, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
41 | 41 | ||
42 | QPushButton *three = new QPushButton("3", this, "three"); | 42 | QPushButton *three = new QPushButton("3", this, "three"); |
43 | layout->addWidget(three, 0, 6, 0); | 43 | layout->addWidget(three, 0, 6, 0); |
44 | connect(three, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 44 | connect(three, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
45 | 45 | ||
46 | QPushButton *four = new QPushButton("4", this, "four"); | 46 | QPushButton *four = new QPushButton("4", this, "four"); |
47 | layout->addWidget(four, 2, 2, 0); | 47 | layout->addWidget(four, 2, 2, 0); |
48 | connect(four, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 48 | connect(four, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
49 | 49 | ||
50 | QPushButton *five = new QPushButton("5", this, "five"); | 50 | QPushButton *five = new QPushButton("5", this, "five"); |
51 | layout->addWidget(five, 2, 4, 0); | 51 | layout->addWidget(five, 2, 4, 0); |
52 | connect(five, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 52 | connect(five, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
53 | 53 | ||
54 | QPushButton *six = new QPushButton("6", this, "six"); | 54 | QPushButton *six = new QPushButton("6", this, "six"); |
55 | layout->addWidget(six, 2, 6, 0); | 55 | layout->addWidget(six, 2, 6, 0); |
56 | connect(six, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 56 | connect(six, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
57 | 57 | ||
58 | QPushButton *seven = new QPushButton("7", this, "seven"); | 58 | QPushButton *seven = new QPushButton("7", this, "seven"); |
59 | layout->addWidget(seven, 4, 2, 0); | 59 | layout->addWidget(seven, 4, 2, 0); |
60 | connect(seven, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 60 | connect(seven, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
61 | 61 | ||
62 | QPushButton *eight = new QPushButton("8", this, "eight"); | 62 | QPushButton *eight = new QPushButton("8", this, "eight"); |
63 | layout->addWidget(eight, 4, 4, 0); | 63 | layout->addWidget(eight, 4, 4, 0); |
64 | connect(eight, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 64 | connect(eight, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
65 | 65 | ||
66 | QPushButton *nine = new QPushButton("9", this, "nine"); | 66 | QPushButton *nine = new QPushButton("9", this, "nine"); |
67 | layout->addWidget(nine, 4, 6, 0); | 67 | layout->addWidget(nine, 4, 6, 0); |
68 | connect(nine, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 68 | connect(nine, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
69 | 69 | ||
70 | QPushButton *zero = new QPushButton("0", this, "zero"); | 70 | QPushButton *zero = new QPushButton("0", this, "zero"); |
71 | layout->addWidget(zero, 6, 4, 0); | 71 | layout->addWidget(zero, 6, 4, 0); |
72 | connect(zero, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 72 | connect(zero, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
73 | 73 | ||
74 | layout->addMultiCellLayout(volLayout, 0, 6, 0, 0, 0); | 74 | layout->addMultiCellLayout(volLayout, 0, 6, 0, 0, 0); |
75 | layout->addMultiCellLayout(chanLayout, 0, 6, 8, 8, 0); | 75 | layout->addMultiCellLayout(chanLayout, 0, 6, 8, 8, 0); |
76 | 76 | ||
77 | QPushButton *volUp = new QPushButton("+", this, "volUp"); | 77 | QPushButton *volUp = new QPushButton("+", this, "volUp"); |
78 | volLayout->addWidget(volUp, 1, 0); | 78 | volLayout->addWidget(volUp, 1, 0); |
79 | connect(volUp, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 79 | connect(volUp, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
80 | 80 | ||
81 | QLabel *volLabel = new QLabel("Volume ", this, "volLabel"); | 81 | QLabel *volLabel = new QLabel("Volume ", this, "volLabel"); |
82 | volLayout->addWidget(volLabel, 0, 0); | 82 | volLayout->addWidget(volLabel, 0, 0); |
83 | 83 | ||
84 | QPushButton *volDown = new QPushButton("-", this, "volDown"); | 84 | QPushButton *volDown = new QPushButton("-", this, "volDown"); |
85 | volLayout->addWidget(volDown, 1, 0); | 85 | volLayout->addWidget(volDown, 1, 0); |
86 | connect(volDown, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 86 | connect(volDown, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
87 | 87 | ||
88 | 88 | ||
89 | QPushButton *chanUp = new QPushButton("+", this, "chanUp"); | 89 | QPushButton *chanUp = new QPushButton("+", this, "chanUp"); |
90 | chanLayout->addWidget(chanUp, 1, 0); | 90 | chanLayout->addWidget(chanUp, 1, 0); |
91 | connect(chanUp, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 91 | connect(chanUp, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
92 | 92 | ||
93 | QLabel *chanLabel = new QLabel("Channel", this, "chanLabel"); | 93 | QLabel *chanLabel = new QLabel("Channel", this, "chanLabel"); |
94 | chanLayout->addWidget(chanLabel, 0, 0); | 94 | chanLayout->addWidget(chanLabel, 0, 0); |
95 | 95 | ||
96 | QPushButton *chanDown = new QPushButton("-", this, "chanDown"); | 96 | QPushButton *chanDown = new QPushButton("-", this, "chanDown"); |
97 | chanLayout->addWidget(chanDown, 1, 0); | 97 | chanLayout->addWidget(chanDown, 1, 0); |
98 | connect(chanDown, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 98 | connect(chanDown, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
99 | 99 | ||
100 | } | 100 | } |
diff --git a/noncore/tools/remote/configtab.cpp b/noncore/tools/remote/configtab.cpp index f5896a9..17cdc6a 100644 --- a/noncore/tools/remote/configtab.cpp +++ b/noncore/tools/remote/configtab.cpp | |||
@@ -1,218 +1,218 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "configtab.h" | 17 | #include "configtab.h" |
18 | 18 | ||
19 | ConfigTab::ConfigTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | ConfigTab::ConfigTab(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | 21 | ||
22 | QVBoxLayout *layout = new QVBoxLayout(this); | 22 | QVBoxLayout *layout = new QVBoxLayout(this); |
23 | 23 | ||
24 | topGroupConf = new TopGroupConf(this, "topGroupConf"); | 24 | topGroupConf = new TopGroupConf(this, "topGroupConf"); |
25 | layout->addWidget(topGroupConf, 1); | 25 | layout->addWidget(topGroupConf, 1); |
26 | layout->addSpacing(1); | 26 | layout->addSpacing(1); |
27 | 27 | ||
28 | dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf"); | 28 | dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf"); |
29 | layout->addWidget(dvdGroupConf, 1); | 29 | layout->addWidget(dvdGroupConf, 1); |
30 | layout->addSpacing(1); | 30 | layout->addSpacing(1); |
31 | 31 | ||
32 | vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf"); | 32 | vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf"); |
33 | layout->addWidget(vcrGroupConf, 1); | 33 | layout->addWidget(vcrGroupConf, 1); |
34 | layout->addSpacing(1); | 34 | layout->addSpacing(1); |
35 | 35 | ||
36 | channelGroupConf = new ChannelGroupConf(this, "channelGroupConf"); | 36 | channelGroupConf = new ChannelGroupConf(this, "channelGroupConf"); |
37 | layout->addWidget(channelGroupConf, 1); | 37 | layout->addWidget(channelGroupConf, 1); |
38 | 38 | ||
39 | 39 | ||
40 | } | 40 | } |
41 | 41 | ||
42 | void ConfigTab::setConfig(Config *newCfg) | 42 | void ConfigTab::setConfig(Config *newCfg) |
43 | { | 43 | { |
44 | cfg = newCfg; | 44 | cfg = newCfg; |
45 | cfg->setGroup("Remotes"); | 45 | cfg->setGroup("Remotes"); |
46 | topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') ); | 46 | topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') ); |
47 | cfg->setGroup("Default"); | 47 | cfg->setGroup("Default"); |
48 | const QObject *obj; | 48 | const QObject *obj; |
49 | 49 | ||
50 | const QObjectList *objList = topGroupConf->children(); | 50 | const QObjectList *objList = topGroupConf->children(); |
51 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 51 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
52 | { | 52 | { |
53 | if(obj->inherits("QPushButton")) | 53 | if(obj->inherits("QPushButton")) |
54 | { | 54 | { |
55 | if(!cfg->hasKey((QString)obj->name()+"Label")) | 55 | if(!cfg->hasKey((QString)obj->name()+"Label")) |
56 | { | 56 | { |
57 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | 57 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); |
58 | } | 58 | } |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | objList = dvdGroupConf->children(); | 62 | objList = dvdGroupConf->children(); |
63 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 63 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
64 | { | 64 | { |
65 | if(obj->inherits("QPushButton")) | 65 | if(obj->inherits("QPushButton")) |
66 | { | 66 | { |
67 | if(!cfg->hasKey((QString)obj->name()+"Label")) | 67 | if(!cfg->hasKey((QString)obj->name()+"Label")) |
68 | { | 68 | { |
69 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | 69 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | objList = vcrGroupConf->children(); | 74 | objList = vcrGroupConf->children(); |
75 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 75 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
76 | { | 76 | { |
77 | if(obj->inherits("QPushButton")) | 77 | if(obj->inherits("QPushButton")) |
78 | { | 78 | { |
79 | if(!cfg->hasKey((QString)obj->name()+"Label")) | 79 | if(!cfg->hasKey((QString)obj->name()+"Label")) |
80 | { | 80 | { |
81 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | 81 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | objList = channelGroupConf->children(); | 86 | objList = channelGroupConf->children(); |
87 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 87 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
88 | { | 88 | { |
89 | if(obj->inherits("QPushButton")) | 89 | if(obj->inherits("QPushButton")) |
90 | { | 90 | { |
91 | if(!cfg->hasKey((QString)obj->name()+"Label")) | 91 | if(!cfg->hasKey((QString)obj->name()+"Label")) |
92 | { | 92 | { |
93 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | 93 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | cfg->write(); | 97 | cfg->write(); |
98 | 98 | ||
99 | cfg->setGroup("Remotes"); | 99 | cfg->setGroup("Remotes"); |
100 | } | 100 | } |
101 | /* | 101 | /* |
102 | void ConfigTab::savePressed() | 102 | void ConfigTab::savePressed() |
103 | { | 103 | { |
104 | cfg->setGroup(remotes->currentText()); | 104 | cfg->setGroup(remotes->currentText()); |
105 | ButtonDialog *bd = new ButtonDialog(this, "BD", true, 0); | 105 | ButtonDialog *bd = new ButtonDialog(this, "BD", true, 0); |
106 | if( bd->exec() == 1) | 106 | if( bd->exec() == 1) |
107 | { | 107 | { |
108 | printf("%s\n", bd->getList().join(" ").latin1()); | 108 | printf("%s\n", bd->getList().join(" ").latin1()); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | */ | 111 | */ |
112 | 112 | ||
113 | void ConfigTab::newPressed() | 113 | void ConfigTab::newPressed() |
114 | { | 114 | { |
115 | QStringList list; | 115 | QStringList list; |
116 | cfg->setGroup("Remotes"); | 116 | cfg->setGroup("Remotes"); |
117 | list=cfg->readListEntry("remoteList", ','); | 117 | list=cfg->readListEntry("remoteList", ','); |
118 | list+=topGroupConf->getRemotesText(); | 118 | list+=topGroupConf->getRemotesText(); |
119 | cfg->writeEntry("remoteList", list, ','); | 119 | cfg->writeEntry("remoteList", list, ','); |
120 | cfg->setGroup(topGroupConf->getRemotesText()); | 120 | cfg->setGroup(topGroupConf->getRemotesText()); |
121 | topGroupConf->updateRemotes(QStringList(topGroupConf->getRemotesText()) ); | 121 | topGroupConf->updateRemotes(QStringList(topGroupConf->getRemotesText()) ); |
122 | cfg->write(); | 122 | cfg->write(); |
123 | emit remotesChanged(); | 123 | emit remotesChanged(); |
124 | remoteSelected(topGroupConf->getRemotesText()); | 124 | remoteSelected(topGroupConf->getRemotesText()); |
125 | } | 125 | } |
126 | 126 | ||
127 | void ConfigTab::remoteSelected(const QString &string) | 127 | void ConfigTab::remoteSelected(const QString &string) |
128 | { | 128 | { |
129 | cfg->setGroup(string); | 129 | cfg->setGroup(string); |
130 | const QObject *obj; | 130 | const QObject *obj; |
131 | 131 | ||
132 | const QObjectList *objList = topGroupConf->children(); | 132 | const QObjectList *objList = topGroupConf->children(); |
133 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 133 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
134 | { | 134 | { |
135 | if(obj->inherits("QPushButton")) | 135 | if(obj->inherits("QPushButton")) |
136 | { | 136 | { |
137 | if(cfg->hasKey((QString)obj->name()+"Label")) | 137 | if(cfg->hasKey((QString)obj->name()+"Label")) |
138 | { | 138 | { |
139 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 139 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
140 | } | 140 | } |
141 | else | 141 | else |
142 | { | 142 | { |
143 | cfg->setGroup("Default"); | 143 | cfg->setGroup("Default"); |
144 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 144 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
145 | cfg->setGroup(string); | 145 | cfg->setGroup(string); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | objList = dvdGroupConf->children(); | 150 | objList = dvdGroupConf->children(); |
151 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 151 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
152 | { | 152 | { |
153 | if(obj->inherits("QPushButton")) | 153 | if(obj->inherits("QPushButton")) |
154 | { | 154 | { |
155 | if(cfg->hasKey((QString)obj->name()+"Label")) | 155 | if(cfg->hasKey((QString)obj->name()+"Label")) |
156 | { | 156 | { |
157 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 157 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
158 | } | 158 | } |
159 | else | 159 | else |
160 | { | 160 | { |
161 | cfg->setGroup("Default"); | 161 | cfg->setGroup("Default"); |
162 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 162 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
163 | cfg->setGroup(string); | 163 | cfg->setGroup(string); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | objList = vcrGroupConf->children(); | 168 | objList = vcrGroupConf->children(); |
169 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 169 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
170 | { | 170 | { |
171 | if(obj->inherits("QPushButton")) | 171 | if(obj->inherits("QPushButton")) |
172 | { | 172 | { |
173 | if(cfg->hasKey((QString)obj->name()+"Label")) | 173 | if(cfg->hasKey((QString)obj->name()+"Label")) |
174 | { | 174 | { |
175 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 175 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
176 | } | 176 | } |
177 | else | 177 | else |
178 | { | 178 | { |
179 | cfg->setGroup("Default"); | 179 | cfg->setGroup("Default"); |
180 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 180 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
181 | cfg->setGroup(string); | 181 | cfg->setGroup(string); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | objList = channelGroupConf->children(); | 186 | objList = channelGroupConf->children(); |
187 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 187 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
188 | { | 188 | { |
189 | if(obj->inherits("QPushButton")) | 189 | if(obj->inherits("QPushButton")) |
190 | { | 190 | { |
191 | if(cfg->hasKey((QString)obj->name()+"Label")) | 191 | if(cfg->hasKey((QString)obj->name()+"Label")) |
192 | { | 192 | { |
193 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 193 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
194 | } | 194 | } |
195 | else | 195 | else |
196 | { | 196 | { |
197 | cfg->setGroup("Default"); | 197 | cfg->setGroup("Default"); |
198 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 198 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
199 | cfg->setGroup(string); | 199 | cfg->setGroup(string); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void ConfigTab::buttonPressed() | 205 | void ConfigTab::buttonPressed() |
206 | { | 206 | { |
207 | const QObject *button = sender(); | 207 | const QObject *button = sender(); |
208 | QString string = button->name(); | 208 | QString string = button->name(); |
209 | 209 | ||
210 | ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), this, "BD", true, 0); | 210 | ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), this, "BD", true, 0); |
211 | if( bd->exec() == 1) | 211 | if( bd->exec() == 1) |
212 | { | 212 | { |
213 | cfg->writeEntry(string, bd->getList().join(" ").latin1()); | 213 | cfg->writeEntry(string, bd->getList().join(" ").latin1()); |
214 | cfg->writeEntry(string+"Label", bd->getLabel().latin1()); | 214 | cfg->writeEntry(string+"Label", bd->getLabel().latin1()); |
215 | } | 215 | } |
216 | cfg->write(); | 216 | cfg->write(); |
217 | ((QPushButton *)button)->setText(bd->getLabel()); | 217 | ((QPushButton *)button)->setText(bd->getLabel()); |
218 | } | 218 | } |
diff --git a/noncore/tools/remote/dvdgroup.cpp b/noncore/tools/remote/dvdgroup.cpp index a75c48a..d7ff515 100644 --- a/noncore/tools/remote/dvdgroup.cpp +++ b/noncore/tools/remote/dvdgroup.cpp | |||
@@ -1,93 +1,93 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under | 5 | This program is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public | 6 | the terms of the GNU General Public |
7 | License as published by the Free Software Foundation; either version 2 of the | 7 | License as published by the Free Software Foundation; either version 2 of the |
8 | License, or (at your option) any later | 8 | License, or (at your option) any later |
9 | version. | 9 | version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, but WITHOUT ANY | 11 | This program is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the | 12 | WARRANTY; without even the |
13 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 | ||
15 | GNU General | 15 | GNU General |
16 | Public License for more details. | 16 | Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License along with | 18 | You should have received a copy of the GNU General Public License along with |
19 | this program; if not, write to the Free | 19 | this program; if not, write to the Free |
20 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "dvdgroup.h" | 23 | #include "dvdgroup.h" |
24 | 24 | ||
25 | DVDGroup::DVDGroup(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 25 | DVDGroup::DVDGroup(QWidget *parent, const char *name):QWidget(parent,name) |
26 | { | 26 | { |
27 | QGridLayout *layout = new QGridLayout(this); | 27 | QGridLayout *layout = new QGridLayout(this); |
28 | 28 | ||
29 | //put rows between the buttons of size 1 | 29 | //put rows between the buttons of size 1 |
30 | layout->addRowSpacing(1,1); | 30 | layout->addRowSpacing(1,1); |
31 | layout->addRowSpacing(3,1); | 31 | layout->addRowSpacing(3,1); |
32 | 32 | ||
33 | //put collumns between the buttons of size 5 | 33 | //put collumns between the buttons of size 5 |
34 | layout->addColSpacing(1,5); | 34 | layout->addColSpacing(1,5); |
35 | layout->addColSpacing(3,5); | 35 | layout->addColSpacing(3,5); |
36 | layout->addColSpacing(5,5); | 36 | layout->addColSpacing(5,5); |
37 | layout->addColSpacing(7,5); | 37 | layout->addColSpacing(7,5); |
38 | 38 | ||
39 | //make sure that the collumns with the buttons in them stretch before the filler collumns do | 39 | //make sure that the collumns with the buttons in them stretch before the filler collumns do |
40 | //since there is so little room, there is no need to do this for the rows | 40 | //since there is so little room, there is no need to do this for the rows |
41 | layout->setColStretch(4,1); | 41 | layout->setColStretch(4,1); |
42 | layout->setColStretch(2,1); | 42 | layout->setColStretch(2,1); |
43 | layout->setColStretch(6,1); | 43 | layout->setColStretch(6,1); |
44 | layout->setColStretch(8,1); | 44 | layout->setColStretch(8,1); |
45 | layout->setColStretch(0,1); | 45 | layout->setColStretch(0,1); |
46 | 46 | ||
47 | //add the menu navigation buttons, and connect them to the RemoteTab slots... | 47 | //add the menu navigation buttons, and connect them to the RemoteTab slots... |
48 | QPushButton *up = new QPushButton("Up", this,"up"); | 48 | QPushButton *up = new QPushButton("Up", this,"up"); |
49 | layout->addWidget(up, 0, 4, 0); | 49 | layout->addWidget(up, 0, 4, 0); |
50 | connect(up, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 50 | connect(up, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
51 | 51 | ||
52 | QPushButton *down = new QPushButton("Down",this,"down"); | 52 | QPushButton *down = new QPushButton("Down",this,"down"); |
53 | layout->addWidget(down, 4, 4, 0); | 53 | layout->addWidget(down, 4, 4, 0); |
54 | connect(down, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 54 | connect(down, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
55 | 55 | ||
56 | QPushButton *left = new QPushButton("Left",this,"left"); | 56 | QPushButton *left = new QPushButton("Left",this,"left"); |
57 | layout->addWidget(left, 2, 2, 0); | 57 | layout->addWidget(left, 2, 2, 0); |
58 | connect(left, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 58 | connect(left, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
59 | 59 | ||
60 | QPushButton *right = new QPushButton("Right", this, "right"); | 60 | QPushButton *right = new QPushButton("Right", this, "right"); |
61 | layout->addWidget(right, 2, 6, 0); | 61 | layout->addWidget(right, 2, 6, 0); |
62 | connect(right, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 62 | connect(right, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
63 | 63 | ||
64 | QPushButton *enter = new QPushButton("Enter",this,"enter"); | 64 | QPushButton *enter = new QPushButton("Enter",this,"enter"); |
65 | layout->addWidget(enter, 2, 4, 0); | 65 | layout->addWidget(enter, 2, 4, 0); |
66 | connect(enter, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 66 | connect(enter, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
67 | 67 | ||
68 | //add some other buttons | 68 | //add some other buttons |
69 | 69 | ||
70 | QPushButton *eject = new QPushButton("Eject", this, "eject"); | 70 | QPushButton *eject = new QPushButton("Eject", this, "eject"); |
71 | layout->addWidget(eject, 0, 0, 0); | 71 | layout->addWidget(eject, 0, 0, 0); |
72 | connect(eject, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 72 | connect(eject, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
73 | 73 | ||
74 | QPushButton *menu = new QPushButton("Menu", this, "menu"); | 74 | QPushButton *menu = new QPushButton("Menu", this, "menu"); |
75 | layout->addWidget(menu, 2, 0, 0); | 75 | layout->addWidget(menu, 2, 0, 0); |
76 | connect(menu, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 76 | connect(menu, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
77 | 77 | ||
78 | QPushButton *topMenu = new QPushButton("Top", this, "topMenu"); | 78 | QPushButton *topMenu = new QPushButton("Top", this, "topMenu"); |
79 | layout->addWidget(topMenu, 4, 0, 0); | 79 | layout->addWidget(topMenu, 4, 0, 0); |
80 | connect(topMenu, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 80 | connect(topMenu, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
81 | 81 | ||
82 | QPushButton *audio = new QPushButton("Audio", this, "audio"); | 82 | QPushButton *audio = new QPushButton("Audio", this, "audio"); |
83 | layout->addWidget(audio, 0, 8, 0); | 83 | layout->addWidget(audio, 0, 8, 0); |
84 | connect(audio, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 84 | connect(audio, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
85 | 85 | ||
86 | QPushButton *sub = new QPushButton("Sub", this, "sub"); | 86 | QPushButton *sub = new QPushButton("Sub", this, "sub"); |
87 | layout->addWidget(sub, 2, 8, 0); | 87 | layout->addWidget(sub, 2, 8, 0); |
88 | connect(sub, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 88 | connect(sub, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
89 | 89 | ||
90 | QPushButton *angle = new QPushButton("Angle", this, "angle"); | 90 | QPushButton *angle = new QPushButton("Angle", this, "angle"); |
91 | layout->addWidget(angle, 4, 8, 0); | 91 | layout->addWidget(angle, 4, 8, 0); |
92 | connect(angle, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 92 | connect(angle, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
93 | } | 93 | } |
diff --git a/noncore/tools/remote/dvdgroupconf.cpp b/noncore/tools/remote/dvdgroupconf.cpp index 5bfe393..2a08ab6 100644 --- a/noncore/tools/remote/dvdgroupconf.cpp +++ b/noncore/tools/remote/dvdgroupconf.cpp | |||
@@ -1,87 +1,87 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "dvdgroupconf.h" | 17 | #include "dvdgroupconf.h" |
18 | 18 | ||
19 | DVDGroupConf::DVDGroupConf(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | DVDGroupConf::DVDGroupConf(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | QGridLayout *layout = new QGridLayout(this); | 21 | QGridLayout *layout = new QGridLayout(this); |
22 | 22 | ||
23 | //put rows between the buttons of size 1 | 23 | //put rows between the buttons of size 1 |
24 | layout->addRowSpacing(1,1); | 24 | layout->addRowSpacing(1,1); |
25 | layout->addRowSpacing(3,1); | 25 | layout->addRowSpacing(3,1); |
26 | 26 | ||
27 | //put collumns between the buttons of size 5 | 27 | //put collumns between the buttons of size 5 |
28 | layout->addColSpacing(1,5); | 28 | layout->addColSpacing(1,5); |
29 | layout->addColSpacing(3,5); | 29 | layout->addColSpacing(3,5); |
30 | layout->addColSpacing(5,5); | 30 | layout->addColSpacing(5,5); |
31 | layout->addColSpacing(7,5); | 31 | layout->addColSpacing(7,5); |
32 | 32 | ||
33 | //make sure that the collumns with the buttons in them stretch before the filler collumns do | 33 | //make sure that the collumns with the buttons in them stretch before the filler collumns do |
34 | //since there is so little room, there is no need to do this for the rows | 34 | //since there is so little room, there is no need to do this for the rows |
35 | layout->setColStretch(4,1); | 35 | layout->setColStretch(4,1); |
36 | layout->setColStretch(2,1); | 36 | layout->setColStretch(2,1); |
37 | layout->setColStretch(6,1); | 37 | layout->setColStretch(6,1); |
38 | layout->setColStretch(8,1); | 38 | layout->setColStretch(8,1); |
39 | layout->setColStretch(0,1); | 39 | layout->setColStretch(0,1); |
40 | 40 | ||
41 | //add the menu navigation buttons, and connect them to the RemoteTab slots... | 41 | //add the menu navigation buttons, and connect them to the RemoteTab slots... |
42 | QPushButton *up = new QPushButton("Up",this,"up"); | 42 | QPushButton *up = new QPushButton("Up",this,"up"); |
43 | layout->addWidget(up, 0, 4, 0); | 43 | layout->addWidget(up, 0, 4, 0); |
44 | connect(up, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 44 | connect(up, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
45 | 45 | ||
46 | QPushButton *down = new QPushButton("Down",this,"down"); | 46 | QPushButton *down = new QPushButton("Down",this,"down"); |
47 | layout->addWidget(down, 4, 4, 0); | 47 | layout->addWidget(down, 4, 4, 0); |
48 | connect(down, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 48 | connect(down, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
49 | 49 | ||
50 | QPushButton *left = new QPushButton("Left",this,"left"); | 50 | QPushButton *left = new QPushButton("Left",this,"left"); |
51 | layout->addWidget(left, 2, 2, 0); | 51 | layout->addWidget(left, 2, 2, 0); |
52 | connect(left, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 52 | connect(left, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
53 | 53 | ||
54 | QPushButton *right = new QPushButton("Right", this, "right"); | 54 | QPushButton *right = new QPushButton("Right", this, "right"); |
55 | layout->addWidget(right, 2, 6, 0); | 55 | layout->addWidget(right, 2, 6, 0); |
56 | connect(right, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 56 | connect(right, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
57 | 57 | ||
58 | QPushButton *enter = new QPushButton("Enter",this,"enter"); | 58 | QPushButton *enter = new QPushButton("Enter",this,"enter"); |
59 | layout->addWidget(enter, 2, 4, 0); | 59 | layout->addWidget(enter, 2, 4, 0); |
60 | connect(enter, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 60 | connect(enter, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
61 | 61 | ||
62 | //add some other buttons | 62 | //add some other buttons |
63 | 63 | ||
64 | QPushButton *eject = new QPushButton("Eject", this, "eject"); | 64 | QPushButton *eject = new QPushButton("Eject", this, "eject"); |
65 | layout->addWidget(eject, 0, 0, 0); | 65 | layout->addWidget(eject, 0, 0, 0); |
66 | connect(eject, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 66 | connect(eject, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
67 | 67 | ||
68 | QPushButton *menu = new QPushButton("Menu", this, "menu"); | 68 | QPushButton *menu = new QPushButton("Menu", this, "menu"); |
69 | layout->addWidget(menu, 2, 0, 0); | 69 | layout->addWidget(menu, 2, 0, 0); |
70 | connect(menu, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 70 | connect(menu, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
71 | 71 | ||
72 | QPushButton *topMenu = new QPushButton("Top", this, "topMenu"); | 72 | QPushButton *topMenu = new QPushButton("Top", this, "topMenu"); |
73 | layout->addWidget(topMenu, 4, 0, 0); | 73 | layout->addWidget(topMenu, 4, 0, 0); |
74 | connect(topMenu, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 74 | connect(topMenu, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
75 | 75 | ||
76 | QPushButton *audio = new QPushButton("Audio", this, "audio"); | 76 | QPushButton *audio = new QPushButton("Audio", this, "audio"); |
77 | layout->addWidget(audio, 0, 8, 0); | 77 | layout->addWidget(audio, 0, 8, 0); |
78 | connect(audio, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 78 | connect(audio, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
79 | 79 | ||
80 | QPushButton *sub = new QPushButton("Sub", this, "sub"); | 80 | QPushButton *sub = new QPushButton("Sub", this, "sub"); |
81 | layout->addWidget(sub, 2, 8, 0); | 81 | layout->addWidget(sub, 2, 8, 0); |
82 | connect(sub, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 82 | connect(sub, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
83 | 83 | ||
84 | QPushButton *angle = new QPushButton("Angle", this, "angle"); | 84 | QPushButton *angle = new QPushButton("Angle", this, "angle"); |
85 | layout->addWidget(angle, 4, 8, 0); | 85 | layout->addWidget(angle, 4, 8, 0); |
86 | connect(angle, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 86 | connect(angle, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
87 | } | 87 | } |
diff --git a/noncore/tools/remote/learntab.cpp b/noncore/tools/remote/learntab.cpp index 054bc7b..998f449 100644 --- a/noncore/tools/remote/learntab.cpp +++ b/noncore/tools/remote/learntab.cpp | |||
@@ -1,26 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "learntab.h" | 17 | #include "learntab.h" |
18 | 18 | ||
19 | LearnTab::LearnTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | LearnTab::LearnTab(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | QVBoxLayout *layout = new QVBoxLayout(this); | 21 | QVBoxLayout *layout = new QVBoxLayout(this); |
22 | QString *string = new QString("<qt><h1>Opie-Remote Usage Instructions</h1><p>First, some definitions. A Remote is a remote entry in an lircd.conf file, it represents one remote you want to emulate. A Remote Layout is one entry in your ~/Settings/Remote.conf file. It represents the buttons that you see on your screen. Each button on a Remote Layout can be mapped to any button in a Remote. This way you can have, for example, a vcr remote layout, in which all the play/pause/etc buttons are mapped to the buttons on your vcr's remote. However, most VCR's don't have volume controls, so the volume buttons can be mapped to the volume buttons on your TV.</p><p>The first things you need the lirc and lirc-modules ipkgs. If you installed this from an ipkg, they should already be there, thanks to the wonderful world of dependencies. If not, get them. The next thing you need is an lircd.conf file. you can get these at <a href=http://www.lirc.org/>http://www.lirc.org/</a>. Read the documentation there to figure out how to make your own, if one for your remote doesn't exist, or how to have multiple remotes in one lircd.conf file. Once you have a good lircd.conf file, put it in /etc, kill the lircd daemon (if its running) and do a modprobe lirc_sir. Then, run lircd again.</p><p>The next thing you want to do is to create a remote layout. Go to the config tab, and enter a name for your remote layout in the pulldown menu. Dont use the name Remotes, as that could confuse the app. Hopefully, that will be fixed soon. after entering the name you want to use, press New, and then select the name again from the pulldown menu (another oddity that i hope to fix). Then, press each button that you want to map, and a dialog should appear. Select the remote and button that you want to use, and click OK. Once you are done, go to the Remote tab, and select the new remote from the dropdown menu. It should works fine. If at any time you want to change a remote layout, go to the Config tab, select the layout from the dropdown menu, and change the buttons you want to change.</p><p>This is program is written and maintaned by Thomas (spiralman) Stephens. <a href=mailto:spiralman@softhome.net>spiralman@softhome.net</a>. Or, look for me on #opie or #handhelds.org on irc.openprojects.net.</p></qt>"); | 22 | QString *string = new QString("<qt><h1>Opie-Remote Usage Instructions</h1><p>First, some definitions. A Remote is a remote entry in an lircd.conf file, it represents one remote you want to emulate. A Remote Layout is one entry in your ~/Settings/Remote.conf file. It represents the buttons that you see on your screen. Each button on a Remote Layout can be mapped to any button in a Remote. This way you can have, for example, a vcr remote layout, in which all the play/pause/etc buttons are mapped to the buttons on your vcr's remote. However, most VCR's don't have volume controls, so the volume buttons can be mapped to the volume buttons on your TV.</p><p>The first things you need the lirc and lirc-modules ipkgs. If you installed this from an ipkg, they should already be there, thanks to the wonderful world of dependencies. If not, get them. The next thing you need is an lircd.conf file. you can get these at <a href=http://www.lirc.org/>http://www.lirc.org/</a>. Read the documentation there to figure out how to make your own, if one for your remote doesn't exist, or how to have multiple remotes in one lircd.conf file. Once you have a good lircd.conf file, put it in /etc, kill the lircd daemon (if its running) and do a modprobe lirc_sir. Then, run lircd again.</p><p>The next thing you want to do is to create a remote layout. Go to the config tab, and enter a name for your remote layout in the pulldown menu. Dont use the name Remotes, as that could confuse the app. Hopefully, that will be fixed soon. after entering the name you want to use, press New, and then select the name again from the pulldown menu (another oddity that i hope to fix). Then, press each button that you want to map, and a dialog should appear. Select the remote and button that you want to use, and click OK. Once you are done, go to the Remote tab, and select the new remote from the dropdown menu. It should works fine. If at any time you want to change a remote layout, go to the Config tab, select the layout from the dropdown menu, and change the buttons you want to change.</p><p>This is program is written and maintaned by Thomas (spiralman) Stephens. <a href=mailto:spiralman@softhome.net>spiralman@softhome.net</a>. Or, look for me on #opie or #handhelds.org on irc.openprojects.net.</p></qt>"); |
23 | 23 | ||
24 | QTextView *textView = new QTextView(*string, 0, this); | 24 | QTextView *textView = new QTextView(*string, 0, this); |
25 | layout->addWidget(textView); | 25 | layout->addWidget(textView); |
26 | } | 26 | } |
diff --git a/noncore/tools/remote/mainview.cpp b/noncore/tools/remote/mainview.cpp index 47027fb..a7be9e3 100644 --- a/noncore/tools/remote/mainview.cpp +++ b/noncore/tools/remote/mainview.cpp | |||
@@ -1,68 +1,68 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "mainview.h" | 17 | #include "mainview.h" |
18 | 18 | ||
19 | MainView::MainView(QWidget *parent, const char *name=0) : QWidget(parent, name) | 19 | MainView::MainView(QWidget *parent, const char *name) : QWidget(parent, name) |
20 | { | 20 | { |
21 | setIcon( Resource::loadPixmap( "remote" ) ); | 21 | setIcon( Resource::loadPixmap( "remote" ) ); |
22 | setCaption(tr("Remote") ); | 22 | setCaption(tr("Remote") ); |
23 | 23 | ||
24 | QVBoxLayout *layout = new QVBoxLayout(this); | 24 | QVBoxLayout *layout = new QVBoxLayout(this); |
25 | QTabWidget *tabs = new QTabWidget(this); | 25 | QTabWidget *tabs = new QTabWidget(this); |
26 | 26 | ||
27 | layout->addWidget(tabs); | 27 | layout->addWidget(tabs); |
28 | 28 | ||
29 | printf("MainView: 1\n"); | 29 | printf("MainView: 1\n"); |
30 | remote = new RemoteTab(tabs); | 30 | remote = new RemoteTab(tabs); |
31 | printf("MainView: 2\n"); | 31 | printf("MainView: 2\n"); |
32 | learn = new LearnTab(tabs); | 32 | learn = new LearnTab(tabs); |
33 | printf("MainView: 3\n"); | 33 | printf("MainView: 3\n"); |
34 | config = new ConfigTab(tabs); | 34 | config = new ConfigTab(tabs); |
35 | printf("MainView: 4\n"); | 35 | printf("MainView: 4\n"); |
36 | connect(config, SIGNAL(remotesChanged()), this, SLOT(updateRemotesList()) ); | 36 | connect(config, SIGNAL(remotesChanged()), this, SLOT(updateRemotesList()) ); |
37 | printf("MainView: 5\n"); | 37 | printf("MainView: 5\n"); |
38 | 38 | ||
39 | remote->setIRSocket(fd); | 39 | remote->setIRSocket(fd); |
40 | 40 | ||
41 | tabs->addTab(remote, tr("Remote") ); | 41 | tabs->addTab(remote, tr("Remote") ); |
42 | tabs->addTab(learn,tr("Learn") ); | 42 | tabs->addTab(learn,tr("Learn") ); |
43 | tabs->addTab(config,tr("Config") ); | 43 | tabs->addTab(config,tr("Config") ); |
44 | 44 | ||
45 | printf("1\n"); | 45 | printf("1\n"); |
46 | cfg = new Config("Remote"); | 46 | cfg = new Config("Remote"); |
47 | printf("2\n"); | 47 | printf("2\n"); |
48 | 48 | ||
49 | remote->setConfig(cfg); | 49 | remote->setConfig(cfg); |
50 | config->setConfig(cfg); | 50 | config->setConfig(cfg); |
51 | } | 51 | } |
52 | 52 | ||
53 | int MainView::getIRSocket() | 53 | int MainView::getIRSocket() |
54 | { | 54 | { |
55 | return fd; | 55 | return fd; |
56 | } | 56 | } |
57 | 57 | ||
58 | void MainView::setIRSocket(int newfd) | 58 | void MainView::setIRSocket(int newfd) |
59 | { | 59 | { |
60 | fd = newfd; | 60 | fd = newfd; |
61 | remote->setIRSocket(fd); | 61 | remote->setIRSocket(fd); |
62 | } | 62 | } |
63 | 63 | ||
64 | void MainView::updateRemotesList() | 64 | void MainView::updateRemotesList() |
65 | { | 65 | { |
66 | remote->updateRemotesList(); | 66 | remote->updateRemotesList(); |
67 | printf("MainView: got remotes changed signal\n"); | 67 | printf("MainView: got remotes changed signal\n"); |
68 | } | 68 | } |
diff --git a/noncore/tools/remote/remotetab.cpp b/noncore/tools/remote/remotetab.cpp index 64b8ee4..5b02e94 100644 --- a/noncore/tools/remote/remotetab.cpp +++ b/noncore/tools/remote/remotetab.cpp | |||
@@ -1,263 +1,263 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "remotetab.h" | 17 | #include "remotetab.h" |
18 | 18 | ||
19 | RemoteTab::RemoteTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | RemoteTab::RemoteTab(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | QVBoxLayout *layout = new QVBoxLayout(this); | 21 | QVBoxLayout *layout = new QVBoxLayout(this); |
22 | 22 | ||
23 | topGroup = new TopGroup(this); | 23 | topGroup = new TopGroup(this); |
24 | //topGroup->setMaximumHeight(22); | 24 | //topGroup->setMaximumHeight(22); |
25 | layout->addWidget(topGroup, 0, 0); | 25 | layout->addWidget(topGroup, 0, 0); |
26 | printf("%d %d", topGroup->width(), topGroup->height()); | 26 | printf("%d %d", topGroup->width(), topGroup->height()); |
27 | 27 | ||
28 | layout->addSpacing(1); | 28 | layout->addSpacing(1); |
29 | 29 | ||
30 | dvdGroup = new DVDGroup(this); | 30 | dvdGroup = new DVDGroup(this); |
31 | //dvdGroup->setMaximumHeight(68); | 31 | //dvdGroup->setMaximumHeight(68); |
32 | layout->addWidget(dvdGroup, 0, 0); | 32 | layout->addWidget(dvdGroup, 0, 0); |
33 | 33 | ||
34 | layout->addSpacing(1); | 34 | layout->addSpacing(1); |
35 | 35 | ||
36 | vcrGroup = new VCRGroup(this); | 36 | vcrGroup = new VCRGroup(this); |
37 | layout->addWidget(vcrGroup, 0, 0); | 37 | layout->addWidget(vcrGroup, 0, 0); |
38 | //vcrGroup->setMaximumHeight(45); | 38 | //vcrGroup->setMaximumHeight(45); |
39 | 39 | ||
40 | layout->addSpacing(1); | 40 | layout->addSpacing(1); |
41 | 41 | ||
42 | channelGroup = new ChannelGroup(this); | 42 | channelGroup = new ChannelGroup(this); |
43 | //channelGroup->setMaximumHeight(91); | 43 | //channelGroup->setMaximumHeight(91); |
44 | layout->addWidget(channelGroup, 0, 0); | 44 | layout->addWidget(channelGroup, 0, 0); |
45 | 45 | ||
46 | this->setMaximumWidth(240); | 46 | this->setMaximumWidth(240); |
47 | 47 | ||
48 | timeout = 0; | 48 | timeout = 0; |
49 | 49 | ||
50 | addr.sun_family=AF_UNIX; | 50 | addr.sun_family=AF_UNIX; |
51 | strcpy(addr.sun_path,"/dev/lircd"); | 51 | strcpy(addr.sun_path,"/dev/lircd"); |
52 | } | 52 | } |
53 | 53 | ||
54 | int RemoteTab::sendIR() | 54 | int RemoteTab::sendIR() |
55 | { | 55 | { |
56 | const QObject *button = sender(); | 56 | const QObject *button = sender(); |
57 | QString string = cfg->readEntry(button->name()); | 57 | QString string = cfg->readEntry(button->name()); |
58 | string+='\n'; | 58 | string+='\n'; |
59 | const char *write_buffer = string.latin1(); | 59 | const char *write_buffer = string.latin1(); |
60 | const char *read_buffer; | 60 | const char *read_buffer; |
61 | bool done=false; | 61 | bool done=false; |
62 | 62 | ||
63 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 63 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
64 | if(fd == -1) | 64 | if(fd == -1) |
65 | { | 65 | { |
66 | QMessageBox *mb = new QMessageBox("Error!", | 66 | QMessageBox *mb = new QMessageBox("Error!", |
67 | "couldnt connect to socket", | 67 | "couldnt connect to socket", |
68 | QMessageBox::NoIcon, | 68 | QMessageBox::NoIcon, |
69 | QMessageBox::Ok, | 69 | QMessageBox::Ok, |
70 | QMessageBox::NoButton, | 70 | QMessageBox::NoButton, |
71 | QMessageBox::NoButton); | 71 | QMessageBox::NoButton); |
72 | mb->exec(); | 72 | mb->exec(); |
73 | perror("RemoteTab::SendIR"); | 73 | perror("RemoteTab::SendIR"); |
74 | return NULL; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) | 78 | if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) |
79 | { | 79 | { |
80 | QMessageBox *mb = new QMessageBox("Error!", | 80 | QMessageBox *mb = new QMessageBox("Error!", |
81 | "couldnt connect to socket", | 81 | "couldnt connect to socket", |
82 | QMessageBox::NoIcon, | 82 | QMessageBox::NoIcon, |
83 | QMessageBox::Ok, | 83 | QMessageBox::Ok, |
84 | QMessageBox::NoButton, | 84 | QMessageBox::NoButton, |
85 | QMessageBox::NoButton); | 85 | QMessageBox::NoButton); |
86 | mb->exec(); | 86 | mb->exec(); |
87 | perror("RemoteTab::SendIR"); | 87 | perror("RemoteTab::SendIR"); |
88 | } | 88 | } |
89 | 89 | ||
90 | printf("fd2: %d\n", fd); | 90 | printf("fd2: %d\n", fd); |
91 | printf("%s", write_buffer); | 91 | printf("%s", write_buffer); |
92 | 92 | ||
93 | printf("1\n"); | 93 | printf("1\n"); |
94 | printf("%d\n", write(fd, write_buffer, strlen(write_buffer) ) ); | 94 | printf("%d\n", write(fd, write_buffer, strlen(write_buffer) ) ); |
95 | printf("2\n"); | 95 | printf("2\n"); |
96 | while(!done) | 96 | while(!done) |
97 | { | 97 | { |
98 | read_buffer=readPacket(); | 98 | read_buffer=readPacket(); |
99 | printf("%s\n", read_buffer); | 99 | printf("%s\n", read_buffer); |
100 | if(strcasecmp(read_buffer, "END") == 0) | 100 | if(strcasecmp(read_buffer, "END") == 0) |
101 | { | 101 | { |
102 | printf("done reading packet\n"); | 102 | printf("done reading packet\n"); |
103 | done=true; | 103 | done=true; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | std::close(fd); | 106 | ::close(fd); |
107 | } | 107 | } |
108 | 108 | ||
109 | // printf("%s\n", readPacket()); | 109 | // printf("%s\n", readPacket()); |
110 | // printf("%d\n", read(fd, read_buffer,sizeof(read_buffer)) ); | 110 | // printf("%d\n", read(fd, read_buffer,sizeof(read_buffer)) ); |
111 | // printf("%s", read_buffer); | 111 | // printf("%s", read_buffer); |
112 | 112 | ||
113 | //this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html | 113 | //this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html |
114 | const char *RemoteTab::readPacket() | 114 | const char *RemoteTab::readPacket() |
115 | { | 115 | { |
116 | static char buffer[PACKET_SIZE+1]=""; | 116 | static char buffer[PACKET_SIZE+1]=""; |
117 | char *end; | 117 | char *end; |
118 | static int ptr=0,end_len=0; | 118 | static int ptr=0,end_len=0; |
119 | ssize_t ret; | 119 | ssize_t ret; |
120 | 120 | ||
121 | if(ptr>0) | 121 | if(ptr>0) |
122 | { | 122 | { |
123 | memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); | 123 | memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); |
124 | ptr=strlen(buffer); | 124 | ptr=strlen(buffer); |
125 | end=strchr(buffer,'\n'); | 125 | end=strchr(buffer,'\n'); |
126 | } | 126 | } |
127 | else | 127 | else |
128 | { | 128 | { |
129 | end=NULL; | 129 | end=NULL; |
130 | } | 130 | } |
131 | alarm(TIMEOUT); | 131 | alarm(TIMEOUT); |
132 | while(end==NULL) | 132 | while(end==NULL) |
133 | { | 133 | { |
134 | if(PACKET_SIZE<=ptr) | 134 | if(PACKET_SIZE<=ptr) |
135 | { | 135 | { |
136 | // fprintf(stderr,"%s: bad packet\n",progname); | 136 | // fprintf(stderr,"%s: bad packet\n",progname); |
137 | ptr=0; | 137 | ptr=0; |
138 | return(NULL); | 138 | return(NULL); |
139 | } | 139 | } |
140 | ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); | 140 | ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); |
141 | 141 | ||
142 | if(ret<=0 || timeout) | 142 | if(ret<=0 || timeout) |
143 | { | 143 | { |
144 | if(timeout) | 144 | if(timeout) |
145 | { | 145 | { |
146 | // fprintf(stderr,"%s: timeout\n",progname); | 146 | // fprintf(stderr,"%s: timeout\n",progname); |
147 | } | 147 | } |
148 | else | 148 | else |
149 | { | 149 | { |
150 | alarm(0); | 150 | alarm(0); |
151 | } | 151 | } |
152 | ptr=0; | 152 | ptr=0; |
153 | return(NULL); | 153 | return(NULL); |
154 | } | 154 | } |
155 | buffer[ptr+ret]=0; | 155 | buffer[ptr+ret]=0; |
156 | ptr=strlen(buffer); | 156 | ptr=strlen(buffer); |
157 | end=strchr(buffer,'\n'); | 157 | end=strchr(buffer,'\n'); |
158 | } | 158 | } |
159 | alarm(0);timeout=0; | 159 | alarm(0);timeout=0; |
160 | 160 | ||
161 | end[0]=0; | 161 | end[0]=0; |
162 | ptr=strlen(buffer)+1; | 162 | ptr=strlen(buffer)+1; |
163 | //# ifdef DEBUG | 163 | //# ifdef DEBUG |
164 | //printf("buffer: -%s-\n",buffer); | 164 | //printf("buffer: -%s-\n",buffer); |
165 | //# endif | 165 | //# endif |
166 | return(buffer); | 166 | return(buffer); |
167 | } | 167 | } |
168 | 168 | ||
169 | void RemoteTab::setIRSocket(int newfd) | 169 | void RemoteTab::setIRSocket(int newfd) |
170 | { | 170 | { |
171 | fd = newfd; | 171 | fd = newfd; |
172 | } | 172 | } |
173 | 173 | ||
174 | void RemoteTab::setConfig(Config *newCfg) | 174 | void RemoteTab::setConfig(Config *newCfg) |
175 | { | 175 | { |
176 | cfg = newCfg; | 176 | cfg = newCfg; |
177 | cfg->setGroup("Remotes"); | 177 | cfg->setGroup("Remotes"); |
178 | topGroup->updateRemotes(cfg); | 178 | topGroup->updateRemotes(cfg); |
179 | } | 179 | } |
180 | 180 | ||
181 | void RemoteTab::remoteSelected(const QString &string) | 181 | void RemoteTab::remoteSelected(const QString &string) |
182 | { | 182 | { |
183 | printf("1%s\n", string.latin1() ); | 183 | printf("1%s\n", string.latin1() ); |
184 | cfg->setGroup(string); | 184 | cfg->setGroup(string); |
185 | const QObject *obj; | 185 | const QObject *obj; |
186 | 186 | ||
187 | const QObjectList *objList = topGroup->children(); | 187 | const QObjectList *objList = topGroup->children(); |
188 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 188 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
189 | { | 189 | { |
190 | if(obj->inherits("QPushButton")) | 190 | if(obj->inherits("QPushButton")) |
191 | { | 191 | { |
192 | if(cfg->hasKey((QString)obj->name()+"Label")) | 192 | if(cfg->hasKey((QString)obj->name()+"Label")) |
193 | { | 193 | { |
194 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 194 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | { | 197 | { |
198 | cfg->setGroup("Default"); | 198 | cfg->setGroup("Default"); |
199 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 199 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
200 | cfg->setGroup(string); | 200 | cfg->setGroup(string); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | objList = dvdGroup->children(); | 205 | objList = dvdGroup->children(); |
206 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 206 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
207 | { | 207 | { |
208 | if(obj->inherits("QPushButton")) | 208 | if(obj->inherits("QPushButton")) |
209 | { | 209 | { |
210 | if(cfg->hasKey((QString)obj->name()+"Label")) | 210 | if(cfg->hasKey((QString)obj->name()+"Label")) |
211 | { | 211 | { |
212 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 212 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
213 | } | 213 | } |
214 | else | 214 | else |
215 | { | 215 | { |
216 | cfg->setGroup("Default"); | 216 | cfg->setGroup("Default"); |
217 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 217 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
218 | cfg->setGroup(string); | 218 | cfg->setGroup(string); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | objList = vcrGroup->children(); | 223 | objList = vcrGroup->children(); |
224 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 224 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
225 | { | 225 | { |
226 | if(obj->inherits("QPushButton")) | 226 | if(obj->inherits("QPushButton")) |
227 | { | 227 | { |
228 | if(cfg->hasKey((QString)obj->name()+"Label")) | 228 | if(cfg->hasKey((QString)obj->name()+"Label")) |
229 | { | 229 | { |
230 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 230 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
231 | } | 231 | } |
232 | else | 232 | else |
233 | { | 233 | { |
234 | cfg->setGroup("Default"); | 234 | cfg->setGroup("Default"); |
235 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 235 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
236 | cfg->setGroup(string); | 236 | cfg->setGroup(string); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | objList = channelGroup->children(); | 241 | objList = channelGroup->children(); |
242 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 242 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
243 | { | 243 | { |
244 | if(obj->inherits("QPushButton")) | 244 | if(obj->inherits("QPushButton")) |
245 | { | 245 | { |
246 | if(cfg->hasKey((QString)obj->name()+"Label")) | 246 | if(cfg->hasKey((QString)obj->name()+"Label")) |
247 | { | 247 | { |
248 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 248 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
249 | } | 249 | } |
250 | else | 250 | else |
251 | { | 251 | { |
252 | cfg->setGroup("Default"); | 252 | cfg->setGroup("Default"); |
253 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 253 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
254 | cfg->setGroup(string); | 254 | cfg->setGroup(string); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void RemoteTab::updateRemotesList() | 260 | void RemoteTab::updateRemotesList() |
261 | { | 261 | { |
262 | topGroup->updateRemotes(cfg); | 262 | topGroup->updateRemotes(cfg); |
263 | } | 263 | } |
diff --git a/noncore/tools/remote/topgroup.cpp b/noncore/tools/remote/topgroup.cpp index 94ea622..93cffbb 100644 --- a/noncore/tools/remote/topgroup.cpp +++ b/noncore/tools/remote/topgroup.cpp | |||
@@ -1,54 +1,54 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "topgroup.h" | 17 | #include "topgroup.h" |
18 | 18 | ||
19 | TopGroup::TopGroup(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | TopGroup::TopGroup(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | QHBoxLayout *layout = new QHBoxLayout(this, 0, -1, 0); | 21 | QHBoxLayout *layout = new QHBoxLayout(this, 0, -1, 0); |
22 | 22 | ||
23 | QPushButton *power = new QPushButton("Power",this,"power"); | 23 | QPushButton *power = new QPushButton("Power",this,"power"); |
24 | layout->addWidget(power); | 24 | layout->addWidget(power); |
25 | connect(power, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 25 | connect(power, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
26 | //power->setGeometry(5, 5,40, 20); | 26 | //power->setGeometry(5, 5,40, 20); |
27 | 27 | ||
28 | layout->addSpacing(5); | 28 | layout->addSpacing(5); |
29 | 29 | ||
30 | QPushButton *source = new QPushButton("Source",this,"source"); | 30 | QPushButton *source = new QPushButton("Source",this,"source"); |
31 | layout->addWidget(source); | 31 | layout->addWidget(source); |
32 | connect(source, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 32 | connect(source, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
33 | //source->setGeometry(50,5,40,20); | 33 | //source->setGeometry(50,5,40,20); |
34 | 34 | ||
35 | remotes = new QComboBox(false, this, "remotes"); | 35 | remotes = new QComboBox(false, this, "remotes"); |
36 | connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); | 36 | connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); |
37 | remotes->insertItem("Select Remote"); | 37 | remotes->insertItem("Select Remote"); |
38 | //remotes->setGeometry(135,5,95,20); | 38 | //remotes->setGeometry(135,5,95,20); |
39 | 39 | ||
40 | QLabel *remoteLabel = new QLabel(remotes, "Remote: ",this,"remoteLabel"); | 40 | QLabel *remoteLabel = new QLabel(remotes, "Remote: ",this,"remoteLabel"); |
41 | //remoteLabel->setGeometry(90,5,40,20); | 41 | //remoteLabel->setGeometry(90,5,40,20); |
42 | remoteLabel->setAlignment(AlignRight | AlignVCenter); | 42 | remoteLabel->setAlignment(AlignRight | AlignVCenter); |
43 | 43 | ||
44 | layout->addWidget(remoteLabel); | 44 | layout->addWidget(remoteLabel); |
45 | layout->addWidget(remotes); | 45 | layout->addWidget(remotes); |
46 | } | 46 | } |
47 | 47 | ||
48 | void TopGroup::updateRemotes(Config *cfg) | 48 | void TopGroup::updateRemotes(Config *cfg) |
49 | { | 49 | { |
50 | remotes->clear(); | 50 | remotes->clear(); |
51 | remotes->insertItem(QString("SelectRemote")); | 51 | remotes->insertItem(QString("SelectRemote")); |
52 | cfg->setGroup("Remotes"); | 52 | cfg->setGroup("Remotes"); |
53 | remotes->insertStringList(cfg->readListEntry("remoteList", ',') ); | 53 | remotes->insertStringList(cfg->readListEntry("remoteList", ',') ); |
54 | } | 54 | } |
diff --git a/noncore/tools/remote/topgroupconf.cpp b/noncore/tools/remote/topgroupconf.cpp index eb071fb..d763a3a 100644 --- a/noncore/tools/remote/topgroupconf.cpp +++ b/noncore/tools/remote/topgroupconf.cpp | |||
@@ -1,70 +1,70 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "topgroupconf.h" | 17 | #include "topgroupconf.h" |
18 | 18 | ||
19 | TopGroupConf::TopGroupConf(QWidget *parent=0, const char *name=0):QWidget(parent,name) | 19 | TopGroupConf::TopGroupConf(QWidget *parent, const char *name):QWidget(parent,name) |
20 | { | 20 | { |
21 | QHBoxLayout *layout = new QHBoxLayout(this); | 21 | QHBoxLayout *layout = new QHBoxLayout(this); |
22 | 22 | ||
23 | QPushButton *power = new QPushButton("Power",this,"power"); | 23 | QPushButton *power = new QPushButton("Power",this,"power"); |
24 | layout->addWidget(power); | 24 | layout->addWidget(power); |
25 | connect(power, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 25 | connect(power, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
26 | //power->setGeometry(5, 5,40, 20); | 26 | //power->setGeometry(5, 5,40, 20); |
27 | 27 | ||
28 | layout->addSpacing(5); | 28 | layout->addSpacing(5); |
29 | 29 | ||
30 | QPushButton *source = new QPushButton("Source",this,"source"); | 30 | QPushButton *source = new QPushButton("Source",this,"source"); |
31 | layout->addWidget(source); | 31 | layout->addWidget(source); |
32 | connect(source, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 32 | connect(source, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
33 | //source->setGeometry(50,5,40,20); | 33 | //source->setGeometry(50,5,40,20); |
34 | 34 | ||
35 | remotes = new QComboBox(true, this, "remotes"); | 35 | remotes = new QComboBox(true, this, "remotes"); |
36 | remotes->insertItem(QString("Remotes")); | 36 | remotes->insertItem(QString("Remotes")); |
37 | layout->addWidget(remotes); | 37 | layout->addWidget(remotes); |
38 | layout->setStretchFactor(remotes, 1); | 38 | layout->setStretchFactor(remotes, 1); |
39 | connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); | 39 | connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); |
40 | 40 | ||
41 | 41 | ||
42 | QPushButton *newrem = new QPushButton("New", this, "new"); | 42 | QPushButton *newrem = new QPushButton("New", this, "new"); |
43 | layout->addWidget(newrem); | 43 | layout->addWidget(newrem); |
44 | connect(newrem, SIGNAL(pressed()), this->parentWidget(), SLOT(newPressed()) ); | 44 | connect(newrem, SIGNAL(pressed()), this->parentWidget(), SLOT(newPressed()) ); |
45 | 45 | ||
46 | 46 | ||
47 | /*remotes = new QComboBox(false, this, "remotes"); | 47 | /*remotes = new QComboBox(false, this, "remotes"); |
48 | connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); | 48 | connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); |
49 | remotes->insertItem("Select Remote"); | 49 | remotes->insertItem("Select Remote"); |
50 | //remotes->setGeometry(135,5,95,20); | 50 | //remotes->setGeometry(135,5,95,20); |
51 | 51 | ||
52 | QLabel *remoteLabel = new QLabel(remotes, "Remote: ",this,"remoteLabel"); | 52 | QLabel *remoteLabel = new QLabel(remotes, "Remote: ",this,"remoteLabel"); |
53 | //remoteLabel->setGeometry(90,5,40,20); | 53 | //remoteLabel->setGeometry(90,5,40,20); |
54 | remoteLabel->setAlignment(AlignRight | AlignVCenter); | 54 | remoteLabel->setAlignment(AlignRight | AlignVCenter); |
55 | 55 | ||
56 | layout->addWidget(remoteLabel); | 56 | layout->addWidget(remoteLabel); |
57 | layout->addWidget(remotes); | 57 | layout->addWidget(remotes); |
58 | */ | 58 | */ |
59 | } | 59 | } |
60 | 60 | ||
61 | void TopGroupConf::updateRemotes(QStringList list) | 61 | void TopGroupConf::updateRemotes(QStringList list) |
62 | { | 62 | { |
63 | remotes->insertStringList(list); | 63 | remotes->insertStringList(list); |
64 | } | 64 | } |
65 | 65 | ||
66 | QString TopGroupConf::getRemotesText() | 66 | QString TopGroupConf::getRemotesText() |
67 | { | 67 | { |
68 | return remotes->currentText(); | 68 | return remotes->currentText(); |
69 | } | 69 | } |
70 | 70 | ||
diff --git a/noncore/tools/remote/vcrgroup.cpp b/noncore/tools/remote/vcrgroup.cpp index 4f07ca3..10ebe5d 100644 --- a/noncore/tools/remote/vcrgroup.cpp +++ b/noncore/tools/remote/vcrgroup.cpp | |||
@@ -1,88 +1,88 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under | 5 | This program is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public | 6 | the terms of the GNU General Public |
7 | License as published by the Free Software Foundation; either version 2 of the | 7 | License as published by the Free Software Foundation; either version 2 of the |
8 | License, or (at your option) any later | 8 | License, or (at your option) any later |
9 | version. | 9 | version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, but WITHOUT ANY | 11 | This program is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the | 12 | WARRANTY; without even the |
13 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 | ||
15 | GNU General | 15 | GNU General |
16 | Public License for more details. | 16 | Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License along with | 18 | You should have received a copy of the GNU General Public License along with |
19 | this program; if not, write to the Free | 19 | this program; if not, write to the Free |
20 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "vcrgroup.h" | 23 | #include "vcrgroup.h" |
24 | 24 | ||
25 | VCRGroup::VCRGroup(QWidget *parent=0, const char *name=0) : QWidget(parent, | 25 | VCRGroup::VCRGroup(QWidget *parent, const char *name) : QWidget(parent, |
26 | name) | 26 | name) |
27 | { | 27 | { |
28 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 28 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
29 | 29 | ||
30 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); | 30 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); |
31 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); | 31 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); |
32 | 32 | ||
33 | vlayout->addLayout(hlayout1); | 33 | vlayout->addLayout(hlayout1); |
34 | vlayout->addSpacing(1); | 34 | vlayout->addSpacing(1); |
35 | vlayout->addLayout(hlayout2); | 35 | vlayout->addLayout(hlayout2); |
36 | 36 | ||
37 | QPushButton *play = new | 37 | QPushButton *play = new |
38 | QPushButton("Play",this, "play"); | 38 | QPushButton("Play",this, "play"); |
39 | hlayout1->addWidget(play); | 39 | hlayout1->addWidget(play); |
40 | connect(play, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 40 | connect(play, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
41 | 41 | ||
42 | hlayout1->addSpacing(5); | 42 | hlayout1->addSpacing(5); |
43 | 43 | ||
44 | QPushButton *pause = new | 44 | QPushButton *pause = new |
45 | QPushButton("Pause",this, "pause"); | 45 | QPushButton("Pause",this, "pause"); |
46 | hlayout1->addWidget(pause); | 46 | hlayout1->addWidget(pause); |
47 | connect(pause, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 47 | connect(pause, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
48 | 48 | ||
49 | hlayout1->addSpacing(5); | 49 | hlayout1->addSpacing(5); |
50 | 50 | ||
51 | QPushButton *stop = new | 51 | QPushButton *stop = new |
52 | QPushButton("Stop",this, "stop"); | 52 | QPushButton("Stop",this, "stop"); |
53 | hlayout1->addWidget(stop); | 53 | hlayout1->addWidget(stop); |
54 | connect(stop, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 54 | connect(stop, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
55 | 55 | ||
56 | hlayout1->addSpacing(5); | 56 | hlayout1->addSpacing(5); |
57 | 57 | ||
58 | QPushButton *record = new | 58 | QPushButton *record = new |
59 | QPushButton("Record",this, "record"); | 59 | QPushButton("Record",this, "record"); |
60 | hlayout1->addWidget(record); | 60 | hlayout1->addWidget(record); |
61 | connect(record, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 61 | connect(record, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
62 | 62 | ||
63 | QPushButton *back = new | 63 | QPushButton *back = new |
64 | QPushButton("Back",this, "back"); | 64 | QPushButton("Back",this, "back"); |
65 | hlayout2->addWidget(back); | 65 | hlayout2->addWidget(back); |
66 | connect(back, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 66 | connect(back, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
67 | 67 | ||
68 | hlayout2->addSpacing(5); | 68 | hlayout2->addSpacing(5); |
69 | 69 | ||
70 | QPushButton *rewind = new | 70 | QPushButton *rewind = new |
71 | QPushButton("Rewind",this, "rewind"); | 71 | QPushButton("Rewind",this, "rewind"); |
72 | hlayout2->addWidget(rewind); | 72 | hlayout2->addWidget(rewind); |
73 | connect(rewind, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 73 | connect(rewind, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
74 | 74 | ||
75 | hlayout2->addSpacing(5); | 75 | hlayout2->addSpacing(5); |
76 | 76 | ||
77 | QPushButton *ff = new | 77 | QPushButton *ff = new |
78 | QPushButton("FF",this, "ff"); | 78 | QPushButton("FF",this, "ff"); |
79 | hlayout2->addWidget(ff); | 79 | hlayout2->addWidget(ff); |
80 | connect(ff, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 80 | connect(ff, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
81 | 81 | ||
82 | hlayout2->addSpacing(5); | 82 | hlayout2->addSpacing(5); |
83 | 83 | ||
84 | QPushButton *next = new | 84 | QPushButton *next = new |
85 | QPushButton("Next",this, "next"); | 85 | QPushButton("Next",this, "next"); |
86 | hlayout2->addWidget(next); | 86 | hlayout2->addWidget(next); |
87 | connect(next, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); | 87 | connect(next, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); |
88 | } | 88 | } |
diff --git a/noncore/tools/remote/vcrgroupconf.cpp b/noncore/tools/remote/vcrgroupconf.cpp index a50ed0a..2158d43 100644 --- a/noncore/tools/remote/vcrgroupconf.cpp +++ b/noncore/tools/remote/vcrgroupconf.cpp | |||
@@ -1,73 +1,73 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "vcrgroupconf.h" | 17 | #include "vcrgroupconf.h" |
18 | 18 | ||
19 | VCRGroupConf::VCRGroupConf(QWidget *parent=0, const char *name=0) : QWidget(parent, name) | 19 | VCRGroupConf::VCRGroupConf(QWidget *parent, const char *name) : QWidget(parent, name) |
20 | { | 20 | { |
21 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 21 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
22 | 22 | ||
23 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); | 23 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); |
24 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); | 24 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); |
25 | 25 | ||
26 | vlayout->addLayout(hlayout1); | 26 | vlayout->addLayout(hlayout1); |
27 | vlayout->addSpacing(1); | 27 | vlayout->addSpacing(1); |
28 | vlayout->addLayout(hlayout2); | 28 | vlayout->addLayout(hlayout2); |
29 | 29 | ||
30 | QPushButton *play = new QPushButton("Play",this, "play"); | 30 | QPushButton *play = new QPushButton("Play",this, "play"); |
31 | hlayout1->addWidget(play); | 31 | hlayout1->addWidget(play); |
32 | connect(play, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 32 | connect(play, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
33 | 33 | ||
34 | hlayout1->addSpacing(5); | 34 | hlayout1->addSpacing(5); |
35 | 35 | ||
36 | QPushButton *pause = new QPushButton("Pause",this, "pause"); | 36 | QPushButton *pause = new QPushButton("Pause",this, "pause"); |
37 | hlayout1->addWidget(pause); | 37 | hlayout1->addWidget(pause); |
38 | connect(pause, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 38 | connect(pause, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
39 | 39 | ||
40 | hlayout1->addSpacing(5); | 40 | hlayout1->addSpacing(5); |
41 | 41 | ||
42 | QPushButton *stop = new QPushButton("Stop",this, "stop"); | 42 | QPushButton *stop = new QPushButton("Stop",this, "stop"); |
43 | hlayout1->addWidget(stop); | 43 | hlayout1->addWidget(stop); |
44 | connect(stop, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 44 | connect(stop, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
45 | 45 | ||
46 | hlayout1->addSpacing(5); | 46 | hlayout1->addSpacing(5); |
47 | 47 | ||
48 | QPushButton *record = new QPushButton("Record",this, "record"); | 48 | QPushButton *record = new QPushButton("Record",this, "record"); |
49 | hlayout1->addWidget(record); | 49 | hlayout1->addWidget(record); |
50 | connect(record, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 50 | connect(record, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
51 | 51 | ||
52 | QPushButton *back = new QPushButton("Back",this, "back"); | 52 | QPushButton *back = new QPushButton("Back",this, "back"); |
53 | hlayout2->addWidget(back); | 53 | hlayout2->addWidget(back); |
54 | connect(back, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 54 | connect(back, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
55 | 55 | ||
56 | hlayout2->addSpacing(5); | 56 | hlayout2->addSpacing(5); |
57 | 57 | ||
58 | QPushButton *rewind = new QPushButton("Rewind",this, "rewind"); | 58 | QPushButton *rewind = new QPushButton("Rewind",this, "rewind"); |
59 | hlayout2->addWidget(rewind); | 59 | hlayout2->addWidget(rewind); |
60 | connect(rewind, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 60 | connect(rewind, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
61 | 61 | ||
62 | hlayout2->addSpacing(5); | 62 | hlayout2->addSpacing(5); |
63 | 63 | ||
64 | QPushButton *ff = new QPushButton("FF",this, "ff"); | 64 | QPushButton *ff = new QPushButton("FF",this, "ff"); |
65 | hlayout2->addWidget(ff); | 65 | hlayout2->addWidget(ff); |
66 | connect(ff, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 66 | connect(ff, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
67 | 67 | ||
68 | hlayout2->addSpacing(5); | 68 | hlayout2->addSpacing(5); |
69 | 69 | ||
70 | QPushButton *next = new QPushButton("Next",this, "next"); | 70 | QPushButton *next = new QPushButton("Next",this, "next"); |
71 | hlayout2->addWidget(next); | 71 | hlayout2->addWidget(next); |
72 | connect(next, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); | 72 | connect(next, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); |
73 | } | 73 | } |
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.cpp b/noncore/unsupported/mail2/libmail/imaphandler.cpp index 730a004..7493240 100644 --- a/noncore/unsupported/mail2/libmail/imaphandler.cpp +++ b/noncore/unsupported/mail2/libmail/imaphandler.cpp | |||
@@ -1,343 +1,343 @@ | |||
1 | #include "imapresponse.h" | 1 | #include "imapresponse.h" |
2 | #include "imaphandler.h" | 2 | #include "imaphandler.h" |
3 | #include "imapbase.h" | 3 | #include "imapbase.h" |
4 | 4 | ||
5 | IMAPHandler::IMAPHandler(const Account &account) | 5 | IMAPHandler::IMAPHandler(const Account &account) |
6 | : QObject(), _account(account) | 6 | : QObject(), _account(account) |
7 | { | 7 | { |
8 | _ready = false; | 8 | _ready = false; |
9 | _loggingin = false; | 9 | _loggingin = false; |
10 | _loggedin = false; | 10 | _loggedin = false; |
11 | _tag = 0; | 11 | _tag = 0; |
12 | _ibase = new IMAPBase(account); | 12 | _ibase = new IMAPBase(account); |
13 | 13 | ||
14 | connect(_ibase, SIGNAL(dataReceived(const QString &)), SLOT(slotDataReceived(const QString &))); | 14 | connect(_ibase, SIGNAL(dataReceived(const QString &)), SLOT(slotDataReceived(const QString &))); |
15 | connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost())); | 15 | connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost())); |
16 | connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound())); | 16 | connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound())); |
17 | connect(_ibase, SIGNAL(connected()), SLOT(slotConnected())); | 17 | connect(_ibase, SIGNAL(connected()), SLOT(slotConnected())); |
18 | connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected())); | 18 | connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected())); |
19 | connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int))); | 19 | connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int))); |
20 | } | 20 | } |
21 | 21 | ||
22 | void IMAPHandler::doLogin() | 22 | void IMAPHandler::doLogin() |
23 | { | 23 | { |
24 | if (_loggedin) return; | 24 | if (_loggedin) return; |
25 | if (_loggingin) return; | 25 | if (_loggingin) return; |
26 | 26 | ||
27 | _loggingin = true; | 27 | _loggingin = true; |
28 | iLogin(_account.user(), _account.pass()); | 28 | iLogin(_account.user(), _account.pass()); |
29 | } | 29 | } |
30 | 30 | ||
31 | QString IMAPHandler::iCapability() | 31 | QString IMAPHandler::iCapability() |
32 | { | 32 | { |
33 | _ibase->sendCommand(QString("%1 CAPABILITY\r\n") | 33 | _ibase->sendCommand(QString("%1 CAPABILITY\r\n") |
34 | .arg(tag())); | 34 | .arg(tag())); |
35 | return tag(false); | 35 | return tag(false); |
36 | } | 36 | } |
37 | 37 | ||
38 | QString IMAPHandler::iNoop() | 38 | QString IMAPHandler::iNoop() |
39 | { | 39 | { |
40 | _ibase->sendCommand(QString("%1 NOOP\r\n") | 40 | _ibase->sendCommand(QString("%1 NOOP\r\n") |
41 | .arg(tag())); | 41 | .arg(tag())); |
42 | return tag(false); | 42 | return tag(false); |
43 | } | 43 | } |
44 | 44 | ||
45 | QString IMAPHandler::iLogout() | 45 | QString IMAPHandler::iLogout() |
46 | { | 46 | { |
47 | _ibase->sendCommand(QString("%1 LOGOUT\r\n") | 47 | _ibase->sendCommand(QString("%1 LOGOUT\r\n") |
48 | .arg(tag())); | 48 | .arg(tag())); |
49 | return tag(false); | 49 | return tag(false); |
50 | } | 50 | } |
51 | 51 | ||
52 | QString IMAPHandler::iAuthenticate(const QString &mechanism) | 52 | QString IMAPHandler::iAuthenticate(const QString &mechanism) |
53 | { | 53 | { |
54 | _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n") | 54 | _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n") |
55 | .arg(tag()) | 55 | .arg(tag()) |
56 | .arg(escape(mechanism))); | 56 | .arg(escape(mechanism))); |
57 | return tag(false); | 57 | return tag(false); |
58 | } | 58 | } |
59 | 59 | ||
60 | QString IMAPHandler::iLogin(const QString &user, const QString &pass) | 60 | QString IMAPHandler::iLogin(const QString &user, const QString &pass) |
61 | { | 61 | { |
62 | _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n") | 62 | _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n") |
63 | .arg(tag()) | 63 | .arg(tag()) |
64 | .arg(escape(user)) | 64 | .arg(escape(user)) |
65 | .arg(escape(pass))); | 65 | .arg(escape(pass))); |
66 | return tag(false); | 66 | return tag(false); |
67 | } | 67 | } |
68 | 68 | ||
69 | QString IMAPHandler::iSelect(const QString &mailbox) | 69 | QString IMAPHandler::iSelect(const QString &mailbox) |
70 | { | 70 | { |
71 | doLogin(); | 71 | doLogin(); |
72 | 72 | ||
73 | _ibase->sendCommand(QString("%1 SELECT \"%2\"\r\n") | 73 | _ibase->sendCommand(QString("%1 SELECT \"%2\"\r\n") |
74 | .arg(tag()) | 74 | .arg(tag()) |
75 | .arg(escape(mailbox))); | 75 | .arg(escape(mailbox))); |
76 | return tag(false); | 76 | return tag(false); |
77 | } | 77 | } |
78 | 78 | ||
79 | QString IMAPHandler::iExamine(const QString &mailbox) | 79 | QString IMAPHandler::iExamine(const QString &mailbox) |
80 | { | 80 | { |
81 | doLogin(); | 81 | doLogin(); |
82 | 82 | ||
83 | _ibase->sendCommand(QString("%1 EXAMINE \"%2\"\r\n") | 83 | _ibase->sendCommand(QString("%1 EXAMINE \"%2\"\r\n") |
84 | .arg(tag()) | 84 | .arg(tag()) |
85 | .arg(escape(mailbox))); | 85 | .arg(escape(mailbox))); |
86 | return tag(false); | 86 | return tag(false); |
87 | } | 87 | } |
88 | 88 | ||
89 | QString IMAPHandler::iCreate(const QString &mailbox) | 89 | QString IMAPHandler::iCreate(const QString &mailbox) |
90 | { | 90 | { |
91 | doLogin(); | 91 | doLogin(); |
92 | 92 | ||
93 | _ibase->sendCommand(QString("%1 CREATE \"%2\"\r\n") | 93 | _ibase->sendCommand(QString("%1 CREATE \"%2\"\r\n") |
94 | .arg(tag()) | 94 | .arg(tag()) |
95 | .arg(escape(mailbox))); | 95 | .arg(escape(mailbox))); |
96 | return tag(false); | 96 | return tag(false); |
97 | } | 97 | } |
98 | 98 | ||
99 | QString IMAPHandler::iDelete(const QString &mailbox) | 99 | QString IMAPHandler::iDelete(const QString &mailbox) |
100 | { | 100 | { |
101 | doLogin(); | 101 | doLogin(); |
102 | 102 | ||
103 | _ibase->sendCommand(QString("%1 DELETE \"%2\"\r\n") | 103 | _ibase->sendCommand(QString("%1 DELETE \"%2\"\r\n") |
104 | .arg(tag()) | 104 | .arg(tag()) |
105 | .arg(escape(mailbox))); | 105 | .arg(escape(mailbox))); |
106 | return tag(false); | 106 | return tag(false); |
107 | } | 107 | } |
108 | 108 | ||
109 | QString IMAPHandler::iRename(const QString &mailbox, const QString &newMailbox) | 109 | QString IMAPHandler::iRename(const QString &mailbox, const QString &newMailbox) |
110 | { | 110 | { |
111 | doLogin(); | 111 | doLogin(); |
112 | 112 | ||
113 | _ibase->sendCommand(QString("%1 RENAME \"%2\" \"%3\"\r\n") | 113 | _ibase->sendCommand(QString("%1 RENAME \"%2\" \"%3\"\r\n") |
114 | .arg(tag()) | 114 | .arg(tag()) |
115 | .arg(escape(mailbox)) | 115 | .arg(escape(mailbox)) |
116 | .arg(escape(newMailbox))); | 116 | .arg(escape(newMailbox))); |
117 | return tag(false); | 117 | return tag(false); |
118 | } | 118 | } |
119 | 119 | ||
120 | QString IMAPHandler::iSubscribe(const QString &mailbox) | 120 | QString IMAPHandler::iSubscribe(const QString &mailbox) |
121 | { | 121 | { |
122 | doLogin(); | 122 | doLogin(); |
123 | 123 | ||
124 | _ibase->sendCommand(QString("%1 SUBSCRIBE \"%2\"\r\n") | 124 | _ibase->sendCommand(QString("%1 SUBSCRIBE \"%2\"\r\n") |
125 | .arg(tag()) | 125 | .arg(tag()) |
126 | .arg(escape(mailbox))); | 126 | .arg(escape(mailbox))); |
127 | return tag(false); | 127 | return tag(false); |
128 | } | 128 | } |
129 | 129 | ||
130 | QString IMAPHandler::iUnsubscribe(const QString &mailbox) | 130 | QString IMAPHandler::iUnsubscribe(const QString &mailbox) |
131 | { | 131 | { |
132 | doLogin(); | 132 | doLogin(); |
133 | 133 | ||
134 | _ibase->sendCommand(QString("%1 UNSUBSCRIBE \"%2\"\r\n") | 134 | _ibase->sendCommand(QString("%1 UNSUBSCRIBE \"%2\"\r\n") |
135 | .arg(tag()) | 135 | .arg(tag()) |
136 | .arg(escape(mailbox))); | 136 | .arg(escape(mailbox))); |
137 | return tag(false); | 137 | return tag(false); |
138 | } | 138 | } |
139 | 139 | ||
140 | QString IMAPHandler::iList(const QString &reference, const QString &mailbox) | 140 | QString IMAPHandler::iList(const QString &reference, const QString &mailbox) |
141 | { | 141 | { |
142 | doLogin(); | 142 | doLogin(); |
143 | 143 | ||
144 | _ibase->sendCommand(QString("%1 LIST \"%2\" \"%3\"\r\n") | 144 | _ibase->sendCommand(QString("%1 LIST \"%2\" \"%3\"\r\n") |
145 | .arg(tag()) | 145 | .arg(tag()) |
146 | .arg(escape(reference)) | 146 | .arg(escape(reference)) |
147 | .arg(escape(mailbox))); | 147 | .arg(escape(mailbox))); |
148 | return tag(false); | 148 | return tag(false); |
149 | } | 149 | } |
150 | 150 | ||
151 | QString IMAPHandler::iLsub(const QString &reference, const QString &mailbox) | 151 | QString IMAPHandler::iLsub(const QString &reference, const QString &mailbox) |
152 | { | 152 | { |
153 | doLogin(); | 153 | doLogin(); |
154 | 154 | ||
155 | _ibase->sendCommand(QString("%1 LSUB \"%2\" \"%3\"\r\n") | 155 | _ibase->sendCommand(QString("%1 LSUB \"%2\" \"%3\"\r\n") |
156 | .arg(tag()) | 156 | .arg(tag()) |
157 | .arg(escape(reference)) | 157 | .arg(escape(reference)) |
158 | .arg(escape(mailbox))); | 158 | .arg(escape(mailbox))); |
159 | return tag(false); | 159 | return tag(false); |
160 | } | 160 | } |
161 | 161 | ||
162 | QString IMAPHandler::iStatus(const QString &mailbox, const QString &items) | 162 | QString IMAPHandler::iStatus(const QString &mailbox, const QString &items) |
163 | { | 163 | { |
164 | doLogin(); | 164 | doLogin(); |
165 | 165 | ||
166 | _ibase->sendCommand(QString("%1 STATUS \"%2\" (%3)\r\n") | 166 | _ibase->sendCommand(QString("%1 STATUS \"%2\" (%3)\r\n") |
167 | .arg(tag()) | 167 | .arg(tag()) |
168 | .arg(escape(mailbox)) | 168 | .arg(escape(mailbox)) |
169 | .arg(escape(items))); | 169 | .arg(escape(items))); |
170 | return tag(false); | 170 | return tag(false); |
171 | } | 171 | } |
172 | 172 | ||
173 | QString IMAPHandler::iAppend(const QString &mailbox, const QString &literal, const QString &flags, const QString &datetime = 0) | 173 | QString IMAPHandler::iAppend(const QString &mailbox, const QString &literal, const QString &flags, const QString &datetime) |
174 | { | 174 | { |
175 | doLogin(); | 175 | doLogin(); |
176 | 176 | ||
177 | _ibase->sendCommand(QString("%1 APPEND \"%2\" (%3) \"%4\" {%5}\r\n%6\r\n") | 177 | _ibase->sendCommand(QString("%1 APPEND \"%2\" (%3) \"%4\" {%5}\r\n%6\r\n") |
178 | .arg(tag()) | 178 | .arg(tag()) |
179 | .arg(escape(mailbox)) | 179 | .arg(escape(mailbox)) |
180 | .arg(flags) | 180 | .arg(flags) |
181 | .arg(escape(datetime)) | 181 | .arg(escape(datetime)) |
182 | .arg(literal.length()) | 182 | .arg(literal.length()) |
183 | .arg(literal)); | 183 | .arg(literal)); |
184 | return tag(false); | 184 | return tag(false); |
185 | } | 185 | } |
186 | 186 | ||
187 | QString IMAPHandler::iCheck() | 187 | QString IMAPHandler::iCheck() |
188 | { | 188 | { |
189 | doLogin(); | 189 | doLogin(); |
190 | 190 | ||
191 | _ibase->sendCommand(QString("%1 CHECK\r\n") | 191 | _ibase->sendCommand(QString("%1 CHECK\r\n") |
192 | .arg(tag())); | 192 | .arg(tag())); |
193 | return tag(false); | 193 | return tag(false); |
194 | } | 194 | } |
195 | 195 | ||
196 | QString IMAPHandler::iClose() | 196 | QString IMAPHandler::iClose() |
197 | { | 197 | { |
198 | doLogin(); | 198 | doLogin(); |
199 | 199 | ||
200 | _ibase->sendCommand(QString("%1 CLOSE\r\n") | 200 | _ibase->sendCommand(QString("%1 CLOSE\r\n") |
201 | .arg(tag())); | 201 | .arg(tag())); |
202 | return tag(false); | 202 | return tag(false); |
203 | } | 203 | } |
204 | 204 | ||
205 | QString IMAPHandler::iExpunge() | 205 | QString IMAPHandler::iExpunge() |
206 | { | 206 | { |
207 | doLogin(); | 207 | doLogin(); |
208 | 208 | ||
209 | _ibase->sendCommand(QString("%1 EXPUNGE\r\n") | 209 | _ibase->sendCommand(QString("%1 EXPUNGE\r\n") |
210 | .arg(tag())); | 210 | .arg(tag())); |
211 | return tag(false); | 211 | return tag(false); |
212 | } | 212 | } |
213 | 213 | ||
214 | QString IMAPHandler::iSearch(const QString &search, const QString &charset) | 214 | QString IMAPHandler::iSearch(const QString &search, const QString &charset) |
215 | { | 215 | { |
216 | doLogin(); | 216 | doLogin(); |
217 | 217 | ||
218 | _ibase->sendCommand(QString("%1 SEARCH %2 %3\r\n") | 218 | _ibase->sendCommand(QString("%1 SEARCH %2 %3\r\n") |
219 | .arg(tag()) | 219 | .arg(tag()) |
220 | .arg(charset.isEmpty() ? QString(0) : escape(charset)) | 220 | .arg(charset.isEmpty() ? QString(0) : escape(charset)) |
221 | .arg(search)); | 221 | .arg(search)); |
222 | return tag(false); | 222 | return tag(false); |
223 | } | 223 | } |
224 | 224 | ||
225 | QString IMAPHandler::iFetch(const QString &message, const QString &items) | 225 | QString IMAPHandler::iFetch(const QString &message, const QString &items) |
226 | { | 226 | { |
227 | doLogin(); | 227 | doLogin(); |
228 | 228 | ||
229 | _ibase->sendCommand(QString("%1 FETCH %2 (%3)\r\n") | 229 | _ibase->sendCommand(QString("%1 FETCH %2 (%3)\r\n") |
230 | .arg(tag()) | 230 | .arg(tag()) |
231 | .arg(message) | 231 | .arg(message) |
232 | .arg(items)); | 232 | .arg(items)); |
233 | return tag(false); | 233 | return tag(false); |
234 | } | 234 | } |
235 | 235 | ||
236 | QString IMAPHandler::iStore(const QString &message, const QString &items) | 236 | QString IMAPHandler::iStore(const QString &message, const QString &items) |
237 | { | 237 | { |
238 | doLogin(); | 238 | doLogin(); |
239 | 239 | ||
240 | _ibase->sendCommand(QString("%1 STORE %2 %3\r\n") | 240 | _ibase->sendCommand(QString("%1 STORE %2 %3\r\n") |
241 | .arg(tag()) | 241 | .arg(tag()) |
242 | .arg(message) | 242 | .arg(message) |
243 | .arg(items)); | 243 | .arg(items)); |
244 | return tag(false); | 244 | return tag(false); |
245 | } | 245 | } |
246 | 246 | ||
247 | QString IMAPHandler::iCopy(const QString &message, const QString &mailbox) | 247 | QString IMAPHandler::iCopy(const QString &message, const QString &mailbox) |
248 | { | 248 | { |
249 | doLogin(); | 249 | doLogin(); |
250 | 250 | ||
251 | _ibase->sendCommand(QString("%1 COPY %2 \"%3\"\r\n") | 251 | _ibase->sendCommand(QString("%1 COPY %2 \"%3\"\r\n") |
252 | .arg(tag()) | 252 | .arg(tag()) |
253 | .arg(message) | 253 | .arg(message) |
254 | .arg(escape(mailbox))); | 254 | .arg(escape(mailbox))); |
255 | return tag(false); | 255 | return tag(false); |
256 | } | 256 | } |
257 | 257 | ||
258 | QString IMAPHandler::iUid(const QString &command, const QString &arguments) | 258 | QString IMAPHandler::iUid(const QString &command, const QString &arguments) |
259 | { | 259 | { |
260 | doLogin(); | 260 | doLogin(); |
261 | 261 | ||
262 | _ibase->sendCommand(QString("%1 UID %2 %3\r\n") | 262 | _ibase->sendCommand(QString("%1 UID %2 %3\r\n") |
263 | .arg(tag()) | 263 | .arg(tag()) |
264 | .arg(command) | 264 | .arg(command) |
265 | .arg(arguments)); | 265 | .arg(arguments)); |
266 | return tag(false); | 266 | return tag(false); |
267 | } | 267 | } |
268 | 268 | ||
269 | QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments) | 269 | QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments) |
270 | { | 270 | { |
271 | doLogin(); | 271 | doLogin(); |
272 | 272 | ||
273 | _ibase->sendCommand(QString("%1 X%2 %3\r\n") | 273 | _ibase->sendCommand(QString("%1 X%2 %3\r\n") |
274 | .arg(tag()) | 274 | .arg(tag()) |
275 | .arg(commandAtom) | 275 | .arg(commandAtom) |
276 | .arg(arguments)); | 276 | .arg(arguments)); |
277 | return tag(false); | 277 | return tag(false); |
278 | } | 278 | } |
279 | 279 | ||
280 | QString IMAPHandler::escape(const QString &in) | 280 | QString IMAPHandler::escape(const QString &in) |
281 | { | 281 | { |
282 | QString in_ = in; | 282 | QString in_ = in; |
283 | return in_.replace(QRegExp("\""), "\\\""); | 283 | return in_.replace(QRegExp("\""), "\\\""); |
284 | } | 284 | } |
285 | 285 | ||
286 | QString IMAPHandler::tag(bool count) | 286 | QString IMAPHandler::tag(bool count) |
287 | { | 287 | { |
288 | return QString("a%1").arg(count ? _tag++ : _tag); | 288 | return QString("a%1").arg(count ? _tag++ : _tag); |
289 | } | 289 | } |
290 | 290 | ||
291 | void IMAPHandler::slotDataReceived(const QString &data) | 291 | void IMAPHandler::slotDataReceived(const QString &data) |
292 | { | 292 | { |
293 | if (!_ready) { | 293 | if (!_ready) { |
294 | // The first data is always the greeting string. | 294 | // The first data is always the greeting string. |
295 | // We can ignore it. | 295 | // We can ignore it. |
296 | _ready = true; | 296 | _ready = true; |
297 | return; | 297 | return; |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | IMAPResponseParser parser(data); | 301 | IMAPResponseParser parser(data); |
302 | IMAPResponse response = parser.response(); | 302 | IMAPResponse response = parser.response(); |
303 | response.setImapHandler(this); | 303 | response.setImapHandler(this); |
304 | 304 | ||
305 | if (!_loggingin) emit gotResponse(response); | 305 | if (!_loggingin) emit gotResponse(response); |
306 | else { | 306 | else { |
307 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 307 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
308 | _loggingin = false; | 308 | _loggingin = false; |
309 | _loggedin = true; | 309 | _loggedin = true; |
310 | qWarning("OK. Logged in. Leaving loggingin state."); | 310 | qWarning("OK. Logged in. Leaving loggingin state."); |
311 | } else { | 311 | } else { |
312 | _loggingin = false; | 312 | _loggingin = false; |
313 | emit IMAPError(IMAPBase::IMAPErrLoginFailed); | 313 | emit IMAPError(IMAPBase::IMAPErrLoginFailed); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | void IMAPHandler::slotLookingUpHost() | 318 | void IMAPHandler::slotLookingUpHost() |
319 | { | 319 | { |
320 | emit IMAPLookingUpHost(); | 320 | emit IMAPLookingUpHost(); |
321 | } | 321 | } |
322 | 322 | ||
323 | void IMAPHandler::slotHostFound() | 323 | void IMAPHandler::slotHostFound() |
324 | { | 324 | { |
325 | emit IMAPHostFound(); | 325 | emit IMAPHostFound(); |
326 | } | 326 | } |
327 | 327 | ||
328 | void IMAPHandler::slotConnected() | 328 | void IMAPHandler::slotConnected() |
329 | { | 329 | { |
330 | emit IMAPConnected(); | 330 | emit IMAPConnected(); |
331 | } | 331 | } |
332 | 332 | ||
333 | void IMAPHandler::slotDisconnected() | 333 | void IMAPHandler::slotDisconnected() |
334 | { | 334 | { |
335 | _loggedin = false; | 335 | _loggedin = false; |
336 | emit IMAPDisconnected(); | 336 | emit IMAPDisconnected(); |
337 | } | 337 | } |
338 | 338 | ||
339 | void IMAPHandler::slotError(int err) | 339 | void IMAPHandler::slotError(int err) |
340 | { | 340 | { |
341 | emit IMAPError(err); | 341 | emit IMAPError(err); |
342 | } | 342 | } |
343 | 343 | ||
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 7df1d6b..05f2f06 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp | |||
@@ -1,497 +1,497 @@ | |||
1 | // adadpted form qpe/qipkg | 1 | // adadpted form qpe/qipkg |
2 | 2 | ||
3 | 3 | ||
4 | #include "mainwindow.h" | 4 | #include "mainwindow.h" |
5 | 5 | ||
6 | #include <qpe/qpemenubar.h> | 6 | #include <qpe/qpemenubar.h> |
7 | #include <qpe/qpemessagebox.h> | 7 | #include <qpe/qpemessagebox.h> |
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | #include <qpe/qpetoolbar.h> | 10 | #include <qpe/qpetoolbar.h> |
11 | #include <qpe/qcopenvelope_qws.h> | 11 | #include <qpe/qcopenvelope_qws.h> |
12 | #include <qaction.h> | 12 | #include <qaction.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <qpopupmenu.h> | 14 | #include <qpopupmenu.h> |
15 | #include <qtoolbutton.h> | 15 | #include <qtoolbutton.h> |
16 | #include <qstring.h> | 16 | #include <qstring.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qfile.h> | 18 | #include <qfile.h> |
19 | #include <qlistview.h> | 19 | #include <qlistview.h> |
20 | #include <qtextview.h> | 20 | #include <qtextview.h> |
21 | #include <qcheckbox.h> | 21 | #include <qcheckbox.h> |
22 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | 28 | ||
29 | #include "pksettingsbase.h" | 29 | #include "pksettingsbase.h" |
30 | #include "utils.h" | 30 | #include "utils.h" |
31 | #include "packagelistitem.h" | 31 | #include "packagelistitem.h" |
32 | 32 | ||
33 | 33 | ||
34 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | 34 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
35 | QMainWindow( parent, name, f ) | 35 | QMainWindow( parent, name, f ) |
36 | // packageListServers( QObject(parent), name ), | 36 | // packageListServers( QObject(parent), name ), |
37 | // packageListSearch( parent, name ), | 37 | // packageListSearch( parent, name ), |
38 | // packageListDocLnk( parent, name ) | 38 | // packageListDocLnk( parent, name ) |
39 | { | 39 | { |
40 | setCaption( tr("Package Manager") ); | 40 | setCaption( tr("Package Manager") ); |
41 | settings = new PackageManagerSettings(this,0,TRUE); | 41 | settings = new PackageManagerSettings(this,0,TRUE); |
42 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); | 42 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); |
43 | setCentralWidget( listViewPackages ); | 43 | setCentralWidget( listViewPackages ); |
44 | listViewPackages->addList( tr("feeds"), &packageListServers ); | 44 | listViewPackages->addList( tr("feeds"), &packageListServers ); |
45 | listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); | 45 | listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); |
46 | //listViewPackages->addList( tr("documents"), &packageListDocLnk ); | 46 | //listViewPackages->addList( tr("documents"), &packageListDocLnk ); |
47 | ipkg = new PmIpkg( settings, this ); | 47 | ipkg = new PmIpkg( settings, this ); |
48 | packageListServers.setSettings( settings ); | 48 | packageListServers.setSettings( settings ); |
49 | packageListSearch.setSettings( settings ); | 49 | packageListSearch.setSettings( settings ); |
50 | packageListDocLnk.setSettings( settings ); | 50 | packageListDocLnk.setSettings( settings ); |
51 | pvDebug(9,"packageListServers.update"); | 51 | pvDebug(9,"packageListServers.update"); |
52 | packageListServers.update(); | 52 | packageListServers.update(); |
53 | pvDebug(9,"packageListDocLnk.update"); | 53 | pvDebug(9,"packageListDocLnk.update"); |
54 | pvDebug(0,"no UPDATE of DocLnk"); | 54 | pvDebug(0,"no UPDATE of DocLnk"); |
55 | // packageListDocLnk.update(); | 55 | // packageListDocLnk.update(); |
56 | pvDebug(9,"makeMenu"); | 56 | pvDebug(9,"makeMenu"); |
57 | makeMenu(); | 57 | makeMenu(); |
58 | makeChannel(); | 58 | makeChannel(); |
59 | //opie is hardcoded default ;) | 59 | //opie is hardcoded default ;) |
60 | //pvDebug(9,"section->setCurrentItem"); | 60 | //pvDebug(9,"section->setCurrentItem"); |
61 | // for (int i=0;i<section->count();i++) | 61 | // for (int i=0;i<section->count();i++) |
62 | // if (section->text(i)=="opie") | 62 | // if (section->text(i)=="opie") |
63 | // section->setCurrentItem(i); | 63 | // section->setCurrentItem(i); |
64 | // sectionChanged(); | 64 | // sectionChanged(); |
65 | 65 | ||
66 | connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); | 66 | connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); |
67 | connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); | 67 | connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); |
68 | 68 | ||
69 | connect( settings->removeLinksButton, SIGNAL( clicked()), | 69 | connect( settings->removeLinksButton, SIGNAL( clicked()), |
70 | SLOT(removeLinks()) ); | 70 | SLOT(removeLinks()) ); |
71 | connect( settings->createLinksButton, SIGNAL( clicked()), | 71 | connect( settings->createLinksButton, SIGNAL( clicked()), |
72 | SLOT(createLinks()) ); | 72 | SLOT(createLinks()) ); |
73 | 73 | ||
74 | pvDebug(9,"displayList"); | 74 | pvDebug(9,"displayList"); |
75 | displayList(); | 75 | displayList(); |
76 | } | 76 | } |
77 | 77 | ||
78 | void MainWindow::makeMenu() | 78 | void MainWindow::makeMenu() |
79 | { | 79 | { |
80 | 80 | ||
81 | QPEToolBar *toolBar = new QPEToolBar( this ); | 81 | QPEToolBar *toolBar = new QPEToolBar( this ); |
82 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | 82 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); |
83 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); | 83 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); |
84 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 84 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
85 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 85 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
86 | QPopupMenu *helpMenu = new QPopupMenu( menuBar ); | 86 | QPopupMenu *helpMenu = new QPopupMenu( menuBar ); |
87 | 87 | ||
88 | setToolBarsMovable( false ); | 88 | setToolBarsMovable( false ); |
89 | toolBar->setHorizontalStretchable( true ); | 89 | toolBar->setHorizontalStretchable( true ); |
90 | menuBar->insertItem( tr( "Package" ), srvMenu ); | 90 | menuBar->insertItem( tr( "Package" ), srvMenu ); |
91 | menuBar->insertItem( tr( "View" ), viewMenu ); | 91 | menuBar->insertItem( tr( "View" ), viewMenu ); |
92 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 92 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
93 | menuBar->insertItem( tr( "Help" ), helpMenu ); | 93 | menuBar->insertItem( tr( "Help" ), helpMenu ); |
94 | 94 | ||
95 | QLabel *spacer; | 95 | QLabel *spacer; |
96 | // spacer = new QLabel( "", toolBar ); | 96 | // spacer = new QLabel( "", toolBar ); |
97 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); | 97 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); |
98 | // toolBar->setStretchableWidget( spacer ); | 98 | // toolBar->setStretchableWidget( spacer ); |
99 | 99 | ||
100 | 100 | ||
101 | runAction = new QAction( tr( "Apply" ), | 101 | runAction = new QAction( tr( "Apply" ), |
102 | Resource::loadPixmap( "oipkg/install" ), | 102 | Resource::loadPixmap( "oipkg/install" ), |
103 | QString::null, 0, this, 0 ); | 103 | QString::null, 0, this, 0 ); |
104 | connect( runAction, SIGNAL( activated() ), | 104 | connect( runAction, SIGNAL( activated() ), |
105 | this, SLOT( runIpkg() ) ); | 105 | this, SLOT( runIpkg() ) ); |
106 | runAction->addTo( toolBar ); | 106 | runAction->addTo( toolBar ); |
107 | runAction->addTo( srvMenu ); | 107 | runAction->addTo( srvMenu ); |
108 | 108 | ||
109 | srvMenu->insertSeparator(); | 109 | srvMenu->insertSeparator(); |
110 | 110 | ||
111 | updateAction = new QAction( tr( "Update" ), | 111 | updateAction = new QAction( tr( "Update" ), |
112 | Resource::loadIconSet( "oipkg/update" ), | 112 | Resource::loadIconSet( "oipkg/update" ), |
113 | QString::null, 0, this, 0 ); | 113 | QString::null, 0, this, 0 ); |
114 | connect( updateAction, SIGNAL( activated() ), | 114 | connect( updateAction, SIGNAL( activated() ), |
115 | this , SLOT( updateList() ) ); | 115 | this , SLOT( updateList() ) ); |
116 | updateAction->addTo( toolBar ); | 116 | updateAction->addTo( toolBar ); |
117 | updateAction->addTo( srvMenu ); | 117 | updateAction->addTo( srvMenu ); |
118 | 118 | ||
119 | QAction *cfgact; | 119 | QAction *cfgact; |
120 | 120 | ||
121 | cfgact = new QAction( tr( "Setups" ), | 121 | cfgact = new QAction( tr( "Setups" ), |
122 | QString::null, 0, this, 0 ); | 122 | QString::null, 0, this, 0 ); |
123 | connect( cfgact, SIGNAL( activated() ), | 123 | connect( cfgact, SIGNAL( activated() ), |
124 | SLOT( showSettings() ) ); | 124 | SLOT( showSettings() ) ); |
125 | cfgact->addTo( cfgMenu ); | 125 | cfgact->addTo( cfgMenu ); |
126 | 126 | ||
127 | cfgact = new QAction( tr( "Servers" ), | 127 | cfgact = new QAction( tr( "Servers" ), |
128 | QString::null, 0, this, 0 ); | 128 | QString::null, 0, this, 0 ); |
129 | connect( cfgact, SIGNAL( activated() ), | 129 | connect( cfgact, SIGNAL( activated() ), |
130 | SLOT( showSettingsSrv() ) ); | 130 | SLOT( showSettingsSrv() ) ); |
131 | cfgact->addTo( cfgMenu ); | 131 | cfgact->addTo( cfgMenu ); |
132 | cfgact = new QAction( tr( "Destinations" ), | 132 | cfgact = new QAction( tr( "Destinations" ), |
133 | QString::null, 0, this, 0 ); | 133 | QString::null, 0, this, 0 ); |
134 | connect( cfgact, SIGNAL( activated() ), | 134 | connect( cfgact, SIGNAL( activated() ), |
135 | SLOT( showSettingsDst() ) ); | 135 | SLOT( showSettingsDst() ) ); |
136 | cfgact->addTo( cfgMenu ); | 136 | cfgact->addTo( cfgMenu ); |
137 | 137 | ||
138 | QAction *a; | 138 | QAction *a; |
139 | 139 | ||
140 | // SECTIONS | 140 | // SECTIONS |
141 | sectionBar = new QPEToolBar( this ); | 141 | sectionBar = new QPEToolBar( this ); |
142 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); | 142 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); |
143 | sectionBar->setHorizontalStretchable( true ); | 143 | sectionBar->setHorizontalStretchable( true ); |
144 | QLabel *label = new QLabel( tr("Section: "), sectionBar ); | 144 | QLabel *label = new QLabel( tr("Section: "), sectionBar ); |
145 | label->setBackgroundColor( sectionBar->backgroundColor() ); | 145 | label->setBackgroundColor( sectionBar->backgroundColor() ); |
146 | section = new QComboBox( false, sectionBar ); | 146 | section = new QComboBox( false, sectionBar ); |
147 | label = new QLabel( " / ", sectionBar ); | 147 | label = new QLabel( " / ", sectionBar ); |
148 | label->setBackgroundColor( sectionBar->backgroundColor() ); | 148 | label->setBackgroundColor( sectionBar->backgroundColor() ); |
149 | subsection = new QComboBox( false, sectionBar ); | 149 | subsection = new QComboBox( false, sectionBar ); |
150 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 150 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
151 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); | 151 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); |
152 | a->addTo( sectionBar ); | 152 | a->addTo( sectionBar ); |
153 | setSections(); | 153 | setSections(); |
154 | setSubSections(); | 154 | setSubSections(); |
155 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); | 155 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); |
156 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); | 156 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); |
157 | sectionAction->setToggleAction( true ); | 157 | sectionAction->setToggleAction( true ); |
158 | sectionAction->addTo( viewMenu ); | 158 | sectionAction->addTo( viewMenu ); |
159 | sectionBar->setStretchableWidget( section ); | 159 | sectionBar->setStretchableWidget( section ); |
160 | 160 | ||
161 | //FIND | 161 | //FIND |
162 | findBar = new QPEToolBar(this); | 162 | findBar = new QPEToolBar(this); |
163 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); | 163 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); |
164 | label = new QLabel( tr("Filter: "), findBar ); | 164 | label = new QLabel( tr("Filter: "), findBar ); |
165 | label->setBackgroundColor( findBar->backgroundColor() ); | 165 | label->setBackgroundColor( findBar->backgroundColor() ); |
166 | findBar->setHorizontalStretchable( TRUE ); | 166 | findBar->setHorizontalStretchable( TRUE ); |
167 | findEdit = new QLineEdit( findBar, "findEdit" ); | 167 | findEdit = new QLineEdit( findBar, "findEdit" ); |
168 | findBar->setStretchableWidget( findEdit ); | 168 | findBar->setStretchableWidget( findEdit ); |
169 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), | 169 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), |
170 | this, SLOT( displayList() ) ); | 170 | this, SLOT( displayList() ) ); |
171 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 171 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
172 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); | 172 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); |
173 | a->addTo( findBar ); | 173 | a->addTo( findBar ); |
174 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 174 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
175 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 175 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
176 | a->addTo( findBar ); | 176 | a->addTo( findBar ); |
177 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); | 177 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); |
178 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); | 178 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); |
179 | findAction->setToggleAction( true ); | 179 | findAction->setToggleAction( true ); |
180 | findAction->addTo( viewMenu ); | 180 | findAction->addTo( viewMenu ); |
181 | 181 | ||
182 | //SEARCH | 182 | //SEARCH |
183 | searchBar = new QPEToolBar(this); | 183 | searchBar = new QPEToolBar(this); |
184 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 184 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
185 | label = new QLabel( tr("ipkgfind: "), searchBar ); | 185 | label = new QLabel( tr("ipkgfind: "), searchBar ); |
186 | label->setBackgroundColor( searchBar->backgroundColor() ); | 186 | label->setBackgroundColor( searchBar->backgroundColor() ); |
187 | searchBar->setHorizontalStretchable( TRUE ); | 187 | searchBar->setHorizontalStretchable( TRUE ); |
188 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 188 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
189 | searchBar->setStretchableWidget( searchEdit ); | 189 | searchBar->setStretchableWidget( searchEdit ); |
190 | // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 190 | // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
191 | // this, SLOT( displayList() ) ); | 191 | // this, SLOT( displayList() ) ); |
192 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 192 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
193 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); | 193 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); |
194 | a->addTo( searchBar ); | 194 | a->addTo( searchBar ); |
195 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 195 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
196 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); | 196 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); |
197 | searchCommit->addTo( searchBar ); | 197 | searchCommit->addTo( searchBar ); |
198 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 198 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
199 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); |
200 | a->addTo( searchBar ); | 200 | a->addTo( searchBar ); |
201 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); | 201 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); |
202 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); | 202 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); |
203 | searchAction->setToggleAction( true ); | 203 | searchAction->setToggleAction( true ); |
204 | searchAction->addTo( viewMenu ); | 204 | searchAction->addTo( viewMenu ); |
205 | 205 | ||
206 | //DEST | 206 | //DEST |
207 | destBar = new QPEToolBar(this); | 207 | destBar = new QPEToolBar(this); |
208 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); | 208 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); |
209 | label = new QLabel( tr("Destination: "), destBar ); | 209 | label = new QLabel( tr("Destination: "), destBar ); |
210 | label->setBackgroundColor( destBar->backgroundColor() ); | 210 | label->setBackgroundColor( destBar->backgroundColor() ); |
211 | destBar->setHorizontalStretchable( TRUE ); | 211 | destBar->setHorizontalStretchable( TRUE ); |
212 | destination = new QComboBox( false, destBar ); | 212 | destination = new QComboBox( false, destBar ); |
213 | destination->insertStringList( settings->getDestinationNames() ); | 213 | destination->insertStringList( settings->getDestinationNames() ); |
214 | setComboName(destination,settings->getDestinationName()); | 214 | setComboName(destination,settings->getDestinationName()); |
215 | connect( destination, SIGNAL(activated(int)), | 215 | connect( destination, SIGNAL(activated(int)), |
216 | settings, SLOT(activeDestinationChange(int)) ); | 216 | settings, SLOT(activeDestinationChange(int)) ); |
217 | spacer = new QLabel( " ", destBar ); | 217 | spacer = new QLabel( " ", destBar ); |
218 | spacer->setBackgroundColor( destBar->backgroundColor() ); | 218 | spacer->setBackgroundColor( destBar->backgroundColor() ); |
219 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); | 219 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); |
220 | CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); | 220 | CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); |
221 | CheckBoxLink->setChecked( settings->createLinks() ); | 221 | CheckBoxLink->setChecked( settings->createLinks() ); |
222 | connect( CheckBoxLink, SIGNAL(toggled(bool)), | 222 | connect( CheckBoxLink, SIGNAL(toggled(bool)), |
223 | settings, SLOT(linkEnabled(bool)) ); | 223 | settings, SLOT(linkEnabled(bool)) ); |
224 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); | 224 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); |
225 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); | 225 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); |
226 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 226 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
227 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); | 227 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); |
228 | a->addTo( destBar ); | 228 | a->addTo( destBar ); |
229 | destBar->setStretchableWidget( CheckBoxLink ); | 229 | destBar->setStretchableWidget( CheckBoxLink ); |
230 | destAction->setToggleAction( true ); | 230 | destAction->setToggleAction( true ); |
231 | // destAction->addTo( viewMenu ); | 231 | // destAction->addTo( viewMenu ); |
232 | 232 | ||
233 | // helpMenu | 233 | // helpMenu |
234 | helpMenu->insertSeparator(); | 234 | helpMenu->insertSeparator(); |
235 | a = new QAction( tr( "Package Actions" ), QString::null, 0, this, 0 ); | 235 | a = new QAction( tr( "Package Actions" ), QString::null, 0, this, 0 ); |
236 | a->addTo( helpMenu ); | 236 | a->addTo( helpMenu ); |
237 | helpMenu->insertSeparator(); | 237 | helpMenu->insertSeparator(); |
238 | a = new QAction( tr( "Install" ), | 238 | a = new QAction( tr( "Install" ), |
239 | Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); | 239 | Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); |
240 | a->addTo( helpMenu ); | 240 | a->addTo( helpMenu ); |
241 | a = new QAction( tr( "Remove" ), | 241 | a = new QAction( tr( "Remove" ), |
242 | Resource::loadPixmap( "oipkg/uninstall" ), QString::null, 0, this, 0 ); | 242 | Resource::loadPixmap( "oipkg/uninstall" ), QString::null, 0, this, 0 ); |
243 | a->addTo( helpMenu ); | 243 | a->addTo( helpMenu ); |
244 | helpMenu->insertSeparator(); | 244 | helpMenu->insertSeparator(); |
245 | a = new QAction( tr( "Package Status" ), QString::null, 0, this, 0 ); | 245 | a = new QAction( tr( "Package Status" ), QString::null, 0, this, 0 ); |
246 | a->addTo( helpMenu ); | 246 | a->addTo( helpMenu ); |
247 | helpMenu->insertSeparator(); | 247 | helpMenu->insertSeparator(); |
248 | a = new QAction( tr( "New version, installed" ), | 248 | a = new QAction( tr( "New version, installed" ), |
249 | Resource::loadPixmap( "oipkg/installed" ), QString::null, 0, this, 0 ); | 249 | Resource::loadPixmap( "oipkg/installed" ), QString::null, 0, this, 0 ); |
250 | a->addTo( helpMenu ); | 250 | a->addTo( helpMenu ); |
251 | a = new QAction( tr( "New version, not installed" ), | 251 | a = new QAction( tr( "New version, not installed" ), |
252 | Resource::loadPixmap( "oipkg/uninstalled" ), QString::null, 0, this, 0 ); | 252 | Resource::loadPixmap( "oipkg/uninstalled" ), QString::null, 0, this, 0 ); |
253 | a->addTo( helpMenu ); | 253 | a->addTo( helpMenu ); |
254 | a = new QAction( tr( "Old version, installed" ), | 254 | a = new QAction( tr( "Old version, installed" ), |
255 | Resource::loadPixmap( "oipkg/installedOld" ), QString::null, 0, this, 0 ); | 255 | Resource::loadPixmap( "oipkg/installedOld" ), QString::null, 0, this, 0 ); |
256 | a->addTo( helpMenu ); | 256 | a->addTo( helpMenu ); |
257 | a = new QAction( tr( "Old version, not installed" ), | 257 | a = new QAction( tr( "Old version, not installed" ), |
258 | Resource::loadPixmap( "oipkg/uninstalledOld" ), QString::null, 0, this, 0 ); | 258 | Resource::loadPixmap( "oipkg/uninstalledOld" ), QString::null, 0, this, 0 ); |
259 | a->addTo( helpMenu ); | 259 | a->addTo( helpMenu ); |
260 | a = new QAction( tr( "Old version, new version installed" ), | 260 | a = new QAction( tr( "Old version, new version installed" ), |
261 | Resource::loadPixmap( "oipkg/uninstalledOldinstalledNew" ), QString::null, 0, this, 0 ); | 261 | Resource::loadPixmap( "oipkg/uninstalledOldinstalledNew" ), QString::null, 0, this, 0 ); |
262 | a->addTo( helpMenu ); | 262 | a->addTo( helpMenu ); |
263 | a = new QAction( tr( "New version, old version installed" ), | 263 | a = new QAction( tr( "New version, old version installed" ), |
264 | Resource::loadPixmap( "oipkg/uninstalledInstalledOld" ), QString::null, 0, this, 0 ); | 264 | Resource::loadPixmap( "oipkg/uninstalledInstalledOld" ), QString::null, 0, this, 0 ); |
265 | a->addTo( helpMenu ); | 265 | a->addTo( helpMenu ); |
266 | //a = new QAction( tr( "" ), | 266 | //a = new QAction( tr( "" ), |
267 | // Resource::loadPixmap( "oipkg/" ), QString::null, 0, this, 0 ); | 267 | // Resource::loadPixmap( "oipkg/" ), QString::null, 0, this, 0 ); |
268 | // a->addTo( helpMenu ); | 268 | // a->addTo( helpMenu ); |
269 | 269 | ||
270 | // configure the menus | 270 | // configure the menus |
271 | Config cfg( "oipkg", Config::User ); | 271 | Config cfg( "oipkg", Config::User ); |
272 | cfg.setGroup( "gui" ); | 272 | cfg.setGroup( "gui" ); |
273 | 273 | ||
274 | findShow( cfg.readBoolEntry( "findBar", true ) ); | 274 | findShow( cfg.readBoolEntry( "findBar", true ) ); |
275 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); | 275 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); |
276 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); | 276 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); |
277 | destShow( cfg.readBoolEntry( "destBar", false ) ); | 277 | destShow( cfg.readBoolEntry( "destBar", false ) ); |
278 | } | 278 | } |
279 | 279 | ||
280 | MainWindow::~MainWindow() | 280 | MainWindow::~MainWindow() |
281 | { | 281 | { |
282 | Config cfg( "oipkg", Config::User ); | 282 | Config cfg( "oipkg", Config::User ); |
283 | cfg.setGroup( "gui" ); | 283 | cfg.setGroup( "gui" ); |
284 | cfg.writeEntry( "findBar", !findBar->isHidden() ); | 284 | cfg.writeEntry( "findBar", !findBar->isHidden() ); |
285 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); | 285 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); |
286 | cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); | 286 | cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); |
287 | cfg.writeEntry( "destBar", !destBar->isHidden() ); | 287 | cfg.writeEntry( "destBar", !destBar->isHidden() ); |
288 | 288 | ||
289 | } | 289 | } |
290 | 290 | ||
291 | void MainWindow::runIpkg() | 291 | void MainWindow::runIpkg() |
292 | { | 292 | { |
293 | packageListServers.allPackages(); | 293 | packageListServers.allPackages(); |
294 | ipkg->loadList( &packageListSearch ); | 294 | ipkg->loadList( &packageListSearch ); |
295 | //ipkg->loadList( &packageListDocLnk ); | 295 | //ipkg->loadList( &packageListDocLnk ); |
296 | ipkg->loadList( &packageListServers ); | 296 | ipkg->loadList( &packageListServers ); |
297 | ipkg->commit(); | 297 | ipkg->commit(); |
298 | ipkg->clearLists(); | 298 | ipkg->clearLists(); |
299 | // ##### If we looked in the list of files, we could send out accurate | 299 | // ##### If we looked in the list of files, we could send out accurate |
300 | // ##### messages. But we don't bother yet, and just do an "all". | 300 | // ##### messages. But we don't bother yet, and just do an "all". |
301 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 301 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
302 | QString lf = QString::null; | 302 | QString lf = QString::null; |
303 | e << lf; | 303 | e << lf; |
304 | displayList(); | 304 | displayList(); |
305 | } | 305 | } |
306 | 306 | ||
307 | void MainWindow::updateList() | 307 | void MainWindow::updateList() |
308 | { | 308 | { |
309 | packageListServers.clear(); | 309 | packageListServers.clear(); |
310 | packageListSearch.clear(); | 310 | packageListSearch.clear(); |
311 | 311 | ||
312 | // packageListDocLnk.clear(); | 312 | // packageListDocLnk.clear(); |
313 | ipkg->update(); | 313 | ipkg->update(); |
314 | packageListServers.update(); | 314 | packageListServers.update(); |
315 | packageListSearch.update(); | 315 | packageListSearch.update(); |
316 | // packageListDocLnk.update(); | 316 | // packageListDocLnk.update(); |
317 | } | 317 | } |
318 | 318 | ||
319 | void MainWindow::filterList() | 319 | void MainWindow::filterList() |
320 | { | 320 | { |
321 | QString f = ""; | 321 | QString f = ""; |
322 | if ( findAction->isOn() ) f = findEdit->text(); | 322 | if ( findAction->isOn() ) f = findEdit->text(); |
323 | packageListServers.filterPackages( f ); | 323 | packageListServers.filterPackages( f ); |
324 | } | 324 | } |
325 | 325 | ||
326 | void MainWindow::displayList() | 326 | void MainWindow::displayList() |
327 | { | 327 | { |
328 | filterList(); | 328 | filterList(); |
329 | listViewPackages->display(); | 329 | listViewPackages->display(); |
330 | } | 330 | } |
331 | 331 | ||
332 | void MainWindow::sectionChanged() | 332 | void MainWindow::sectionChanged() |
333 | { | 333 | { |
334 | disconnect( section, SIGNAL( activated(int) ), | 334 | disconnect( section, SIGNAL( activated(int) ), |
335 | this, SLOT( sectionChanged() ) ); | 335 | this, SLOT( sectionChanged() ) ); |
336 | disconnect( subsection, SIGNAL(activated(int) ), | 336 | disconnect( subsection, SIGNAL(activated(int) ), |
337 | this, SLOT( subSectionChanged() ) ); | 337 | this, SLOT( subSectionChanged() ) ); |
338 | subsection->clear(); | 338 | subsection->clear(); |
339 | packageListServers.setSection( section->currentText() ); | 339 | packageListServers.setSection( section->currentText() ); |
340 | setSubSections(); | 340 | setSubSections(); |
341 | connect( section, SIGNAL( activated(int) ), | 341 | connect( section, SIGNAL( activated(int) ), |
342 | this, SLOT( sectionChanged() ) ); | 342 | this, SLOT( sectionChanged() ) ); |
343 | connect( subsection, SIGNAL(activated(int) ), | 343 | connect( subsection, SIGNAL(activated(int) ), |
344 | this, SLOT( subSectionChanged() ) ); | 344 | this, SLOT( subSectionChanged() ) ); |
345 | displayList(); | 345 | displayList(); |
346 | } | 346 | } |
347 | 347 | ||
348 | void MainWindow::subSectionChanged() | 348 | void MainWindow::subSectionChanged() |
349 | { | 349 | { |
350 | disconnect( section, SIGNAL( activated(int) ), | 350 | disconnect( section, SIGNAL( activated(int) ), |
351 | this, SLOT( sectionChanged() ) ); | 351 | this, SLOT( sectionChanged() ) ); |
352 | disconnect( subsection, SIGNAL(activated(int) ), | 352 | disconnect( subsection, SIGNAL(activated(int) ), |
353 | this, SLOT( subSectionChanged() ) ); | 353 | this, SLOT( subSectionChanged() ) ); |
354 | packageListServers.setSubSection( subsection->currentText() ); | 354 | packageListServers.setSubSection( subsection->currentText() ); |
355 | connect( section, SIGNAL( activated(int) ), | 355 | connect( section, SIGNAL( activated(int) ), |
356 | this, SLOT( sectionChanged() ) ); | 356 | this, SLOT( sectionChanged() ) ); |
357 | connect( subsection, SIGNAL(activated(int) ), | 357 | connect( subsection, SIGNAL(activated(int) ), |
358 | this, SLOT( subSectionChanged() ) ); | 358 | this, SLOT( subSectionChanged() ) ); |
359 | displayList(); | 359 | displayList(); |
360 | } | 360 | } |
361 | 361 | ||
362 | void MainWindow::setSections() | 362 | void MainWindow::setSections() |
363 | { | 363 | { |
364 | section->clear(); | 364 | section->clear(); |
365 | section->insertStringList( packageListServers.getSections() ); | 365 | section->insertStringList( packageListServers.getSections() ); |
366 | } | 366 | } |
367 | 367 | ||
368 | void MainWindow::setSubSections() | 368 | void MainWindow::setSubSections() |
369 | { | 369 | { |
370 | subsection->clear(); | 370 | subsection->clear(); |
371 | subsection->insertStringList( packageListServers.getSubSections() ); | 371 | subsection->insertStringList( packageListServers.getSubSections() ); |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | void MainWindow::showSettings() | 375 | void MainWindow::showSettings() |
376 | { | 376 | { |
377 | if ( settings->showDialog( 0 ) ) | 377 | if ( settings->showDialog( 0 ) ) |
378 | updateList(); | 378 | updateList(); |
379 | } | 379 | } |
380 | void MainWindow::showSettingsSrv() | 380 | void MainWindow::showSettingsSrv() |
381 | { | 381 | { |
382 | if ( settings->showDialog( 1 ) ) | 382 | if ( settings->showDialog( 1 ) ) |
383 | updateList(); | 383 | updateList(); |
384 | } | 384 | } |
385 | void MainWindow::showSettingsDst() | 385 | void MainWindow::showSettingsDst() |
386 | { | 386 | { |
387 | if ( settings->showDialog( 2 ) ) | 387 | if ( settings->showDialog( 2 ) ) |
388 | updateList(); | 388 | updateList(); |
389 | } | 389 | } |
390 | 390 | ||
391 | void MainWindow::sectionShow(bool b) | 391 | void MainWindow::sectionShow(bool b) |
392 | { | 392 | { |
393 | if (b) sectionBar->show(); | 393 | if (b) sectionBar->show(); |
394 | else sectionBar->hide(); | 394 | else sectionBar->hide(); |
395 | sectionAction->setOn( b ); | 395 | sectionAction->setOn( b ); |
396 | } | 396 | } |
397 | 397 | ||
398 | void MainWindow::sectionClose() | 398 | void MainWindow::sectionClose() |
399 | { | 399 | { |
400 | sectionAction->setOn( false ); | 400 | sectionAction->setOn( false ); |
401 | } | 401 | } |
402 | 402 | ||
403 | void MainWindow::findShow(bool b) | 403 | void MainWindow::findShow(bool b) |
404 | { | 404 | { |
405 | if (b) findBar->show(); | 405 | if (b) findBar->show(); |
406 | else findBar->hide(); | 406 | else findBar->hide(); |
407 | findAction->setOn( b ); | 407 | findAction->setOn( b ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void MainWindow::findClose() | 410 | void MainWindow::findClose() |
411 | { | 411 | { |
412 | findAction->setOn( false ); | 412 | findAction->setOn( false ); |
413 | } | 413 | } |
414 | 414 | ||
415 | void MainWindow::searchShow(bool b) | 415 | void MainWindow::searchShow(bool b) |
416 | { | 416 | { |
417 | if (b) searchBar->show(); | 417 | if (b) searchBar->show(); |
418 | else searchBar->hide(); | 418 | else searchBar->hide(); |
419 | searchAction->setOn( b ); | 419 | searchAction->setOn( b ); |
420 | } | 420 | } |
421 | 421 | ||
422 | void MainWindow::searchClose() | 422 | void MainWindow::searchClose() |
423 | { | 423 | { |
424 | searchAction->setOn( false ); | 424 | searchAction->setOn( false ); |
425 | } | 425 | } |
426 | 426 | ||
427 | 427 | ||
428 | void MainWindow::destShow(bool b) | 428 | void MainWindow::destShow(bool b) |
429 | { | 429 | { |
430 | if (b) destBar->show(); | 430 | if (b) destBar->show(); |
431 | else destBar->hide(); | 431 | else destBar->hide(); |
432 | destAction->setOn( b ); | 432 | destAction->setOn( b ); |
433 | } | 433 | } |
434 | 434 | ||
435 | void MainWindow::destClose() | 435 | void MainWindow::destClose() |
436 | { | 436 | { |
437 | destAction->setOn( false ); | 437 | destAction->setOn( false ); |
438 | } | 438 | } |
439 | 439 | ||
440 | void MainWindow::setDocument(const QString &fileName) | 440 | void MainWindow::setDocument(const QString &fileName) |
441 | { | 441 | { |
442 | if ( !QFile::exists( fileName ) ) return; | 442 | if ( !QFile::exists( fileName ) ) return; |
443 | ipkg->installFile( fileName ); | 443 | ipkg->installFile( fileName ); |
444 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 444 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
445 | QString lf = QString::null; | 445 | QString lf = QString::null; |
446 | e << lf; | 446 | e << lf; |
447 | } | 447 | } |
448 | 448 | ||
449 | 449 | ||
450 | void MainWindow::makeChannel() | 450 | void MainWindow::makeChannel() |
451 | { | 451 | { |
452 | channel = new QCopChannel( "QPE/Application/oipkg", this ); | 452 | channel = new QCopChannel( "QPE/Application/oipkg", this ); |
453 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 453 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
454 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 454 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | 458 | ||
459 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) | 459 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) |
460 | { | 460 | { |
461 | pvDebug(3, "QCop "+msg+" "+QCString(arg)); | 461 | pvDebug(3, "QCop "+msg+" "+QCString(arg)); |
462 | if ( msg == "installFile(QString)" ) | 462 | if ( msg == "installFile(QString)" ) |
463 | { | 463 | { |
464 | ipkg->installFile( QString(arg) ); | 464 | ipkg->installFile( QString(arg) ); |
465 | }else if( msg == "removeFile(QString)" ) | 465 | }else if( msg == "removeFile(QString)" ) |
466 | { | 466 | { |
467 | ipkg->removeFile( QString(arg) ); | 467 | ipkg->removeFile( QString(arg) ); |
468 | }else if( msg == "createLinks(QString)" ) | 468 | }else if( msg == "createLinks(QString)" ) |
469 | { | 469 | { |
470 | ipkg->createLinks( QString(arg) ); | 470 | ipkg->createLinks( QString(arg) ); |
471 | }else if( msg == "removeLinks(QString)" ) | 471 | }else if( msg == "removeLinks(QString)" ) |
472 | { | 472 | { |
473 | ipkg->removeLinks( QString(arg) ); | 473 | ipkg->removeLinks( QString(arg) ); |
474 | }else{ | 474 | }else{ |
475 | pvDebug(2,"Huh what do ya want") | 475 | pvDebug(2,"Huh what do ya want") |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | 479 | ||
480 | void MainWindow::createLinks() | 480 | void MainWindow::createLinks() |
481 | { | 481 | { |
482 | pvDebug(2,"creating links..."); | 482 | pvDebug(2,"creating links..."); |
483 | ipkg->createLinks( settings->destinationurl->text() ); | 483 | ipkg->createLinks( settings->destinationurl->text() ); |
484 | } | 484 | } |
485 | 485 | ||
486 | void MainWindow::removeLinks() | 486 | void MainWindow::removeLinks() |
487 | { | 487 | { |
488 | pvDebug(2,"removing links..."); | 488 | pvDebug(2,"removing links..."); |
489 | ipkg->removeLinks( settings->destinationurl->text() ); | 489 | ipkg->removeLinks( settings->destinationurl->text() ); |
490 | } | 490 | } |
491 | 491 | ||
492 | void MainWindow::remotePackageQuery() | 492 | void MainWindow::remotePackageQuery() |
493 | { | 493 | { |
494 | packageListSearch.query( searchEdit->text() ); | 494 | packageListSearch.query( searchEdit->text() ); |
495 | packageListSearch.update(); | 495 | packageListSearch.update(); |
496 | displayList(); | 496 | displayList(); |
497 | } | 497 | } |
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 97f7813..517b37a 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp | |||
@@ -1,453 +1,453 @@ | |||
1 | #include "package.h" | 1 | #include "package.h" |
2 | 2 | ||
3 | #include <qpe/process.h> | 3 | #include <qpe/process.h> |
4 | #include <qpe/stringutil.h> | 4 | #include <qpe/stringutil.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | #include "debug.h" | 10 | #include "debug.h" |
11 | 11 | ||
12 | Package::Package( QObject *parent=0, const char *name=0 ) | 12 | Package::Package( QObject *parent, const char *name ) |
13 | : QObject(parent,name) | 13 | : QObject(parent,name) |
14 | { | 14 | { |
15 | 15 | ||
16 | } | 16 | } |
17 | 17 | ||
18 | Package::~Package() | 18 | Package::~Package() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | Package::Package( PackageManagerSettings *s, QObject *parent=0, const char *name=0 ) | 22 | Package::Package( PackageManagerSettings *s, QObject *parent, const char *name ) |
23 | : QObject(parent,name) | 23 | : QObject(parent,name) |
24 | { | 24 | { |
25 | Package(parent,name); | 25 | Package(parent,name); |
26 | init(s); | 26 | init(s); |
27 | } | 27 | } |
28 | 28 | ||
29 | void Package::init( PackageManagerSettings *s ) | 29 | void Package::init( PackageManagerSettings *s ) |
30 | { | 30 | { |
31 | settings = s; | 31 | settings = s; |
32 | _size = ""; | 32 | _size = ""; |
33 | _section = ""; | 33 | _section = ""; |
34 | _subsection = ""; | 34 | _subsection = ""; |
35 | _shortDesc = ""; | 35 | _shortDesc = ""; |
36 | _desc = ""; | 36 | _desc = ""; |
37 | _name = ""; | 37 | _name = ""; |
38 | _toProcess = false; | 38 | _toProcess = false; |
39 | _useFileName = false; | 39 | _useFileName = false; |
40 | _old = false; | 40 | _old = false; |
41 | _status = ""; | 41 | _status = ""; |
42 | _dest = settings->getDestinationName(); | 42 | _dest = settings->getDestinationName(); |
43 | _link = settings->createLinks(); | 43 | _link = settings->createLinks(); |
44 | _versions=0; | 44 | _versions=0; |
45 | _version=""; | 45 | _version=""; |
46 | } | 46 | } |
47 | 47 | ||
48 | Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent=0, const char *name=0 ) | 48 | Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) |
49 | : QObject(parent,name) | 49 | : QObject(parent,name) |
50 | { | 50 | { |
51 | init(s); | 51 | init(s); |
52 | parsePackage( pack ); | 52 | parsePackage( pack ); |
53 | } | 53 | } |
54 | 54 | ||
55 | Package::Package( QString n, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ) | 55 | Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) |
56 | { | 56 | { |
57 | init(s); | 57 | init(s); |
58 | if ( !QFile::exists( n ) ) | 58 | if ( !QFile::exists( n ) ) |
59 | { | 59 | { |
60 | _name = QString( n ); | 60 | _name = QString( n ); |
61 | }else{ | 61 | }else{ |
62 | pvDebug(4,"remote file: "+n); | 62 | pvDebug(4,"remote file: "+n); |
63 | parseIpkgFile( n ); | 63 | parseIpkgFile( n ); |
64 | _useFileName = true; | 64 | _useFileName = true; |
65 | _fileName = QString( n ); | 65 | _fileName = QString( n ); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | Package::Package( Package *pi, QObject *parent=0, const char *name=0 ) | 69 | Package::Package( Package *pi, QObject *parent, const char *name ) |
70 | { | 70 | { |
71 | init(pi->settings); | 71 | init(pi->settings); |
72 | copyValues( pi ); | 72 | copyValues( pi ); |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | void Package::setValue( QString n, QString t ) | 76 | void Package::setValue( QString n, QString t ) |
77 | { | 77 | { |
78 | if ( n == "Package" ) | 78 | if ( n == "Package" ) |
79 | { | 79 | { |
80 | _name = QString( t ); | 80 | _name = QString( t ); |
81 | }else if ( n == "Installed-Size" ) | 81 | }else if ( n == "Installed-Size" ) |
82 | { | 82 | { |
83 | _size = t; | 83 | _size = t; |
84 | // }else if ( n == "Priority") | 84 | // }else if ( n == "Priority") |
85 | // { | 85 | // { |
86 | 86 | ||
87 | }else if ( n == "Section") | 87 | }else if ( n == "Section") |
88 | { | 88 | { |
89 | setSection( t ); | 89 | setSection( t ); |
90 | // }else if ( n == "Maintainer") | 90 | // }else if ( n == "Maintainer") |
91 | // { | 91 | // { |
92 | // | 92 | // |
93 | // }else if ( n == "Architecture") | 93 | // }else if ( n == "Architecture") |
94 | // { | 94 | // { |
95 | 95 | ||
96 | }else if ( n == "Version") | 96 | }else if ( n == "Version") |
97 | { | 97 | { |
98 | _version = t; | 98 | _version = t; |
99 | // }else if ( n == "Pre-Depends") | 99 | // }else if ( n == "Pre-Depends") |
100 | // { | 100 | // { |
101 | // | 101 | // |
102 | // }else if ( n == "Depends") | 102 | // }else if ( n == "Depends") |
103 | // { | 103 | // { |
104 | 104 | ||
105 | }else if ( n == "Filename") | 105 | }else if ( n == "Filename") |
106 | { | 106 | { |
107 | _fileName = t; | 107 | _fileName = t; |
108 | // }else if ( n == "Size") | 108 | // }else if ( n == "Size") |
109 | // { | 109 | // { |
110 | // | 110 | // |
111 | //}else if ( n == "MD5Sum") | 111 | //}else if ( n == "MD5Sum") |
112 | //{ | 112 | //{ |
113 | 113 | ||
114 | }else if ( n == "Description") | 114 | }else if ( n == "Description") |
115 | { | 115 | { |
116 | setDesc( t ); | 116 | setDesc( t ); |
117 | }else if ( n == "Status") | 117 | }else if ( n == "Status") |
118 | { | 118 | { |
119 | if ( installed() ) return; | 119 | if ( installed() ) return; |
120 | _status = t; | 120 | _status = t; |
121 | // }else if ( n == "Essential") | 121 | // }else if ( n == "Essential") |
122 | // { | 122 | // { |
123 | 123 | ||
124 | }else{ | 124 | }else{ |
125 | _values.insert(n,new QString(t)); | 125 | _values.insert(n,new QString(t)); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | QString Package::name() | 129 | QString Package::name() |
130 | { | 130 | { |
131 | if (_displayName.isEmpty() ) return _name; | 131 | if (_displayName.isEmpty() ) return _name; |
132 | else return _displayName; | 132 | else return _displayName; |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | QString Package::installName() | 136 | QString Package::installName() |
137 | { | 137 | { |
138 | if (_useFileName) return _fileName; | 138 | if (_useFileName) return _fileName; |
139 | else return _name; | 139 | else return _name; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool Package::installed() | 142 | bool Package::installed() |
143 | { | 143 | { |
144 | if (_status.contains("installed")) | 144 | if (_status.contains("installed")) |
145 | { | 145 | { |
146 | if (_status.contains("not-installed")) | 146 | if (_status.contains("not-installed")) |
147 | { | 147 | { |
148 | _toProcess = true; | 148 | _toProcess = true; |
149 | return false; | 149 | return false; |
150 | } | 150 | } |
151 | else return true; | 151 | else return true; |
152 | } | 152 | } |
153 | else | 153 | else |
154 | if (_versions) | 154 | if (_versions) |
155 | { | 155 | { |
156 | QDictIterator<Package> other( *_versions ); | 156 | QDictIterator<Package> other( *_versions ); |
157 | while ( other.current() ) | 157 | while ( other.current() ) |
158 | { | 158 | { |
159 | if (other.current()->status().contains("installed") | 159 | if (other.current()->status().contains("installed") |
160 | && other.current()->version() == version()) | 160 | && other.current()->version() == version()) |
161 | return true; | 161 | return true; |
162 | ++other; | 162 | ++other; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | return false; | 165 | return false; |
166 | } | 166 | } |
167 | 167 | ||
168 | bool Package::otherInstalled() | 168 | bool Package::otherInstalled() |
169 | { | 169 | { |
170 | if (_versions) | 170 | if (_versions) |
171 | { | 171 | { |
172 | QDictIterator<Package> other( *_versions ); | 172 | QDictIterator<Package> other( *_versions ); |
173 | while ( other.current() ) | 173 | while ( other.current() ) |
174 | { | 174 | { |
175 | if (other.current()->installed()) return true; | 175 | if (other.current()->installed()) return true; |
176 | ++other; | 176 | ++other; |
177 | } | 177 | } |
178 | } | 178 | } |
179 | return false; | 179 | return false; |
180 | } | 180 | } |
181 | 181 | ||
182 | void Package::setDesc( QString s ) | 182 | void Package::setDesc( QString s ) |
183 | { | 183 | { |
184 | _desc = s; | 184 | _desc = s; |
185 | _shortDesc = s.left( s.find("\n") ); | 185 | _shortDesc = s.left( s.find("\n") ); |
186 | } | 186 | } |
187 | 187 | ||
188 | QString Package::desc() | 188 | QString Package::desc() |
189 | { | 189 | { |
190 | return _desc; | 190 | return _desc; |
191 | } | 191 | } |
192 | 192 | ||
193 | QString Package::shortDesc() | 193 | QString Package::shortDesc() |
194 | { | 194 | { |
195 | return _shortDesc; | 195 | return _shortDesc; |
196 | } | 196 | } |
197 | 197 | ||
198 | QString Package::size() | 198 | QString Package::size() |
199 | { | 199 | { |
200 | return _size; | 200 | return _size; |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | QString Package::version() | 204 | QString Package::version() |
205 | { | 205 | { |
206 | return _version; | 206 | return _version; |
207 | } | 207 | } |
208 | 208 | ||
209 | QString Package::sizeUnits() | 209 | QString Package::sizeUnits() |
210 | { | 210 | { |
211 | int i = _size.toInt(); | 211 | int i = _size.toInt(); |
212 | int c = 0; | 212 | int c = 0; |
213 | QString ret; | 213 | QString ret; |
214 | QStringList unit; | 214 | QStringList unit; |
215 | unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) | 215 | unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) |
216 | while (i > 1) | 216 | while (i > 1) |
217 | { | 217 | { |
218 | ret=QString::number(i)+" "+unit[c]; | 218 | ret=QString::number(i)+" "+unit[c]; |
219 | c++; | 219 | c++; |
220 | i /= 1024; | 220 | i /= 1024; |
221 | } | 221 | } |
222 | return ret; | 222 | return ret; |
223 | } | 223 | } |
224 | 224 | ||
225 | bool Package::toProcess() | 225 | bool Package::toProcess() |
226 | { | 226 | { |
227 | return _toProcess; | 227 | return _toProcess; |
228 | } | 228 | } |
229 | 229 | ||
230 | bool Package::toRemove() | 230 | bool Package::toRemove() |
231 | { | 231 | { |
232 | if ( _toProcess && installed() ) return true; | 232 | if ( _toProcess && installed() ) return true; |
233 | else return false; | 233 | else return false; |
234 | } | 234 | } |
235 | 235 | ||
236 | bool Package::toInstall() | 236 | bool Package::toInstall() |
237 | { | 237 | { |
238 | if ( _toProcess && !installed() ) return true; | 238 | if ( _toProcess && !installed() ) return true; |
239 | else return false; | 239 | else return false; |
240 | } | 240 | } |
241 | 241 | ||
242 | void Package::toggleProcess() | 242 | void Package::toggleProcess() |
243 | { | 243 | { |
244 | _toProcess = ! _toProcess; | 244 | _toProcess = ! _toProcess; |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | 248 | ||
249 | void Package::copyValues( Package* pack ) | 249 | void Package::copyValues( Package* pack ) |
250 | { | 250 | { |
251 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); | 251 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); |
252 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); | 252 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); |
253 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); | 253 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); |
254 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); | 254 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); |
255 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); | 255 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); |
256 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); | 256 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); |
257 | if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); | 257 | if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); |
258 | if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); | 258 | if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); |
259 | if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); | 259 | if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); |
260 | if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); | 260 | if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); |
261 | if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); | 261 | if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); |
262 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); | 262 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); |
263 | } | 263 | } |
264 | 264 | ||
265 | QString Package::section() | 265 | QString Package::section() |
266 | { | 266 | { |
267 | return _section; | 267 | return _section; |
268 | } | 268 | } |
269 | 269 | ||
270 | void Package::setSection( QString s) | 270 | void Package::setSection( QString s) |
271 | { | 271 | { |
272 | int i = s.find("/"); | 272 | int i = s.find("/"); |
273 | if ( i > 0 ) | 273 | if ( i > 0 ) |
274 | { | 274 | { |
275 | _section = s.left(i); | 275 | _section = s.left(i); |
276 | _subsection = s.mid(i+1); | 276 | _subsection = s.mid(i+1); |
277 | }else{ | 277 | }else{ |
278 | _section = s; | 278 | _section = s; |
279 | _subsection = ""; | 279 | _subsection = ""; |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | QString Package::subSection() | 283 | QString Package::subSection() |
284 | { | 284 | { |
285 | return _subsection; | 285 | return _subsection; |
286 | } | 286 | } |
287 | 287 | ||
288 | void Package::parsePackage( QStringList pack ) | 288 | void Package::parsePackage( QStringList pack ) |
289 | { | 289 | { |
290 | if ( pack.isEmpty() ) return; | 290 | if ( pack.isEmpty() ) return; |
291 | int count = pack.count(); | 291 | int count = pack.count(); |
292 | for( int i = 0; i < count; i++ ) | 292 | for( int i = 0; i < count; i++ ) |
293 | { | 293 | { |
294 | QString line = pack[i]; | 294 | QString line = pack[i]; |
295 | int sep = line.find( QRegExp(":[\t ]+") ); | 295 | int sep = line.find( QRegExp(":[\t ]+") ); |
296 | if ( sep >= 0 ) | 296 | if ( sep >= 0 ) |
297 | { | 297 | { |
298 | QString tag = line.left(sep); | 298 | QString tag = line.left(sep); |
299 | QString value = line.mid(sep+2).simplifyWhiteSpace(); | 299 | QString value = line.mid(sep+2).simplifyWhiteSpace(); |
300 | setValue( tag, value ); | 300 | setValue( tag, value ); |
301 | }else{ | 301 | }else{ |
302 | } | 302 | } |
303 | } | 303 | } |
304 | return; | 304 | return; |
305 | } | 305 | } |
306 | 306 | ||
307 | QString Package::details() | 307 | QString Package::details() |
308 | { | 308 | { |
309 | QString status; | 309 | QString status; |
310 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); | 310 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); |
311 | QString description; | 311 | QString description; |
312 | if ( ipkg_status.exec("",status) ) | 312 | if ( ipkg_status.exec("",status) ) |
313 | { | 313 | { |
314 | QStringList lines = QStringList::split('\n',status,TRUE); | 314 | QStringList lines = QStringList::split('\n',status,TRUE); |
315 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { | 315 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { |
316 | QString line = *it; | 316 | QString line = *it; |
317 | if ( line == " ." ) | 317 | if ( line == " ." ) |
318 | { | 318 | { |
319 | description.append("<p>"); | 319 | description.append("<p>"); |
320 | } else | 320 | } else |
321 | if ( line[0] == ' ' || line[0] == '\t' ) | 321 | if ( line[0] == ' ' || line[0] == '\t' ) |
322 | { | 322 | { |
323 | // continuation | 323 | // continuation |
324 | description.append(" "); | 324 | description.append(" "); |
325 | description.append(Qtopia::escapeString(line)); | 325 | description.append(Qtopia::escapeString(line)); |
326 | } else { | 326 | } else { |
327 | int sep = line.find(QRegExp(":[\t ]+")); | 327 | int sep = line.find(QRegExp(":[\t ]+")); |
328 | if ( sep >= 0 ) | 328 | if ( sep >= 0 ) |
329 | { | 329 | { |
330 | QString tag = line.left(sep); | 330 | QString tag = line.left(sep); |
331 | description.append("<br>"); | 331 | description.append("<br>"); |
332 | description.append("<b>"); | 332 | description.append("<b>"); |
333 | description.append(Qtopia::escapeString(tag)); | 333 | description.append(Qtopia::escapeString(tag)); |
334 | description.append(":</b> "); | 334 | description.append(":</b> "); |
335 | description.append(Qtopia::escapeString(line.mid(sep+2))); | 335 | description.append(Qtopia::escapeString(line.mid(sep+2))); |
336 | } else { | 336 | } else { |
337 | description.append(" "); | 337 | description.append(" "); |
338 | description.append(Qtopia::escapeString(line)); | 338 | description.append(Qtopia::escapeString(line)); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | } | 341 | } |
342 | } | 342 | } |
343 | return description; | 343 | return description; |
344 | } | 344 | } |
345 | 345 | ||
346 | void Package::processed() | 346 | void Package::processed() |
347 | { | 347 | { |
348 | _toProcess = false; | 348 | _toProcess = false; |
349 | //hack, but we're not writing status anyway... | 349 | //hack, but we're not writing status anyway... |
350 | if ( installed() ) _status = "install"; | 350 | if ( installed() ) _status = "install"; |
351 | else _status = "installed"; | 351 | else _status = "installed"; |
352 | } | 352 | } |
353 | 353 | ||
354 | QString Package::dest() | 354 | QString Package::dest() |
355 | { | 355 | { |
356 | if ( installed()||(!installed() && _toProcess) ) | 356 | if ( installed()||(!installed() && _toProcess) ) |
357 | return _dest!=""?_dest:settings->getDestinationName(); | 357 | return _dest!=""?_dest:settings->getDestinationName(); |
358 | else return ""; | 358 | else return ""; |
359 | } | 359 | } |
360 | 360 | ||
361 | void Package::setDest( QString d ) | 361 | void Package::setDest( QString d ) |
362 | { | 362 | { |
363 | if ( d == "remote") _useFileName = true; | 363 | if ( d == "remote") _useFileName = true; |
364 | else _dest = d; | 364 | else _dest = d; |
365 | } | 365 | } |
366 | 366 | ||
367 | void Package::setOn() | 367 | void Package::setOn() |
368 | { | 368 | { |
369 | _toProcess = true; | 369 | _toProcess = true; |
370 | } | 370 | } |
371 | 371 | ||
372 | bool Package::link() | 372 | bool Package::link() |
373 | { | 373 | { |
374 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; | 374 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; |
375 | return _link; | 375 | return _link; |
376 | } | 376 | } |
377 | 377 | ||
378 | void Package::setLink(bool b) | 378 | void Package::setLink(bool b) |
379 | { | 379 | { |
380 | _link = b; | 380 | _link = b; |
381 | } | 381 | } |
382 | 382 | ||
383 | void Package::parseIpkgFile( QString file) | 383 | void Package::parseIpkgFile( QString file) |
384 | { | 384 | { |
385 | system("tar xzf "+file+" -C /tmp"); | 385 | system("tar xzf "+file+" -C /tmp"); |
386 | system("tar xzf /tmp/control.tar.gz -C /tmp"); | 386 | system("tar xzf /tmp/control.tar.gz -C /tmp"); |
387 | QFile f("/tmp/control"); | 387 | QFile f("/tmp/control"); |
388 | if ( f.open(IO_ReadOnly) ) | 388 | if ( f.open(IO_ReadOnly) ) |
389 | { | 389 | { |
390 | QTextStream t( &f ); | 390 | QTextStream t( &f ); |
391 | QStringList pack; | 391 | QStringList pack; |
392 | while ( !t.eof() ) | 392 | while ( !t.eof() ) |
393 | { | 393 | { |
394 | pack << t.readLine(); | 394 | pack << t.readLine(); |
395 | } | 395 | } |
396 | f.close(); | 396 | f.close(); |
397 | parsePackage( pack ); | 397 | parsePackage( pack ); |
398 | } | 398 | } |
399 | 399 | ||
400 | } | 400 | } |
401 | 401 | ||
402 | //QString Package::getPackageName() | 402 | //QString Package::getPackageName() |
403 | //{ | 403 | //{ |
404 | //if ( _packageName.isEmpty() ) return _name; | 404 | //if ( _packageName.isEmpty() ) return _name; |
405 | //else return _packageName; | 405 | //else return _packageName; |
406 | //} | 406 | //} |
407 | 407 | ||
408 | void Package::instalFromFile(bool iff) | 408 | void Package::instalFromFile(bool iff) |
409 | { | 409 | { |
410 | _useFileName = iff; | 410 | _useFileName = iff; |
411 | } | 411 | } |
412 | 412 | ||
413 | void Package::setName(QString n) | 413 | void Package::setName(QString n) |
414 | { | 414 | { |
415 | _displayName = n; | 415 | _displayName = n; |
416 | } | 416 | } |
417 | 417 | ||
418 | QDict<QString>* Package::getFields() | 418 | QDict<QString>* Package::getFields() |
419 | { | 419 | { |
420 | return &_values; | 420 | return &_values; |
421 | } | 421 | } |
422 | 422 | ||
423 | QString Package::status() | 423 | QString Package::status() |
424 | { | 424 | { |
425 | return _status; | 425 | return _status; |
426 | } | 426 | } |
427 | 427 | ||
428 | bool Package::isOld() | 428 | bool Package::isOld() |
429 | { | 429 | { |
430 | if (!_versions) return false; | 430 | if (!_versions) return false; |
431 | QDictIterator<Package> other( *_versions ); | 431 | QDictIterator<Package> other( *_versions ); |
432 | while ( other.current() ) { | 432 | while ( other.current() ) { |
433 | if (other.current()->version() > version() ) return true; | 433 | if (other.current()->version() > version() ) return true; |
434 | ++other; | 434 | ++other; |
435 | } | 435 | } |
436 | return false; | 436 | return false; |
437 | } | 437 | } |
438 | 438 | ||
439 | bool Package::hasVersions() | 439 | bool Package::hasVersions() |
440 | { | 440 | { |
441 | if (!_versions) return false; | 441 | if (!_versions) return false; |
442 | else return true; | 442 | else return true; |
443 | } | 443 | } |
444 | 444 | ||
445 | QDict<Package>* Package::getOtherVersions() | 445 | QDict<Package>* Package::getOtherVersions() |
446 | { | 446 | { |
447 | return _versions; | 447 | return _versions; |
448 | } | 448 | } |
449 | 449 | ||
450 | void Package::setOtherVersions(QDict<Package> *v) | 450 | void Package::setOtherVersions(QDict<Package> *v) |
451 | { | 451 | { |
452 | _versions=v; | 452 | _versions=v; |
453 | } | 453 | } |
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index 3cc0443..e445570 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp | |||
@@ -1,221 +1,221 @@ | |||
1 | #include "packagelist.h" | 1 | #include "packagelist.h" |
2 | 2 | ||
3 | #include <assert.h> | 3 | #include <assert.h> |
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qfileinfo.h> | 5 | #include <qfileinfo.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | 7 | ||
8 | #include "debug.h" | 8 | #include "debug.h" |
9 | 9 | ||
10 | static QDict<Package> *packageListAll; | 10 | static QDict<Package> *packageListAll; |
11 | static int packageListAllRefCount = 0; | 11 | static int packageListAllRefCount = 0; |
12 | 12 | ||
13 | PackageList::PackageList(QObject *parent=0, const char *name=0) | 13 | PackageList::PackageList(QObject *parent, const char *name) |
14 | : QObject(parent,name), packageIter( packageList ) | 14 | : QObject(parent,name), packageIter( packageList ) |
15 | { | 15 | { |
16 | empty=true; | 16 | empty=true; |
17 | if (!packageListAll) packageListAll = new QDict<Package>(); | 17 | if (!packageListAll) packageListAll = new QDict<Package>(); |
18 | packageListAllRefCount++; | 18 | packageListAllRefCount++; |
19 | sections << "All"; | 19 | sections << "All"; |
20 | subSections.insert("All", new QStringList() ); | 20 | subSections.insert("All", new QStringList() ); |
21 | QStringList *ss = subSections["All"]; | 21 | QStringList *ss = subSections["All"]; |
22 | *ss << "All"; | 22 | *ss << "All"; |
23 | aktSection = "All"; | 23 | aktSection = "All"; |
24 | aktSubSection = "All"; | 24 | aktSubSection = "All"; |
25 | } | 25 | } |
26 | 26 | ||
27 | PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) | 27 | PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) |
28 | : QObject(parent,name), packageIter( packageList ) | 28 | : QObject(parent,name), packageIter( packageList ) |
29 | { | 29 | { |
30 | settings = s; | 30 | settings = s; |
31 | PackageList(parent, name); | 31 | PackageList(parent, name); |
32 | } | 32 | } |
33 | 33 | ||
34 | PackageList::~PackageList() | 34 | PackageList::~PackageList() |
35 | { | 35 | { |
36 | if (--packageListAllRefCount < 1 ) delete packageListAll; | 36 | if (--packageListAllRefCount < 1 ) delete packageListAll; |
37 | } | 37 | } |
38 | 38 | ||
39 | /** Inserts a package into the list */ | 39 | /** Inserts a package into the list */ |
40 | void PackageList::insertPackage( Package* pack ) | 40 | void PackageList::insertPackage( Package* pack ) |
41 | { | 41 | { |
42 | if (!pack) return; | 42 | if (!pack) return; |
43 | Package* p = packageListAll->find( pack->name() ); | 43 | Package* p = packageListAll->find( pack->name() ); |
44 | if ( p ) | 44 | if ( p ) |
45 | { | 45 | { |
46 | if ( (p->version() == pack->version()) | 46 | if ( (p->version() == pack->version()) |
47 | // && (p->dest() == pack->dest()) | 47 | // && (p->dest() == pack->dest()) |
48 | ) | 48 | ) |
49 | { | 49 | { |
50 | p->copyValues( pack ); | 50 | p->copyValues( pack ); |
51 | delete pack; | 51 | delete pack; |
52 | pack = p; | 52 | pack = p; |
53 | } else { | 53 | } else { |
54 | QDict<Package> *packver = p->getOtherVersions(); | 54 | QDict<Package> *packver = p->getOtherVersions(); |
55 | // p->setName( pack->name()+"["+p->version()+"]" ); | 55 | // p->setName( pack->name()+"["+p->version()+"]" ); |
56 | if (!packver) | 56 | if (!packver) |
57 | { | 57 | { |
58 | packver = new QDict<Package>(); | 58 | packver = new QDict<Package>(); |
59 | packver->insert( pack->name(), p ); | 59 | packver->insert( pack->name(), p ); |
60 | p->setOtherVersions( packver ); | 60 | p->setOtherVersions( packver ); |
61 | } | 61 | } |
62 | pack->setName( pack->name()+"["+pack->version()+"]" ); | 62 | pack->setName( pack->name()+"["+pack->version()+"]" ); |
63 | pack->setOtherVersions( packver ); | 63 | pack->setOtherVersions( packver ); |
64 | packver->insert( pack->name(), pack ); | 64 | packver->insert( pack->name(), pack ); |
65 | packageListAll->insert( pack->name(), pack ); | 65 | packageListAll->insert( pack->name(), pack ); |
66 | packageList.insert( pack->name(), pack ); | 66 | packageList.insert( pack->name(), pack ); |
67 | origPackageList.insert( pack->name(), pack ); | 67 | origPackageList.insert( pack->name(), pack ); |
68 | } | 68 | } |
69 | }else{ | 69 | }else{ |
70 | packageListAll->insert( pack->name(), pack ); | 70 | packageListAll->insert( pack->name(), pack ); |
71 | packageList.insert( pack->name(), pack ); | 71 | packageList.insert( pack->name(), pack ); |
72 | origPackageList.insert( pack->name(), pack ); | 72 | origPackageList.insert( pack->name(), pack ); |
73 | }; | 73 | }; |
74 | empty=false; | 74 | empty=false; |
75 | updateSections( pack ); | 75 | updateSections( pack ); |
76 | } | 76 | } |
77 | 77 | ||
78 | void PackageList::filterPackages( QString f ) | 78 | void PackageList::filterPackages( QString f ) |
79 | { | 79 | { |
80 | packageList.clear(); | 80 | packageList.clear(); |
81 | QDictIterator<Package> filterIter( origPackageList ); | 81 | QDictIterator<Package> filterIter( origPackageList ); |
82 | filterIter.toFirst(); | 82 | filterIter.toFirst(); |
83 | Package *pack= filterIter.current() ; | 83 | Package *pack= filterIter.current() ; |
84 | while ( pack ) | 84 | while ( pack ) |
85 | { | 85 | { |
86 | if ( | 86 | if ( |
87 | ((aktSection=="All")||(pack->section()==aktSection)) && | 87 | ((aktSection=="All")||(pack->section()==aktSection)) && |
88 | ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && | 88 | ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && |
89 | pack->name().contains( f ) | 89 | pack->name().contains( f ) |
90 | ) | 90 | ) |
91 | { | 91 | { |
92 | packageList.insert( pack->name(), pack ); | 92 | packageList.insert( pack->name(), pack ); |
93 | } | 93 | } |
94 | ++filterIter; | 94 | ++filterIter; |
95 | pack = filterIter.current(); | 95 | pack = filterIter.current(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | Package* PackageList::find( QString n ) | 99 | Package* PackageList::find( QString n ) |
100 | { | 100 | { |
101 | return packageList.find( n ); | 101 | return packageList.find( n ); |
102 | } | 102 | } |
103 | 103 | ||
104 | Package* PackageList::first() | 104 | Package* PackageList::first() |
105 | { | 105 | { |
106 | packageIter.toFirst(); | 106 | packageIter.toFirst(); |
107 | return packageIter.current(); | 107 | return packageIter.current(); |
108 | } | 108 | } |
109 | 109 | ||
110 | Package* PackageList::next() | 110 | Package* PackageList::next() |
111 | { | 111 | { |
112 | ++packageIter; | 112 | ++packageIter; |
113 | return packageIter.current(); | 113 | return packageIter.current(); |
114 | } | 114 | } |
115 | 115 | ||
116 | QStringList PackageList::getSections() | 116 | QStringList PackageList::getSections() |
117 | { | 117 | { |
118 | sections.sort(); | 118 | sections.sort(); |
119 | return sections; | 119 | return sections; |
120 | } | 120 | } |
121 | 121 | ||
122 | QStringList PackageList::getSubSections() | 122 | QStringList PackageList::getSubSections() |
123 | { | 123 | { |
124 | QStringList ss; | 124 | QStringList ss; |
125 | if ( !subSections[aktSection] ) return ss; | 125 | if ( !subSections[aktSection] ) return ss; |
126 | ss = *subSections[aktSection]; | 126 | ss = *subSections[aktSection]; |
127 | ss.sort(); | 127 | ss.sort(); |
128 | return ss; | 128 | return ss; |
129 | } | 129 | } |
130 | 130 | ||
131 | void PackageList::setSection( QString sec ) | 131 | void PackageList::setSection( QString sec ) |
132 | { | 132 | { |
133 | aktSection = sec; | 133 | aktSection = sec; |
134 | } | 134 | } |
135 | 135 | ||
136 | void PackageList::setSubSection( QString ssec ) | 136 | void PackageList::setSubSection( QString ssec ) |
137 | { | 137 | { |
138 | aktSubSection = ssec; | 138 | aktSubSection = ssec; |
139 | } | 139 | } |
140 | 140 | ||
141 | void PackageList::updateSections( Package* pack ) | 141 | void PackageList::updateSections( Package* pack ) |
142 | { | 142 | { |
143 | QString s = pack->section(); | 143 | QString s = pack->section(); |
144 | if ( s.isEmpty() || s == "") return; | 144 | if ( s.isEmpty() || s == "") return; |
145 | if ( sections.contains(s) ) return; | 145 | if ( sections.contains(s) ) return; |
146 | sections += s; | 146 | sections += s; |
147 | QString ss = pack->subSection(); | 147 | QString ss = pack->subSection(); |
148 | if ( ss.isEmpty() || ss == "" ) return; | 148 | if ( ss.isEmpty() || ss == "" ) return; |
149 | if ( !subSections[s] ) { | 149 | if ( !subSections[s] ) { |
150 | subSections.insert( s, new QStringList() ); | 150 | subSections.insert( s, new QStringList() ); |
151 | QStringList *subsecs = subSections[s]; | 151 | QStringList *subsecs = subSections[s]; |
152 | *subsecs += "All"; | 152 | *subsecs += "All"; |
153 | } | 153 | } |
154 | QStringList *subsecs = subSections[s]; | 154 | QStringList *subsecs = subSections[s]; |
155 | *subsecs += ss; | 155 | *subsecs += ss; |
156 | if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); | 156 | if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); |
157 | subsecs = subSections["All"]; | 157 | subsecs = subSections["All"]; |
158 | *subsecs += ss; | 158 | *subsecs += ss; |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void PackageList::readFileEntries( QString filename, QString dest ) | 162 | void PackageList::readFileEntries( QString filename, QString dest ) |
163 | { | 163 | { |
164 | pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); | 164 | pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); |
165 | QStringList packEntry; | 165 | QStringList packEntry; |
166 | QFile f( filename ); | 166 | QFile f( filename ); |
167 | if ( !f.open(IO_ReadOnly) ) return; | 167 | if ( !f.open(IO_ReadOnly) ) return; |
168 | QTextStream *statusStream = new QTextStream( &f ); | 168 | QTextStream *statusStream = new QTextStream( &f ); |
169 | while ( !statusStream ->eof() ) | 169 | while ( !statusStream ->eof() ) |
170 | { | 170 | { |
171 | QString line = statusStream->readLine(); | 171 | QString line = statusStream->readLine(); |
172 | if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) | 172 | if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) |
173 | { | 173 | { |
174 | //end of package | 174 | //end of package |
175 | if ( ! packEntry.isEmpty() ) | 175 | if ( ! packEntry.isEmpty() ) |
176 | { | 176 | { |
177 | Package *p = new Package( packEntry, settings ); | 177 | Package *p = new Package( packEntry, settings ); |
178 | if ( p ) | 178 | if ( p ) |
179 | { | 179 | { |
180 | p->setDest( dest ); | 180 | p->setDest( dest ); |
181 | insertPackage( p ); | 181 | insertPackage( p ); |
182 | packEntry.clear(); | 182 | packEntry.clear(); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | }else{ | 185 | }else{ |
186 | packEntry << line; | 186 | packEntry << line; |
187 | }; | 187 | }; |
188 | } | 188 | } |
189 | delete statusStream; | 189 | delete statusStream; |
190 | return; | 190 | return; |
191 | } | 191 | } |
192 | 192 | ||
193 | void PackageList::setSettings( PackageManagerSettings *s ) | 193 | void PackageList::setSettings( PackageManagerSettings *s ) |
194 | { | 194 | { |
195 | settings = s; | 195 | settings = s; |
196 | } | 196 | } |
197 | 197 | ||
198 | Package* PackageList::getByName( QString n ) | 198 | Package* PackageList::getByName( QString n ) |
199 | { | 199 | { |
200 | origPackageList[n]; | 200 | return origPackageList[n]; |
201 | } | 201 | } |
202 | 202 | ||
203 | void PackageList::clear() | 203 | void PackageList::clear() |
204 | { | 204 | { |
205 | origPackageList.clear(); | 205 | origPackageList.clear(); |
206 | packageList.clear(); | 206 | packageList.clear(); |
207 | } | 207 | } |
208 | 208 | ||
209 | void PackageList::allPackages() | 209 | void PackageList::allPackages() |
210 | { | 210 | { |
211 | packageList.clear(); | 211 | packageList.clear(); |
212 | QDictIterator<Package> filterIter( origPackageList ); | 212 | QDictIterator<Package> filterIter( origPackageList ); |
213 | filterIter.toFirst(); | 213 | filterIter.toFirst(); |
214 | Package *pack= filterIter.current() ; | 214 | Package *pack= filterIter.current() ; |
215 | while ( pack ) | 215 | while ( pack ) |
216 | { | 216 | { |
217 | packageList.insert( pack->name(), pack ); | 217 | packageList.insert( pack->name(), pack ); |
218 | ++filterIter; | 218 | ++filterIter; |
219 | pack = filterIter.current(); | 219 | pack = filterIter.current(); |
220 | } | 220 | } |
221 | } | 221 | } |
diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.cpp b/noncore/unsupported/oipkg/packagelistdoclnk.cpp index b42cfdd..deb8a6d 100644 --- a/noncore/unsupported/oipkg/packagelistdoclnk.cpp +++ b/noncore/unsupported/oipkg/packagelistdoclnk.cpp | |||
@@ -1,45 +1,45 @@ | |||
1 | 1 | ||
2 | #include "packagelistdoclnk.h" | 2 | #include "packagelistdoclnk.h" |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qlist.h> | 6 | #include <qlist.h> |
7 | 7 | ||
8 | #include "package.h" | 8 | #include "package.h" |
9 | #include "pksettings.h" | 9 | #include "pksettings.h" |
10 | 10 | ||
11 | PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s, QObject *parent=0, const char *name=0) | 11 | PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s, QObject *parent, const char *name) |
12 | : PackageList(s) | 12 | : PackageList(s) |
13 | { | 13 | { |
14 | PackageListDocLnk(parent, name); | 14 | PackageListDocLnk(parent, name); |
15 | } | 15 | } |
16 | 16 | ||
17 | PackageListDocLnk::PackageListDocLnk(QObject *parent=0, const char *name=0) | 17 | PackageListDocLnk::PackageListDocLnk(QObject *parent, const char *name) |
18 | : PackageList(parent, name) | 18 | : PackageList(parent, name) |
19 | { | 19 | { |
20 | Config cfg( "oipkg", Config::User ); | 20 | Config cfg( "oipkg", Config::User ); |
21 | cfg.setGroup( "Common" ); | 21 | cfg.setGroup( "Common" ); |
22 | docLnkDir = cfg.readEntry( "docLnkDir", "/root/" ); | 22 | docLnkDir = cfg.readEntry( "docLnkDir", "/root/" ); |
23 | pvDebug(2,"opening DocLnkSet "+docLnkDir); | 23 | pvDebug(2,"opening DocLnkSet "+docLnkDir); |
24 | doclnkset = new DocLnkSet(docLnkDir,"application/ipkg"); | 24 | doclnkset = new DocLnkSet(docLnkDir,"application/ipkg"); |
25 | } | 25 | } |
26 | 26 | ||
27 | PackageListDocLnk::~PackageListDocLnk() | 27 | PackageListDocLnk::~PackageListDocLnk() |
28 | { | 28 | { |
29 | Config cfg( "oipkg", Config::User ); | 29 | Config cfg( "oipkg", Config::User ); |
30 | cfg.setGroup( "Common" ); | 30 | cfg.setGroup( "Common" ); |
31 | cfg.writeEntry( "docLnkDir", docLnkDir ); | 31 | cfg.writeEntry( "docLnkDir", docLnkDir ); |
32 | delete doclnkset; | 32 | delete doclnkset; |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | void PackageListDocLnk::update() | 37 | void PackageListDocLnk::update() |
38 | { | 38 | { |
39 | pvDebug(2,"PackageListDocLnk::update "); | 39 | pvDebug(2,"PackageListDocLnk::update "); |
40 | QList<DocLnk> packlist = doclnkset->children(); | 40 | QList<DocLnk> packlist = doclnkset->children(); |
41 | for (DocLnk *pack =packlist.first(); pack != 0; pack=packlist.next() ) | 41 | for (DocLnk *pack =packlist.first(); pack != 0; pack=packlist.next() ) |
42 | { | 42 | { |
43 | insertPackage( new Package(pack->file(), settings ) ); | 43 | insertPackage( new Package(pack->file(), settings ) ); |
44 | } | 44 | } |
45 | } | 45 | } |
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 0c9c676..7c54441 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp | |||
@@ -1,166 +1,166 @@ | |||
1 | #include "packagelistitem.h" | 1 | #include "packagelistitem.h" |
2 | 2 | ||
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | 5 | ||
6 | #include "debug.h" | 6 | #include "debug.h" |
7 | 7 | ||
8 | static QPixmap *pm_uninstalled=0; | 8 | static QPixmap *pm_uninstalled=0; |
9 | static QPixmap *pm_uninstalled_old=0; | 9 | static QPixmap *pm_uninstalled_old=0; |
10 | static QPixmap *pm_installed=0; | 10 | static QPixmap *pm_installed=0; |
11 | static QPixmap *pm_installed_old=0; | 11 | static QPixmap *pm_installed_old=0; |
12 | static QPixmap *pm_uninstall=0; | 12 | static QPixmap *pm_uninstall=0; |
13 | static QPixmap *pm_install=0; | 13 | static QPixmap *pm_install=0; |
14 | static QPixmap *pm_uninstalled_old_installed_new=0; | 14 | static QPixmap *pm_uninstalled_old_installed_new=0; |
15 | static QPixmap *pm_uninstalled_installed_old=0; | 15 | static QPixmap *pm_uninstalled_installed_old=0; |
16 | 16 | ||
17 | PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) | 17 | PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) |
18 | :QCheckListItem(lv,pi->name(),CheckBox) | 18 | :QCheckListItem(lv,pi->name(),CheckBox) |
19 | { | 19 | { |
20 | init(pi,s); | 20 | init(pi,s); |
21 | } | 21 | } |
22 | 22 | ||
23 | PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) | 23 | PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) |
24 | :QCheckListItem(lvi,pi->name(),CheckBox) | 24 | :QCheckListItem(lvi,pi->name(),CheckBox) |
25 | { | 25 | { |
26 | init(pi,s); | 26 | init(pi,s); |
27 | } | 27 | } |
28 | 28 | ||
29 | void PackageListItem::init( Package *pi, PackageManagerSettings *s) | 29 | void PackageListItem::init( Package *pi, PackageManagerSettings *s) |
30 | { | 30 | { |
31 | package = pi; | 31 | package = pi; |
32 | settings = s; | 32 | settings = s; |
33 | setExpandable( true ); | 33 | setExpandable( true ); |
34 | QCheckListItem *item; | 34 | QCheckListItem *item; |
35 | nameItem = new QCheckListItem( this, "" ); | 35 | nameItem = new QCheckListItem( this, "" ); |
36 | item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() ); | 36 | item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() ); |
37 | item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); | 37 | item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); |
38 | destItem = new QCheckListItem( this, "" ); | 38 | destItem = new QCheckListItem( this, "" ); |
39 | linkItem = new QCheckListItem( this, "" ); | 39 | linkItem = new QCheckListItem( this, "" ); |
40 | statusItem = new QCheckListItem( this, "" ); | 40 | statusItem = new QCheckListItem( this, "" ); |
41 | QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") ); | 41 | QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") ); |
42 | item = new QCheckListItem( otherItem, QObject::tr("Install Name: ")+pi->installName() ); | 42 | item = new QCheckListItem( otherItem, QObject::tr("Install Name: ")+pi->installName() ); |
43 | QDict<QString> *fields = pi->getFields(); | 43 | QDict<QString> *fields = pi->getFields(); |
44 | QDictIterator<QString> it( *fields ); | 44 | QDictIterator<QString> it( *fields ); |
45 | while ( it.current() ) { | 45 | while ( it.current() ) { |
46 | item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) ); | 46 | item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) ); |
47 | ++it; | 47 | ++it; |
48 | } | 48 | } |
49 | displayDetails(); | 49 | displayDetails(); |
50 | 50 | ||
51 | if (!pm_uninstalled) | 51 | if (!pm_uninstalled) |
52 | { | 52 | { |
53 | pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); | 53 | pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); |
54 | pm_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld")); | 54 | pm_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld")); |
55 | pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew")); | 55 | pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew")); |
56 | pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld")); | 56 | pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld")); |
57 | pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); | 57 | pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); |
58 | pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld")); | 58 | pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld")); |
59 | pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); | 59 | pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); |
60 | pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); | 60 | pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, | 64 | void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, |
65 | int column, int width, int alignment ) | 65 | int column, int width, int alignment ) |
66 | { | 66 | { |
67 | if ( !p ) | 67 | if ( !p ) |
68 | return; | 68 | return; |
69 | 69 | ||
70 | p->fillRect( 0, 0, width, height(), | 70 | p->fillRect( 0, 0, width, height(), |
71 | isSelected()? cg.highlight() : cg.base() ); | 71 | isSelected()? cg.highlight() : cg.base() ); |
72 | 72 | ||
73 | if ( column != 0 ) { | 73 | if ( column != 0 ) { |
74 | // The rest is text | 74 | // The rest is text |
75 | QListViewItem::paintCell( p, cg, column, width, alignment ); | 75 | QListViewItem::paintCell( p, cg, column, width, alignment ); |
76 | return; | 76 | return; |
77 | } | 77 | } |
78 | 78 | ||
79 | QListView *lv = listView(); | 79 | QListView *lv = listView(); |
80 | if ( !lv ) | 80 | if ( !lv ) |
81 | return; | 81 | return; |
82 | int marg = lv->itemMargin(); | 82 | int marg = lv->itemMargin(); |
83 | int r = marg; | 83 | int r = marg; |
84 | 84 | ||
85 | QPixmap pm = statePixmap(); | 85 | QPixmap pm = statePixmap(); |
86 | p->drawPixmap(marg,(height()-pm.height())/2,pm); | 86 | p->drawPixmap(marg,(height()-pm.height())/2,pm); |
87 | r += pm.width()+1; | 87 | r += pm.width()+1; |
88 | 88 | ||
89 | p->translate( r, 0 ); | 89 | p->translate( r, 0 ); |
90 | QListViewItem::paintCell( p, cg, column, width - r, alignment ); | 90 | QListViewItem::paintCell( p, cg, column, width - r, alignment ); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, | 94 | void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, |
95 | const QRect & r ) | 95 | const QRect & r ) |
96 | { | 96 | { |
97 | // Skip QCheckListItem | 97 | // Skip QCheckListItem |
98 | // (makes you wonder what we're getting from QCheckListItem) | 98 | // (makes you wonder what we're getting from QCheckListItem) |
99 | QListViewItem::paintFocus(p,cg,r); | 99 | QListViewItem::paintFocus(p,cg,r); |
100 | } | 100 | } |
101 | 101 | ||
102 | QPixmap PackageListItem::statePixmap() const | 102 | QPixmap PackageListItem::statePixmap() const |
103 | { | 103 | { |
104 | bool installed = package->installed(); | 104 | bool installed = package->installed(); |
105 | bool old = package->isOld(); | 105 | bool old = package->isOld(); |
106 | bool versions = package->hasVersions(); | 106 | bool versions = package->hasVersions(); |
107 | bool verinstalled = package->otherInstalled(); | 107 | bool verinstalled = package->otherInstalled(); |
108 | if ( !package->toProcess() ) { | 108 | if ( !package->toProcess() ) { |
109 | if ( !installed ) | 109 | if ( !installed ) |
110 | if (old) | 110 | if (old) |
111 | { | 111 | { |
112 | if (verinstalled) return *pm_uninstalled_old_installed_new; | 112 | if (verinstalled) return *pm_uninstalled_old_installed_new; |
113 | else return *pm_uninstalled_old; | 113 | else return *pm_uninstalled_old; |
114 | } | 114 | } |
115 | else | 115 | else |
116 | { | 116 | { |
117 | if (verinstalled) return *pm_uninstalled_installed_old; | 117 | if (verinstalled) return *pm_uninstalled_installed_old; |
118 | else return *pm_uninstalled; | 118 | else return *pm_uninstalled; |
119 | } | 119 | } |
120 | else | 120 | else |
121 | if (old) return *pm_installed_old; | 121 | if (old) return *pm_installed_old; |
122 | else return *pm_installed; | 122 | else return *pm_installed; |
123 | } else { //toProcess() == true | 123 | } else { //toProcess() == true |
124 | if ( !installed ) | 124 | if ( !installed ) |
125 | return *pm_install; | 125 | return *pm_install; |
126 | else | 126 | else |
127 | return *pm_uninstall; | 127 | return *pm_uninstall; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | QString PackageListItem::key( int column, bool ascending ) const | 131 | QString PackageListItem::key( int column, bool ascending ) const |
132 | { | 132 | { |
133 | if ( column == 2 ) { | 133 | if ( column == 2 ) { |
134 | QString t = text(2); | 134 | QString t = text(2); |
135 | double bytes=t.toDouble(); | 135 | double bytes=t.toDouble(); |
136 | if ( t.contains('M') ) bytes*=1024*1024; | 136 | if ( t.contains('M') ) bytes*=1024*1024; |
137 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; | 137 | else if ( t.contains('K') || t.contains('k') ) bytes*=1024; |
138 | if ( !ascending ) bytes=999999999-bytes; | 138 | if ( !ascending ) bytes=999999999-bytes; |
139 | return QString().sprintf("%09d",(int)bytes); | 139 | return QString().sprintf("%09d",(int)bytes); |
140 | } else { | 140 | } else { |
141 | return QListViewItem::key(column,ascending); | 141 | return QListViewItem::key(column,ascending); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void PackageListItem::setOn( bool b ) | 145 | void PackageListItem::setOn( bool b ) |
146 | { | 146 | { |
147 | QCheckListItem::setOn( b ); | 147 | QCheckListItem::setOn( b ); |
148 | package->toggleProcess(); | 148 | package->toggleProcess(); |
149 | package->setLink( settings->createLinks() ); | 149 | package->setLink( settings->createLinks() ); |
150 | displayDetails(); | 150 | displayDetails(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void PackageListItem::displayDetails() | 153 | void PackageListItem::displayDetails() |
154 | { | 154 | { |
155 | QString sod; | 155 | QString sod; |
156 | sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); | 156 | sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); |
157 | //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); | 157 | //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); |
158 | sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); | 158 | sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); |
159 | sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); | 159 | sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); |
160 | setText(0, package->name()+sod ); | 160 | setText(0, package->name()+sod ); |
161 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); | 161 | nameItem->setText( 0, QObject::tr("Name: ")+package->name()); |
162 | linkItem->setText( 0, QObject::tr("Link: ")+package->link()?QObject::tr("Yes"):QObject::tr("No")); | 162 | linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); |
163 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); | 163 | destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); |
164 | statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); | 164 | statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); |
165 | repaint(); | 165 | repaint(); |
166 | } | 166 | } |
diff --git a/noncore/unsupported/qpdf/fixed.h b/noncore/unsupported/qpdf/fixed.h index d073421..ec0e696 100644 --- a/noncore/unsupported/qpdf/fixed.h +++ b/noncore/unsupported/qpdf/fixed.h | |||
@@ -1,191 +1,191 @@ | |||
1 | #ifndef __FIXED_H__ | 1 | #ifndef __FIXED_H__ |
2 | #define __FIXED_H__ | 2 | #define __FIXED_H__ |
3 | 3 | ||
4 | #include <iostream> | 4 | #include <iostream> |
5 | 5 | ||
6 | #define _GCC_TEMPLATE_BUG_ 1 | 6 | #define _GCC_TEMPLATE_BUG_ 1 |
7 | 7 | ||
8 | template <unsigned int SH> class fixed { | 8 | template <unsigned int SH> class fixed { |
9 | public: | 9 | public: |
10 | inline fixed ( int i = 0 ) : m_f ( i2f( i ) ) { } | 10 | inline fixed ( int i = 0 ) : m_f ( i2f( i ) ) { } |
11 | inline fixed ( double d ) : m_f ( d2f( d )) { } | 11 | inline fixed ( double d ) : m_f ( d2f( d )) { } |
12 | inline fixed ( const fixed &f ) : m_f ( f. m_f ) { } | 12 | inline fixed ( const fixed &f ) : m_f ( f. m_f ) { } |
13 | 13 | ||
14 | inline operator bool ( ) const { return m_f != 0; } | 14 | inline operator bool ( ) const { return m_f != 0; } |
15 | inline operator double ( ) const { return f2d( m_f ); } | 15 | inline operator double ( ) const { return f2d( m_f ); } |
16 | inline operator float ( ) const { return (float) f2d( m_f ); } | 16 | inline operator float ( ) const { return (float) f2d( m_f ); } |
17 | inline operator int ( ) const { return (int) f2i( m_f ); } | 17 | inline operator int ( ) const { return (int) f2i( m_f ); } |
18 | 18 | ||
19 | inline fixed &operator = ( const fixed &f ) { m_f = f. m_f; return *this; } | 19 | inline fixed &operator = ( const fixed &f ) { m_f = f. m_f; return *this; } |
20 | inline fixed &operator = ( double d ) { m_f = d2f( d ); return *this; } | 20 | inline fixed &operator = ( double d ) { m_f = d2f( d ); return *this; } |
21 | inline fixed &operator = ( float f ) { m_f = d2f( f ); return *this; } | 21 | inline fixed &operator = ( float f ) { m_f = d2f( f ); return *this; } |
22 | inline fixed &operator = ( int i ) { m_f = i2f( i ); return *this; } | 22 | inline fixed &operator = ( int i ) { m_f = i2f( i ); return *this; } |
23 | 23 | ||
24 | inline fixed &operator += ( const fixed &f ) { m_f += f. m_f; return *this; } | 24 | inline fixed &operator += ( const fixed &f ) { m_f += f. m_f; return *this; } |
25 | inline fixed &operator -= ( const fixed &f ) { m_f -= f. m_f; return *this; } | 25 | inline fixed &operator -= ( const fixed &f ) { m_f -= f. m_f; return *this; } |
26 | inline fixed &operator *= ( const fixed &f ) { m_f = mul ( m_f, f. m_f ); return *this; } | 26 | inline fixed &operator *= ( const fixed &f ) { m_f = mul ( m_f, f. m_f ); return *this; } |
27 | inline fixed &operator /= ( const fixed &f ) { m_f = div ( m_f, f. m_f ); return *this; } | 27 | inline fixed &operator /= ( const fixed &f ) { m_f = div ( m_f, f. m_f ); return *this; } |
28 | 28 | ||
29 | inline fixed &operator += ( int i ) { m_f += i2f( i ); return *this; } | 29 | inline fixed &operator += ( int i ) { m_f += i2f( i ); return *this; } |
30 | inline fixed &operator -= ( int i ) { m_f -= i2f( i ); return *this; } | 30 | inline fixed &operator -= ( int i ) { m_f -= i2f( i ); return *this; } |
31 | inline fixed &operator *= ( int i ) { m_f *= i; return *this; } | 31 | inline fixed &operator *= ( int i ) { m_f *= i; return *this; } |
32 | inline fixed &operator /= ( int i ) { m_f /= i; return *this; } | 32 | inline fixed &operator /= ( int i ) { m_f /= i; return *this; } |
33 | 33 | ||
34 | inline fixed &operator += ( double d ) { m_f += d2f( d ); return *this; } | 34 | inline fixed &operator += ( double d ) { m_f += d2f( d ); return *this; } |
35 | inline fixed &operator -= ( double d ) { m_f -= d2f( d ); return *this; } | 35 | inline fixed &operator -= ( double d ) { m_f -= d2f( d ); return *this; } |
36 | inline fixed &operator *= ( double d ) { m_f = mul ( m_f, d2f( d )); return *this; } | 36 | inline fixed &operator *= ( double d ) { m_f = mul ( m_f, d2f( d )); return *this; } |
37 | inline fixed &operator /= ( double d ) { m_f = div ( m_f, d2f( d )); return *this; } | 37 | inline fixed &operator /= ( double d ) { m_f = div ( m_f, d2f( d )); return *this; } |
38 | 38 | ||
39 | inline fixed operator - ( ) const { return fixed ( -m_f, true ); } | 39 | inline fixed operator - ( ) const { return fixed ( -m_f, true ); } |
40 | 40 | ||
41 | inline fixed operator + ( const fixed &f ) const { return fixed ( m_f + f. m_f, true ); } | 41 | inline fixed operator + ( const fixed &f ) const { return fixed ( m_f + f. m_f, true ); } |
42 | inline fixed operator - ( const fixed &f ) const { return fixed ( m_f - f. m_f, true ); } | 42 | inline fixed operator - ( const fixed &f ) const { return fixed ( m_f - f. m_f, true ); } |
43 | inline fixed operator * ( const fixed &f ) const { return fixed ( mul ( m_f, f. m_f ), true ); } | 43 | inline fixed operator * ( const fixed &f ) const { return fixed ( mul ( m_f, f. m_f ), true ); } |
44 | inline fixed operator / ( const fixed &f ) const { return fixed ( div ( m_f, f. m_f ), true ); } | 44 | inline fixed operator / ( const fixed &f ) const { return fixed ( div ( m_f, f. m_f ), true ); } |
45 | 45 | ||
46 | inline fixed operator + ( double d ) const { return fixed ( m_f + d2f( d ), true ); } | 46 | inline fixed operator + ( double d ) const { return fixed ( m_f + d2f( d ), true ); } |
47 | inline fixed operator - ( double d ) const { return fixed ( m_f - d2f( d ), true ); } | 47 | inline fixed operator - ( double d ) const { return fixed ( m_f - d2f( d ), true ); } |
48 | inline fixed operator * ( double d ) const { return fixed ( mul ( m_f, d2f( d )), true ); } | 48 | inline fixed operator * ( double d ) const { return fixed ( mul ( m_f, d2f( d )), true ); } |
49 | inline fixed operator / ( double d ) const { return fixed ( div ( m_f, d2f( d )), true ); } | 49 | inline fixed operator / ( double d ) const { return fixed ( div ( m_f, d2f( d )), true ); } |
50 | 50 | ||
51 | inline fixed operator + ( int i ) const { return fixed ( m_f + i2f( i ), true ); } | 51 | inline fixed operator + ( int i ) const { return fixed ( m_f + i2f( i ), true ); } |
52 | inline fixed operator - ( int i ) const { return fixed ( m_f - i2f( i ), true ); } | 52 | inline fixed operator - ( int i ) const { return fixed ( m_f - i2f( i ), true ); } |
53 | inline fixed operator * ( int i ) const { return fixed ( m_f * i, true ); } | 53 | inline fixed operator * ( int i ) const { return fixed ( m_f * i, true ); } |
54 | inline fixed operator / ( int i ) const { return fixed ( m_f / i, true ); } | 54 | inline fixed operator / ( int i ) const { return fixed ( m_f / i, true ); } |
55 | 55 | ||
56 | inline bool operator < ( const fixed &f ) const { return m_f < f. m_f; } | 56 | inline bool operator < ( const fixed &f ) const { return m_f < f. m_f; } |
57 | inline bool operator > ( const fixed &f ) const { return m_f > f. m_f; } | 57 | inline bool operator > ( const fixed &f ) const { return m_f > f. m_f; } |
58 | inline bool operator <= ( const fixed &f ) const { return m_f <= f. m_f; } | 58 | inline bool operator <= ( const fixed &f ) const { return m_f <= f. m_f; } |
59 | inline bool operator >= ( const fixed &f ) const { return m_f >= f. m_f; } | 59 | inline bool operator >= ( const fixed &f ) const { return m_f >= f. m_f; } |
60 | inline bool operator == ( const fixed &f ) const { return m_f == f. m_f; } | 60 | inline bool operator == ( const fixed &f ) const { return m_f == f. m_f; } |
61 | inline bool operator != ( const fixed &f ) const { return m_f != f. m_f; } | 61 | inline bool operator != ( const fixed &f ) const { return m_f != f. m_f; } |
62 | 62 | ||
63 | inline bool operator < ( double d ) const { return m_f < d2f( d ); } | 63 | inline bool operator < ( double d ) const { return m_f < d2f( d ); } |
64 | inline bool operator > ( double d ) const { return m_f > d2f( d ); } | 64 | inline bool operator > ( double d ) const { return m_f > d2f( d ); } |
65 | inline bool operator <= ( double d ) const { return m_f <= d2f( d ); } | 65 | inline bool operator <= ( double d ) const { return m_f <= d2f( d ); } |
66 | inline bool operator >= ( double d ) const { return m_f >= d2f( d ); } | 66 | inline bool operator >= ( double d ) const { return m_f >= d2f( d ); } |
67 | inline bool operator == ( double d ) const { return m_f == d2f( d ); } | 67 | inline bool operator == ( double d ) const { return m_f == d2f( d ); } |
68 | inline bool operator != ( double d ) const { return m_f != d2f( d ); } | 68 | inline bool operator != ( double d ) const { return m_f != d2f( d ); } |
69 | 69 | ||
70 | inline bool operator < ( int i ) const { return m_f < i2f( i ); } | 70 | inline bool operator < ( int i ) const { return m_f < i2f( i ); } |
71 | inline bool operator > ( int i ) const { return m_f > i2f( i ); } | 71 | inline bool operator > ( int i ) const { return m_f > i2f( i ); } |
72 | inline bool operator <= ( int i ) const { return m_f <= i2f( i ); } | 72 | inline bool operator <= ( int i ) const { return m_f <= i2f( i ); } |
73 | inline bool operator >= ( int i ) const { return m_f >= i2f( i ); } | 73 | inline bool operator >= ( int i ) const { return m_f >= i2f( i ); } |
74 | inline bool operator == ( int i ) const { return m_f == i2f( i ); } | 74 | inline bool operator == ( int i ) const { return m_f == i2f( i ); } |
75 | inline bool operator != ( int i ) const { return m_f != i2f( i ); } | 75 | inline bool operator != ( int i ) const { return m_f != i2f( i ); } |
76 | 76 | ||
77 | #if _GCC_TEMPLATE_BUG_ | 77 | #if _GCC_TEMPLATE_BUG_ |
78 | public: | 78 | public: |
79 | #else | 79 | #else |
80 | private: | 80 | private: |
81 | #endif | 81 | #endif |
82 | typedef int fix_t; | 82 | typedef int fix_t; |
83 | 83 | ||
84 | inline static double f2d ( fix_t f ) { return ((double) f ) / ((double) ( 1 << SH )); } | 84 | inline static double f2d ( fix_t f ) { return ((double) f ) / ((double) ( 1 << SH )); } |
85 | inline static fix_t d2f ( double d ) { return (fix_t) ( d * ((double) ( 1 << SH ))); } | 85 | inline static fix_t d2f ( double d ) { return (fix_t) ( d * ((double) ( 1 << SH ))); } |
86 | 86 | ||
87 | inline static int f2i ( fix_t f ) { return (int) ( f >> SH ); } | 87 | inline static int f2i ( fix_t f ) { return (int) ( f >> SH ); } |
88 | inline static fix_t i2f ( int i ) { return (fix_t) ( i << SH ); } | 88 | inline static fix_t i2f ( int i ) { return (fix_t) ( i << SH ); } |
89 | 89 | ||
90 | inline static fix_t mul ( fix_t m1, fix_t m2 ) { return (fix_t) ((((long long int) m1 ) * m2 ) >> SH ); } | 90 | inline static fix_t mul ( fix_t m1, fix_t m2 ) { return (fix_t) ((((long long int) m1 ) * m2 ) >> SH ); } |
91 | inline static fix_t div ( fix_t d1, fix_t d2 ){ return (fix_t) ((((long long int) d1 ) << SH ) / d2 ); } | 91 | inline static fix_t div ( fix_t d1, fix_t d2 ){ return (fix_t) ((((long long int) d1 ) << SH ) / d2 ); } |
92 | 92 | ||
93 | fixed ( fix_t f, bool /*dummy*/ ) : m_f ( f ) { } | 93 | fixed ( fix_t f, bool /*dummy*/ ) : m_f ( f ) { } |
94 | 94 | ||
95 | //data | 95 | //data |
96 | fix_t m_f; | 96 | fix_t m_f; |
97 | 97 | ||
98 | // friends: | 98 | // friends: |
99 | #if !_GCC_TEMPLATE_BUG_ | 99 | #if !_GCC_TEMPLATE_BUG_ |
100 | friend fixed operator + <> ( int i, const fixed &f ); | 100 | friend fixed operator + <> ( int i, const fixed &f ); |
101 | friend fixed operator - <> ( int i, const fixed &f ); | 101 | friend fixed operator - <> ( int i, const fixed &f ); |
102 | friend fixed operator * <> ( int i, const fixed &f ); | 102 | friend fixed operator * <> ( int i, const fixed &f ); |
103 | friend fixed operator / <> ( int i, const fixed &f ); | 103 | friend fixed operator / <> ( int i, const fixed &f ); |
104 | 104 | ||
105 | friend fixed operator + <> ( double d, const fixed &f ); | 105 | friend fixed operator + <> ( double d, const fixed &f ); |
106 | friend fixed operator - <> ( double d, const fixed &f ); | 106 | friend fixed operator - <> ( double d, const fixed &f ); |
107 | friend fixed operator * <> ( double d, const fixed &f ); | 107 | friend fixed operator * <> ( double d, const fixed &f ); |
108 | friend fixed &operator / <> ( double d, const fixed<SH> &f ); | 108 | friend fixed &operator / <> ( double d, const fixed<SH> &f ); |
109 | 109 | ||
110 | friend bool operator < <> ( double d, const fixed &f ); | 110 | friend bool operator < <> ( double d, const fixed &f ); |
111 | friend bool operator > <> ( double d, const fixed &f ); | 111 | friend bool operator > <> ( double d, const fixed &f ); |
112 | friend bool operator <= <> ( double d, const fixed &f ); | 112 | friend bool operator <= <> ( double d, const fixed &f ); |
113 | friend bool operator >= <> ( double d, const fixed &f ); | 113 | friend bool operator >= <> ( double d, const fixed &f ); |
114 | friend bool operator == <> ( double d, const fixed &f ); | 114 | friend bool operator == <> ( double d, const fixed &f ); |
115 | friend bool operator != <> ( double d, const fixed &f ); | 115 | friend bool operator != <> ( double d, const fixed &f ); |
116 | 116 | ||
117 | friend bool operator < <> ( int i, const fixed &f ); | 117 | friend bool operator < <> ( int i, const fixed &f ); |
118 | friend bool operator > <> ( int i, const fixed &f ); | 118 | friend bool operator > <> ( int i, const fixed &f ); |
119 | friend bool operator <= <> ( int i, const fixed &f ); | 119 | friend bool operator <= <> ( int i, const fixed &f ); |
120 | friend bool operator >= <> ( int i, const fixed &f ); | 120 | friend bool operator >= <> ( int i, const fixed &f ); |
121 | friend bool operator == <> ( int i, const fixed &f ); | 121 | friend bool operator == <> ( int i, const fixed &f ); |
122 | friend bool operator != <> ( int i, const fixed &f ); | 122 | friend bool operator != <> ( int i, const fixed &f ); |
123 | 123 | ||
124 | friend long int lrint ( const fixed &f ); | 124 | friend long int lrint ( const fixed &f ); |
125 | friend fixed sqrt ( const fixed &f ); | 125 | friend fixed sqrt ( const fixed &f ); |
126 | friend fixed fabs ( const fixed &f ); | 126 | friend fixed fabs ( const fixed &f ); |
127 | #endif | 127 | #endif |
128 | }; | 128 | }; |
129 | 129 | ||
130 | 130 | ||
131 | template <unsigned int SH> inline fixed<SH> operator + ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) + f. m_f, true ); } | 131 | template <unsigned int SH> inline fixed<SH> operator + ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) + f. m_f, true ); } |
132 | template <unsigned int SH> inline fixed<SH> operator - ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) - f. m_f, true ); } | 132 | template <unsigned int SH> inline fixed<SH> operator - ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) - f. m_f, true ); } |
133 | template <unsigned int SH> inline fixed<SH> operator * ( int i, const fixed<SH> &f ) { return fixed<SH> ( i * f. m_f, true ); } | 133 | template <unsigned int SH> inline fixed<SH> operator * ( int i, const fixed<SH> &f ) { return fixed<SH> ( i * f. m_f, true ); } |
134 | template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::div ( fixed<SH>::i2f( i ), f. m_f ), true ); } | 134 | template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::div ( fixed<SH>::i2f( i ), f. m_f ), true ); } |
135 | //template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f ( i / fixed<SH>::f2i ( f. m_f )), true ); } | 135 | //template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f ( i / fixed<SH>::f2i ( f. m_f )), true ); } |
136 | 136 | ||
137 | template <unsigned int SH> inline fixed<SH> operator + ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) + f. m_f, true ); } | 137 | template <unsigned int SH> inline fixed<SH> operator + ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) + f. m_f, true ); } |
138 | template <unsigned int SH> inline fixed<SH> operator - ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) - f. m_f, true ); } | 138 | template <unsigned int SH> inline fixed<SH> operator - ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) - f. m_f, true ); } |
139 | template <unsigned int SH> inline fixed<SH> operator * ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } | 139 | template <unsigned int SH> inline fixed<SH> operator * ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } |
140 | template <unsigned int SH> inline fixed<SH> operator / ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } | 140 | template <unsigned int SH> inline fixed<SH> operator / ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } |
141 | 141 | ||
142 | template <unsigned int SH> inline bool operator < ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) < f. m_f; } | 142 | template <unsigned int SH> inline bool operator < ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) < f. m_f; } |
143 | template <unsigned int SH> inline bool operator > ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) > f. m_f; } | 143 | template <unsigned int SH> inline bool operator > ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) > f. m_f; } |
144 | template <unsigned int SH> inline bool operator <= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) <= f. m_f; } | 144 | template <unsigned int SH> inline bool operator <= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) <= f. m_f; } |
145 | template <unsigned int SH> inline bool operator >= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) >= f. m_f; } | 145 | template <unsigned int SH> inline bool operator >= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) >= f. m_f; } |
146 | template <unsigned int SH> inline bool operator == ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) == f. m_f; } | 146 | template <unsigned int SH> inline bool operator == ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) == f. m_f; } |
147 | template <unsigned int SH> inline bool operator != ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) != f. m_f; } | 147 | template <unsigned int SH> inline bool operator != ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) != f. m_f; } |
148 | 148 | ||
149 | template <unsigned int SH> inline bool operator < ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) < f. m_f; } | 149 | template <unsigned int SH> inline bool operator < ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) < f. m_f; } |
150 | template <unsigned int SH> inline bool operator > ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) > f. m_f; } | 150 | template <unsigned int SH> inline bool operator > ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) > f. m_f; } |
151 | template <unsigned int SH> inline bool operator <= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) <= f. m_f; } | 151 | template <unsigned int SH> inline bool operator <= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) <= f. m_f; } |
152 | template <unsigned int SH> inline bool operator >= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) >= f. m_f; } | 152 | template <unsigned int SH> inline bool operator >= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) >= f. m_f; } |
153 | template <unsigned int SH> inline bool operator == ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) == f. m_f; } | 153 | template <unsigned int SH> inline bool operator == ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) == f. m_f; } |
154 | template <unsigned int SH> inline bool operator != ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) != f. m_f; } | 154 | template <unsigned int SH> inline bool operator != ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) != f. m_f; } |
155 | 155 | ||
156 | template <unsigned int SH> inline long int lrint ( const fixed<SH> &f ) | 156 | template <unsigned int SH> inline long int lrint ( const fixed<SH> &f ) |
157 | { | 157 | { |
158 | return fixed<SH>::f2i (( f. m_f < 0 ) ? f. m_f - ( 1 << ( SH - 1 )) : f. m_f + ( 1 << ( SH - 1 ))); | 158 | return fixed<SH>::f2i (( f. m_f < 0 ) ? f. m_f - ( 1 << ( SH - 1 )) : f. m_f + ( 1 << ( SH - 1 ))); |
159 | } | 159 | } |
160 | 160 | ||
161 | template <unsigned int SH> inline fixed<SH> fabs ( const fixed<SH> &f ) | 161 | template <unsigned int SH> inline fixed<SH> fabs ( const fixed<SH> &f ) |
162 | { | 162 | { |
163 | return ( f. m_f < 0 ) ? fixed<SH> ( -f. m_f, true ) : f; | 163 | return ( f. m_f < 0 ) ? fixed<SH> ( -f. m_f, true ) : f; |
164 | } | 164 | } |
165 | 165 | ||
166 | // roughly from QPE / qmath.h | 166 | // roughly from QPE / qmath.h |
167 | template <unsigned int SH> inline fixed<SH> sqrt ( const fixed<SH> &f ) | 167 | template <unsigned int SH> inline fixed<SH> sqrt ( const fixed<SH> &f ) |
168 | { | 168 | { |
169 | if ( f. m_f <= 0 ) | 169 | if ( f. m_f <= 0 ) |
170 | return fixed<SH> ( 0, true ); | 170 | return fixed<SH> ( 0, true ); |
171 | 171 | ||
172 | fixed<SH>::fix_t a0 = 0; | 172 | typename fixed<SH>::fix_t a0 = 0; |
173 | fixed<SH>::fix_t a1 = f. m_f; // take value as first approximation | 173 | typename fixed<SH>::fix_t a1 = f. m_f; // take value as first approximation |
174 | 174 | ||
175 | do { | 175 | do { |
176 | a0 = a1; | 176 | a0 = a1; |
177 | a1 = ( a0 + fixed<SH>::div ( f. m_f, a0 )) >> 1; | 177 | a1 = ( a0 + fixed<SH>::div ( f. m_f, a0 )) >> 1; |
178 | } while ( abs ( fixed<SH>::div ( a1 - a0, a1 )) > 1 ); | 178 | } while ( abs ( fixed<SH>::div ( a1 - a0, a1 )) > 1 ); |
179 | 179 | ||
180 | return fixed<SH> ( a1, true ); | 180 | return fixed<SH> ( a1, true ); |
181 | } | 181 | } |
182 | 182 | ||
183 | #if 0 // no std::ostream needed in OPIE | 183 | #if 0 // no std::ostream needed in OPIE |
184 | template <unsigned int SH> inline std::ostream &operator << ( std::ostream &o, const fixed<SH> &f ) | 184 | template <unsigned int SH> inline std::ostream &operator << ( std::ostream &o, const fixed<SH> &f ) |
185 | { | 185 | { |
186 | o << double( f ); | 186 | o << double( f ); |
187 | return o; | 187 | return o; |
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | #endif | 191 | #endif |