author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (side-by-side diff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/tinykate | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
4 files changed, 8 insertions, 8 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,481 +1,481 @@ /*************************************************************************** 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 ); hbox1->layout()->setMargin(5); QVBox *vbox1=new QVBox(hbox1); // grid->addMultiCellWidget(vbox1,0,0,0,1); QVGroupBox *vbox2 = new QVGroupBox( i18n("Item Style"), page2 ); // grid->addWidget(vbox2,1,0); QVGroupBox *vbox3 = new QVGroupBox( i18n("Highlight Auto Select"), hbox1 ); //grid->addWidget(vbox3,1,1); QLabel *label = new QLabel( i18n("Highlight:"), vbox1 ); hlCombo = new QComboBox( false, vbox1 ); QHBox *modHl = new QHBox(vbox1); // connect(new QPushButton(i18n("New"),modHl),SIGNAL(clicked()),this,SLOT(hlNew())); // connect(new QPushButton(i18n("Edit"),modHl),SIGNAL(clicked()),this,SLOT(hlEdit())); connect( hlCombo, SIGNAL(activated(int)), this, SLOT(hlChanged(int)) ); for( int i = 0; i < hlManager->highlights(); i++) { hlCombo->insertItem(hlManager->hlName(i)); } hlCombo->setCurrentItem(hlNumber); label = new QLabel( i18n("Item:"), vbox2 ); itemCombo = new QComboBox( false, vbox2 ); connect( itemCombo, SIGNAL(activated(int)), this, SLOT(itemChanged(int)) ); label = new QLabel( i18n("File Extensions:"), vbox3 ); wildcards = new QLineEdit( vbox3 ); label = new QLabel( i18n("Mime Types:"), vbox3 ); mimetypes = new QLineEdit( vbox3 ); 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); data=HlManager::self()->syntax->getGroupInfo("highlighting","context"); int i=0; if (data) { while (HlManager::self()->syntax->nextGroup(data)) //<context tags> { kdDebug(13010)<< "Adding context to list"<<endl; last= new QListViewItem(contextList,last, HlManager::self()->syntax->groupData(data,QString("name")), QString("%1").arg(i), HlManager::self()->syntax->groupData(data,QString("attribute")), HlManager::self()->syntax->groupData(data,QString("lineEndContext"))); i++; lastsub=0; while (HlManager::self()->syntax->nextItem(data)) { kdDebug(13010)<< "Adding item to list"<<endl; lastsub=addContextItem(last,lastsub,data); } } if (data) HlManager::self()->syntax->freeGroupInfo(data); } ContextAttribute->clear(); ItemAttribute->clear(); data=HlManager::self()->syntax->getGroupInfo("highlighting","itemData"); while (HlManager::self()->syntax->nextGroup(data)) { ContextAttribute->insertItem(HlManager::self()->syntax->groupData(data,QString("name"))); ItemAttribute->insertItem(HlManager::self()->syntax->groupData(data,QString("name"))); } if (data) HlManager::self()->syntax->freeGroupInfo(data); } QListViewItem *HlEditDialog::addContextItem(QListViewItem *_parent,QListViewItem *prev,struct syntaxContextData *data) { kdDebug(13010)<<HlManager::self()->syntax->groupItemData(data,QString("name")) << endl; QString dataname=HlManager::self()->syntax->groupItemData(data,QString("")); QString attr=(HlManager::self()->syntax->groupItemData(data,QString("attribute"))); QString context=(HlManager::self()->syntax->groupItemData(data,QString("context"))); char chr; if (! HlManager::self()->syntax->groupItemData(data,QString("char")).isEmpty()) chr= (HlManager::self()->syntax->groupItemData(data,QString("char")).latin1())[0]; else chr=0; QString stringdata=HlManager::self()->syntax->groupItemData(data,QString("String")); char chr1; if (! HlManager::self()->syntax->groupItemData(data,QString("char1")).isEmpty()) chr1= (HlManager::self()->syntax->groupItemData(data,QString("char1")).latin1())[0]; else chr1=0; bool insensitive=(HlManager::self()->syntax->groupItemData(data,QString("insensitive"))==QString("TRUE")); QString param(""); if ((dataname=="keyword") || (dataname=="dataType")) param=dataname; else if (dataname=="CharDetect") param=chr; else if ((dataname=="2CharDetect") || (dataname=="RangeDetect")) param=QString("%1%2").arg(chr).arg(chr1); else if ((dataname=="StringDetect") || (dataname=="AnyChar") || (dataname=="RegExpr")) param=stringdata; else kdDebug(13010)<<"***********************************"<<endl<<"Unknown entry for Context:"<<dataname<<endl; kdDebug(13010)<<dataname << endl; return new QListViewItem(_parent,prev,i18n(dataname.latin1())+" "+param,dataname,param,attr,context); } void HlEditDialog::currentSelectionChanged ( QListViewItem *it) { kdDebug(13010)<<"Update data view"<<endl<<"Depth:"<<it->depth()<<endl; currentItem=it; if (it->depth()==0) showContext(); else showItem(); } /****************************************************************************/ /* CONTEXTS */ /****************************************************************************/ void HlEditDialog::showContext() { stack->raiseWidget(HlEContext); ContextDescr->setText(currentItem->text(0)); ContextAttribute->setCurrentItem(currentItem->text(2).toInt()); ContextLineEnd->clear(); for (QListViewItem *it=contextList->firstChild();it;it=it->nextSibling()) ContextLineEnd->insertItem(it->text(0)); ContextLineEnd->setCurrentItem(currentItem->text(3).toInt()); // ContextAttribute->setText(currentItem->text(1)); // ContextLineEnd->setText(currentItem->text(2)); } void HlEditDialog::contextDescrChanged(const QString& name) { if (currentItem) 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 @@ -1,363 +1,363 @@ /*************************************************************************** katedocument.cpp - description ------------------- begin : Mon Jan 15 2001 copyright : (C) 2001 by Christoph "Crossfire" Cullmann (C) 2002 by Joseph Wenninger email : crossfire@babylon2k.de 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. * * * ***************************************************************************/ /* Copyright (C) 1998, 1999 Jochen Wilhelmy digisnap@cs.tu-berlin.de This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "katedocument.h" #include <qfileinfo.h> #include <qdatetime.h> #include <kmessagebox.h> #include <qpe/config.h> #include <qstring.h> #include <sys/time.h> #include <unistd.h> #include <stdio.h> #include <qtimer.h> #include <qobject.h> #include <qapplication.h> #include <qclipboard.h> #include <qfont.h> #include <qpainter.h> #include <qfile.h> #include <qtextstream.h> #include <qtextcodec.h> #include <kglobal.h> //#include <kcharsets.h> #include <kdebug.h> //#include <kinstance.h> #include <kglobalsettings.h> //#include <kaction.h> //#include <kstdaction.h> #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) { till = max; } PreHighlightedTill = till; updateLines(from,till); emit preHighlightChanged(PreHighlightedTill); if (PreHighlightedTill<RequestPreHighlightTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); } KateDocument::~KateDocument() { m_highlight->release(); writeConfig(); if ( !m_bSingleViewMode ) { m_views.setAutoDelete( true ); m_views.clear(); m_views.setAutoDelete( false ); } delete_d(this); } void KateDocument::openURL(const QString &filename) { m_file=filename; fileInfo->setFile (m_file); setMTime(); if (!fileInfo->exists() || !fileInfo->isReadable()) { qDebug("File doesn't exit or couldn't be read"); return ; } buffer->clear(); #warning fixme // buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); qDebug("Telling buffer to open file"); buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); setMTime(); if (myWordWrap) wrapText (myWordWrapAt); int hl = hlManager->wildcardFind( m_file ); setHighlight(hl); updateLines(); updateViews(); emit fileNameChanged(); return ; } bool KateDocument::saveFile() { QFile f( m_file ); if ( !f.open( IO_WriteOnly ) ) return false; // Error QTextStream stream(&f); stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers #warning fixme // stream.setCodec(KGlobal::charsets()->codecForName(myEncoding)); stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec int maxLine = numLines(); int line = 0; while(true) { stream << getTextLine(line)->getString(); line++; if (line >= maxLine) break; if (eolMode == KateDocument::eolUnix) stream << "\n"; else if (eolMode == KateDocument::eolDos) stream << "\r\n"; else if (eolMode == KateDocument::eolMacintosh) stream << '\r'; }; f.close(); fileInfo->setFile (m_file); setMTime(); if (!(d(this)->hlSetByUser)) { int hl = hlManager->wildcardFind( m_file ); setHighlight(hl); diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp index a85fb87..8e68262 100644 --- a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp +++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp @@ -346,226 +346,226 @@ void SelectConfigTab::getData(KateView *view) { if (opt[z]->isChecked()) configFlags |= flags[z]; // set flag if checked } view->setConfig(configFlags); } const int EditConfigTab::flags[] = {KateView::cfWordWrap, KateView::cfReplaceTabs, KateView::cfRemoveSpaces, KateView::cfAutoBrackets, KateView::cfGroupUndo, KateView::cfShowTabs, KateView::cfSmartHome, KateView::cfPageUDMovesCursor, KateView::cfWrapCursor}; EditConfigTab::EditConfigTab(QWidget *parent, KateView *view) : QWidget(parent, 0L) { QHBoxLayout *mainLayout; QVBoxLayout *cbLayout, *leLayout; int configFlags; mainLayout = new QHBoxLayout(this, 0, KDialog::spacingHint() ); // checkboxes cbLayout = new QVBoxLayout( mainLayout ); configFlags = view->config(); opt[0] = new QCheckBox(i18n("&Word wrap"), this); cbLayout->addWidget(opt[0], 0, AlignLeft); opt[0]->setChecked(view->doc()->wordWrap()); opt[1] = new QCheckBox(i18n("Replace &tabs with spaces"), this); cbLayout->addWidget(opt[1], 0, AlignLeft); opt[1]->setChecked(configFlags & flags[1]); opt[2] = new QCheckBox(i18n("&Remove trailing spaces"), this); cbLayout->addWidget(opt[2], 0, AlignLeft); opt[2]->setChecked(configFlags & flags[2]); opt[3] = new QCheckBox(i18n("&Auto brackets"), this); cbLayout->addWidget(opt[3], 0, AlignLeft); opt[3]->setChecked(configFlags & flags[3]); opt[4] = new QCheckBox(i18n("Group &undos"), this); cbLayout->addWidget(opt[4], 0, AlignLeft); opt[4]->setChecked(configFlags & flags[4]); opt[5] = new QCheckBox(i18n("&Show tabs"), this); cbLayout->addWidget(opt[5], 0, AlignLeft); opt[5]->setChecked(configFlags & flags[5]); opt[6] = new QCheckBox(i18n("Smart &home"), this); cbLayout->addWidget(opt[6], 0, AlignLeft); opt[6]->setChecked(configFlags & flags[6]); opt[7] = new QCheckBox(i18n("&Page up/down moves cursor"), this); cbLayout->addWidget(opt[7], 0, AlignLeft); opt[7]->setChecked(configFlags & flags[7]); opt[8] = new QCheckBox(i18n("Wrap &cursor"), this); cbLayout->addWidget(opt[8], 0, AlignLeft); opt[8]->setChecked(configFlags & flags[8]); cbLayout->addStretch(); // edit lines leLayout = new QVBoxLayout(); mainLayout->addLayout(leLayout,10); e1 = new QSpinBox(this); e1->setMinValue(20); e1->setMaxValue( 200); e1->setValue((int)(view->doc()->wordWrapAt())); #warning fixme e1->setLabel(i18n("Wrap Words At:")); e2 = new QSpinBox(this); e2->setMinValue(1); e2->setMaxValue(16); e2->setValue((int)view->tabWidth()); #warning fixme e2->setLabel(i18n("Tab/Indent Width:")); e3 = new QSpinBox(this); e3->setMinValue(5); e3->setMaxValue( 30000); #warning fixme e3->setLabel(i18n("Undo steps:")); e3->setValue((int)view->undoSteps()); leLayout->addWidget(e1, 0, AlignLeft); leLayout->addWidget(e2, 0, AlignLeft); leLayout->addWidget(e3, 0, AlignLeft); QVBox *box = new QVBox (this); leLayout->addWidget (box, 0, AlignLeft); new QLabel (i18n("Encoding:"), box); encoding = new QComboBox(box); #warning fixme #if 0 encoding->insertStringList (KGlobal::charsets()->availableEncodingNames()); encoding->setCurrentItem (KGlobal::charsets()->availableEncodingNames().findIndex(view->doc()->encoding())); #endif leLayout->addStretch(); // What is this? help QWhatsThis::add(opt[0], i18n("Word wrap is a feature that causes the editor to automatically start a new line of text and move (wrap) the cursor to the beginning of that new line. KateView will automatically start a new line of text when the current line reaches the length specified by the Wrap Words At: option.<p><b>NOTE:<b> Word Wrap will not change existing lines or wrap them for easy reading as in some applications.")); QWhatsThis::add(e1, i18n("If the Word Wrap option is selected this entry determines the length (in characters) at which the editor will automatically start a new line.")); QWhatsThis::add(opt[1], i18n("KateView will replace any tabs with the number of spaces indicated in the Tab Width: entry.")); QWhatsThis::add(e2, i18n("If the Replace Tabs By Spaces option is selected this entry determines the number of spaces with which the editor will automatically replace tabs.")); QWhatsThis::add(opt[2], i18n("KateView will automatically eliminate extra spaces at the ends of lines of text.")); QWhatsThis::add(opt[3], i18n("When the user types a left bracket ([,(, or {) KateView automatically enters the right bracket (}, ), or ]) to the right of the cursor.")); QWhatsThis::add(opt[4], i18n("Checking this will cause sequences of similar actions to be undone at once.")); QWhatsThis::add(opt[5], i18n("The editor will display a symbol to indicate the presence of a tab in the text.")); QWhatsThis::add(opt[6], i18n("Not yet implemented.")); QWhatsThis::add(opt[7], i18n("If this is selected, the insertion cursor will be moved to the first/last line when pressing the page up/down buttons.<p>If not selected, it will remain at it's relative position in the visible text.")); QWhatsThis::add(e3, i18n("Sets the number of undo/redo steps to record. More steps uses more memory.")); QWhatsThis::add(opt[8], i18n("When on, moving the insertion cursor using the <b>Left</b> and <b>Right</b> keys will go on to previous/next line at beginning/end of the line, similar to most editors.<p>When off, the insertion cursor cannot be moved left of the line start, but it can be moved off the line end, which can be very handy for programmers.")); } void EditConfigTab::getData(KateView *view) { int configFlags, z; configFlags = view->config(); for (z = 1; z < numFlags; z++) { configFlags &= ~flags[z]; if (opt[z]->isChecked()) configFlags |= flags[z]; } view->setConfig(configFlags); view->setEncoding (encoding->currentText()); view->doc()->setWordWrapAt(e1->value()); view->doc()->setWordWrap (opt[0]->isChecked()); view->setTabWidth(e2->value()); view->setUndoSteps(e3->value()); } ColorConfig::ColorConfig( QWidget *parent, char *name ) : QWidget( parent, name ) { QGridLayout *glay = new QGridLayout( this, 6, 2, 0, KDialog::spacingHint()); glay->setColStretch(1,1); glay->setRowStretch(5,1); QLabel *label; label = new QLabel( i18n("Background:"), this); label->setAlignment( AlignRight|AlignVCenter ); m_back = new KColorButton( this ); glay->addWidget( label, 0, 0 ); glay->addWidget( m_back, 0, 1 ); label = new QLabel( i18n("Selected:"), this); label->setAlignment( AlignRight|AlignVCenter ); m_selected = new KColorButton( this ); glay->addWidget( label, 2, 0 ); glay->addWidget( m_selected, 2, 1 ); // QWhatsThis help QWhatsThis::add(m_back, i18n("Sets the background color of the editing area")); QWhatsThis::add(m_selected, i18n("Sets the background color of the selection. To set the text color for selected text, use the "<b>Configure Highlighting</b>" dialog.")); } ColorConfig::~ColorConfig() { } void ColorConfig::setColors(QColor *colors) { m_back->setColor( colors[0] ); m_selected->setColor( colors[1] ); } void ColorConfig::getColors(QColor *colors) { colors[0] = m_back->color(); colors[1] = m_selected->color(); } FontConfig::FontConfig( QWidget *parent, char *name ) : QWidget( parent, name ) { // sizemanagment QGridLayout *grid = new QGridLayout( this, 1, 1 ); // QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); // QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); // int size = cfg. readNumEntry ( "FontSize", 10 ); // OFontSelector *m_fontselect; m_fontselect = new Opie::OFontSelector ( false, this, "FontTab" ); // m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); // QWhatsThis::add( m_fontselect, // tr( "Select the desired name, style and size of the default font applications will use." ) ); - connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), - this, SLOT( slotFontSelected( const QFont & ))); + connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), + this, SLOT( slotFontSelected(const QFont&))); grid->addWidget( m_fontselect, 0, 0); // #if 0 // m_fontchooser = new KFontChooser ( this ); // m_fontchooser->enableColumn(KFontChooser::StyleList, false); // grid->addWidget( m_fontchooser, 0, 0); -// connect (m_fontchooser, SIGNAL (fontSelected( const QFont & )), this, SLOT (slotFontSelected( const QFont & ))); +// connect (m_fontchooser, SIGNAL (fontSelected(const QFont&)), this, SLOT (slotFontSelected(const QFont&))); // #endif } FontConfig::~FontConfig() { } void FontConfig::setFont ( const QFont &font ) { //#if 0 m_fontselect->setFont (font); myFont = font; //#endif } void FontConfig::slotFontSelected( const QFont &font ) { myFont = font; } diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index 19a0127..32c1eab 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp @@ -1,237 +1,237 @@ /*************************************************************************** tinykate.cpp Tiny KATE mainwindow ------------------- begin : November 2002 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> ***************************************************************************/ /*************************************************************************** * * * This program is free softwaSre; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation. * * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * * * ***************************************************************************/ #include <qaction.h> #include <qtoolbutton.h> #include <qmenubar.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <opie2/ofiledialog.h> #include "tinykate.h" #include <katedocument.h> #include <kglobal.h> TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : QMainWindow( parent, name, f ) { shutDown=false; nextUnnamed=0; currentView=0; viewCount=0; setCaption(tr("TinyKATE")); KGlobal::setAppName("TinyKATE"); QMenuBar *mb = new QMenuBar( this ); mb->setMargin( 0 ); tabwidget=new OTabWidget(this); setCentralWidget(tabwidget); - connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); + connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*))); //FILE ACTIONS QPopupMenu *popup = new QPopupMenu( this ); // Action for creating a new document QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); a->addTo( popup ); connect(a, SIGNAL(activated()), this, SLOT(slotNew())); // Action for opening an exisiting document a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); // Action for saving document a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotSave())); // Action for saving document to a new name a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); // Action for closing the currently active document a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); a->addTo(popup); connect(a, SIGNAL(activated()), this, SLOT(slotClose())); mb->insertItem(tr("File"),popup); //EDIT ACTIONS // Action for cutting text editCut = new QToolButton( 0 ); editCut->setAutoRaise( true ); editCut->setIconSet( Resource::loadPixmap( "cut" ) ); // Action for Copying text editCopy = new QToolButton( 0 ); editCopy->setAutoRaise( true ); editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); // Action for pasting text editPaste = new QToolButton( 0 ); editPaste->setAutoRaise( true ); editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); // Action for finding / replacing text editFindReplace = new QToolButton( 0 ); editFindReplace->setAutoRaise( true ); editFindReplace->setIconSet( Resource::loadPixmap("find") ); // Action for undo editUndo = new QToolButton( 0 ); editUndo->setAutoRaise( true ); editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); // Action for redo editRedo = new QToolButton( 0 ); editRedo->setAutoRaise( true ); editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); //VIEW ACITONS popup = new QPopupMenu( this ); viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); viewIncFontSizes->addTo( popup ); viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); viewDecFontSizes->addTo( popup ); mb->insertItem(tr("View"),popup); popup = new QPopupMenu( this ); mb->insertItem(tr("Utils"),popup); mb->insertItem( editCut ); mb->insertItem( editCopy ); mb->insertItem( editPaste ); mb->insertItem( editFindReplace ); mb->insertItem( editUndo ); mb->insertItem( editRedo ); //Highlight management hlmenu=new QPopupMenu(this); HlManager *hlm=HlManager::self(); for (int i=0;i<hlm->highlights();i++) { hlmenu->insertItem(hlm->hlName(i),i); } popup->insertItem(tr("Highlighting"),hlmenu); utilSettings = new QAction( tr( "Settings" ), QString::null, 0, this, 0 ); utilSettings->addTo( popup); if( qApp->argc() > 1) open(qApp->argv()[1]); else slotNew(); } TinyKate::~TinyKate( ) { qWarning("TinyKate destructor\n"); shutDown=true; while (currentView!=0) { slotClose(); } if( KGlobal::config() != 0 ) { qWarning("deleting KateConfig object..\n"); delete KGlobal::config(); } } void TinyKate::slotOpen( ) { QString filename = Opie::OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, QString::null); if (!filename.isEmpty()) { open(filename); } } void TinyKate::open(const QString & filename) { KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; QFileInfo fi(filename); QString filenamed = fi.fileName(); tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); qDebug(filename); kd->setDocName( filenamed); kd->open( filename ); viewCount++; } void TinyKate::setDocument(const QString& fileref) { open( fileref ); } void TinyKate::slotCurrentChanged( QWidget * view) { if (currentView) { disconnect(editCopy,SIGNAL(activated()),currentView,SLOT(copy())); disconnect(editCut,SIGNAL(activated()),currentView,SLOT(cut())); disconnect(editPaste,SIGNAL(activated()),currentView,SLOT(paste())); disconnect(editUndo,SIGNAL(activated()),currentView,SLOT(undo())); disconnect(editRedo,SIGNAL(activated()),currentView,SLOT(redo())); disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); } currentView=(KTextEditor::View*)view; connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); } void TinyKate::slotNew( ) { KateDocument *kd= new KateDocument(false, false, this,0,this); KTextEditor::View *kv; tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), "tinykate/tinykate", tr("Unnamed %1").arg(nextUnnamed++)); viewCount++; } void TinyKate::slotClose( ) { if (currentView==0) return; KTextEditor::View *dv=currentView; |