-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 3 | ||||
-rw-r--r-- | libopie2/opiemm/opieexif.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/filereceive.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/logger.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/script.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 26 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/helpwindow.cpp | 64 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/bmp_slave.cpp | 4 | ||||
-rw-r--r-- | noncore/net/ftplib/ftplib.c | 8 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/stockticker/helpwindow.cpp | 42 | ||||
-rw-r--r-- | noncore/todayplugins/weather/weatherpluginwidget.cpp | 5 | ||||
-rw-r--r-- | noncore/tools/opie-sh/inputdialog.cpp | 20 |
14 files changed, 109 insertions, 92 deletions
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp index 48aa47e..68ea015 100644 --- a/core/multimedia/opieplayer/om3u.cpp +++ b/core/multimedia/opieplayer/om3u.cpp | |||
@@ -26,49 +26,50 @@ | |||
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "om3u.h" | 31 | #include "om3u.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | 35 | ||
36 | 36 | ||
37 | static inline QString fullBaseName ( const QFileInfo &fi ) | 37 | static inline QString fullBaseName ( const QFileInfo &fi ) |
38 | { | 38 | { |
39 | QString str = fi. fileName ( ); | 39 | QString str = fi. fileName ( ); |
40 | return str. left ( str. findRev ( '.' )); | 40 | return str. left ( str. findRev ( '.' )); |
41 | } | 41 | } |
42 | 42 | ||
43 | 43 | ||
44 | //extern PlayListWidget *playList; | 44 | //extern PlayListWidget *playList; |
45 | 45 | ||
46 | Om3u::Om3u( const QString &filePath, int mode) | 46 | Om3u::Om3u( const QString &filePath, int mode) |
47 | : QStringList (){ | 47 | : QStringList (){ |
48 | //odebug << "<<<<<<<new m3u "+filePath << oendl; | 48 | //odebug << "<<<<<<<new m3u "+filePath << oendl; |
49 | f.setName(filePath); | 49 | f.setName(filePath); |
50 | f.open(mode); | 50 | if ( !f.open(mode) ) |
51 | owarn << "Failed to open file " << f.name() << oendl; | ||
51 | } | 52 | } |
52 | 53 | ||
53 | Om3u::~Om3u(){} | 54 | Om3u::~Om3u(){} |
54 | 55 | ||
55 | void Om3u::readM3u() { | 56 | void Om3u::readM3u() { |
56 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; | 57 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; |
57 | QTextStream t(&f); | 58 | QTextStream t(&f); |
58 | t.setEncoding(QTextStream::UnicodeUTF8); | 59 | t.setEncoding(QTextStream::UnicodeUTF8); |
59 | QString s; | 60 | QString s; |
60 | while ( !t.atEnd() ) { | 61 | while ( !t.atEnd() ) { |
61 | s=t.readLine(); | 62 | s=t.readLine(); |
62 | // odebug << s << oendl; | 63 | // odebug << s << oendl; |
63 | if( s.find( "#", 0, TRUE) == -1 ) { | 64 | if( s.find( "#", 0, TRUE) == -1 ) { |
64 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 65 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
65 | s = s.right( s.length() -2 ); | 66 | s = s.right( s.length() -2 ); |
66 | QFileInfo f( s ); | 67 | QFileInfo f( s ); |
67 | QString name = fullBaseName ( f ); | 68 | QString name = fullBaseName ( f ); |
68 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 69 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
69 | s=s.replace( QRegExp( "\\" ), "/" ); | 70 | s=s.replace( QRegExp( "\\" ), "/" ); |
70 | append(s); | 71 | append(s); |
71 | // odebug << s << oendl; | 72 | // odebug << s << oendl; |
72 | } else { // is url | 73 | } else { // is url |
73 | s.replace( QRegExp( "%20" )," " ); | 74 | s.replace( QRegExp( "%20" )," " ); |
74 | QString name; | 75 | QString name; |
diff --git a/libopie2/opiemm/opieexif.cpp b/libopie2/opiemm/opieexif.cpp index de49937..653216c 100644 --- a/libopie2/opiemm/opieexif.cpp +++ b/libopie2/opiemm/opieexif.cpp | |||
@@ -184,49 +184,49 @@ int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode) | |||
184 | } | 184 | } |
185 | 185 | ||
186 | Sections[SectionsRead].Size = itemlen; | 186 | Sections[SectionsRead].Size = itemlen; |
187 | 187 | ||
188 | Data = (uchar *)malloc(itemlen+1); // Add 1 to allow sticking a 0 at the end. | 188 | Data = (uchar *)malloc(itemlen+1); // Add 1 to allow sticking a 0 at the end. |
189 | Sections[SectionsRead].Data = Data; | 189 | Sections[SectionsRead].Data = Data; |
190 | 190 | ||
191 | // Store first two pre-read bytes. | 191 | // Store first two pre-read bytes. |
192 | Data[0] = (uchar)lh; | 192 | Data[0] = (uchar)lh; |
193 | Data[1] = (uchar)ll; | 193 | Data[1] = (uchar)ll; |
194 | 194 | ||
195 | got = infile.readBlock((char*)Data+2, itemlen-2); // Read the whole section. | 195 | got = infile.readBlock((char*)Data+2, itemlen-2); // Read the whole section. |
196 | if (( unsigned ) got != itemlen-2){ | 196 | if (( unsigned ) got != itemlen-2){ |
197 | return false; | 197 | return false; |
198 | } | 198 | } |
199 | SectionsRead++; | 199 | SectionsRead++; |
200 | 200 | ||
201 | switch(marker){ | 201 | switch(marker){ |
202 | 202 | ||
203 | case M_SOS: // stop before hitting compressed data | 203 | case M_SOS: // stop before hitting compressed data |
204 | // If reading entire image is requested, read the rest of the data. | 204 | // If reading entire image is requested, read the rest of the data. |
205 | if (ReadMode & READ_IMAGE){ | 205 | if (ReadMode & READ_IMAGE){ |
206 | unsigned long size; | 206 | unsigned long size; |
207 | 207 | ||
208 | size = QMAX( 0ul, infile.size()-infile.at() ); | 208 | size = infile.size()-infile.at(); |
209 | Data = (uchar *)malloc(size); | 209 | Data = (uchar *)malloc(size); |
210 | if (Data == NULL){ | 210 | if (Data == NULL){ |
211 | return false; | 211 | return false; |
212 | } | 212 | } |
213 | 213 | ||
214 | got = infile.readBlock((char*)Data, size); | 214 | got = infile.readBlock((char*)Data, size); |
215 | if (( unsigned ) got != size){ | 215 | if (( unsigned ) got != size){ |
216 | return false; | 216 | return false; |
217 | } | 217 | } |
218 | 218 | ||
219 | Sections[SectionsRead].Data = Data; | 219 | Sections[SectionsRead].Data = Data; |
220 | Sections[SectionsRead].Size = size; | 220 | Sections[SectionsRead].Size = size; |
221 | Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER; | 221 | Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER; |
222 | SectionsRead ++; | 222 | SectionsRead ++; |
223 | //HaveAll = 1; | 223 | //HaveAll = 1; |
224 | } | 224 | } |
225 | return true; | 225 | return true; |
226 | 226 | ||
227 | case M_EOI: // in case it's a tables-only JPEG stream | 227 | case M_EOI: // in case it's a tables-only JPEG stream |
228 | owarn << "No image in jpeg!" << oendl; | 228 | owarn << "No image in jpeg!" << oendl; |
229 | return false; | 229 | return false; |
230 | 230 | ||
231 | case M_COM: // Comment section | 231 | case M_COM: // Comment section |
232 | // pieczy 2002-02-12 | 232 | // pieczy 2002-02-12 |
@@ -788,49 +788,53 @@ ExifData::ExifData() | |||
788 | FocalLength = 0; | 788 | FocalLength = 0; |
789 | ExposureTime = 0; | 789 | ExposureTime = 0; |
790 | ApertureFNumber = 0; | 790 | ApertureFNumber = 0; |
791 | Distance = 0; | 791 | Distance = 0; |
792 | CCDWidth = 0; | 792 | CCDWidth = 0; |
793 | ExposureBias = 0; | 793 | ExposureBias = 0; |
794 | ExposureProgram = 0; | 794 | ExposureProgram = 0; |
795 | ISOequivalent = 0; | 795 | ISOequivalent = 0; |
796 | CompressionLevel = 0; | 796 | CompressionLevel = 0; |
797 | MotorolaOrder = 0; | 797 | MotorolaOrder = 0; |
798 | } | 798 | } |
799 | 799 | ||
800 | ExifData::~ExifData() | 800 | ExifData::~ExifData() |
801 | { | 801 | { |
802 | } | 802 | } |
803 | 803 | ||
804 | //-------------------------------------------------------------------------- | 804 | //-------------------------------------------------------------------------- |
805 | // process a EXIF jpeg file | 805 | // process a EXIF jpeg file |
806 | //-------------------------------------------------------------------------- | 806 | //-------------------------------------------------------------------------- |
807 | bool ExifData::scan(const QString & path) | 807 | bool ExifData::scan(const QString & path) |
808 | { | 808 | { |
809 | int ret; | 809 | int ret; |
810 | 810 | ||
811 | QFile f(path); | 811 | QFile f(path); |
812 | f.open(IO_ReadOnly); | 812 | if ( !f.open(IO_ReadOnly) ) { |
813 | owarn << "Unable to open file " << f.name() << " readonly" << oendl; | ||
814 | DiscardData(); | ||
815 | return false; | ||
816 | } | ||
813 | 817 | ||
814 | // Scan the JPEG headers. | 818 | // Scan the JPEG headers. |
815 | ret = ReadJpegSections(f, READ_EXIF); | 819 | ret = ReadJpegSections(f, READ_EXIF); |
816 | 820 | ||
817 | if (ret == false){ | 821 | if (ret == false){ |
818 | owarn << "Not JPEG file!" << oendl; | 822 | owarn << "Not JPEG file!" << oendl; |
819 | DiscardData(); | 823 | DiscardData(); |
820 | f.close(); | 824 | f.close(); |
821 | return false; | 825 | return false; |
822 | } | 826 | } |
823 | f.close(); | 827 | f.close(); |
824 | DiscardData(); | 828 | DiscardData(); |
825 | 829 | ||
826 | //now make the strings clean, | 830 | //now make the strings clean, |
827 | // for exmaple my Casio is a "QV-4000 " | 831 | // for exmaple my Casio is a "QV-4000 " |
828 | CameraMake = CameraMake.stripWhiteSpace(); | 832 | CameraMake = CameraMake.stripWhiteSpace(); |
829 | CameraModel = CameraModel.stripWhiteSpace(); | 833 | CameraModel = CameraModel.stripWhiteSpace(); |
830 | UserComment = UserComment.stripWhiteSpace(); | 834 | UserComment = UserComment.stripWhiteSpace(); |
831 | Comment = Comment.stripWhiteSpace(); | 835 | Comment = Comment.stripWhiteSpace(); |
832 | return true; | 836 | return true; |
833 | } | 837 | } |
834 | 838 | ||
835 | //-------------------------------------------------------------------------- | 839 | //-------------------------------------------------------------------------- |
836 | // Does the embedded thumbnail match the jpeg image? | 840 | // Does the embedded thumbnail match the jpeg image? |
diff --git a/noncore/apps/opie-console/filereceive.cpp b/noncore/apps/opie-console/filereceive.cpp index 452be60..41e6888 100644 --- a/noncore/apps/opie-console/filereceive.cpp +++ b/noncore/apps/opie-console/filereceive.cpp | |||
@@ -1,29 +1,30 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | #include <signal.h> | 3 | #include <signal.h> |
4 | #include <errno.h> | 4 | #include <errno.h> |
5 | 5 | ||
6 | #include <opie2/odebug.h> | ||
6 | #include <qsocketnotifier.h> | 7 | #include <qsocketnotifier.h> |
7 | 8 | ||
8 | #include "io_layer.h" | 9 | #include "io_layer.h" |
9 | #include "procctl.h" | 10 | #include "procctl.h" |
10 | #include "filereceive.h" | 11 | #include "filereceive.h" |
11 | 12 | ||
12 | FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir ) | 13 | FileReceive::FileReceive( Type t, IOLayer* lay, const QString& dir ) |
13 | : ReceiveLayer(lay, dir ), m_type( t ) | 14 | : ReceiveLayer(lay, dir ), m_type( t ) |
14 | { | 15 | { |
15 | m_fd = -1; | 16 | m_fd = -1; |
16 | m_not = 0l; | 17 | m_not = 0l; |
17 | m_proc = 0l; | 18 | m_proc = 0l; |
18 | } | 19 | } |
19 | FileReceive::~FileReceive() { | 20 | FileReceive::~FileReceive() { |
20 | } | 21 | } |
21 | void FileReceive::receive() { | 22 | void FileReceive::receive() { |
22 | receive( currentDir() ); | 23 | receive( currentDir() ); |
23 | } | 24 | } |
24 | void FileReceive::receive( const QString& dir ) { | 25 | void FileReceive::receive( const QString& dir ) { |
25 | m_prog = -1; | 26 | m_prog = -1; |
26 | m_fd = layer()->rawIO(); | 27 | m_fd = layer()->rawIO(); |
27 | m_curDir = dir; | 28 | m_curDir = dir; |
28 | 29 | ||
29 | if (pipe( m_comm ) < 0 ) | 30 | if (pipe( m_comm ) < 0 ) |
@@ -127,36 +128,37 @@ void FileReceive::setupChild() { | |||
127 | 128 | ||
128 | if (m_comm[0] ) | 129 | if (m_comm[0] ) |
129 | close( m_comm[0] ); | 130 | close( m_comm[0] ); |
130 | /* | 131 | /* |
131 | * now set the communication | 132 | * now set the communication |
132 | * m_fd STDIN_FILENO | 133 | * m_fd STDIN_FILENO |
133 | * STDOUT_FILENO | 134 | * STDOUT_FILENO |
134 | * STDERR_FILENO | 135 | * STDERR_FILENO |
135 | */ | 136 | */ |
136 | dup2( m_fd, STDIN_FILENO ); | 137 | dup2( m_fd, STDIN_FILENO ); |
137 | dup2( m_fd, STDOUT_FILENO ); | 138 | dup2( m_fd, STDOUT_FILENO ); |
138 | dup2( m_comm[1], STDERR_FILENO ); | 139 | dup2( m_comm[1], STDERR_FILENO ); |
139 | } | 140 | } |
140 | void FileReceive::slotRead() { | 141 | void FileReceive::slotRead() { |
141 | QByteArray ar(4096); | 142 | QByteArray ar(4096); |
142 | int len = read(m_comm[0], ar.data(), 4096 ); | 143 | int len = read(m_comm[0], ar.data(), 4096 ); |
143 | for (int i = 0; i < len; i++ ) { | 144 | for (int i = 0; i < len; i++ ) { |
144 | // printf("%c", ar[i] ); | 145 | // printf("%c", ar[i] ); |
145 | } | 146 | } |
146 | ar.resize( len ); | 147 | ar.resize( len ); |
147 | QString str( ar ); | 148 | QString str( ar ); |
148 | } | 149 | } |
149 | void FileReceive::slotExec() { | 150 | void FileReceive::slotExec() { |
150 | char buf[2]; | 151 | char buf[2]; |
151 | ::read(m_term[0], buf, 1 ); | 152 | if (::read(m_term[0], buf, 1 ) == -1) |
153 | owarn << "read of m_term[0] failed" << oendl; | ||
152 | delete m_proc; | 154 | delete m_proc; |
153 | delete m_not; | 155 | delete m_not; |
154 | m_not = m_proc = 0l; | 156 | m_not = m_proc = 0l; |
155 | close( m_term[0] ); | 157 | close( m_term[0] ); |
156 | close( m_term[1] ); | 158 | close( m_term[1] ); |
157 | close( m_comm[0] ); | 159 | close( m_comm[0] ); |
158 | close( m_comm[1] ); | 160 | close( m_comm[1] ); |
159 | layer()->closeRawIO(m_fd); | 161 | layer()->closeRawIO(m_fd); |
160 | emit received(QString::null); | 162 | emit received(QString::null); |
161 | 163 | ||
162 | } | 164 | } |
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index 7eebc65..6e2d2d5 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp | |||
@@ -1,30 +1,31 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <fcntl.h> | 4 | #include <fcntl.h> |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | ||
7 | #include <qsocketnotifier.h> | 8 | #include <qsocketnotifier.h> |
8 | 9 | ||
9 | #include "procctl.h" | 10 | #include "procctl.h" |
10 | #include "filetransfer.h" | 11 | #include "filetransfer.h" |
11 | 12 | ||
12 | 13 | ||
13 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) | 14 | FileTransfer::FileTransfer( Type t, IOLayer* lay ) |
14 | : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { | 15 | : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { |
15 | signal(SIGPIPE, SIG_IGN ); | 16 | signal(SIGPIPE, SIG_IGN ); |
16 | 17 | ||
17 | m_pid = 0; | 18 | m_pid = 0; |
18 | m_not = 0l; | 19 | m_not = 0l; |
19 | m_proc = 0l; | 20 | m_proc = 0l; |
20 | } | 21 | } |
21 | FileTransfer::~FileTransfer() { | 22 | FileTransfer::~FileTransfer() { |
22 | } | 23 | } |
23 | 24 | ||
24 | /** | 25 | /** |
25 | * now we will send the file. | 26 | * now we will send the file. |
26 | * | 27 | * |
27 | * we request an fd. The IOLayer should be closed | 28 | * we request an fd. The IOLayer should be closed |
28 | * then we will setup a pipe for progress communication | 29 | * then we will setup a pipe for progress communication |
29 | * then we will dup2 the m_fd in the forked process | 30 | * then we will dup2 the m_fd in the forked process |
30 | * to do direct IO from and to the fd | 31 | * to do direct IO from and to the fd |
@@ -213,36 +214,37 @@ void FileTransfer::slotProgress( const QStringList& list ) { | |||
213 | int prog = pro * 100; | 214 | int prog = pro * 100; |
214 | 215 | ||
215 | // speed | 216 | // speed |
216 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); | 217 | progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); |
217 | bps = progi[1].toInt(); | 218 | bps = progi[1].toInt(); |
218 | 219 | ||
219 | // time | 220 | // time |
220 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); | 221 | progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); |
221 | min = progi[0].toInt(); | 222 | min = progi[0].toInt(); |
222 | sec = progi[1].toInt(); | 223 | sec = progi[1].toInt(); |
223 | 224 | ||
224 | 225 | ||
225 | if ( prog > m_prog ) { | 226 | if ( prog > m_prog ) { |
226 | m_prog = prog; | 227 | m_prog = prog; |
227 | emit progress(m_file, m_prog, bps, -1, min , sec ); | 228 | emit progress(m_file, m_prog, bps, -1, min , sec ); |
228 | } | 229 | } |
229 | 230 | ||
230 | } | 231 | } |
231 | void FileTransfer::cancel() { | 232 | void FileTransfer::cancel() { |
232 | if(m_pid > 0) ::kill(m_pid,9 ); | 233 | if(m_pid > 0) ::kill(m_pid,9 ); |
233 | 234 | ||
234 | } | 235 | } |
235 | void FileTransfer::slotExec() { | 236 | void FileTransfer::slotExec() { |
236 | char buf[2]; | 237 | char buf[2]; |
237 | ::read(m_term[0], buf, 1 ); | 238 | if (::read(m_term[0], buf, 1 ) == -1) |
239 | owarn << "read of m_term[0] failed" << oendl; | ||
238 | delete m_proc; | 240 | delete m_proc; |
239 | delete m_not; | 241 | delete m_not; |
240 | m_proc = m_not = 0l; | 242 | m_proc = m_not = 0l; |
241 | close( m_term[0] ); | 243 | close( m_term[0] ); |
242 | close( m_term[1] ); | 244 | close( m_term[1] ); |
243 | close( m_comm[0] ); | 245 | close( m_comm[0] ); |
244 | close( m_comm[1] ); | 246 | close( m_comm[1] ); |
245 | layer()->closeRawIO( m_fd ); | 247 | layer()->closeRawIO( m_fd ); |
246 | emit sent(); | 248 | emit sent(); |
247 | m_pid = 0; | 249 | m_pid = 0; |
248 | } | 250 | } |
diff --git a/noncore/apps/opie-console/logger.cpp b/noncore/apps/opie-console/logger.cpp index 6620faf..0fdeca0 100644 --- a/noncore/apps/opie-console/logger.cpp +++ b/noncore/apps/opie-console/logger.cpp | |||
@@ -1,20 +1,22 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include <opie2/odebug.h> | ||
3 | 4 | ||
4 | #include "logger.h" | 5 | #include "logger.h" |
5 | 6 | ||
6 | 7 | ||
7 | Logger::Logger() {} | 8 | Logger::Logger() {} |
8 | 9 | ||
9 | Logger::Logger(const QString fileName) { | 10 | Logger::Logger(const QString fileName) { |
10 | m_file.setName(fileName); | 11 | m_file.setName(fileName); |
11 | m_file.open(IO_ReadWrite); | 12 | if ( !m_file.open(IO_ReadWrite) ) |
13 | owarn << "failed to open " << m_file.name() << oendl; | ||
12 | } | 14 | } |
13 | 15 | ||
14 | Logger::~Logger() { | 16 | Logger::~Logger() { |
15 | m_file.close(); | 17 | m_file.close(); |
16 | } | 18 | } |
17 | 19 | ||
18 | void Logger::append(QByteArray ar) { | 20 | void Logger::append(QByteArray ar) { |
19 | m_file.writeBlock(ar); | 21 | m_file.writeBlock(ar); |
20 | } | 22 | } |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 18c0434..aba7244 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -803,32 +803,33 @@ void MainWindow::slotSaveLog() { | |||
803 | 803 | ||
804 | m_recordLog->setText( tr("Stop log") ); | 804 | m_recordLog->setText( tr("Stop log") ); |
805 | m_recordingLog = true; | 805 | m_recordingLog = true; |
806 | currentSession()->emulationHandler()->startLogging(m_logName); | 806 | currentSession()->emulationHandler()->startLogging(m_logName); |
807 | } | 807 | } |
808 | } | 808 | } |
809 | 809 | ||
810 | void MainWindow::slotSaveHistory() { | 810 | void MainWindow::slotSaveHistory() { |
811 | QMap<QString, QStringList> map; | 811 | QMap<QString, QStringList> map; |
812 | QStringList text; | 812 | QStringList text; |
813 | text << "text/plain"; | 813 | text << "text/plain"; |
814 | map.insert(tr("History"), text ); | 814 | map.insert(tr("History"), text ); |
815 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 815 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
816 | if (filename.isEmpty() ) return; | 816 | if (filename.isEmpty() ) return; |
817 | 817 | ||
818 | QFileInfo info(filename); | 818 | QFileInfo info(filename); |
819 | 819 | ||
820 | DocLnk nf; | 820 | DocLnk nf; |
821 | nf.setType("text/plain"); | 821 | nf.setType("text/plain"); |
822 | nf.setFile(filename); | 822 | nf.setFile(filename); |
823 | nf.setName(info.fileName()); | 823 | nf.setName(info.fileName()); |
824 | 824 | ||
825 | 825 | ||
826 | QFile file(filename); | 826 | QFile file(filename); |
827 | file.open(IO_WriteOnly ); | 827 | if ( !file.open(IO_WriteOnly ) ) return; |
828 | |||
828 | QTextStream str(&file ); | 829 | QTextStream str(&file ); |
829 | if ( currentSession() ) | 830 | if ( currentSession() ) |
830 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 831 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
831 | 832 | ||
832 | file.close(); | 833 | file.close(); |
833 | nf.writeLink(); | 834 | nf.writeLink(); |
834 | } | 835 | } |
diff --git a/noncore/apps/opie-console/script.cpp b/noncore/apps/opie-console/script.cpp index faea412..8d35776 100644 --- a/noncore/apps/opie-console/script.cpp +++ b/noncore/apps/opie-console/script.cpp | |||
@@ -1,29 +1,31 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include "script.h" | 2 | #include "script.h" |
3 | 3 | ||
4 | Script::Script() { | 4 | Script::Script() { |
5 | } | 5 | } |
6 | 6 | ||
7 | Script::Script(const QString fileName) { | 7 | Script::Script(const QString fileName) { |
8 | QFile file(fileName); | 8 | QFile file(fileName); |
9 | file.open(IO_ReadOnly ); | 9 | if ( !file.open(IO_ReadOnly ) ) |
10 | return; | ||
10 | m_script = file.readAll(); | 11 | m_script = file.readAll(); |
11 | } | 12 | } |
12 | 13 | ||
13 | void Script::saveTo(const QString fileName) const { | 14 | void Script::saveTo(const QString fileName) const { |
14 | QFile file(fileName); | 15 | QFile file(fileName); |
15 | file.open(IO_WriteOnly); | 16 | if ( !file.open(IO_WriteOnly) ) |
17 | return; | ||
16 | file.writeBlock(m_script); | 18 | file.writeBlock(m_script); |
17 | file.close(); | 19 | file.close(); |
18 | } | 20 | } |
19 | 21 | ||
20 | 22 | ||
21 | void Script::append(const QByteArray &data) { | 23 | void Script::append(const QByteArray &data) { |
22 | int size = m_script.size(); | 24 | int size = m_script.size(); |
23 | m_script.resize(size + data.size()); | 25 | m_script.resize(size + data.size()); |
24 | memcpy(m_script.data() + size, data.data(), data.size()); | 26 | memcpy(m_script.data() + size, data.data(), data.size()); |
25 | } | 27 | } |
26 | 28 | ||
27 | QByteArray Script::script() const { | 29 | QByteArray Script::script() const { |
28 | return m_script; | 30 | return m_script; |
29 | } | 31 | } |
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index 733db17..8b02f9f 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -824,64 +824,58 @@ bool Gutenbrowser::load( const char *fileName) { | |||
824 | << ", pageSize " << Lview->PageSize() << oendl; | 824 | << ", pageSize " << Lview->PageSize() << oendl; |
825 | 825 | ||
826 | Lview->setMaxLines(Lview->PageSize()*2); | 826 | Lview->setMaxLines(Lview->PageSize()*2); |
827 | // odebug << "Gulped " << currentLine << "" << oendl; | 827 | // odebug << "Gulped " << currentLine << "" << oendl; |
828 | setCaption(title); | 828 | setCaption(title); |
829 | Lview->setAutoUpdate( TRUE); | 829 | Lview->setAutoUpdate( TRUE); |
830 | 830 | ||
831 | // Lview->setCursorPosition(0,0,FALSE); | 831 | // Lview->setCursorPosition(0,0,FALSE); |
832 | 832 | ||
833 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; | 833 | // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; |
834 | //odebug << "number of pages " << pages << "" << oendl; | 834 | //odebug << "number of pages " << pages << "" << oendl; |
835 | 835 | ||
836 | loadCheck = true; | 836 | loadCheck = true; |
837 | enableButtons(true); | 837 | enableButtons(true); |
838 | if( donateMenu->count() == 3) { | 838 | if( donateMenu->count() == 3) { |
839 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); | 839 | donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); |
840 | } | 840 | } |
841 | Lview->setFocus(); | 841 | Lview->setFocus(); |
842 | 842 | ||
843 | // QCopEnvelope("QPE/System", "notBusy()" ); | 843 | // QCopEnvelope("QPE/System", "notBusy()" ); |
844 | return true; | 844 | return true; |
845 | } // end load | 845 | } // end load |
846 | 846 | ||
847 | void Gutenbrowser::Search() { | 847 | void Gutenbrowser::Search() { |
848 | 848 | odebug << "Starting search dialog" << oendl; | |
849 | // if( searchDlg->isHidden()) | 849 | searchDlg = new SearchDialog( this, "Etext Search", true); |
850 | { | 850 | searchDlg->setCaption( tr( "Etext Search" )); |
851 | odebug << "Starting search dialog" << oendl; | 851 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); |
852 | searchDlg = new SearchDialog( this, "Etext Search", true); | 852 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); |
853 | searchDlg->setCaption( tr( "Etext Search" )); | 853 | |
854 | // searchDlg->setLabel( "- searches etext"); | 854 | QString resultString; |
855 | connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); | 855 | QString string = searchDlg->searchString; |
856 | connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); | 856 | Lview->deselect(); |
857 | 857 | searchDlg->show(); | |
858 | QString resultString; | ||
859 | QString string = searchDlg->searchString; | ||
860 | Lview->deselect(); | ||
861 | searchDlg->show(); | ||
862 | searchDlg->result(); | ||
863 | } | ||
864 | } | 858 | } |
865 | 859 | ||
866 | void Gutenbrowser::search_slot( ) { | 860 | void Gutenbrowser::search_slot( ) { |
867 | int line, col; | 861 | int line, col; |
868 | if (!searchDlg /*&& !loadCheck */) | 862 | if (!searchDlg /*&& !loadCheck */) |
869 | return; | 863 | return; |
870 | 864 | ||
871 | Lview->getCursorPosition(&line,&col); | 865 | Lview->getCursorPosition(&line,&col); |
872 | QString to_find_string=searchDlg->get_text(); | 866 | QString to_find_string=searchDlg->get_text(); |
873 | 867 | ||
874 | // searchDlg->get_direction();// is true if searching backward | 868 | // searchDlg->get_direction();// is true if searching backward |
875 | if ( last_search != 0 && searchDlg->get_direction() ){ | 869 | if ( last_search != 0 && searchDlg->get_direction() ){ |
876 | col = col - pattern.length() - 1 ; | 870 | col = col - pattern.length() - 1 ; |
877 | } | 871 | } |
878 | again: | 872 | again: |
879 | int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); | 873 | int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); |
880 | if(result == 0){ | 874 | if(result == 0){ |
881 | if(!searchDlg->get_direction()){ // forward search | 875 | if(!searchDlg->get_direction()){ // forward search |
882 | int query = QMessageBox::information( searchDlg, "Find", | 876 | int query = QMessageBox::information( searchDlg, "Find", |
883 | "End of document reached.\nContinue from the beginning?", | 877 | "End of document reached.\nContinue from the beginning?", |
884 | "Yes", "No", "", 0,1); | 878 | "Yes", "No", "", 0,1); |
885 | if (query == 0){ | 879 | if (query == 0){ |
886 | line = 0; | 880 | line = 0; |
887 | col = 0; | 881 | col = 0; |
diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.cpp b/noncore/apps/opie-gutenbrowser/helpwindow.cpp index 4bdac02..f444a2e 100644 --- a/noncore/apps/opie-gutenbrowser/helpwindow.cpp +++ b/noncore/apps/opie-gutenbrowser/helpwindow.cpp | |||
@@ -172,78 +172,71 @@ void HelpWindow::textChanged() | |||
172 | if ( !selectedURL.isEmpty() && pathCombo ) { | 172 | if ( !selectedURL.isEmpty() && pathCombo ) { |
173 | bool exists = FALSE; | 173 | bool exists = FALSE; |
174 | int i; | 174 | int i; |
175 | for ( i = 0; i < pathCombo->count(); ++i ) { | 175 | for ( i = 0; i < pathCombo->count(); ++i ) { |
176 | if ( pathCombo->text( i ) == selectedURL ) { | 176 | if ( pathCombo->text( i ) == selectedURL ) { |
177 | exists = TRUE; | 177 | exists = TRUE; |
178 | break; | 178 | break; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | if ( !exists ) { | 181 | if ( !exists ) { |
182 | pathCombo->insertItem( selectedURL, 0 ); | 182 | pathCombo->insertItem( selectedURL, 0 ); |
183 | pathCombo->setCurrentItem( 0 ); | 183 | pathCombo->setCurrentItem( 0 ); |
184 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 184 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
185 | } else | 185 | } else |
186 | pathCombo->setCurrentItem( i ); | 186 | pathCombo->setCurrentItem( i ); |
187 | selectedURL = QString::null; | 187 | selectedURL = QString::null; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | HelpWindow::~HelpWindow() | 191 | HelpWindow::~HelpWindow() |
192 | { | 192 | { |
193 | history.clear(); | 193 | history.clear(); |
194 | QMap<int, QString>::Iterator it = mHistory.begin(); | 194 | QMap<int, QString>::Iterator it = mHistory.begin(); |
195 | for ( ; it != mHistory.end(); ++it ) | 195 | for ( ; it != mHistory.end(); ++it ) |
196 | history.append( *it ); | 196 | history.append( *it ); |
197 | 197 | ||
198 | QFile f( QDir::currentDirPath() + "/.history" ); | 198 | QFile f( QDir::currentDirPath() + "/.history" ); |
199 | f.open( IO_WriteOnly ); | 199 | if ( f.open( IO_WriteOnly ) ) { |
200 | QDataStream s( &f ); | 200 | QDataStream s( &f ); |
201 | s << history; | 201 | s << history; |
202 | f.close(); | 202 | f.close(); |
203 | } | ||
203 | 204 | ||
204 | bookmarks.clear(); | 205 | bookmarks.clear(); |
205 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 206 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
206 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 207 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
207 | bookmarks.append( *it2 ); | 208 | bookmarks.append( *it2 ); |
208 | 209 | ||
209 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 210 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
210 | f2.open( IO_WriteOnly ); | 211 | if ( !f2.open( IO_WriteOnly ) ) |
212 | return; | ||
213 | |||
211 | QDataStream s2( &f2 ); | 214 | QDataStream s2( &f2 ); |
212 | s2 << bookmarks; | 215 | s2 << bookmarks; |
213 | f2.close(); | 216 | f2.close(); |
214 | } | 217 | } |
215 | 218 | ||
216 | // void HelpWindow::about() | ||
217 | // { | ||
218 | // QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" ); | ||
219 | // } | ||
220 | |||
221 | // void HelpWindow::aboutQt() | ||
222 | // { | ||
223 | // QMessageBox::aboutQt( this, "QBrowser" ); | ||
224 | // } | ||
225 | |||
226 | void HelpWindow::openFile() | 219 | void HelpWindow::openFile() |
227 | { | 220 | { |
228 | #ifndef QT_NO_FILEDIALOG | 221 | #ifndef QT_NO_FILEDIALOG |
229 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); | 222 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); |
230 | if ( !fn.isEmpty() ) | 223 | if ( !fn.isEmpty() ) |
231 | browser->setSource( fn ); | 224 | browser->setSource( fn ); |
232 | #endif | 225 | #endif |
233 | } | 226 | } |
234 | 227 | ||
235 | void HelpWindow::newWindow() | 228 | void HelpWindow::newWindow() |
236 | { | 229 | { |
237 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 230 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
238 | } | 231 | } |
239 | 232 | ||
240 | void HelpWindow::print() | 233 | void HelpWindow::print() |
241 | { | 234 | { |
242 | #ifndef QT_NO_PRINTER | 235 | #ifndef QT_NO_PRINTER |
243 | QPrinter printer; | 236 | QPrinter printer; |
244 | printer.setFullPage(TRUE); | 237 | printer.setFullPage(TRUE); |
245 | if ( printer.setup() ) { | 238 | if ( printer.setup() ) { |
246 | QPainter p( &printer ); | 239 | QPainter p( &printer ); |
247 | QPaintDeviceMetrics metrics(p.device()); | 240 | QPaintDeviceMetrics metrics(p.device()); |
248 | int dpix = metrics.logicalDpiX(); | 241 | int dpix = metrics.logicalDpiX(); |
249 | int dpiy = metrics.logicalDpiY(); | 242 | int dpiy = metrics.logicalDpiY(); |
@@ -271,63 +264,68 @@ void HelpWindow::print() | |||
271 | printer.newPage(); | 264 | printer.newPage(); |
272 | page++; | 265 | page++; |
273 | } while (TRUE); | 266 | } while (TRUE); |
274 | } | 267 | } |
275 | #endif | 268 | #endif |
276 | } | 269 | } |
277 | 270 | ||
278 | void HelpWindow::pathSelected( const QString &_path ) | 271 | void HelpWindow::pathSelected( const QString &_path ) |
279 | { | 272 | { |
280 | browser->setSource( _path ); | 273 | browser->setSource( _path ); |
281 | QMap<int, QString>::Iterator it = mHistory.begin(); | 274 | QMap<int, QString>::Iterator it = mHistory.begin(); |
282 | bool exists = FALSE; | 275 | bool exists = FALSE; |
283 | for ( ; it != mHistory.end(); ++it ) { | 276 | for ( ; it != mHistory.end(); ++it ) { |
284 | if ( *it == _path ) { | 277 | if ( *it == _path ) { |
285 | exists = TRUE; | 278 | exists = TRUE; |
286 | break; | 279 | break; |
287 | } | 280 | } |
288 | } | 281 | } |
289 | if ( !exists ) | 282 | if ( !exists ) |
290 | mHistory[ hist->insertItem( _path ) ] = _path; | 283 | mHistory[ hist->insertItem( _path ) ] = _path; |
291 | } | 284 | } |
292 | 285 | ||
293 | void HelpWindow::readHistory() | 286 | void HelpWindow::readHistory() |
294 | { | 287 | { |
295 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 288 | if ( !QFile::exists( QDir::currentDirPath() + "/.history" ) ) |
296 | QFile f( QDir::currentDirPath() + "/.history" ); | 289 | return; |
297 | f.open( IO_ReadOnly ); | 290 | |
298 | QDataStream s( &f ); | 291 | QFile f( QDir::currentDirPath() + "/.history" ); |
299 | s >> history; | 292 | if ( !f.open( IO_ReadOnly ) ) |
300 | f.close(); | 293 | return; |
301 | while ( history.count() > 20 ) | 294 | |
302 | history.remove( history.begin() ); | 295 | QDataStream s( &f ); |
303 | } | 296 | s >> history; |
297 | f.close(); | ||
298 | while ( history.count() > 20 ) | ||
299 | history.remove( history.begin() ); | ||
304 | } | 300 | } |
305 | 301 | ||
306 | void HelpWindow::readBookmarks() | 302 | void HelpWindow::readBookmarks() |
307 | { | 303 | { |
308 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 304 | if ( !QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) |
309 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 305 | return; |
310 | f.open( IO_ReadOnly ); | 306 | |
311 | QDataStream s( &f ); | 307 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
312 | s >> bookmarks; | 308 | if ( !f.open( IO_ReadOnly ) ) |
313 | f.close(); | 309 | return; |
314 | } | 310 | QDataStream s( &f ); |
311 | s >> bookmarks; | ||
312 | f.close(); | ||
315 | } | 313 | } |
316 | 314 | ||
317 | void HelpWindow::histChosen( int i ) | 315 | void HelpWindow::histChosen( int i ) |
318 | { | 316 | { |
319 | if ( mHistory.contains( i ) ) | 317 | if ( mHistory.contains( i ) ) |
320 | browser->setSource( mHistory[ i ] ); | 318 | browser->setSource( mHistory[ i ] ); |
321 | } | 319 | } |
322 | 320 | ||
323 | void HelpWindow::bookmChosen( int i ) | 321 | void HelpWindow::bookmChosen( int i ) |
324 | { | 322 | { |
325 | if ( mBookmarks.contains( i ) ) | 323 | if ( mBookmarks.contains( i ) ) |
326 | browser->setSource( mBookmarks[ i ] ); | 324 | browser->setSource( mBookmarks[ i ] ); |
327 | } | 325 | } |
328 | 326 | ||
329 | void HelpWindow::addBookmark() | 327 | void HelpWindow::addBookmark() |
330 | { | 328 | { |
331 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 329 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
332 | } | 330 | } |
333 | 331 | ||
diff --git a/noncore/graphics/opie-eye/slave/bmp_slave.cpp b/noncore/graphics/opie-eye/slave/bmp_slave.cpp index 2fa825f..0efadac 100644 --- a/noncore/graphics/opie-eye/slave/bmp_slave.cpp +++ b/noncore/graphics/opie-eye/slave/bmp_slave.cpp | |||
@@ -61,52 +61,50 @@ namespace { | |||
61 | 61 | ||
62 | QString BmpHeader::imageCompression()const | 62 | QString BmpHeader::imageCompression()const |
63 | { | 63 | { |
64 | switch (m_Header.Compression) { | 64 | switch (m_Header.Compression) { |
65 | case RLE8: | 65 | case RLE8: |
66 | return "8Bit RLE Encoding"; | 66 | return "8Bit RLE Encoding"; |
67 | break; | 67 | break; |
68 | case RLE4: | 68 | case RLE4: |
69 | return "4Bit RLE Encoding"; | 69 | return "4Bit RLE Encoding"; |
70 | break; | 70 | break; |
71 | case RGB: | 71 | case RGB: |
72 | default: | 72 | default: |
73 | return "No encoding"; | 73 | return "No encoding"; |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | BmpHeader::BmpHeader(const QString&fname) | 77 | BmpHeader::BmpHeader(const QString&fname) |
78 | : _name(fname),_inputfile(_name) | 78 | : _name(fname),_inputfile(_name) |
79 | { | 79 | { |
80 | read_data(); | 80 | read_data(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void BmpHeader::read_data() { | 83 | void BmpHeader::read_data() { |
84 | memset(&m_Header,0,sizeof(pBmpHeader)); | 84 | memset(&m_Header,0,sizeof(pBmpHeader)); |
85 | _inputfile.open(IO_Raw|IO_ReadOnly); | 85 | if (!_inputfile.open(IO_Raw|IO_ReadOnly)) |
86 | if (!_inputfile.isOpen()) { | ||
87 | return; | 86 | return; |
88 | } | ||
89 | QDataStream s(&_inputfile); | 87 | QDataStream s(&_inputfile); |
90 | s.setByteOrder( QDataStream::LittleEndian ); | 88 | s.setByteOrder( QDataStream::LittleEndian ); |
91 | s.readRawBytes(m_Header.type,2); | 89 | s.readRawBytes(m_Header.type,2); |
92 | if (!isBmp()) { | 90 | if (!isBmp()) { |
93 | _inputfile.close(); | 91 | _inputfile.close(); |
94 | return; | 92 | return; |
95 | } | 93 | } |
96 | s >> m_Header.hSize; | 94 | s >> m_Header.hSize; |
97 | s >> m_Header.reserved1 >> m_Header.reserved2; | 95 | s >> m_Header.reserved1 >> m_Header.reserved2; |
98 | s >> m_Header.Size; | 96 | s >> m_Header.Size; |
99 | if ( m_Header.Size == BmpHeader::WIN || m_Header.Size == BmpHeader::OS2 ) { | 97 | if ( m_Header.Size == BmpHeader::WIN || m_Header.Size == BmpHeader::OS2 ) { |
100 | s >> m_Header.Width >> m_Header.Height >> m_Header.Planes >> m_Header.BitCount; | 98 | s >> m_Header.Width >> m_Header.Height >> m_Header.Planes >> m_Header.BitCount; |
101 | s >> m_Header.Compression >> m_Header.SizeImage; | 99 | s >> m_Header.Compression >> m_Header.SizeImage; |
102 | s >> m_Header.XPerMeter >> m_Header.YPerMeter; | 100 | s >> m_Header.XPerMeter >> m_Header.YPerMeter; |
103 | s >> m_Header.ClrUsed >> m_Header.ClrImportant; | 101 | s >> m_Header.ClrUsed >> m_Header.ClrImportant; |
104 | } else { | 102 | } else { |
105 | Q_INT16 w, h; | 103 | Q_INT16 w, h; |
106 | s >> w >> h >> m_Header.Planes >> m_Header.BitCount; | 104 | s >> w >> h >> m_Header.Planes >> m_Header.BitCount; |
107 | m_Header.Width = w; | 105 | m_Header.Width = w; |
108 | m_Header.Height = h; | 106 | m_Header.Height = h; |
109 | m_Header.Compression = BmpHeader::RGB; | 107 | m_Header.Compression = BmpHeader::RGB; |
110 | m_Header.SizeImage = 0; | 108 | m_Header.SizeImage = 0; |
111 | m_Header.XPerMeter = m_Header.YPerMeter = 0; | 109 | m_Header.XPerMeter = m_Header.YPerMeter = 0; |
112 | m_Header.ClrUsed = m_Header.ClrImportant = 0; | 110 | m_Header.ClrUsed = m_Header.ClrImportant = 0; |
diff --git a/noncore/net/ftplib/ftplib.c b/noncore/net/ftplib/ftplib.c index 421f855..efcd6f0 100644 --- a/noncore/net/ftplib/ftplib.c +++ b/noncore/net/ftplib/ftplib.c | |||
@@ -937,49 +937,50 @@ GLOBALDEF int FtpRead(void *buf, int max, netbuf *nData) | |||
937 | { | 937 | { |
938 | nData->xfered1 += i; | 938 | nData->xfered1 += i; |
939 | if (nData->xfered1 > nData->cbbytes) | 939 | if (nData->xfered1 > nData->cbbytes) |
940 | { | 940 | { |
941 | if (nData->idlecb(nData, nData->xfered, nData->idlearg) == 0) | 941 | if (nData->idlecb(nData, nData->xfered, nData->idlearg) == 0) |
942 | return 0; | 942 | return 0; |
943 | nData->xfered1 = 0; | 943 | nData->xfered1 = 0; |
944 | } | 944 | } |
945 | } | 945 | } |
946 | return i; | 946 | return i; |
947 | } | 947 | } |
948 | 948 | ||
949 | /* | 949 | /* |
950 | * FtpWrite - write to a data connection | 950 | * FtpWrite - write to a data connection |
951 | */ | 951 | */ |
952 | GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData) | 952 | GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData) |
953 | { | 953 | { |
954 | int i; | 954 | int i; |
955 | if (nData->dir != FTPLIB_WRITE) | 955 | if (nData->dir != FTPLIB_WRITE) |
956 | return 0; | 956 | return 0; |
957 | if (nData->buf) | 957 | if (nData->buf) |
958 | i = writeline(buf, len, nData); | 958 | i = writeline(buf, len, nData); |
959 | else | 959 | else |
960 | { | 960 | { |
961 | socket_wait(nData); | 961 | if (socket_wait(nData) < 0) |
962 | fprintf(stderr, "FtpWrite: socket_wait failed with %s\n", nData->ctrl->response); | ||
962 | i = net_write(nData->handle, buf, len); | 963 | i = net_write(nData->handle, buf, len); |
963 | } | 964 | } |
964 | if (i == -1) | 965 | if (i == -1) |
965 | return 0; | 966 | return 0; |
966 | nData->xfered += i; | 967 | nData->xfered += i; |
967 | if (nData->idlecb && nData->cbbytes) | 968 | if (nData->idlecb && nData->cbbytes) |
968 | { | 969 | { |
969 | nData->xfered1 += i; | 970 | nData->xfered1 += i; |
970 | if (nData->xfered1 > nData->cbbytes) | 971 | if (nData->xfered1 > nData->cbbytes) |
971 | { | 972 | { |
972 | nData->idlecb(nData, nData->xfered, nData->idlearg); | 973 | nData->idlecb(nData, nData->xfered, nData->idlearg); |
973 | nData->xfered1 = 0; | 974 | nData->xfered1 = 0; |
974 | } | 975 | } |
975 | } | 976 | } |
976 | return i; | 977 | return i; |
977 | } | 978 | } |
978 | 979 | ||
979 | /* | 980 | /* |
980 | * FtpClose - close a data connection | 981 | * FtpClose - close a data connection |
981 | */ | 982 | */ |
982 | GLOBALDEF int FtpClose(netbuf *nData) | 983 | GLOBALDEF int FtpClose(netbuf *nData) |
983 | { | 984 | { |
984 | netbuf *ctrl; | 985 | netbuf *ctrl; |
985 | switch (nData->dir) | 986 | switch (nData->dir) |
@@ -1318,29 +1319,32 @@ GLOBALDEF int FtpRename(const char *src, const char *dst, netbuf *nControl) | |||
1318 | * | 1319 | * |
1319 | * return 1 if successful, 0 otherwise | 1320 | * return 1 if successful, 0 otherwise |
1320 | */ | 1321 | */ |
1321 | GLOBALDEF int FtpDelete(const char *fnm, netbuf *nControl) | 1322 | GLOBALDEF int FtpDelete(const char *fnm, netbuf *nControl) |
1322 | { | 1323 | { |
1323 | char cmd[256]; | 1324 | char cmd[256]; |
1324 | 1325 | ||
1325 | if ((strlen(fnm) + 7) > sizeof(cmd)) | 1326 | if ((strlen(fnm) + 7) > sizeof(cmd)) |
1326 | return 0; | 1327 | return 0; |
1327 | sprintf(cmd,"DELE %s",fnm); | 1328 | sprintf(cmd,"DELE %s",fnm); |
1328 | if (!FtpSendCmd(cmd,'2', nControl)) | 1329 | if (!FtpSendCmd(cmd,'2', nControl)) |
1329 | return 0; | 1330 | return 0; |
1330 | return 1; | 1331 | return 1; |
1331 | } | 1332 | } |
1332 | 1333 | ||
1333 | /* | 1334 | /* |
1334 | * FtpQuit - disconnect from remote | 1335 | * FtpQuit - disconnect from remote |
1335 | * | 1336 | * |
1336 | * return 1 if successful, 0 otherwise | 1337 | * return 1 if successful, 0 otherwise |
1337 | */ | 1338 | */ |
1338 | GLOBALDEF void FtpQuit(netbuf *nControl) | 1339 | GLOBALDEF void FtpQuit(netbuf *nControl) |
1339 | { | 1340 | { |
1340 | if (nControl->dir != FTPLIB_CONTROL) | 1341 | if (nControl->dir != FTPLIB_CONTROL) |
1341 | return; | 1342 | return; |
1342 | FtpSendCmd("QUIT",'2',nControl); | 1343 | if (FtpSendCmd("QUIT",'2',nControl) == 1) { |
1344 | if (ftplib_debug > 2) | ||
1345 | fprintf(stderr, "FtpQuit: FtpSendCmd(QUIT) failed\n"); | ||
1346 | } | ||
1343 | net_close(nControl->handle); | 1347 | net_close(nControl->handle); |
1344 | free(nControl->buf); | 1348 | free(nControl->buf); |
1345 | free(nControl); | 1349 | free(nControl); |
1346 | } | 1350 | } |
diff --git a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp index 410d642..2498bf9 100644 --- a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp +++ b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp | |||
@@ -158,114 +158,118 @@ void HelpWindow::textChanged() | |||
158 | if ( !selectedURL.isEmpty() && pathCombo ) { | 158 | if ( !selectedURL.isEmpty() && pathCombo ) { |
159 | bool exists = FALSE; | 159 | bool exists = FALSE; |
160 | int i; | 160 | int i; |
161 | for ( i = 0; i < pathCombo->count(); ++i ) { | 161 | for ( i = 0; i < pathCombo->count(); ++i ) { |
162 | if ( pathCombo->text( i ) == selectedURL ) { | 162 | if ( pathCombo->text( i ) == selectedURL ) { |
163 | exists = TRUE; | 163 | exists = TRUE; |
164 | break; | 164 | break; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | if ( !exists ) { | 167 | if ( !exists ) { |
168 | pathCombo->insertItem( selectedURL, 0 ); | 168 | pathCombo->insertItem( selectedURL, 0 ); |
169 | pathCombo->setCurrentItem( 0 ); | 169 | pathCombo->setCurrentItem( 0 ); |
170 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 170 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
171 | } else | 171 | } else |
172 | pathCombo->setCurrentItem( i ); | 172 | pathCombo->setCurrentItem( i ); |
173 | selectedURL = QString::null; | 173 | selectedURL = QString::null; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | HelpWindow::~HelpWindow() | 177 | HelpWindow::~HelpWindow() |
178 | { | 178 | { |
179 | history.clear(); | 179 | history.clear(); |
180 | QMap<int, QString>::Iterator it = mHistory.begin(); | 180 | QMap<int, QString>::Iterator it = mHistory.begin(); |
181 | for ( ; it != mHistory.end(); ++it ) | 181 | for ( ; it != mHistory.end(); ++it ) |
182 | history.append( *it ); | 182 | history.append( *it ); |
183 | 183 | ||
184 | QFile f( QDir::currentDirPath() + "/.history" ); | 184 | QFile f( QDir::currentDirPath() + "/.history" ); |
185 | f.open( IO_WriteOnly ); | 185 | if ( f.open( IO_WriteOnly ) ) { |
186 | QDataStream s( &f ); | 186 | QDataStream s( &f ); |
187 | s << history; | 187 | s << history; |
188 | f.close(); | 188 | f.close(); |
189 | } | ||
189 | 190 | ||
190 | bookmarks.clear(); | 191 | bookmarks.clear(); |
191 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 192 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
192 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 193 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
193 | bookmarks.append( *it2 ); | 194 | bookmarks.append( *it2 ); |
194 | 195 | ||
195 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 196 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
196 | f2.open( IO_WriteOnly ); | 197 | if ( !f2.open( IO_WriteOnly ) ) |
198 | return; | ||
197 | QDataStream s2( &f2 ); | 199 | QDataStream s2( &f2 ); |
198 | s2 << bookmarks; | 200 | s2 << bookmarks; |
199 | f2.close(); | 201 | f2.close(); |
200 | } | 202 | } |
201 | 203 | ||
202 | void HelpWindow::openFile() | 204 | void HelpWindow::openFile() |
203 | { | 205 | { |
204 | #ifndef QT_NO_FILEDIALOG | 206 | #ifndef QT_NO_FILEDIALOG |
205 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); | 207 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); |
206 | if ( !fn.isEmpty() ) | 208 | if ( !fn.isEmpty() ) |
207 | browser->setSource( fn ); | 209 | browser->setSource( fn ); |
208 | #endif | 210 | #endif |
209 | } | 211 | } |
210 | 212 | ||
211 | void HelpWindow::newWindow() | 213 | void HelpWindow::newWindow() |
212 | { | 214 | { |
213 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 215 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
214 | } | 216 | } |
215 | 217 | ||
216 | void HelpWindow::pathSelected( const QString &_path ) | 218 | void HelpWindow::pathSelected( const QString &_path ) |
217 | { | 219 | { |
218 | browser->setSource( _path ); | 220 | browser->setSource( _path ); |
219 | QMap<int, QString>::Iterator it = mHistory.begin(); | 221 | QMap<int, QString>::Iterator it = mHistory.begin(); |
220 | bool exists = FALSE; | 222 | bool exists = FALSE; |
221 | for ( ; it != mHistory.end(); ++it ) { | 223 | for ( ; it != mHistory.end(); ++it ) { |
222 | if ( *it == _path ) { | 224 | if ( *it == _path ) { |
223 | exists = TRUE; | 225 | exists = TRUE; |
224 | break; | 226 | break; |
225 | } | 227 | } |
226 | } | 228 | } |
227 | if ( !exists ) | 229 | if ( !exists ) |
228 | mHistory[ hist->insertItem( _path ) ] = _path; | 230 | mHistory[ hist->insertItem( _path ) ] = _path; |
229 | } | 231 | } |
230 | 232 | ||
231 | void HelpWindow::readHistory() | 233 | void HelpWindow::readHistory() |
232 | { | 234 | { |
233 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 235 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { |
234 | QFile f( QDir::currentDirPath() + "/.history" ); | 236 | QFile f( QDir::currentDirPath() + "/.history" ); |
235 | f.open( IO_ReadOnly ); | 237 | if ( !f.open( IO_ReadOnly ) ) |
236 | QDataStream s( &f ); | 238 | return; |
237 | s >> history; | 239 | QDataStream s( &f ); |
238 | f.close(); | 240 | s >> history; |
239 | while ( history.count() > 20 ) | 241 | f.close(); |
240 | history.remove( history.begin() ); | 242 | while ( history.count() > 20 ) |
243 | history.remove( history.begin() ); | ||
241 | } | 244 | } |
242 | } | 245 | } |
243 | 246 | ||
244 | void HelpWindow::readBookmarks() | 247 | void HelpWindow::readBookmarks() |
245 | { | 248 | { |
246 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 249 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { |
247 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 250 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
248 | f.open( IO_ReadOnly ); | 251 | if ( !f.open( IO_ReadOnly ) ) |
249 | QDataStream s( &f ); | 252 | return; |
250 | s >> bookmarks; | 253 | QDataStream s( &f ); |
251 | f.close(); | 254 | s >> bookmarks; |
255 | f.close(); | ||
252 | } | 256 | } |
253 | } | 257 | } |
254 | 258 | ||
255 | void HelpWindow::histChosen( int i ) | 259 | void HelpWindow::histChosen( int i ) |
256 | { | 260 | { |
257 | if ( mHistory.contains( i ) ) | 261 | if ( mHistory.contains( i ) ) |
258 | browser->setSource( mHistory[ i ] ); | 262 | browser->setSource( mHistory[ i ] ); |
259 | } | 263 | } |
260 | 264 | ||
261 | void HelpWindow::bookmChosen( int i ) | 265 | void HelpWindow::bookmChosen( int i ) |
262 | { | 266 | { |
263 | if ( mBookmarks.contains( i ) ) | 267 | if ( mBookmarks.contains( i ) ) |
264 | browser->setSource( mBookmarks[ i ] ); | 268 | browser->setSource( mBookmarks[ i ] ); |
265 | } | 269 | } |
266 | 270 | ||
267 | void HelpWindow::addBookmark() | 271 | void HelpWindow::addBookmark() |
268 | { | 272 | { |
269 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 273 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
270 | } | 274 | } |
271 | 275 | ||
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.cpp b/noncore/todayplugins/weather/weatherpluginwidget.cpp index fe54051..27624c5 100644 --- a/noncore/todayplugins/weather/weatherpluginwidget.cpp +++ b/noncore/todayplugins/weather/weatherpluginwidget.cpp | |||
@@ -83,87 +83,88 @@ void WeatherPluginWidget::retreiveData() | |||
83 | location = config.readEntry( "Location", "" ); | 83 | location = config.readEntry( "Location", "" ); |
84 | useMetric = config.readBoolEntry( "Metric", true ); | 84 | useMetric = config.readBoolEntry( "Metric", true ); |
85 | frequency = config.readNumEntry( "Frequency", 5 ); | 85 | frequency = config.readNumEntry( "Frequency", 5 ); |
86 | 86 | ||
87 | startTimer( frequency * 60000 ); | 87 | startTimer( frequency * 60000 ); |
88 | 88 | ||
89 | localFile = "/tmp/"; | 89 | localFile = "/tmp/"; |
90 | localFile.append( location ); | 90 | localFile.append( location ); |
91 | localFile.append( ".TXT" ); | 91 | localFile.append( ".TXT" ); |
92 | 92 | ||
93 | remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/"; | 93 | remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/"; |
94 | remoteFile.append( location ); | 94 | remoteFile.append( location ); |
95 | remoteFile.append( ".TXT" ); | 95 | remoteFile.append( ".TXT" ); |
96 | 96 | ||
97 | QFile file( localFile ); | 97 | QFile file( localFile ); |
98 | if ( file.exists() ) | 98 | if ( file.exists() ) |
99 | { | 99 | { |
100 | file.remove(); | 100 | file.remove(); |
101 | } | 101 | } |
102 | 102 | ||
103 | OProcess *proc = new OProcess; | 103 | OProcess *proc = new OProcess; |
104 | 104 | ||
105 | *proc << "wget" << "-q" << remoteFile << "-O" << localFile; | 105 | *proc << "wget" << "-q" << remoteFile << "-O" << localFile; |
106 | connect( proc, SIGNAL( processExited(Opie::Core::OProcess*) ), this, SLOT( dataRetrieved(Opie::Core::OProcess*) ) ); | 106 | connect( proc, SIGNAL( processExited(Opie::Core::OProcess*) ), this, SLOT( dataRetrieved(Opie::Core::OProcess*) ) ); |
107 | proc->start(); | 107 | if ( !proc->start() ) |
108 | weatherLabel->setText( tr( "Could not start wget process." ) ); | ||
108 | } | 109 | } |
109 | 110 | ||
110 | void WeatherPluginWidget::displayWeather() | 111 | void WeatherPluginWidget::displayWeather() |
111 | { | 112 | { |
112 | weatherData = QString::null; | 113 | weatherData = QString::null; |
113 | 114 | ||
114 | QFile file( localFile ); | 115 | QFile file( localFile ); |
115 | 116 | ||
116 | if ( file.size() > 0 && file.open( IO_ReadOnly ) ) | 117 | if ( file.size() > 0 && file.open( IO_ReadOnly ) ) |
117 | { | 118 | { |
118 | QTextStream data( &file ); | 119 | QTextStream data( &file ); |
119 | while ( !data.eof() ) | 120 | while ( !data.eof() ) |
120 | { | 121 | { |
121 | weatherData.append( data.readLine() ); | 122 | weatherData.append( data.readLine() ); |
122 | } | 123 | } |
123 | file.close(); | 124 | file.close(); |
124 | weatherData = weatherData.simplifyWhiteSpace(); | 125 | weatherData = weatherData.simplifyWhiteSpace(); |
125 | 126 | ||
126 | QString tmpstr; | 127 | QString tmpstr; |
127 | 128 | ||
128 | tmpstr.append( tr( "Temp: " ) ); | 129 | tmpstr.append( tr( "Temp: " ) ); |
129 | getTemp( weatherData ); | 130 | getTemp( weatherData ); |
130 | tmpstr.append( dataStr ); | 131 | tmpstr.append( dataStr ); |
131 | 132 | ||
132 | tmpstr.append( tr( " Wind: " ) ); | 133 | tmpstr.append( tr( " Wind: " ) ); |
133 | getWind( weatherData ); | 134 | getWind( weatherData ); |
134 | tmpstr.append( dataStr ); | 135 | tmpstr.append( dataStr ); |
135 | 136 | ||
136 | tmpstr.append( tr( "\nPres: " ) ); | 137 | tmpstr.append( tr( "\nPres: " ) ); |
137 | getPressure( weatherData ); | 138 | getPressure( weatherData ); |
138 | tmpstr.append( dataStr ); | 139 | tmpstr.append( dataStr ); |
139 | 140 | ||
140 | weatherLabel->setText( tmpstr ); | 141 | weatherLabel->setText( tmpstr ); |
141 | 142 | ||
142 | tmpstr = "todayweatherplugin/"; | 143 | tmpstr = "todayweatherplugin/"; |
143 | getIcon( weatherData ); | 144 | getIcon( weatherData ); |
144 | tmpstr.append( dataStr ); | 145 | tmpstr.append( dataStr ); |
145 | weatherIcon->setPixmap( Opie::Core::OResource::loadPixmap( tmpstr, Opie::Core::OResource::SmallIcon ) ); | 146 | weatherIcon->setPixmap( Opie::Core::OResource::loadPixmap( tmpstr, Opie::Core::OResource::SmallIcon ) ); |
146 | } | 147 | } |
147 | else | 148 | else |
148 | { | 149 | { |
149 | weatherLabel->setText( tr( "Current weather data not available." ) ); | 150 | weatherLabel->setText( tr( "Current weather data not available." ) ); |
150 | } | 151 | } |
151 | } | 152 | } |
152 | 153 | ||
153 | void WeatherPluginWidget::getTemp( const QString &data ) | 154 | void WeatherPluginWidget::getTemp( const QString &data ) |
154 | { | 155 | { |
155 | int value; | 156 | int value; |
156 | bool ok; | 157 | bool ok; |
157 | 158 | ||
158 | int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 ); | 159 | int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 ); |
159 | if ( pos > -1 ) | 160 | if ( pos > -1 ) |
160 | { | 161 | { |
161 | if ( data.at( pos ) == 'M' ) | 162 | if ( data.at( pos ) == 'M' ) |
162 | { | 163 | { |
163 | value = -1 * data.mid( pos + 1, 2 ).toInt( &ok ); | 164 | value = -1 * data.mid( pos + 1, 2 ).toInt( &ok ); |
164 | } | 165 | } |
165 | else | 166 | else |
166 | { | 167 | { |
167 | value = data.mid( pos, 2 ).toInt( &ok ); | 168 | value = data.mid( pos, 2 ).toInt( &ok ); |
168 | } | 169 | } |
169 | if ( useMetric ) | 170 | if ( useMetric ) |
diff --git a/noncore/tools/opie-sh/inputdialog.cpp b/noncore/tools/opie-sh/inputdialog.cpp index 8046795..1dd8bf7 100644 --- a/noncore/tools/opie-sh/inputdialog.cpp +++ b/noncore/tools/opie-sh/inputdialog.cpp | |||
@@ -19,76 +19,80 @@ InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString | |||
19 | { | 19 | { |
20 | type = newtype; | 20 | type = newtype; |
21 | QHBoxLayout *layout = new QHBoxLayout(this); | 21 | QHBoxLayout *layout = new QHBoxLayout(this); |
22 | layout->addStrut(32); | 22 | layout->addStrut(32); |
23 | QLabel *label = new QLabel(labelString, this, "label"); | 23 | QLabel *label = new QLabel(labelString, this, "label"); |
24 | setCaption(title); | 24 | setCaption(title); |
25 | int x, y; | 25 | int x, y; |
26 | 26 | ||
27 | layout->addSpacing(5); | 27 | layout->addSpacing(5); |
28 | layout->addWidget(label); | 28 | layout->addWidget(label); |
29 | layout->addSpacing(5); | 29 | layout->addSpacing(5); |
30 | 30 | ||
31 | switch(type) | 31 | switch(type) |
32 | { | 32 | { |
33 | case 0: | 33 | case 0: |
34 | lineEdit = new QLineEdit(this, "line edit"); | 34 | lineEdit = new QLineEdit(this, "line edit"); |
35 | layout->addWidget(lineEdit); | 35 | layout->addWidget(lineEdit); |
36 | break; | 36 | break; |
37 | case 1: | 37 | case 1: |
38 | comboBox = new QComboBox(edit, this, "combo box"); | 38 | comboBox = new QComboBox(edit, this, "combo box"); |
39 | layout->addWidget(comboBox); | 39 | layout->addWidget(comboBox); |
40 | if(!filename.isNull()) | 40 | if(!filename.isNull()) |
41 | { | 41 | { |
42 | QFile file(filename); | 42 | QFile file(filename); |
43 | file.open(IO_ReadOnly); | 43 | if (file.open(IO_ReadOnly)) |
44 | QTextStream stream(&file); | 44 | { |
45 | QString string = stream.read(); | 45 | QTextStream stream(&file); |
46 | QString string = stream.read(); | ||
46 | 47 | ||
47 | comboBox->insertStringList(QStringList::split('\n', string)); | 48 | comboBox->insertStringList(QStringList::split('\n', string)); |
49 | } | ||
48 | } | 50 | } |
49 | else | 51 | else |
50 | { | 52 | { |
51 | QFile file; | 53 | QFile file; |
52 | file.open(IO_ReadOnly, 0); | 54 | file.open(IO_ReadOnly, 0); |
53 | QTextStream stream(&file); | 55 | QTextStream stream(&file); |
54 | QString string = stream.read(); | 56 | QString string = stream.read(); |
55 | 57 | ||
56 | comboBox->insertStringList(QStringList::split('\n', string)); | 58 | comboBox->insertStringList(QStringList::split('\n', string)); |
57 | } | 59 | } |
58 | break; | 60 | break; |
59 | case 2: | 61 | case 2: |
60 | listBox = new QListBox(this, "list box"); | 62 | listBox = new QListBox(this, "list box"); |
61 | listBox->setSelectionMode(QListBox::Multi); | 63 | listBox->setSelectionMode(QListBox::Multi); |
62 | layout->addWidget(listBox); | 64 | layout->addWidget(listBox); |
63 | if(!filename.isNull()) | 65 | if(!filename.isNull()) |
64 | { | 66 | { |
65 | QFile file(filename); | 67 | QFile file(filename); |
66 | file.open(IO_ReadOnly); | 68 | if (file.open(IO_ReadOnly)) |
67 | QTextStream stream(&file); | 69 | { |
68 | QString string = stream.read(); | 70 | QTextStream stream(&file); |
71 | QString string = stream.read(); | ||
69 | 72 | ||
70 | listBox->insertStringList(QStringList::split('\n', string)); | 73 | listBox->insertStringList(QStringList::split('\n', string)); |
74 | } | ||
71 | } | 75 | } |
72 | else | 76 | else |
73 | { | 77 | { |
74 | QFile file; | 78 | QFile file; |
75 | file.open(IO_ReadOnly, 0); | 79 | file.open(IO_ReadOnly, 0); |
76 | QTextStream stream(&file); | 80 | QTextStream stream(&file); |
77 | QString string = stream.read(); | 81 | QString string = stream.read(); |
78 | 82 | ||
79 | listBox->insertStringList(QStringList::split('\n', string)); | 83 | listBox->insertStringList(QStringList::split('\n', string)); |
80 | } | 84 | } |
81 | break; | 85 | break; |
82 | case 3: | 86 | case 3: |
83 | lineEdit = new QLineEdit(this, "line edit"); | 87 | lineEdit = new QLineEdit(this, "line edit"); |
84 | lineEdit->setEchoMode(QLineEdit::Password); | 88 | lineEdit->setEchoMode(QLineEdit::Password); |
85 | layout->addWidget(lineEdit); | 89 | layout->addWidget(lineEdit); |
86 | break; | 90 | break; |
87 | } | 91 | } |
88 | layout->addSpacing(5); | 92 | layout->addSpacing(5); |
89 | 93 | ||
90 | x=(w/2)-(width()/2); | 94 | x=(w/2)-(width()/2); |
91 | y=(h/2)-(height()/2); | 95 | y=(h/2)-(height()/2); |
92 | 96 | ||
93 | move(x,y); | 97 | move(x,y); |
94 | } | 98 | } |