author | mickeyl <mickeyl> | 2005-06-24 12:51:12 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-06-24 12:51:12 (UTC) |
commit | 0fa3d7e26d0c1571e27cd05916043c72dc254077 (patch) (unidiff) | |
tree | 561ddc2d965411f9ca629b912e522f9f481c90d4 | |
parent | fac3dd32424a22ae6ded78a8d9eaaaf318aae2f3 (diff) | |
download | opie-0fa3d7e26d0c1571e27cd05916043c72dc254077.zip opie-0fa3d7e26d0c1571e27cd05916043c72dc254077.tar.gz opie-0fa3d7e26d0c1571e27cd05916043c72dc254077.tar.bz2 |
s,cardmon/pcmcia,pcmcia,
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 2 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/filesystem.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/libopie/ofileselector.cpp | 2 |
6 files changed, 6 insertions, 6 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 11ce880..2a66494 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,382 +1,382 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.cpp | 2 | * cardmon.cpp |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2002 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "cardmon.h" | 19 | #include "cardmon.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | #include <opie2/odevice.h> | 23 | #include <opie2/odevice.h> |
24 | #include <opie2/oprocess.h> | 24 | #include <opie2/oprocess.h> |
25 | #include <opie2/oresource.h> | 25 | #include <opie2/oresource.h> |
26 | #include <opie2/otaskbarapplet.h> | 26 | #include <opie2/otaskbarapplet.h> |
27 | 27 | ||
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | using namespace Opie::Ui; | 31 | using namespace Opie::Ui; |
32 | 32 | ||
33 | /* QT */ | 33 | /* QT */ |
34 | #include <qcopchannel_qws.h> | 34 | #include <qcopchannel_qws.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qsound.h> | 38 | #include <qsound.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | 40 | ||
41 | /* STD */ | 41 | /* STD */ |
42 | #include <stdio.h> | 42 | #include <stdio.h> |
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <string.h> | 45 | #include <string.h> |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 47 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
48 | #include <sys/vfs.h> | 48 | #include <sys/vfs.h> |
49 | #include <mntent.h> | 49 | #include <mntent.h> |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ) | 52 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ) |
53 | { | 53 | { |
54 | pm = Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ); | 54 | pm = Opie::Core::OResource::loadPixmap( "pcmcia", Opie::Core::OResource::SmallIcon ); |
55 | 55 | ||
56 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 56 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
57 | connect( pcmciaChannel, | 57 | connect( pcmciaChannel, |
58 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 58 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
59 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 59 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
60 | 60 | ||
61 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); | 61 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); |
62 | connect( sdChannel, | 62 | connect( sdChannel, |
63 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 63 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
64 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 64 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
65 | 65 | ||
66 | cardInPcmcia0 = FALSE; | 66 | cardInPcmcia0 = FALSE; |
67 | cardInPcmcia1 = FALSE; | 67 | cardInPcmcia1 = FALSE; |
68 | cardInSd = FALSE; | 68 | cardInSd = FALSE; |
69 | m_process = 0; | 69 | m_process = 0; |
70 | 70 | ||
71 | setFocusPolicy( NoFocus ); | 71 | setFocusPolicy( NoFocus ); |
72 | 72 | ||
73 | setFixedWidth ( AppLnk::smallIconSize() ); | 73 | setFixedWidth ( AppLnk::smallIconSize() ); |
74 | setFixedHeight ( AppLnk::smallIconSize() ); | 74 | setFixedHeight ( AppLnk::smallIconSize() ); |
75 | 75 | ||
76 | getStatusPcmcia( TRUE ); | 76 | getStatusPcmcia( TRUE ); |
77 | getStatusSd( TRUE ); | 77 | getStatusSd( TRUE ); |
78 | repaint( FALSE ); | 78 | repaint( FALSE ); |
79 | popupMenu = 0; | 79 | popupMenu = 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | CardMonitor::~CardMonitor() { | 82 | CardMonitor::~CardMonitor() { |
83 | delete popupMenu; | 83 | delete popupMenu; |
84 | } | 84 | } |
85 | 85 | ||
86 | void CardMonitor::popUp( QString message, QString icon ) { | 86 | void CardMonitor::popUp( QString message, QString icon ) { |
87 | if ( !popupMenu ) { | 87 | if ( !popupMenu ) { |
88 | popupMenu = new QPopupMenu( this ); | 88 | popupMenu = new QPopupMenu( this ); |
89 | } | 89 | } |
90 | 90 | ||
91 | popupMenu->clear(); | 91 | popupMenu->clear(); |
92 | if ( icon.isEmpty() ) { | 92 | if ( icon.isEmpty() ) { |
93 | popupMenu->insertItem( message, 0 ); | 93 | popupMenu->insertItem( message, 0 ); |
94 | } else { | 94 | } else { |
95 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), | 95 | popupMenu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ), |
96 | message, 0 ); | 96 | message, 0 ); |
97 | } | 97 | } |
98 | 98 | ||
99 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 99 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
100 | QSize s = popupMenu->sizeHint(); | 100 | QSize s = popupMenu->sizeHint(); |
101 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 101 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
102 | p.y() - s.height() ), 0 ); | 102 | p.y() - s.height() ), 0 ); |
103 | 103 | ||
104 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 104 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
105 | } | 105 | } |
106 | 106 | ||
107 | void CardMonitor::popupTimeout() { | 107 | void CardMonitor::popupTimeout() { |
108 | popupMenu->hide(); | 108 | popupMenu->hide(); |
109 | } | 109 | } |
110 | 110 | ||
111 | void CardMonitor::mousePressEvent( QMouseEvent * ) { | 111 | void CardMonitor::mousePressEvent( QMouseEvent * ) { |
112 | QPopupMenu * menu = new QPopupMenu( this ); | 112 | QPopupMenu * menu = new QPopupMenu( this ); |
113 | QStringList cmd; | 113 | QStringList cmd; |
114 | bool execute = true; | 114 | bool execute = true; |
115 | 115 | ||
116 | if ( cardInSd ) { | 116 | if ( cardInSd ) { |
117 | menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ), | 117 | menu->insertItem( QIconSet( Opie::Core::OResource::loadPixmap( "cardmon/ide", Opie::Core::OResource::SmallIcon ) ), |
118 | tr( "Eject SD/MMC card" ), 0 ); | 118 | tr( "Eject SD/MMC card" ), 0 ); |
119 | } | 119 | } |
120 | 120 | ||
121 | if ( cardInPcmcia0 ) { | 121 | if ( cardInPcmcia0 ) { |
122 | menu-> | 122 | menu-> |
123 | insertItem( QIconSet | 123 | insertItem( QIconSet |
124 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ), | 124 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia0Type, Opie::Core::OResource::SmallIcon ) ), |
125 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); | 125 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); |
126 | } | 126 | } |
127 | 127 | ||
128 | if ( cardInPcmcia1 ) { | 128 | if ( cardInPcmcia1 ) { |
129 | menu-> | 129 | menu-> |
130 | insertItem( QIconSet | 130 | insertItem( QIconSet |
131 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ), | 131 | ( Opie::Core::OResource::loadPixmap( "cardmon/" + cardInPcmcia1Type, Opie::Core::OResource::SmallIcon ) ), |
132 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | 132 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); |
133 | } | 133 | } |
134 | 134 | ||
135 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 135 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
136 | QSize s = menu->sizeHint(); | 136 | QSize s = menu->sizeHint(); |
137 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 137 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
138 | p.y() - s.height() ), 0 ); | 138 | p.y() - s.height() ), 0 ); |
139 | 139 | ||
140 | if ( opt == 1 ) { | 140 | if ( opt == 1 ) { |
141 | m_commandOrig = PCMCIA_Socket1; | 141 | m_commandOrig = PCMCIA_Socket1; |
142 | cmd << "/sbin/cardctl" << "eject" << "0"; | 142 | cmd << "/sbin/cardctl" << "eject" << "0"; |
143 | } else if ( opt == 0 ) { | 143 | } else if ( opt == 0 ) { |
144 | m_commandOrig = MMC_Socket; | 144 | m_commandOrig = MMC_Socket; |
145 | cmd << "umount" << cardSdName; | 145 | cmd << "umount" << cardSdName; |
146 | } else if ( opt == 2 ) { | 146 | } else if ( opt == 2 ) { |
147 | m_commandOrig = PCMCIA_Socket2; | 147 | m_commandOrig = PCMCIA_Socket2; |
148 | cmd << "/sbin/cardctl" << "eject" << "1"; | 148 | cmd << "/sbin/cardctl" << "eject" << "1"; |
149 | }else | 149 | }else |
150 | execute = false; | 150 | execute = false; |
151 | 151 | ||
152 | if ( execute ) | 152 | if ( execute ) |
153 | execCommand( cmd ); | 153 | execCommand( cmd ); |
154 | 154 | ||
155 | delete menu; | 155 | delete menu; |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) { | 159 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) { |
160 | if ( msg == "stabChanged()" ) { | 160 | if ( msg == "stabChanged()" ) { |
161 | // odebug << "Pcmcia: stabchanged" << oendl; | 161 | // odebug << "Pcmcia: stabchanged" << oendl; |
162 | getStatusPcmcia(); | 162 | getStatusPcmcia(); |
163 | } else if ( msg == "mtabChanged()" ) { | 163 | } else if ( msg == "mtabChanged()" ) { |
164 | // odebug << "CARDMONAPPLET: mtabchanged" << oendl; | 164 | // odebug << "CARDMONAPPLET: mtabchanged" << oendl; |
165 | getStatusSd(); | 165 | getStatusSd(); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { | 169 | bool CardMonitor::getStatusPcmcia( int showPopUp ) { |
170 | 170 | ||
171 | bool cardWas0 = cardInPcmcia0; // remember last state | 171 | bool cardWas0 = cardInPcmcia0; // remember last state |
172 | bool cardWas1 = cardInPcmcia1; | 172 | bool cardWas1 = cardInPcmcia1; |
173 | 173 | ||
174 | QString fileName; | 174 | QString fileName; |
175 | 175 | ||
176 | // one of these 3 files should exist | 176 | // one of these 3 files should exist |
177 | if ( QFile::exists( "/var/run/stab" ) ) { | 177 | if ( QFile::exists( "/var/run/stab" ) ) { |
178 | fileName = "/var/run/stab"; | 178 | fileName = "/var/run/stab"; |
179 | } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { | 179 | } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { |
180 | fileName = "/var/state/pcmcia/stab"; | 180 | fileName = "/var/state/pcmcia/stab"; |
181 | } else { | 181 | } else { |
182 | fileName = "/var/lib/pcmcia/stab"; | 182 | fileName = "/var/lib/pcmcia/stab"; |
183 | } | 183 | } |
184 | 184 | ||
185 | QFile f( fileName ); | 185 | QFile f( fileName ); |
186 | 186 | ||
187 | if ( f.open( IO_ReadOnly ) ) { | 187 | if ( f.open( IO_ReadOnly ) ) { |
188 | QStringList list; | 188 | QStringList list; |
189 | QTextStream stream( &f ); | 189 | QTextStream stream( &f ); |
190 | QString streamIn; | 190 | QString streamIn; |
191 | streamIn = stream.read(); | 191 | streamIn = stream.read(); |
192 | list = QStringList::split( "\n", streamIn ); | 192 | list = QStringList::split( "\n", streamIn ); |
193 | for ( QStringList::Iterator line = list.begin(); line != list.end(); | 193 | for ( QStringList::Iterator line = list.begin(); line != list.end(); |
194 | line++ ) { | 194 | line++ ) { |
195 | if ( ( *line ).startsWith( "Socket 0:" ) ) { | 195 | if ( ( *line ).startsWith( "Socket 0:" ) ) { |
196 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) { | 196 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) { |
197 | cardInPcmcia0 = FALSE; | 197 | cardInPcmcia0 = FALSE; |
198 | } else if ( !( *line ).startsWith( "Socket 0: empty" ) | 198 | } else if ( !( *line ).startsWith( "Socket 0: empty" ) |
199 | && !cardInPcmcia0 ) { | 199 | && !cardInPcmcia0 ) { |
200 | cardInPcmcia0Name = | 200 | cardInPcmcia0Name = |
201 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | 201 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), |
202 | ( *line ).length() - 9 ); | 202 | ( *line ).length() - 9 ); |
203 | cardInPcmcia0Name.stripWhiteSpace(); | 203 | cardInPcmcia0Name.stripWhiteSpace(); |
204 | cardInPcmcia0 = TRUE; | 204 | cardInPcmcia0 = TRUE; |
205 | show(); | 205 | show(); |
206 | line++; | 206 | line++; |
207 | int pos = ( *line ).find( '\t' ) + 1; | 207 | int pos = ( *line ).find( '\t' ) + 1; |
208 | cardInPcmcia0Type = | 208 | cardInPcmcia0Type = |
209 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | 209 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); |
210 | } | 210 | } |
211 | } else if ( ( *line ).startsWith( "Socket 1:" ) ) { | 211 | } else if ( ( *line ).startsWith( "Socket 1:" ) ) { |
212 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { | 212 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) { |
213 | cardInPcmcia1 = FALSE; | 213 | cardInPcmcia1 = FALSE; |
214 | } else if ( !( *line ).startsWith( "Socket 1: empty" ) | 214 | } else if ( !( *line ).startsWith( "Socket 1: empty" ) |
215 | && !cardInPcmcia1 ) { | 215 | && !cardInPcmcia1 ) { |
216 | cardInPcmcia1Name = | 216 | cardInPcmcia1Name = |
217 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | 217 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), |
218 | ( *line ).length() - 9 ); | 218 | ( *line ).length() - 9 ); |
219 | cardInPcmcia1Name.stripWhiteSpace(); | 219 | cardInPcmcia1Name.stripWhiteSpace(); |
220 | cardInPcmcia1 = TRUE; | 220 | cardInPcmcia1 = TRUE; |
221 | show(); | 221 | show(); |
222 | line++; | 222 | line++; |
223 | int pos = ( *line ).find( '\t' ) + 1; | 223 | int pos = ( *line ).find( '\t' ) + 1; |
224 | cardInPcmcia1Type = | 224 | cardInPcmcia1Type = |
225 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | 225 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | f.close(); | 229 | f.close(); |
230 | 230 | ||
231 | if ( !showPopUp | 231 | if ( !showPopUp |
232 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) { | 232 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) { |
233 | QString text = QString::null; | 233 | QString text = QString::null; |
234 | QString what = QString::null; | 234 | QString what = QString::null; |
235 | if ( cardWas0 != cardInPcmcia0 ) { | 235 | if ( cardWas0 != cardInPcmcia0 ) { |
236 | if ( cardInPcmcia0 ) { | 236 | if ( cardInPcmcia0 ) { |
237 | text += tr( "New card: " ); | 237 | text += tr( "New card: " ); |
238 | what = "on"; | 238 | what = "on"; |
239 | } else { | 239 | } else { |
240 | text += tr( "Ejected: " ); | 240 | text += tr( "Ejected: " ); |
241 | what = "off"; | 241 | what = "off"; |
242 | } | 242 | } |
243 | text += cardInPcmcia0Name; | 243 | text += cardInPcmcia0Name; |
244 | popUp( text, "cardmon/" + cardInPcmcia0Type ); | 244 | popUp( text, "cardmon/" + cardInPcmcia0Type ); |
245 | } | 245 | } |
246 | 246 | ||
247 | if ( cardWas1 != cardInPcmcia1 ) { | 247 | if ( cardWas1 != cardInPcmcia1 ) { |
248 | if ( cardInPcmcia1 ) { | 248 | if ( cardInPcmcia1 ) { |
249 | text += tr( "New card: " ); | 249 | text += tr( "New card: " ); |
250 | what = "on"; | 250 | what = "on"; |
251 | } else { | 251 | } else { |
252 | text += tr( "Ejected: " ); | 252 | text += tr( "Ejected: " ); |
253 | what = "off"; | 253 | what = "off"; |
254 | } | 254 | } |
255 | text += cardInPcmcia1Name; | 255 | text += cardInPcmcia1Name; |
256 | popUp( text, "cardmon/" + cardInPcmcia1Type ); | 256 | popUp( text, "cardmon/" + cardInPcmcia1Type ); |
257 | } | 257 | } |
258 | #ifndef QT_NO_SOUND | 258 | #ifndef QT_NO_SOUND |
259 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 259 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); |
260 | #endif | 260 | #endif |
261 | 261 | ||
262 | } | 262 | } |
263 | } else { | 263 | } else { |
264 | // no file found | 264 | // no file found |
265 | odebug << "no file found" << oendl; | 265 | odebug << "no file found" << oendl; |
266 | cardInPcmcia0 = FALSE; | 266 | cardInPcmcia0 = FALSE; |
267 | cardInPcmcia1 = FALSE; | 267 | cardInPcmcia1 = FALSE; |
268 | } | 268 | } |
269 | repaint( FALSE ); | 269 | repaint( FALSE ); |
270 | return ( ( cardWas0 == cardInPcmcia0 | 270 | return ( ( cardWas0 == cardInPcmcia0 |
271 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); | 271 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); |
272 | 272 | ||
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | bool CardMonitor::getStatusSd( int showPopUp ) { | 276 | bool CardMonitor::getStatusSd( int showPopUp ) { |
277 | 277 | ||
278 | bool cardWas = cardInSd; // remember last state | 278 | bool cardWas = cardInSd; // remember last state |
279 | cardInSd = FALSE; | 279 | cardInSd = FALSE; |
280 | 280 | ||
281 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 281 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
282 | 282 | ||
283 | struct mntent *me; | 283 | struct mntent *me; |
284 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 284 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
285 | 285 | ||
286 | if ( mntfp ) { | 286 | if ( mntfp ) { |
287 | while ( ( me = getmntent( mntfp ) ) != 0 ) { | 287 | while ( ( me = getmntent( mntfp ) ) != 0 ) { |
288 | QString fs = QFile::decodeName( me->mnt_fsname ); | 288 | QString fs = QFile::decodeName( me->mnt_fsname ); |
289 | //odebug << fs << oendl; | 289 | //odebug << fs << oendl; |
290 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" | 290 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" |
291 | || fs.left( 9 ) == "/dev/mmcd" || fs.left(11) == "/dev/mmcblk" ) { | 291 | || fs.left( 9 ) == "/dev/mmcd" || fs.left(11) == "/dev/mmcblk" ) { |
292 | cardInSd = TRUE; | 292 | cardInSd = TRUE; |
293 | cardSdName = fs; | 293 | cardSdName = fs; |
294 | show(); | 294 | show(); |
295 | } | 295 | } |
296 | // else { | 296 | // else { |
297 | // cardInSd = FALSE; | 297 | // cardInSd = FALSE; |
298 | // } | 298 | // } |
299 | } | 299 | } |
300 | endmntent( mntfp ); | 300 | endmntent( mntfp ); |
301 | } | 301 | } |
302 | 302 | ||
303 | if ( !showPopUp && cardWas != cardInSd ) { | 303 | if ( !showPopUp && cardWas != cardInSd ) { |
304 | QString text = QString::null; | 304 | QString text = QString::null; |
305 | QString what = QString::null; | 305 | QString what = QString::null; |
306 | if ( cardInSd ) { | 306 | if ( cardInSd ) { |
307 | text += tr("New card: SD/MMC"); | 307 | text += tr("New card: SD/MMC"); |
308 | what = "on"; | 308 | what = "on"; |
309 | } else { | 309 | } else { |
310 | text += tr("Ejected: SD/MMC"); | 310 | text += tr("Ejected: SD/MMC"); |
311 | what = "off"; | 311 | what = "off"; |
312 | } | 312 | } |
313 | //odebug << "TEXT: " + text << oendl; | 313 | //odebug << "TEXT: " + text << oendl; |
314 | #ifndef QT_NO_SOUND | 314 | #ifndef QT_NO_SOUND |
315 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 315 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | popUp( text, "cardmon/ide" ); // XX add SD pic | 318 | popUp( text, "cardmon/ide" ); // XX add SD pic |
319 | } | 319 | } |
320 | #else | 320 | #else |
321 | #error "Not on Linux" | 321 | #error "Not on Linux" |
322 | #endif | 322 | #endif |
323 | repaint( FALSE ); | 323 | repaint( FALSE ); |
324 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); | 324 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); |
325 | } | 325 | } |
326 | 326 | ||
327 | void CardMonitor::paintEvent( QPaintEvent * ) { | 327 | void CardMonitor::paintEvent( QPaintEvent * ) { |
328 | 328 | ||
329 | QPainter p( this ); | 329 | QPainter p( this ); |
330 | 330 | ||
331 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 331 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { |
332 | p.drawPixmap( 0, 0, pm ); | 332 | p.drawPixmap( 0, 0, pm ); |
333 | show(); | 333 | show(); |
334 | } else { | 334 | } else { |
335 | //p.eraseRect(rect()); | 335 | //p.eraseRect(rect()); |
336 | hide(); | 336 | hide(); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | int CardMonitor::position() { | 340 | int CardMonitor::position() { |
341 | return 7; | 341 | return 7; |
342 | } | 342 | } |
343 | 343 | ||
344 | void CardMonitor::execCommand( const QStringList &strList ) { | 344 | void CardMonitor::execCommand( const QStringList &strList ) { |
345 | delete m_process; | 345 | delete m_process; |
346 | m_process = 0; | 346 | m_process = 0; |
347 | 347 | ||
348 | if ( m_process == 0 ) { | 348 | if ( m_process == 0 ) { |
349 | m_process = new OProcess(); | 349 | m_process = new OProcess(); |
350 | 350 | ||
351 | 351 | ||
352 | for ( QStringList::ConstIterator it = strList.begin(); it != strList.end(); ++it ) { | 352 | for ( QStringList::ConstIterator it = strList.begin(); it != strList.end(); ++it ) { |
353 | *m_process << *it; | 353 | *m_process << *it; |
354 | } | 354 | } |
355 | 355 | ||
356 | connect(m_process, SIGNAL(processExited(Opie::Core::OProcess*)), | 356 | connect(m_process, SIGNAL(processExited(Opie::Core::OProcess*)), |
357 | this, SLOT( slotExited(Opie::Core::OProcess*))); | 357 | this, SLOT( slotExited(Opie::Core::OProcess*))); |
358 | 358 | ||
359 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) { | 359 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ) { |
360 | delete m_process; | 360 | delete m_process; |
361 | m_process = 0; | 361 | m_process = 0; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | void CardMonitor::slotExited( OProcess* ) { | 366 | void CardMonitor::slotExited( OProcess* ) { |
367 | 367 | ||
368 | if( m_process->normalExit() ) { | 368 | if( m_process->normalExit() ) { |
369 | int ret = m_process->exitStatus(); | 369 | int ret = m_process->exitStatus(); |
370 | if( ret != 0 ) { | 370 | if( ret != 0 ) { |
371 | if ( m_commandOrig == PCMCIA_Socket1 || | 371 | if ( m_commandOrig == PCMCIA_Socket1 || |
372 | m_commandOrig == PCMCIA_Socket2 ) { | 372 | m_commandOrig == PCMCIA_Socket2 ) { |
373 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 373 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
374 | } else if ( m_commandOrig == MMC_Socket ) { | 374 | } else if ( m_commandOrig == MMC_Socket ) { |
375 | popUp( tr( "SD/MMC card eject failed!" ) ); | 375 | popUp( tr( "SD/MMC card eject failed!" ) ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | EXPORT_OPIE_APPLET_v1( CardMonitor ) | 381 | EXPORT_OPIE_APPLET_v1( CardMonitor ) |
382 | 382 | ||
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index a30bd8b..02404e5 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -1,884 +1,884 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> | 4 | Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* hacky but we need to get FileSelector::filter */ | 31 | /* hacky but we need to get FileSelector::filter */ |
32 | #define private public | 32 | #define private public |
33 | #include <qpe/fileselector.h> | 33 | #include <qpe/fileselector.h> |
34 | #undef private | 34 | #undef private |
35 | 35 | ||
36 | #include "ofileselector_p.h" | 36 | #include "ofileselector_p.h" |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/odebug.h> | 39 | #include <opie2/odebug.h> |
40 | #include <opie2/ofileselector.h> | 40 | #include <opie2/ofileselector.h> |
41 | #include <opie2/oresource.h> | 41 | #include <opie2/oresource.h> |
42 | 42 | ||
43 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
44 | #include <qpe/mimetype.h> | 44 | #include <qpe/mimetype.h> |
45 | #include <qpe/storage.h> | 45 | #include <qpe/storage.h> |
46 | 46 | ||
47 | /* QT */ | 47 | /* QT */ |
48 | #include <qcombobox.h> | 48 | #include <qcombobox.h> |
49 | #include <qdir.h> | 49 | #include <qdir.h> |
50 | #include <qhbox.h> | 50 | #include <qhbox.h> |
51 | #include <qheader.h> | 51 | #include <qheader.h> |
52 | #include <qlabel.h> | 52 | #include <qlabel.h> |
53 | #include <qlayout.h> | 53 | #include <qlayout.h> |
54 | #include <qlineedit.h> | 54 | #include <qlineedit.h> |
55 | #include <qlistview.h> | 55 | #include <qlistview.h> |
56 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
57 | #include <qwidgetstack.h> | 57 | #include <qwidgetstack.h> |
58 | #include <qregexp.h> | 58 | #include <qregexp.h> |
59 | #include <qobjectlist.h> | 59 | #include <qobjectlist.h> |
60 | 60 | ||
61 | using namespace Opie::Ui::Internal; | 61 | using namespace Opie::Ui::Internal; |
62 | 62 | ||
63 | namespace Opie { | 63 | namespace Opie { |
64 | namespace Ui { | 64 | namespace Ui { |
65 | namespace Internal { | 65 | namespace Internal { |
66 | /* | 66 | /* |
67 | * Create a path by adding a '/'/QDir::seperator in between | 67 | * Create a path by adding a '/'/QDir::seperator in between |
68 | * base and ending, but only if base is not empty | 68 | * base and ending, but only if base is not empty |
69 | */ | 69 | */ |
70 | static inline QString createNewPath(const QString& base, const QString &ending) { | 70 | static inline QString createNewPath(const QString& base, const QString &ending) { |
71 | return base == QString::fromLatin1("/") ? | 71 | return base == QString::fromLatin1("/") ? |
72 | base + ending : base + "/" + ending; | 72 | base + ending : base + "/" + ending; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) | 76 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) |
77 | : m_selector( _selector ) | 77 | : m_selector( _selector ) |
78 | { | 78 | { |
79 | selector()->registerView( this ); | 79 | selector()->registerView( this ); |
80 | } | 80 | } |
81 | 81 | ||
82 | OFileViewInterface::~OFileViewInterface() | 82 | OFileViewInterface::~OFileViewInterface() |
83 | {} | 83 | {} |
84 | 84 | ||
85 | QString OFileViewInterface::name()const | 85 | QString OFileViewInterface::name()const |
86 | { | 86 | { |
87 | return m_name; | 87 | return m_name; |
88 | } | 88 | } |
89 | 89 | ||
90 | void OFileViewInterface::setName( const QString& name ) | 90 | void OFileViewInterface::setName( const QString& name ) |
91 | { | 91 | { |
92 | m_name = name; | 92 | m_name = name; |
93 | } | 93 | } |
94 | 94 | ||
95 | OFileSelector* OFileViewInterface::selector()const | 95 | OFileSelector* OFileViewInterface::selector()const |
96 | { | 96 | { |
97 | return m_selector; | 97 | return m_selector; |
98 | } | 98 | } |
99 | 99 | ||
100 | DocLnk OFileViewInterface::selectedDocument()const | 100 | DocLnk OFileViewInterface::selectedDocument()const |
101 | { | 101 | { |
102 | return DocLnk( selectedName() ); | 102 | return DocLnk( selectedName() ); |
103 | } | 103 | } |
104 | 104 | ||
105 | bool OFileViewInterface::showNew()const | 105 | bool OFileViewInterface::showNew()const |
106 | { | 106 | { |
107 | return selector()->showNew(); | 107 | return selector()->showNew(); |
108 | } | 108 | } |
109 | 109 | ||
110 | bool OFileViewInterface::showClose()const | 110 | bool OFileViewInterface::showClose()const |
111 | { | 111 | { |
112 | return selector()->showClose(); | 112 | return selector()->showClose(); |
113 | } | 113 | } |
114 | 114 | ||
115 | MimeTypes OFileViewInterface::mimeTypes()const | 115 | MimeTypes OFileViewInterface::mimeTypes()const |
116 | { | 116 | { |
117 | return selector()->mimeTypes(); | 117 | return selector()->mimeTypes(); |
118 | } | 118 | } |
119 | 119 | ||
120 | QStringList OFileViewInterface::currentMimeType()const | 120 | QStringList OFileViewInterface::currentMimeType()const |
121 | { | 121 | { |
122 | return selector()->currentMimeType(); | 122 | return selector()->currentMimeType(); |
123 | } | 123 | } |
124 | 124 | ||
125 | void OFileViewInterface::activate( const QString& ) | 125 | void OFileViewInterface::activate( const QString& ) |
126 | { | 126 | { |
127 | // not implemented here | 127 | // not implemented here |
128 | } | 128 | } |
129 | 129 | ||
130 | void OFileViewInterface::ok() | 130 | void OFileViewInterface::ok() |
131 | { | 131 | { |
132 | emit selector()->ok(); | 132 | emit selector()->ok(); |
133 | } | 133 | } |
134 | 134 | ||
135 | void OFileViewInterface::cancel() | 135 | void OFileViewInterface::cancel() |
136 | { | 136 | { |
137 | emit selector()->cancel(); | 137 | emit selector()->cancel(); |
138 | } | 138 | } |
139 | 139 | ||
140 | void OFileViewInterface::closeMe() | 140 | void OFileViewInterface::closeMe() |
141 | { | 141 | { |
142 | emit selector()->closeMe(); | 142 | emit selector()->closeMe(); |
143 | } | 143 | } |
144 | 144 | ||
145 | void OFileViewInterface::fileSelected( const QString& str) | 145 | void OFileViewInterface::fileSelected( const QString& str) |
146 | { | 146 | { |
147 | emit selector()->fileSelected( str); | 147 | emit selector()->fileSelected( str); |
148 | } | 148 | } |
149 | 149 | ||
150 | void OFileViewInterface::fileSelected( const DocLnk& lnk) | 150 | void OFileViewInterface::fileSelected( const DocLnk& lnk) |
151 | { | 151 | { |
152 | emit selector()->fileSelected( lnk ); | 152 | emit selector()->fileSelected( lnk ); |
153 | } | 153 | } |
154 | 154 | ||
155 | void OFileViewInterface::setCurrentFileName( const QString& str ) | 155 | void OFileViewInterface::setCurrentFileName( const QString& str ) |
156 | { | 156 | { |
157 | selector()->m_lneEdit->setText( str ); | 157 | selector()->m_lneEdit->setText( str ); |
158 | } | 158 | } |
159 | 159 | ||
160 | QString OFileViewInterface::currentFileName()const | 160 | QString OFileViewInterface::currentFileName()const |
161 | { | 161 | { |
162 | return selector()->m_lneEdit->text(); | 162 | return selector()->m_lneEdit->text(); |
163 | } | 163 | } |
164 | 164 | ||
165 | QString OFileViewInterface::startDirectory()const | 165 | QString OFileViewInterface::startDirectory()const |
166 | { | 166 | { |
167 | return selector()->m_startDir; | 167 | return selector()->m_startDir; |
168 | } | 168 | } |
169 | 169 | ||
170 | bool OFileViewInterface::allItem( const QString& item )const | 170 | bool OFileViewInterface::allItem( const QString& item )const |
171 | { | 171 | { |
172 | return selector()->m_allList.contains( item ); | 172 | return selector()->m_allList.contains( item ); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 176 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
177 | :OFileViewInterface( selector ) | 177 | :OFileViewInterface( selector ) |
178 | { | 178 | { |
179 | m_selector = 0; | 179 | m_selector = 0; |
180 | setName( QObject::tr("Documents") ); | 180 | setName( QObject::tr("Documents") ); |
181 | } | 181 | } |
182 | 182 | ||
183 | ODocumentFileView::~ODocumentFileView() | 183 | ODocumentFileView::~ODocumentFileView() |
184 | { | 184 | { |
185 | } | 185 | } |
186 | 186 | ||
187 | QString ODocumentFileView::selectedName()const | 187 | QString ODocumentFileView::selectedName()const |
188 | { | 188 | { |
189 | if (!m_selector) | 189 | if (!m_selector) |
190 | return QString::null; | 190 | return QString::null; |
191 | 191 | ||
192 | return m_selector->selectedDocument().file(); | 192 | return m_selector->selectedDocument().file(); |
193 | } | 193 | } |
194 | 194 | ||
195 | QString ODocumentFileView::selectedPath()const | 195 | QString ODocumentFileView::selectedPath()const |
196 | { | 196 | { |
197 | return QPEApplication::documentDir(); | 197 | return QPEApplication::documentDir(); |
198 | } | 198 | } |
199 | 199 | ||
200 | QString ODocumentFileView::directory()const | 200 | QString ODocumentFileView::directory()const |
201 | { | 201 | { |
202 | return selectedPath(); | 202 | return selectedPath(); |
203 | } | 203 | } |
204 | 204 | ||
205 | void ODocumentFileView::reread() | 205 | void ODocumentFileView::reread() |
206 | { | 206 | { |
207 | if (!m_selector) | 207 | if (!m_selector) |
208 | return; | 208 | return; |
209 | 209 | ||
210 | m_selector->setNewVisible( showNew() ); | 210 | m_selector->setNewVisible( showNew() ); |
211 | m_selector->setCloseVisible( showClose() ); | 211 | m_selector->setCloseVisible( showClose() ); |
212 | m_selector->filter = currentMimeType().join(";"); | 212 | m_selector->filter = currentMimeType().join(";"); |
213 | m_selector->reread(); | 213 | m_selector->reread(); |
214 | } | 214 | } |
215 | 215 | ||
216 | int ODocumentFileView::fileCount()const | 216 | int ODocumentFileView::fileCount()const |
217 | { | 217 | { |
218 | if (!m_selector) | 218 | if (!m_selector) |
219 | return -1; | 219 | return -1; |
220 | 220 | ||
221 | return m_selector->fileCount(); | 221 | return m_selector->fileCount(); |
222 | } | 222 | } |
223 | 223 | ||
224 | DocLnk ODocumentFileView::selectedDocument()const | 224 | DocLnk ODocumentFileView::selectedDocument()const |
225 | { | 225 | { |
226 | if (!m_selector) | 226 | if (!m_selector) |
227 | return DocLnk(); | 227 | return DocLnk(); |
228 | 228 | ||
229 | return m_selector->selectedDocument(); | 229 | return m_selector->selectedDocument(); |
230 | } | 230 | } |
231 | 231 | ||
232 | QWidget* ODocumentFileView::widget( QWidget* parent ) | 232 | QWidget* ODocumentFileView::widget( QWidget* parent ) |
233 | { | 233 | { |
234 | if (!m_selector ) | 234 | if (!m_selector ) |
235 | { | 235 | { |
236 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 236 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
237 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), | 237 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), |
238 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 238 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
239 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 239 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
240 | selector(), SIGNAL(closeMe() ) ); | 240 | selector(), SIGNAL(closeMe() ) ); |
241 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), | 241 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), |
242 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); | 242 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); |
243 | } | 243 | } |
244 | 244 | ||
245 | return m_selector; | 245 | return m_selector; |
246 | } | 246 | } |
247 | 247 | ||
248 | /* | 248 | /* |
249 | * This is the file system view used | 249 | * This is the file system view used |
250 | * we use a QListView + QListViewItems for it | 250 | * we use a QListView + QListViewItems for it |
251 | */ | 251 | */ |
252 | 252 | ||
253 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 253 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
254 | const QString& path, const QString& date, | 254 | const QString& path, const QString& date, |
255 | const QString& size, const QString& dir, | 255 | const QString& size, const QString& dir, |
256 | bool isLocked, bool isDir ) | 256 | bool isLocked, bool isDir ) |
257 | : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) | 257 | : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) |
258 | { | 258 | { |
259 | setPixmap(0, pixmap ); | 259 | setPixmap(0, pixmap ); |
260 | setText(1, path ); | 260 | setText(1, path ); |
261 | setText(2, size ); | 261 | setText(2, size ); |
262 | setText(3, date ); | 262 | setText(3, date ); |
263 | } | 263 | } |
264 | 264 | ||
265 | OFileSelectorItem::~OFileSelectorItem() | 265 | OFileSelectorItem::~OFileSelectorItem() |
266 | { | 266 | { |
267 | } | 267 | } |
268 | 268 | ||
269 | bool OFileSelectorItem::isLocked()const | 269 | bool OFileSelectorItem::isLocked()const |
270 | { | 270 | { |
271 | return m_locked; | 271 | return m_locked; |
272 | } | 272 | } |
273 | 273 | ||
274 | QString OFileSelectorItem::directory()const | 274 | QString OFileSelectorItem::directory()const |
275 | { | 275 | { |
276 | return m_dir; | 276 | return m_dir; |
277 | } | 277 | } |
278 | 278 | ||
279 | bool OFileSelectorItem::isDir()const | 279 | bool OFileSelectorItem::isDir()const |
280 | { | 280 | { |
281 | return m_isDir; | 281 | return m_isDir; |
282 | } | 282 | } |
283 | 283 | ||
284 | QString OFileSelectorItem::path()const | 284 | QString OFileSelectorItem::path()const |
285 | { | 285 | { |
286 | return text( 1 ); | 286 | return text( 1 ); |
287 | } | 287 | } |
288 | 288 | ||
289 | QString OFileSelectorItem::key( int id, bool )const | 289 | QString OFileSelectorItem::key( int id, bool )const |
290 | { | 290 | { |
291 | QString ke; | 291 | QString ke; |
292 | 292 | ||
293 | /* | 293 | /* |
294 | * id = 0 ||id == 1 : Sort By Name but Directories at Top | 294 | * id = 0 ||id == 1 : Sort By Name but Directories at Top |
295 | * id = 2 : Sort By Size: Prepend '0' to the key | 295 | * id = 2 : Sort By Size: Prepend '0' to the key |
296 | */ | 296 | */ |
297 | if( id == 0 || id == 1 ) | 297 | if( id == 0 || id == 1 ) |
298 | { // name | 298 | { // name |
299 | if( m_isDir ) | 299 | if( m_isDir ) |
300 | { | 300 | { |
301 | ke.append("0" ); | 301 | ke.append("0" ); |
302 | ke.append( text(1) ); | 302 | ke.append( text(1) ); |
303 | } | 303 | } |
304 | else | 304 | else |
305 | { | 305 | { |
306 | ke.append("1" ); | 306 | ke.append("1" ); |
307 | ke.append( text(1) ); | 307 | ke.append( text(1) ); |
308 | } | 308 | } |
309 | return ke; | 309 | return ke; |
310 | }else if(id == 2) { | 310 | }else if(id == 2) { |
311 | return text(2).rightJustify(20, '0'); | 311 | return text(2).rightJustify(20, '0'); |
312 | }else | 312 | }else |
313 | return text( id ); | 313 | return text( id ); |
314 | 314 | ||
315 | } | 315 | } |
316 | 316 | ||
317 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) | 317 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) |
318 | :QWidget( parent ), m_sel( sel ) | 318 | :QWidget( parent ), m_sel( sel ) |
319 | { | 319 | { |
320 | m_all = false; | 320 | m_all = false; |
321 | QVBoxLayout* lay = new QVBoxLayout( this ); | 321 | QVBoxLayout* lay = new QVBoxLayout( this ); |
322 | m_currentDir = startDir; | 322 | m_currentDir = startDir; |
323 | bool bigicons = qApp->desktop()->size().width()>330; | 323 | bool bigicons = qApp->desktop()->size().width()>330; |
324 | 324 | ||
325 | /* | 325 | /* |
326 | * now we add a special bar | 326 | * now we add a special bar |
327 | * One Button For Up | 327 | * One Button For Up |
328 | * Home | 328 | * Home |
329 | * Doc | 329 | * Doc |
330 | * And a dropdown menu with FileSystems | 330 | * And a dropdown menu with FileSystems |
331 | * FUTURE: one to change dir with lineedit | 331 | * FUTURE: one to change dir with lineedit |
332 | * Bookmarks | 332 | * Bookmarks |
333 | * Create Dir | 333 | * Create Dir |
334 | */ | 334 | */ |
335 | QHBox* box = new QHBox(this ); | 335 | QHBox* box = new QHBox(this ); |
336 | box->setBackgroundMode( PaletteButton ); | 336 | box->setBackgroundMode( PaletteButton ); |
337 | box->setSpacing( 0 ); | 337 | box->setSpacing( 0 ); |
338 | 338 | ||
339 | QToolButton *btn = new QToolButton( box ); | 339 | QToolButton *btn = new QToolButton( box ); |
340 | btn->setUsesBigPixmap(bigicons); | 340 | btn->setUsesBigPixmap(bigicons); |
341 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); | 341 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); |
342 | connect(btn, SIGNAL(clicked() ), | 342 | connect(btn, SIGNAL(clicked() ), |
343 | this, SLOT( cdUP() ) ); | 343 | this, SLOT( cdUP() ) ); |
344 | 344 | ||
345 | btn = new QToolButton( box ); | 345 | btn = new QToolButton( box ); |
346 | btn->setUsesBigPixmap(bigicons); | 346 | btn->setUsesBigPixmap(bigicons); |
347 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) ); | 347 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) ); |
348 | connect(btn, SIGNAL(clicked() ), | 348 | connect(btn, SIGNAL(clicked() ), |
349 | this, SLOT( cdHome() ) ); | 349 | this, SLOT( cdHome() ) ); |
350 | 350 | ||
351 | btn = new QToolButton( box ); | 351 | btn = new QToolButton( box ); |
352 | btn->setUsesBigPixmap(bigicons); | 352 | btn->setUsesBigPixmap(bigicons); |
353 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) ); | 353 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) ); |
354 | connect(btn, SIGNAL(clicked() ), | 354 | connect(btn, SIGNAL(clicked() ), |
355 | this, SLOT(cdDoc() ) ); | 355 | this, SLOT(cdDoc() ) ); |
356 | 356 | ||
357 | m_btnNew = new QToolButton( box ); | 357 | m_btnNew = new QToolButton( box ); |
358 | m_btnNew->setUsesBigPixmap(bigicons); | 358 | m_btnNew->setUsesBigPixmap(bigicons); |
359 | m_btnNew->setPixmap( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ) ); | 359 | m_btnNew->setPixmap( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ) ); |
360 | connect(m_btnNew, SIGNAL(clicked() ), | 360 | connect(m_btnNew, SIGNAL(clicked() ), |
361 | this, SLOT(slotNew() ) ); | 361 | this, SLOT(slotNew() ) ); |
362 | 362 | ||
363 | 363 | ||
364 | m_btnClose = new QToolButton( box ); | 364 | m_btnClose = new QToolButton( box ); |
365 | m_btnClose->setUsesBigPixmap(bigicons); | 365 | m_btnClose->setUsesBigPixmap(bigicons); |
366 | m_btnClose->setPixmap( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) ); | 366 | m_btnClose->setPixmap( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) ); |
367 | connect(m_btnClose, SIGNAL(clicked() ), | 367 | connect(m_btnClose, SIGNAL(clicked() ), |
368 | selector(), SIGNAL(closeMe() ) ); | 368 | selector(), SIGNAL(closeMe() ) ); |
369 | 369 | ||
370 | btn = new QToolButton( box ); | 370 | btn = new QToolButton( box ); |
371 | btn->setUsesBigPixmap(bigicons); | 371 | btn->setUsesBigPixmap(bigicons); |
372 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) ); | 372 | btn->setPixmap( Opie::Core::OResource::loadPixmap( "pcmcia", Opie::Core::OResource::SmallIcon ) ); |
373 | 373 | ||
374 | m_fsButton = btn; | 374 | m_fsButton = btn; |
375 | /* let's fill device parts */ | 375 | /* let's fill device parts */ |
376 | QPopupMenu* pop = new QPopupMenu(this); | 376 | QPopupMenu* pop = new QPopupMenu(this); |
377 | connect(pop, SIGNAL( activated(int) ), | 377 | connect(pop, SIGNAL( activated(int) ), |
378 | this, SLOT(slotFSActivated(int) ) ); | 378 | this, SLOT(slotFSActivated(int) ) ); |
379 | 379 | ||
380 | StorageInfo storage; | 380 | StorageInfo storage; |
381 | const QList<FileSystem> &fs = storage.fileSystems(); | 381 | const QList<FileSystem> &fs = storage.fileSystems(); |
382 | QListIterator<FileSystem> it(fs); | 382 | QListIterator<FileSystem> it(fs); |
383 | for ( ; it.current(); ++it ) | 383 | for ( ; it.current(); ++it ) |
384 | { | 384 | { |
385 | const QString disk = (*it)->name(); | 385 | const QString disk = (*it)->name(); |
386 | const QString path = (*it)->path(); | 386 | const QString path = (*it)->path(); |
387 | m_dev.insert( disk, path ); | 387 | m_dev.insert( disk, path ); |
388 | pop->insertItem( disk ); | 388 | pop->insertItem( disk ); |
389 | } | 389 | } |
390 | m_fsPop = pop; | 390 | m_fsPop = pop; |
391 | 391 | ||
392 | connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed())); | 392 | connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed())); |
393 | 393 | ||
394 | lay->addWidget( box ); | 394 | lay->addWidget( box ); |
395 | 395 | ||
396 | m_view = new QListView( this ); | 396 | m_view = new QListView( this ); |
397 | 397 | ||
398 | m_view->installEventFilter(this); | 398 | m_view->installEventFilter(this); |
399 | 399 | ||
400 | QPEApplication::setStylusOperation( m_view->viewport(), | 400 | QPEApplication::setStylusOperation( m_view->viewport(), |
401 | QPEApplication::RightOnHold); | 401 | QPEApplication::RightOnHold); |
402 | m_view->addColumn(" " ); | 402 | m_view->addColumn(" " ); |
403 | m_view->addColumn(tr("Name"), 135 ); | 403 | m_view->addColumn(tr("Name"), 135 ); |
404 | m_view->addColumn(tr("Size"), -1 ); | 404 | m_view->addColumn(tr("Size"), -1 ); |
405 | m_view->addColumn(tr("Date"), 60 ); | 405 | m_view->addColumn(tr("Date"), 60 ); |
406 | m_view->addColumn(tr("Mime Type"), -1 ); | 406 | m_view->addColumn(tr("Mime Type"), -1 ); |
407 | 407 | ||
408 | 408 | ||
409 | m_view->setSorting( 1 ); | 409 | m_view->setSorting( 1 ); |
410 | m_view->setAllColumnsShowFocus( TRUE ); | 410 | m_view->setAllColumnsShowFocus( TRUE ); |
411 | 411 | ||
412 | lay->addWidget( m_view, 1000 ); | 412 | lay->addWidget( m_view, 1000 ); |
413 | connectSlots(); | 413 | connectSlots(); |
414 | } | 414 | } |
415 | 415 | ||
416 | void OFileViewFileListView::slotFSpressed() | 416 | void OFileViewFileListView::slotFSpressed() |
417 | { | 417 | { |
418 | m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y())); | 418 | m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y())); |
419 | m_fsButton->setDown(false); | 419 | m_fsButton->setDown(false); |
420 | } | 420 | } |
421 | 421 | ||
422 | OFileViewFileListView::~OFileViewFileListView() | 422 | OFileViewFileListView::~OFileViewFileListView() |
423 | { | 423 | { |
424 | } | 424 | } |
425 | 425 | ||
426 | void OFileViewFileListView::slotNew() | 426 | void OFileViewFileListView::slotNew() |
427 | { | 427 | { |
428 | DocLnk lnk; | 428 | DocLnk lnk; |
429 | emit selector()->newSelected( lnk ); | 429 | emit selector()->newSelected( lnk ); |
430 | } | 430 | } |
431 | 431 | ||
432 | OFileSelectorItem* OFileViewFileListView::currentItem()const | 432 | OFileSelectorItem* OFileViewFileListView::currentItem()const |
433 | { | 433 | { |
434 | QListViewItem* item = m_view->currentItem(); | 434 | QListViewItem* item = m_view->currentItem(); |
435 | if (!item ) | 435 | if (!item ) |
436 | return 0l; | 436 | return 0l; |
437 | 437 | ||
438 | return static_cast<OFileSelectorItem*>(item); | 438 | return static_cast<OFileSelectorItem*>(item); |
439 | } | 439 | } |
440 | 440 | ||
441 | void OFileViewFileListView::reread( bool all ) | 441 | void OFileViewFileListView::reread( bool all ) |
442 | { | 442 | { |
443 | m_view->clear(); | 443 | m_view->clear(); |
444 | 444 | ||
445 | if (selector()->showClose() ) | 445 | if (selector()->showClose() ) |
446 | m_btnClose->show(); | 446 | m_btnClose->show(); |
447 | else | 447 | else |
448 | m_btnClose->hide(); | 448 | m_btnClose->hide(); |
449 | 449 | ||
450 | if (selector()->showNew() ) | 450 | if (selector()->showNew() ) |
451 | m_btnNew->show(); | 451 | m_btnNew->show(); |
452 | else | 452 | else |
453 | m_btnNew->hide(); | 453 | m_btnNew->hide(); |
454 | 454 | ||
455 | m_mimes = selector()->currentMimeType(); | 455 | m_mimes = selector()->currentMimeType(); |
456 | m_all = all; | 456 | m_all = all; |
457 | 457 | ||
458 | QDir dir( m_currentDir ); | 458 | QDir dir( m_currentDir ); |
459 | if (!dir.exists() ) | 459 | if (!dir.exists() ) |
460 | return; | 460 | return; |
461 | 461 | ||
462 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 462 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
463 | int filter; | 463 | int filter; |
464 | filter = QDir::Dirs; | 464 | filter = QDir::Dirs; |
465 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) | 465 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) |
466 | filter = filter | QDir::Files | QDir::All; | 466 | filter = filter | QDir::Files | QDir::All; |
467 | 467 | ||
468 | if ( m_all ) | 468 | if ( m_all ) |
469 | filter = filter | QDir::Hidden; | 469 | filter = filter | QDir::Hidden; |
470 | 470 | ||
471 | dir.setFilter( filter ); | 471 | dir.setFilter( filter ); |
472 | 472 | ||
473 | // now go through all files | 473 | // now go through all files |
474 | const QFileInfoList *list = dir.entryInfoList(); | 474 | const QFileInfoList *list = dir.entryInfoList(); |
475 | if (!list) | 475 | if (!list) |
476 | { | 476 | { |
477 | cdUP(); | 477 | cdUP(); |
478 | return; | 478 | return; |
479 | } | 479 | } |
480 | 480 | ||
481 | QFileInfoListIterator it( *list ); | 481 | QFileInfoListIterator it( *list ); |
482 | QFileInfo *fi; | 482 | QFileInfo *fi; |
483 | while( (fi=it.current() ) ) | 483 | while( (fi=it.current() ) ) |
484 | { | 484 | { |
485 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) | 485 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) |
486 | { | 486 | { |
487 | ++it; | 487 | ++it; |
488 | continue; | 488 | continue; |
489 | } | 489 | } |
490 | 490 | ||
491 | /* | 491 | /* |
492 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 492 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
493 | * | 493 | * |
494 | */ | 494 | */ |
495 | if( fi->isSymLink() ) | 495 | if( fi->isSymLink() ) |
496 | { | 496 | { |
497 | QString file = createNewPath(fi->dirPath( true ),fi->readLink()); | 497 | QString file = createNewPath(fi->dirPath( true ),fi->readLink()); |
498 | for( int i = 0; i<=4; i++) | 498 | for( int i = 0; i<=4; i++) |
499 | { // 5 tries to prevent dos | 499 | { // 5 tries to prevent dos |
500 | QFileInfo info( file ); | 500 | QFileInfo info( file ); |
501 | if( !info.exists() ) | 501 | if( !info.exists() ) |
502 | { | 502 | { |
503 | addSymlink( fi, TRUE ); | 503 | addSymlink( fi, TRUE ); |
504 | break; | 504 | break; |
505 | } | 505 | } |
506 | else if( info.isDir() ) | 506 | else if( info.isDir() ) |
507 | { | 507 | { |
508 | addDir( fi, TRUE ); | 508 | addDir( fi, TRUE ); |
509 | break; | 509 | break; |
510 | } | 510 | } |
511 | else if( info.isFile() ) | 511 | else if( info.isFile() ) |
512 | { | 512 | { |
513 | addFile( fi, TRUE ); | 513 | addFile( fi, TRUE ); |
514 | break; | 514 | break; |
515 | } | 515 | } |
516 | else if( info.isSymLink() ) | 516 | else if( info.isSymLink() ) |
517 | { | 517 | { |
518 | file = createNewPath(info.dirPath(true ),info.readLink()); | 518 | file = createNewPath(info.dirPath(true ),info.readLink()); |
519 | break; | 519 | break; |
520 | } | 520 | } |
521 | else if( i == 4) | 521 | else if( i == 4) |
522 | { // couldn't resolve symlink add it as symlink | 522 | { // couldn't resolve symlink add it as symlink |
523 | addSymlink( fi ); | 523 | addSymlink( fi ); |
524 | } | 524 | } |
525 | } // off for loop for symlink resolving | 525 | } // off for loop for symlink resolving |
526 | } | 526 | } |
527 | else if( fi->isDir() ) | 527 | else if( fi->isDir() ) |
528 | addDir( fi ); | 528 | addDir( fi ); |
529 | else if( fi->isFile() ) | 529 | else if( fi->isFile() ) |
530 | addFile( fi ); | 530 | addFile( fi ); |
531 | 531 | ||
532 | ++it; | 532 | ++it; |
533 | } // of while loop | 533 | } // of while loop |
534 | m_view->sort(); | 534 | m_view->sort(); |
535 | 535 | ||
536 | } | 536 | } |
537 | int OFileViewFileListView::fileCount()const | 537 | int OFileViewFileListView::fileCount()const |
538 | { | 538 | { |
539 | return m_view->childCount(); | 539 | return m_view->childCount(); |
540 | } | 540 | } |
541 | 541 | ||
542 | QString OFileViewFileListView::currentDir()const | 542 | QString OFileViewFileListView::currentDir()const |
543 | { | 543 | { |
544 | return m_currentDir; | 544 | return m_currentDir; |
545 | } | 545 | } |
546 | 546 | ||
547 | OFileSelector* OFileViewFileListView::selector() | 547 | OFileSelector* OFileViewFileListView::selector() |
548 | { | 548 | { |
549 | return m_sel; | 549 | return m_sel; |
550 | } | 550 | } |
551 | 551 | ||
552 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) | 552 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) |
553 | { | 553 | { |
554 | if ( e->type() == QEvent::KeyPress ) | 554 | if ( e->type() == QEvent::KeyPress ) |
555 | { | 555 | { |
556 | QKeyEvent *k = (QKeyEvent *)e; | 556 | QKeyEvent *k = (QKeyEvent *)e; |
557 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 557 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
558 | { | 558 | { |
559 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 559 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
560 | return true; | 560 | return true; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | return false; | 563 | return false; |
564 | } | 564 | } |
565 | 565 | ||
566 | void OFileViewFileListView::connectSlots() | 566 | void OFileViewFileListView::connectSlots() |
567 | { | 567 | { |
568 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 568 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
569 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 569 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
570 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 570 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
571 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); | 571 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
572 | } | 572 | } |
573 | 573 | ||
574 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | 574 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) |
575 | { | 575 | { |
576 | if (!item) | 576 | if (!item) |
577 | return; | 577 | return; |
578 | #if 0 | 578 | #if 0 |
579 | 579 | ||
580 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 580 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
581 | 581 | ||
582 | if (!sel->isDir() ) | 582 | if (!sel->isDir() ) |
583 | { | 583 | { |
584 | selector()->m_lneEdit->setText( sel->text(1) ); | 584 | selector()->m_lneEdit->setText( sel->text(1) ); |
585 | // if in fileselector mode we will emit selected | 585 | // if in fileselector mode we will emit selected |
586 | if ( selector()->mode() == OFileSelector::FileSelector ) | 586 | if ( selector()->mode() == OFileSelector::FileSelector ) |
587 | { | 587 | { |
588 | odebug << "slot Current Changed" << oendl; | 588 | odebug << "slot Current Changed" << oendl; |
589 | QStringList str = QStringList::split("->", sel->text(1) ); | 589 | QStringList str = QStringList::split("->", sel->text(1) ); |
590 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 590 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
591 | emit selector()->fileSelected( path ); | 591 | emit selector()->fileSelected( path ); |
592 | DocLnk lnk( path ); | 592 | DocLnk lnk( path ); |
593 | emit selector()->fileSelected( lnk ); | 593 | emit selector()->fileSelected( lnk ); |
594 | } | 594 | } |
595 | } | 595 | } |
596 | #endif | 596 | #endif |
597 | } | 597 | } |
598 | 598 | ||
599 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) | 599 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) |
600 | { | 600 | { |
601 | if (!item || ( button != Qt::LeftButton) ) | 601 | if (!item || ( button != Qt::LeftButton) ) |
602 | return; | 602 | return; |
603 | 603 | ||
604 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 604 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
605 | if (!sel->isLocked() ) | 605 | if (!sel->isLocked() ) |
606 | { | 606 | { |
607 | QStringList str = QStringList::split("->", sel->text(1) ); | 607 | QStringList str = QStringList::split("->", sel->text(1) ); |
608 | if (sel->isDir() ) | 608 | if (sel->isDir() ) |
609 | { | 609 | { |
610 | m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 610 | m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
611 | emit selector()->dirSelected( m_currentDir ); | 611 | emit selector()->dirSelected( m_currentDir ); |
612 | reread( m_all ); | 612 | reread( m_all ); |
613 | } | 613 | } |
614 | else | 614 | else |
615 | { // file | 615 | { // file |
616 | odebug << "slot Clicked" << oendl; | 616 | odebug << "slot Clicked" << oendl; |
617 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 617 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
618 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 618 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
619 | emit selector()->fileSelected( path ); | 619 | emit selector()->fileSelected( path ); |
620 | DocLnk lnk( path ); | 620 | DocLnk lnk( path ); |
621 | emit selector()->fileSelected( lnk ); | 621 | emit selector()->fileSelected( lnk ); |
622 | } | 622 | } |
623 | } // not locked | 623 | } // not locked |
624 | } | 624 | } |
625 | 625 | ||
626 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) | 626 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) |
627 | { | 627 | { |
628 | MimeType type( info->absFilePath() ); | 628 | MimeType type( info->absFilePath() ); |
629 | if (!compliesMime( type.id() ) ) | 629 | if (!compliesMime( type.id() ) ) |
630 | return; | 630 | return; |
631 | 631 | ||
632 | QPixmap pix = type.pixmap(); | 632 | QPixmap pix = type.pixmap(); |
633 | QString dir, name; bool locked; | 633 | QString dir, name; bool locked; |
634 | if ( pix.isNull() ) | 634 | if ( pix.isNull() ) |
635 | { | 635 | { |
636 | QWMatrix matrix; | 636 | QWMatrix matrix; |
637 | QPixmap pixer( Opie::Core::OResource::loadPixmap( "UnknownDocument" ) ); | 637 | QPixmap pixer( Opie::Core::OResource::loadPixmap( "UnknownDocument" ) ); |
638 | matrix.scale( .4, .4 ); | 638 | matrix.scale( .4, .4 ); |
639 | pix = pixer.xForm( matrix ); | 639 | pix = pixer.xForm( matrix ); |
640 | } | 640 | } |
641 | dir = info->dirPath( true ); | 641 | dir = info->dirPath( true ); |
642 | locked = false; | 642 | locked = false; |
643 | if ( symlink ) | 643 | if ( symlink ) |
644 | name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink()); | 644 | name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink()); |
645 | else | 645 | else |
646 | { | 646 | { |
647 | name = info->fileName(); | 647 | name = info->fileName(); |
648 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 648 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
649 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) | 649 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) |
650 | { | 650 | { |
651 | locked = true; | 651 | locked = true; |
652 | pix = Opie::Core::OResource::loadPixmap( "locked" ); | 652 | pix = Opie::Core::OResource::loadPixmap( "locked" ); |
653 | } | 653 | } |
654 | } | 654 | } |
655 | (void)new OFileSelectorItem( m_view, pix, name, | 655 | (void)new OFileSelectorItem( m_view, pix, name, |
656 | info->lastModified().toString(), QString::number( info->size() ), | 656 | info->lastModified().toString(), QString::number( info->size() ), |
657 | dir, locked ); | 657 | dir, locked ); |
658 | } | 658 | } |
659 | 659 | ||
660 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) | 660 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) |
661 | { | 661 | { |
662 | bool locked = false; QString name; QPixmap pix; | 662 | bool locked = false; QString name; QPixmap pix; |
663 | 663 | ||
664 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 664 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
665 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) | 665 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) |
666 | { | 666 | { |
667 | locked = true; | 667 | locked = true; |
668 | if ( symlink ) | 668 | if ( symlink ) |
669 | pix = Opie::Core::OResource::loadPixmap( "opie/symlink" ); | 669 | pix = Opie::Core::OResource::loadPixmap( "opie/symlink" ); |
670 | else | 670 | else |
671 | pix = Opie::Core::OResource::loadPixmap( "lockedfolder" ); | 671 | pix = Opie::Core::OResource::loadPixmap( "lockedfolder" ); |
672 | } | 672 | } |
673 | else | 673 | else |
674 | pix = symlink ? Opie::Core::OResource::loadPixmap( "opie/symlink" ) : Opie::Core::OResource::loadPixmap( "folder" ); | 674 | pix = symlink ? Opie::Core::OResource::loadPixmap( "opie/symlink" ) : Opie::Core::OResource::loadPixmap( "folder" ); |
675 | 675 | ||
676 | name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) : | 676 | name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) : |
677 | info->fileName(); | 677 | info->fileName(); |
678 | 678 | ||
679 | (void)new OFileSelectorItem( m_view, pix, name, | 679 | (void)new OFileSelectorItem( m_view, pix, name, |
680 | info->lastModified().toString(), | 680 | info->lastModified().toString(), |
681 | QString::number( info->size() ), | 681 | QString::number( info->size() ), |
682 | info->dirPath( true ), locked, true ); | 682 | info->dirPath( true ), locked, true ); |
683 | 683 | ||
684 | 684 | ||
685 | } | 685 | } |
686 | 686 | ||
687 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) | 687 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) |
688 | { | 688 | { |
689 | } | 689 | } |
690 | 690 | ||
691 | void OFileViewFileListView::cdUP() | 691 | void OFileViewFileListView::cdUP() |
692 | { | 692 | { |
693 | QDir dir( m_currentDir ); | 693 | QDir dir( m_currentDir ); |
694 | dir.cdUp(); | 694 | dir.cdUp(); |
695 | 695 | ||
696 | if (!dir.exists() ) | 696 | if (!dir.exists() ) |
697 | m_currentDir = "/"; | 697 | m_currentDir = "/"; |
698 | else | 698 | else |
699 | m_currentDir = dir.absPath(); | 699 | m_currentDir = dir.absPath(); |
700 | 700 | ||
701 | emit selector()->dirSelected( m_currentDir ); | 701 | emit selector()->dirSelected( m_currentDir ); |
702 | reread( m_all ); | 702 | reread( m_all ); |
703 | } | 703 | } |
704 | 704 | ||
705 | void OFileViewFileListView::cdHome() | 705 | void OFileViewFileListView::cdHome() |
706 | { | 706 | { |
707 | m_currentDir = QDir::homeDirPath(); | 707 | m_currentDir = QDir::homeDirPath(); |
708 | emit selector()->dirSelected( m_currentDir ); | 708 | emit selector()->dirSelected( m_currentDir ); |
709 | reread( m_all ); | 709 | reread( m_all ); |
710 | } | 710 | } |
711 | 711 | ||
712 | void OFileViewFileListView::cdDoc() | 712 | void OFileViewFileListView::cdDoc() |
713 | { | 713 | { |
714 | m_currentDir = QPEApplication::documentDir(); | 714 | m_currentDir = QPEApplication::documentDir(); |
715 | emit selector()->dirSelected( m_currentDir ); | 715 | emit selector()->dirSelected( m_currentDir ); |
716 | reread( m_all ); | 716 | reread( m_all ); |
717 | } | 717 | } |
718 | 718 | ||
719 | void OFileViewFileListView::changeDir( const QString& dir ) | 719 | void OFileViewFileListView::changeDir( const QString& dir ) |
720 | { | 720 | { |
721 | m_currentDir = dir; | 721 | m_currentDir = dir; |
722 | emit selector()->dirSelected( m_currentDir ); | 722 | emit selector()->dirSelected( m_currentDir ); |
723 | reread( m_all ); | 723 | reread( m_all ); |
724 | } | 724 | } |
725 | 725 | ||
726 | void OFileViewFileListView::slotFSActivated( int id ) | 726 | void OFileViewFileListView::slotFSActivated( int id ) |
727 | { | 727 | { |
728 | changeDir ( m_dev[m_fsPop->text(id)] ); | 728 | changeDir ( m_dev[m_fsPop->text(id)] ); |
729 | } | 729 | } |
730 | 730 | ||
731 | /* check if the mimetype in mime | 731 | /* check if the mimetype in mime |
732 | * complies with the one which is current | 732 | * complies with the one which is current |
733 | */ | 733 | */ |
734 | /* | 734 | /* |
735 | * We've the mimetype of the file | 735 | * We've the mimetype of the file |
736 | * We need to get the stringlist of the current mimetype | 736 | * We need to get the stringlist of the current mimetype |
737 | * | 737 | * |
738 | * mime = image@slashjpeg | 738 | * mime = image@slashjpeg |
739 | * QStringList = 'image@slash*' | 739 | * QStringList = 'image@slash*' |
740 | * or QStringList = image/jpeg;image/png;application/x-ogg | 740 | * or QStringList = image/jpeg;image/png;application/x-ogg |
741 | * or QStringList = application/x-ogg;image@slash*; | 741 | * or QStringList = application/x-ogg;image@slash*; |
742 | * with all these mime filters it should get acceptes | 742 | * with all these mime filters it should get acceptes |
743 | * to do so we need to look if mime is contained inside | 743 | * to do so we need to look if mime is contained inside |
744 | * the stringlist | 744 | * the stringlist |
745 | * if it's contained return true | 745 | * if it's contained return true |
746 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 746 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
747 | * is contained in the mimefilter and then we will | 747 | * is contained in the mimefilter and then we will |
748 | * look if both are equal until the '/' | 748 | * look if both are equal until the '/' |
749 | */ | 749 | */ |
750 | 750 | ||
751 | bool OFileViewFileListView::compliesMime( const QString& str) | 751 | bool OFileViewFileListView::compliesMime( const QString& str) |
752 | { | 752 | { |
753 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 753 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
754 | return true; | 754 | return true; |
755 | 755 | ||
756 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) | 756 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) |
757 | { | 757 | { |
758 | QRegExp reg( (*it) ); | 758 | QRegExp reg( (*it) ); |
759 | reg.setWildcard( true ); | 759 | reg.setWildcard( true ); |
760 | if ( str.find( reg ) != -1 ) | 760 | if ( str.find( reg ) != -1 ) |
761 | return true; | 761 | return true; |
762 | 762 | ||
763 | } | 763 | } |
764 | return false; | 764 | return false; |
765 | } | 765 | } |
766 | /* | 766 | /* |
767 | * The listView giving access to the file system! | 767 | * The listView giving access to the file system! |
768 | */ | 768 | */ |
769 | 769 | ||
770 | class OFileViewFileSystem : public OFileViewInterface | 770 | class OFileViewFileSystem : public OFileViewInterface |
771 | { | 771 | { |
772 | public: | 772 | public: |
773 | OFileViewFileSystem( OFileSelector* ); | 773 | OFileViewFileSystem( OFileSelector* ); |
774 | ~OFileViewFileSystem(); | 774 | ~OFileViewFileSystem(); |
775 | 775 | ||
776 | QString selectedName() const; | 776 | QString selectedName() const; |
777 | QString selectedPath() const; | 777 | QString selectedPath() const; |
778 | 778 | ||
779 | QString directory()const; | 779 | QString directory()const; |
780 | void reread(); | 780 | void reread(); |
781 | int fileCount()const; | 781 | int fileCount()const; |
782 | 782 | ||
783 | QWidget* widget( QWidget* parent ); | 783 | QWidget* widget( QWidget* parent ); |
784 | void activate( const QString& ); | 784 | void activate( const QString& ); |
785 | private: | 785 | private: |
786 | OFileViewFileListView* m_view; | 786 | OFileViewFileListView* m_view; |
787 | bool m_all : 1; | 787 | bool m_all : 1; |
788 | }; | 788 | }; |
789 | 789 | ||
790 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 790 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
791 | : OFileViewInterface( sel ) | 791 | : OFileViewInterface( sel ) |
792 | { | 792 | { |
793 | m_view = 0; | 793 | m_view = 0; |
794 | m_all = false; | 794 | m_all = false; |
795 | } | 795 | } |
796 | 796 | ||
797 | OFileViewFileSystem::~OFileViewFileSystem() | 797 | OFileViewFileSystem::~OFileViewFileSystem() |
798 | { | 798 | { |
799 | } | 799 | } |
800 | 800 | ||
801 | QString OFileViewFileSystem::selectedName()const | 801 | QString OFileViewFileSystem::selectedName()const |
802 | { | 802 | { |
803 | if (!m_view ) | 803 | if (!m_view ) |
804 | return QString::null; | 804 | return QString::null; |
805 | 805 | ||
806 | QString cFN=currentFileName(); | 806 | QString cFN=currentFileName(); |
807 | if (cFN.startsWith("/")) return cFN; | 807 | if (cFN.startsWith("/")) return cFN; |
808 | return createNewPath(m_view->currentDir(),cFN); | 808 | return createNewPath(m_view->currentDir(),cFN); |
809 | } | 809 | } |
810 | 810 | ||
811 | QString OFileViewFileSystem::selectedPath()const | 811 | QString OFileViewFileSystem::selectedPath()const |
812 | { | 812 | { |
813 | return QString::null; | 813 | return QString::null; |
814 | } | 814 | } |
815 | 815 | ||
816 | QString OFileViewFileSystem::directory()const | 816 | QString OFileViewFileSystem::directory()const |
817 | { | 817 | { |
818 | if (!m_view) | 818 | if (!m_view) |
819 | return QString::null; | 819 | return QString::null; |
820 | 820 | ||
821 | OFileSelectorItem* item = m_view->currentItem(); | 821 | OFileSelectorItem* item = m_view->currentItem(); |
822 | if (!item ) | 822 | if (!item ) |
823 | return QString::null; | 823 | return QString::null; |
824 | 824 | ||
825 | return QDir(item->directory() ).absPath(); | 825 | return QDir(item->directory() ).absPath(); |
826 | } | 826 | } |
827 | 827 | ||
828 | void OFileViewFileSystem::reread() | 828 | void OFileViewFileSystem::reread() |
829 | { | 829 | { |
830 | if (!m_view) | 830 | if (!m_view) |
831 | return; | 831 | return; |
832 | 832 | ||
833 | m_view->reread( m_all ); | 833 | m_view->reread( m_all ); |
834 | } | 834 | } |
835 | 835 | ||
836 | int OFileViewFileSystem::fileCount()const | 836 | int OFileViewFileSystem::fileCount()const |
837 | { | 837 | { |
838 | if (!m_view ) | 838 | if (!m_view ) |
839 | return -1; | 839 | return -1; |
840 | return m_view->fileCount(); | 840 | return m_view->fileCount(); |
841 | } | 841 | } |
842 | 842 | ||
843 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 843 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
844 | { | 844 | { |
845 | if (!m_view ) | 845 | if (!m_view ) |
846 | { | 846 | { |
847 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 847 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
848 | } | 848 | } |
849 | return m_view; | 849 | return m_view; |
850 | } | 850 | } |
851 | 851 | ||
852 | void OFileViewFileSystem::activate( const QString& str ) | 852 | void OFileViewFileSystem::activate( const QString& str ) |
853 | { | 853 | { |
854 | m_all = allItem( str ); | 854 | m_all = allItem( str ); |
855 | } | 855 | } |
856 | 856 | ||
857 | 857 | ||
858 | } | 858 | } |
859 | /* Selector */ | 859 | /* Selector */ |
860 | /** | 860 | /** |
861 | * @short new and complete c'tor | 861 | * @short new and complete c'tor |
862 | * | 862 | * |
863 | * Create a OFileSelector to let the user select a file. It can | 863 | * Create a OFileSelector to let the user select a file. It can |
864 | * either be used to open a file, select a save name in a dir or | 864 | * either be used to open a file, select a save name in a dir or |
865 | * as a dropin for the FileSelector. | 865 | * as a dropin for the FileSelector. |
866 | * | 866 | * |
867 | * <pre> | 867 | * <pre> |
868 | * QMap<QString, QStringList> mimeTypes; | 868 | * QMap<QString, QStringList> mimeTypes; |
869 | * QStringList types; | 869 | * QStringList types; |
870 | * types << "text@slash* "; | 870 | * types << "text@slash* "; |
871 | * types << "audio@slash*"; | 871 | * types << "audio@slash*"; |
872 | * mimeTypes.insert( tr("Audio and Text"), types ); | 872 | * mimeTypes.insert( tr("Audio and Text"), types ); |
873 | * mimeTypes.insert( tr("All"), "*@slash*); | 873 | * mimeTypes.insert( tr("All"), "*@slash*); |
874 | * | 874 | * |
875 | * now you could create your fileselector | 875 | * now you could create your fileselector |
876 | * </pre> | 876 | * </pre> |
877 | * | 877 | * |
878 | * | 878 | * |
879 | * @param parent the parent of this widget | 879 | * @param parent the parent of this widget |
880 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 880 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
881 | * @param sel The selector to be used | 881 | * @param sel The selector to be used |
882 | * @param dirName The name of the dir to start int | 882 | * @param dirName The name of the dir to start int |
883 | * @param fileName The fileName placed in the fileselector lineedit | 883 | * @param fileName The fileName placed in the fileselector lineedit |
884 | * @param mimetypes The MimeType map of used mimetypes | 884 | * @param mimetypes The MimeType map of used mimetypes |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index aa9db52..feda198 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -1,277 +1,277 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfmData.cpp | 2 | advancedfmData.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Mon 09-23-2002 13:24:11 | 4 | ** Created: Mon 09-23-2002 13:24:11 |
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 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <opie2/oresource.h> | 16 | #include <opie2/oresource.h> |
17 | #include <qpe/applnk.h> | 17 | #include <qpe/applnk.h> |
18 | #include <qpe/storage.h> | 18 | #include <qpe/storage.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/menubutton.h> | 20 | #include <qpe/menubutton.h> |
21 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
22 | using namespace Opie::Ui; | 22 | using namespace Opie::Ui; |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qmenubar.h> | 27 | #include <qmenubar.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | 32 | ||
33 | /* STD */ | 33 | /* STD */ |
34 | #include <sys/utsname.h> | 34 | #include <sys/utsname.h> |
35 | 35 | ||
36 | void AdvancedFm::init() { | 36 | void AdvancedFm::init() { |
37 | b = false; | 37 | b = false; |
38 | setCaption( tr( "AdvancedFm" ) ); | 38 | setCaption( tr( "AdvancedFm" ) ); |
39 | 39 | ||
40 | QVBoxLayout *layout = new QVBoxLayout( this ); | 40 | QVBoxLayout *layout = new QVBoxLayout( this ); |
41 | layout->setSpacing( 2); | 41 | layout->setSpacing( 2); |
42 | layout->setMargin( 0); // squeeze | 42 | layout->setMargin( 0); // squeeze |
43 | 43 | ||
44 | QMenuBar *menuBar = new QMenuBar(this); | 44 | QMenuBar *menuBar = new QMenuBar(this); |
45 | menuBar->setMargin( 0 ); // squeeze | 45 | menuBar->setMargin( 0 ); // squeeze |
46 | fileMenu = new QPopupMenu( this ); | 46 | fileMenu = new QPopupMenu( this ); |
47 | viewMenu = new QPopupMenu( this ); | 47 | viewMenu = new QPopupMenu( this ); |
48 | // customDirMenu = new QPopupMenu( this ); | 48 | // customDirMenu = new QPopupMenu( this ); |
49 | 49 | ||
50 | layout->addWidget( menuBar ); | 50 | layout->addWidget( menuBar ); |
51 | 51 | ||
52 | menuBar->insertItem( tr( "File" ), fileMenu); | 52 | menuBar->insertItem( tr( "File" ), fileMenu); |
53 | menuBar->insertItem( tr( "View" ), viewMenu); | 53 | menuBar->insertItem( tr( "View" ), viewMenu); |
54 | 54 | ||
55 | bool useBigIcon = qApp->desktop()->size().width() > 330; | 55 | bool useBigIcon = qApp->desktop()->size().width() > 330; |
56 | 56 | ||
57 | cdUpButton = new QToolButton( 0,"cdUpButton"); | 57 | cdUpButton = new QToolButton( 0,"cdUpButton"); |
58 | cdUpButton->setUsesBigPixmap( useBigIcon ); | 58 | cdUpButton->setUsesBigPixmap( useBigIcon ); |
59 | cdUpButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); | 59 | cdUpButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); |
60 | cdUpButton->setAutoRaise( true ); | 60 | cdUpButton->setAutoRaise( true ); |
61 | menuBar->insertItem( cdUpButton ); | 61 | menuBar->insertItem( cdUpButton ); |
62 | 62 | ||
63 | qpeDirButton= new QToolButton( 0,"QPEButton"); | 63 | qpeDirButton= new QToolButton( 0,"QPEButton"); |
64 | qpeDirButton->setUsesBigPixmap( useBigIcon ); | 64 | qpeDirButton->setUsesBigPixmap( useBigIcon ); |
65 | qpeDirButton->setPixmap( Opie::Core::OResource::loadPixmap( "logo/opielogo", Opie::Core::OResource::SmallIcon ) ); | 65 | qpeDirButton->setPixmap( Opie::Core::OResource::loadPixmap( "logo/opielogo", Opie::Core::OResource::SmallIcon ) ); |
66 | qpeDirButton->setAutoRaise( true ); | 66 | qpeDirButton->setAutoRaise( true ); |
67 | menuBar->insertItem( qpeDirButton ); | 67 | menuBar->insertItem( qpeDirButton ); |
68 | 68 | ||
69 | cfButton = new QToolButton( 0, "CFButton"); | 69 | cfButton = new QToolButton( 0, "CFButton"); |
70 | cfButton->setUsesBigPixmap( useBigIcon ); | 70 | cfButton->setUsesBigPixmap( useBigIcon ); |
71 | cfButton->setPixmap( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) ); | 71 | cfButton->setPixmap( Opie::Core::OResource::loadPixmap( "pcmcia", Opie::Core::OResource::SmallIcon ) ); |
72 | cfButton->setAutoRaise( true ); | 72 | cfButton->setAutoRaise( true ); |
73 | menuBar->insertItem( cfButton ); | 73 | menuBar->insertItem( cfButton ); |
74 | 74 | ||
75 | sdButton = new QToolButton( 0, "SDButton"); | 75 | sdButton = new QToolButton( 0, "SDButton"); |
76 | sdButton->setUsesBigPixmap( useBigIcon ); | 76 | sdButton->setUsesBigPixmap( useBigIcon ); |
77 | sdButton->setPixmap( Opie::Core::OResource::loadPixmap( "advancedfm/sdcard", Opie::Core::OResource::SmallIcon ) ); | 77 | sdButton->setPixmap( Opie::Core::OResource::loadPixmap( "advancedfm/sdcard", Opie::Core::OResource::SmallIcon ) ); |
78 | sdButton->setAutoRaise( true ); | 78 | sdButton->setAutoRaise( true ); |
79 | menuBar->insertItem( sdButton ); | 79 | menuBar->insertItem( sdButton ); |
80 | 80 | ||
81 | docButton = new QToolButton( 0,"docsButton"); | 81 | docButton = new QToolButton( 0,"docsButton"); |
82 | docButton->setUsesBigPixmap( useBigIcon ); | 82 | docButton->setUsesBigPixmap( useBigIcon ); |
83 | docButton->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) ); | 83 | docButton->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) ); |
84 | docButton->setAutoRaise( true ); | 84 | docButton->setAutoRaise( true ); |
85 | menuBar->insertItem( docButton ); | 85 | menuBar->insertItem( docButton ); |
86 | 86 | ||
87 | homeButton = new QToolButton( 0, "homeButton"); | 87 | homeButton = new QToolButton( 0, "homeButton"); |
88 | homeButton->setUsesBigPixmap( useBigIcon ); | 88 | homeButton->setUsesBigPixmap( useBigIcon ); |
89 | homeButton->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) ); | 89 | homeButton->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) ); |
90 | homeButton->setAutoRaise( true ); | 90 | homeButton->setAutoRaise( true ); |
91 | menuBar->insertItem( homeButton ); | 91 | menuBar->insertItem( homeButton ); |
92 | 92 | ||
93 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); | 93 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); |
94 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 94 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
95 | fileMenu->insertSeparator(); | 95 | fileMenu->insertSeparator(); |
96 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); | 96 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); |
97 | fileMenu->insertSeparator(); | 97 | fileMenu->insertSeparator(); |
98 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 98 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
99 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 99 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
100 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 100 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
101 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 101 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
102 | fileMenu->insertSeparator(); | 102 | fileMenu->insertSeparator(); |
103 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 103 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
104 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); | 104 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); |
105 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 105 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
106 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 106 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
107 | fileMenu->setCheckable(TRUE); | 107 | fileMenu->setCheckable(TRUE); |
108 | 108 | ||
109 | viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); | 109 | viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); |
110 | viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); | 110 | viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); |
111 | viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab())); | 111 | viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab())); |
112 | // viewMenu->insertSeparator(); | 112 | // viewMenu->insertSeparator(); |
113 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 113 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
114 | viewMenu->setCheckable(true); | 114 | viewMenu->setCheckable(true); |
115 | viewMenu->setItemChecked( viewMenu->idAt(0), true); | 115 | viewMenu->setItemChecked( viewMenu->idAt(0), true); |
116 | viewMenu->setItemChecked( viewMenu->idAt(1), false); | 116 | viewMenu->setItemChecked( viewMenu->idAt(1), false); |
117 | 117 | ||
118 | s_addBookmark = tr("Bookmark Directory"); | 118 | s_addBookmark = tr("Bookmark Directory"); |
119 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); | 119 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); |
120 | 120 | ||
121 | // menuButton->insertItem(""); | 121 | // menuButton->insertItem(""); |
122 | 122 | ||
123 | // customDirMenu->insertItem(tr("Add This Directory")); | 123 | // customDirMenu->insertItem(tr("Add This Directory")); |
124 | // customDirMenu->insertItem(tr("Remove This Directory")); | 124 | // customDirMenu->insertItem(tr("Remove This Directory")); |
125 | // customDirMenu->insertSeparator(); | 125 | // customDirMenu->insertSeparator(); |
126 | 126 | ||
127 | QHBoxLayout *CBHB = new QHBoxLayout(); // parent layout will be set later | 127 | QHBoxLayout *CBHB = new QHBoxLayout(); // parent layout will be set later |
128 | CBHB->setMargin( 0 ); | 128 | CBHB->setMargin( 0 ); |
129 | CBHB->setSpacing( 1 ); | 129 | CBHB->setSpacing( 1 ); |
130 | 130 | ||
131 | menuButton = new MenuButton( this ); | 131 | menuButton = new MenuButton( this ); |
132 | 132 | ||
133 | menuButton->setUseLabel(false); | 133 | menuButton->setUseLabel(false); |
134 | menuButton->setMaximumWidth( 20 ); | 134 | menuButton->setMaximumWidth( 20 ); |
135 | menuButton->insertItem( s_addBookmark); | 135 | menuButton->insertItem( s_addBookmark); |
136 | menuButton->insertItem( s_removeBookmark); | 136 | menuButton->insertItem( s_removeBookmark); |
137 | menuButton->insertSeparator(); | 137 | menuButton->insertSeparator(); |
138 | // menuButton->setFocusPolicy(NoFocus); | 138 | // menuButton->setFocusPolicy(NoFocus); |
139 | CBHB->addWidget( menuButton ); | 139 | CBHB->addWidget( menuButton ); |
140 | 140 | ||
141 | customDirsToMenu(); | 141 | customDirsToMenu(); |
142 | 142 | ||
143 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 143 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
144 | currentPathCombo->setEditable(TRUE); | 144 | currentPathCombo->setEditable(TRUE); |
145 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 145 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
146 | // currentPathCombo->setFocusPolicy(NoFocus); | 146 | // currentPathCombo->setFocusPolicy(NoFocus); |
147 | CBHB->addWidget( currentPathCombo ); | 147 | CBHB->addWidget( currentPathCombo ); |
148 | 148 | ||
149 | layout->addLayout( CBHB ); | 149 | layout->addLayout( CBHB ); |
150 | 150 | ||
151 | TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); | 151 | TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); |
152 | // TabWidget = new QTabWidget( this, "TabWidget" ); | 152 | // TabWidget = new QTabWidget( this, "TabWidget" ); |
153 | layout->addWidget( TabWidget, 4 ); | 153 | layout->addWidget( TabWidget, 4 ); |
154 | 154 | ||
155 | tab = new QWidget( TabWidget, "tab" ); | 155 | tab = new QWidget( TabWidget, "tab" ); |
156 | tabLayout = new QGridLayout( tab ); | 156 | tabLayout = new QGridLayout( tab ); |
157 | tabLayout->setSpacing( 2); | 157 | tabLayout->setSpacing( 2); |
158 | tabLayout->setMargin( 2); | 158 | tabLayout->setMargin( 2); |
159 | 159 | ||
160 | Local_View = new QListView( tab, "Local_View" ); | 160 | Local_View = new QListView( tab, "Local_View" ); |
161 | Local_View->addColumn( tr("File"),130); | 161 | Local_View->addColumn( tr("File"),130); |
162 | Local_View->addColumn( tr("Size"),-1); | 162 | Local_View->addColumn( tr("Size"),-1); |
163 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 163 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
164 | Local_View->addColumn( tr("Date"),-1); | 164 | Local_View->addColumn( tr("Date"),-1); |
165 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 165 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
166 | Local_View->setAllColumnsShowFocus(TRUE); | 166 | Local_View->setAllColumnsShowFocus(TRUE); |
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(StrongFocus); | 169 | Local_View->setFocusPolicy(StrongFocus); |
170 | Local_View->installEventFilter( this ); | 170 | Local_View->installEventFilter( this ); |
171 | 171 | ||
172 | QPEApplication::setStylusOperation( Local_View->viewport() , QPEApplication::RightOnHold); | 172 | QPEApplication::setStylusOperation( Local_View->viewport() , QPEApplication::RightOnHold); |
173 | 173 | ||
174 | tabLayout->addWidget( Local_View, 0, 0 ); | 174 | tabLayout->addWidget( Local_View, 0, 0 ); |
175 | 175 | ||
176 | TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); | 176 | TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); |
177 | // TabWidget->insertTab( tab, tr("1")); | 177 | // TabWidget->insertTab( tab, tr("1")); |
178 | 178 | ||
179 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 179 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
180 | tabLayout_2 = new QGridLayout( tab_2 ); | 180 | tabLayout_2 = new QGridLayout( tab_2 ); |
181 | tabLayout_2->setSpacing( 2); | 181 | tabLayout_2->setSpacing( 2); |
182 | tabLayout_2->setMargin( 2); | 182 | tabLayout_2->setMargin( 2); |
183 | 183 | ||
184 | Remote_View = new QListView( tab_2, "Remote_View" ); | 184 | Remote_View = new QListView( tab_2, "Remote_View" ); |
185 | Remote_View->addColumn( tr("File"),130); | 185 | Remote_View->addColumn( tr("File"),130); |
186 | Remote_View->addColumn( tr("Size"),-1); | 186 | Remote_View->addColumn( tr("Size"),-1); |
187 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 187 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
188 | Remote_View->addColumn( tr("Date"),-1); | 188 | Remote_View->addColumn( tr("Date"),-1); |
189 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 189 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
190 | Remote_View->setAllColumnsShowFocus(TRUE); | 190 | Remote_View->setAllColumnsShowFocus(TRUE); |
191 | Remote_View->setMultiSelection( TRUE ); | 191 | Remote_View->setMultiSelection( TRUE ); |
192 | Remote_View->setSelectionMode(QListView::Extended); | 192 | Remote_View->setSelectionMode(QListView::Extended); |
193 | Remote_View->setFocusPolicy(StrongFocus); | 193 | Remote_View->setFocusPolicy(StrongFocus); |
194 | Remote_View->installEventFilter( this ); | 194 | Remote_View->installEventFilter( this ); |
195 | 195 | ||
196 | QPEApplication::setStylusOperation( Remote_View->viewport(), QPEApplication::RightOnHold); | 196 | QPEApplication::setStylusOperation( Remote_View->viewport(), QPEApplication::RightOnHold); |
197 | 197 | ||
198 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 198 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
199 | 199 | ||
200 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); | 200 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); |
201 | TabWidget->setSizeChange( 370 ); | 201 | TabWidget->setSizeChange( 370 ); |
202 | // TabWidget->insertTab( tab_2, tr( "2")); | 202 | // TabWidget->insertTab( tab_2, tr( "2")); |
203 | 203 | ||
204 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 204 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
205 | tabLayout_3 = new QGridLayout( tab_3 ); | 205 | tabLayout_3 = new QGridLayout( tab_3 ); |
206 | tabLayout_3->setSpacing( 2); | 206 | tabLayout_3->setSpacing( 2); |
207 | tabLayout_3->setMargin( 2); | 207 | tabLayout_3->setMargin( 2); |
208 | 208 | ||
209 | 209 | ||
210 | // OFileDialog fileDialog; | 210 | // OFileDialog fileDialog; |
211 | // fileDialog; | 211 | // fileDialog; |
212 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 212 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
213 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 213 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
214 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 214 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
215 | 215 | ||
216 | QListView *fileTree; | 216 | QListView *fileTree; |
217 | fileTree = new QListView( tab_3, "tree" ); | 217 | fileTree = new QListView( tab_3, "tree" ); |
218 | 218 | ||
219 | 219 | ||
220 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 220 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
221 | 221 | ||
222 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 222 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
223 | */ | 223 | */ |
224 | 224 | ||
225 | /////////////// | 225 | /////////////// |
226 | 226 | ||
227 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { | 227 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { |
228 | sdButton->hide(); | 228 | sdButton->hide(); |
229 | } | 229 | } |
230 | if( !StorageInfo::hasCf() ) { | 230 | if( !StorageInfo::hasCf() ) { |
231 | cfButton->hide(); | 231 | cfButton->hide(); |
232 | } | 232 | } |
233 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 233 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
234 | currentDir.setPath( QDir::currentDirPath()); | 234 | currentDir.setPath( QDir::currentDirPath()); |
235 | 235 | ||
236 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 236 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
237 | currentRemoteDir.setPath( QDir::currentDirPath()); | 237 | currentRemoteDir.setPath( QDir::currentDirPath()); |
238 | 238 | ||
239 | filterStr="*"; | 239 | filterStr="*"; |
240 | showMenuHidden(); | 240 | showMenuHidden(); |
241 | TabWidget->setCurrentWidget(0); | 241 | TabWidget->setCurrentWidget(0); |
242 | 242 | ||
243 | } | 243 | } |
244 | 244 | ||
245 | void AdvancedFm::initConnections() | 245 | void AdvancedFm::initConnections() |
246 | { | 246 | { |
247 | 247 | ||
248 | connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(cleanUp())); | 248 | connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(cleanUp())); |
249 | connect(qpeDirButton,SIGNAL(released()),this,SLOT(QPEButtonPushed())); | 249 | connect(qpeDirButton,SIGNAL(released()),this,SLOT(QPEButtonPushed())); |
250 | connect(cfButton,SIGNAL(released()),this,SLOT(CFButtonPushed())); | 250 | connect(cfButton,SIGNAL(released()),this,SLOT(CFButtonPushed())); |
251 | connect(sdButton,SIGNAL(released()),this,SLOT(SDButtonPushed())); | 251 | connect(sdButton,SIGNAL(released()),this,SLOT(SDButtonPushed())); |
252 | connect(cdUpButton,SIGNAL(released()),this,SLOT(upDir())); | 252 | connect(cdUpButton,SIGNAL(released()),this,SLOT(upDir())); |
253 | connect(docButton,SIGNAL(released()),this,SLOT(docButtonPushed())); | 253 | connect(docButton,SIGNAL(released()),this,SLOT(docButtonPushed())); |
254 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed())); | 254 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed())); |
255 | connect(currentPathCombo,SIGNAL(activated(const QString&)),this,SLOT(changeTo(const QString&))); | 255 | connect(currentPathCombo,SIGNAL(activated(const QString&)),this,SLOT(changeTo(const QString&))); |
256 | 256 | ||
257 | connect(currentPathCombo->lineEdit(),SIGNAL(returnPressed()),this,SLOT(currentPathComboChanged())); | 257 | connect(currentPathCombo->lineEdit(),SIGNAL(returnPressed()),this,SLOT(currentPathComboChanged())); |
258 | 258 | ||
259 | connect(Local_View,SIGNAL(clicked(QListViewItem*)),this,SLOT( ListClicked(QListViewItem*))); | 259 | connect(Local_View,SIGNAL(clicked(QListViewItem*)),this,SLOT( ListClicked(QListViewItem*))); |
260 | 260 | ||
261 | connect(Local_View,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); | 261 | connect(Local_View,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); |
262 | 262 | ||
263 | connect(Remote_View,SIGNAL(clicked(QListViewItem*)),this,SLOT(ListClicked(QListViewItem*))); | 263 | connect(Remote_View,SIGNAL(clicked(QListViewItem*)),this,SLOT(ListClicked(QListViewItem*))); |
264 | connect(Remote_View,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(ListPressed(int,QListViewItem*,const QPoint&,int))); | 264 | connect(Remote_View,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(ListPressed(int,QListViewItem*,const QPoint&,int))); |
265 | 265 | ||
266 | connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 266 | connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
267 | 267 | ||
268 | connect(Remote_View,SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),this,SLOT(showFileMenu())); | 268 | connect(Remote_View,SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),this,SLOT(showFileMenu())); |
269 | connect(Local_View,SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),this,SLOT(showFileMenu())); | 269 | connect(Local_View,SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),this,SLOT(showFileMenu())); |
270 | 270 | ||
271 | connect(menuButton,SIGNAL(selected(const QString&)),SLOT(gotoCustomDir(const QString&))); | 271 | connect(menuButton,SIGNAL(selected(const QString&)),SLOT(gotoCustomDir(const QString&))); |
272 | // connect( menuButton, SIGNAL( selected(int)), SLOT( dirMenuSelected(int))); | 272 | // connect( menuButton, SIGNAL( selected(int)), SLOT( dirMenuSelected(int))); |
273 | connect(viewMenu,SIGNAL(activated(int)),this,SLOT(slotSwitchMenu(int))); | 273 | connect(viewMenu,SIGNAL(activated(int)),this,SLOT(slotSwitchMenu(int))); |
274 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); | 274 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); |
275 | 275 | ||
276 | } | 276 | } |
277 | 277 | ||
diff --git a/noncore/graphics/opie-eye/gui/filesystem.cpp b/noncore/graphics/opie-eye/gui/filesystem.cpp index d84e9f8..9448843 100644 --- a/noncore/graphics/opie-eye/gui/filesystem.cpp +++ b/noncore/graphics/opie-eye/gui/filesystem.cpp | |||
@@ -1,66 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | 8 | ||
9 | #include <opie2/oresource.h> | 9 | #include <opie2/oresource.h> |
10 | 10 | ||
11 | #include <qpe/storage.h> | 11 | #include <qpe/storage.h> |
12 | 12 | ||
13 | 13 | ||
14 | #include "filesystem.h" | 14 | #include "filesystem.h" |
15 | 15 | ||
16 | PFileSystem::PFileSystem( QToolBar* bar) | 16 | PFileSystem::PFileSystem( QToolBar* bar) |
17 | : QToolButton( bar ) | 17 | : QToolButton( bar ) |
18 | { | 18 | { |
19 | setIconSet( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) ); | 19 | setIconSet( Opie::Core::OResource::loadPixmap( "pcmcia", Opie::Core::OResource::SmallIcon ) ); |
20 | 20 | ||
21 | m_pop = new QPopupMenu( this ); | 21 | m_pop = new QPopupMenu( this ); |
22 | connect( m_pop, SIGNAL( activated( int ) ), | 22 | connect( m_pop, SIGNAL( activated( int ) ), |
23 | this, SLOT(slotSelectDir( int ) ) ); | 23 | this, SLOT(slotSelectDir( int ) ) ); |
24 | 24 | ||
25 | m_storage = new StorageInfo(); | 25 | m_storage = new StorageInfo(); |
26 | connect(m_storage, SIGNAL(disksChanged() ), | 26 | connect(m_storage, SIGNAL(disksChanged() ), |
27 | this, SLOT( changed() ) ); | 27 | this, SLOT( changed() ) ); |
28 | changed(); | 28 | changed(); |
29 | 29 | ||
30 | connect(this,SIGNAL(pressed()),SLOT(slotPopUp())); | 30 | connect(this,SIGNAL(pressed()),SLOT(slotPopUp())); |
31 | } | 31 | } |
32 | 32 | ||
33 | PFileSystem::~PFileSystem() { | 33 | PFileSystem::~PFileSystem() { |
34 | delete m_storage; | 34 | delete m_storage; |
35 | } | 35 | } |
36 | 36 | ||
37 | 37 | ||
38 | void PFileSystem::changed() { | 38 | void PFileSystem::changed() { |
39 | m_pop->clear(); | 39 | m_pop->clear(); |
40 | m_dev.clear(); | 40 | m_dev.clear(); |
41 | 41 | ||
42 | /* home dir, too */ | 42 | /* home dir, too */ |
43 | QString f = getenv( "HOME" ); | 43 | QString f = getenv( "HOME" ); |
44 | if (!f.isEmpty()) { | 44 | if (!f.isEmpty()) { |
45 | m_dev.insert("Home directory",f); | 45 | m_dev.insert("Home directory",f); |
46 | m_pop->insertItem("Home directory"); | 46 | m_pop->insertItem("Home directory"); |
47 | } | 47 | } |
48 | 48 | ||
49 | const QList<FileSystem> &fs = m_storage->fileSystems(); | 49 | const QList<FileSystem> &fs = m_storage->fileSystems(); |
50 | QListIterator<FileSystem> it(fs ); | 50 | QListIterator<FileSystem> it(fs ); |
51 | for ( ; it.current(); ++it ) { | 51 | for ( ; it.current(); ++it ) { |
52 | const QString disk = (*it)->name(); | 52 | const QString disk = (*it)->name(); |
53 | const QString path = (*it)->path(); | 53 | const QString path = (*it)->path(); |
54 | m_dev.insert( disk, path ); | 54 | m_dev.insert( disk, path ); |
55 | m_pop->insertItem( disk ); | 55 | m_pop->insertItem( disk ); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | void PFileSystem::slotPopUp() { | 59 | void PFileSystem::slotPopUp() { |
60 | m_pop->exec(QCursor::pos()); | 60 | m_pop->exec(QCursor::pos()); |
61 | setDown(false); | 61 | setDown(false); |
62 | } | 62 | } |
63 | 63 | ||
64 | void PFileSystem::slotSelectDir( int id ) { | 64 | void PFileSystem::slotSelectDir( int id ) { |
65 | emit changeDir( m_dev[m_pop->text(id )] ); | 65 | emit changeDir( m_dev[m_pop->text(id )] ); |
66 | } | 66 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index d4c5b42..2cf687b 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -236,632 +236,632 @@ void PMainWindow::slotConfig() { | |||
236 | 236 | ||
237 | /* | 237 | /* |
238 | * create a new image info component | 238 | * create a new image info component |
239 | * and detach the current one | 239 | * and detach the current one |
240 | * we will make the other delete on exit | 240 | * we will make the other delete on exit |
241 | */ | 241 | */ |
242 | template<class T> | 242 | template<class T> |
243 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 243 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
244 | if ( *ptr ) { | 244 | if ( *ptr ) { |
245 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 245 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
246 | (*ptr)->setDestructiveClose(); | 246 | (*ptr)->setDestructiveClose(); |
247 | m_stack->removeWidget( *ptr ); | 247 | m_stack->removeWidget( *ptr ); |
248 | } | 248 | } |
249 | *ptr = new T(m_cfg, m_stack, name ); | 249 | *ptr = new T(m_cfg, m_stack, name ); |
250 | m_stack->addWidget( *ptr, id ); | 250 | m_stack->addWidget( *ptr, id ); |
251 | 251 | ||
252 | connect(*ptr, SIGNAL(sig_return()), | 252 | connect(*ptr, SIGNAL(sig_return()), |
253 | this,SLOT(slotReturn())); | 253 | this,SLOT(slotReturn())); |
254 | 254 | ||
255 | } | 255 | } |
256 | 256 | ||
257 | void PMainWindow::initInfo() { | 257 | void PMainWindow::initInfo() { |
258 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 258 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
259 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 259 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
260 | } | 260 | } |
261 | 261 | ||
262 | void PMainWindow::initDisp() { | 262 | void PMainWindow::initDisp() { |
263 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 263 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
264 | if (m_disp) { | 264 | if (m_disp) { |
265 | // if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 265 | // if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
266 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 266 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
267 | // } | 267 | // } |
268 | m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType,m_hBright); | 268 | m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType,m_hBright); |
269 | m_disp->setAutoScale(!m_aUnscaled->isOn()); | 269 | m_disp->setAutoScale(!m_aUnscaled->isOn()); |
270 | m_disp->setAutoRotate(m_aAutoRotate->isOn()); | 270 | m_disp->setAutoRotate(m_aAutoRotate->isOn()); |
271 | m_disp->setShowZoomer(m_aZoomer->isOn()); | 271 | m_disp->setShowZoomer(m_aZoomer->isOn()); |
272 | m_disp->setBackgroundColor(white); | 272 | m_disp->setBackgroundColor(white); |
273 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 273 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
274 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | 274 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); |
275 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | 275 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); |
276 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); | 276 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); |
277 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); | 277 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); |
278 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); | 278 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); |
279 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); | 279 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); |
280 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); | 280 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); |
281 | connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); | 281 | connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); |
282 | connect(m_IncBrightness,SIGNAL(activated()),m_disp,SLOT(slotIncBrightness())); | 282 | connect(m_IncBrightness,SIGNAL(activated()),m_disp,SLOT(slotIncBrightness())); |
283 | connect(m_DecBrightness,SIGNAL(activated()),m_disp,SLOT(slotDecBrightness())); | 283 | connect(m_DecBrightness,SIGNAL(activated()),m_disp,SLOT(slotDecBrightness())); |
284 | slotFullScreenToggled(m_aFullScreen->isOn()); | 284 | slotFullScreenToggled(m_aFullScreen->isOn()); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | void PMainWindow::slotToggleFullScreen() | 288 | void PMainWindow::slotToggleFullScreen() |
289 | { | 289 | { |
290 | bool current = !m_aFullScreen->isOn(); | 290 | bool current = !m_aFullScreen->isOn(); |
291 | m_aFullScreen->setOn(current); | 291 | m_aFullScreen->setOn(current); |
292 | } | 292 | } |
293 | 293 | ||
294 | void PMainWindow::slotFullScreenButton(bool current) | 294 | void PMainWindow::slotFullScreenButton(bool current) |
295 | { | 295 | { |
296 | if (autoSave) { | 296 | if (autoSave) { |
297 | m_cfg->writeEntry("fullscreen",current); | 297 | m_cfg->writeEntry("fullscreen",current); |
298 | } | 298 | } |
299 | if (!m_disp) return; | 299 | if (!m_disp) return; |
300 | if (m_disp->isVisible()) { | 300 | if (m_disp->isVisible()) { |
301 | setupViewWindow(current, true); | 301 | setupViewWindow(current, true); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | void PMainWindow::setupViewWindow(bool current, bool forceDisplay) | 305 | void PMainWindow::setupViewWindow(bool current, bool forceDisplay) |
306 | { | 306 | { |
307 | if (!m_disp) { | 307 | if (!m_disp) { |
308 | return; | 308 | return; |
309 | } | 309 | } |
310 | if (current) { | 310 | if (current) { |
311 | m_disp->setBackgroundColor(black); | 311 | m_disp->setBackgroundColor(black); |
312 | m_disp->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); | 312 | m_disp->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); |
313 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); | 313 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); |
314 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); | 314 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); |
315 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 315 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
316 | m_disp->setFullScreen(current,forceDisplay); | 316 | m_disp->setFullScreen(current,forceDisplay); |
317 | } else { | 317 | } else { |
318 | setUpdatesEnabled(false); | 318 | setUpdatesEnabled(false); |
319 | #if 0 | 319 | #if 0 |
320 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 320 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
321 | 321 | ||
322 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 322 | //m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
323 | } else { | 323 | } else { |
324 | //m_disp->setMinimumSize(10,10); | 324 | //m_disp->setMinimumSize(10,10); |
325 | } | 325 | } |
326 | #endif | 326 | #endif |
327 | m_disp->setBackgroundColor(white); | 327 | m_disp->setBackgroundColor(white); |
328 | m_stack->addWidget(m_disp,ImageDisplay); | 328 | m_stack->addWidget(m_disp,ImageDisplay); |
329 | m_disp->setVScrollBarMode(QScrollView::Auto); | 329 | m_disp->setVScrollBarMode(QScrollView::Auto); |
330 | m_disp->setHScrollBarMode(QScrollView::Auto); | 330 | m_disp->setHScrollBarMode(QScrollView::Auto); |
331 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 331 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
332 | m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); | 332 | m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); |
333 | } | 333 | } |
334 | if (forceDisplay || m_disp->isVisible()) { | 334 | if (forceDisplay || m_disp->isVisible()) { |
335 | m_stack->raiseWidget(m_disp); | 335 | m_stack->raiseWidget(m_disp); |
336 | m_disp->setFocus(); | 336 | m_disp->setFocus(); |
337 | } | 337 | } |
338 | setUpdatesEnabled(true); | 338 | setUpdatesEnabled(true); |
339 | } | 339 | } |
340 | m_disp->setFullScreen(current,forceDisplay); | 340 | m_disp->setFullScreen(current,forceDisplay); |
341 | } | 341 | } |
342 | 342 | ||
343 | void PMainWindow::slotFullScreenToggled(bool current) | 343 | void PMainWindow::slotFullScreenToggled(bool current) |
344 | { | 344 | { |
345 | setupViewWindow(current,true); | 345 | setupViewWindow(current,true); |
346 | } | 346 | } |
347 | 347 | ||
348 | /** | 348 | /** |
349 | * With big Screen the plan could be to 'detach' the image | 349 | * With big Screen the plan could be to 'detach' the image |
350 | * window if visible and to create a ne wone | 350 | * window if visible and to create a ne wone |
351 | * init* already supports it but I make no use of it for | 351 | * init* already supports it but I make no use of it for |
352 | * now. We set filename and raise | 352 | * now. We set filename and raise |
353 | * | 353 | * |
354 | * ### FIXME and talk to alwin | 354 | * ### FIXME and talk to alwin |
355 | */ | 355 | */ |
356 | void PMainWindow::slotShowInfo( const QString& inf ) { | 356 | void PMainWindow::slotShowInfo( const QString& inf ) { |
357 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 357 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
358 | return; | 358 | return; |
359 | } | 359 | } |
360 | if ( !m_info ) { | 360 | if ( !m_info ) { |
361 | initInfo(); | 361 | initInfo(); |
362 | } | 362 | } |
363 | m_info->setPath( inf ); | 363 | m_info->setPath( inf ); |
364 | if (m_SmallWindow) { | 364 | if (m_SmallWindow) { |
365 | m_aNext->removeFrom(toolBar); | 365 | m_aNext->removeFrom(toolBar); |
366 | m_aPrevious->removeFrom(toolBar); | 366 | m_aPrevious->removeFrom(toolBar); |
367 | fsButton->hide(); | 367 | fsButton->hide(); |
368 | } | 368 | } |
369 | m_aNext->setEnabled(false); | 369 | m_aNext->setEnabled(false); |
370 | m_aPrevious->setEnabled(false); | 370 | m_aPrevious->setEnabled(false); |
371 | m_aDirUp->setEnabled(false); | 371 | m_aDirUp->setEnabled(false); |
372 | m_aShowInfo->setEnabled(false); | 372 | m_aShowInfo->setEnabled(false); |
373 | m_aViewfile->setEnabled(true); | 373 | m_aViewfile->setEnabled(true); |
374 | m_aStartSlide->setEnabled(false); | 374 | m_aStartSlide->setEnabled(false); |
375 | m_stack->raiseWidget( ImageInfo ); | 375 | m_stack->raiseWidget( ImageInfo ); |
376 | } | 376 | } |
377 | 377 | ||
378 | void PMainWindow::slotDisplay( const QString& inf ) { | 378 | void PMainWindow::slotDisplay( const QString& inf ) { |
379 | bool nwindow = false; | 379 | bool nwindow = false; |
380 | if ( !m_disp ) { | 380 | if ( !m_disp ) { |
381 | nwindow = true; | 381 | nwindow = true; |
382 | initDisp(); | 382 | initDisp(); |
383 | m_disp->setIntensity(m_Intensity); | 383 | m_disp->setIntensity(m_Intensity); |
384 | m_setCurrentBrightness->setEnabled(true); | 384 | m_setCurrentBrightness->setEnabled(true); |
385 | m_hBright->setEnabled(true); | 385 | m_hBright->setEnabled(true); |
386 | } | 386 | } |
387 | m_disp->setImage( inf ); | 387 | m_disp->setImage( inf ); |
388 | if (m_SmallWindow) { | 388 | if (m_SmallWindow) { |
389 | if (m_gPrevNext->isEnabled()==false) { | 389 | if (m_gPrevNext->isEnabled()==false) { |
390 | m_gPrevNext->addTo(toolBar); | 390 | m_gPrevNext->addTo(toolBar); |
391 | fsButton->hide(); | 391 | fsButton->hide(); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | m_gPrevNext->setEnabled(true); | 394 | m_gPrevNext->setEnabled(true); |
395 | m_aDirUp->setEnabled(false); | 395 | m_aDirUp->setEnabled(false); |
396 | m_aShowInfo->setEnabled(true); | 396 | m_aShowInfo->setEnabled(true); |
397 | m_aViewfile->setEnabled(false); | 397 | m_aViewfile->setEnabled(false); |
398 | m_aStartSlide->setEnabled(false); | 398 | m_aStartSlide->setEnabled(false); |
399 | 399 | ||
400 | if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { | 400 | if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { |
401 | slotFullScreenToggled(m_aFullScreen->isOn()); | 401 | slotFullScreenToggled(m_aFullScreen->isOn()); |
402 | } | 402 | } |
403 | if (m_disp->fullScreen()) { | 403 | if (m_disp->fullScreen()) { |
404 | if (!m_disp->isVisible()) { | 404 | if (!m_disp->isVisible()) { |
405 | m_disp->showFullScreen(); | 405 | m_disp->showFullScreen(); |
406 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 406 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
407 | } | 407 | } |
408 | } else { | 408 | } else { |
409 | m_stack->raiseWidget( ImageDisplay ); | 409 | m_stack->raiseWidget( ImageDisplay ); |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | void PMainWindow::raiseIconView() { | 413 | void PMainWindow::raiseIconView() { |
414 | setUpdatesEnabled(false); | 414 | setUpdatesEnabled(false); |
415 | if (m_SmallWindow) { | 415 | if (m_SmallWindow) { |
416 | m_gPrevNext->removeFrom(toolBar); | 416 | m_gPrevNext->removeFrom(toolBar); |
417 | fsButton->show(); | 417 | fsButton->show(); |
418 | } | 418 | } |
419 | m_gPrevNext->setEnabled(false); | 419 | m_gPrevNext->setEnabled(false); |
420 | m_aDirUp->setEnabled(true); | 420 | m_aDirUp->setEnabled(true); |
421 | m_aShowInfo->setEnabled(true); | 421 | m_aShowInfo->setEnabled(true); |
422 | m_aViewfile->setEnabled(true); | 422 | m_aViewfile->setEnabled(true); |
423 | m_aStartSlide->setEnabled(true); | 423 | m_aStartSlide->setEnabled(true); |
424 | 424 | ||
425 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 425 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
426 | m_disp->stopSlide(); | 426 | m_disp->stopSlide(); |
427 | m_disp->hide(); | 427 | m_disp->hide(); |
428 | } | 428 | } |
429 | m_stack->raiseWidget( IconView ); | 429 | m_stack->raiseWidget( IconView ); |
430 | setUpdatesEnabled(true); | 430 | setUpdatesEnabled(true); |
431 | repaint(); | 431 | repaint(); |
432 | } | 432 | } |
433 | 433 | ||
434 | void PMainWindow::slotReturn() { | 434 | void PMainWindow::slotReturn() { |
435 | raiseIconView(); | 435 | raiseIconView(); |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 439 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
440 | /* | 440 | /* |
441 | * return from view | 441 | * return from view |
442 | * or properly quit | 442 | * or properly quit |
443 | */ | 443 | */ |
444 | if (!m_setDocCalled) { | 444 | if (!m_setDocCalled) { |
445 | if ( m_stack->visibleWidget() == m_info || | 445 | if ( m_stack->visibleWidget() == m_info || |
446 | m_stack->visibleWidget() == m_disp ) { | 446 | m_stack->visibleWidget() == m_disp ) { |
447 | ev->ignore(); | 447 | ev->ignore(); |
448 | raiseIconView(); | 448 | raiseIconView(); |
449 | return; | 449 | return; |
450 | } | 450 | } |
451 | } | 451 | } |
452 | if (m_disp && m_disp->fullScreen()) { | 452 | if (m_disp && m_disp->fullScreen()) { |
453 | /* otherwise opie-eye crashes in bigscreen mode! */ | 453 | /* otherwise opie-eye crashes in bigscreen mode! */ |
454 | m_disp->reparent(0,QPoint(0,0)); | 454 | m_disp->reparent(0,QPoint(0,0)); |
455 | m_stack->addWidget(m_disp,ImageDisplay); | 455 | m_stack->addWidget(m_disp,ImageDisplay); |
456 | } | 456 | } |
457 | ev->accept(); | 457 | ev->accept(); |
458 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 458 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
459 | } | 459 | } |
460 | 460 | ||
461 | void PMainWindow::setDocument( const QString& showImg ) | 461 | void PMainWindow::setDocument( const QString& showImg ) |
462 | { | 462 | { |
463 | QString file = showImg; | 463 | QString file = showImg; |
464 | DocLnk lnk(showImg); | 464 | DocLnk lnk(showImg); |
465 | if (lnk.isValid() ) | 465 | if (lnk.isValid() ) |
466 | file = lnk.file(); | 466 | file = lnk.file(); |
467 | slotDisplay( file ); | 467 | slotDisplay( file ); |
468 | #if 0 | 468 | #if 0 |
469 | if (!m_polishDone) { | 469 | if (!m_polishDone) { |
470 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); | 470 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | } | 473 | } |
474 | 474 | ||
475 | void PMainWindow::check_view_fullscreen() | 475 | void PMainWindow::check_view_fullscreen() |
476 | { | 476 | { |
477 | if (!m_view) return; | 477 | if (!m_view) return; |
478 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { | 478 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { |
479 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 479 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | void PMainWindow::slotSelectDir(int id) | 483 | void PMainWindow::slotSelectDir(int id) |
484 | { | 484 | { |
485 | emit changeDir( m_dev[fsMenu->text(id )] ); | 485 | emit changeDir( m_dev[fsMenu->text(id )] ); |
486 | } | 486 | } |
487 | 487 | ||
488 | void PMainWindow::dirChanged() | 488 | void PMainWindow::dirChanged() |
489 | { | 489 | { |
490 | fsMenu->clear(); | 490 | fsMenu->clear(); |
491 | m_dev.clear(); | 491 | m_dev.clear(); |
492 | 492 | ||
493 | /* home dir, too */ | 493 | /* home dir, too */ |
494 | QString f = getenv( "HOME" ); | 494 | QString f = getenv( "HOME" ); |
495 | if (!f.isEmpty()) { | 495 | if (!f.isEmpty()) { |
496 | m_dev.insert("Home directory",f); | 496 | m_dev.insert("Home directory",f); |
497 | fsMenu->insertItem("Home directory"); | 497 | fsMenu->insertItem("Home directory"); |
498 | } | 498 | } |
499 | const QList<FileSystem> &fs = m_storage->fileSystems(); | 499 | const QList<FileSystem> &fs = m_storage->fileSystems(); |
500 | QListIterator<FileSystem> it(fs ); | 500 | QListIterator<FileSystem> it(fs ); |
501 | for ( ; it.current(); ++it ) { | 501 | for ( ; it.current(); ++it ) { |
502 | const QString disk = (*it)->name(); | 502 | const QString disk = (*it)->name(); |
503 | const QString path = (*it)->path(); | 503 | const QString path = (*it)->path(); |
504 | m_dev.insert( disk, path ); | 504 | m_dev.insert( disk, path ); |
505 | fsMenu->insertItem( disk ); | 505 | fsMenu->insertItem( disk ); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | 508 | ||
509 | void PMainWindow::showToolbar(bool how) | 509 | void PMainWindow::showToolbar(bool how) |
510 | { | 510 | { |
511 | if (!how) toolBar->hide(); | 511 | if (!how) toolBar->hide(); |
512 | else toolBar->show(); | 512 | else toolBar->show(); |
513 | if (autoSave) { | 513 | if (autoSave) { |
514 | m_cfg->writeEntry("showtoolbar",how); | 514 | m_cfg->writeEntry("showtoolbar",how); |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | void PMainWindow::setupActions() | 518 | void PMainWindow::setupActions() |
519 | { | 519 | { |
520 | m_aDirUp = new QAction( tr( "Go dir up" ), Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), | 520 | m_aDirUp = new QAction( tr( "Go dir up" ), Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), |
521 | 0, 0, this, 0, true ); | 521 | 0, 0, this, 0, true ); |
522 | m_aDirUp->setToggleAction(false); | 522 | m_aDirUp->setToggleAction(false); |
523 | connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); | 523 | connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); |
524 | 524 | ||
525 | if ( Ir::supported() ) { | 525 | if ( Ir::supported() ) { |
526 | m_aBeam = new QAction( tr( "Beam file" ), Opie::Core::OResource::loadPixmap( "beam", Opie::Core::OResource::SmallIcon ), | 526 | m_aBeam = new QAction( tr( "Beam file" ), Opie::Core::OResource::loadPixmap( "beam", Opie::Core::OResource::SmallIcon ), |
527 | 0, 0, this, 0, true ); | 527 | 0, 0, this, 0, true ); |
528 | m_aBeam->setToggleAction(false); | 528 | m_aBeam->setToggleAction(false); |
529 | connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); | 529 | connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); |
530 | } else { | 530 | } else { |
531 | m_aBeam = 0; | 531 | m_aBeam = 0; |
532 | } | 532 | } |
533 | 533 | ||
534 | m_aShowInfo = new QAction( tr( "Show imageinfo" ), Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), | 534 | m_aShowInfo = new QAction( tr( "Show imageinfo" ), Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), |
535 | 0, 0, this, 0, true ); | 535 | 0, 0, this, 0, true ); |
536 | m_aShowInfo->setToggleAction(false); | 536 | m_aShowInfo->setToggleAction(false); |
537 | connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); | 537 | connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); |
538 | 538 | ||
539 | m_aTrash = new QAction( tr( "Delete file" ), Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), | 539 | m_aTrash = new QAction( tr( "Delete file" ), Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), |
540 | 0, 0, this, 0, true ); | 540 | 0, 0, this, 0, true ); |
541 | m_aTrash->setToggleAction(false); | 541 | m_aTrash->setToggleAction(false); |
542 | connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); | 542 | connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); |
543 | 543 | ||
544 | m_aViewfile = new QAction( tr( "Display image" ), Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), | 544 | m_aViewfile = new QAction( tr( "Display image" ), Opie::Core::OResource::loadPixmap("mag", Opie::Core::OResource::SmallIcon), |
545 | 0, 0, this, 0, true ); | 545 | 0, 0, this, 0, true ); |
546 | m_aViewfile->setToggleAction(false); | 546 | m_aViewfile->setToggleAction(false); |
547 | connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); | 547 | connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); |
548 | 548 | ||
549 | m_aStartSlide = new QAction( tr( "Start slideshow" ), Opie::Core::OResource::loadPixmap("play", Opie::Core::OResource::SmallIcon), | 549 | m_aStartSlide = new QAction( tr( "Start slideshow" ), Opie::Core::OResource::loadPixmap("play", Opie::Core::OResource::SmallIcon), |
550 | 0, 0, this, 0, true ); | 550 | 0, 0, this, 0, true ); |
551 | m_aStartSlide->setToggleAction(false); | 551 | m_aStartSlide->setToggleAction(false); |
552 | connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); | 552 | connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); |
553 | 553 | ||
554 | m_aHideToolbar = new QAction( tr( "Show toolbar" ), Opie::Core::OResource::loadPixmap( "UtilsIcon", | 554 | m_aHideToolbar = new QAction( tr( "Show toolbar" ), Opie::Core::OResource::loadPixmap( "UtilsIcon", |
555 | Opie::Core::OResource::SmallIcon ), 0, 0, this, 0, true ); | 555 | Opie::Core::OResource::SmallIcon ), 0, 0, this, 0, true ); |
556 | m_aHideToolbar->setOn (true); | 556 | m_aHideToolbar->setOn (true); |
557 | connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); | 557 | connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); |
558 | 558 | ||
559 | m_aSetup = new QAction( tr( "Settings" ), Opie::Core::OResource::loadPixmap("SettingsIcon", Opie::Core::OResource::SmallIcon), | 559 | m_aSetup = new QAction( tr( "Settings" ), Opie::Core::OResource::loadPixmap("SettingsIcon", Opie::Core::OResource::SmallIcon), |
560 | 0, 0, this, 0, true ); | 560 | 0, 0, this, 0, true ); |
561 | m_aSetup->setToggleAction(false); | 561 | m_aSetup->setToggleAction(false); |
562 | connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); | 562 | connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); |
563 | 563 | ||
564 | m_gListViewMode = new QActionGroup(this,"Select listmode",true); | 564 | m_gListViewMode = new QActionGroup(this,"Select listmode",true); |
565 | connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); | 565 | connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); |
566 | 566 | ||
567 | m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", | 567 | m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", |
568 | Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); | 568 | Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); |
569 | m_aDirLong->setToggleAction(true); | 569 | m_aDirLong->setToggleAction(true); |
570 | m_aDirShort = new QAction( tr( "Thumbnail and name" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumbonly", | 570 | m_aDirShort = new QAction( tr( "Thumbnail and name" ),Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumbonly", |
571 | Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); | 571 | Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); |
572 | m_aDirShort->setToggleAction(true); | 572 | m_aDirShort->setToggleAction(true); |
573 | m_aDirName = new QAction( tr( "Name only" ), Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-textview", | 573 | m_aDirName = new QAction( tr( "Name only" ), Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-textview", |
574 | Opie::Core::OResource::SmallIcon),0, 0, this, 0, true ); | 574 | Opie::Core::OResource::SmallIcon),0, 0, this, 0, true ); |
575 | m_aDirName->setToggleAction(true); | 575 | m_aDirName->setToggleAction(true); |
576 | int mode = m_cfg->readNumEntry("ListViewMode", 1); | 576 | int mode = m_cfg->readNumEntry("ListViewMode", 1); |
577 | if (mode < 1 || mode>3) mode = 1; | 577 | if (mode < 1 || mode>3) mode = 1; |
578 | switch (mode) { | 578 | switch (mode) { |
579 | case 3: | 579 | case 3: |
580 | m_aDirName->setOn(true); | 580 | m_aDirName->setOn(true); |
581 | break; | 581 | break; |
582 | case 2: | 582 | case 2: |
583 | m_aDirShort->setOn(true); | 583 | m_aDirShort->setOn(true); |
584 | break; | 584 | break; |
585 | case 1: | 585 | case 1: |
586 | default: | 586 | default: |
587 | m_aDirLong->setOn(true); | 587 | m_aDirLong->setOn(true); |
588 | } | 588 | } |
589 | m_gListViewMode->insert(m_aDirLong); | 589 | m_gListViewMode->insert(m_aDirLong); |
590 | m_gListViewMode->insert(m_aDirShort); | 590 | m_gListViewMode->insert(m_aDirShort); |
591 | m_gListViewMode->insert(m_aDirName); | 591 | m_gListViewMode->insert(m_aDirName); |
592 | 592 | ||
593 | m_gPrevNext = new QActionGroup(this,"imageprevnext",false); | 593 | m_gPrevNext = new QActionGroup(this,"imageprevnext",false); |
594 | m_aNext = new QAction( tr( "Next image" ),Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), | 594 | m_aNext = new QAction( tr( "Next image" ),Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), |
595 | 0, 0, this, 0, true ); | 595 | 0, 0, this, 0, true ); |
596 | m_aNext->setToggleAction(false); | 596 | m_aNext->setToggleAction(false); |
597 | connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); | 597 | connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); |
598 | m_aPrevious = new QAction( tr( "Previous image" ),Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), | 598 | m_aPrevious = new QAction( tr( "Previous image" ),Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), |
599 | 0, 0, this, 0, true ); | 599 | 0, 0, this, 0, true ); |
600 | m_aPrevious->setToggleAction(false); | 600 | m_aPrevious->setToggleAction(false); |
601 | connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); | 601 | connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); |
602 | m_gPrevNext->insert(m_aPrevious); | 602 | m_gPrevNext->insert(m_aPrevious); |
603 | m_gPrevNext->insert(m_aNext); | 603 | m_gPrevNext->insert(m_aNext); |
604 | 604 | ||
605 | m_aFullScreen = new QAction( tr( "Show images fullscreen" ), | 605 | m_aFullScreen = new QAction( tr( "Show images fullscreen" ), |
606 | Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); | 606 | Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon), 0, 0, this, 0, true ); |
607 | m_aFullScreen->setToggleAction(true); | 607 | m_aFullScreen->setToggleAction(true); |
608 | if (autoSave) { | 608 | if (autoSave) { |
609 | m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); | 609 | m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); |
610 | } else { | 610 | } else { |
611 | m_aFullScreen->setOn(false); | 611 | m_aFullScreen->setOn(false); |
612 | } | 612 | } |
613 | connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); | 613 | connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); |
614 | 614 | ||
615 | m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); | 615 | m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); |
616 | m_aAutoRotate = new QAction( tr( "Auto rotate images" ), | 616 | m_aAutoRotate = new QAction( tr( "Auto rotate images" ), |
617 | Opie::Core::OResource::loadPixmap( "rotate", Opie::Core::OResource::SmallIcon ), | 617 | Opie::Core::OResource::loadPixmap( "rotate", Opie::Core::OResource::SmallIcon ), |
618 | 0, 0, this, 0, true ); | 618 | 0, 0, this, 0, true ); |
619 | m_aAutoRotate->setToggleAction(true); | 619 | m_aAutoRotate->setToggleAction(true); |
620 | 620 | ||
621 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 621 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
622 | m_aAutoRotate->setOn(true); | 622 | m_aAutoRotate->setOn(true); |
623 | } else { | 623 | } else { |
624 | m_aAutoRotate->setOn(false); | 624 | m_aAutoRotate->setOn(false); |
625 | } | 625 | } |
626 | if (autoSave) { | 626 | if (autoSave) { |
627 | m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); | 627 | m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); |
628 | } | 628 | } |
629 | connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 629 | connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
630 | 630 | ||
631 | m_aUnscaled = new QAction( tr( "Show images unscaled" ), | 631 | m_aUnscaled = new QAction( tr( "Show images unscaled" ), |
632 | Opie::Core::OResource::loadPixmap( "1to1", Opie::Core::OResource::SmallIcon ), | 632 | Opie::Core::OResource::loadPixmap( "1to1", Opie::Core::OResource::SmallIcon ), |
633 | 0, 0, this, 0, true ); | 633 | 0, 0, this, 0, true ); |
634 | m_aUnscaled->setToggleAction(true); | 634 | m_aUnscaled->setToggleAction(true); |
635 | connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 635 | connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
636 | if (autoSave) { | 636 | if (autoSave) { |
637 | m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); | 637 | m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); |
638 | } else { | 638 | } else { |
639 | m_aUnscaled->setOn(false); | 639 | m_aUnscaled->setOn(false); |
640 | } | 640 | } |
641 | 641 | ||
642 | m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), | 642 | m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), |
643 | Opie::Core::OResource::loadPixmap( "mag", Opie::Core::OResource::SmallIcon ), | 643 | Opie::Core::OResource::loadPixmap( "mag", Opie::Core::OResource::SmallIcon ), |
644 | 0, 0, this, 0, true ); | 644 | 0, 0, this, 0, true ); |
645 | m_aZoomer->setToggleAction(true); | 645 | m_aZoomer->setToggleAction(true); |
646 | if (autoSave) { | 646 | if (autoSave) { |
647 | m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); | 647 | m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); |
648 | } else { | 648 | } else { |
649 | m_aZoomer->setOn (true); | 649 | m_aZoomer->setOn (true); |
650 | } | 650 | } |
651 | connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 651 | connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
652 | m_gDisplayType->insert(m_aAutoRotate); | 652 | m_gDisplayType->insert(m_aAutoRotate); |
653 | m_gDisplayType->insert(m_aUnscaled); | 653 | m_gDisplayType->insert(m_aUnscaled); |
654 | m_gDisplayType->insert(m_aZoomer); | 654 | m_gDisplayType->insert(m_aZoomer); |
655 | 655 | ||
656 | m_hGroup = new QActionGroup(this,"actioncollection",false); | 656 | m_hGroup = new QActionGroup(this,"actioncollection",false); |
657 | m_hGroup->insert(m_aFullScreen); | 657 | m_hGroup->insert(m_aFullScreen); |
658 | 658 | ||
659 | if (!m_SmallWindow) { | 659 | if (!m_SmallWindow) { |
660 | m_aForceSmall = new QAction(tr("Dont show seperate windows"), | 660 | m_aForceSmall = new QAction(tr("Dont show seperate windows"), |
661 | Opie::Core::OResource::loadPixmap( "AppsIcon", Opie::Core::OResource::SmallIcon ), | 661 | Opie::Core::OResource::loadPixmap( "AppsIcon", Opie::Core::OResource::SmallIcon ), |
662 | 0, 0, this, 0, true); | 662 | 0, 0, this, 0, true); |
663 | m_aForceSmall->setToggleAction(true); | 663 | m_aForceSmall->setToggleAction(true); |
664 | connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); | 664 | connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); |
665 | } else { | 665 | } else { |
666 | m_aForceSmall = 0; | 666 | m_aForceSmall = 0; |
667 | } | 667 | } |
668 | m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); | 668 | m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); |
669 | connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); | 669 | connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); |
670 | m_IncBrightness = new QAction(tr("Increase brightness by 5"), | 670 | m_IncBrightness = new QAction(tr("Increase brightness by 5"), |
671 | Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), | 671 | Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ), |
672 | 0, 0, this, 0, false); | 672 | 0, 0, this, 0, false); |
673 | m_DecBrightness = new QAction(tr("Decrease brightness by 5"), | 673 | m_DecBrightness = new QAction(tr("Decrease brightness by 5"), |
674 | Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ), | 674 | Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ), |
675 | 0, 0, this, 0, false); | 675 | 0, 0, this, 0, false); |
676 | m_hBright = new QActionGroup(this,"actioncollection",false), | 676 | m_hBright = new QActionGroup(this,"actioncollection",false), |
677 | m_hBright->insert(m_setCurrentBrightness); | 677 | m_hBright->insert(m_setCurrentBrightness); |
678 | m_hBright->insert(m_IncBrightness); | 678 | m_hBright->insert(m_IncBrightness); |
679 | m_hBright->insert(m_DecBrightness); | 679 | m_hBright->insert(m_DecBrightness); |
680 | } | 680 | } |
681 | 681 | ||
682 | void PMainWindow::setupBrightness() | 682 | void PMainWindow::setupBrightness() |
683 | { | 683 | { |
684 | if (!m_disp) { | 684 | if (!m_disp) { |
685 | return; | 685 | return; |
686 | } | 686 | } |
687 | bool reshow=false; | 687 | bool reshow=false; |
688 | if (m_disp->isVisible()&&m_disp->fullScreen()) { | 688 | if (m_disp->isVisible()&&m_disp->fullScreen()) { |
689 | m_disp->hide(); | 689 | m_disp->hide(); |
690 | reshow = true; | 690 | reshow = true; |
691 | } | 691 | } |
692 | int lb = m_disp->Intensity(); | 692 | int lb = m_disp->Intensity(); |
693 | if (Valuebox(0,-100,100,lb,lb)) { | 693 | if (Valuebox(0,-100,100,lb,lb)) { |
694 | m_disp->setIntensity(lb,true); | 694 | m_disp->setIntensity(lb,true); |
695 | } | 695 | } |
696 | if (reshow) { | 696 | if (reshow) { |
697 | m_disp->showFullScreen(); | 697 | m_disp->showFullScreen(); |
698 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 698 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
699 | } | 699 | } |
700 | } | 700 | } |
701 | 701 | ||
702 | void PMainWindow::setupToolbar() | 702 | void PMainWindow::setupToolbar() |
703 | { | 703 | { |
704 | toolBar = new QToolBar( this ); | 704 | toolBar = new QToolBar( this ); |
705 | addToolBar(toolBar); | 705 | addToolBar(toolBar); |
706 | toolBar->setHorizontalStretchable( true ); | 706 | toolBar->setHorizontalStretchable( true ); |
707 | setToolBarsMovable( false ); | 707 | setToolBarsMovable( false ); |
708 | m_aDirUp->addTo( toolBar ); | 708 | m_aDirUp->addTo( toolBar ); |
709 | 709 | ||
710 | fsButton = new PFileSystem( toolBar ); | 710 | fsButton = new PFileSystem( toolBar ); |
711 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), | 711 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), |
712 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 712 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
713 | connect( this, SIGNAL( changeDir( const QString& ) ), | 713 | connect( this, SIGNAL( changeDir( const QString& ) ), |
714 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 714 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
715 | 715 | ||
716 | if (m_aBeam) { | 716 | if (m_aBeam) { |
717 | m_aBeam->addTo( toolBar ); | 717 | m_aBeam->addTo( toolBar ); |
718 | } | 718 | } |
719 | m_aShowInfo->addTo(toolBar); | 719 | m_aShowInfo->addTo(toolBar); |
720 | m_aTrash->addTo(toolBar); | 720 | m_aTrash->addTo(toolBar); |
721 | 721 | ||
722 | m_gDisplayType->addTo(toolBar); | 722 | m_gDisplayType->addTo(toolBar); |
723 | 723 | ||
724 | if (!m_SmallWindow) { | 724 | if (!m_SmallWindow) { |
725 | m_gPrevNext->addTo(toolBar); | 725 | m_gPrevNext->addTo(toolBar); |
726 | } else { | 726 | } else { |
727 | m_gPrevNext->setEnabled(false); | 727 | m_gPrevNext->setEnabled(false); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | 730 | ||
731 | void PMainWindow::setupMenu() | 731 | void PMainWindow::setupMenu() |
732 | { | 732 | { |
733 | fileMenu = new QPopupMenu( menuBar() ); | 733 | fileMenu = new QPopupMenu( menuBar() ); |
734 | menuBar()->insertItem( tr( "File" ), fileMenu ); | 734 | menuBar()->insertItem( tr( "File" ), fileMenu ); |
735 | dispMenu = new QPopupMenu( menuBar() ); | 735 | dispMenu = new QPopupMenu( menuBar() ); |
736 | menuBar()->insertItem( tr( "Show" ), dispMenu ); | 736 | menuBar()->insertItem( tr( "Show" ), dispMenu ); |
737 | settingsMenu = new QPopupMenu( menuBar() ); | 737 | settingsMenu = new QPopupMenu( menuBar() ); |
738 | menuBar()->insertItem( tr( "Settings" ), settingsMenu ); | 738 | menuBar()->insertItem( tr( "Settings" ), settingsMenu ); |
739 | 739 | ||
740 | m_aViewfile->addTo(fileMenu); | 740 | m_aViewfile->addTo(fileMenu); |
741 | m_aShowInfo->addTo(fileMenu); | 741 | m_aShowInfo->addTo(fileMenu); |
742 | m_aStartSlide->addTo(fileMenu); | 742 | m_aStartSlide->addTo(fileMenu); |
743 | 743 | ||
744 | fileMenu->insertSeparator(); | 744 | fileMenu->insertSeparator(); |
745 | m_aDirUp->addTo( fileMenu ); | 745 | m_aDirUp->addTo( fileMenu ); |
746 | 746 | ||
747 | fsMenu = new QPopupMenu(fileMenu); | 747 | fsMenu = new QPopupMenu(fileMenu); |
748 | fileMenu->insertItem(Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ), | 748 | fileMenu->insertItem(Opie::Core::OResource::loadPixmap( "pcmcia", Opie::Core::OResource::SmallIcon ), |
749 | tr("Select filesystem"),fsMenu); | 749 | tr("Select filesystem"),fsMenu); |
750 | connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); | 750 | connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); |
751 | dirChanged(); | 751 | dirChanged(); |
752 | 752 | ||
753 | if ( m_aBeam ) { | 753 | if ( m_aBeam ) { |
754 | fileMenu->insertSeparator(); | 754 | fileMenu->insertSeparator(); |
755 | m_aBeam->addTo( fileMenu ); | 755 | m_aBeam->addTo( fileMenu ); |
756 | } | 756 | } |
757 | fileMenu->insertSeparator(); | 757 | fileMenu->insertSeparator(); |
758 | m_aTrash->addTo(fileMenu); | 758 | m_aTrash->addTo(fileMenu); |
759 | 759 | ||
760 | listviewMenu = new QPopupMenu(dispMenu); | 760 | listviewMenu = new QPopupMenu(dispMenu); |
761 | dispMenu->insertItem(Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", Opie::Core::OResource::SmallIcon), | 761 | dispMenu->insertItem(Opie::Core::OResource::loadPixmap("opie-eye/opie-eye-thumb", Opie::Core::OResource::SmallIcon), |
762 | tr("Listview mode"),listviewMenu); | 762 | tr("Listview mode"),listviewMenu); |
763 | m_gListViewMode->addTo(listviewMenu); | 763 | m_gListViewMode->addTo(listviewMenu); |
764 | dispMenu->insertSeparator(); | 764 | dispMenu->insertSeparator(); |
765 | m_aFullScreen->addTo(dispMenu); | 765 | m_aFullScreen->addTo(dispMenu); |
766 | m_gDisplayType->addTo(dispMenu); | 766 | m_gDisplayType->addTo(dispMenu); |
767 | dispMenu->insertSeparator(); | 767 | dispMenu->insertSeparator(); |
768 | m_gPrevNext->addTo(dispMenu); | 768 | m_gPrevNext->addTo(dispMenu); |
769 | dispMenu->insertSeparator(); | 769 | dispMenu->insertSeparator(); |
770 | m_hBright->addTo(dispMenu); | 770 | m_hBright->addTo(dispMenu); |
771 | m_hBright->setEnabled(false); | 771 | m_hBright->setEnabled(false); |
772 | 772 | ||
773 | if (m_aForceSmall) { | 773 | if (m_aForceSmall) { |
774 | dispMenu->insertSeparator(); | 774 | dispMenu->insertSeparator(); |
775 | m_aForceSmall->addTo(dispMenu); | 775 | m_aForceSmall->addTo(dispMenu); |
776 | } | 776 | } |
777 | 777 | ||
778 | m_aSetup->addTo(settingsMenu); | 778 | m_aSetup->addTo(settingsMenu); |
779 | m_aHideToolbar->addTo(settingsMenu); | 779 | m_aHideToolbar->addTo(settingsMenu); |
780 | } | 780 | } |
781 | 781 | ||
782 | void PMainWindow::listviewselected(QAction*which) | 782 | void PMainWindow::listviewselected(QAction*which) |
783 | { | 783 | { |
784 | if (!which || which->isOn()==false) return; | 784 | if (!which || which->isOn()==false) return; |
785 | int val = 1; | 785 | int val = 1; |
786 | 786 | ||
787 | if (which==m_aDirName) { | 787 | if (which==m_aDirName) { |
788 | val = 3; | 788 | val = 3; |
789 | } else if (which==m_aDirShort) { | 789 | } else if (which==m_aDirShort) { |
790 | val = 2; | 790 | val = 2; |
791 | } else if (which==m_aDirLong) { | 791 | } else if (which==m_aDirLong) { |
792 | val = 1; | 792 | val = 1; |
793 | } | 793 | } |
794 | emit changeListMode(val); | 794 | emit changeListMode(val); |
795 | } | 795 | } |
796 | 796 | ||
797 | void PMainWindow::readConfig() | 797 | void PMainWindow::readConfig() |
798 | { | 798 | { |
799 | autoSave =m_cfg->readBoolEntry("savestatus",true); | 799 | autoSave =m_cfg->readBoolEntry("savestatus",true); |
800 | m_Intensity = m_cfg->readNumEntry("intensity",0); | 800 | m_Intensity = m_cfg->readNumEntry("intensity",0); |
801 | } | 801 | } |
802 | 802 | ||
803 | void PMainWindow::polish() | 803 | void PMainWindow::polish() |
804 | { | 804 | { |
805 | if (m_disp) { | 805 | if (m_disp) { |
806 | odebug << "======================\n" | 806 | odebug << "======================\n" |
807 | << "Called via setdocument\n" | 807 | << "Called via setdocument\n" |
808 | << "======================" << oendl; | 808 | << "======================" << oendl; |
809 | m_setDocCalled = true; | 809 | m_setDocCalled = true; |
810 | m_view->setDoccalled(true); | 810 | m_view->setDoccalled(true); |
811 | m_disp->setCloseIfHide(true); | 811 | m_disp->setCloseIfHide(true); |
812 | } else { | 812 | } else { |
813 | m_setDocCalled = false; | 813 | m_setDocCalled = false; |
814 | m_view->setDoccalled(false); | 814 | m_view->setDoccalled(false); |
815 | } | 815 | } |
816 | m_polishDone = true; | 816 | m_polishDone = true; |
817 | QMainWindow::polish(); | 817 | QMainWindow::polish(); |
818 | if (m_setDocCalled) { | 818 | if (m_setDocCalled) { |
819 | if (m_aFullScreen->isOn()) { | 819 | if (m_aFullScreen->isOn()) { |
820 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); | 820 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); |
821 | } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 821 | } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
822 | } | 822 | } |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | void PMainWindow::slotForceSmall(bool how) | 826 | void PMainWindow::slotForceSmall(bool how) |
827 | { | 827 | { |
828 | odebug << "Disable separate windows: " << how << oendl; | 828 | odebug << "Disable separate windows: " << how << oendl; |
829 | if (m_stack) { | 829 | if (m_stack) { |
830 | if (how) { | 830 | if (how) { |
831 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); | 831 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); |
832 | } else { | 832 | } else { |
833 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 833 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
834 | } | 834 | } |
835 | } | 835 | } |
836 | if (autoSave) { | 836 | if (autoSave) { |
837 | m_cfg->writeEntry("dontshowseperate",how); | 837 | m_cfg->writeEntry("dontshowseperate",how); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | 840 | ||
841 | bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) | 841 | bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) |
842 | { | 842 | { |
843 | QDialog dlg(parent,"brightnessbox",true); | 843 | QDialog dlg(parent,"brightnessbox",true); |
844 | QVBoxLayout * m_MainLayout; | 844 | QVBoxLayout * m_MainLayout; |
845 | QGridLayout * m_IntensityLayout; | 845 | QGridLayout * m_IntensityLayout; |
846 | QSpinBox * m_Intensity; | 846 | QSpinBox * m_Intensity; |
847 | QLabel * m_IntensityLabel; | 847 | QLabel * m_IntensityLabel; |
848 | 848 | ||
849 | m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); | 849 | m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); |
850 | m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); | 850 | m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); |
851 | m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); | 851 | m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); |
852 | m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); | 852 | m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); |
853 | m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); | 853 | m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); |
854 | m_Intensity->setMaxValue( max ); | 854 | m_Intensity->setMaxValue( max ); |
855 | m_Intensity->setMinValue(min); | 855 | m_Intensity->setMinValue(min); |
856 | m_Intensity->setValue( current ); | 856 | m_Intensity->setValue( current ); |
857 | m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); | 857 | m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); |
858 | m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); | 858 | m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); |
859 | m_IntensityLabel->setText(QObject::tr("Display brightness:")); | 859 | m_IntensityLabel->setText(QObject::tr("Display brightness:")); |
860 | m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); | 860 | m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); |
861 | m_MainLayout->addLayout(m_IntensityLayout); | 861 | m_MainLayout->addLayout(m_IntensityLayout); |
862 | if (dlg.exec()) { | 862 | if (dlg.exec()) { |
863 | store = m_Intensity->value(); | 863 | store = m_Intensity->value(); |
864 | return true; | 864 | return true; |
865 | } | 865 | } |
866 | return false; | 866 | return false; |
867 | } | 867 | } |
diff --git a/noncore/unsupported/libopie/ofileselector.cpp b/noncore/unsupported/libopie/ofileselector.cpp index 2a6aed0..3bb85e0 100644 --- a/noncore/unsupported/libopie/ofileselector.cpp +++ b/noncore/unsupported/libopie/ofileselector.cpp | |||
@@ -1,747 +1,747 @@ | |||
1 | #include <qcombobox.h> | 1 | #include <qcombobox.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qlayout.h> | 4 | #include <qlayout.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qwidgetstack.h> | 7 | #include <qwidgetstack.h> |
8 | 8 | ||
9 | /* hacky but we need to get FileSelector::filter */ | 9 | /* hacky but we need to get FileSelector::filter */ |
10 | #define private public | 10 | #define private public |
11 | #include <qpe/fileselector.h> | 11 | #include <qpe/fileselector.h> |
12 | #undef private | 12 | #undef private |
13 | 13 | ||
14 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
15 | #include <qpe/mimetype.h> | 15 | #include <qpe/mimetype.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/storage.h> | 17 | #include <qpe/storage.h> |
18 | 18 | ||
19 | #include "ofileselector_p.h" | 19 | #include "ofileselector_p.h" |
20 | #include "ofileselector.h" | 20 | #include "ofileselector.h" |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
24 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | 24 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) |
25 | : m_selector( selector ) { | 25 | : m_selector( selector ) { |
26 | } | 26 | } |
27 | OFileViewInterface::~OFileViewInterface() { | 27 | OFileViewInterface::~OFileViewInterface() { |
28 | } | 28 | } |
29 | QString OFileViewInterface::name()const{ | 29 | QString OFileViewInterface::name()const{ |
30 | return m_name; | 30 | return m_name; |
31 | } | 31 | } |
32 | void OFileViewInterface::setName( const QString& name ) { | 32 | void OFileViewInterface::setName( const QString& name ) { |
33 | m_name = name; | 33 | m_name = name; |
34 | } | 34 | } |
35 | OFileSelector* OFileViewInterface::selector()const { | 35 | OFileSelector* OFileViewInterface::selector()const { |
36 | return m_selector; | 36 | return m_selector; |
37 | } | 37 | } |
38 | DocLnk OFileViewInterface::selectedDocument()const { | 38 | DocLnk OFileViewInterface::selectedDocument()const { |
39 | return DocLnk( selectedName() ); | 39 | return DocLnk( selectedName() ); |
40 | } | 40 | } |
41 | bool OFileViewInterface::showNew()const { | 41 | bool OFileViewInterface::showNew()const { |
42 | return selector()->showNew(); | 42 | return selector()->showNew(); |
43 | } | 43 | } |
44 | bool OFileViewInterface::showClose()const { | 44 | bool OFileViewInterface::showClose()const { |
45 | return selector()->showClose(); | 45 | return selector()->showClose(); |
46 | } | 46 | } |
47 | MimeTypes OFileViewInterface::mimeTypes()const { | 47 | MimeTypes OFileViewInterface::mimeTypes()const { |
48 | return selector()->mimeTypes(); | 48 | return selector()->mimeTypes(); |
49 | } | 49 | } |
50 | QStringList OFileViewInterface::currentMimeType()const { | 50 | QStringList OFileViewInterface::currentMimeType()const { |
51 | return selector()->currentMimeType(); | 51 | return selector()->currentMimeType(); |
52 | } | 52 | } |
53 | void OFileViewInterface::activate( const QString& ) { | 53 | void OFileViewInterface::activate( const QString& ) { |
54 | // not implemented here | 54 | // not implemented here |
55 | } | 55 | } |
56 | void OFileViewInterface::ok() { | 56 | void OFileViewInterface::ok() { |
57 | emit selector()->ok(); | 57 | emit selector()->ok(); |
58 | } | 58 | } |
59 | void OFileViewInterface::cancel() { | 59 | void OFileViewInterface::cancel() { |
60 | emit selector()->cancel(); | 60 | emit selector()->cancel(); |
61 | } | 61 | } |
62 | void OFileViewInterface::closeMe() { | 62 | void OFileViewInterface::closeMe() { |
63 | emit selector()->closeMe(); | 63 | emit selector()->closeMe(); |
64 | } | 64 | } |
65 | void OFileViewInterface::fileSelected( const QString& str) { | 65 | void OFileViewInterface::fileSelected( const QString& str) { |
66 | emit selector()->fileSelected( str); | 66 | emit selector()->fileSelected( str); |
67 | } | 67 | } |
68 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { | 68 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { |
69 | emit selector()->fileSelected( lnk ); | 69 | emit selector()->fileSelected( lnk ); |
70 | } | 70 | } |
71 | void OFileViewInterface::setCurrentFileName( const QString& str ) { | 71 | void OFileViewInterface::setCurrentFileName( const QString& str ) { |
72 | selector()->m_lneEdit->setText( str ); | 72 | selector()->m_lneEdit->setText( str ); |
73 | } | 73 | } |
74 | QString OFileViewInterface::currentFileName()const{ | 74 | QString OFileViewInterface::currentFileName()const{ |
75 | return selector()->m_lneEdit->text(); | 75 | return selector()->m_lneEdit->text(); |
76 | } | 76 | } |
77 | QString OFileViewInterface::startDirectory()const{ | 77 | QString OFileViewInterface::startDirectory()const{ |
78 | return selector()->m_startDir; | 78 | return selector()->m_startDir; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 82 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
83 | : OFileViewInterface( selector ) { | 83 | : OFileViewInterface( selector ) { |
84 | m_selector = 0; | 84 | m_selector = 0; |
85 | setName( QObject::tr("Documents") ); | 85 | setName( QObject::tr("Documents") ); |
86 | } | 86 | } |
87 | ODocumentFileView::~ODocumentFileView() { | 87 | ODocumentFileView::~ODocumentFileView() { |
88 | 88 | ||
89 | } | 89 | } |
90 | QString ODocumentFileView::selectedName()const { | 90 | QString ODocumentFileView::selectedName()const { |
91 | if (!m_selector) | 91 | if (!m_selector) |
92 | return QString::null; | 92 | return QString::null; |
93 | 93 | ||
94 | return m_selector->selectedDocument().file(); | 94 | return m_selector->selectedDocument().file(); |
95 | } | 95 | } |
96 | QString ODocumentFileView::selectedPath()const { | 96 | QString ODocumentFileView::selectedPath()const { |
97 | return QPEApplication::documentDir(); | 97 | return QPEApplication::documentDir(); |
98 | } | 98 | } |
99 | QString ODocumentFileView::directory()const { | 99 | QString ODocumentFileView::directory()const { |
100 | return selectedPath(); | 100 | return selectedPath(); |
101 | } | 101 | } |
102 | void ODocumentFileView::reread() { | 102 | void ODocumentFileView::reread() { |
103 | if (!m_selector) | 103 | if (!m_selector) |
104 | return; | 104 | return; |
105 | 105 | ||
106 | m_selector->setNewVisible( showNew() ); | 106 | m_selector->setNewVisible( showNew() ); |
107 | m_selector->setCloseVisible( showClose() ); | 107 | m_selector->setCloseVisible( showClose() ); |
108 | m_selector->filter = currentMimeType().join(";"); | 108 | m_selector->filter = currentMimeType().join(";"); |
109 | m_selector->reread(); | 109 | m_selector->reread(); |
110 | } | 110 | } |
111 | int ODocumentFileView::fileCount()const { | 111 | int ODocumentFileView::fileCount()const { |
112 | if (!m_selector) | 112 | if (!m_selector) |
113 | return -1; | 113 | return -1; |
114 | 114 | ||
115 | return m_selector->fileCount(); | 115 | return m_selector->fileCount(); |
116 | } | 116 | } |
117 | DocLnk ODocumentFileView::selectedDocument()const { | 117 | DocLnk ODocumentFileView::selectedDocument()const { |
118 | if (!m_selector) | 118 | if (!m_selector) |
119 | return DocLnk(); | 119 | return DocLnk(); |
120 | 120 | ||
121 | return m_selector->selectedDocument(); | 121 | return m_selector->selectedDocument(); |
122 | } | 122 | } |
123 | QWidget* ODocumentFileView::widget( QWidget* parent ) { | 123 | QWidget* ODocumentFileView::widget( QWidget* parent ) { |
124 | if (!m_selector ) { | 124 | if (!m_selector ) { |
125 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 125 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
126 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), | 126 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), |
127 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 127 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
128 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 128 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
129 | selector(), SIGNAL(closeMe() ) ); | 129 | selector(), SIGNAL(closeMe() ) ); |
130 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), | 130 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), |
131 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); | 131 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); |
132 | } | 132 | } |
133 | 133 | ||
134 | return m_selector; | 134 | return m_selector; |
135 | } | 135 | } |
136 | 136 | ||
137 | /* | 137 | /* |
138 | * This is the file system view used | 138 | * This is the file system view used |
139 | * we use a QListView + QListViewItems for it | 139 | * we use a QListView + QListViewItems for it |
140 | */ | 140 | */ |
141 | 141 | ||
142 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 142 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
143 | const QString& path, const QString& date, | 143 | const QString& path, const QString& date, |
144 | const QString& size, const QString& dir, | 144 | const QString& size, const QString& dir, |
145 | bool isLocked, bool isDir ) | 145 | bool isLocked, bool isDir ) |
146 | : QListViewItem( view ) | 146 | : QListViewItem( view ) |
147 | { | 147 | { |
148 | setPixmap(0, pixmap ); | 148 | setPixmap(0, pixmap ); |
149 | setText(1, path ); | 149 | setText(1, path ); |
150 | setText(2, size ); | 150 | setText(2, size ); |
151 | setText(3, date ); | 151 | setText(3, date ); |
152 | m_isDir = isDir; | 152 | m_isDir = isDir; |
153 | m_dir = dir; | 153 | m_dir = dir; |
154 | m_locked = isLocked; | 154 | m_locked = isLocked; |
155 | } | 155 | } |
156 | OFileSelectorItem::~OFileSelectorItem() { | 156 | OFileSelectorItem::~OFileSelectorItem() { |
157 | 157 | ||
158 | } | 158 | } |
159 | bool OFileSelectorItem::isLocked()const { | 159 | bool OFileSelectorItem::isLocked()const { |
160 | return m_locked; | 160 | return m_locked; |
161 | } | 161 | } |
162 | QString OFileSelectorItem::directory()const { | 162 | QString OFileSelectorItem::directory()const { |
163 | return m_dir; | 163 | return m_dir; |
164 | } | 164 | } |
165 | bool OFileSelectorItem::isDir()const { | 165 | bool OFileSelectorItem::isDir()const { |
166 | return m_isDir; | 166 | return m_isDir; |
167 | } | 167 | } |
168 | QString OFileSelectorItem::path()const { | 168 | QString OFileSelectorItem::path()const { |
169 | return text( 1 ); | 169 | return text( 1 ); |
170 | } | 170 | } |
171 | QString OFileSelectorItem::key( int id, bool )const { | 171 | QString OFileSelectorItem::key( int id, bool )const { |
172 | QString ke; | 172 | QString ke; |
173 | if( id == 0 || id == 1 ){ // name | 173 | if( id == 0 || id == 1 ){ // name |
174 | if( m_isDir ){ | 174 | if( m_isDir ){ |
175 | ke.append("0" ); | 175 | ke.append("0" ); |
176 | ke.append( text(1) ); | 176 | ke.append( text(1) ); |
177 | }else{ | 177 | }else{ |
178 | ke.append("1" ); | 178 | ke.append("1" ); |
179 | ke.append( text(1) ); | 179 | ke.append( text(1) ); |
180 | } | 180 | } |
181 | return ke; | 181 | return ke; |
182 | }else | 182 | }else |
183 | return text( id ); | 183 | return text( id ); |
184 | 184 | ||
185 | } | 185 | } |
186 | 186 | ||
187 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, | 187 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, |
188 | OFileSelector* sel) | 188 | OFileSelector* sel) |
189 | : QWidget( parent ), m_sel( sel ) { | 189 | : QWidget( parent ), m_sel( sel ) { |
190 | m_all = false; | 190 | m_all = false; |
191 | QVBoxLayout* lay = new QVBoxLayout( this ); | 191 | QVBoxLayout* lay = new QVBoxLayout( this ); |
192 | m_currentDir = startDir; | 192 | m_currentDir = startDir; |
193 | 193 | ||
194 | /* | 194 | /* |
195 | * now we add a special bar | 195 | * now we add a special bar |
196 | * One Button For Up | 196 | * One Button For Up |
197 | * Home | 197 | * Home |
198 | * Doc | 198 | * Doc |
199 | * And a dropdown menu with FileSystems | 199 | * And a dropdown menu with FileSystems |
200 | * FUTURE: one to change dir with lineedit | 200 | * FUTURE: one to change dir with lineedit |
201 | * Bookmarks | 201 | * Bookmarks |
202 | * Create Dir | 202 | * Create Dir |
203 | */ | 203 | */ |
204 | QHBox* box = new QHBox(this ); | 204 | QHBox* box = new QHBox(this ); |
205 | box->setBackgroundMode( PaletteButton ); | 205 | box->setBackgroundMode( PaletteButton ); |
206 | box->setSpacing( 0 ); | 206 | box->setSpacing( 0 ); |
207 | 207 | ||
208 | QToolButton *btn = new QToolButton( box ); | 208 | QToolButton *btn = new QToolButton( box ); |
209 | btn->setIconSet( Resource::loadIconSet("up") ); | 209 | btn->setIconSet( Resource::loadIconSet("up") ); |
210 | connect(btn, SIGNAL(clicked() ), | 210 | connect(btn, SIGNAL(clicked() ), |
211 | this, SLOT( cdUP() ) ); | 211 | this, SLOT( cdUP() ) ); |
212 | 212 | ||
213 | btn = new QToolButton( box ); | 213 | btn = new QToolButton( box ); |
214 | btn->setIconSet( Resource::loadIconSet("home") ); | 214 | btn->setIconSet( Resource::loadIconSet("home") ); |
215 | connect(btn, SIGNAL(clicked() ), | 215 | connect(btn, SIGNAL(clicked() ), |
216 | this, SLOT( cdHome() ) ); | 216 | this, SLOT( cdHome() ) ); |
217 | 217 | ||
218 | btn = new QToolButton( box ); | 218 | btn = new QToolButton( box ); |
219 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); | 219 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); |
220 | connect(btn, SIGNAL(clicked() ), | 220 | connect(btn, SIGNAL(clicked() ), |
221 | this, SLOT(cdDoc() ) ); | 221 | this, SLOT(cdDoc() ) ); |
222 | 222 | ||
223 | m_btnNew = new QToolButton( box ); | 223 | m_btnNew = new QToolButton( box ); |
224 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); | 224 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); |
225 | connect(m_btnNew, SIGNAL(clicked() ), | 225 | connect(m_btnNew, SIGNAL(clicked() ), |
226 | this, SLOT(slotNew() ) ); | 226 | this, SLOT(slotNew() ) ); |
227 | 227 | ||
228 | 228 | ||
229 | m_btnClose = new QToolButton( box ); | 229 | m_btnClose = new QToolButton( box ); |
230 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); | 230 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); |
231 | connect(m_btnClose, SIGNAL(clicked() ), | 231 | connect(m_btnClose, SIGNAL(clicked() ), |
232 | selector(), SIGNAL(closeMe() ) ); | 232 | selector(), SIGNAL(closeMe() ) ); |
233 | 233 | ||
234 | btn = new QToolButton( box ); | 234 | btn = new QToolButton( box ); |
235 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); | 235 | btn->setIconSet( Resource::loadIconSet("pcmcia") ); |
236 | 236 | ||
237 | /* let's fill device parts */ | 237 | /* let's fill device parts */ |
238 | QPopupMenu* pop = new QPopupMenu(this); | 238 | QPopupMenu* pop = new QPopupMenu(this); |
239 | connect(pop, SIGNAL( activated(int) ), | 239 | connect(pop, SIGNAL( activated(int) ), |
240 | this, SLOT(slotFSActivated(int) ) ); | 240 | this, SLOT(slotFSActivated(int) ) ); |
241 | 241 | ||
242 | StorageInfo storage; | 242 | StorageInfo storage; |
243 | const QList<FileSystem> &fs = storage.fileSystems(); | 243 | const QList<FileSystem> &fs = storage.fileSystems(); |
244 | QListIterator<FileSystem> it(fs); | 244 | QListIterator<FileSystem> it(fs); |
245 | for ( ; it.current(); ++it ) { | 245 | for ( ; it.current(); ++it ) { |
246 | const QString disk = (*it)->name(); | 246 | const QString disk = (*it)->name(); |
247 | const QString path = (*it)->path(); | 247 | const QString path = (*it)->path(); |
248 | m_dev.insert( disk, path ); | 248 | m_dev.insert( disk, path ); |
249 | pop->insertItem( disk ); | 249 | pop->insertItem( disk ); |
250 | } | 250 | } |
251 | m_fsPop = pop; | 251 | m_fsPop = pop; |
252 | 252 | ||
253 | 253 | ||
254 | btn->setPopup( pop ); | 254 | btn->setPopup( pop ); |
255 | 255 | ||
256 | lay->addWidget( box ); | 256 | lay->addWidget( box ); |
257 | 257 | ||
258 | m_view = new QListView( this ); | 258 | m_view = new QListView( this ); |
259 | 259 | ||
260 | m_view->installEventFilter(this); | 260 | m_view->installEventFilter(this); |
261 | 261 | ||
262 | QPEApplication::setStylusOperation( m_view->viewport(), | 262 | QPEApplication::setStylusOperation( m_view->viewport(), |
263 | QPEApplication::RightOnHold); | 263 | QPEApplication::RightOnHold); |
264 | m_view->addColumn(" " ); | 264 | m_view->addColumn(" " ); |
265 | m_view->addColumn(tr("Name"), 135 ); | 265 | m_view->addColumn(tr("Name"), 135 ); |
266 | m_view->addColumn(tr("Size"), -1 ); | 266 | m_view->addColumn(tr("Size"), -1 ); |
267 | m_view->addColumn(tr("Date"), 60 ); | 267 | m_view->addColumn(tr("Date"), 60 ); |
268 | m_view->addColumn(tr("Mime Type"), -1 ); | 268 | m_view->addColumn(tr("Mime Type"), -1 ); |
269 | 269 | ||
270 | 270 | ||
271 | m_view->setSorting( 1 ); | 271 | m_view->setSorting( 1 ); |
272 | m_view->setAllColumnsShowFocus( TRUE ); | 272 | m_view->setAllColumnsShowFocus( TRUE ); |
273 | 273 | ||
274 | lay->addWidget( m_view, 1000 ); | 274 | lay->addWidget( m_view, 1000 ); |
275 | connectSlots(); | 275 | connectSlots(); |
276 | } | 276 | } |
277 | OFileViewFileListView::~OFileViewFileListView() { | 277 | OFileViewFileListView::~OFileViewFileListView() { |
278 | } | 278 | } |
279 | void OFileViewFileListView::slotNew() { | 279 | void OFileViewFileListView::slotNew() { |
280 | DocLnk lnk; | 280 | DocLnk lnk; |
281 | emit selector()->newSelected( lnk ); | 281 | emit selector()->newSelected( lnk ); |
282 | } | 282 | } |
283 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | 283 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ |
284 | QListViewItem* item = m_view->currentItem(); | 284 | QListViewItem* item = m_view->currentItem(); |
285 | if (!item ) | 285 | if (!item ) |
286 | return 0l; | 286 | return 0l; |
287 | 287 | ||
288 | return static_cast<OFileSelectorItem*>(item); | 288 | return static_cast<OFileSelectorItem*>(item); |
289 | } | 289 | } |
290 | void OFileViewFileListView::reread( bool all ) { | 290 | void OFileViewFileListView::reread( bool all ) { |
291 | m_view->clear(); | 291 | m_view->clear(); |
292 | 292 | ||
293 | if (selector()->showClose() ) | 293 | if (selector()->showClose() ) |
294 | m_btnClose->show(); | 294 | m_btnClose->show(); |
295 | else | 295 | else |
296 | m_btnClose->hide(); | 296 | m_btnClose->hide(); |
297 | 297 | ||
298 | if (selector()->showNew() ) | 298 | if (selector()->showNew() ) |
299 | m_btnNew->show(); | 299 | m_btnNew->show(); |
300 | else | 300 | else |
301 | m_btnNew->hide(); | 301 | m_btnNew->hide(); |
302 | 302 | ||
303 | m_mimes = selector()->currentMimeType(); | 303 | m_mimes = selector()->currentMimeType(); |
304 | m_all = all; | 304 | m_all = all; |
305 | 305 | ||
306 | QDir dir( m_currentDir ); | 306 | QDir dir( m_currentDir ); |
307 | if (!dir.exists() ) | 307 | if (!dir.exists() ) |
308 | return; | 308 | return; |
309 | 309 | ||
310 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 310 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
311 | int filter; | 311 | int filter; |
312 | if (m_all ) | 312 | if (m_all ) |
313 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 313 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
314 | else | 314 | else |
315 | filter = QDir::Files | QDir::Dirs | QDir::All; | 315 | filter = QDir::Files | QDir::Dirs | QDir::All; |
316 | dir.setFilter( filter ); | 316 | dir.setFilter( filter ); |
317 | 317 | ||
318 | // now go through all files | 318 | // now go through all files |
319 | const QFileInfoList *list = dir.entryInfoList(); | 319 | const QFileInfoList *list = dir.entryInfoList(); |
320 | if (!list) { | 320 | if (!list) { |
321 | cdUP(); | 321 | cdUP(); |
322 | return; | 322 | return; |
323 | } | 323 | } |
324 | QFileInfoListIterator it( *list ); | 324 | QFileInfoListIterator it( *list ); |
325 | QFileInfo *fi; | 325 | QFileInfo *fi; |
326 | while( (fi=it.current() ) ){ | 326 | while( (fi=it.current() ) ){ |
327 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 327 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
328 | ++it; | 328 | ++it; |
329 | continue; | 329 | continue; |
330 | } | 330 | } |
331 | 331 | ||
332 | /* | 332 | /* |
333 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 333 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
334 | * | 334 | * |
335 | */ | 335 | */ |
336 | if( fi->isSymLink() ){ | 336 | if( fi->isSymLink() ){ |
337 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 337 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
338 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | 338 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos |
339 | QFileInfo info( file ); | 339 | QFileInfo info( file ); |
340 | if( !info.exists() ){ | 340 | if( !info.exists() ){ |
341 | addSymlink( fi, TRUE ); | 341 | addSymlink( fi, TRUE ); |
342 | break; | 342 | break; |
343 | }else if( info.isDir() ){ | 343 | }else if( info.isDir() ){ |
344 | addDir( fi, TRUE ); | 344 | addDir( fi, TRUE ); |
345 | break; | 345 | break; |
346 | }else if( info.isFile() ){ | 346 | }else if( info.isFile() ){ |
347 | addFile( fi, TRUE ); | 347 | addFile( fi, TRUE ); |
348 | break; | 348 | break; |
349 | }else if( info.isSymLink() ){ | 349 | }else if( info.isSymLink() ){ |
350 | file = info.dirPath(true ) + "/" + info.readLink() ; | 350 | file = info.dirPath(true ) + "/" + info.readLink() ; |
351 | break; | 351 | break; |
352 | }else if( i == 4){ // couldn't resolve symlink add it as symlink | 352 | }else if( i == 4){ // couldn't resolve symlink add it as symlink |
353 | addSymlink( fi ); | 353 | addSymlink( fi ); |
354 | } | 354 | } |
355 | } // off for loop for symlink resolving | 355 | } // off for loop for symlink resolving |
356 | }else if( fi->isDir() ) | 356 | }else if( fi->isDir() ) |
357 | addDir( fi ); | 357 | addDir( fi ); |
358 | else if( fi->isFile() ) | 358 | else if( fi->isFile() ) |
359 | addFile( fi ); | 359 | addFile( fi ); |
360 | 360 | ||
361 | ++it; | 361 | ++it; |
362 | } // of while loop | 362 | } // of while loop |
363 | m_view->sort(); | 363 | m_view->sort(); |
364 | 364 | ||
365 | } | 365 | } |
366 | int OFileViewFileListView::fileCount()const{ | 366 | int OFileViewFileListView::fileCount()const{ |
367 | return m_view->childCount(); | 367 | return m_view->childCount(); |
368 | } | 368 | } |
369 | QString OFileViewFileListView::currentDir()const{ | 369 | QString OFileViewFileListView::currentDir()const{ |
370 | return m_currentDir; | 370 | return m_currentDir; |
371 | } | 371 | } |
372 | OFileSelector* OFileViewFileListView::selector() { | 372 | OFileSelector* OFileViewFileListView::selector() { |
373 | return m_sel; | 373 | return m_sel; |
374 | } | 374 | } |
375 | 375 | ||
376 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { | 376 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { |
377 | if ( e->type() == QEvent::KeyPress ) { | 377 | if ( e->type() == QEvent::KeyPress ) { |
378 | QKeyEvent *k = (QKeyEvent *)e; | 378 | QKeyEvent *k = (QKeyEvent *)e; |
379 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 379 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
380 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 380 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
381 | return true; | 381 | return true; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | return false; | 384 | return false; |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | void OFileViewFileListView::connectSlots() { | 388 | void OFileViewFileListView::connectSlots() { |
389 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 389 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
390 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 390 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
391 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 391 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
392 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); | 392 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
393 | } | 393 | } |
394 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { | 394 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { |
395 | if (!item) | 395 | if (!item) |
396 | return; | 396 | return; |
397 | #if 0 | 397 | #if 0 |
398 | 398 | ||
399 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 399 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
400 | 400 | ||
401 | if (!sel->isDir() ) { | 401 | if (!sel->isDir() ) { |
402 | selector()->m_lneEdit->setText( sel->text(1) ); | 402 | selector()->m_lneEdit->setText( sel->text(1) ); |
403 | // if in fileselector mode we will emit selected | 403 | // if in fileselector mode we will emit selected |
404 | if ( selector()->mode() == OFileSelector::FileSelector ) { | 404 | if ( selector()->mode() == OFileSelector::FileSelector ) { |
405 | qWarning("slot Current Changed"); | 405 | qWarning("slot Current Changed"); |
406 | QStringList str = QStringList::split("->", sel->text(1) ); | 406 | QStringList str = QStringList::split("->", sel->text(1) ); |
407 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 407 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
408 | emit selector()->fileSelected( path ); | 408 | emit selector()->fileSelected( path ); |
409 | DocLnk lnk( path ); | 409 | DocLnk lnk( path ); |
410 | emit selector()->fileSelected( lnk ); | 410 | emit selector()->fileSelected( lnk ); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | #endif | 413 | #endif |
414 | } | 414 | } |
415 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { | 415 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { |
416 | if (!item || ( button != Qt::LeftButton) ) | 416 | if (!item || ( button != Qt::LeftButton) ) |
417 | return; | 417 | return; |
418 | 418 | ||
419 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 419 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
420 | if (!sel->isLocked() ) { | 420 | if (!sel->isLocked() ) { |
421 | QStringList str = QStringList::split("->", sel->text(1) ); | 421 | QStringList str = QStringList::split("->", sel->text(1) ); |
422 | if (sel->isDir() ) { | 422 | if (sel->isDir() ) { |
423 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 423 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
424 | emit selector()->dirSelected( m_currentDir ); | 424 | emit selector()->dirSelected( m_currentDir ); |
425 | reread( m_all ); | 425 | reread( m_all ); |
426 | }else { // file | 426 | }else { // file |
427 | qWarning("slot Clicked"); | 427 | qWarning("slot Clicked"); |
428 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 428 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
429 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 429 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
430 | emit selector()->fileSelected( path ); | 430 | emit selector()->fileSelected( path ); |
431 | DocLnk lnk( path ); | 431 | DocLnk lnk( path ); |
432 | emit selector()->fileSelected( lnk ); | 432 | emit selector()->fileSelected( lnk ); |
433 | } | 433 | } |
434 | } // not locked | 434 | } // not locked |
435 | } | 435 | } |
436 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { | 436 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { |
437 | MimeType type( info->absFilePath() ); | 437 | MimeType type( info->absFilePath() ); |
438 | if (!compliesMime( type.id() ) ) | 438 | if (!compliesMime( type.id() ) ) |
439 | return; | 439 | return; |
440 | 440 | ||
441 | QPixmap pix = type.pixmap(); | 441 | QPixmap pix = type.pixmap(); |
442 | QString dir, name; bool locked; | 442 | QString dir, name; bool locked; |
443 | if ( pix.isNull() ) { | 443 | if ( pix.isNull() ) { |
444 | QWMatrix matrix; | 444 | QWMatrix matrix; |
445 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 445 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
446 | matrix.scale( .4, .4 ); | 446 | matrix.scale( .4, .4 ); |
447 | pix = pixer.xForm( matrix ); | 447 | pix = pixer.xForm( matrix ); |
448 | } | 448 | } |
449 | dir = info->dirPath( true ); | 449 | dir = info->dirPath( true ); |
450 | locked = false; | 450 | locked = false; |
451 | if ( symlink ) | 451 | if ( symlink ) |
452 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 452 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); |
453 | else{ | 453 | else{ |
454 | name = info->fileName(); | 454 | name = info->fileName(); |
455 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 455 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
456 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { | 456 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { |
457 | locked = true; pix = Resource::loadPixmap("locked"); | 457 | locked = true; pix = Resource::loadPixmap("locked"); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | (void)new OFileSelectorItem( m_view, pix, name, | 460 | (void)new OFileSelectorItem( m_view, pix, name, |
461 | info->lastModified().toString(), QString::number( info->size() ), | 461 | info->lastModified().toString(), QString::number( info->size() ), |
462 | dir, locked ); | 462 | dir, locked ); |
463 | } | 463 | } |
464 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { | 464 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { |
465 | bool locked = false; QString name; QPixmap pix; | 465 | bool locked = false; QString name; QPixmap pix; |
466 | 466 | ||
467 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 467 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
468 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { | 468 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { |
469 | locked = true; | 469 | locked = true; |
470 | if ( symlink ) | 470 | if ( symlink ) |
471 | pix = Resource::loadPixmap( "opie/symlink" ); | 471 | pix = Resource::loadPixmap( "opie/symlink" ); |
472 | else | 472 | else |
473 | pix = Resource::loadPixmap( "lockedfolder" ); | 473 | pix = Resource::loadPixmap( "lockedfolder" ); |
474 | }else | 474 | }else |
475 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); | 475 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); |
476 | 476 | ||
477 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | 477 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : |
478 | info->fileName(); | 478 | info->fileName(); |
479 | 479 | ||
480 | (void)new OFileSelectorItem( m_view, pix, name, | 480 | (void)new OFileSelectorItem( m_view, pix, name, |
481 | info->lastModified().toString(), | 481 | info->lastModified().toString(), |
482 | QString::number( info->size() ), | 482 | QString::number( info->size() ), |
483 | info->dirPath( true ), locked, true ); | 483 | info->dirPath( true ), locked, true ); |
484 | 484 | ||
485 | 485 | ||
486 | } | 486 | } |
487 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { | 487 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { |
488 | 488 | ||
489 | } | 489 | } |
490 | void OFileViewFileListView::cdUP() { | 490 | void OFileViewFileListView::cdUP() { |
491 | QDir dir( m_currentDir ); | 491 | QDir dir( m_currentDir ); |
492 | dir.cdUp(); | 492 | dir.cdUp(); |
493 | 493 | ||
494 | if (!dir.exists() ) | 494 | if (!dir.exists() ) |
495 | m_currentDir = "/"; | 495 | m_currentDir = "/"; |
496 | else | 496 | else |
497 | m_currentDir = dir.absPath(); | 497 | m_currentDir = dir.absPath(); |
498 | 498 | ||
499 | emit selector()->dirSelected( m_currentDir ); | 499 | emit selector()->dirSelected( m_currentDir ); |
500 | reread( m_all ); | 500 | reread( m_all ); |
501 | } | 501 | } |
502 | void OFileViewFileListView::cdHome() { | 502 | void OFileViewFileListView::cdHome() { |
503 | m_currentDir = QDir::homeDirPath(); | 503 | m_currentDir = QDir::homeDirPath(); |
504 | emit selector()->dirSelected( m_currentDir ); | 504 | emit selector()->dirSelected( m_currentDir ); |
505 | reread( m_all ); | 505 | reread( m_all ); |
506 | } | 506 | } |
507 | void OFileViewFileListView::cdDoc() { | 507 | void OFileViewFileListView::cdDoc() { |
508 | m_currentDir = QPEApplication::documentDir(); | 508 | m_currentDir = QPEApplication::documentDir(); |
509 | emit selector()->dirSelected( m_currentDir ); | 509 | emit selector()->dirSelected( m_currentDir ); |
510 | reread( m_all ); | 510 | reread( m_all ); |
511 | } | 511 | } |
512 | void OFileViewFileListView::changeDir( const QString& dir ) { | 512 | void OFileViewFileListView::changeDir( const QString& dir ) { |
513 | m_currentDir = dir; | 513 | m_currentDir = dir; |
514 | emit selector()->dirSelected( m_currentDir ); | 514 | emit selector()->dirSelected( m_currentDir ); |
515 | reread( m_all ); | 515 | reread( m_all ); |
516 | } | 516 | } |
517 | void OFileViewFileListView::slotFSActivated( int id ) { | 517 | void OFileViewFileListView::slotFSActivated( int id ) { |
518 | changeDir ( m_dev[m_fsPop->text(id)] ); | 518 | changeDir ( m_dev[m_fsPop->text(id)] ); |
519 | } | 519 | } |
520 | 520 | ||
521 | /* check if the mimetype in mime | 521 | /* check if the mimetype in mime |
522 | * complies with the one which is current | 522 | * complies with the one which is current |
523 | */ | 523 | */ |
524 | /* | 524 | /* |
525 | * We've the mimetype of the file | 525 | * We've the mimetype of the file |
526 | * We need to get the stringlist of the current mimetype | 526 | * We need to get the stringlist of the current mimetype |
527 | * | 527 | * |
528 | * mime = image@slashjpeg | 528 | * mime = image@slashjpeg |
529 | * QStringList = 'image@slash*' | 529 | * QStringList = 'image@slash*' |
530 | * or QStringList = image/jpeg;image/png;application/x-ogg | 530 | * or QStringList = image/jpeg;image/png;application/x-ogg |
531 | * or QStringList = application/x-ogg;image@slash*; | 531 | * or QStringList = application/x-ogg;image@slash*; |
532 | * with all these mime filters it should get acceptes | 532 | * with all these mime filters it should get acceptes |
533 | * to do so we need to look if mime is contained inside | 533 | * to do so we need to look if mime is contained inside |
534 | * the stringlist | 534 | * the stringlist |
535 | * if it's contained return true | 535 | * if it's contained return true |
536 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 536 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
537 | * is contained in the mimefilter and then we will | 537 | * is contained in the mimefilter and then we will |
538 | * look if both are equal until the '/' | 538 | * look if both are equal until the '/' |
539 | */ | 539 | */ |
540 | bool OFileViewFileListView::compliesMime( const QString& str) { | 540 | bool OFileViewFileListView::compliesMime( const QString& str) { |
541 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 541 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
542 | return true; | 542 | return true; |
543 | 543 | ||
544 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { | 544 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { |
545 | QRegExp reg( (*it) ); | 545 | QRegExp reg( (*it) ); |
546 | reg.setWildcard( true ); | 546 | reg.setWildcard( true ); |
547 | if ( str.find( reg ) != -1 ) | 547 | if ( str.find( reg ) != -1 ) |
548 | return true; | 548 | return true; |
549 | 549 | ||
550 | } | 550 | } |
551 | return false; | 551 | return false; |
552 | } | 552 | } |
553 | /* | 553 | /* |
554 | * The listView giving access to the file system! | 554 | * The listView giving access to the file system! |
555 | */ | 555 | */ |
556 | class OFileViewFileSystem : public OFileViewInterface { | 556 | class OFileViewFileSystem : public OFileViewInterface { |
557 | public: | 557 | public: |
558 | OFileViewFileSystem( OFileSelector* ); | 558 | OFileViewFileSystem( OFileSelector* ); |
559 | ~OFileViewFileSystem(); | 559 | ~OFileViewFileSystem(); |
560 | 560 | ||
561 | QString selectedName() const; | 561 | QString selectedName() const; |
562 | QString selectedPath() const; | 562 | QString selectedPath() const; |
563 | 563 | ||
564 | QString directory()const; | 564 | QString directory()const; |
565 | void reread(); | 565 | void reread(); |
566 | int fileCount()const; | 566 | int fileCount()const; |
567 | 567 | ||
568 | QWidget* widget( QWidget* parent ); | 568 | QWidget* widget( QWidget* parent ); |
569 | void activate( const QString& ); | 569 | void activate( const QString& ); |
570 | private: | 570 | private: |
571 | OFileViewFileListView* m_view; | 571 | OFileViewFileListView* m_view; |
572 | bool m_all : 1; | 572 | bool m_all : 1; |
573 | }; | 573 | }; |
574 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 574 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
575 | : OFileViewInterface( sel ) { | 575 | : OFileViewInterface( sel ) { |
576 | m_view = 0; | 576 | m_view = 0; |
577 | m_all = false; | 577 | m_all = false; |
578 | } | 578 | } |
579 | OFileViewFileSystem::~OFileViewFileSystem() { | 579 | OFileViewFileSystem::~OFileViewFileSystem() { |
580 | } | 580 | } |
581 | QString OFileViewFileSystem::selectedName()const{ | 581 | QString OFileViewFileSystem::selectedName()const{ |
582 | if (!m_view ) | 582 | if (!m_view ) |
583 | return QString::null; | 583 | return QString::null; |
584 | 584 | ||
585 | QString cFN=currentFileName(); | 585 | QString cFN=currentFileName(); |
586 | if (cFN.startsWith("/")) return cFN; | 586 | if (cFN.startsWith("/")) return cFN; |
587 | return m_view->currentDir() + "/" + cFN; | 587 | return m_view->currentDir() + "/" + cFN; |
588 | } | 588 | } |
589 | QString OFileViewFileSystem::selectedPath()const{ | 589 | QString OFileViewFileSystem::selectedPath()const{ |
590 | return QString::null; | 590 | return QString::null; |
591 | } | 591 | } |
592 | QString OFileViewFileSystem::directory()const{ | 592 | QString OFileViewFileSystem::directory()const{ |
593 | if (!m_view) | 593 | if (!m_view) |
594 | return QString::null; | 594 | return QString::null; |
595 | 595 | ||
596 | OFileSelectorItem* item = m_view->currentItem(); | 596 | OFileSelectorItem* item = m_view->currentItem(); |
597 | if (!item ) | 597 | if (!item ) |
598 | return QString::null; | 598 | return QString::null; |
599 | 599 | ||
600 | return QDir(item->directory() ).absPath(); | 600 | return QDir(item->directory() ).absPath(); |
601 | } | 601 | } |
602 | void OFileViewFileSystem::reread() { | 602 | void OFileViewFileSystem::reread() { |
603 | if (!m_view) | 603 | if (!m_view) |
604 | return; | 604 | return; |
605 | 605 | ||
606 | m_view->reread( m_all ); | 606 | m_view->reread( m_all ); |
607 | } | 607 | } |
608 | int OFileViewFileSystem::fileCount()const{ | 608 | int OFileViewFileSystem::fileCount()const{ |
609 | if (!m_view ) | 609 | if (!m_view ) |
610 | return -1; | 610 | return -1; |
611 | return m_view->fileCount(); | 611 | return m_view->fileCount(); |
612 | } | 612 | } |
613 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | 613 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { |
614 | if (!m_view ) { | 614 | if (!m_view ) { |
615 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 615 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
616 | } | 616 | } |
617 | return m_view; | 617 | return m_view; |
618 | } | 618 | } |
619 | void OFileViewFileSystem::activate( const QString& str) { | 619 | void OFileViewFileSystem::activate( const QString& str) { |
620 | m_all = (str != QObject::tr("Files") ); | 620 | m_all = (str != QObject::tr("Files") ); |
621 | 621 | ||
622 | 622 | ||
623 | } | 623 | } |
624 | 624 | ||
625 | /* Selector */ | 625 | /* Selector */ |
626 | /** | 626 | /** |
627 | * @short new and complete c'tor | 627 | * @short new and complete c'tor |
628 | * | 628 | * |
629 | * Create a OFileSelector to let the user select a file. It can | 629 | * Create a OFileSelector to let the user select a file. It can |
630 | * either be used to open a file, select a save name in a dir or | 630 | * either be used to open a file, select a save name in a dir or |
631 | * as a dropin for the FileSelector. | 631 | * as a dropin for the FileSelector. |
632 | * | 632 | * |
633 | * <pre> | 633 | * <pre> |
634 | * QMap<QString, QStringList> mimeTypes; | 634 | * QMap<QString, QStringList> mimeTypes; |
635 | * QStringList types; | 635 | * QStringList types; |
636 | * types << "text@slash* "; | 636 | * types << "text@slash* "; |
637 | * types << "audio@slash*"; | 637 | * types << "audio@slash*"; |
638 | * mimeTypes.insert( tr("Audio and Text"), types ); | 638 | * mimeTypes.insert( tr("Audio and Text"), types ); |
639 | * mimeTypes.insert( tr("All"), "*@slash*); | 639 | * mimeTypes.insert( tr("All"), "*@slash*); |
640 | * | 640 | * |
641 | * now you could create your fileselector | 641 | * now you could create your fileselector |
642 | * </pre> | 642 | * </pre> |
643 | * | 643 | * |
644 | * | 644 | * |
645 | * @param parent the parent of this widget | 645 | * @param parent the parent of this widget |
646 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 646 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
647 | * @param sel The selector to be used | 647 | * @param sel The selector to be used |
648 | * @param dirName The name of the dir to start int | 648 | * @param dirName The name of the dir to start int |
649 | * @param fileName The fileName placed in the fileselector lineedit | 649 | * @param fileName The fileName placed in the fileselector lineedit |
650 | * @param mimetypes The MimeType map of used mimetypes | 650 | * @param mimetypes The MimeType map of used mimetypes |
651 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. | 651 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. |
652 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. | 652 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. |
653 | * | 653 | * |
654 | */ | 654 | */ |
655 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 655 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
656 | const QString& dirName, const QString& fileName, | 656 | const QString& dirName, const QString& fileName, |
657 | const MimeTypes& mimetypes, | 657 | const MimeTypes& mimetypes, |
658 | bool showNew, bool showClose) | 658 | bool showNew, bool showClose) |
659 | : QWidget( parent, "OFileSelector" ) | 659 | : QWidget( parent, "OFileSelector" ) |
660 | { | 660 | { |
661 | m_current = 0; | 661 | m_current = 0; |
662 | m_shNew = showNew; | 662 | m_shNew = showNew; |
663 | m_shClose = showClose; | 663 | m_shClose = showClose; |
664 | m_mimeType = mimetypes; | 664 | m_mimeType = mimetypes; |
665 | m_startDir = dirName; | 665 | m_startDir = dirName; |
666 | 666 | ||
667 | m_mode = mode; | 667 | m_mode = mode; |
668 | m_selector = sel; | 668 | m_selector = sel; |
669 | 669 | ||
670 | initUI(); | 670 | initUI(); |
671 | m_lneEdit->setText( fileName ); | 671 | m_lneEdit->setText( fileName ); |
672 | initMime(); | 672 | initMime(); |
673 | initViews(); | 673 | initViews(); |
674 | 674 | ||
675 | QString str; | 675 | QString str; |
676 | switch ( m_selector ) { | 676 | switch ( m_selector ) { |
677 | default: | 677 | default: |
678 | case Normal: | 678 | case Normal: |
679 | str = QObject::tr("Documents"); | 679 | str = QObject::tr("Documents"); |
680 | m_cmbView->setCurrentItem( 0 ); | 680 | m_cmbView->setCurrentItem( 0 ); |
681 | break; | 681 | break; |
682 | case Extended: | 682 | case Extended: |
683 | str = QObject::tr("Files"); | 683 | str = QObject::tr("Files"); |
684 | m_cmbView->setCurrentItem( 1 ); | 684 | m_cmbView->setCurrentItem( 1 ); |
685 | break; | 685 | break; |
686 | case ExtendedAll: | 686 | case ExtendedAll: |
687 | str = QObject::tr("All Files"); | 687 | str = QObject::tr("All Files"); |
688 | m_cmbView->setCurrentItem( 2 ); | 688 | m_cmbView->setCurrentItem( 2 ); |
689 | break; | 689 | break; |
690 | } | 690 | } |
691 | slotViewChange( str ); | 691 | slotViewChange( str ); |
692 | 692 | ||
693 | } | 693 | } |
694 | 694 | ||
695 | /** | 695 | /** |
696 | * This a convience c'tor to just substitute the use of FileSelector | 696 | * This a convience c'tor to just substitute the use of FileSelector |
697 | */ | 697 | */ |
698 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 698 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
699 | bool showNew, bool showClose ) | 699 | bool showNew, bool showClose ) |
700 | : QWidget( parent, name ) | 700 | : QWidget( parent, name ) |
701 | { | 701 | { |
702 | m_current = 0; | 702 | m_current = 0; |
703 | m_shNew = showNew; | 703 | m_shNew = showNew; |
704 | m_shClose = showClose; | 704 | m_shClose = showClose; |
705 | m_startDir = QPEApplication::documentDir(); | 705 | m_startDir = QPEApplication::documentDir(); |
706 | 706 | ||
707 | if (!mimeFilter.isEmpty() ) | 707 | if (!mimeFilter.isEmpty() ) |
708 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 708 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
709 | 709 | ||
710 | m_mode = OFileSelector::FileSelector; | 710 | m_mode = OFileSelector::FileSelector; |
711 | m_selector = OFileSelector::Normal; | 711 | m_selector = OFileSelector::Normal; |
712 | 712 | ||
713 | initUI(); | 713 | initUI(); |
714 | initMime(); | 714 | initMime(); |
715 | initViews(); | 715 | initViews(); |
716 | m_cmbView->setCurrentItem( 0 ); | 716 | m_cmbView->setCurrentItem( 0 ); |
717 | slotViewChange( QObject::tr("Documents") ); | 717 | slotViewChange( QObject::tr("Documents") ); |
718 | } | 718 | } |
719 | /* | 719 | /* |
720 | * INIT UI will set up the basic GUI | 720 | * INIT UI will set up the basic GUI |
721 | * Layout: Simple VBoxLayout | 721 | * Layout: Simple VBoxLayout |
722 | * On top a WidgetStack containing the Views... | 722 | * On top a WidgetStack containing the Views... |
723 | * - List View | 723 | * - List View |
724 | * - Document View | 724 | * - Document View |
725 | * Below we will have a Label + LineEdit | 725 | * Below we will have a Label + LineEdit |
726 | * Below we will have two ComoBoxes one for choosing the view one for | 726 | * Below we will have two ComoBoxes one for choosing the view one for |
727 | * choosing the mimetype | 727 | * choosing the mimetype |
728 | */ | 728 | */ |
729 | void OFileSelector::initUI() { | 729 | void OFileSelector::initUI() { |
730 | QVBoxLayout* lay = new QVBoxLayout( this ); | 730 | QVBoxLayout* lay = new QVBoxLayout( this ); |
731 | 731 | ||
732 | m_stack = new QWidgetStack( this ); | 732 | m_stack = new QWidgetStack( this ); |
733 | lay->addWidget( m_stack, 1000 ); | 733 | lay->addWidget( m_stack, 1000 ); |
734 | 734 | ||
735 | m_nameBox = new QHBox( this ); | 735 | m_nameBox = new QHBox( this ); |
736 | (void)new QLabel( tr("Name:"), m_nameBox ); | 736 | (void)new QLabel( tr("Name:"), m_nameBox ); |
737 | m_lneEdit = new QLineEdit( m_nameBox ); | 737 | m_lneEdit = new QLineEdit( m_nameBox ); |
738 | m_lneEdit ->installEventFilter(this); | 738 | m_lneEdit ->installEventFilter(this); |
739 | lay->addWidget( m_nameBox ); | 739 | lay->addWidget( m_nameBox ); |
740 | 740 | ||
741 | m_cmbBox = new QHBox( this ); | 741 | m_cmbBox = new QHBox( this ); |
742 | m_cmbView = new QComboBox( m_cmbBox ); | 742 | m_cmbView = new QComboBox( m_cmbBox ); |
743 | m_cmbMime = new QComboBox( m_cmbBox ); | 743 | m_cmbMime = new QComboBox( m_cmbBox ); |
744 | lay->addWidget( m_cmbBox ); | 744 | lay->addWidget( m_cmbBox ); |
745 | } | 745 | } |
746 | 746 | ||
747 | /* | 747 | /* |