summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/tinykate.cpp41
-rw-r--r--noncore/apps/tinykate/tinykate.h6
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
@@ -33,8 +33,9 @@
#include "pics/edit-redo.xpm"
#include <katedocument.h>
#include <katehighlight.h>
+#include <kateview.h>
TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
QMainWindow( parent, name, f )
{
@@ -70,12 +71,14 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
// Action for saving document
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
a = new QAction( tr( "Close" ), QPixmap(), QString::null, 0, this, 0 );
a->addTo(popup);
@@ -167,8 +170,9 @@ void TinyKate::open(const QString & filename)
void TinyKate::slotCurrentChanged( QWidget * view)
{
if (currentView) {
+
disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
@@ -196,9 +200,11 @@ void TinyKate::slotCurrentChanged( QWidget * view)
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++;
}
void TinyKate::slotClose( )
@@ -211,4 +217,37 @@ void TinyKate::slotClose( )
viewCount--;
if (!viewCount) slotNew();
}
+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,7 +1,7 @@
/***************************************************************************
tinykate.h
- Tiny KATE mainwindow
+ Tiny KATE mainwindow
-------------------
begin : November 2002
copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
***************************************************************************/
@@ -32,15 +32,17 @@ Q_OBJECT
public:
TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0);
public slots:
+ QString currentFileName;
void slotNew();
protected slots:
void slotOpen();
void slotClose();
void slotCurrentChanged(QWidget *);
-
+ void slotSave();
+ void slotSaveAs();
protected:
void open(const QString&);
private:
OTabWidget *tabwidget;