Diffstat (limited to 'noncore/apps/tinykate/tinykate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/tinykate.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index 3c9a637..9865c35 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp | |||
@@ -5,36 +5,41 @@ | |||
5 | begin : November 2002 | 5 | begin : November 2002 |
6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free softwaSre; you can redistribute it and/or modify * | 11 | * This program is free softwaSre; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation. * | 13 | * the Free Software Foundation. * |
14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | #include <qaction.h> | ||
18 | #include <qtoolbutton.h> | ||
19 | #include <qmenubar.h> | ||
20 | #include <qpe/resource.h> | ||
21 | #include <qpe/qpeapplication.h> | ||
22 | 17 | ||
18 | #include "tinykate.h" | ||
19 | |||
20 | #include "katedocument.h" | ||
21 | #include "kglobal.h" | ||
22 | |||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
23 | #include <opie2/ofiledialog.h> | 25 | #include <opie2/ofiledialog.h> |
26 | #include <qpe/resource.h> | ||
27 | #include <qpe/qpeapplication.h> | ||
24 | 28 | ||
25 | #include "tinykate.h" | 29 | /* QT */ |
30 | #include <qaction.h> | ||
31 | #include <qtoolbutton.h> | ||
32 | #include <qmenubar.h> | ||
26 | 33 | ||
27 | #include <katedocument.h> | ||
28 | #include <kglobal.h> | ||
29 | 34 | ||
30 | using namespace Opie::Ui; | 35 | using namespace Opie::Ui; |
31 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | 36 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : |
32 | QMainWindow( parent, name, f ) | 37 | QMainWindow( parent, name, f ) |
33 | { | 38 | { |
34 | shutDown=false; | 39 | shutDown=false; |
35 | nextUnnamed=0; | 40 | nextUnnamed=0; |
36 | currentView=0; | 41 | currentView=0; |
37 | viewCount=0; | 42 | viewCount=0; |
38 | setCaption(tr("TinyKATE")); | 43 | setCaption(tr("TinyKATE")); |
39 | KGlobal::setAppName("TinyKATE"); | 44 | KGlobal::setAppName("TinyKATE"); |
40 | 45 | ||
@@ -143,54 +148,54 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
143 | 148 | ||
144 | 149 | ||
145 | utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); | 150 | utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); |
146 | utilSettings->addTo( popup); | 151 | utilSettings->addTo( popup); |
147 | 152 | ||
148 | if( qApp->argc() > 1) open(qApp->argv()[1]); | 153 | if( qApp->argc() > 1) open(qApp->argv()[1]); |
149 | else slotNew(); | 154 | else slotNew(); |
150 | 155 | ||
151 | } | 156 | } |
152 | 157 | ||
153 | TinyKate::~TinyKate( ) | 158 | TinyKate::~TinyKate( ) |
154 | { | 159 | { |
155 | qWarning("TinyKate destructor\n"); | 160 | owarn << "TinyKate destructor\n" << oendl; |
156 | 161 | ||
157 | shutDown=true; | 162 | shutDown=true; |
158 | while (currentView!=0) { | 163 | while (currentView!=0) { |
159 | slotClose(); | 164 | slotClose(); |
160 | } | 165 | } |
161 | 166 | ||
162 | if( KGlobal::config() != 0 ) { | 167 | if( KGlobal::config() != 0 ) { |
163 | qWarning("deleting KateConfig object..\n"); | 168 | owarn << "deleting KateConfig object..\n" << oendl; |
164 | delete KGlobal::config(); | 169 | delete KGlobal::config(); |
165 | } | 170 | } |
166 | } | 171 | } |
167 | 172 | ||
168 | void TinyKate::slotOpen( ) | 173 | void TinyKate::slotOpen( ) |
169 | { | 174 | { |
170 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 175 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
171 | QString::null); | 176 | QString::null); |
172 | if (!filename.isEmpty()) { | 177 | if (!filename.isEmpty()) { |
173 | open(filename); | 178 | open(filename); |
174 | } | 179 | } |
175 | } | 180 | } |
176 | 181 | ||
177 | void TinyKate::open(const QString & filename) | 182 | void TinyKate::open(const QString & filename) |
178 | { | 183 | { |
179 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 184 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
180 | KTextEditor::View *kv; | 185 | KTextEditor::View *kv; |
181 | QFileInfo fi(filename); | 186 | QFileInfo fi(filename); |
182 | QString filenamed = fi.fileName(); | 187 | QString filenamed = fi.fileName(); |
183 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); | 188 | tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); |
184 | qDebug(filename); | 189 | odebug << filename << oendl; |
185 | 190 | ||
186 | kd->setDocName( filenamed); | 191 | kd->setDocName( filenamed); |
187 | kd->open( filename ); | 192 | kd->open( filename ); |
188 | viewCount++; | 193 | viewCount++; |
189 | } | 194 | } |
190 | 195 | ||
191 | void TinyKate::setDocument(const QString& fileref) | 196 | void TinyKate::setDocument(const QString& fileref) |
192 | { | 197 | { |
193 | open( fileref ); | 198 | open( fileref ); |
194 | } | 199 | } |
195 | 200 | ||
196 | void TinyKate::slotCurrentChanged( QWidget * view) | 201 | void TinyKate::slotCurrentChanged( QWidget * view) |
@@ -240,40 +245,40 @@ void TinyKate::slotClose( ) | |||
240 | tabwidget->removePage(dv); | 245 | tabwidget->removePage(dv); |
241 | delete dv->document(); | 246 | delete dv->document(); |
242 | viewCount--; | 247 | viewCount--; |
243 | if ((!viewCount) && (!shutDown)) slotNew(); | 248 | if ((!viewCount) && (!shutDown)) slotNew(); |
244 | } | 249 | } |
245 | 250 | ||
246 | void TinyKate::slotSave() { | 251 | void TinyKate::slotSave() { |
247 | // feel free to make this how you want | 252 | // feel free to make this how you want |
248 | if (currentView==0) return; | 253 | if (currentView==0) return; |
249 | 254 | ||
250 | // KateView *kv = (KateView*) currentView; | 255 | // KateView *kv = (KateView*) currentView; |
251 | KateDocument *kd = (KateDocument*) currentView->document(); | 256 | KateDocument *kd = (KateDocument*) currentView->document(); |
252 | // qDebug("saving file "+kd->docName()); | 257 | // odebug << "saving file "+kd->docName() << oendl; |
253 | if( kd->docName().isEmpty()) | 258 | if( kd->docName().isEmpty()) |
254 | slotSaveAs(); | 259 | slotSaveAs(); |
255 | else | 260 | else |
256 | kd->saveFile(); | 261 | kd->saveFile(); |
257 | // kv->save(); | 262 | // kv->save(); |
258 | // kd->saveFile(); | 263 | // kd->saveFile(); |
259 | } | 264 | } |
260 | 265 | ||
261 | void TinyKate::slotSaveAs() { | 266 | void TinyKate::slotSaveAs() { |
262 | if (currentView==0) return; | 267 | if (currentView==0) return; |
263 | KateDocument *kd = (KateDocument*) currentView->document(); | 268 | KateDocument *kd = (KateDocument*) currentView->document(); |
264 | 269 | ||
265 | QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, | 270 | QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, |
266 | QString::null); | 271 | QString::null); |
267 | if (!filename.isEmpty()) { | 272 | if (!filename.isEmpty()) { |
268 | qDebug("saving file "+filename); | 273 | odebug << "saving file "+filename << oendl; |
269 | QFileInfo fi(filename); | 274 | QFileInfo fi(filename); |
270 | QString filenamed = fi.fileName(); | 275 | QString filenamed = fi.fileName(); |
271 | kd->setDocFile( filename); | 276 | kd->setDocFile( filename); |
272 | kd->setDocName( filenamed); | 277 | kd->setDocName( filenamed); |
273 | kd->saveFile(); | 278 | kd->saveFile(); |
274 | // KTextEditor::View *dv = currentView; | 279 | // KTextEditor::View *dv = currentView; |
275 | // tabwidget->changeTab( dv, filenamed); | 280 | // tabwidget->changeTab( dv, filenamed); |
276 | // need to change tab label here | 281 | // need to change tab label here |
277 | } | 282 | } |
278 | 283 | ||
279 | } | 284 | } |