summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/tinykate.cpp24
-rw-r--r--noncore/apps/tinykate/tinykate.h9
2 files changed, 25 insertions, 8 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
index 03c6e50..f177e47 100644
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/noncore/apps/tinykate/tinykate.cpp
@@ -20,8 +20,9 @@
#include <qpe/qpetoolbar.h>
#include <qpe/qpemenubar.h>
#include <qpe/resource.h>
#include <qpe/global.h>
+#include <qpe/qpeapplication.h>
#include <opie/ofiledialog.h>
#include "tinykate.h"
@@ -35,10 +36,12 @@
#include <katehighlight.h>
TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
QMainWindow( parent, name, f )
-{
+{
+ nextUnnamed=0;
currentView=0;
+ viewCount=0;
setCaption(tr("TinyKATE"));
setToolBarsMovable(FALSE);
@@ -136,21 +139,30 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
utilSettings->addTo( popup);
+ if( qApp->argc() > 1) open(qApp->argv()[1]);
+ else slotNew();
+
}
void TinyKate::slotOpen( )
{
QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL);
if (!filename.isEmpty()) {
+ open(filename);
+ }
+}
+
+void TinyKate::open(const QString & filename)
+{
KateDocument *kd= new KateDocument(false, false, this,0,this);
KTextEditor::View *kv;
- tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"BLAH","BLAH");
+ tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate","BLAH");
qDebug(filename);
kd->open(filename);
- }
+ viewCount++;
}
void TinyKate::slotCurrentChanged( QWidget * view)
{
@@ -183,10 +195,10 @@ 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"),"BLAH",tr("Unnamed %1").arg(0));
-
+ tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),"tinykate/tinykate",tr("Unnamed %1").arg(nextUnnamed++));
+ viewCount++;
}
void TinyKate::slotClose( )
{
@@ -194,6 +206,8 @@ void TinyKate::slotClose( )
KTextEditor::View *dv=currentView;
currentView=0;
tabwidget->removePage(dv);
delete dv->document();
+ viewCount--;
+ if (!viewCount) slotNew();
}
diff --git a/noncore/apps/tinykate/tinykate.h b/noncore/apps/tinykate/tinykate.h
index 6dda05d..ef0dcba 100644
--- a/noncore/apps/tinykate/tinykate.h
+++ b/noncore/apps/tinykate/tinykate.h
@@ -32,15 +32,17 @@ Q_OBJECT
public:
TinyKate( QWidget *parent=0, const char *name=0, WFlags f = 0);
public slots:
- void slotOpen();
+ void slotNew();
protected slots:
- void slotNew();
+ void slotOpen();
void slotClose();
void slotCurrentChanged(QWidget *);
+protected:
+ void open(const QString&);
private:
OTabWidget *tabwidget;
KTextEditor::View *currentView;
@@ -54,9 +56,10 @@ private:
QAction *viewDecFontSizes;
QAction *utilSettings;
QPopupMenu *hlmenu;
-
+ uint nextUnnamed;
+ uint viewCount;
};
#endif // __TINYKATE_H__