summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-04-05 13:30:36 (UTC)
committer mickeyl <mickeyl>2004-04-05 13:30:36 (UTC)
commit743adf3ed3032feb15e71002613a4643d059aa09 (patch) (unidiff)
treeda8c0549515f694775a1cd169cdc5abe615a3847
parentb136b4d55c810c35c54b18b435aa4172b7f6b9fe (diff)
downloadopie-743adf3ed3032feb15e71002613a4643d059aa09.zip
opie-743adf3ed3032feb15e71002613a4643d059aa09.tar.gz
opie-743adf3ed3032feb15e71002613a4643d059aa09.tar.bz2
convert helpbrowser, taboapp and textedit to Opie debugging framework
qcop and embeddedkonsole needs more work. the diagnostics part uses printf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/helpbrowser/helpbrowser.cpp103
-rw-r--r--core/apps/taboapp/main.cpp48
-rw-r--r--core/apps/textedit/filePermissions.cpp2
-rw-r--r--core/apps/textedit/textedit.cpp83
4 files changed, 122 insertions, 114 deletions
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp
index 336d9fb..cbb4059 100644
--- a/core/apps/helpbrowser/helpbrowser.cpp
+++ b/core/apps/helpbrowser/helpbrowser.cpp
@@ -18,26 +18,27 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_LANGLIST 21#define QTOPIA_INTERNAL_LANGLIST
22 22
23#include "helpbrowser.h" 23#include "helpbrowser.h"
24#include "magictextbrowser.h"
24 25
26/* OPIE */
27#include <opie2/odebug.h>
25#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
26#include <qpe/resource.h> 29#include <qpe/resource.h>
30using namespace Opie::Core;
27 31
32/* QT */
28#include <qmenubar.h> 33#include <qmenubar.h>
29#include <qtoolbar.h> 34#include <qtoolbar.h>
30#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
31#include <qfileinfo.h> 36#include <qfileinfo.h>
32#include <qaction.h> 37#include <qaction.h>
33 38
34#include <cctype>
35
36#include "magictextbrowser.h"
37
38HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) 39HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f )
39 : QMainWindow( parent, name, f ), 40 : QMainWindow( parent, name, f ),
40 selectedURL() 41 selectedURL()
41{ 42{
42 init( "index.html" ); 43 init( "index.html" );
43} 44}
@@ -49,40 +50,40 @@ void HelpBrowser::init( const QString& _home )
49 setIcon( Resource::loadPixmap( "HelpBrowser" ) ); 50 setIcon( Resource::loadPixmap( "HelpBrowser" ) );
50 setBackgroundMode( PaletteButton ); 51 setBackgroundMode( PaletteButton );
51 52
52 browser = new MagicTextBrowser( this ); 53 browser = new MagicTextBrowser( this );
53 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 54 browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
54 connect( browser, SIGNAL( textChanged() ), 55 connect( browser, SIGNAL( textChanged() ),
55 this, SLOT( textChanged() ) ); 56 this, SLOT( textChanged() ) );
56 57
57 setCentralWidget( browser ); 58 setCentralWidget( browser );
58 setToolBarsMovable( FALSE ); 59 setToolBarsMovable( FALSE );
59 60
60 if ( !_home.isEmpty() ) 61 if ( !_home.isEmpty() )
61 browser->setSource( _home ); 62 browser->setSource( _home );
62 63
63 QToolBar* toolbar = new QToolBar( this ); 64 QToolBar* toolbar = new QToolBar( this );
64 toolbar->setHorizontalStretchable( TRUE ); 65 toolbar->setHorizontalStretchable( TRUE );
65 QMenuBar *menu = new QMenuBar( toolbar ); 66 QMenuBar *menu = new QMenuBar( toolbar );
66 67
67 toolbar = new QToolBar( this ); 68 toolbar = new QToolBar( this );
68 // addToolBar( toolbar, "Toolbar"); 69 // addToolBar( toolbar, "Toolbar");
69 70
70 QPopupMenu* go = new QPopupMenu( this ); 71 QPopupMenu* go = new QPopupMenu( this );
71 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); 72 backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 );
72 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); 73 connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) );
73 connect( browser, SIGNAL( backwardAvailable(bool) ), 74 connect( browser, SIGNAL( backwardAvailable(bool) ),
74 backAction, SLOT( setEnabled(bool) ) ); 75 backAction, SLOT( setEnabled(bool) ) );
75 backAction->addTo( go ); 76 backAction->addTo( go );
76 backAction->addTo( toolbar ); 77 backAction->addTo( toolbar );
77 backAction->setEnabled( FALSE ); 78 backAction->setEnabled( FALSE );
78 79
79 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); 80 forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 );
80 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); 81 connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) );
81 connect( browser, SIGNAL( forwardAvailable(bool) ), 82 connect( browser, SIGNAL( forwardAvailable(bool) ),
82 forwardAction, SLOT( setEnabled(bool) ) ); 83 forwardAction, SLOT( setEnabled(bool) ) );
83 forwardAction->addTo( go ); 84 forwardAction->addTo( go );
84 forwardAction->addTo( toolbar ); 85 forwardAction->addTo( toolbar );
85 forwardAction->setEnabled( FALSE ); 86 forwardAction->setEnabled( FALSE );
86 87
87 QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); 88 QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 );
88 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); 89 connect( a, SIGNAL( activated() ), browser, SLOT( home() ) );
@@ -91,13 +92,13 @@ void HelpBrowser::init( const QString& _home )
91 92
92 bookm = new QPopupMenu( this ); 93 bookm = new QPopupMenu( this );
93 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); 94 bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
94 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); 95 bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) );
95 bookm->insertSeparator(); 96 bookm->insertSeparator();
96 connect( bookm, SIGNAL( activated(int) ), 97 connect( bookm, SIGNAL( activated(int) ),
97 this, SLOT( bookmChosen(int) ) ); 98 this, SLOT( bookmChosen(int) ) );
98 99
99 readBookmarks(); 100 readBookmarks();
100 101
101 menu->insertItem( tr("Go"), go ); 102 menu->insertItem( tr("Go"), go );
102 menu->insertItem( tr( "Bookmarks" ), bookm ); 103 menu->insertItem( tr( "Bookmarks" ), bookm );
103 104
@@ -109,120 +110,120 @@ void HelpBrowser::init( const QString& _home )
109 QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); 110 QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this );
110 connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), 111 connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)),
111 this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); 112 this, SLOT ( appMessage(const QCString&,const QByteArray&) ) );
112#endif 113#endif
113 114
114 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 115 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
115 this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 116 this, SLOT(appMessage(const QCString&,const QByteArray&)) );
116} 117}
117 118
118void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) 119void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data)
119{ 120{
120 qDebug("reached appMessage"); 121 odebug << "reached appMessage" << oendl;
121 if ( msg == "showFile(QString)" ) { 122 if ( msg == "showFile(QString)" ) {
122 QDataStream ds(data,IO_ReadOnly); 123 QDataStream ds(data,IO_ReadOnly);
123 QString fn; 124 QString fn;
124 ds >> fn; 125 ds >> fn;
125 setDocument( fn ); 126 setDocument( fn );
126 127
127 QPEApplication::setKeepRunning(); 128 QPEApplication::setKeepRunning();
128 129
129 showMaximized(); 130 showMaximized();
130 setActiveWindow(); 131 setActiveWindow();
131 raise(); 132 raise();
132 } 133 }
133} 134}
134 135
135void HelpBrowser::setDocument( const QString &doc ) 136void HelpBrowser::setDocument( const QString &doc )
136{ 137{
137 if ( !doc.isEmpty() ) 138 if ( !doc.isEmpty() )
138 browser->setSource( doc ); 139 browser->setSource( doc );
139 raise(); 140 raise();
140} 141}
141 142
142 143
143void HelpBrowser::textChanged() 144void HelpBrowser::textChanged()
144{ 145{
145 if ( browser->documentTitle().isNull() ) 146 if ( browser->documentTitle().isNull() )
146 setCaption( tr("Help Browser") ); 147 setCaption( tr("Help Browser") );
147 else 148 else
148 setCaption( browser->documentTitle() ) ; 149 setCaption( browser->documentTitle() ) ;
149 150
150 selectedURL = caption(); 151 selectedURL = caption();
151} 152}
152 153
153HelpBrowser::~HelpBrowser() 154HelpBrowser::~HelpBrowser()
154{ 155{
155 QStringList bookmarks; 156 QStringList bookmarks;
156 QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); 157 QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin();
157 for ( ; it2 != mBookmarks.end(); ++it2 ) 158 for ( ; it2 != mBookmarks.end(); ++it2 )
158 bookmarks.append( (*it2).name + "=" + (*it2).file ); 159 bookmarks.append( (*it2).name + "=" + (*it2).file );
159 160
160 QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); 161 QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") );
161 if ( f2.open( IO_WriteOnly ) ) { 162 if ( f2.open( IO_WriteOnly ) ) {
162 QDataStream s2( &f2 ); 163 QDataStream s2( &f2 );
163 s2 << bookmarks; 164 s2 << bookmarks;
164 f2.close(); 165 f2.close();
165 } 166 }
166} 167}
167 168
168void HelpBrowser::pathSelected( const QString &_path ) 169void HelpBrowser::pathSelected( const QString &_path )
169{ 170{
170 browser->setSource( _path ); 171 browser->setSource( _path );
171} 172}
172 173
173void HelpBrowser::readBookmarks() 174void HelpBrowser::readBookmarks()
174{ 175{
175 QString file = Global::applicationFileName("helpbrowser", "bookmarks"); 176 QString file = Global::applicationFileName("helpbrowser", "bookmarks");
176 if ( QFile::exists( file ) ) { 177 if ( QFile::exists( file ) ) {
177 QStringList bookmarks; 178 QStringList bookmarks;
178 QFile f( file ); 179 QFile f( file );
179 if ( f.open( IO_ReadOnly ) ) { 180 if ( f.open( IO_ReadOnly ) ) {
180 QDataStream s( &f ); 181 QDataStream s( &f );
181 s >> bookmarks; 182 s >> bookmarks;
182 f.close(); 183 f.close();
183 } 184 }
184 QStringList::Iterator it = bookmarks.begin(); 185 QStringList::Iterator it = bookmarks.begin();
185 for ( ; it != bookmarks.end(); ++it ) { 186 for ( ; it != bookmarks.end(); ++it ) {
186 Bookmark b; 187 Bookmark b;
187 QString current = *it; 188 QString current = *it;
188 int equal = current.find( "=" ); 189 int equal = current.find( "=" );
189 if ( equal < 1 || equal == (int)current.length() - 1 ) 190 if ( equal < 1 || equal == (int)current.length() - 1 )
190 continue; 191 continue;
191 b.name = current.left( equal ); 192 b.name = current.left( equal );
192 b.file = current.mid( equal + 1 ); 193 b.file = current.mid( equal + 1 );
193 mBookmarks[ bookm->insertItem( b.name ) ] = b; 194 mBookmarks[ bookm->insertItem( b.name ) ] = b;
194 } 195 }
195 } 196 }
196} 197}
197 198
198void HelpBrowser::bookmChosen( int i ) 199void HelpBrowser::bookmChosen( int i )
199{ 200{
200 if ( mBookmarks.contains( i ) ) 201 if ( mBookmarks.contains( i ) )
201 browser->setSource( mBookmarks[ i ].file ); 202 browser->setSource( mBookmarks[ i ].file );
202} 203}
203 204
204void HelpBrowser::addBookmark() 205void HelpBrowser::addBookmark()
205{ 206{
206 Bookmark b; 207 Bookmark b;
207 b.name = browser->documentTitle(); 208 b.name = browser->documentTitle();
208 b.file = browser->source(); 209 b.file = browser->source();
209 if (b.name.isEmpty() ) { 210 if (b.name.isEmpty() ) {
210 b.name = b.file.left( b.file.length() - 5 ); // remove .html 211 b.name = b.file.left( b.file.length() - 5 ); // remove .html
211 } 212 }
212 QMap<int, Bookmark>::Iterator it; 213 QMap<int, Bookmark>::Iterator it;
213 for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) 214 for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it )
214 if ( (*it).file == b.file ) return; 215 if ( (*it).file == b.file ) return;
215 mBookmarks[ bookm->insertItem( b.name ) ] = b; 216 mBookmarks[ bookm->insertItem( b.name ) ] = b;
216} 217}
217 218
218void HelpBrowser::removeBookmark() 219void HelpBrowser::removeBookmark()
219{ 220{
220 QString file = browser->source(); 221 QString file = browser->source();
221 QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); 222 QMap<int, Bookmark>::Iterator it = mBookmarks.begin();
222 for( ; it != mBookmarks.end(); ++it ) 223 for( ; it != mBookmarks.end(); ++it )
223 if ( (*it).file == file ) { 224 if ( (*it).file == file ) {
224 bookm->removeItem( it.key() ); 225 bookm->removeItem( it.key() );
225 mBookmarks.remove( it ); 226 mBookmarks.remove( it );
226 break; 227 break;
227 } 228 }
228} 229}
diff --git a/core/apps/taboapp/main.cpp b/core/apps/taboapp/main.cpp
index e46c71f..e43f118 100644
--- a/core/apps/taboapp/main.cpp
+++ b/core/apps/taboapp/main.cpp
@@ -1,53 +1,57 @@
1#include <qdir.h> 1/* OPIE */
2
3#include <qpe/qpeapplication.h>
4#include <qpe/qlibrary.h>
5#include <oappinterface.h> 2#include <oappinterface.h>
6#include <oappplugin.h> 3#include <oappplugin.h>
7 4#include <opie2/odebug.h>
8#include <opie2/otabwidget.h> 5#include <opie2/otabwidget.h>
6#include <qpe/qpeapplication.h>
7#include <qpe/qlibrary.h>
8using namespace Opie::Core;
9using namespace Opie::Ui;
10
11/* QT */
12#include <qdir.h>
9 13
10int main( int argc, char **argv ) 14int main( int argc, char **argv )
11{ 15{
12 QPEApplication a( argc, argv ); 16 QPEApplication a( argc, argv );
13 17
14 Opie::Ui::OTabWidget *tabwidget = new Opie::Ui::OTabWidget(0, "tab widget"); 18 OTabWidget *tabwidget = new OTabWidget(0, "tab widget");
15 19
16 QString path = QPEApplication::qpeDir() + "/plugins/app"; 20 QString path = QPEApplication::qpeDir() + "/plugins/app";
17 QDir dir( path, "lib*.so" ); 21 QDir dir( path, "lib*.so" );
18 22
19 QStringList list = dir.entryList(); 23 QStringList list = dir.entryList();
20 QStringList::Iterator it; 24 QStringList::Iterator it;
21 25
22 QInterfacePtr<OAppInterface> iface; 26 QInterfacePtr<OAppInterface> iface;
23 for ( it = list.begin(); it != list.end(); ++it ) { 27 for ( it = list.begin(); it != list.end(); ++it ) {
24 QLibrary *lib = new QLibrary( path + "/" + *it ); 28 QLibrary *lib = new QLibrary( path + "/" + *it );
25 29
26 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 30 odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl;
27 if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 31 if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
28 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); 32 odebug << "accepted: " << QString( path + "/" + *it ) << "" << oendl;
29 33
30 QList<QWidget> list = iface->widgets(); 34 QList<QWidget> list = iface->widgets();
31 QWidget *widget; 35 QWidget *widget;
32 for ( widget = list.first(); widget != 0; widget = list.next() ) 36 for ( widget = list.first(); widget != 0; widget = list.next() )
33 tabwidget->addTab(widget, QString(*it), QString(*it)); 37 tabwidget->addTab(widget, QString(*it), QString(*it));
34 38
35 QString lang = getenv( "LANG" ); 39 QString lang = getenv( "LANG" );
36 if (lang.isNull()) 40 if (lang.isNull())
37 lang = "en"; 41 lang = "en";
38 QTranslator *trans = new QTranslator(qApp); 42 QTranslator *trans = new QTranslator(qApp);
39 QString type = (*it).left( (*it).find(".") ); 43 QString type = (*it).left( (*it).find(".") );
40 if (type.left(3) == "lib") 44 if (type.left(3) == "lib")
41 type = type.mid(3); 45 type = type.mid(3);
42 type = type.right( type.find("lib") ); 46 type = type.right( type.find("lib") );
43 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 47 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
44 if ( trans->load( tfn )) 48 if ( trans->load( tfn ))
45 qApp->installTranslator( trans ); 49 qApp->installTranslator( trans );
46 else 50 else
47 delete trans; 51 delete trans;
48 } 52 }
49 } 53 }
50 54
51 a.showMainDocumentWidget(tabwidget); 55 a.showMainDocumentWidget(tabwidget);
52 return a.exec(); 56 return a.exec();
53} 57}
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp
index db353a9..a059dce 100644
--- a/core/apps/textedit/filePermissions.cpp
+++ b/core/apps/textedit/filePermissions.cpp
@@ -29,13 +29,13 @@
29 29
30filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) 30filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
31 : QDialog( parent, name, modal, fl ) 31 : QDialog( parent, name, modal, fl )
32{ 32{
33 if ( !name ) 33 if ( !name )
34 setName( tr("File Permissions") ); 34 setName( tr("File Permissions") );
35// qDebug("FilePermissions "+fileName); 35// odebug << "FilePermissions "+fileName << oendl;
36 resize( 236, 210 ); 36 resize( 236, 210 );
37 setMaximumSize( QSize( 236, 210 ) ); 37 setMaximumSize( QSize( 236, 210 ) );
38 setCaption( tr( "Set File Permissions" ) ); 38 setCaption( tr( "Set File Permissions" ) );
39 39
40 TextLabel1 = new QLabel( this, "TextLabel1" ); 40 TextLabel1 = new QLabel( this, "TextLabel1" );
41 TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); 41 TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 5bb65a9..c9178a5 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -8,42 +8,45 @@
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
14#include "textedit.h" 15#include "textedit.h"
15#include "filePermissions.h" 16#include "filePermissions.h"
16 17
17 18/* OPIE */
19#include <opie2/odebug.h>
18#include <opie2/ofileselector.h> 20#include <opie2/ofileselector.h>
19#include <opie2/ofiledialog.h> 21#include <opie2/ofiledialog.h>
20#include <opie2/ofontselector.h> 22#include <opie2/ofontselector.h>
21
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23#include <qpe/config.h> 24#include <qpe/config.h>
24#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26using namespace Opie::Core;
27using namespace Opie::Ui;
28
29/* QT */
25#include <qmenubar.h> 30#include <qmenubar.h>
26#include <qtoolbar.h> 31#include <qtoolbar.h>
27
28#include <qtextstream.h> 32#include <qtextstream.h>
29#include <qclipboard.h> 33#include <qclipboard.h>
30#include <qaction.h> 34#include <qaction.h>
31#include <qlineedit.h> 35#include <qlineedit.h>
32#include <qmessagebox.h> 36#include <qmessagebox.h>
33#include <qlayout.h> 37#include <qlayout.h>
34#include <qtimer.h> 38#include <qtimer.h>
35#include <qdir.h> 39#include <qdir.h>
40
41/* STD */
36#include <unistd.h> 42#include <unistd.h>
37#include <sys/stat.h> 43#include <sys/stat.h>
38#include <stdlib.h> //getenv 44#include <stdlib.h> //getenv
39 45
40using namespace Opie::Ui;
41
42#if QT_VERSION < 300 46#if QT_VERSION < 300
43
44class QpeEditor : public QMultiLineEdit 47class QpeEditor : public QMultiLineEdit
45{ 48{
46 49
47public: 50public:
48 QpeEditor( QWidget *parent, const char * name = 0 ) 51 QpeEditor( QWidget *parent, const char * name = 0 )
49 : QMultiLineEdit( parent, name ) { 52 : QMultiLineEdit( parent, name ) {
@@ -408,13 +411,13 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
408 } 411 }
409 412
410 viewSelection = cfg.readNumEntry( "FileView", 0 ); 413 viewSelection = cfg.readNumEntry( "FileView", 0 );
411} 414}
412 415
413TextEdit::~TextEdit() { 416TextEdit::~TextEdit() {
414 qWarning("textedit d'tor"); 417 owarn << "textedit d'tor" << oendl;
415 delete editor; 418 delete editor;
416} 419}
417 420
418void TextEdit::closeEvent(QCloseEvent *) { 421void TextEdit::closeEvent(QCloseEvent *) {
419 if( edited1 && promptExit) 422 if( edited1 && promptExit)
420 { 423 {
@@ -643,22 +646,22 @@ void TextEdit::newFile( const DocLnk &f ) {
643 nf.setType("text/plain"); 646 nf.setType("text/plain");
644 clear(); 647 clear();
645 setWState (WState_Reserved1 ); 648 setWState (WState_Reserved1 );
646 editor->setFocus(); 649 editor->setFocus();
647 doc = new DocLnk(nf); 650 doc = new DocLnk(nf);
648 currentFileName = "Unnamed"; 651 currentFileName = "Unnamed";
649 qDebug("newFile "+currentFileName); 652 odebug << "newFile "+currentFileName << oendl;
650 updateCaption( currentFileName); 653 updateCaption( currentFileName);
651// editor->setEdited( false); 654// editor->setEdited( false);
652} 655}
653 656
654void TextEdit::openDotFile( const QString &f ) { 657void TextEdit::openDotFile( const QString &f ) {
655 if(!currentFileName.isEmpty()) { 658 if(!currentFileName.isEmpty()) {
656 currentFileName=f; 659 currentFileName=f;
657 660
658 qDebug("openFile dotfile " + currentFileName); 661 odebug << "openFile dotfile " + currentFileName << oendl;
659 QString txt; 662 QString txt;
660 QFile file(f); 663 QFile file(f);
661 file.open(IO_ReadWrite); 664 file.open(IO_ReadWrite);
662 QTextStream t(&file); 665 QTextStream t(&file);
663 while ( !t.atEnd()) { 666 while ( !t.atEnd()) {
664 txt+=t.readLine()+"\n"; 667 txt+=t.readLine()+"\n";
@@ -671,13 +674,13 @@ void TextEdit::openDotFile( const QString &f ) {
671 674
672 } 675 }
673 updateCaption( currentFileName); 676 updateCaption( currentFileName);
674} 677}
675 678
676void TextEdit::openFile( const QString &f ) { 679void TextEdit::openFile( const QString &f ) {
677 qDebug("filename is "+ f); 680 odebug << "filename is "+ f << oendl;
678 QString filer; 681 QString filer;
679 QFileInfo fi( f); 682 QFileInfo fi( f);
680// bFromDocView = true; 683// bFromDocView = true;
681 if(f.find(".desktop",0,true) != -1 && !openDesktop ) 684 if(f.find(".desktop",0,true) != -1 && !openDesktop )
682 { 685 {
683 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) 686 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) )
@@ -690,13 +693,13 @@ void TextEdit::openFile( const QString &f ) {
690 filer = sf.file(); 693 filer = sf.file();
691 break; 694 break;
692 }; 695 };
693 } 696 }
694 else if(fi.baseName().left(1) == "") 697 else if(fi.baseName().left(1) == "")
695 { 698 {
696 qDebug("opening dotfile"); 699 odebug << "opening dotfile" << oendl;
697 currentFileName=f; 700 currentFileName=f;
698 openDotFile(currentFileName); 701 openDotFile(currentFileName);
699 return; 702 return;
700 } 703 }
701 /* 704 /*
702 * The problem is a file where Config(f).isValid() and it does not 705 * The problem is a file where Config(f).isValid() and it does not
@@ -718,13 +721,13 @@ void TextEdit::openFile( const QString &f ) {
718 nf.setFile(filer); 721 nf.setFile(filer);
719 currentFileName=filer; 722 currentFileName=filer;
720 723
721 nf.setName(fi.baseName()); 724 nf.setName(fi.baseName());
722 openFile(nf); 725 openFile(nf);
723 726
724 qDebug("openFile string "+currentFileName); 727 odebug << "openFile string "+currentFileName << oendl;
725 728
726 showEditTools(); 729 showEditTools();
727 // Show filename in caption 730 // Show filename in caption
728 QString name = filer; 731 QString name = filer;
729 int sep = name.findRev( '/' ); 732 int sep = name.findRev( '/' );
730 if ( sep > 0 ) 733 if ( sep > 0 )
@@ -735,16 +738,16 @@ void TextEdit::openFile( const QString &f ) {
735void TextEdit::openFile( const DocLnk &f ) { 738void TextEdit::openFile( const DocLnk &f ) {
736// clear(); 739// clear();
737// bFromDocView = true; 740// bFromDocView = true;
738 FileManager fm; 741 FileManager fm;
739 QString txt; 742 QString txt;
740 currentFileName=f.file(); 743 currentFileName=f.file();
741 qDebug("openFile doclnk " + currentFileName); 744 odebug << "openFile doclnk " + currentFileName << oendl;
742 if ( !fm.loadFile( f, txt ) ) { 745 if ( !fm.loadFile( f, txt ) ) {
743 // ####### could be a new file 746 // ####### could be a new file
744 qDebug( "Cannot open file" ); 747 odebug << "Cannot open file" << oendl;
745 } 748 }
746// fileNew(); 749// fileNew();
747 if ( doc ) 750 if ( doc )
748 delete doc; 751 delete doc;
749 doc = new DocLnk(f); 752 doc = new DocLnk(f);
750 editor->setText(txt); 753 editor->setText(txt);
@@ -767,51 +770,51 @@ void TextEdit::showEditTools() {
767 setWState (WState_Reserved1 ); 770 setWState (WState_Reserved1 );
768} 771}
769 772
770/*! 773/*!
771 unprompted save */ 774 unprompted save */
772bool TextEdit::save() { 775bool TextEdit::save() {
773 qDebug("saveAsFile " + currentFileName); 776 odebug << "saveAsFile " + currentFileName << oendl;
774 if(currentFileName.isEmpty()) { 777 if(currentFileName.isEmpty()) {
775 saveAs(); 778 saveAs();
776 return false; 779 return false;
777 } 780 }
778 781
779 QString file = doc->file(); 782 QString file = doc->file();
780 qDebug("saver file "+file); 783 odebug << "saver file "+file << oendl;
781 QString name= doc->name(); 784 QString name= doc->name();
782 qDebug("File named "+name); 785 odebug << "File named "+name << oendl;
783 QString rt = editor->text(); 786 QString rt = editor->text();
784 if( !rt.isEmpty() ) { 787 if( !rt.isEmpty() ) {
785 if(name.isEmpty()) { 788 if(name.isEmpty()) {
786 saveAs(); 789 saveAs();
787 } else { 790 } else {
788 currentFileName= name ; 791 currentFileName= name ;
789 qDebug("saveFile "+currentFileName); 792 odebug << "saveFile "+currentFileName << oendl;
790 793
791 struct stat buf; 794 struct stat buf;
792 mode_t mode; 795 mode_t mode;
793 stat(file.latin1(), &buf); 796 stat(file.latin1(), &buf);
794 mode = buf.st_mode; 797 mode = buf.st_mode;
795 798
796 if(!fileIs) { 799 if(!fileIs) {
797 doc->setName( name); 800 doc->setName( name);
798 FileManager fm; 801 FileManager fm;
799 if ( !fm.saveFile( *doc, rt ) ) { 802 if ( !fm.saveFile( *doc, rt ) ) {
800 QMessageBox::message(tr("Text Edit"),tr("Save Failed")); 803 QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
801 return false; 804 return false;
802 } 805 }
803 } else { 806 } else {
804 qDebug("regular save file"); 807 odebug << "regular save file" << oendl;
805 QFile f(file); 808 QFile f(file);
806 if( f.open(IO_WriteOnly)) { 809 if( f.open(IO_WriteOnly)) {
807 QCString crt = rt.utf8(); 810 QCString crt = rt.utf8();
808 f.writeBlock(crt,crt.length()); 811 f.writeBlock(crt,crt.length());
809 } else { 812 } else {
810 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 813 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
811 return false; 814 return false;
812 } 815 }
813 816
814 } 817 }
815 editor->setEdited( false); 818 editor->setEdited( false);
816 edited1=false; 819 edited1=false;
817 edited=false; 820 edited=false;
@@ -829,32 +832,32 @@ bool TextEdit::save() {
829/*! 832/*!
830 prompted save */ 833 prompted save */
831bool TextEdit::saveAs() { 834bool TextEdit::saveAs() {
832 835
833 if(caption() == tr("Text Editor")) 836 if(caption() == tr("Text Editor"))
834 return false; 837 return false;
835 qDebug("saveAsFile " + currentFileName); 838 odebug << "saveAsFile " + currentFileName << oendl;
836 // case of nothing to save... 839 // case of nothing to save...
837// if ( !doc && !currentFileName.isEmpty()) { 840// if ( !doc && !currentFileName.isEmpty()) {
838// //|| !bFromDocView) 841// //|| !bFromDocView)
839// qDebug("no doc"); 842// odebug << "no doc" << oendl;
840// return true; 843// return true;
841// } 844// }
842// if ( !editor->edited() ) { 845// if ( !editor->edited() ) {
843// delete doc; 846// delete doc;
844// doc = 0; 847// doc = 0;
845// return true; 848// return true;
846// } 849// }
847 850
848 QString rt = editor->text(); 851 QString rt = editor->text();
849 qDebug(currentFileName); 852 odebug << currentFileName << oendl;
850 853
851 if( currentFileName.isEmpty() 854 if( currentFileName.isEmpty()
852 || currentFileName == tr("Unnamed") 855 || currentFileName == tr("Unnamed")
853 || currentFileName == tr("Text Editor")) { 856 || currentFileName == tr("Text Editor")) {
854 qDebug("do silly TT filename thing"); 857 odebug << "do silly TT filename thing" << oendl;
855// if ( doc && doc->name().isEmpty() ) { 858// if ( doc && doc->name().isEmpty() ) {
856 QString pt = rt.simplifyWhiteSpace(); 859 QString pt = rt.simplifyWhiteSpace();
857 int i = pt.find( ' ' ); 860 int i = pt.find( ' ' );
858 QString docname = pt; 861 QString docname = pt;
859 if ( i > 0 ) 862 if ( i > 0 )
860 docname = pt.left( i ); 863 docname = pt.left( i );
@@ -869,13 +872,13 @@ bool TextEdit::saveAs() {
869 if ( docname.isEmpty() ) 872 if ( docname.isEmpty() )
870 docname = tr("Unnamed"); 873 docname = tr("Unnamed");
871 if(doc) doc->setName(docname); 874 if(doc) doc->setName(docname);
872 currentFileName=docname; 875 currentFileName=docname;
873// } 876// }
874// else 877// else
875// qDebug("hmmmmmm"); 878// odebug << "hmmmmmm" << oendl;
876 } 879 }
877 880
878 881
879 QMap<QString, QStringList> map; 882 QMap<QString, QStringList> map;
880 map.insert(tr("All"), QStringList() ); 883 map.insert(tr("All"), QStringList() );
881 QStringList text; 884 QStringList text;
@@ -897,31 +900,31 @@ bool TextEdit::saveAs() {
897 } else 900 } else
898 str=currentFileName; 901 str=currentFileName;
899 902
900 if(!str.isEmpty()) { 903 if(!str.isEmpty()) {
901 QString fileNm=str; 904 QString fileNm=str;
902 905
903 qDebug("saving filename "+fileNm); 906 odebug << "saving filename "+fileNm << oendl;
904 QFileInfo fi(fileNm); 907 QFileInfo fi(fileNm);
905 currentFileName=fi.fileName(); 908 currentFileName=fi.fileName();
906 if(doc) 909 if(doc)
907// QString file = doc->file(); 910// QString file = doc->file();
908// doc->removeFiles(); 911// doc->removeFiles();
909 delete doc; 912 delete doc;
910 DocLnk nf; 913 DocLnk nf;
911 nf.setType("text/plain"); 914 nf.setType("text/plain");
912 nf.setFile( fileNm); 915 nf.setFile( fileNm);
913 doc = new DocLnk(nf); 916 doc = new DocLnk(nf);
914// editor->setText(rt); 917// editor->setText(rt);
915 qDebug("Saving file as "+currentFileName); 918 odebug << "Saving file as "+currentFileName << oendl;
916 doc->setName( currentFileName); 919 doc->setName( currentFileName);
917 updateCaption( currentFileName); 920 updateCaption( currentFileName);
918 921
919 FileManager fm; 922 FileManager fm;
920 if ( !fm.saveFile( *doc, rt ) ) { 923 if ( !fm.saveFile( *doc, rt ) ) {
921 QMessageBox::message(tr("Text Edit"),tr("Save Failed")); 924 QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
922 return false; 925 return false;
923 } 926 }
924 927
925 if( filePerms ) { 928 if( filePerms ) {
926 filePermissions *filePerm; 929 filePermissions *filePerm;
927 filePerm = new filePermissions(this, 930 filePerm = new filePermissions(this,
@@ -938,13 +941,13 @@ bool TextEdit::saveAs() {
938 edited = false; 941 edited = false;
939 if(caption().left(1)=="*") 942 if(caption().left(1)=="*")
940 setCaption(caption().right(caption().length()-1)); 943 setCaption(caption().right(caption().length()-1));
941 944
942 return true; 945 return true;
943 } 946 }
944 qDebug("returning false"); 947 odebug << "returning false" << oendl;
945 return false; 948 return false;
946} //end saveAs 949} //end saveAs
947 950
948void TextEdit::clear() { 951void TextEdit::clear() {
949 delete doc; 952 delete doc;
950 doc = 0; 953 doc = 0;
@@ -969,20 +972,20 @@ void TextEdit::updateCaption( const QString &name ) {
969 } 972 }
970} 973}
971 974
972void TextEdit::setDocument(const QString& fileref) { 975void TextEdit::setDocument(const QString& fileref) {
973 if(fileref != "Unnamed") { 976 if(fileref != "Unnamed") {
974 currentFileName=fileref; 977 currentFileName=fileref;
975 qDebug("setDocument"); 978 odebug << "setDocument" << oendl;
976 QFileInfo fi(currentFileName); 979 QFileInfo fi(currentFileName);
977 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); 980 odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl;
978 if( (fi.baseName().left(1)).isEmpty() ) { 981 if( (fi.baseName().left(1)).isEmpty() ) {
979 openDotFile(currentFileName); 982 openDotFile(currentFileName);
980 983
981 } else { 984 } else {
982 qDebug("setDoc open"); 985 odebug << "setDoc open" << oendl;
983 bFromDocView = true; 986 bFromDocView = true;
984 openFile(fileref); 987 openFile(fileref);
985 editor->setEdited(true); 988 editor->setEdited(true);
986 edited1=false; 989 edited1=false;
987 edited=true; 990 edited=true;
988 // fromSetDocument=false; 991 // fromSetDocument=false;
@@ -1031,24 +1034,24 @@ void TextEdit::changeStartConfig( bool b ) {
1031 cfg.setGroup("View"); 1034 cfg.setGroup("View");
1032 cfg.writeEntry("startNew",b); 1035 cfg.writeEntry("startNew",b);
1033 update(); 1036 update();
1034} 1037}
1035 1038
1036void TextEdit::editorChanged() { 1039void TextEdit::editorChanged() {
1037// qDebug("editor changed"); 1040// odebug << "editor changed" << oendl;
1038 if( /*editor->edited() &&*/ /*edited && */!edited1) { 1041 if( /*editor->edited() &&*/ /*edited && */!edited1) {
1039 setCaption( "*"+caption()); 1042 setCaption( "*"+caption());
1040 edited1=true; 1043 edited1=true;
1041 } 1044 }
1042 edited=true; 1045 edited=true;
1043} 1046}
1044 1047
1045void TextEdit::receive(const QCString&msg, const QByteArray &) { 1048void TextEdit::receive(const QCString&msg, const QByteArray &) {
1046 qDebug("QCop "+msg); 1049 odebug << "QCop "+msg << oendl;
1047 if ( msg == "setDocument(QString)" ) { 1050 if ( msg == "setDocument(QString)" ) {
1048 qDebug("bugger all"); 1051 odebug << "bugger all" << oendl;
1049 1052
1050 } 1053 }
1051 1054
1052} 1055}
1053 1056
1054void TextEdit::doAbout() { 1057void TextEdit::doAbout() {
@@ -1126,13 +1129,13 @@ void TextEdit::timerCrank()
1126 { 1129 {
1127 currentFileName = QDir::homeDirPath()+"/textedit.tmp"; 1130 currentFileName = QDir::homeDirPath()+"/textedit.tmp";
1128 saveAs(); 1131 saveAs();
1129 } 1132 }
1130 else 1133 else
1131 { 1134 {
1132// qDebug("autosave"); 1135// odebug << "autosave" << oendl;
1133 save(); 1136 save();
1134 } 1137 }
1135 setTimer(); 1138 setTimer();
1136 } 1139 }
1137} 1140}
1138 1141
@@ -1142,24 +1145,24 @@ void TextEdit::doTimer(bool b)
1142 cfg.setGroup ( "View" ); 1145 cfg.setGroup ( "View" );
1143 cfg.writeEntry ( "autosave", b); 1146 cfg.writeEntry ( "autosave", b);
1144 featureAutoSave = b; 1147 featureAutoSave = b;
1145 nAutoSave->setOn(b); 1148 nAutoSave->setOn(b);
1146 if(b) 1149 if(b)
1147 { 1150 {
1148// qDebug("doTimer true"); 1151// odebug << "doTimer true" << oendl;
1149 setTimer(); 1152 setTimer();
1150 } 1153 }
1151// else 1154// else
1152// qDebug("doTimer false"); 1155// odebug << "doTimer false" << oendl;
1153} 1156}
1154 1157
1155void TextEdit::setTimer() 1158void TextEdit::setTimer()
1156{ 1159{
1157if(featureAutoSave) 1160if(featureAutoSave)
1158 { 1161 {
1159// qDebug("setting autosave"); 1162// odebug << "setting autosave" << oendl;
1160 QTimer *timer = new QTimer(this ); 1163 QTimer *timer = new QTimer(this );
1161 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); 1164 connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) );
1162 timer->start( 300000, true); //5 minutes 1165 timer->start( 300000, true); //5 minutes
1163 } 1166 }
1164} 1167}
1165 1168