KDevelop API Documentation

editors/qeditor/qeditor_view.cpp

Go to the documentation of this file.
00001 /* $Id: qeditor_view.cpp,v 1.48 2003/11/06 21:19:11 dagerbo Exp $ 00002 * 00003 * Copyright (C) 2001 Roberto Raggi (roberto@kdevelop.org) 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; see the file COPYING. If not, write to 00017 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 * Boston, MA 02111-1307, USA. 00019 * 00020 */ 00021 00029 #include "qeditor_view.h" 00030 #include "qeditor_part.h" 00031 #include "qeditor_settings.h" 00032 #include "qeditor_factory.h" 00033 #include "qeditor.h" 00034 #include "paragdata.h" 00035 #include "qeditorcodecompletion.h" 00036 #include "linenumberwidget.h" 00037 #include "markerwidget.h" 00038 #include "levelwidget.h" 00039 #include "gotolinedialog.h" 00040 #include "koFind.h" 00041 #include "koReplace.h" 00042 #include "qeditor_texthint.h" 00043 00044 #include <qregexp.h> 00045 #include <qlayout.h> 00046 #include <qpopupmenu.h> 00047 #include <private/qrichtext_p.h> 00048 00049 #include <kdebug.h> 00050 #include <kaction.h> 00051 #include <klocale.h> 00052 #include <kapplication.h> 00053 #include <kcombobox.h> 00054 #include <kdeversion.h> 00055 00056 #include "kdevkstdaction.h" 00057 00058 QEditorView::QEditorView( QEditorPart* document, QWidget* parent, const char* name ) 00059 : KTextEditor::View( document, parent, name ), 00060 m_document( document ), m_textHintToolTip( 0 ) 00061 { 00062 setInstance( QEditorPartFactory::instance() ); 00063 00064 QEditorPartFactory::registerView( this ); 00065 m_findDialog = new KoFindDialog( this, "FindDialog_0", long(KoFindDialog::FromCursor) ); 00066 m_replaceDialog = new KoReplaceDialog( this, "ReplaceDialog_0", 00067 long(KoReplaceDialog::PromptOnReplace | 00068 KoReplaceDialog::FromCursor) ); 00069 m_currentParag = 0; 00070 m_find = 0; 00071 m_replace = 0; 00072 m_options = 0; 00073 m_offset = 0; 00074 00075 QHBoxLayout* lay = new QHBoxLayout( this ); 00076 00077 m_editor = new QEditor( this ); 00078 m_lineNumberWidget = new LineNumberWidget( m_editor, this ); 00079 00080 m_markerWidget = new MarkerWidget( m_editor, this ); 00081 connect( document, SIGNAL(marksChanged()), 00082 m_markerWidget, SLOT(doRepaint()) ); 00083 connect( m_markerWidget, SIGNAL(markChanged(KTextEditor::Mark,KTextEditor::MarkInterfaceExtension::MarkChangeAction)), 00084 document, SIGNAL(markChanged(KTextEditor::Mark,KTextEditor::MarkInterfaceExtension::MarkChangeAction)) ); 00085 connect( m_markerWidget, SIGNAL(marksChanged()), document, SIGNAL(marksChanged()) ); 00086 00087 m_levelWidget = new LevelWidget( m_editor, this ); 00088 connect( m_levelWidget, SIGNAL(expandBlock(QTextParagraph*)), 00089 this, SLOT(expandBlock(QTextParagraph*)) ); 00090 connect( m_levelWidget, SIGNAL(collapseBlock(QTextParagraph*)), 00091 this, SLOT(collapseBlock(QTextParagraph*)) ); 00092 00093 lay->addWidget( m_markerWidget ); 00094 lay->addWidget( m_lineNumberWidget ); 00095 lay->addWidget( m_levelWidget ); 00096 lay->addWidget( m_editor ); 00097 00098 setFocusProxy( m_editor ); 00099 connect( m_editor, SIGNAL(cursorPositionChanged(int, int)), 00100 this, SIGNAL(cursorPositionChanged()) ); 00101 00102 // connections 00103 connect( m_editor, SIGNAL(textChanged()), 00104 doc(), SIGNAL(textChanged()) ); 00105 connect( doc(), SIGNAL(newStatus()), 00106 this, SIGNAL(newStatus()) ); 00107 connect( m_editor, SIGNAL(selectionChanged()), 00108 doc(), SIGNAL(selectionChanged()) ); 00109 00110 connect( m_editor, SIGNAL(ensureTextIsVisible(QTextParagraph*)), 00111 this, SLOT(ensureTextIsVisible(QTextParagraph*)) ); 00112 00113 m_pCodeCompletion = new QEditorCodeCompletion( this ); 00114 connect(m_pCodeCompletion,SIGNAL(completionAborted()), 00115 this,SIGNAL(completionAborted())); 00116 connect(m_pCodeCompletion,SIGNAL(completionDone()), 00117 this,SIGNAL(completionDone())); 00118 connect(m_pCodeCompletion,SIGNAL(argHintHidden()), 00119 this,SIGNAL(argHintHidden())); 00120 connect(m_pCodeCompletion,SIGNAL(completionDone(KTextEditor::CompletionEntry)), 00121 this,SIGNAL(completionDone(KTextEditor::CompletionEntry))); 00122 connect(m_pCodeCompletion,SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,QString *)), 00123 this,SIGNAL(filterInsertString(KTextEditor::CompletionEntry*,QString *)) ); 00124 00125 // set our XML-UI resource file 00126 setXMLFile( "qeditor_part.rc" ); 00127 00128 setupActions(); 00129 00130 configChanged(); 00131 00132 //enableTextHints( 500 ); 00133 } 00134 00135 QEditorView::~QEditorView() 00136 { 00137 delete( m_pCodeCompletion ); 00138 m_pCodeCompletion = 0; 00139 QEditorPartFactory::deregisterView( this ); 00140 } 00141 00142 void QEditorView::configChanged() 00143 { 00144 m_editor->configChanged(); 00145 00146 setMarkerWidgetVisible( QEditorSettings::self()->showMarkers() ); 00147 setLineNumberWidgetVisible( QEditorSettings::self()->showLineNumber() ); 00148 setLevelWidgetVisible( QEditorSettings::self()->showCodeFoldingMarkers() ); 00149 } 00150 00151 bool QEditorView::isMarkerWidgetVisible() const 00152 { 00153 return m_markerWidget->isVisible(); 00154 } 00155 00156 void QEditorView::setMarkerWidgetVisible( bool b ) 00157 { 00158 if( b ){ 00159 m_markerWidget->show(); 00160 } else { 00161 m_markerWidget->hide(); 00162 } 00163 } 00164 00165 bool QEditorView::isLineNumberWidgetVisible() const 00166 { 00167 return m_lineNumberWidget->isVisible(); 00168 } 00169 00170 void QEditorView::setLineNumberWidgetVisible( bool b ) 00171 { 00172 if( b ){ 00173 m_lineNumberWidget->show(); 00174 } else { 00175 m_lineNumberWidget->hide(); 00176 } 00177 } 00178 00179 bool QEditorView::isLevelWidgetVisible() const 00180 { 00181 return m_levelWidget->isVisible(); 00182 } 00183 00184 void QEditorView::setLevelWidgetVisible( bool b ) 00185 { 00186 if( b ){ 00187 m_levelWidget->show(); 00188 } else { 00189 m_levelWidget->hide(); 00190 } 00191 } 00192 00193 int QEditorView::tabStop() const 00194 { 00195 return m_editor->tabStop(); 00196 } 00197 00198 void QEditorView::setTabStop( int tabStop ) 00199 { 00200 m_editor->setTabStop( tabStop ); 00201 } 00202 00203 KTextEditor::Document* QEditorView::document() const 00204 { 00205 return m_document; 00206 } 00207 00208 QPoint QEditorView::cursorCoordinates() 00209 { 00210 QTextCursor *cursor = m_editor->textCursor(); 00211 QTextStringChar *chr = cursor->paragraph()->at( cursor->index() ); 00212 int h = cursor->paragraph()->lineHeightOfChar( cursor->index() ); 00213 int x = cursor->paragraph()->rect().x() + chr->x; 00214 int y, dummy; 00215 cursor->paragraph()->lineHeightOfChar( cursor->index(), &dummy, &y ); 00216 y += cursor->paragraph()->rect().y(); 00217 return m_editor->contentsToViewport( QPoint( x, y+h ) ); 00218 } 00219 00220 void QEditorView::cursorPosition(unsigned int *line, unsigned int *col) 00221 { 00222 *line = cursorLine(); 00223 *col = cursorColumn(); 00224 } 00225 00226 void QEditorView::cursorPositionReal(unsigned int *line, unsigned int *col) 00227 { 00228 *line = cursorLine(); 00229 *col = cursorColumnReal(); 00230 } 00231 00232 bool QEditorView::setCursorPosition(unsigned int line, unsigned int col) 00233 { 00234 #warning "TODO: implement QEditorView::setCursorPosition" 00235 kdDebug(9032) << "TODO: implement QEditorView::setCursorPosition" << endl; 00236 00237 QTextParagraph* p = m_editor->document()->paragAt( line ); 00238 if (p) 00239 ensureTextIsVisible( p ); 00240 00241 m_editor->setCursorPosition( line, col ); 00242 m_editor->ensureCursorVisible(); 00243 00244 return true; 00245 } 00246 00247 bool QEditorView::setCursorPositionReal(unsigned int line, unsigned int col) 00248 { 00249 QTextParagraph* p = m_editor->document()->paragAt( line ); 00250 if( p ) 00251 ensureTextIsVisible( p ); 00252 00253 m_editor->setCursorPosition( line, col ); 00254 m_editor->ensureCursorVisible(); 00255 return true; 00256 } 00257 00258 unsigned int QEditorView::cursorLine() 00259 { 00260 int line, col; 00261 m_editor->getCursorPosition( &line, &col ); 00262 return line; 00263 } 00264 00265 unsigned int QEditorView::cursorColumn() 00266 { 00267 const int tabwidth = 4; 00268 int line, col; 00269 00270 m_editor->getCursorPosition( &line, &col ); 00271 QString text = m_editor->text( line ).left( col ); 00272 col = 0; 00273 00274 for( uint i=0; i<text.length(); ++i ){ 00275 if( text[ i ] == QChar('\t') ){ 00276 col += tabwidth - (col % tabwidth); 00277 } else { 00278 ++col; 00279 } 00280 } 00281 return col; 00282 } 00283 00284 unsigned int QEditorView::cursorColumnReal() 00285 { 00286 int line, col; 00287 m_editor->getCursorPosition( &line, &col ); 00288 return col; 00289 } 00290 00291 void QEditorView::copy( ) const 00292 { 00293 m_editor->copy(); 00294 } 00295 00296 void QEditorView::cut( ) 00297 { 00298 m_editor->cut(); 00299 } 00300 00301 void QEditorView::paste( ) 00302 { 00303 m_editor->paste(); 00304 } 00305 00306 void QEditorView::installPopup( QPopupMenu *rmb_Menu ) 00307 { 00308 m_editor->setApplicationMenu( rmb_Menu ); 00309 } 00310 00311 void QEditorView::showArgHint(QStringList functionList, 00312 const QString& strWrapping, 00313 const QString& strDelimiter) 00314 { 00315 m_pCodeCompletion->showArgHint( functionList, strWrapping, strDelimiter ); 00316 } 00317 00318 void QEditorView::showCompletionBox(QValueList<KTextEditor::CompletionEntry> complList, 00319 int offset, 00320 bool casesensitive ) 00321 { 00322 emit aboutToShowCompletionBox(); 00323 m_pCodeCompletion->showCompletionBox( complList, offset, casesensitive ); 00324 } 00325 00326 QString QEditorView::currentTextLine() const 00327 { 00328 int line, col; 00329 m_editor->getCursorPosition( &line, &col ); 00330 return m_editor->text( line ); 00331 } 00332 00333 void QEditorView::insertText( const QString& text ) 00334 { 00335 m_editor->insert( text ); 00336 } 00337 00338 void QEditorView::setLanguage( const QString& language ) 00339 { 00340 m_editor->setLanguage( language ); 00341 } 00342 00343 QString QEditorView::language() const 00344 { 00345 return m_editor->language(); 00346 } 00347 00348 void QEditorView::indent() 00349 { 00350 m_editor->indent(); 00351 } 00352 00353 void QEditorView::gotoLine() 00354 { 00355 GotoLineDialog dlg; 00356 dlg.setEditor( m_editor ); 00357 dlg.exec(); 00358 } 00359 00360 void QEditorView::proceed() 00361 { 00362 // Start point 00363 QTextParagraph * firstParagraph = m_editor->document()->firstParagraph(); 00364 int firstIndex = 0; 00365 QTextParagraph * startParagraph = firstParagraph; 00366 int startIndex = 0; 00367 QTextParagraph * lastParagraph; 00368 int lastIndex; 00369 00370 // 'From Cursor' option 00371 QEditor* edit = m_editor; 00372 if ( edit && ( m_options & KoFindDialog::FromCursor ) ) 00373 { 00374 startParagraph = edit->textCursor()->paragraph(); 00375 startIndex = edit->textCursor()->index(); 00376 } // no else here ! 00377 00378 bool forw = ! (m_options & KoFindDialog::FindBackwards); 00379 00380 // 'Selected Text' option 00381 if ( edit && ( m_options & KoFindDialog::SelectedText ) ) 00382 { 00383 QTextCursor c1 = edit->document()->selectionStartCursor( QTextDocument::Standard ); 00384 firstParagraph = c1.paragraph(); 00385 firstIndex = c1.index(); 00386 QTextCursor c2 = edit->document()->selectionEndCursor( QTextDocument::Standard ); 00387 lastParagraph = c2.paragraph(); 00388 lastIndex = c2.index(); 00389 } 00390 else // Not 'find in selection', need to iterate over the framesets 00391 { 00392 lastParagraph = edit->document()->lastParagraph(); 00393 lastIndex = lastParagraph->length()-1; 00394 } 00395 00396 bool bProceed = true; 00397 if (forw) { 00398 while (bProceed) { // loop until cancelled 00399 bProceed = find_real( startParagraph, startIndex, lastParagraph, lastIndex ); 00400 if (bProceed) { 00401 bProceed = find_real( firstParagraph, firstIndex, startParagraph, startIndex ); 00402 } 00403 if (!m_editor->selectedText()) { 00404 bProceed = false; // nothing found in the whole selection or file 00405 } 00406 } 00407 } 00408 else { // backwards 00409 while (bProceed) { // loop until cancelled 00410 bProceed = find_real( firstParagraph, firstIndex, startParagraph, startIndex ); 00411 if (bProceed) { 00412 bProceed = find_real( startParagraph, startIndex, lastParagraph, lastIndex ); 00413 } 00414 if (!m_editor->selectedText()) { 00415 bProceed = false; // nothing found in the whole selection or file 00416 } 00417 } 00418 } 00419 } 00420 00421 bool QEditorView::find_real( QTextParagraph* firstParagraph, int firstIndex, 00422 QTextParagraph* lastParagraph, int lastIndex ) 00423 { 00424 Q_ASSERT( firstParagraph ); 00425 Q_ASSERT( lastParagraph ); 00426 00427 m_currentParag = firstParagraph; 00428 m_offset = 0; 00429 00430 if( firstParagraph == lastParagraph ){ 00431 m_offset = firstIndex; 00432 return process( firstParagraph->string()->toString().mid( firstIndex, lastIndex-firstIndex ) ); 00433 } else { 00434 bool forw = ! (m_options & KoFindDialog::FindBackwards); 00435 bool ret = true; 00436 if( forw ){ 00437 m_offset = firstIndex; 00438 QString str = m_currentParag->string()->toString(); 00439 ret = process( str.mid( firstIndex ) ); 00440 if (!ret) return false; 00441 } else { 00442 m_currentParag = lastParagraph; 00443 ret = process( lastParagraph->string()->toString().left( lastIndex + 1 ) ); 00444 if (!ret) return false; 00445 } 00446 00447 m_currentParag = forw ? firstParagraph->next() : lastParagraph->prev(); 00448 m_offset = 0; 00449 QTextParagraph* endParag = forw ? lastParagraph : firstParagraph; 00450 while( m_currentParag && m_currentParag != endParag ){ 00451 QString str = m_currentParag->string()->toString(); 00452 str = str.left( str.length() - 1 ); 00453 ret = process( str ); 00454 00455 if (!ret) return false; 00456 m_currentParag = forw ? m_currentParag->next() : m_currentParag->prev(); 00457 } 00458 Q_ASSERT( endParag == m_currentParag ); 00459 if ( forw ) 00460 { 00461 QString s = lastParagraph->string()->toString().left( lastIndex + 1 ); 00462 ret = process( s ); 00463 } else { 00464 m_offset = firstIndex; 00465 QString str = m_currentParag->string()->toString(); 00466 str = str.mid( firstIndex ); 00467 ret = process( str ); 00468 } 00469 return ret; 00470 } 00471 } 00472 00473 void QEditorView::doFind() 00474 { 00475 m_findDialog->m_find->setEditURL(m_editor->selectedText()); 00476 00477 if( m_findDialog->exec() ){ 00478 m_options = m_findDialog->options(); 00479 if ( m_find ) 00480 { 00481 m_find->abort(); 00482 delete m_find; 00483 } 00484 m_find = new KoFind( m_findDialog->pattern(), m_findDialog->options() ); 00485 connect( m_find, SIGNAL(highlight(const QString&,int,int,const QRect&)), 00486 this, SLOT(highlight(const QString&,int,int,const QRect&)) ); 00487 proceed(); 00488 delete m_find; 00489 m_find = 0; 00490 } 00491 } 00492 00493 void QEditorView::doReplace() 00494 { 00495 m_replaceDialog->m_find->setEditURL(m_editor->selectedText()); 00496 00497 if( m_replaceDialog->exec() ){ 00498 m_options = m_replaceDialog->options(); 00499 if ( m_replace ) 00500 { 00501 m_replace->abort(); 00502 delete m_replace; 00503 } 00504 m_replace = new KoReplace( m_replaceDialog->pattern(), m_replaceDialog->replacement(), 00505 m_replaceDialog->options() ); 00506 connect( m_replace, SIGNAL(highlight(const QString&,int,int,const QRect&)), 00507 this, SLOT(highlight(const QString&,int,int,const QRect&)) ); 00508 connect( m_replace, SIGNAL(replace(const QString&,int,int,int,const QRect&)), 00509 this, SLOT(replace(const QString&,int,int,int,const QRect&)) ); 00510 proceed(); 00511 delete m_replace; 00512 m_replace = 0; 00513 } 00514 } 00515 00516 bool QEditorView::process( const QString& _text ) 00517 { 00518 if( m_find ){ 00519 return m_find->find( _text, QRect() ); 00520 } else if( m_replace ) { 00521 QString text( _text ); 00522 return m_replace->replace( text, QRect() ); 00523 } 00524 return false; 00525 } 00526 00527 void QEditorView::highlight( const QString& /*text*/, int matchingIndex, int matchedLength, const QRect& ) 00528 { 00529 m_editor->setSelection( m_currentParag->paragId(), matchingIndex, 00530 m_currentParag->paragId(), matchingIndex + matchedLength ); 00531 } 00532 00533 void QEditorView::replace( const QString&, int matchingIndex, 00534 int /*matchingLength*/, int matchedLength, 00535 const QRect &/*expose*/ ) 00536 { 00537 m_editor->setSelection( m_currentParag->paragId(), matchingIndex, 00538 m_currentParag->paragId(), matchingIndex + matchedLength ); 00539 m_editor->removeSelectedText(); 00540 m_editor->insertAt( m_replaceDialog->replacement(), 00541 m_currentParag->paragId(), 00542 matchingIndex ); 00543 } 00544 00545 void QEditorView::ensureTextIsVisible( QTextParagraph* p) 00546 { 00547 internalEnsureVisibleBlock( p ); 00548 00549 m_editor->refresh(); 00550 doRepaint(); 00551 00552 // some math 00553 QRect r = m_editor->paragraphRect(p->paragId()); 00554 int y = r.y(); 00555 int h = r.height(); 00556 y = y + h/2; 00557 int cY = m_editor->contentsY(); 00558 h = m_editor->viewport()->size().height(); 00559 00560 // if the paragraph is in the lower quarter of the viewport, center it 00561 if (y > (cY + (3*h)/4)) { 00562 m_editor->center(0, y); 00563 } 00564 } 00565 00566 void QEditorView::internalEnsureVisibleBlock( QTextParagraph* p ) 00567 { 00568 ParagData* data = (ParagData*) p->extraData(); 00569 00570 if( !data ){ 00571 return; 00572 } 00573 int lev = data->level(), parentLevel; 00574 00575 while( lev > 0 ){ 00576 QTextParagraph* parent = p->prev(); 00577 00578 parentLevel = parent ? ((ParagData*) parent->extraData())->level() : 0; 00579 00580 while( parentLevel > lev ){ 00581 parent = parent->prev(); 00582 parentLevel = ((ParagData*) parent->extraData())->level(); 00583 } 00584 if( parentLevel < lev ){ 00585 internalExpandBlock(p); 00586 lev = parentLevel; 00587 } 00588 00589 p = parent; 00590 } 00591 } 00592 00593 void QEditorView::internalExpandBlock( QTextParagraph* p ) 00594 { 00595 ParagData* data = (ParagData*) p->extraData(); 00596 if( !data ){ 00597 return; 00598 } 00599 int lev = QMAX( data->level() - 1, 0 ); 00600 00601 data->setOpen( true ); 00602 00603 p = p->next(); 00604 while( p ){ 00605 ParagData* data = (ParagData*) p->extraData(); 00606 if( data ){ 00607 p->show(); 00608 data->setOpen( true ); 00609 00610 if( data->level() == lev ){ 00611 break; 00612 } 00613 p = p->next(); 00614 } 00615 } 00616 } 00617 00618 void QEditorView::internalCollapseBlock( QTextParagraph* p ) 00619 { 00620 ParagData* data = (ParagData*) p->extraData(); 00621 if( !data ){ 00622 return; 00623 } 00624 00625 int lev = QMAX( data->level() - 1, 0 ); 00626 data->setOpen( false ); 00627 00628 p = p->next(); 00629 while( p ){ 00630 ParagData* data = (ParagData*) p->extraData(); 00631 if( data ){ 00632 00633 if( data->level() == lev ){ 00634 break; 00635 } 00636 00637 // kdDebug(9032) << "hide parag " << p->paragId() << " level = " << data->level() << endl; 00638 p->hide(); 00639 00640 p = p->next(); 00641 } 00642 } 00643 } 00644 00645 void QEditorView::expandBlock( QTextParagraph* p ) 00646 { 00647 internalExpandBlock( p ); 00648 00649 m_editor->setCursorPosition( p->paragId(), 0 ); 00650 m_editor->refresh(); 00651 doRepaint(); 00652 } 00653 00654 void QEditorView::collapseBlock( QTextParagraph* p ) 00655 { 00656 internalCollapseBlock( p ); 00657 00658 m_editor->setCursorPosition( p->paragId(), 0 ); 00659 m_editor->refresh(); 00660 doRepaint(); 00661 } 00662 00663 void QEditorView::doRepaint() 00664 { 00665 m_markerWidget->doRepaint(); 00666 m_lineNumberWidget->doRepaint(); 00667 m_levelWidget->doRepaint(); 00668 } 00669 00670 void QEditorView::selectAll( ) 00671 { 00672 m_editor->selectAll(); 00673 } 00674 00675 void QEditorView::setupActions() 00676 { 00677 // create our actions 00678 KStdAction::open( doc(), SLOT(fileOpen()), actionCollection() ); 00679 KStdAction::saveAs( doc(), SLOT(fileSaveAs()), actionCollection() ); 00680 KStdAction::save( doc(), SLOT(save()), actionCollection() ); 00681 00682 KAction *action = new KAction( i18n("Reloa&d"), "reload", Key_F5, 00683 doc(), SLOT(fileReload()), actionCollection(), "file_reload" ); 00684 action->setToolTip(i18n("Reload")); 00685 action->setWhatsThis(i18n("<b>Reload</b><p>Reloads the current document from disk.")); 00686 00687 action = KStdAction::undo( doc(), SLOT(undo()), actionCollection() ); 00688 action->setWhatsThis(i18n("Reverts the most recent editing actions.")); 00689 action = KStdAction::redo( doc(), SLOT(redo()), actionCollection() ); 00690 action->setWhatsThis(i18n("Reverts the most recent undo operation.")); 00691 00692 action = KStdAction::cut( this, SLOT(cut()), actionCollection() ); 00693 action->setWhatsThis(i18n("Cuts the selected text and moves it to the clipboard.")); 00694 action = KStdAction::copy( this, SLOT(copy()), actionCollection() ); 00695 action->setWhatsThis(i18n("Copies the selected text to the clipboard.")); 00696 00697 action = KStdAction::pasteText( this, SLOT(paste()), actionCollection() ); 00698 action->setWhatsThis(i18n("Pastes previously copied or cut clipboard contents.")); 00699 action = KStdAction::selectAll( this, SLOT(selectAll()), actionCollection() ); 00700 action->setWhatsThis(i18n("Selects the entire text of the current document.")); 00701 00702 action = KStdAction::gotoLine( this, SLOT(gotoLine()), actionCollection() ); 00703 action->setWhatsThis(i18n("Opens a dialog and lets you choose a line that you want the cursor to move to.")); 00704 action = KStdAction::find( this, SLOT(doFind()), actionCollection() ); 00705 action->setWhatsThis(i18n("Looks up the first occurence of a piece of text or regular expression.")); 00706 action = KStdAction::replace( this, SLOT(doReplace()), actionCollection() ); 00707 action->setWhatsThis(i18n("Looks up a piece of text or regular expression and replace the result with some given text.")); 00708 00709 action = new KAction( i18n("&Indent"), "indent", CTRL + Key_I, 00710 editor(), SLOT(indent()), 00711 actionCollection(), "edit_indent" ); 00712 action->setToolTip(i18n("Indent")); 00713 action->setWhatsThis(i18n("<b>Indent</b><p>Indents a selected block of text.")); 00714 00715 action = new KAction( i18n("Collapse All Blocks"), "collapse all blocks", 0, 00716 this, SLOT(collapseAllBlocks()), 00717 actionCollection(), "edit_collapse_all_blocks" ); 00718 action->setToolTip(i18n("Collapse all blocks")); 00719 action->setWhatsThis(i18n("<b>Collapse all blocks</b><p>Collapses all blocks in the current document.")); 00720 00721 action = new KAction( i18n("Expand All Blocks"), "collapse all blocks", 0, 00722 this, SLOT(expandAllBlocks()), 00723 actionCollection(), "edit_expand_all_blocks" ); 00724 action->setToolTip(i18n("Expand all blocks")); 00725 action->setWhatsThis(i18n("<b>Expand all blocks</b><p>Expands all blocks in the current document.")); 00726 00727 action = new KAction( i18n("Start Macro"), "start macro", CTRL + Key_ParenLeft, 00728 editor(), SLOT(startMacro()), 00729 actionCollection(), "tools_start_macro" ); 00730 action->setToolTip(i18n("Start macro")); 00731 action->setWhatsThis(i18n("<b>Start macro</b><p>Starts recording a macro based on the editor input.")); 00732 00733 action = new KAction( i18n("Stop Macro"), "stop macro", CTRL + Key_ParenRight, 00734 editor(), SLOT(stopMacro()), 00735 actionCollection(), "tools_stop_macro" ); 00736 action->setToolTip(i18n("Stop macro")); 00737 action->setWhatsThis(i18n("<b>Stop macro</b><p>Stops recording a macro.")); 00738 00739 action = new KAction( i18n("Execute Macro"), "execute macro", CTRL + Key_E, 00740 editor(), SLOT(executeMacro()), 00741 actionCollection(), "tools_execute_macro" ); 00742 action->setToolTip(i18n("Execute macro")); 00743 action->setWhatsThis(i18n("<b>Execute macro</b><p>Executes previously recorded macro.")); 00744 00745 action = new KAction( i18n("&Configure Editor..."), "configure editor", 0, 00746 doc(), SLOT(configDialog()), 00747 actionCollection(), "set_confdlg" ); 00748 action->setToolTip(i18n("Configure editor")); 00749 action->setWhatsThis(i18n("<b>Configure editor</b><p>Opens an editor configuration dialog.")); 00750 // actionCollection(), "settings_configure_editor" ); 00751 } 00752 00753 void QEditorView::expandAllBlocks() 00754 { 00755 QTextParagraph* p = m_editor->document()->firstParagraph(); 00756 while( p ){ 00757 ParagData* data = (ParagData*) p->extraData(); 00758 if( data && data->isBlockStart() ){ 00759 internalExpandBlock( p ); 00760 } 00761 p = p->next(); 00762 } 00763 00764 m_editor->refresh(); 00765 doRepaint(); 00766 } 00767 00768 void QEditorView::collapseAllBlocks() 00769 { 00770 QTextParagraph* p = m_editor->document()->firstParagraph(); 00771 while( p ){ 00772 ParagData* data = (ParagData*) p->extraData(); 00773 if( data && data->isBlockStart() ){ 00774 internalCollapseBlock( p ); 00775 } 00776 p = p->next(); 00777 } 00778 00779 m_editor->refresh(); 00780 doRepaint(); 00781 } 00782 00783 QString QEditorView::computeTextHint( int line, int column ) 00784 { 00785 QString s; 00786 emit needTextHint( line, column, s ); 00787 return s; 00788 } 00789 00790 void QEditorView::enableTextHints( int timeout ) 00791 { 00792 if( !m_textHintToolTip ) 00793 m_textHintToolTip = new QEditorTextHint( this ); 00794 00795 #if KDE_VERSION > 305 00796 m_textHintToolTip->setWakeUpDelay( timeout ); 00797 #else 00798 00799 #endif 00800 } 00801 00802 void QEditorView::disableTextHints() 00803 { 00804 if( m_textHintToolTip ){ 00805 delete m_textHintToolTip; 00806 m_textHintToolTip = 0; 00807 } 00808 } 00809 00810 00811 #include "qeditor_view.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:38 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003