summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/tinykate.cpp
authormickeyl <mickeyl>2004-05-23 11:26:00 (UTC)
committer mickeyl <mickeyl>2004-05-23 11:26:00 (UTC)
commit163a07abb5fbf5346585bce5edf5e48d015b442a (patch) (unidiff)
tree0ae95b1f32ded0e1766b240ccfcfec856dafea09 /noncore/apps/tinykate/tinykate.cpp
parent6cd90404121a78f3181a35acc056d7feca3d6aeb (diff)
downloadopie-163a07abb5fbf5346585bce5edf5e48d015b442a.zip
opie-163a07abb5fbf5346585bce5edf5e48d015b442a.tar.gz
opie-163a07abb5fbf5346585bce5edf5e48d015b442a.tar.bz2
CLEANUP: sanitize tinykate's build structure
Diffstat (limited to 'noncore/apps/tinykate/tinykate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/tinykate.cpp284
1 files changed, 0 insertions, 284 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp
deleted file mode 100644
index 9865c35..0000000
--- a/noncore/apps/tinykate/tinykate.cpp
+++ b/dev/null
@@ -1,284 +0,0 @@
1/***************************************************************************
2 tinykate.cpp
3 Tiny KATE mainwindow
4 -------------------
5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * *
16 ***************************************************************************/
17
18#include "tinykate.h"
19
20#include "katedocument.h"
21#include "kglobal.h"
22
23/* OPIE */
24#include <opie2/odebug.h>
25#include <opie2/ofiledialog.h>
26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h>
28
29/* QT */
30#include <qaction.h>
31#include <qtoolbutton.h>
32#include <qmenubar.h>
33
34
35using namespace Opie::Ui;
36TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
37 QMainWindow( parent, name, f )
38{
39 shutDown=false;
40 nextUnnamed=0;
41 currentView=0;
42 viewCount=0;
43 setCaption(tr("TinyKATE"));
44 KGlobal::setAppName("TinyKATE");
45
46 QMenuBar *mb = new QMenuBar( this );
47 mb->setMargin( 0 );
48
49 tabwidget=new OTabWidget(this);
50 setCentralWidget(tabwidget);
51 connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*)));
52
53//FILE ACTIONS
54 QPopupMenu *popup = new QPopupMenu( this );
55
56 // Action for creating a new document
57 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
58 a->addTo( popup );
59 connect(a, SIGNAL(activated()), this, SLOT(slotNew()));
60
61 // Action for opening an exisiting document
62 a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 );
63 a->addTo(popup);
64 connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
65
66
67 // Action for saving document
68 a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 );
69 a->addTo(popup);
70 connect(a, SIGNAL(activated()), this, SLOT(slotSave()));
71
72 // Action for saving document to a new name
73 a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 );
74 a->addTo(popup);
75 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));
76
77 // Action for closing the currently active document
78 a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 );
79 a->addTo(popup);
80 connect(a, SIGNAL(activated()), this, SLOT(slotClose()));
81
82
83 mb->insertItem(tr("File"),popup);
84
85//EDIT ACTIONS
86
87 // Action for cutting text
88 editCut = new QToolButton( 0 );
89 editCut->setAutoRaise( true );
90 editCut->setIconSet( Resource::loadPixmap( "cut" ) );
91
92 // Action for Copying text
93 editCopy = new QToolButton( 0 );
94 editCopy->setAutoRaise( true );
95 editCopy->setIconSet( Resource::loadPixmap( "copy" ) );
96
97 // Action for pasting text
98 editPaste = new QToolButton( 0 );
99 editPaste->setAutoRaise( true );
100 editPaste->setIconSet( Resource::loadPixmap( "paste" ) );
101
102 // Action for finding / replacing text
103 editFindReplace = new QToolButton( 0 );
104 editFindReplace->setAutoRaise( true );
105 editFindReplace->setIconSet( Resource::loadPixmap("find") );
106
107 // Action for undo
108 editUndo = new QToolButton( 0 );
109 editUndo->setAutoRaise( true );
110 editUndo->setIconSet( Resource::loadPixmap( "undo" ) );
111
112 // Action for redo
113 editRedo = new QToolButton( 0 );
114 editRedo->setAutoRaise( true );
115 editRedo->setIconSet( Resource::loadPixmap( "redo" ) );
116
117//VIEW ACITONS
118 popup = new QPopupMenu( this );
119
120 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
121 viewIncFontSizes->addTo( popup );
122
123 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
124 viewDecFontSizes->addTo( popup );
125
126 mb->insertItem(tr("View"),popup);
127
128 popup = new QPopupMenu( this );
129 mb->insertItem(tr("Utils"),popup);
130
131
132 mb->insertItem( editCut );
133 mb->insertItem( editCopy );
134 mb->insertItem( editPaste );
135 mb->insertItem( editFindReplace );
136 mb->insertItem( editUndo );
137 mb->insertItem( editRedo );
138
139
140//Highlight management
141 hlmenu=new QPopupMenu(this);
142 HlManager *hlm=HlManager::self();
143 for (int i=0;i<hlm->highlights();i++)
144 {
145 hlmenu->insertItem(hlm->hlName(i),i);
146 }
147 popup->insertItem(tr("Highlighting"),hlmenu);
148
149
150 utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 );
151 utilSettings->addTo( popup);
152
153 if( qApp->argc() > 1) open(qApp->argv()[1]);
154 else slotNew();
155
156}
157
158TinyKate::~TinyKate( )
159{
160 owarn << "TinyKate destructor\n" << oendl;
161
162 shutDown=true;
163 while (currentView!=0) {
164 slotClose();
165 }
166
167 if( KGlobal::config() != 0 ) {
168 owarn << "deleting KateConfig object..\n" << oendl;
169 delete KGlobal::config();
170 }
171}
172
173void TinyKate::slotOpen( )
174{
175 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
176 QString::null);
177 if (!filename.isEmpty()) {
178 open(filename);
179 }
180}
181
182void TinyKate::open(const QString & filename)
183{
184 KateDocument *kd= new KateDocument(false, false, this,0,this);
185 KTextEditor::View *kv;
186 QFileInfo fi(filename);
187 QString filenamed = fi.fileName();
188 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed );
189 odebug << filename << oendl;
190
191 kd->setDocName( filenamed);
192 kd->open( filename );
193 viewCount++;
194}
195
196void TinyKate::setDocument(const QString& fileref)
197{
198 open( fileref );
199}
200
201void TinyKate::slotCurrentChanged( QWidget * view)
202{
203 if (currentView) {
204
205 disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy()));
206 disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut()));
207 disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste()));
208 disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo()));
209 disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo()));
210 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
211 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
212 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
213 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
214 }
215
216 currentView=(KTextEditor::View*)view;
217
218 connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy()));
219 connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut()));
220 connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste()));
221 connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo()));
222 connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo()));
223 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
224 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
225 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
226 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
227
228}
229
230void TinyKate::slotNew( )
231{
232 KateDocument *kd= new KateDocument(false, false, this,0,this);
233 KTextEditor::View *kv;
234 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"),
235 "tinykate/tinykate",
236 tr("Unnamed %1").arg(nextUnnamed++));
237 viewCount++;
238}
239
240void TinyKate::slotClose( )
241{
242 if (currentView==0) return;
243 KTextEditor::View *dv=currentView;
244 currentView=0;
245 tabwidget->removePage(dv);
246 delete dv->document();
247 viewCount--;
248 if ((!viewCount) && (!shutDown)) slotNew();
249}
250
251void TinyKate::slotSave() {
252 // feel free to make this how you want
253 if (currentView==0) return;
254
255 // KateView *kv = (KateView*) currentView;
256 KateDocument *kd = (KateDocument*) currentView->document();
257 // odebug << "saving file "+kd->docName() << oendl;
258 if( kd->docName().isEmpty())
259 slotSaveAs();
260 else
261 kd->saveFile();
262 // kv->save();
263 // kd->saveFile();
264}
265
266void TinyKate::slotSaveAs() {
267 if (currentView==0) return;
268 KateDocument *kd = (KateDocument*) currentView->document();
269
270 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL,
271 QString::null);
272 if (!filename.isEmpty()) {
273 odebug << "saving file "+filename << oendl;
274 QFileInfo fi(filename);
275 QString filenamed = fi.fileName();
276 kd->setDocFile( filename);
277 kd->setDocName( filenamed);
278 kd->saveFile();
279// KTextEditor::View *dv = currentView;
280// tabwidget->changeTab( dv, filenamed);
281 // need to change tab label here
282 }
283
284}