author | llornkcor <llornkcor> | 2003-06-14 17:39:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-06-14 17:39:26 (UTC) |
commit | e2a1c237211e4009ce2b76d3adc3860fbb255732 (patch) (unidiff) | |
tree | 6d76151c961368c111f478fe58cb367424c6e2c6 /noncore/apps/tinykate/tinykate.cpp | |
parent | 437e389cc5cca518c5f26677f98c464f9255ec04 (diff) | |
download | opie-e2a1c237211e4009ce2b76d3adc3860fbb255732.zip opie-e2a1c237211e4009ce2b76d3adc3860fbb255732.tar.gz opie-e2a1c237211e4009ce2b76d3adc3860fbb255732.tar.bz2 |
changes by craig graham. please test to make sure nothing important was taken out.
Diffstat (limited to 'noncore/apps/tinykate/tinykate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/tinykate.cpp | 157 |
1 files changed, 101 insertions, 56 deletions
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index ea7ea45..dda8405 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp | |||
@@ -10,3 +10,3 @@ | |||
10 | * * | 10 | * * |
11 | * This program is free softwaSre; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
@@ -19,4 +19,4 @@ | |||
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qtoolbutton.h> | 20 | #include <qpe/qpetoolbar.h> |
21 | #include <qmenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
@@ -27,2 +27,4 @@ | |||
27 | 27 | ||
28 | #include "cgotoline.h" | ||
29 | |||
28 | #include "tinykate.h" | 30 | #include "tinykate.h" |
@@ -36,3 +38,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
36 | QMainWindow( parent, name, f ) | 38 | QMainWindow( parent, name, f ) |
37 | { | 39 | { |
38 | nextUnnamed=0; | 40 | nextUnnamed=0; |
@@ -40,7 +42,13 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
40 | viewCount=0; | 42 | viewCount=0; |
41 | setCaption(tr("TinyKATE")); | 43 | setCaption("TinyKATE : line 1 col 1"); |
42 | KGlobal::setAppName("TinyKATE"); | 44 | KGlobal::setAppName("TinyKATE"); |
43 | 45 | ||
44 | QMenuBar *mb = new QMenuBar( this ); | 46 | curLine=curCol=1; |
45 | mb->setMargin( 0 ); | 47 | |
48 | setToolBarsMovable(FALSE); | ||
49 | |||
50 | QPEToolBar *bar = new QPEToolBar( this ); | ||
51 | bar->setHorizontalStretchable( TRUE ); | ||
52 | QPEMenuBar *mb = new QPEMenuBar( bar ); | ||
53 | mb->setMargin( 0 ); | ||
46 | 54 | ||
@@ -54,3 +62,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
54 | // Action for creating a new document | 62 | // Action for creating a new document |
55 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 63 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, CTRL+Key_N, this, 0 ); |
56 | a->addTo( popup ); | 64 | a->addTo( popup ); |
@@ -59,3 +67,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
59 | // Action for opening an exisiting document | 67 | // Action for opening an exisiting document |
60 | a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); | 68 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, CTRL+Key_O, this, 0 ); |
61 | a->addTo(popup); | 69 | a->addTo(popup); |
@@ -65,3 +73,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
65 | // Action for saving document | 73 | // Action for saving document |
66 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); | 74 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ), QString::null, CTRL+Key_S, this, 0 ); |
67 | a->addTo(popup); | 75 | a->addTo(popup); |
@@ -70,3 +78,3 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
70 | // Action for saving document to a new name | 78 | // Action for saving document to a new name |
71 | a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); | 79 | a = new QAction( tr( "Save As" ), Resource::loadPixmap( "save" ), QString::null, 0, this, 0 ); |
72 | a->addTo(popup); | 80 | a->addTo(popup); |
@@ -75,6 +83,6 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
75 | // Action for closing the currently active document | 83 | // Action for closing the currently active document |
76 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); | 84 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "close" ), QString::null, CTRL+Key_W, this, 0 ); |
77 | a->addTo(popup); | 85 | a->addTo(popup); |
78 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); | 86 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); |
79 | 87 | ||
80 | 88 | ||
@@ -85,30 +93,27 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
85 | // Action for cutting text | 93 | // Action for cutting text |
86 | editCut = new QToolButton( 0 ); | 94 | editCut = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, CTRL+Key_X, this, 0 ); |
87 | editCut->setAutoRaise( true ); | 95 | editCut->addTo( bar ); |
88 | editCut->setIconSet( Resource::loadPixmap( "cut" ) ); | ||
89 | 96 | ||
90 | // Action for Copying text | 97 | // Action for Copying text |
91 | editCopy = new QToolButton( 0 ); | 98 | editCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, CTRL+Key_C, this, 0 ); |
92 | editCopy->setAutoRaise( true ); | 99 | editCopy->addTo( bar ); |
93 | editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); | ||
94 | 100 | ||
95 | // Action for pasting text | 101 | // Action for pasting text |
96 | editPaste = new QToolButton( 0 ); | 102 | editPaste = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, CTRL+Key_V, this, 0 ); |
97 | editPaste->setAutoRaise( true ); | 103 | editPaste->addTo( bar ); |
98 | editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); | 104 | |
99 | 105 | ||
100 | // Action for finding / replacing text | 106 | // Action for finding / replacing text |
101 | editFindReplace = new QToolButton( 0 ); | 107 | editFindReplace = new QAction( tr( "Replace" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_R, this, 0 ); |
102 | editFindReplace->setAutoRaise( true ); | 108 | editFind = new QAction( tr( "Find" ), Resource::loadPixmap("find"), QString::null, CTRL+Key_F, this, 0 ); |
103 | editFindReplace->setIconSet( Resource::loadPixmap("find") ); | 109 | editFind->addTo( bar ); |
104 | 110 | ||
105 | // Action for undo | 111 | // Action for undo |
106 | editUndo = new QToolButton( 0 ); | 112 | editUndo = new QAction( tr( "Undo" ), Resource::loadPixmap( "undo" ), QString::null, CTRL+Key_Z, this, 0 ); |
107 | editUndo->setAutoRaise( true ); | 113 | editUndo->addTo( bar ); |
108 | editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); | ||
109 | 114 | ||
110 | // Action for redo | 115 | // Action for redo |
111 | editRedo = new QToolButton( 0 ); | 116 | editRedo = new QAction( tr( "Redo" ), Resource::loadPixmap( "redo" ), QString::null, CTRL+SHIFT+Key_Z, this, 0 ); |
112 | editRedo->setAutoRaise( true ); | 117 | editRedo->addTo( bar ); |
113 | editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); | 118 | |
114 | 119 | ||
@@ -116,3 +121,7 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
116 | popup = new QPopupMenu( this ); | 121 | popup = new QPopupMenu( this ); |
117 | 122 | ||
123 | a = new QAction( tr( "Goto" ), QString::null, CTRL+Key_G, this, 0 ); | ||
124 | a->addTo( popup ); | ||
125 | connect(a, SIGNAL(activated()), this, SLOT(slotGoTo())); | ||
126 | |||
118 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); | 127 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); |
@@ -123,15 +132,8 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
123 | 132 | ||
124 | mb->insertItem(tr("View"),popup); | 133 | mb->insertItem(tr("View"),popup); |
125 | |||
126 | popup = new QPopupMenu( this ); | ||
127 | mb->insertItem(tr("Utils"),popup); | ||
128 | 134 | ||
129 | 135 | ||
130 | mb->insertItem( editCut ); | ||
131 | mb->insertItem( editCopy ); | ||
132 | mb->insertItem( editPaste ); | ||
133 | mb->insertItem( editFindReplace ); | ||
134 | mb->insertItem( editUndo ); | ||
135 | mb->insertItem( editRedo ); | ||
136 | 136 | ||
137 | popup = new QPopupMenu( this ); | ||
138 | mb->insertItem(tr("Utils"),popup); | ||
137 | 139 | ||
@@ -150,2 +152,6 @@ TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | |||
150 | 152 | ||
153 | popup->insertSeparator(); | ||
154 | editFind->addTo(popup); | ||
155 | editFindReplace->addTo(popup); | ||
156 | |||
151 | if( qApp->argc() > 1) open(qApp->argv()[1]); | 157 | if( qApp->argc() > 1) open(qApp->argv()[1]); |
@@ -158,3 +164,5 @@ TinyKate::~TinyKate( ) | |||
158 | qWarning("TinyKate destructor\n"); | 164 | qWarning("TinyKate destructor\n"); |
165 | printf("~TinyKate()\n"); | ||
159 | if( KGlobal::config() != 0 ) { | 166 | if( KGlobal::config() != 0 ) { |
167 | printf("~TinyKate(): delete configs...\n"); | ||
160 | qWarning("deleting KateConfig object..\n"); | 168 | qWarning("deleting KateConfig object..\n"); |
@@ -167,3 +175,3 @@ void TinyKate::slotOpen( ) | |||
167 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 175 | QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
168 | QPEApplication::documentDir()); | 176 | QString::null); |
169 | if (!filename.isEmpty()) { | 177 | if (!filename.isEmpty()) { |
@@ -187,5 +195,6 @@ void TinyKate::open(const QString & filename) | |||
187 | 195 | ||
188 | void TinyKate::setDocument(const QString& fileref) | 196 | void TinyKate::setDocument(const QString &doc) |
189 | { | 197 | { |
190 | open( fileref ); | 198 | printf("tinykate: setDocument(\"%s\")\n",(const char*)doc); |
199 | open(doc); | ||
191 | } | 200 | } |
@@ -201,6 +210,9 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
201 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); | 210 | disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); |
202 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 211 | disconnect(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); |
203 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | 212 | disconnect(editFind,SIGNAL(activated()),currentView,SLOT(find())); |
213 | disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | ||
214 | disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); | ||
204 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); | 215 | disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); |
205 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 216 | disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
217 | disconnect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); | ||
206 | } | 218 | } |
@@ -208,8 +220,10 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
208 | currentView=(KTextEditor::View*)view; | 220 | currentView=(KTextEditor::View*)view; |
209 | 221 | ||
210 | connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); | 222 | connect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); |
211 | connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); | 223 | connect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); |
212 | connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); | 224 | connect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); |
213 | connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); | 225 | connect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); |
214 | connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); | 226 | connect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); |
227 | connect(editFindReplace,SIGNAL(activated()),currentView,SLOT(replace())); | ||
228 | connect(editFind,SIGNAL(activated()),currentView,SLOT(find())); | ||
215 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); | 229 | connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); |
@@ -218,3 +232,3 @@ void TinyKate::slotCurrentChanged( QWidget * view) | |||
218 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); | 232 | connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); |
219 | 233 | connect(currentView,SIGNAL(newCurPos()),this,SLOT(slotCursorMoved())); | |
220 | } | 234 | } |
@@ -262,3 +276,3 @@ void TinyKate::slotSaveAs() { | |||
262 | QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, | 276 | QString filename=OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, |
263 | QPEApplication::documentDir()); | 277 | QString::null); |
264 | if (!filename.isEmpty()) { | 278 | if (!filename.isEmpty()) { |
@@ -276 +290,32 @@ void TinyKate::slotSaveAs() { | |||
276 | } | 290 | } |
291 | |||
292 | void TinyKate::slotGoTo() | ||
293 | { | ||
294 | int l,c; | ||
295 | if (currentView==0) return; | ||
296 | |||
297 | currentView->getCursorPosition(&l,&c); | ||
298 | |||
299 | CGotoLine g(l); | ||
300 | |||
301 | if(g.exec()==QDialog::Accepted) | ||
302 | { | ||
303 | currentView->setCursorPosition( g.line(), c ); | ||
304 | } | ||
305 | } | ||
306 | |||
307 | void TinyKate::slotCursorMoved() | ||
308 | { | ||
309 | char buf[100]; | ||
310 | int newLine,newCol; | ||
311 | currentView->getCursorPosition(&newLine,&newCol); | ||
312 | newLine++; | ||
313 | newCol++; | ||
314 | if((newLine!=curLine)||(newCol!=curCol)) | ||
315 | { | ||
316 | sprintf(buf,"TinyKATE : line %-6d col %d",newLine,newCol); | ||
317 | setCaption(buf); | ||
318 | curLine=newLine; | ||
319 | curCol=newCol; | ||
320 | } | ||
321 | } | ||