summaryrefslogtreecommitdiff
authorzecke <zecke>2004-03-14 17:56:46 (UTC)
committer zecke <zecke>2004-03-14 17:56:46 (UTC)
commit98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54 (patch) (unidiff)
tree8a440150cc5f66ac5dfce1062b436d9878517779
parentd69b11f67e3118f86d068c38c422984d754e13cc (diff)
downloadopie-98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54.zip
opie-98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54.tar.gz
opie-98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54.tar.bz2
ODP and only ODP
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp1
-rw-r--r--core/apps/embeddedkonsole/main.cpp1
-rw-r--r--core/apps/helpbrowser/main.cpp1
-rw-r--r--core/apps/qcop/config.in4
-rw-r--r--core/apps/textedit/main.cpp1
-rw-r--r--core/apps/textedit/textedit.cpp4
-rw-r--r--core/apps/textedit/textedit.h2
7 files changed, 8 insertions, 6 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 281835e..c5df47f 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -1,243 +1,244 @@
1 1
2/* ---------------------------------------------------------------------- */ 2/* ---------------------------------------------------------------------- */
3/* */ 3/* */
4/* [main.C] Konsole */ 4/* [main.C] Konsole */
5/* */ 5/* */
6/* ---------------------------------------------------------------------- */ 6/* ---------------------------------------------------------------------- */
7/* */ 7/* */
8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 8/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
9/* */ 9/* */
10/* This file is part of Konsole, an X terminal. */ 10/* This file is part of Konsole, an X terminal. */
11/* */ 11/* */
12/* The material contained in here more or less directly orginates from */ 12/* The material contained in here more or less directly orginates from */
13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 13/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
14/* */ 14/* */
15/* ---------------------------------------------------------------------- */ 15/* ---------------------------------------------------------------------- */
16/* */ 16/* */
17/* Ported Konsole to Qt/Embedded */ 17/* Ported Konsole to Qt/Embedded */
18/* */ 18/* */
19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 19/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
20/* */ 20/* */
21/* -------------------------------------------------------------------------- */ 21/* -------------------------------------------------------------------------- */
22// enhancements added by L.J. Potter <ljp@llornkcor.com> 22// enhancements added by L.J. Potter <ljp@llornkcor.com>
23// enhancements added by Phillip Kuhn 23// enhancements added by Phillip Kuhn
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26#include <sys/types.h> 26#include <sys/types.h>
27#include <pwd.h> 27#include <pwd.h>
28#include <unistd.h> 28#include <unistd.h>
29 29
30#ifdef QT_QWS_OPIE 30#ifdef QT_QWS_OPIE
31#include <opie2/ocolorpopupmenu.h> 31#include <opie2/ocolorpopupmenu.h>
32#endif 32#endif
33 33
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35 35
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qtabbar.h> 37#include <qtabbar.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qfontdatabase.h> 39#include <qfontdatabase.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qspinbox.h> 41#include <qspinbox.h>
42#include <qlayout.h> 42#include <qlayout.h>
43 43
44#include <sys/wait.h> 44#include <sys/wait.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <assert.h> 47#include <assert.h>
48 48
49#include "konsole.h" 49#include "konsole.h"
50#include "commandeditdialog.h" 50#include "commandeditdialog.h"
51 51
52using namespace Opie;
52class EKNumTabBar : public QTabBar 53class EKNumTabBar : public QTabBar
53{ 54{
54public: 55public:
55 EKNumTabBar(QWidget *parent = 0, const char *name = 0) : 56 EKNumTabBar(QWidget *parent = 0, const char *name = 0) :
56 QTabBar(parent, name) 57 QTabBar(parent, name)
57 {} 58 {}
58 59
59 // QList<QTab> *getTabList() { return(tabList()); } 60 // QList<QTab> *getTabList() { return(tabList()); }
60 61
61 void numberTabs() 62 void numberTabs()
62 { 63 {
63 // Yes, it really is this messy. QTabWidget needs functions 64 // Yes, it really is this messy. QTabWidget needs functions
64 // that provide acces to tabs in a sequential way. 65 // that provide acces to tabs in a sequential way.
65 int m=INT_MIN; 66 int m=INT_MIN;
66 for (int i=0; i<count(); i++) 67 for (int i=0; i<count(); i++)
67 { 68 {
68 QTab* left=0; 69 QTab* left=0;
69 QListIterator<QTab> it(*tabList()); 70 QListIterator<QTab> it(*tabList());
70 int x=INT_MAX; 71 int x=INT_MAX;
71 for( QTab* t; (t=it.current()); ++it ) 72 for( QTab* t; (t=it.current()); ++it )
72 { 73 {
73 int tx = t->rect().x(); 74 int tx = t->rect().x();
74 if ( tx<x && tx>m ) 75 if ( tx<x && tx>m )
75 { 76 {
76 x = tx; 77 x = tx;
77 left = t; 78 left = t;
78 } 79 }
79 } 80 }
80 if ( left ) 81 if ( left )
81 { 82 {
82 left->setText(QString::number(i+1)); 83 left->setText(QString::number(i+1));
83 m = left->rect().x(); 84 m = left->rect().x();
84 } 85 }
85 } 86 }
86 } 87 }
87 88
88 virtual QSize sizeHint() const 89 virtual QSize sizeHint() const
89 { 90 {
90 if (isHidden()) 91 if (isHidden())
91 { 92 {
92 return(QSize(0,0)); 93 return(QSize(0,0));
93 } 94 }
94 else 95 else
95 { 96 {
96 QSize size = QTabBar::sizeHint(); 97 QSize size = QTabBar::sizeHint();
97 int shrink = 5; 98 int shrink = 5;
98 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) 99 if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600)
99 { 100 {
100 shrink = 10; 101 shrink = 10;
101 } 102 }
102 size.setHeight(size.height() - shrink); 103 size.setHeight(size.height() - shrink);
103 return(size); 104 return(size);
104 } 105 }
105 } 106 }
106 107
107}; 108};
108 109
109class EKNumTabWidget : public QTabWidget 110class EKNumTabWidget : public QTabWidget
110{ 111{
111public: 112public:
112 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 113 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
113 { 114 {
114 setTabBar(new EKNumTabBar(parent,"EKTabBar")); 115 setTabBar(new EKNumTabBar(parent,"EKTabBar"));
115 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 116 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
116 } 117 }
117 118
118 EKNumTabBar *getTabBar() const 119 EKNumTabBar *getTabBar() const
119 { 120 {
120 return ((EKNumTabBar*)tabBar()); 121 return ((EKNumTabBar*)tabBar());
121 } 122 }
122 123
123 124
124 void addTab(QWidget* w) 125 void addTab(QWidget* w)
125 { 126 {
126 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 127 QTab* t = new QTab(QString::number(tabBar()->count()+1));
127 QTabWidget::addTab(w,t); 128 QTabWidget::addTab(w,t);
128 } 129 }
129 130
130 void removeTab(QWidget* w) 131 void removeTab(QWidget* w)
131 { 132 {
132 removePage(w); 133 removePage(w);
133 ((EKNumTabBar*)tabBar())->numberTabs(); 134 ((EKNumTabBar*)tabBar())->numberTabs();
134 } 135 }
135}; 136};
136 137
137// This could be configurable or dynamicly generated from the bash history 138// This could be configurable or dynamicly generated from the bash history
138// file of the user 139// file of the user
139static const char *commonCmds[] = 140static const char *commonCmds[] =
140 { 141 {
141 "ls ", // I left this here, cause it looks better than the first alpha 142 "ls ", // I left this here, cause it looks better than the first alpha
142 "cardctl eject", 143 "cardctl eject",
143 "cat ", 144 "cat ",
144 "cd ", 145 "cd ",
145 "chmod ", 146 "chmod ",
146 "clear", 147 "clear",
147 "cp ", 148 "cp ",
148 "dc ", 149 "dc ",
149 "df ", 150 "df ",
150 "dmesg", 151 "dmesg",
151 "echo ", 152 "echo ",
152 "env", 153 "env",
153 "find ", 154 "find ",
154 "free", 155 "free",
155 "grep ", 156 "grep ",
156 "ifconfig ", 157 "ifconfig ",
157 "ipkg ", 158 "ipkg ",
158 "mkdir ", 159 "mkdir ",
159 "mv ", 160 "mv ",
160 "nc localhost 7776", 161 "nc localhost 7776",
161 "nc localhost 7777", 162 "nc localhost 7777",
162 "netstat ", 163 "netstat ",
163 "nslookup ", 164 "nslookup ",
164 "ping ", 165 "ping ",
165 "ps aux", 166 "ps aux",
166 "pwd ", 167 "pwd ",
167 "qcop QPE/System 'linkChanged(QString)' ''", 168 "qcop QPE/System 'linkChanged(QString)' ''",
168 "qcop QPE/System 'restart()'", 169 "qcop QPE/System 'restart()'",
169 "qcop QPE/System 'quit()'", 170 "qcop QPE/System 'quit()'",
170 "rm ", 171 "rm ",
171 "rmdir ", 172 "rmdir ",
172 "route ", 173 "route ",
173 "set ", 174 "set ",
174 "traceroute", 175 "traceroute",
175 176
176 /* 177 /*
177 "gzip", 178 "gzip",
178 "gunzip", 179 "gunzip",
179 "chgrp", 180 "chgrp",
180 "chown", 181 "chown",
181 "date", 182 "date",
182 "dd", 183 "dd",
183 "df", 184 "df",
184 "dmesg", 185 "dmesg",
185 "fuser", 186 "fuser",
186 "hostname", 187 "hostname",
187 "kill", 188 "kill",
188 "killall", 189 "killall",
189 "ln", 190 "ln",
190 "ping", 191 "ping",
191 "mount", 192 "mount",
192 "more", 193 "more",
193 "sort", 194 "sort",
194 "touch", 195 "touch",
195 "umount", 196 "umount",
196 "mknod", 197 "mknod",
197 "netstat", 198 "netstat",
198 */ 199 */
199 200
200 "exit", 201 "exit",
201 NULL 202 NULL
202 }; 203 };
203 204
204 205
205static void konsoleInit(const char** shell) { 206static void konsoleInit(const char** shell) {
206 if(setuid(getuid()) !=0) qDebug("setuid failed"); 207 if(setuid(getuid()) !=0) qDebug("setuid failed");
207 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 208 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
208 209
209 210
210// QPEApplication::grabKeyboard(); // for CTRL and ALT 211// QPEApplication::grabKeyboard(); // for CTRL and ALT
211 212
212 qDebug("keyboard grabbed"); 213 qDebug("keyboard grabbed");
213#ifdef FAKE_CTRL_AND_ALT 214#ifdef FAKE_CTRL_AND_ALT
214 qDebug("Fake Ctrl and Alt defined"); 215 qDebug("Fake Ctrl and Alt defined");
215 QPEApplication::grabKeyboard(); // for CTRL and ALT 216 QPEApplication::grabKeyboard(); // for CTRL and ALT
216#endif 217#endif
217 218
218 *shell = getenv("SHELL"); 219 *shell = getenv("SHELL");
219 qWarning("SHell initially is %s", *shell ); 220 qWarning("SHell initially is %s", *shell );
220 221
221 if (shell == NULL || *shell == '\0') { 222 if (shell == NULL || *shell == '\0') {
222 struct passwd *ent = 0; 223 struct passwd *ent = 0;
223 uid_t me = getuid(); 224 uid_t me = getuid();
224 *shell = "/bin/sh"; 225 *shell = "/bin/sh";
225 226
226 while ( (ent = getpwent()) != 0 ) { 227 while ( (ent = getpwent()) != 0 ) {
227 if (ent->pw_uid == me) { 228 if (ent->pw_uid == me) {
228 if (ent->pw_shell != "") 229 if (ent->pw_shell != "")
229 *shell = ent->pw_shell; 230 *shell = ent->pw_shell;
230 break; 231 break;
231 } 232 }
232 } 233 }
233 endpwent(); 234 endpwent();
234 } 235 }
235 236
236 if( putenv((char*)"COLORTERM=") !=0) 237 if( putenv((char*)"COLORTERM=") !=0)
237 qDebug("putenv failed"); // to trigger mc's color detection 238 qDebug("putenv failed"); // to trigger mc's color detection
238} 239}
239 240
240 241
241Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 242Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
242 QMainWindow(parent, name, fl) 243 QMainWindow(parent, name, fl)
243{ 244{
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp
index fe30b7e..b456ce2 100644
--- a/core/apps/embeddedkonsole/main.cpp
+++ b/core/apps/embeddedkonsole/main.cpp
@@ -1,29 +1,30 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
4/* */ 4/* */
5/* ---------------------------------------------------------------------- */ 5/* ---------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21 21
22#include "konsole.h" 22#include "konsole.h"
23 23
24#include <opie2/oapplicationfactory.h> 24#include <opie2/oapplicationfactory.h>
25 25
26 26
27/* --| main |------------------------------------------------------ */ 27/* --| main |------------------------------------------------------ */
28using namespace Opie::Core;
28OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) 29OPIE_EXPORT_APP( OApplicationFactory<Konsole> )
29 30
diff --git a/core/apps/helpbrowser/main.cpp b/core/apps/helpbrowser/main.cpp
index c726cd3..66241ae 100644
--- a/core/apps/helpbrowser/main.cpp
+++ b/core/apps/helpbrowser/main.cpp
@@ -1,25 +1,26 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "helpbrowser.h" 21#include "helpbrowser.h"
22 22
23#include <opie2/oapplicationfactory.h> 23#include <opie2/oapplicationfactory.h>
24 24
25using namespace Opie::Core;
25OPIE_EXPORT_APP( OApplicationFactory<HelpBrowser> ) 26OPIE_EXPORT_APP( OApplicationFactory<HelpBrowser> )
diff --git a/core/apps/qcop/config.in b/core/apps/qcop/config.in
index 2bd1a73..f99ff03 100644
--- a/core/apps/qcop/config.in
+++ b/core/apps/qcop/config.in
@@ -1,4 +1,4 @@
1 config QCOP 1 config QCOP
2 boolean "opie-qcop (inter-application communication daemon)" 2 boolean "opie-qcop (inter-application communication client)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 )
diff --git a/core/apps/textedit/main.cpp b/core/apps/textedit/main.cpp
index 9aee47b..d05d6d6 100644
--- a/core/apps/textedit/main.cpp
+++ b/core/apps/textedit/main.cpp
@@ -1,25 +1,26 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "textedit.h" 21#include "textedit.h"
22 22
23#include <opie2/oapplicationfactory.h> 23#include <opie2/oapplicationfactory.h>
24 24
25using namespace Opie::Core;
25OPIE_EXPORT_APP( OApplicationFactory<TextEdit> ) 26OPIE_EXPORT_APP( OApplicationFactory<TextEdit> )
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index b54da34..5bb65a9 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -1,234 +1,232 @@
1/********************************************************************** 1/**********************************************************************
2// textedit.cpp 2// textedit.cpp
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Opie Environment. 5** This file is part of Opie Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12**********************************************************************/ 12**********************************************************************/
13// changes added by L. J. Potter Sun 02-17-2002 21:31:31 13// changes added by L. J. Potter Sun 02-17-2002 21:31:31
14#include "textedit.h" 14#include "textedit.h"
15#include "filePermissions.h" 15#include "filePermissions.h"
16 16
17 17
18#include <opie2/ofileselector.h> 18#include <opie2/ofileselector.h>
19#include <opie2/ofiledialog.h> 19#include <opie2/ofiledialog.h>
20#include <opie2/ofontselector.h> 20#include <opie2/ofontselector.h>
21 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qmenubar.h> 25#include <qmenubar.h>
26#include <qtoolbar.h> 26#include <qtoolbar.h>
27 27
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qclipboard.h> 29#include <qclipboard.h>
30#include <qaction.h> 30#include <qaction.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qdir.h> 35#include <qdir.h>
36#include <unistd.h> 36#include <unistd.h>
37#include <sys/stat.h> 37#include <sys/stat.h>
38#include <stdlib.h> //getenv 38#include <stdlib.h> //getenv
39 39
40using Opie::OFileDialog; 40using namespace Opie::Ui;
41using Opie::OFileSelector;
42using Opie::OFontSelector;
43 41
44#if QT_VERSION < 300 42#if QT_VERSION < 300
45 43
46class QpeEditor : public QMultiLineEdit 44class QpeEditor : public QMultiLineEdit
47{ 45{
48 46
49public: 47public:
50 QpeEditor( QWidget *parent, const char * name = 0 ) 48 QpeEditor( QWidget *parent, const char * name = 0 )
51 : QMultiLineEdit( parent, name ) { 49 : QMultiLineEdit( parent, name ) {
52 clearTableFlags(); 50 clearTableFlags();
53 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); 51 setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
54} 52}
55 53
56 void find( const QString &txt, bool caseSensitive, 54 void find( const QString &txt, bool caseSensitive,
57 bool backwards ); 55 bool backwards );
58protected: 56protected:
59 bool markIt; 57 bool markIt;
60 int line1, line2, col1, col2; 58 int line1, line2, col1, col2;
61 void mousePressEvent( QMouseEvent * ); 59 void mousePressEvent( QMouseEvent * );
62 void mouseReleaseEvent( QMouseEvent * ); 60 void mouseReleaseEvent( QMouseEvent * );
63 61
64//public slots: 62//public slots:
65 /* 63 /*
66signals: 64signals:
67 void notFound(); 65 void notFound();
68 void searchWrapped(); 66 void searchWrapped();
69 */ 67 */
70 68
71private: 69private:
72 70
73}; 71};
74 72
75void QpeEditor::mousePressEvent( QMouseEvent *e ) { 73void QpeEditor::mousePressEvent( QMouseEvent *e ) {
76 switch(e->button()) { 74 switch(e->button()) {
77 case RightButton: 75 case RightButton:
78 { //rediculous workaround for qt popup menu 76 { //rediculous workaround for qt popup menu
79 //and the hold right click mechanism 77 //and the hold right click mechanism
80 this->setSelection( line1, col1, line2, col2); 78 this->setSelection( line1, col1, line2, col2);
81 QMultiLineEdit::mousePressEvent( e ); 79 QMultiLineEdit::mousePressEvent( e );
82 markIt = false; 80 markIt = false;
83 } 81 }
84 break; 82 break;
85 default: 83 default:
86 { 84 {
87 if(!markIt) { 85 if(!markIt) {
88 int line, col; 86 int line, col;
89 this->getCursorPosition(&line, &col); 87 this->getCursorPosition(&line, &col);
90 line1=line2=line; 88 line1=line2=line;
91 col1=col2=col; 89 col1=col2=col;
92 } 90 }
93 QMultiLineEdit::mousePressEvent( e ); 91 QMultiLineEdit::mousePressEvent( e );
94 } 92 }
95 break; 93 break;
96 }; 94 };
97} 95}
98 96
99void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { 97void QpeEditor::mouseReleaseEvent( QMouseEvent * ) {
100 if(this->hasMarkedText()) { 98 if(this->hasMarkedText()) {
101 markIt = true; 99 markIt = true;
102 this->getMarkedRegion( &line1, &col1, &line2, & col2 ); 100 this->getMarkedRegion( &line1, &col1, &line2, & col2 );
103 } else { 101 } else {
104 markIt = false; 102 markIt = false;
105 } 103 }
106} 104}
107 105
108void QpeEditor::find ( const QString &txt, bool caseSensitive, 106void QpeEditor::find ( const QString &txt, bool caseSensitive,
109 bool backwards ) 107 bool backwards )
110{ 108{
111 static bool wrap = false; 109 static bool wrap = false;
112 int line, col; 110 int line, col;
113 if ( wrap ) { 111 if ( wrap ) {
114 if ( !backwards ) 112 if ( !backwards )
115 line = col = 0; 113 line = col = 0;
116 wrap = false; 114 wrap = false;
117 // emit searchWrapped(); 115 // emit searchWrapped();
118 } else { 116 } else {
119 getCursorPosition( &line, &col ); 117 getCursorPosition( &line, &col );
120 } 118 }
121 //ignore backwards for now.... 119 //ignore backwards for now....
122 if ( !backwards ) { 120 if ( !backwards ) {
123 for ( ; ; ) { 121 for ( ; ; ) {
124 if ( line >= numLines() ) { 122 if ( line >= numLines() ) {
125 wrap = true; 123 wrap = true;
126 //emit notFound(); 124 //emit notFound();
127 break; 125 break;
128 } 126 }
129 int findCol = getString( line )->find( txt, col, caseSensitive ); 127 int findCol = getString( line )->find( txt, col, caseSensitive );
130 if ( findCol >= 0 ) { 128 if ( findCol >= 0 ) {
131 setCursorPosition( line, findCol, false ); 129 setCursorPosition( line, findCol, false );
132 col = findCol + txt.length(); 130 col = findCol + txt.length();
133 setCursorPosition( line, col, true ); 131 setCursorPosition( line, col, true );
134 132
135 //found = true; 133 //found = true;
136 break; 134 break;
137 } 135 }
138 line++; 136 line++;
139 col = 0; 137 col = 0;
140 } 138 }
141 } 139 }
142} 140}
143 141
144 142
145#else 143#else
146 144
147#error "Must make a QpeEditor that inherits QTextEdit" 145#error "Must make a QpeEditor that inherits QTextEdit"
148 146
149#endif 147#endif
150 148
151 149
152static const int nfontsizes = 6; 150static const int nfontsizes = 6;
153static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 151static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
154 152
155TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 153TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
156 : QMainWindow( parent, name, f ), bFromDocView( false ) 154 : QMainWindow( parent, name, f ), bFromDocView( false )
157{ 155{
158 doc = 0; 156 doc = 0;
159 edited=false; 157 edited=false;
160 fromSetDocument=false; 158 fromSetDocument=false;
161 159
162 setToolBarsMovable( false ); 160 setToolBarsMovable( false );
163 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 161 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
164 162
165 channel = new QCopChannel( "QPE/Application/textedit", this ); 163 channel = new QCopChannel( "QPE/Application/textedit", this );
166 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 164 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
167 this, SLOT(receive(const QCString&,const QByteArray&)) ); 165 this, SLOT(receive(const QCString&,const QByteArray&)) );
168 166
169 setIcon( Resource::loadPixmap( "TextEditor" ) ); 167 setIcon( Resource::loadPixmap( "TextEditor" ) );
170 168
171 QToolBar *bar = new QToolBar( this ); 169 QToolBar *bar = new QToolBar( this );
172 bar->setHorizontalStretchable( true ); 170 bar->setHorizontalStretchable( true );
173 menu = bar; 171 menu = bar;
174 172
175 QMenuBar *mb = new QMenuBar( bar ); 173 QMenuBar *mb = new QMenuBar( bar );
176 QPopupMenu *file = new QPopupMenu( this ); 174 QPopupMenu *file = new QPopupMenu( this );
177 QPopupMenu *edit = new QPopupMenu( this ); 175 QPopupMenu *edit = new QPopupMenu( this );
178 QPopupMenu *advancedMenu = new QPopupMenu(this); 176 QPopupMenu *advancedMenu = new QPopupMenu(this);
179 177
180 font = new QPopupMenu( this ); 178 font = new QPopupMenu( this );
181 179
182 bar = new QToolBar( this ); 180 bar = new QToolBar( this );
183 editBar = bar; 181 editBar = bar;
184 182
185 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 183 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
186 QString::null, 0, this, 0 ); 184 QString::null, 0, this, 0 );
187 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 185 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
188// a->addTo( bar ); 186// a->addTo( bar );
189 a->addTo( file ); 187 a->addTo( file );
190 188
191 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), 189 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ),
192 QString::null, 0, this, 0 ); 190 QString::null, 0, this, 0 );
193 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 191 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
194 a->addTo( bar ); 192 a->addTo( bar );
195 a->addTo( file ); 193 a->addTo( file );
196 194
197 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , 195 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") ,
198 QString::null, 0, this, 0 ); 196 QString::null, 0, this, 0 );
199 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 197 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
200 file->insertSeparator(); 198 file->insertSeparator();
201 a->addTo( bar ); 199 a->addTo( bar );
202 a->addTo( file ); 200 a->addTo( file );
203 201
204 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , 202 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") ,
205 QString::null, 0, this, 0 ); 203 QString::null, 0, this, 0 );
206 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 204 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
207 a->addTo( file ); 205 a->addTo( file );
208 206
209 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), 207 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ),
210 QString::null, 0, this, 0 ); 208 QString::null, 0, this, 0 );
211 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 209 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
212 a->addTo( editBar ); 210 a->addTo( editBar );
213 a->addTo( edit ); 211 a->addTo( edit );
214 212
215 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), 213 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ),
216 QString::null, 0, this, 0 ); 214 QString::null, 0, this, 0 );
217 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 215 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
218 a->addTo( editBar ); 216 a->addTo( editBar );
219 a->addTo( edit ); 217 a->addTo( edit );
220 218
221 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), 219 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ),
222 QString::null, 0, this, 0 ); 220 QString::null, 0, this, 0 );
223 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 221 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
224 a->addTo( editBar ); 222 a->addTo( editBar );
225 a->addTo( edit ); 223 a->addTo( edit );
226 224
227 225
228#ifndef QT_NO_CLIPBOARD 226#ifndef QT_NO_CLIPBOARD
229 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), 227 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ),
230 QString::null, 0, this, 0 ); 228 QString::null, 0, this, 0 );
231 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 229 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
232 a->addTo( edit ); 230 a->addTo( edit );
233#endif 231#endif
234 232
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index 34f3617..6cc693f 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -1,143 +1,143 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
14 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
15 ** 15 **
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20// additions made by L.J. Potter Sun 02-17-2002 22:27:46 20// additions made by L.J. Potter Sun 02-17-2002 22:27:46
21 21
22#ifndef TEXTEDIT_H 22#ifndef TEXTEDIT_H
23#define TEXTEDIT_H 23#define TEXTEDIT_H
24 24
25#define QTEXTEDIT_OPEN_API 25#define QTEXTEDIT_OPEN_API
26 26
27//#include "fileBrowser.h" 27//#include "fileBrowser.h"
28//#include "fileSaver.h" 28//#include "fileSaver.h"
29 29
30#include <qpe/filemanager.h> 30#include <qpe/filemanager.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33//#include <opie/ofileselector.h> 33//#include <opie2/ofileselector.h>
34 34
35#include <qmainwindow.h> 35#include <qmainwindow.h>
36#include <qmultilineedit.h> 36#include <qmultilineedit.h>
37#include <qlist.h> 37#include <qlist.h>
38#include <qmap.h> 38#include <qmap.h>
39 39
40class QAction; 40class QAction;
41class QWidgetStack; 41class QWidgetStack;
42class QToolButton; 42class QToolButton;
43class QPopupMenu; 43class QPopupMenu;
44class QToolBar; 44class QToolBar;
45class QLineEdit; 45class QLineEdit;
46class QAction; 46class QAction;
47class FileSelector; 47class FileSelector;
48class QpeEditor; 48class QpeEditor;
49class QPopupMenu; 49class QPopupMenu;
50class QTimer; 50class QTimer;
51 51
52class TextEdit : public QMainWindow 52class TextEdit : public QMainWindow
53{ 53{
54 Q_OBJECT 54 Q_OBJECT
55 55
56public: 56public:
57 static QString appName() { return QString::fromLatin1("textedit"); } 57 static QString appName() { return QString::fromLatin1("textedit"); }
58 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 58 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
59 ~TextEdit(); 59 ~TextEdit();
60 60
61protected: 61protected:
62 QPopupMenu *font; 62 QPopupMenu *font;
63 QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave; 63 QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave;
64 bool edited, edited1; 64 bool edited, edited1;
65 void openFile( const QString & ); 65 void openFile( const QString & );
66 QCopChannel * channel; 66 QCopChannel * channel;
67 67
68 bool featureAutoSave; 68 bool featureAutoSave;
69 void closeEvent( QCloseEvent *e ); 69 void closeEvent( QCloseEvent *e );
70 void doSearchBar(); 70 void doSearchBar();
71 int savePrompt(); 71 int savePrompt();
72 void setTimer(); 72 void setTimer();
73private slots: 73private slots:
74 void editorChanged(); 74 void editorChanged();
75 void receive(const QCString&, const QByteArray&); 75 void receive(const QCString&, const QByteArray&);
76 void timerCrank(); 76 void timerCrank();
77 void doTimer(bool); 77 void doTimer(bool);
78 void editPasteTimeDate(); 78 void editPasteTimeDate();
79 void doPrompt(bool); 79 void doPrompt(bool);
80 void doDesktop(bool); 80 void doDesktop(bool);
81 void doFilePerms(bool); 81 void doFilePerms(bool);
82 void doAbout(); 82 void doAbout();
83 void setDocument(const QString&); 83 void setDocument(const QString&);
84 void changeFont(); 84 void changeFont();
85 void fileNew(); 85 void fileNew();
86 void fileRevert(); 86 void fileRevert();
87 void fileOpen(); 87 void fileOpen();
88 void changeStartConfig(bool); 88 void changeStartConfig(bool);
89 bool save(); 89 bool save();
90 bool saveAs(); 90 bool saveAs();
91 void cleanUp(); 91 void cleanUp();
92 92
93 void gotoLine(); 93 void gotoLine();
94 void doGoto(); 94 void doGoto();
95 95
96 96
97 void editCut(); 97 void editCut();
98 void editCopy(); 98 void editCopy();
99 void editPaste(); 99 void editPaste();
100 void editFind(); 100 void editFind();
101 void editDelete(); 101 void editDelete();
102 102
103 void findNext(); 103 void findNext();
104 void findClose(); 104 void findClose();
105 105
106 void search(); 106 void search();
107 void accept(); 107 void accept();
108 108
109 void newFile( const DocLnk & ); 109 void newFile( const DocLnk & );
110 void openFile( const DocLnk & ); 110 void openFile( const DocLnk & );
111 void showEditTools(); 111 void showEditTools();
112 112
113 void zoomIn(); 113 void zoomIn();
114 void zoomOut(); 114 void zoomOut();
115 void setBold(bool y); 115 void setBold(bool y);
116 void setItalic(bool y); 116 void setItalic(bool y);
117 void setWordWrap(bool y); 117 void setWordWrap(bool y);
118 void setSearchBar(bool); 118 void setSearchBar(bool);
119 119
120private: 120private:
121 void openDotFile(const QString &); 121 void openDotFile(const QString &);
122 void colorChanged( const QColor &c ); 122 void colorChanged( const QColor &c );
123 void clear(); 123 void clear();
124 void updateCaption( const QString &name=QString::null ); 124 void updateCaption( const QString &name=QString::null );
125 void setFontSize(int sz, bool round_down_not_up); 125 void setFontSize(int sz, bool round_down_not_up);
126private: 126private:
127// fileSaver *fileSaveDlg; 127// fileSaver *fileSaveDlg;
128// fileBrowser *browseForFiles; 128// fileBrowser *browseForFiles;
129 bool fromSetDocument; 129 bool fromSetDocument;
130 QpeEditor* editor; 130 QpeEditor* editor;
131 QToolBar *menu, *editBar, *searchBar; 131 QToolBar *menu, *editBar, *searchBar;
132 QPopupMenu *advancedMenu; 132 QPopupMenu *advancedMenu;
133 QLineEdit *gotoEdit; 133 QLineEdit *gotoEdit;
134 QLineEdit *searchEdit; 134 QLineEdit *searchEdit;
135 DocLnk *doc; 135 DocLnk *doc;
136 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew; 136 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew;
137 bool bFromDocView; 137 bool bFromDocView;
138 int viewSelection; 138 int viewSelection;
139 QAction *zin, *zout; 139 QAction *zin, *zout;
140 QString currentFileName; 140 QString currentFileName;
141}; 141};
142 142
143#endif 143#endif