Diffstat (limited to 'noncore/apps/tinykate/libkate/document') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedialogs.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.cpp | 2 |
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 @@ /*************************************************************************** katedialogs.cpp - description ------------------- copyright : (C) 2001 by The Kate Team (C) 2002 by Joseph Wenninger email : kwrite-devel@kde.org jowenn@kde.org ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "katedialogs.h" #include <klocale.h> #include <kdebug.h> #include <qgroupbox.h> #include <qvgroupbox.h> #include <qhgroupbox.h> #include <qhbox.h> #include <qvbox.h> #include <qlayout.h> #include <qpushbutton.h> #include <qwidgetstack.h> #include <qlabel.h> #include <qlistview.h> #include <qlineedit.h> #include <qcombobox.h> #include <qcheckbox.h> //FIXME #include <kcharsets.h> #include <kglobal.h> #include <qmap.h> #include <kmessagebox.h> #include <kstddirs.h> /******************************************************************************************************************* * Context Editor * *******************************************************************************************************************/ StyleChanger::StyleChanger( QWidget *parent ) : QWidget(parent) { QLabel *label; QGridLayout *glay = new QGridLayout( this, 4, 3, 0, KDialog::spacingHint() ); CHECK_PTR(glay); glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better glay->setColStretch( 2, 10 ); col = new KColorButton(this); CHECK_PTR(col); - connect(col,SIGNAL(changed(const QColor &)),this,SLOT(changed())); + connect(col,SIGNAL(changed(const QColor&)),this,SLOT(changed())); label = new QLabel(col,i18n("Normal:"),this); CHECK_PTR(label); glay->addWidget(label,0,0); glay->addWidget(col,1,0); selCol = new KColorButton(this); CHECK_PTR(selCol); - connect(selCol,SIGNAL(changed(const QColor &)),this,SLOT(changed())); + connect(selCol,SIGNAL(changed(const QColor&)),this,SLOT(changed())); label = new QLabel(selCol,i18n("Selected:"),this); CHECK_PTR(label); glay->addWidget(label,2,0); glay->addWidget(selCol,3,0); bold = new QCheckBox(i18n("Bold"),this); CHECK_PTR(bold); connect(bold,SIGNAL(clicked()),SLOT(changed())); glay->addWidget(bold,1,2); italic = new QCheckBox(i18n("Italic"),this); CHECK_PTR(italic); connect(italic,SIGNAL(clicked()),SLOT(changed())); glay->addWidget(italic,2,2); } void StyleChanger::setRef(ItemStyle *s) { style = s; col->setColor(style->col); selCol->setColor(style->selCol); bold->setChecked(style->bold); italic->setChecked(style->italic); } void StyleChanger::setEnabled(bool enable) { col->setEnabled(enable); selCol->setEnabled(enable); bold->setEnabled(enable); italic->setEnabled(enable); } void StyleChanger::changed() { if (style) { style->col = col->color(); style->selCol = selCol->color(); style->bold = bold->isChecked(); style->italic = italic->isChecked(); } } HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList, HlDataList *highlightDataList, int hlNumber, QWidget *parent, const char *name, bool modal ) :KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok) { // QVBox *page = makeVBoxMainWidget(); QFrame *page=addPage("FIXME"); (new QVBoxLayout(page))->setAutoAdd(true); content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page); } void HighlightDialog::done(int r) { kdDebug(13010)<<"HighlightDialod done"<<endl; content->saveData(); KDialogBase::done(r); } HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList, HlDataList* highlightDataList, int hlNumber,QWidget *parent, const char *name) :QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L) { // defaults ========================================================= QFrame *page1 = new QFrame(this); addTab(page1,i18n("&Defaults")); QGridLayout *grid = new QGridLayout(page1, 1, 1); QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 ); /*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 ); QComboBox *styleCombo = new QComboBox( false, dvbox1 ); defaultStyleChanger = new StyleChanger( dvbox1 ); for( int i = 0; i < hlManager->defaultStyles(); i++ ) { styleCombo->insertItem(hlManager->defaultStyleName(i)); } connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int))); grid->addWidget(dvbox1, 0,0); defaultChanged(0); // highlight modes ===================================================== QFrame *page2 = new QFrame(this); addTab(page2,i18n("&Highlight Modes")); //grid = new QGridLayout(page2,2,2); QVBoxLayout *bl=new QVBoxLayout(page2); bl->setAutoAdd(true); QHGroupBox *hbox1 = new QHGroupBox( i18n("Config Select"), page2 ); @@ -193,193 +193,193 @@ HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *st styleDefault = new QCheckBox(i18n("Default"), vbox2 ); connect(styleDefault,SIGNAL(clicked()),SLOT(changed())); styleChanger = new StyleChanger( vbox2 ); hlDataList = highlightDataList; hlChanged(hlNumber); } void HighlightDialogPage::defaultChanged(int z) { defaultStyleChanger->setRef(defaultItemStyleList->at(z)); } void HighlightDialogPage::hlChanged(int z) { writeback(); hlData = hlDataList->at(z); wildcards->setText(hlData->wildcards); mimetypes->setText(hlData->mimetypes); itemCombo->clear(); for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L; itemData = hlData->itemDataList.next()) { kdDebug(13010) << itemData->name << endl; itemCombo->insertItem(i18n(itemData->name.latin1())); } itemChanged(0); } void HighlightDialogPage::itemChanged(int z) { itemData = hlData->itemDataList.at(z); styleDefault->setChecked(itemData->defStyle); styleChanger->setRef(itemData); } void HighlightDialogPage::changed() { itemData->defStyle = styleDefault->isChecked(); } void HighlightDialogPage::writeback() { if (hlData) { hlData->wildcards = wildcards->text(); hlData->mimetypes = mimetypes->text(); } } void HighlightDialogPage::saveData() { kdDebug(13010)<<"HighlightDialogPage::saveData()"<<endl; writeback(); } void HighlightDialogPage::hlEdit() { HlEditDialog diag(0,0,"hlEdit", true,hlData); diag.show(); } void HighlightDialogPage::hlNew() { HlEditDialog diag(0,0,"hlEdit",true,0); diag.show(); } HlEditDialog::HlEditDialog(HlManager *,QWidget *parent, const char *name, bool modal,HlData *data) :KDialogBase(KDialogBase::Swallow, i18n("Highlight Conditions"), Ok|Cancel, Ok, parent, name, modal) { currentItem=0; transTableCnt=0; QHBox *wid=new QHBox(this); QVBox *lbox=new QVBox(wid); contextList=new KListView(lbox); contextList->setRootIsDecorated(true); contextList->addColumn(i18n("Syntax structure")); contextList->setSorting(-1); QHBox *bbox=new QHBox(lbox); QPushButton *addContext=new QPushButton(i18n("New Context"),bbox); QPushButton *addItem=new QPushButton(i18n("New Item"),bbox); QVGroupBox *opt = new QVGroupBox( i18n("Options"), wid); stack=new QWidgetStack(opt); initContextOptions(contextOptions=new QVBox(stack)); stack->addWidget(contextOptions,HlEContext); initItemOptions(itemOptions=new QVBox(stack)); stack->addWidget(itemOptions,HlEItem); stack->raiseWidget(HlEContext); setMainWidget(wid); if (data!=0) loadFromDocument(data); else newDocument(); - connect(contextList,SIGNAL(currentChanged( QListViewItem*)),this,SLOT(currentSelectionChanged ( QListViewItem * ))); + connect(contextList,SIGNAL(currentChanged(QListViewItem*)),this,SLOT(currentSelectionChanged(QListViewItem*))); connect(addContext,SIGNAL(clicked()),this,SLOT(contextAddNew())); connect(addItem,SIGNAL(clicked()),this,SLOT(ItemAddNew())); } void HlEditDialog::newDocument() { KStandardDirs *dirs = KGlobal::dirs(); QStringList list=dirs->findAllResources("data","kate/syntax/syntax.template",false,true); for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { HlData data("","",*it); loadFromDocument(&data); return; } KMessageBox::error(this,i18n("Can't find template file")); } void HlEditDialog::initContextOptions(QVBox *co) { if( co!=0) { QHBox *tmp = new QHBox(co); (void) new QLabel(i18n("Description:"),tmp); ContextDescr=new QLineEdit(tmp); tmp= new QHBox(co); (void) new QLabel(i18n("Attribute:"),tmp); ContextAttribute=new QComboBox(tmp); tmp= new QHBox(co); (void) new QLabel(i18n("LineEnd:"),tmp); ContextLineEnd = new QComboBox(tmp); connect(ContextDescr,SIGNAL(textChanged(const QString&)),this,SLOT(contextDescrChanged(const QString&))); connect(ContextLineEnd,SIGNAL(activated(int)),this,SLOT(contextLineEndChanged(int))); connect(ContextAttribute,SIGNAL(activated(int)),this,SLOT(contextAttributeChanged(int))); } else kdDebug(13010)<<"initContextOptions: Widget is 0"<<endl; } void HlEditDialog::insertTranslationList(QString tag, QString trans,int length) { ItemInfo data(trans,length); id2tag.insert(transTableCnt,tag); id2info.insert(transTableCnt,data); tag2id.insert(tag,transTableCnt); transTableCnt++; } void HlEditDialog::initItemOptions(QVBox *co) { if (co!=0) { QHBox *tmp = new QHBox(co); (void) new QLabel(i18n("Type:"),tmp); ItemType = new QComboBox(tmp); tmp= new QHBox(co); (void) new QLabel(i18n("Parameter:"),tmp); ItemParameter= new QLineEdit(tmp); tmp= new QHBox(co); (void) new QLabel(i18n("Attribute:"),tmp); ItemAttribute= new QComboBox(tmp); (void) new QLabel(i18n("Context switch:"),tmp); ItemContext = new QComboBox(tmp); co->setSpacing(15); QPushButton *delItem=new QPushButton(i18n("Delete this item"),co); /* init translation lists */ insertTranslationList("CharDetect","CharDetect",1); insertTranslationList("2CharDetect","2CharDetect",2); insertTranslationList("RangeDetect","RangeDetect",2); insertTranslationList("StringDetect","StringDetect",-1); insertTranslationList("AnyChar","AnyChar",-1); insertTranslationList("RegExpr","RegExpr",-1); insertTranslationList("Int","Int",0); insertTranslationList("Float","Float",0); insertTranslationList("keyword","keyword",0); insertTranslationList("dataType","dataType",0); ItemType->clear(); for (int i=0; i<transTableCnt; i++) ItemType->insertItem(id2info[i].trans_i18n); connect(ItemType,SIGNAL(activated(int)),this,SLOT(ItemTypeChanged(int))); connect(ItemParameter,SIGNAL(textChanged(const QString&)),this,SLOT(ItemParameterChanged(const QString&))); connect(ItemAttribute,SIGNAL(activated(int)),this,SLOT(ItemAttributeChanged(int))); connect(ItemContext,SIGNAL(activated(int)),this,SLOT(ItemContextChanged(int))); } else kdDebug(13010)<<"initItemOptions: Widget is 0"<<endl; } void HlEditDialog::loadFromDocument(HlData *hl) { struct syntaxContextData *data; QListViewItem *last=0,*lastsub=0; 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 @@ #include "../view/kateview.h" #include "katebuffer.h" #include "katetextline.h" #include "katecmd.h" KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) : action(a), cursor(cursor), len(len), text(text) { } KateActionGroup::KateActionGroup(PointStruc &aStart, int type) : start(aStart), action(0L), undoType(type) { } KateActionGroup::~KateActionGroup() { KateAction *current, *next; current = action; while (current) { next = current->next; delete current; current = next; } } void KateActionGroup::insertAction(KateAction *a) { a->next = action; action = a; } const char * KateActionGroup::typeName(int type) { // return a short text description of the given undo group type suitable for a menu // not the lack of i18n's, the caller is expected to handle translation switch (type) { case ugPaste : return "Paste Text"; case ugDelBlock : return "Selection Overwrite"; case ugIndent : return "Indent"; case ugUnindent : return "Unindent"; case ugComment : return "Comment"; case ugUncomment : return "Uncomment"; case ugReplace : return "Text Replace"; case ugSpell : return "Spell Check"; case ugInsChar : return "Typing"; case ugDelChar : return "Delete Text"; case ugInsLine : return "New Line"; case ugDelLine : return "Delete Line"; } return ""; } const int KateDocument::maxAttribs = 32; QStringList KateDocument::searchForList = QStringList(); QStringList KateDocument::replaceWithList = QStringList(); uint KateDocument::uniqueID = 0; QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0; KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView, QWidget *parentWidget, const char *widgetName, QObject *, const char *) : Kate::Document (), myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()), myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI), hlManager(HlManager::self ()) { d(this)->hlSetByUser = false; PreHighlightedTill=0; RequestPreHighlightTill=0; m_bSingleViewMode=bSingleViewMode; m_bBrowserView = bBrowserView; m_url = QString::null; // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports // (esp. it doesn't distinguish between UTF-8 and iso10646-1) myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); maxLength = -1; setFont (KGlobalSettings::generalFont()); myDocID = uniqueID; uniqueID++; myDocName = QString (""); fileInfo = new QFileInfo (); myCmd = new KateCmd (this); - connect(this,SIGNAL(modifiedChanged ()),this,SLOT(slotModChanged ())); + connect(this,SIGNAL(modifiedChanged()),this,SLOT(slotModChanged())); buffer = new KWBuffer; connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged())); // connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged())); connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long))); colors[0] = KGlobalSettings::baseColor(); colors[1] = KGlobalSettings::highlightColor(); m_attribs = new Attribute[maxAttribs]; m_highlight = 0L; tabChars = 8; m_singleSelection = false; newDocGeometry = false; readOnly = false; newDoc = false; modified = false; undoList.setAutoDelete(true); undoState = 0; undoSteps = 50; pseudoModal = 0L; clear(); setHighlight(0); //calls updateFontData() // if the user changes the highlight with the dialog, notify the doc connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); newDocGeometry = false; readConfig(); setReadOnly(false); } void KateDocument::setDontChangeHlOnSave() { d(this)->hlSetByUser = true; } void KateDocument::setFont (QFont font) { kdDebug()<<"Kate:: setFont"<<endl; int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 myFont = font; myFontBold = QFont (font); myFontBold.setBold (true); myFontItalic = QFont (font); myFontItalic.setItalic (true); myFontBI = QFont (font); myFontBI.setBold (true); myFontBI.setItalic (true); myFontMetrics = CachedFontMetrics (myFont); myFontMetricsBold = CachedFontMetrics (myFontBold); myFontMetricsItalic = CachedFontMetrics (myFontItalic); myFontMetricsBI = CachedFontMetrics (myFontBI); int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 updateFontData(); updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 } long KateDocument::needPreHighlight(long till) { int max=numLines()-1; if (till>max) { till=max; } if (PreHighlightedTill>=till) return -1; long tmp=RequestPreHighlightTill; if (RequestPreHighlightTill<till) { RequestPreHighlightTill=till; if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); } return RequestPreHighlightTill; } void KateDocument::doPreHighlight() { int from = PreHighlightedTill; int till = PreHighlightedTill+200; int max = numLines()-1; if (till > max) |