author | llornkcor <llornkcor> | 2002-12-26 03:49:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-26 03:49:11 (UTC) |
commit | e4e891190200cf26ba4bafcadca17f2473493276 (patch) (side-by-side diff) | |
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 @@ -35,4 +35,5 @@ #include <katedocument.h> #include <katehighlight.h> +#include <kateview.h> TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : @@ -72,8 +73,10 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : a = new QAction( tr( "Save" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); a->addTo(popup); + connect(a, SIGNAL(activated()), this, SLOT(slotSave())); // Action for saving document to a new name a = new QAction( tr( "Save As" ), QPixmap((const char**)file_save_xpm), QString::null, 0, this, 0 ); a->addTo(popup); + connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); // Action for closing the currently active document @@ -169,4 +172,5 @@ void TinyKate::slotCurrentChanged( QWidget * view) { if (currentView) { + disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); @@ -198,5 +202,7 @@ void TinyKate::slotNew( ) KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; - tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),"tinykate/tinykate",tr("Unnamed %1").arg(nextUnnamed++)); + tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), + "tinykate/tinykate", + tr("Unnamed %1").arg(nextUnnamed++)); viewCount++; } @@ -213,2 +219,35 @@ void TinyKate::slotClose( ) } +void TinyKate::slotSave() { + // feel free to make this how you want + if (currentView==0) return; + + // KateView *kv = (KateView*) currentView; + KateDocument *kd = (KateDocument*) currentView->document(); + // qDebug("saving file "+kd->docName()); + if( kd->docName().isEmpty()) + slotSaveAs(); + else + kd->saveFile(); + // kv->save(); + // kd->saveFile(); +} + +void TinyKate::slotSaveAs() { + if (currentView==0) return; + KateDocument *kd = (KateDocument*) currentView->document(); + + QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL); + if (!filename.isEmpty()) { + qDebug("saving file "+filename); + QFileInfo fi(filename); + QString filenamed = fi.fileName(); + kd->setDocFile( filename); + kd->setDocName( filenamed); + kd->saveFile(); +// KTextEditor::View *dv = currentView; +// tabwidget->changeTab( dv, filenamed); + // need to change tab label here + } + +} 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,5 +1,5 @@ /*************************************************************************** tinykate.h - Tiny KATE mainwindow + Tiny KATE mainwindow ------------------- begin : November 2002 @@ -34,4 +34,5 @@ public: public slots: + QString currentFileName; void slotNew(); @@ -40,5 +41,6 @@ protected slots: void slotClose(); void slotCurrentChanged(QWidget *); - + void slotSave(); + void slotSaveAs(); protected: void open(const QString&); |