author | llornkcor <llornkcor> | 2002-12-26 03:49:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-26 03:49:11 (UTC) |
commit | e4e891190200cf26ba4bafcadca17f2473493276 (patch) (unidiff) | |
tree | 16d36e9a6253758c7da926e457cfb613775dae28 | |
parent | f736bf0ae774159a80a97b9492d7624e7caf07a3 (diff) | |
download | opie-e4e891190200cf26ba4bafcadca17f2473493276.zip opie-e4e891190200cf26ba4bafcadca17f2473493276.tar.gz opie-e4e891190200cf26ba4bafcadca17f2473493276.tar.bz2 |
hook up save and saveAs
-rw-r--r-- | noncore/apps/tinykate/tinykate.cpp | 41 | ||||
-rw-r--r-- | noncore/apps/tinykate/tinykate.h | 6 |
2 files changed, 44 insertions, 3 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index a823530..c8c3b31 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp | |||
@@ -31,12 +31,13 @@ | |||
31 | #include "pics/file-save.xpm" | 31 | #include "pics/file-save.xpm" |
32 | #include "pics/edit-undo.xpm" | 32 | #include "pics/edit-undo.xpm" |
33 | #include "pics/edit-redo.xpm" | 33 | #include "pics/edit-redo.xpm" |
34 | 34 | ||
35 | #include <katedocument.h> | 35 | #include <katedocument.h> |
36 | #include <katehighlight.h> | 36 | #include <katehighlight.h> |
37 | #include <kateview.h> | ||
37 | 38 | ||
38 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | 39 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : |
39 | QMainWindow( parent, name, f ) | 40 | QMainWindow( parent, name, f ) |
40 | { | 41 | { |
41 | nextUnnamed=0; | 42 | nextUnnamed=0; |
42 | currentView=0; | 43 | currentView=0; |
@@ -68,16 +69,18 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
68 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); | 69 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); |
69 | 70 | ||
70 | 71 | ||
71 | // Action for saving document | 72 | // Action for saving document |
72 | a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); | 73 | a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); |
73 | a->addTo(popup); | 74 | a->addTo(popup); |
75 | connect(a, SIGNAL(activated()), this, SLOT(slotSave())); | ||
74 | 76 | ||
75 | // Action for saving document to a new name | 77 | // Action for saving document to a new name |
76 | a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); | 78 | a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); |
77 | a->addTo(popup); | 79 | a->addTo(popup); |
80 | connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); | ||
78 | 81 | ||
79 | // Action for closing the currently active document | 82 | // Action for closing the currently active document |
80 | a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 ); | 83 | a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 ); |
81 | a->addTo(popup); | 84 | a->addTo(popup); |
82 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); | 85 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); |
83 | 86 | ||
@@ -165,12 +168,13 @@ void TinyKate::open(const QString & filename) | |||
165 | viewCount++; | 168 | viewCount++; |
166 | } | 169 | } |
167 | 170 | ||
168 | void TinyKate::slotCurrentChanged( QWidget * view) | 171 | void TinyKate::slotCurrentChanged( QWidget * view) |
169 | { | 172 | { |
170 | if (currentView) { | 173 | if (currentView) { |
174 | |||
171 | disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); | 175 | disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); |
172 | disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); | 176 | disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); |
173 | disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); | 177 | disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); |
174 | disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); | 178 | disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); |
175 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); | 179 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); |
176 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 180 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
@@ -194,13 +198,15 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
194 | } | 198 | } |
195 | 199 | ||
196 | void TinyKate::slotNew( ) | 200 | void TinyKate::slotNew( ) |
197 | { | 201 | { |
198 | KateDocument *kd= new KateDocument(false, false, this,0,this); | 202 | KateDocument *kd= new KateDocument(false, false, this,0,this); |
199 | KTextEditor::View *kv; | 203 | KTextEditor::View *kv; |
200 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),"tinykate/tinykate",tr("Unnamed %1").arg(nextUnnamed++)); | 204 | tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), |
205 | "tinykate/tinykate", | ||
206 | tr("Unnamed %1").arg(nextUnnamed++)); | ||
201 | viewCount++; | 207 | viewCount++; |
202 | } | 208 | } |
203 | 209 | ||
204 | void TinyKate::slotClose( ) | 210 | void TinyKate::slotClose( ) |
205 | { | 211 | { |
206 | if (currentView==0) return; | 212 | if (currentView==0) return; |
@@ -209,6 +215,39 @@ void TinyKate::slotClose( ) | |||
209 | tabwidget->removePage(dv); | 215 | tabwidget->removePage(dv); |
210 | delete dv->document(); | 216 | delete dv->document(); |
211 | viewCount--; | 217 | viewCount--; |
212 | if (!viewCount) slotNew(); | 218 | if (!viewCount) slotNew(); |
213 | } | 219 | } |
214 | 220 | ||
221 | void TinyKate::slotSave() { | ||
222 | // feel free to make this how you want | ||
223 | if (currentView==0) return; | ||
224 | |||
225 | // KateView *kv = (KateView*) currentView; | ||
226 | KateDocument *kd = (KateDocument*) currentView->document(); | ||
227 | // qDebug("saving file "+kd->docName()); | ||
228 | if( kd->docName().isEmpty()) | ||
229 | slotSaveAs(); | ||
230 | else | ||
231 | kd->saveFile(); | ||
232 | // kv->save(); | ||
233 | // kd->saveFile(); | ||
234 | } | ||
235 | |||
236 | void TinyKate::slotSaveAs() { | ||
237 | if (currentView==0) return; | ||
238 | KateDocument *kd = (KateDocument*) currentView->document(); | ||
239 | |||
240 | QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL); | ||
241 | if (!filename.isEmpty()) { | ||
242 | qDebug("saving file "+filename); | ||
243 | QFileInfo fi(filename); | ||
244 | QString filenamed = fi.fileName(); | ||
245 | kd->setDocFile( filename); | ||
246 | kd->setDocName( filenamed); | ||
247 | kd->saveFile(); | ||
248 | // KTextEditor::View *dv = currentView; | ||
249 | // tabwidget->changeTab( dv, filenamed); | ||
250 | // need to change tab label here | ||
251 | } | ||
252 | |||
253 | } | ||
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h index ef0dcba..7b61bae 100644 --- a/noncore/apps/tinykate/tinykate.h +++ b/noncore/apps/tinykate/tinykate.h | |||
@@ -1,9 +1,9 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | tinykate.h | 2 | tinykate.h |
3 | Tiny KATE mainwindow | 3 | Tiny KATE mainwindow |
4 | ------------------- | 4 | ------------------- |
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 | /*************************************************************************** |
@@ -30,19 +30,21 @@ class TinyKate : public QMainWindow | |||
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); | 33 | TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0); |
34 | 34 | ||
35 | public slots: | 35 | public slots: |
36 | QString currentFileName; | ||
36 | void slotNew(); | 37 | void slotNew(); |
37 | 38 | ||
38 | protected slots: | 39 | protected slots: |
39 | void slotOpen(); | 40 | void slotOpen(); |
40 | void slotClose(); | 41 | void slotClose(); |
41 | void slotCurrentChanged(QWidget *); | 42 | void slotCurrentChanged(QWidget *); |
42 | 43 | void slotSave(); | |
44 | void slotSaveAs(); | ||
43 | protected: | 45 | protected: |
44 | void open(const QString&); | 46 | void open(const QString&); |
45 | private: | 47 | private: |
46 | OTabWidget *tabwidget; | 48 | OTabWidget *tabwidget; |
47 | KTextEditor::View *currentView; | 49 | KTextEditor::View *currentView; |
48 | 50 | ||