author | paule <paule> | 2007-01-13 07:03:58 (UTC) |
---|---|---|
committer | paule <paule> | 2007-01-13 07:03:58 (UTC) |
commit | 75c65c1dc728929f0430b8faf956195657b73311 (patch) (side-by-side diff) | |
tree | 52fce1ccec59285e4e887d908b0da3a0431c13d9 | |
parent | e9768d9a498037195b8ca3bb5155db7419f30e1a (diff) | |
download | opie-75c65c1dc728929f0430b8faf956195657b73311.zip opie-75c65c1dc728929f0430b8faf956195657b73311.tar.gz opie-75c65c1dc728929f0430b8faf956195657b73311.tar.bz2 |
Call qApp->processEvents() before deleting dialog objects to avoid crashes (Qt bug?)
-rw-r--r-- | noncore/apps/tinykate/libkate/view/kateview.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp index 423634b..c5673a5 100644 --- a/noncore/apps/tinykate/libkate/view/kateview.cpp +++ b/noncore/apps/tinykate/libkate/view/kateview.cpp @@ -1384,1083 +1384,1086 @@ void KateView::slotNewUndo() editUndo->setText(t); t = i18n("Re&do"); // it would be nicer to fetch the original string if (state & 2) { editRedo->setEnabled(true); t += ' '; t += i18n(undoTypeName(nextRedoType())); } else { editRedo->setEnabled(false); } editRedo->setText(t); #endif } void KateView::slotHighlightChanged() { // setHighlight->setCurrentItem(getHl()); } void KateView::keyPressEvent( QKeyEvent *ev ) { switch ( ev->key() ) { case Key_Left: if ( ev->state() & ShiftButton ) { if ( ev->state() & ControlButton ) shiftWordLeft(); else shiftCursorLeft(); } else if ( ev->state() & ControlButton ) wordLeft(); else cursorLeft(); break; case Key_Right: if ( ev->state() & ShiftButton ) { if ( ev->state() & ControlButton ) shiftWordRight(); else shiftCursorRight(); } else if ( ev->state() & ControlButton ) wordRight(); else cursorRight(); break; case Key_Home: if ( ev->state() & ShiftButton ) { if ( ev->state() & ControlButton ) shiftTop(); else shiftHome(); } else if ( ev->state() & ControlButton ) top(); else home(); break; case Key_End: if ( ev->state() & ShiftButton ) { if ( ev->state() & ControlButton ) shiftBottom(); else shiftEnd(); } else if ( ev->state() & ControlButton ) bottom(); else end(); break; case Key_Up: if ( ev->state() & ShiftButton ) shiftUp(); else if ( ev->state() & ControlButton ) scrollUp(); else up(); break; case Key_Down: if ( ev->state() & ShiftButton ) shiftDown(); else if ( ev->state() & ControlButton ) scrollDown(); else down(); break; case Key_PageUp: if ( ev->state() & ShiftButton ) shiftPageUp(); else if ( ev->state() & ControlButton ) topOfView(); else pageUp(); break; case Key_PageDown: if ( ev->state() & ShiftButton ) shiftPageDown(); else if ( ev->state() & ControlButton ) bottomOfView(); else pageDown(); break; case Key_Return: case Key_Enter: keyReturn(); break; case Key_Delete: if ( ev->state() & ControlButton ) { VConfig c; shiftWordRight(); myViewInternal->getVConfig(c); myDoc->delMarkedText(c); myViewInternal->update(); } else keyDelete(); break; case Key_Backspace: if ( ev->state() & ControlButton ) { VConfig c; shiftWordLeft(); myViewInternal->getVConfig(c); myDoc->delMarkedText(c); myViewInternal->update(); } else backspace(); break; case Key_Insert: toggleInsert(); break; case Key_K: if ( ev->state() & ControlButton ) { killLine(); break; } default: KTextEditor::View::keyPressEvent( ev ); return; break; } ev->accept(); } void KateView::setCursorPosition( int line, int col, bool /*mark*/ ) { setCursorPositionInternal( line, col ); } void KateView::getCursorPosition( int *line, int *col ) { if ( line ) *line = currentLine(); if ( col ) *col = currentColumn(); } int KateView::currentLine() { return myViewInternal->cursor.y; } int KateView::currentColumn() { return myDoc->currentColumn(myViewInternal->cursor); } int KateView::currentCharNum() { return myViewInternal->cursor.x; } void KateView::setCursorPositionInternal(int line, int col) { PointStruc cursor; cursor.x = col; cursor.y = line; myViewInternal->updateCursor(cursor); myViewInternal->center(); // myViewInternal->updateView(ufPos, 0, line*myDoc->fontHeight - height()/2); // myDoc->updateViews(myViewInternal); //uptade all other views except this one myDoc->updateViews(); } int KateView::config() { int flags; flags = configFlags; if (myDoc->singleSelection()) flags |= KateView::cfSingleSelection; return flags; } void KateView::setConfig(int flags) { bool updateView; // cfSingleSelection is a doc-property myDoc->setSingleSelection(flags & KateView::cfSingleSelection); flags &= ~KateView::cfSingleSelection; if (flags != configFlags) { // update the view if visibility of tabs has changed updateView = (flags ^ configFlags) & KateView::cfShowTabs; configFlags = flags; emit newStatus(); if (updateView) myViewInternal->update(); } } int KateView::tabWidth() { return myDoc->tabChars; } void KateView::setTabWidth(int w) { myDoc->setTabWidth(w); myDoc->updateViews(); } void KateView::setEncoding (QString e) { myDoc->setEncoding (e); myDoc->updateViews(); } int KateView::undoSteps() { return myDoc->undoSteps; } void KateView::setUndoSteps(int s) { myDoc->setUndoSteps(s); } bool KateView::isReadOnly() { return myDoc->readOnly; } bool KateView::isModified() { return myDoc->modified; } void KateView::setReadOnly(bool m) { myDoc->setReadOnly(m); } void KateView::setModified(bool m) { myDoc->setModified(m); } bool KateView::isLastView() { return myDoc->isLastView(1); } KateDocument *KateView::doc() { return myDoc; } int KateView::undoState() { if (isReadOnly()) return 0; else return myDoc->undoState; } int KateView::nextUndoType() { return myDoc->nextUndoType(); } int KateView::nextRedoType() { return myDoc->nextRedoType(); } void KateView::undoTypeList(QValueList<int> &lst) { myDoc->undoTypeList(lst); } void KateView::redoTypeList(QValueList<int> &lst) { myDoc->redoTypeList(lst); } const char * KateView::undoTypeName(int type) { return KateActionGroup::typeName(type); } QColor* KateView::getColors() { return myDoc->colors; } void KateView::applyColors() { myDoc->tagAll(); myDoc->updateViews(); } bool KateView::isOverwriteMode() const { return ( configFlags & KateView::cfOvr ); } void KateView::setOverwriteMode( bool b ) { if ( isOverwriteMode() && !b ) setConfig( configFlags ^ KateView::cfOvr ); else setConfig( configFlags | KateView::cfOvr ); } void KateView::toggleInsert() { setConfig(configFlags ^ KateView::cfOvr); } void KateView::toggleVertical() { setConfig(configFlags ^ KateView::cfVerticalSelect); } int KateView::numLines() { return myDoc->numLines(); } QString KateView::text() { return myDoc->text(); } QString KateView::currentTextLine() { TextLine::Ptr textLine = myDoc->getTextLine(myViewInternal->cursor.y); return QString(textLine->getText(), textLine->length()); } QString KateView::textLine(int num) { TextLine::Ptr textLine = myDoc->getTextLine(num); return QString(textLine->getText(), textLine->length()); } QString KateView::currentWord() { return myDoc->getWord(myViewInternal->cursor); } QString KateView::word(int x, int y) { PointStruc cursor; cursor.y = (myViewInternal->yPos + y)/myDoc->fontHeight; if (cursor.y < 0 || cursor.y > myDoc->lastLine()) return QString(); cursor.x = myDoc->textPos(myDoc->getTextLine(cursor.y), myViewInternal->xPos-2 + x); return myDoc->getWord(cursor); } void KateView::setText(const QString &s) { myDoc->setText(s); myDoc->updateViews(); } void KateView::insertText(const QString &s, bool /*mark*/) { VConfig c; myViewInternal->getVConfig(c); myDoc->insert(c, s); myDoc->updateViews(); } bool KateView::hasMarkedText() { return myDoc->hasMarkedText(); } QString KateView::markedText() { return myDoc->markedText(configFlags); } bool KateView::canDiscard() { int query; if (isModified()) { query = KMessageBox::warningYesNoCancel(this, i18n("The current Document has been modified.\nWould you like to save it?")); switch (query) { case KMessageBox::Yes: //yes if (save() == CANCEL) return false; if (isModified()) { query = KMessageBox::warningContinueCancel(this, i18n("Could not save the document.\nDiscard it and continue?"), QString::null, i18n("&Discard")); if (query == KMessageBox::Cancel) return false; } break; case KMessageBox::Cancel: //cancel return false; } } return true; } void KateView::flush() { if (canDiscard()) myDoc->flush(); } KateView::fileResult KateView::save() { int query = KMessageBox::Yes; if (isModified()) { return saveAs(); } return OK; } KateView::fileResult KateView::saveAs() { return OK; } void KateView::doCursorCommand(int cmdNum) { VConfig c; myViewInternal->getVConfig(c); if (cmdNum & selectFlag) c.flags |= KateView::cfMark; if (cmdNum & multiSelectFlag) c.flags |= KateView::cfMark | KateView::cfKeepSelection; cmdNum &= ~(selectFlag | multiSelectFlag); myViewInternal->doCursorCommand(c, cmdNum); myDoc->updateViews(); } void KateView::doEditCommand(int cmdNum) { VConfig c; myViewInternal->getVConfig(c); myViewInternal->doEditCommand(c, cmdNum); myDoc->updateViews(); } void KateView::undoMultiple(int count) { if (isReadOnly()) return; VConfig c; myViewInternal->getVConfig(c); myDoc->undo(c, count); myDoc->updateViews(); } void KateView::redoMultiple(int count) { if (isReadOnly()) return; VConfig c; myViewInternal->getVConfig(c); myDoc->redo(c, count); myDoc->updateViews(); } void KateView::undoHistory() { UndoHistory *undoH; undoH = new UndoHistory(this, this, "UndoHistory", true); undoH->setCaption(i18n("Undo/Redo History")); connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo())); connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int))); connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int))); undoH->exec(); delete undoH; } static void kwview_addToStrList(QStringList &list, const QString &str) { if (list.count() > 0) { if (list.first() == str) return; QStringList::Iterator it; it = list.find(str); if (*it != 0L) list.remove(it); if (list.count() >= 16) list.remove(list.fromLast()); } list.prepend(str); } void KateView::find() { SearchDialog *searchDialog; if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, searchFlags & ~KateView::sfReplace); // If the user has marked some text we use that otherwise // use the word under the cursor. QString str; if (myDoc->hasMarkedText()) str = markedText(); if (str.isEmpty()) str = currentWord(); if (!str.isEmpty()) { str.replace(QRegExp("^\n"), ""); int pos=str.find("\n"); if (pos>-1) str=str.left(pos); searchDialog->setSearchText( str ); } myViewInternal->focusOutEvent(0L);// QT bug ? if (searchDialog->exec() == QDialog::Accepted) { kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt); initSearch(s, searchFlags); findAgain(s); } + qApp->processEvents(); delete searchDialog; } void KateView::replace() { SearchDialog *searchDialog; if (isReadOnly()) return; if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected; searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList, searchFlags | KateView::sfReplace); // If the user has marked some text we use that otherwise // use the word under the cursor. QString str; if (myDoc->hasMarkedText()) str = markedText(); if (str.isEmpty()) str = currentWord(); if (!str.isEmpty()) { str.replace(QRegExp("^\n"), ""); int pos=str.find("\n"); if (pos>-1) str=str.left(pos); searchDialog->setSearchText( str ); } myViewInternal->focusOutEvent(0L);// QT bug ? if (searchDialog->exec() == QDialog::Accepted) { // myDoc->recordReset(); kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor()); kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith()); searchFlags = searchDialog->getFlags(); initSearch(s, searchFlags); replaceAgain(); } + qApp->processEvents(); delete searchDialog; } void KateView::gotoLine() { GotoLineDialog *dlg; PointStruc cursor; dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines()); // dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this); if (dlg->exec() == QDialog::Accepted) { // myDoc->recordReset(); cursor.x = 0; cursor.y = dlg->getLine() - 1; myDoc->needPreHighlight(cursor.y); myViewInternal->updateCursor(cursor); myViewInternal->center(); myViewInternal->updateView(KateView::ufUpdateOnScroll); myDoc->updateViews(this); //uptade all other views except this one } + qApp->processEvents(); delete dlg; } void KateView::initSearch(SConfig &s, int flags) { s.flags = flags; s.setPattern(myDoc->searchForList.first()); if (!(s.flags & KateView::sfFromBeginning)) { // If we are continuing a backward search, make sure we do not get stuck // at an existing match. s.cursor = myViewInternal->cursor; TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y); QString const txt(textLine->getText(),textLine->length()); const QString searchFor= myDoc->searchForList.first(); int pos = s.cursor.x-searchFor.length()-1; if ( pos < 0 ) pos = 0; pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive); if ( s.flags & KateView::sfBackward ) { if ( pos <= s.cursor.x ) s.cursor.x= pos-1; } else if ( pos == s.cursor.x ) s.cursor.x++; } else { if (!(s.flags & KateView::sfBackward)) { s.cursor.x = 0; s.cursor.y = 0; } else { s.cursor.x = -1; s.cursor.y = myDoc->lastLine(); } s.flags |= KateView::sfFinished; } if (!(s.flags & KateView::sfBackward)) { if (!(s.cursor.x || s.cursor.y)) s.flags |= KateView::sfFinished; } s.startCursor = s.cursor; } void KateView::continueSearch(SConfig &s) { if (!(s.flags & KateView::sfBackward)) { s.cursor.x = 0; s.cursor.y = 0; } else { s.cursor.x = -1; s.cursor.y = myDoc->lastLine(); } s.flags |= KateView::sfFinished; s.flags &= ~KateView::sfAgain; } void KateView::findAgain(SConfig &s) { int query; PointStruc cursor; QString str; QString searchFor = myDoc->searchForList.first(); if( searchFor.isEmpty() ) { find(); return; } do { query = KMessageBox::Cancel; if (myDoc->doSearch(s,searchFor)) { cursor = s.cursor; if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; myViewInternal->updateCursor(s.cursor); //does deselectAll() exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false); } else { if (!(s.flags & KateView::sfFinished)) { // ask for continue if (!(s.flags & KateView::sfBackward)) { // forward search str = i18n("End of document reached.\n" "Continue from the beginning?"); query = KMessageBox::warningContinueCancel(this, str, i18n("Find"), i18n("Continue")); } else { // backward search str = i18n("Beginning of document reached.\n" "Continue from the end?"); query = KMessageBox::warningContinueCancel(this, str, i18n("Find"), i18n("Continue")); } continueSearch(s); } else { // wrapped KMessageBox::sorry(this, i18n("Search string '%1' not found!").arg(searchFor), i18n("Find")); } } } while (query == KMessageBox::Continue); } void KateView::replaceAgain() { if (isReadOnly()) return; replaces = 0; if (s.flags & KateView::sfPrompt) { doReplaceAction(-1); } else { doReplaceAction(KateView::srAll); } } void KateView::doReplaceAction(int result, bool found) { int rlen; PointStruc cursor; bool started; QString searchFor = myDoc->searchForList.first(); QString replaceWith = myDoc->replaceWithList.first(); rlen = replaceWith.length(); switch (result) { case KateView::srYes: //yes myDoc->recordStart(this, s.cursor, configFlags, KateActionGroup::ugReplace, true); myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); replaces++; if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) s.startCursor.x += rlen - s.matchedLength; if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); break; case KateView::srNo: //no if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength; break; case KateView::srAll: //replace all deleteReplacePrompt(); do { started = false; while (found || myDoc->doSearch(s,searchFor)) { if (!started) { found = false; myDoc->recordStart(this, s.cursor, configFlags, KateActionGroup::ugReplace); started = true; } myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith); replaces++; if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x) s.startCursor.x += rlen - s.matchedLength; if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen; } if (started) myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent); } while (!askReplaceEnd()); return; case KateView::srCancel: //cancel deleteReplacePrompt(); return; default: replacePrompt = 0L; } do { if (myDoc->doSearch(s,searchFor)) { //text found: highlight it, show replace prompt if needed and exit cursor = s.cursor; if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength; myViewInternal->updateCursor(cursor); //does deselectAll() exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true); if (replacePrompt == 0L) { replacePrompt = new ReplacePrompt(this); myDoc->setPseudoModal(replacePrompt);//disable(); connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot())); replacePrompt->show(); //this is not modal } return; //exit if text found } //nothing found: repeat until user cancels "repeat from beginning" dialog } while (!askReplaceEnd()); deleteReplacePrompt(); } void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) { int x1, x2, y1, y2, xPos, yPos; VConfig c; myViewInternal->getVConfig(c); myDoc->selectLength(cursor,slen,c.flags); TextLine::Ptr textLine = myDoc->getTextLine(cursor.y); x1 = myDoc->textWidth(textLine,cursor.x) -10; x2 = myDoc->textWidth(textLine,cursor.x + slen) +20; y1 = myDoc->fontHeight*cursor.y -10; y2 = y1 + myDoc->fontHeight +30; xPos = myViewInternal->xPos; yPos = myViewInternal->yPos; if (x1 < 0) x1 = 0; if (replace) y2 += 90; if (x1 < xPos || x2 > xPos + myViewInternal->width()) { xPos = x2 - myViewInternal->width(); } if (y1 < yPos || y2 > yPos + myViewInternal->height()) { xPos = x2 - myViewInternal->width(); yPos = myDoc->fontHeight*cursor.y - height()/3; } myViewInternal->setPos(xPos, yPos); myViewInternal->updateView(flags);// | ufPos,xPos,yPos); myDoc->updateViews(this); } void KateView::deleteReplacePrompt() { myDoc->setPseudoModal(0L); } bool KateView::askReplaceEnd() { QString str; int query; myDoc->updateViews(); if (s.flags & KateView::sfFinished) { // replace finished str = i18n("%1 replacement(s) made").arg(replaces); KMessageBox::information(this, str, i18n("Replace")); return true; } // ask for continue if (!(s.flags & KateView::sfBackward)) { // forward search str = i18n("%1 replacement(s) made.\n" "End of document reached.\n" "Continue from the beginning?").arg(replaces); query = KMessageBox::questionYesNo(this, str, i18n("Replace"), i18n("Continue"), i18n("Stop")); } else { // backward search str = i18n("%1 replacement(s) made.\n" "Beginning of document reached.\n" "Continue from the end?").arg(replaces); query = KMessageBox::questionYesNo(this, str, i18n("Replace"), i18n("Continue"), i18n("Stop")); } replaces = 0; continueSearch(s); return (query == KMessageBox::No); } void KateView::replaceSlot() { doReplaceAction(replacePrompt->result(),true); } void KateView::installPopup(QPopupMenu *rmb_Menu) { rmbMenu = rmb_Menu; } void KateView::readConfig() { KateConfig *config = KGlobal::config(); config->setGroup("Kate View"); searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt); configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark; // config->sync(); } void KateView::writeConfig() { KateConfig *config = KGlobal::config(); config->setGroup("Kate View"); config->writeEntry("SearchFlags",searchFlags); config->writeEntry("ConfigFlags",configFlags); // config->sync(); } void KateView::readSessionConfig(KateConfig *config) { PointStruc cursor; myViewInternal->xPos = config->readNumEntry("XPos"); myViewInternal->yPos = config->readNumEntry("YPos"); cursor.x = config->readNumEntry("CursorX"); cursor.y = config->readNumEntry("CursorY"); myViewInternal->updateCursor(cursor); myIconBorder = config->readBoolEntry("IconBorder on"); setIconBorder(myIconBorder); } void KateView::writeSessionConfig(KateConfig *config) { config->writeEntry("XPos",myViewInternal->xPos); config->writeEntry("YPos",myViewInternal->yPos); config->writeEntry("CursorX",myViewInternal->cursor.x); config->writeEntry("CursorY",myViewInternal->cursor.y); config->writeEntry("IconBorder on", myIconBorder); } void KateView::configDialog() { #warning fixme #if 1 KDialogBase *kd = new KDialogBase(KDialogBase::IconList, i18n("Configure Editor"), KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help , KDialogBase::Ok, this, "tabdialog"); // color options QFrame *page=kd->addPage(i18n("Colors")); (new QVBoxLayout(page))->setAutoAdd(true); ColorConfig *colorConfig = new ColorConfig(page); QColor* colors = getColors(); colorConfig->setColors(colors); page = kd->addPage(i18n("Fonts")); (new QVBoxLayout(page))->setAutoAdd(true); FontConfig *fontConfig = new FontConfig(page); fontConfig->setFont (myDoc->getFont()); // indent options page=kd->addPage(i18n("Indent")); (new QVBoxLayout(page))->setAutoAdd(true); IndentConfigTab *indentConfig = new IndentConfigTab(page, this); // select options page=kd->addPage(i18n("Select")); (new QVBoxLayout(page))->setAutoAdd(true); SelectConfigTab *selectConfig = new SelectConfigTab(page, this); // edit options page=kd->addPage(i18n("Edit")); (new QVBoxLayout(page))->setAutoAdd(true); EditConfigTab *editConfig = new EditConfigTab(page, this); HighlightDialogPage *hlPage; HlManager *hlManager; HlDataList hlDataList; ItemStyleList defaultStyleList; hlManager = HlManager::self(); defaultStyleList.setAutoDelete(true); hlManager->getDefaults(defaultStyleList); hlDataList.setAutoDelete(true); //this gets the data from the KateConfig object hlManager->getHlDataList(hlDataList); page=kd->addPage(i18n("Highlighting")); (new QVBoxLayout(page))->setAutoAdd(true); hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page); if ( QPEApplication::execDialog( kd )) { // color options colorConfig->getColors(colors); myDoc->setFont (fontConfig->getFont()); applyColors(); // indent options indentConfig->getData(this); // select options selectConfig->getData(this); // edit options editConfig->getData(this); // spell checker hlManager->setHlDataList(hlDataList); hlManager->setDefaults(defaultStyleList); hlPage->saveData(); } // delete kd; #endif } int KateView::getHl() { return myDoc->highlightNum(); } void KateView::setDontChangeHlOnSave() { myDoc->setDontChangeHlOnSave(); } void KateView::setHl(int n) { myDoc->setHighlight(n); myDoc->setDontChangeHlOnSave(); myDoc->updateViews(); } int KateView::getEol() { return myDoc->eolMode; } void KateView::setEol(int eol) { if (isReadOnly()) return; myDoc->eolMode = eol; myDoc->setModified(true); } void KateView::paintEvent(QPaintEvent *e) { int x, y; QRect updateR = e->rect(); // update rectangle // debug("Update rect = ( %i, %i, %i, %i )", // updateR.x(),updateR.y(), updateR.width(), updateR.height() ); int ux1 = updateR.x(); int uy1 = updateR.y(); int ux2 = ux1 + updateR.width(); int uy2 = uy1 + updateR.height(); QPainter paint; paint.begin(this); QColorGroup g = colorGroup(); x = width(); y = height(); paint.setPen(g.dark()); if (uy1 <= 0) paint.drawLine(0,0,x-2,0); if (ux1 <= 0) paint.drawLine(0,1,0,y-2); paint.setPen(black); if (uy1 <= 1) paint.drawLine(1,1,x-3,1); if (ux1 <= 1) paint.drawLine(1,2,1,y-3); paint.setPen(g.midlight()); if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2); if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2); paint.setPen(g.light()); if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1); if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1); x -= 2 + 16; y -= 2 + 16; if (ux2 > x && uy2 > y) { paint.fillRect(x,y,16,16,g.background()); } paint.end(); } void KateView::resizeEvent(QResizeEvent *) { // debug("Resize %d, %d",e->size().width(),e->size().height()); //myViewInternal->resize(width() -20, height() -20); myViewInternal->tagAll(); myViewInternal->updateView(0/*ufNoScroll*/); } // Applies a new pattern to the search context. void SConfig::setPattern(QString &newPattern) { bool regExp = (flags & KateView::sfRegularExpression); m_pattern = newPattern; if (regExp) { m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive); m_regExp.setPattern(m_pattern); } } // Applies the search context to the given string, and returns whether a match was found. If one is, // the length of the string matched is also returned. int SConfig::search(QString &text, int index) { bool regExp = (flags & KateView::sfRegularExpression); bool caseSensitive = (flags & KateView::sfCaseSensitive); if (flags & KateView::sfBackward) { if (regExp) { index = text.findRev(m_regExp, index); } else { index = text.findRev(m_pattern, index, caseSensitive); } } else { if (regExp) { index = text.find(m_regExp, index); } else { index = text.find(m_pattern, index, caseSensitive); } } // Work out the matched length. if (index != -1) { if (regExp) { |