summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/document
Unidiff
Diffstat (limited to 'noncore/apps/tinykate/libkate/document') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedialogs.cpp6
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp2
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedialogs.cpp b/noncore/apps/tinykate/libkate/document/katedialogs.cpp
index 2f0ed7b..f4edd7e 100644
--- a/noncore/apps/tinykate/libkate/document/katedialogs.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedialogs.cpp
@@ -1,162 +1,162 @@
1/*************************************************************************** 1/***************************************************************************
2 katedialogs.cpp - description 2 katedialogs.cpp - description
3 ------------------- 3 -------------------
4 copyright : (C) 2001 by The Kate Team 4 copyright : (C) 2001 by The Kate Team
5 (C) 2002 by Joseph Wenninger 5 (C) 2002 by Joseph Wenninger
6 email : kwrite-devel@kde.org 6 email : kwrite-devel@kde.org
7 jowenn@kde.org 7 jowenn@kde.org
8 8
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19#include "katedialogs.h" 19#include "katedialogs.h"
20#include <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qgroupbox.h> 22#include <qgroupbox.h>
23#include <qvgroupbox.h> 23#include <qvgroupbox.h>
24#include <qhgroupbox.h> 24#include <qhgroupbox.h>
25#include <qhbox.h> 25#include <qhbox.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qwidgetstack.h> 29#include <qwidgetstack.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35//FIXME #include <kcharsets.h> 35//FIXME #include <kcharsets.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <qmap.h> 37#include <qmap.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#include <kstddirs.h> 39#include <kstddirs.h>
40 40
41 41
42/******************************************************************************************************************* 42/*******************************************************************************************************************
43* Context Editor * 43* Context Editor *
44*******************************************************************************************************************/ 44*******************************************************************************************************************/
45 45
46StyleChanger::StyleChanger( QWidget *parent ) 46StyleChanger::StyleChanger( QWidget *parent )
47 : QWidget(parent) 47 : QWidget(parent)
48{ 48{
49 QLabel *label; 49 QLabel *label;
50 50
51 QGridLayout *glay = new QGridLayout( this, 4, 3, 0, KDialog::spacingHint() ); 51 QGridLayout *glay = new QGridLayout( this, 4, 3, 0, KDialog::spacingHint() );
52 CHECK_PTR(glay); 52 CHECK_PTR(glay);
53 glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better 53 glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better
54 glay->setColStretch( 2, 10 ); 54 glay->setColStretch( 2, 10 );
55 55
56 col = new KColorButton(this); 56 col = new KColorButton(this);
57 CHECK_PTR(col); 57 CHECK_PTR(col);
58 connect(col,SIGNAL(changed(const QColor &)),this,SLOT(changed())); 58 connect(col,SIGNAL(changed(const QColor&)),this,SLOT(changed()));
59 label = new QLabel(col,i18n("Normal:"),this); 59 label = new QLabel(col,i18n("Normal:"),this);
60 CHECK_PTR(label); 60 CHECK_PTR(label);
61 glay->addWidget(label,0,0); 61 glay->addWidget(label,0,0);
62 glay->addWidget(col,1,0); 62 glay->addWidget(col,1,0);
63 63
64 selCol = new KColorButton(this); 64 selCol = new KColorButton(this);
65 CHECK_PTR(selCol); 65 CHECK_PTR(selCol);
66 connect(selCol,SIGNAL(changed(const QColor &)),this,SLOT(changed())); 66 connect(selCol,SIGNAL(changed(const QColor&)),this,SLOT(changed()));
67 label = new QLabel(selCol,i18n("Selected:"),this); 67 label = new QLabel(selCol,i18n("Selected:"),this);
68 CHECK_PTR(label); 68 CHECK_PTR(label);
69 glay->addWidget(label,2,0); 69 glay->addWidget(label,2,0);
70 glay->addWidget(selCol,3,0); 70 glay->addWidget(selCol,3,0);
71 71
72 bold = new QCheckBox(i18n("Bold"),this); 72 bold = new QCheckBox(i18n("Bold"),this);
73 CHECK_PTR(bold); 73 CHECK_PTR(bold);
74 connect(bold,SIGNAL(clicked()),SLOT(changed())); 74 connect(bold,SIGNAL(clicked()),SLOT(changed()));
75 glay->addWidget(bold,1,2); 75 glay->addWidget(bold,1,2);
76 76
77 italic = new QCheckBox(i18n("Italic"),this); 77 italic = new QCheckBox(i18n("Italic"),this);
78 CHECK_PTR(italic); 78 CHECK_PTR(italic);
79 connect(italic,SIGNAL(clicked()),SLOT(changed())); 79 connect(italic,SIGNAL(clicked()),SLOT(changed()));
80 glay->addWidget(italic,2,2); 80 glay->addWidget(italic,2,2);
81} 81}
82 82
83void StyleChanger::setRef(ItemStyle *s) { 83void StyleChanger::setRef(ItemStyle *s) {
84 84
85 style = s; 85 style = s;
86 col->setColor(style->col); 86 col->setColor(style->col);
87 selCol->setColor(style->selCol); 87 selCol->setColor(style->selCol);
88 bold->setChecked(style->bold); 88 bold->setChecked(style->bold);
89 italic->setChecked(style->italic); 89 italic->setChecked(style->italic);
90 90
91} 91}
92 92
93void StyleChanger::setEnabled(bool enable) { 93void StyleChanger::setEnabled(bool enable) {
94 94
95 col->setEnabled(enable); 95 col->setEnabled(enable);
96 selCol->setEnabled(enable); 96 selCol->setEnabled(enable);
97 bold->setEnabled(enable); 97 bold->setEnabled(enable);
98 italic->setEnabled(enable); 98 italic->setEnabled(enable);
99} 99}
100 100
101void StyleChanger::changed() { 101void StyleChanger::changed() {
102 102
103 if (style) { 103 if (style) {
104 style->col = col->color(); 104 style->col = col->color();
105 style->selCol = selCol->color(); 105 style->selCol = selCol->color();
106 style->bold = bold->isChecked(); 106 style->bold = bold->isChecked();
107 style->italic = italic->isChecked(); 107 style->italic = italic->isChecked();
108 } 108 }
109} 109}
110 110
111HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList, 111HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList,
112 HlDataList *highlightDataList, 112 HlDataList *highlightDataList,
113 int hlNumber, QWidget *parent, 113 int hlNumber, QWidget *parent,
114 const char *name, bool modal ) 114 const char *name, bool modal )
115 :KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok) 115 :KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok)
116{ 116{
117// QVBox *page = makeVBoxMainWidget(); 117// QVBox *page = makeVBoxMainWidget();
118 QFrame *page=addPage("FIXME"); 118 QFrame *page=addPage("FIXME");
119 (new QVBoxLayout(page))->setAutoAdd(true); 119 (new QVBoxLayout(page))->setAutoAdd(true);
120 content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page); 120 content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page);
121} 121}
122 122
123void HighlightDialog::done(int r) 123void HighlightDialog::done(int r)
124{ 124{
125 kdDebug(13010)<<"HighlightDialod done"<<endl; 125 kdDebug(13010)<<"HighlightDialod done"<<endl;
126 content->saveData(); 126 content->saveData();
127 KDialogBase::done(r); 127 KDialogBase::done(r);
128} 128}
129 129
130HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList, 130HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList,
131 HlDataList* highlightDataList, 131 HlDataList* highlightDataList,
132 int hlNumber,QWidget *parent, const char *name) 132 int hlNumber,QWidget *parent, const char *name)
133 :QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L) 133 :QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L)
134 134
135{ 135{
136 136
137 // defaults ========================================================= 137 // defaults =========================================================
138 138
139 QFrame *page1 = new QFrame(this); 139 QFrame *page1 = new QFrame(this);
140 addTab(page1,i18n("&Defaults")); 140 addTab(page1,i18n("&Defaults"));
141 QGridLayout *grid = new QGridLayout(page1, 1, 1); 141 QGridLayout *grid = new QGridLayout(page1, 1, 1);
142 142
143 QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 ); 143 QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 );
144 /*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 ); 144 /*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 );
145 QComboBox *styleCombo = new QComboBox( false, dvbox1 ); 145 QComboBox *styleCombo = new QComboBox( false, dvbox1 );
146 defaultStyleChanger = new StyleChanger( dvbox1 ); 146 defaultStyleChanger = new StyleChanger( dvbox1 );
147 for( int i = 0; i < hlManager->defaultStyles(); i++ ) { 147 for( int i = 0; i < hlManager->defaultStyles(); i++ ) {
148 styleCombo->insertItem(hlManager->defaultStyleName(i)); 148 styleCombo->insertItem(hlManager->defaultStyleName(i));
149 } 149 }
150 connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int))); 150 connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int)));
151 grid->addWidget(dvbox1, 0,0); 151 grid->addWidget(dvbox1, 0,0);
152 152
153 defaultChanged(0); 153 defaultChanged(0);
154 154
155 // highlight modes ===================================================== 155 // highlight modes =====================================================
156 156
157 QFrame *page2 = new QFrame(this); 157 QFrame *page2 = new QFrame(this);
158 addTab(page2,i18n("&Highlight Modes")); 158 addTab(page2,i18n("&Highlight Modes"));
159 //grid = new QGridLayout(page2,2,2); 159 //grid = new QGridLayout(page2,2,2);
160 QVBoxLayout *bl=new QVBoxLayout(page2); 160 QVBoxLayout *bl=new QVBoxLayout(page2);
161 bl->setAutoAdd(true); 161 bl->setAutoAdd(true);
162 QHGroupBox *hbox1 = new QHGroupBox( i18n("Config Select"), page2 ); 162 QHGroupBox *hbox1 = new QHGroupBox( i18n("Config Select"), page2 );
@@ -193,193 +193,193 @@ HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *st
193 193
194 styleDefault = new QCheckBox(i18n("Default"), vbox2 ); 194 styleDefault = new QCheckBox(i18n("Default"), vbox2 );
195 connect(styleDefault,SIGNAL(clicked()),SLOT(changed())); 195 connect(styleDefault,SIGNAL(clicked()),SLOT(changed()));
196 styleChanger = new StyleChanger( vbox2 ); 196 styleChanger = new StyleChanger( vbox2 );
197 197
198 hlDataList = highlightDataList; 198 hlDataList = highlightDataList;
199 hlChanged(hlNumber); 199 hlChanged(hlNumber);
200} 200}
201 201
202 202
203void HighlightDialogPage::defaultChanged(int z) 203void HighlightDialogPage::defaultChanged(int z)
204{ 204{
205 defaultStyleChanger->setRef(defaultItemStyleList->at(z)); 205 defaultStyleChanger->setRef(defaultItemStyleList->at(z));
206} 206}
207 207
208 208
209void HighlightDialogPage::hlChanged(int z) 209void HighlightDialogPage::hlChanged(int z)
210{ 210{
211 writeback(); 211 writeback();
212 212
213 hlData = hlDataList->at(z); 213 hlData = hlDataList->at(z);
214 214
215 wildcards->setText(hlData->wildcards); 215 wildcards->setText(hlData->wildcards);
216 mimetypes->setText(hlData->mimetypes); 216 mimetypes->setText(hlData->mimetypes);
217 217
218 itemCombo->clear(); 218 itemCombo->clear();
219 for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L; 219 for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L;
220 itemData = hlData->itemDataList.next()) { 220 itemData = hlData->itemDataList.next()) {
221 kdDebug(13010) << itemData->name << endl; 221 kdDebug(13010) << itemData->name << endl;
222 itemCombo->insertItem(i18n(itemData->name.latin1())); 222 itemCombo->insertItem(i18n(itemData->name.latin1()));
223 } 223 }
224 224
225 itemChanged(0); 225 itemChanged(0);
226} 226}
227 227
228void HighlightDialogPage::itemChanged(int z) 228void HighlightDialogPage::itemChanged(int z)
229{ 229{
230 itemData = hlData->itemDataList.at(z); 230 itemData = hlData->itemDataList.at(z);
231 231
232 styleDefault->setChecked(itemData->defStyle); 232 styleDefault->setChecked(itemData->defStyle);
233 styleChanger->setRef(itemData); 233 styleChanger->setRef(itemData);
234} 234}
235 235
236void HighlightDialogPage::changed() 236void HighlightDialogPage::changed()
237{ 237{
238 itemData->defStyle = styleDefault->isChecked(); 238 itemData->defStyle = styleDefault->isChecked();
239} 239}
240 240
241void HighlightDialogPage::writeback() { 241void HighlightDialogPage::writeback() {
242 if (hlData) { 242 if (hlData) {
243 hlData->wildcards = wildcards->text(); 243 hlData->wildcards = wildcards->text();
244 hlData->mimetypes = mimetypes->text(); 244 hlData->mimetypes = mimetypes->text();
245 } 245 }
246} 246}
247 247
248void HighlightDialogPage::saveData() { 248void HighlightDialogPage::saveData() {
249 kdDebug(13010)<<"HighlightDialogPage::saveData()"<<endl; 249 kdDebug(13010)<<"HighlightDialogPage::saveData()"<<endl;
250 writeback(); 250 writeback();
251} 251}
252 252
253 253
254void HighlightDialogPage::hlEdit() { 254void HighlightDialogPage::hlEdit() {
255 HlEditDialog diag(0,0,"hlEdit", true,hlData); 255 HlEditDialog diag(0,0,"hlEdit", true,hlData);
256 diag.show(); 256 diag.show();
257} 257}
258 258
259void HighlightDialogPage::hlNew() { 259void HighlightDialogPage::hlNew() {
260 HlEditDialog diag(0,0,"hlEdit",true,0); 260 HlEditDialog diag(0,0,"hlEdit",true,0);
261 diag.show(); 261 diag.show();
262} 262}
263 263
264 264
265HlEditDialog::HlEditDialog(HlManager *,QWidget *parent, const char *name, bool modal,HlData *data) 265HlEditDialog::HlEditDialog(HlManager *,QWidget *parent, const char *name, bool modal,HlData *data)
266 :KDialogBase(KDialogBase::Swallow, i18n("Highlight Conditions"), Ok|Cancel, Ok, parent, name, modal) 266 :KDialogBase(KDialogBase::Swallow, i18n("Highlight Conditions"), Ok|Cancel, Ok, parent, name, modal)
267{ 267{
268 currentItem=0; 268 currentItem=0;
269 transTableCnt=0; 269 transTableCnt=0;
270 QHBox *wid=new QHBox(this); 270 QHBox *wid=new QHBox(this);
271 QVBox *lbox=new QVBox(wid); 271 QVBox *lbox=new QVBox(wid);
272 contextList=new KListView(lbox); 272 contextList=new KListView(lbox);
273 contextList->setRootIsDecorated(true); 273 contextList->setRootIsDecorated(true);
274 contextList->addColumn(i18n("Syntax structure")); 274 contextList->addColumn(i18n("Syntax structure"));
275 contextList->setSorting(-1); 275 contextList->setSorting(-1);
276 QHBox *bbox=new QHBox(lbox); 276 QHBox *bbox=new QHBox(lbox);
277 QPushButton *addContext=new QPushButton(i18n("New Context"),bbox); 277 QPushButton *addContext=new QPushButton(i18n("New Context"),bbox);
278 QPushButton *addItem=new QPushButton(i18n("New Item"),bbox); 278 QPushButton *addItem=new QPushButton(i18n("New Item"),bbox);
279 QVGroupBox *opt = new QVGroupBox( i18n("Options"), wid); 279 QVGroupBox *opt = new QVGroupBox( i18n("Options"), wid);
280 stack=new QWidgetStack(opt); 280 stack=new QWidgetStack(opt);
281 initContextOptions(contextOptions=new QVBox(stack)); 281 initContextOptions(contextOptions=new QVBox(stack));
282 stack->addWidget(contextOptions,HlEContext); 282 stack->addWidget(contextOptions,HlEContext);
283 initItemOptions(itemOptions=new QVBox(stack)); 283 initItemOptions(itemOptions=new QVBox(stack));
284 stack->addWidget(itemOptions,HlEItem); 284 stack->addWidget(itemOptions,HlEItem);
285 stack->raiseWidget(HlEContext); 285 stack->raiseWidget(HlEContext);
286 setMainWidget(wid); 286 setMainWidget(wid);
287 if (data!=0) loadFromDocument(data); 287 if (data!=0) loadFromDocument(data);
288 else newDocument(); 288 else newDocument();
289 connect(contextList,SIGNAL(currentChanged( QListViewItem*)),this,SLOT(currentSelectionChanged ( QListViewItem * ))); 289 connect(contextList,SIGNAL(currentChanged(QListViewItem*)),this,SLOT(currentSelectionChanged(QListViewItem*)));
290 connect(addContext,SIGNAL(clicked()),this,SLOT(contextAddNew())); 290 connect(addContext,SIGNAL(clicked()),this,SLOT(contextAddNew()));
291 connect(addItem,SIGNAL(clicked()),this,SLOT(ItemAddNew())); 291 connect(addItem,SIGNAL(clicked()),this,SLOT(ItemAddNew()));
292 } 292 }
293 293
294void HlEditDialog::newDocument() 294void HlEditDialog::newDocument()
295{ 295{
296 KStandardDirs *dirs = KGlobal::dirs(); 296 KStandardDirs *dirs = KGlobal::dirs();
297 QStringList list=dirs->findAllResources("data","kate/syntax/syntax.template",false,true); 297 QStringList list=dirs->findAllResources("data","kate/syntax/syntax.template",false,true);
298 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 298 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
299 { 299 {
300 HlData data("","",*it); 300 HlData data("","",*it);
301 loadFromDocument(&data); 301 loadFromDocument(&data);
302 return; 302 return;
303 } 303 }
304 KMessageBox::error(this,i18n("Can't find template file")); 304 KMessageBox::error(this,i18n("Can't find template file"));
305} 305}
306 306
307 307
308void HlEditDialog::initContextOptions(QVBox *co) 308void HlEditDialog::initContextOptions(QVBox *co)
309{ 309{
310 if( co!=0) 310 if( co!=0)
311 { 311 {
312 QHBox *tmp = new QHBox(co); 312 QHBox *tmp = new QHBox(co);
313 (void) new QLabel(i18n("Description:"),tmp); 313 (void) new QLabel(i18n("Description:"),tmp);
314 ContextDescr=new QLineEdit(tmp); 314 ContextDescr=new QLineEdit(tmp);
315 tmp= new QHBox(co); 315 tmp= new QHBox(co);
316 (void) new QLabel(i18n("Attribute:"),tmp); 316 (void) new QLabel(i18n("Attribute:"),tmp);
317 ContextAttribute=new QComboBox(tmp); 317 ContextAttribute=new QComboBox(tmp);
318 tmp= new QHBox(co); 318 tmp= new QHBox(co);
319 (void) new QLabel(i18n("LineEnd:"),tmp); 319 (void) new QLabel(i18n("LineEnd:"),tmp);
320 ContextLineEnd = new QComboBox(tmp); 320 ContextLineEnd = new QComboBox(tmp);
321 connect(ContextDescr,SIGNAL(textChanged(const QString&)),this,SLOT(contextDescrChanged(const QString&))); 321 connect(ContextDescr,SIGNAL(textChanged(const QString&)),this,SLOT(contextDescrChanged(const QString&)));
322 connect(ContextLineEnd,SIGNAL(activated(int)),this,SLOT(contextLineEndChanged(int))); 322 connect(ContextLineEnd,SIGNAL(activated(int)),this,SLOT(contextLineEndChanged(int)));
323 connect(ContextAttribute,SIGNAL(activated(int)),this,SLOT(contextAttributeChanged(int))); 323 connect(ContextAttribute,SIGNAL(activated(int)),this,SLOT(contextAttributeChanged(int)));
324 } 324 }
325 else 325 else
326 kdDebug(13010)<<"initContextOptions: Widget is 0"<<endl; 326 kdDebug(13010)<<"initContextOptions: Widget is 0"<<endl;
327} 327}
328 328
329 329
330void HlEditDialog::insertTranslationList(QString tag, QString trans,int length) 330void HlEditDialog::insertTranslationList(QString tag, QString trans,int length)
331 { 331 {
332 ItemInfo data(trans,length); 332 ItemInfo data(trans,length);
333 id2tag.insert(transTableCnt,tag); 333 id2tag.insert(transTableCnt,tag);
334 id2info.insert(transTableCnt,data); 334 id2info.insert(transTableCnt,data);
335 tag2id.insert(tag,transTableCnt); 335 tag2id.insert(tag,transTableCnt);
336 transTableCnt++; 336 transTableCnt++;
337 } 337 }
338 338
339 339
340void HlEditDialog::initItemOptions(QVBox *co) 340void HlEditDialog::initItemOptions(QVBox *co)
341{ 341{
342 if (co!=0) 342 if (co!=0)
343 { 343 {
344 QHBox *tmp = new QHBox(co); 344 QHBox *tmp = new QHBox(co);
345 (void) new QLabel(i18n("Type:"),tmp); 345 (void) new QLabel(i18n("Type:"),tmp);
346 ItemType = new QComboBox(tmp); 346 ItemType = new QComboBox(tmp);
347 tmp= new QHBox(co); 347 tmp= new QHBox(co);
348 (void) new QLabel(i18n("Parameter:"),tmp); 348 (void) new QLabel(i18n("Parameter:"),tmp);
349 ItemParameter= new QLineEdit(tmp); 349 ItemParameter= new QLineEdit(tmp);
350 tmp= new QHBox(co); 350 tmp= new QHBox(co);
351 (void) new QLabel(i18n("Attribute:"),tmp); 351 (void) new QLabel(i18n("Attribute:"),tmp);
352 ItemAttribute= new QComboBox(tmp); 352 ItemAttribute= new QComboBox(tmp);
353 (void) new QLabel(i18n("Context switch:"),tmp); 353 (void) new QLabel(i18n("Context switch:"),tmp);
354 ItemContext = new QComboBox(tmp); 354 ItemContext = new QComboBox(tmp);
355 co->setSpacing(15); 355 co->setSpacing(15);
356 QPushButton *delItem=new QPushButton(i18n("Delete this item"),co); 356 QPushButton *delItem=new QPushButton(i18n("Delete this item"),co);
357 357
358 /* init translation lists */ 358 /* init translation lists */
359 insertTranslationList("CharDetect","CharDetect",1); 359 insertTranslationList("CharDetect","CharDetect",1);
360 insertTranslationList("2CharDetect","2CharDetect",2); 360 insertTranslationList("2CharDetect","2CharDetect",2);
361 insertTranslationList("RangeDetect","RangeDetect",2); 361 insertTranslationList("RangeDetect","RangeDetect",2);
362 insertTranslationList("StringDetect","StringDetect",-1); 362 insertTranslationList("StringDetect","StringDetect",-1);
363 insertTranslationList("AnyChar","AnyChar",-1); 363 insertTranslationList("AnyChar","AnyChar",-1);
364 insertTranslationList("RegExpr","RegExpr",-1); 364 insertTranslationList("RegExpr","RegExpr",-1);
365 insertTranslationList("Int","Int",0); 365 insertTranslationList("Int","Int",0);
366 insertTranslationList("Float","Float",0); 366 insertTranslationList("Float","Float",0);
367 insertTranslationList("keyword","keyword",0); 367 insertTranslationList("keyword","keyword",0);
368 insertTranslationList("dataType","dataType",0); 368 insertTranslationList("dataType","dataType",0);
369 ItemType->clear(); 369 ItemType->clear();
370 for (int i=0; i<transTableCnt; i++) ItemType->insertItem(id2info[i].trans_i18n); 370 for (int i=0; i<transTableCnt; i++) ItemType->insertItem(id2info[i].trans_i18n);
371 connect(ItemType,SIGNAL(activated(int)),this,SLOT(ItemTypeChanged(int))); 371 connect(ItemType,SIGNAL(activated(int)),this,SLOT(ItemTypeChanged(int)));
372 connect(ItemParameter,SIGNAL(textChanged(const QString&)),this,SLOT(ItemParameterChanged(const QString&))); 372 connect(ItemParameter,SIGNAL(textChanged(const QString&)),this,SLOT(ItemParameterChanged(const QString&)));
373 connect(ItemAttribute,SIGNAL(activated(int)),this,SLOT(ItemAttributeChanged(int))); 373 connect(ItemAttribute,SIGNAL(activated(int)),this,SLOT(ItemAttributeChanged(int)));
374 connect(ItemContext,SIGNAL(activated(int)),this,SLOT(ItemContextChanged(int))); 374 connect(ItemContext,SIGNAL(activated(int)),this,SLOT(ItemContextChanged(int)));
375 } 375 }
376 else 376 else
377 kdDebug(13010)<<"initItemOptions: Widget is 0"<<endl; 377 kdDebug(13010)<<"initItemOptions: Widget is 0"<<endl;
378} 378}
379 379
380void HlEditDialog::loadFromDocument(HlData *hl) 380void HlEditDialog::loadFromDocument(HlData *hl)
381{ 381{
382 struct syntaxContextData *data; 382 struct syntaxContextData *data;
383 QListViewItem *last=0,*lastsub=0; 383 QListViewItem *last=0,*lastsub=0;
384 384
385 HlManager::self()->syntax->setIdentifier(hl->identifier); 385 HlManager::self()->syntax->setIdentifier(hl->identifier);
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index f05e21a..0c742d7 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -75,193 +75,193 @@
75#include "../view/kateview.h" 75#include "../view/kateview.h"
76#include "katebuffer.h" 76#include "katebuffer.h"
77#include "katetextline.h" 77#include "katetextline.h"
78 78
79#include "katecmd.h" 79#include "katecmd.h"
80 80
81KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) 81KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text)
82 : action(a), cursor(cursor), len(len), text(text) { 82 : action(a), cursor(cursor), len(len), text(text) {
83} 83}
84 84
85KateActionGroup::KateActionGroup(PointStruc &aStart, int type) 85KateActionGroup::KateActionGroup(PointStruc &aStart, int type)
86 : start(aStart), action(0L), undoType(type) { 86 : start(aStart), action(0L), undoType(type) {
87} 87}
88 88
89KateActionGroup::~KateActionGroup() { 89KateActionGroup::~KateActionGroup() {
90 KateAction *current, *next; 90 KateAction *current, *next;
91 91
92 current = action; 92 current = action;
93 while (current) { 93 while (current) {
94 next = current->next; 94 next = current->next;
95 delete current; 95 delete current;
96 current = next; 96 current = next;
97 } 97 }
98} 98}
99 99
100void KateActionGroup::insertAction(KateAction *a) { 100void KateActionGroup::insertAction(KateAction *a) {
101 a->next = action; 101 a->next = action;
102 action = a; 102 action = a;
103} 103}
104 104
105const char * KateActionGroup::typeName(int type) 105const char * KateActionGroup::typeName(int type)
106{ 106{
107 // return a short text description of the given undo group type suitable for a menu 107 // return a short text description of the given undo group type suitable for a menu
108 // not the lack of i18n's, the caller is expected to handle translation 108 // not the lack of i18n's, the caller is expected to handle translation
109 switch (type) { 109 switch (type) {
110 case ugPaste : return "Paste Text"; 110 case ugPaste : return "Paste Text";
111 case ugDelBlock : return "Selection Overwrite"; 111 case ugDelBlock : return "Selection Overwrite";
112 case ugIndent : return "Indent"; 112 case ugIndent : return "Indent";
113 case ugUnindent : return "Unindent"; 113 case ugUnindent : return "Unindent";
114 case ugComment : return "Comment"; 114 case ugComment : return "Comment";
115 case ugUncomment : return "Uncomment"; 115 case ugUncomment : return "Uncomment";
116 case ugReplace : return "Text Replace"; 116 case ugReplace : return "Text Replace";
117 case ugSpell : return "Spell Check"; 117 case ugSpell : return "Spell Check";
118 case ugInsChar : return "Typing"; 118 case ugInsChar : return "Typing";
119 case ugDelChar : return "Delete Text"; 119 case ugDelChar : return "Delete Text";
120 case ugInsLine : return "New Line"; 120 case ugInsLine : return "New Line";
121 case ugDelLine : return "Delete Line"; 121 case ugDelLine : return "Delete Line";
122 } 122 }
123 return ""; 123 return "";
124} 124}
125 125
126const int KateDocument::maxAttribs = 32; 126const int KateDocument::maxAttribs = 32;
127 127
128QStringList KateDocument::searchForList = QStringList(); 128QStringList KateDocument::searchForList = QStringList();
129QStringList KateDocument::replaceWithList = QStringList(); 129QStringList KateDocument::replaceWithList = QStringList();
130 130
131uint KateDocument::uniqueID = 0; 131uint KateDocument::uniqueID = 0;
132 132
133QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0; 133QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0;
134 134
135 135
136KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView, 136KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView,
137 QWidget *parentWidget, const char *widgetName, 137 QWidget *parentWidget, const char *widgetName,
138 QObject *, const char *) 138 QObject *, const char *)
139 : Kate::Document (), 139 : Kate::Document (),
140 myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()), 140 myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()),
141 myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI), 141 myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI),
142 hlManager(HlManager::self ()) 142 hlManager(HlManager::self ())
143{ 143{
144 144
145 d(this)->hlSetByUser = false; 145 d(this)->hlSetByUser = false;
146 PreHighlightedTill=0; 146 PreHighlightedTill=0;
147 RequestPreHighlightTill=0; 147 RequestPreHighlightTill=0;
148 148
149 m_bSingleViewMode=bSingleViewMode; 149 m_bSingleViewMode=bSingleViewMode;
150 m_bBrowserView = bBrowserView; 150 m_bBrowserView = bBrowserView;
151 151
152 m_url = QString::null; 152 m_url = QString::null;
153 153
154 // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports 154 // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports
155 // (esp. it doesn't distinguish between UTF-8 and iso10646-1) 155 // (esp. it doesn't distinguish between UTF-8 and iso10646-1)
156 156
157 myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); 157 myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name());
158 158
159 maxLength = -1; 159 maxLength = -1;
160 160
161 setFont (KGlobalSettings::generalFont()); 161 setFont (KGlobalSettings::generalFont());
162 162
163 myDocID = uniqueID; 163 myDocID = uniqueID;
164 uniqueID++; 164 uniqueID++;
165 165
166 myDocName = QString (""); 166 myDocName = QString ("");
167 fileInfo = new QFileInfo (); 167 fileInfo = new QFileInfo ();
168 168
169 myCmd = new KateCmd (this); 169 myCmd = new KateCmd (this);
170 170
171 connect(this,SIGNAL(modifiedChanged ()),this,SLOT(slotModChanged ())); 171 connect(this,SIGNAL(modifiedChanged()),this,SLOT(slotModChanged()));
172 172
173 buffer = new KWBuffer; 173 buffer = new KWBuffer;
174 connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged())); 174 connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged()));
175// connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged())); 175// connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
176 connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long))); 176 connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long)));
177 177
178 colors[0] = KGlobalSettings::baseColor(); 178 colors[0] = KGlobalSettings::baseColor();
179 colors[1] = KGlobalSettings::highlightColor(); 179 colors[1] = KGlobalSettings::highlightColor();
180 180
181 m_attribs = new Attribute[maxAttribs]; 181 m_attribs = new Attribute[maxAttribs];
182 182
183 m_highlight = 0L; 183 m_highlight = 0L;
184 tabChars = 8; 184 tabChars = 8;
185 185
186 m_singleSelection = false; 186 m_singleSelection = false;
187 187
188 newDocGeometry = false; 188 newDocGeometry = false;
189 readOnly = false; 189 readOnly = false;
190 newDoc = false; 190 newDoc = false;
191 191
192 modified = false; 192 modified = false;
193 193
194 undoList.setAutoDelete(true); 194 undoList.setAutoDelete(true);
195 undoState = 0; 195 undoState = 0;
196 undoSteps = 50; 196 undoSteps = 50;
197 197
198 pseudoModal = 0L; 198 pseudoModal = 0L;
199 clear(); 199 clear();
200 200
201 setHighlight(0); //calls updateFontData() 201 setHighlight(0); //calls updateFontData()
202 // if the user changes the highlight with the dialog, notify the doc 202 // if the user changes the highlight with the dialog, notify the doc
203 connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); 203 connect(hlManager,SIGNAL(changed()),SLOT(hlChanged()));
204 204
205 newDocGeometry = false; 205 newDocGeometry = false;
206 206
207 readConfig(); 207 readConfig();
208 208
209 setReadOnly(false); 209 setReadOnly(false);
210} 210}
211 211
212void KateDocument::setDontChangeHlOnSave() 212void KateDocument::setDontChangeHlOnSave()
213{ 213{
214 d(this)->hlSetByUser = true; 214 d(this)->hlSetByUser = true;
215} 215}
216 216
217void KateDocument::setFont (QFont font) 217void KateDocument::setFont (QFont font)
218{ 218{
219 kdDebug()<<"Kate:: setFont"<<endl; 219 kdDebug()<<"Kate:: setFont"<<endl;
220 int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 220 int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
221 myFont = font; 221 myFont = font;
222 myFontBold = QFont (font); 222 myFontBold = QFont (font);
223 myFontBold.setBold (true); 223 myFontBold.setBold (true);
224 224
225 myFontItalic = QFont (font); 225 myFontItalic = QFont (font);
226 myFontItalic.setItalic (true); 226 myFontItalic.setItalic (true);
227 227
228 myFontBI = QFont (font); 228 myFontBI = QFont (font);
229 myFontBI.setBold (true); 229 myFontBI.setBold (true);
230 myFontBI.setItalic (true); 230 myFontBI.setItalic (true);
231 231
232 myFontMetrics = CachedFontMetrics (myFont); 232 myFontMetrics = CachedFontMetrics (myFont);
233 myFontMetricsBold = CachedFontMetrics (myFontBold); 233 myFontMetricsBold = CachedFontMetrics (myFontBold);
234 myFontMetricsItalic = CachedFontMetrics (myFontItalic); 234 myFontMetricsItalic = CachedFontMetrics (myFontItalic);
235 myFontMetricsBI = CachedFontMetrics (myFontBI); 235 myFontMetricsBI = CachedFontMetrics (myFontBI);
236 int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 236 int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
237 maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 237 maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
238 238
239 updateFontData(); 239 updateFontData();
240 updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 240 updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0
241 241
242} 242}
243 243
244long KateDocument::needPreHighlight(long till) 244long KateDocument::needPreHighlight(long till)
245{ 245{
246 int max=numLines()-1; 246 int max=numLines()-1;
247 if (till>max) 247 if (till>max)
248 { 248 {
249 till=max; 249 till=max;
250 } 250 }
251 if (PreHighlightedTill>=till) return -1; 251 if (PreHighlightedTill>=till) return -1;
252 252
253 long tmp=RequestPreHighlightTill; 253 long tmp=RequestPreHighlightTill;
254 if (RequestPreHighlightTill<till) 254 if (RequestPreHighlightTill<till)
255 { 255 {
256 RequestPreHighlightTill=till; 256 RequestPreHighlightTill=till;
257 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); 257 if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight()));
258 } 258 }
259 return RequestPreHighlightTill; 259 return RequestPreHighlightTill;
260} 260}
261 261
262void KateDocument::doPreHighlight() 262void KateDocument::doPreHighlight()
263{ 263{
264 int from = PreHighlightedTill; 264 int from = PreHighlightedTill;
265 int till = PreHighlightedTill+200; 265 int till = PreHighlightedTill+200;
266 int max = numLines()-1; 266 int max = numLines()-1;
267 if (till > max) 267 if (till > max)