Index: branches/KDEVELOP_1_4/kdevelop/ChangeLog =================================================================== --- branches/KDEVELOP_1_4/kdevelop/ChangeLog (revision 100290) +++ branches/KDEVELOP_1_4/kdevelop/ChangeLog (revision 100291) @@ -1,462 +1,465 @@ +2001-06-04 jbb + * bugfix: crash when typing F4 on empty project + 2001-06-02 rokrau@yahoo.com * some minor reorganization of the ctags code and a little enhancement so that not only cpp files but also cxx files are found in header/source switching 2001-06-01 jbb * Patch from August Hörandl just a little "adjustment" to the clone functionalities "templates" - added the copy constructor - corrected operator << and >> 2001-06-01 rokrau@yahoo.com * initial Fortran support, Fortran files are recognized as source files instead of data files and they can be compiled * switch between source and header files now works also without ctags support. This is slower but shouldn't be noticable for smaller projects. * the methods CKDevelop::readProperties and CKDevelop::saveProperties are, as it seems, not called from anywhere anymore, so I commented them out. This marks them for deletion in the next code cleanup. * improved the implementation of the CTags support a little bit. 2001-06-01 Harald Fernengel * added parenthesis highlighting code (stole it from quanta, so if it isn't working please don't blame me ;). Very primitive, works only for () [] and {} 2001-05-30 F@lk Brettschneider * bugfix: focus problems when starting KDevelop in TabPage mode * bugfix: 0L access crash in DocViewMan::slot_gotFocus (reported by Peter Zimmermann) 2001-05-30 F@lk Brettschneider * kdevelop-speed-drop bug fixed (wandering through the popup menu) * from-the-department:-"pointers are evil" bug fixed (reported by rokrau) 2001-05-30 Christian Couder * Improved a little code bookmarks. 2001-05-28 F@lk Brettschneider * TabPage MDI mode ready to use now, please test it! * better icons for the views 2001-05-27 Harald Fernengel * bugfix: Tools-dialog got into an endless loop if all tools were deleted 2001-05-27 F@lk Brettschneider * further work on TabPage mode, (land in sight!) ; * File->Close(), Window->Close(), Window->CloseAll() fixed, DocViewMan improved therefore, should better consider outside/inside changes now 2001-05-26 F@lk Brettschneider * further work on TabPage MDI mode * bugfix: 0L pointer accesses in kwrite lib fixed (important for TabPage mode session loading) 2001-05-24 F@lk Brettschneider * bugfix: solved event timing problem with KDE's window manager on a flood of mixed show, hide and reparent events on app startup --> now we hide the main widget until readDockConfig has finished (you need to update your libkdeui.so (of kdelibs) to tonight's version, too!) * switch between TabPage mode and Childframe mode works properly now 2001-05-22 F@lk Brettschneider * bugfix: backswitch from Toplevel mode to Childframe mode works properly now * --> that's why: enabled readDockConfig() in CKDevelop constructor again 2001-05-22 Harald Fernengel * Added 2 slots activateNextWin() and activatePrevWin() to QextMdiMainFrm. * Added 2 new keyboard accels: "Goto Next Window" and "Goto Previous Window" to easily cycle through the open windows. default-keys: Alt-PgUp and Alt-PgDown 2001-05-19 Harald Fernengel * Added support for events. Define them in "eventsrc" and fire them via KNotifyClient::event(). Currently we have two events: "BuildSuccess" and "BuildError". 2001-05-19 F@lk Brettschneider * fixed focus problems introduced with the bugfixes on 2001-05-18 2001-05-18 F@lk Brettschneider * prevent a gotFocus() signal in QextMdiChildView's activate(). Hope that helps... ; * bugfix: reverted the change for setGeometry(..) called in QextMdiChildFrm::setState(), it didn't work ; * applied patch for QextMDI by Lars Beikirch (lars.beikirch@gmx.net) to make a better fix for the QEvent::ChildInserted/ChildRemoved problem with messageboxes and modal dialogs 2001-05-17 F@lk Brettschneider * probably the bugfix for the 'popupmenu speed drop' problem 2001-05-16 F@lk Brettschneider * evil hack in KDevSession to get rid of the event timing problem when adding a flood of new views to MDI * bugfix: set correct position of system popupmenu of MDI child view 2001-05-16 Christian Couder * Move the browser bookmark stuff from ckdevelop to docviewman. * Rename some browser bookmark methods. * Rename some browser bookmark attributes in docviewman. * Improve browser bookmark popup menu. 2001-05-15 F@lk Brettschneider * bugfix: statusbar resize in case of looong texts doesn't happen any more (Sorry, it wasn't in KStatusBar but in KDevelop's m_statusLabel) * mispelled word 'documenation' fixed 2001-05-14 rokrau@yahoo.com * Check whether the CTags program is installed. * Check whether the user even wants to use the CTags search database. This can now be set in the Options->KDevelop Setup dialog. * Removed Make Tags option, this is now automatic, if the file isnt there, it is created upon loading the tags file. * Made the creation and loading of the CTags database a "blocking" process. * Finally, if the user want to use CTags the database is now loaded when the Project is opened. 2001-05-14 F@lk Brettschneider * bugfix in QextMDI: consider a messagebox with parent==this isn't a real child widget :-/ Don't insert it in the emulated internal MDI-view focus-loop. 2001-05-12 rokrau@yahoo.com * Update: The functionality of the CTags search implementation is being concentrated in an implementation class so it can later be made into a plugin. * Bugfix: F12 now leaves the cursor where it was if the file was opened. 2001-05-11 jbb * Patch from August Hörandl updates clone dialog * remove warnings from code 2001-05-11 F@lk Brettschneider * new feature: now cursor positions in views are saved/restored to/from .kdevses-Session 2001-05-11 jbb * Replace the CMakeOuputWidget with one derived from qmultilineedit. Hmmm - haven't we been here before? Wel not quite this does more than the old qmultilineedit widget and is faster than the qlistview approach. 2001-05-11 F@lk Brettschneider * bugfix: if a file is changed outside the application, it will now be noticed with focus change * bugfix: removing a file from RFV or LFV should remove the views as well now * bugfix: closing a view checks if the file is modified, appropriate dialogs appear 2001-05-10 F@lk Brettschneider * made application accelerators work also for the Toplevel MDI mode which is needed for usuability. * bugfix: crash on Ctrl+f when no view was open 2001-05-09 F@lk Brettschneider * some bugfixes in QextMDI for the view focus change in Toplevel MDI mode 2001-05-09 Ralf Nolden * fixed up the kcmodule errors, works now. TODO would be the binary (standalone) and the desktop file but I think the users will find out about that themselves. 2001-05-08 rokrau@yahoo.com * added F12 for switch to header/source * added Edit menu entries for CTags related functionality 2001-05-07 F@lk Brettschneider * bugfix: prevented annoying undock of output tool-views when calling Make or Run * bugfix: prevented annoying switch to class_tree tool-view when stepping through code with the internal debugger or opening a function subtree in VAR tool-view 2001-05-06 F@lk Brettschneider * bugfix: annoying question 'changed outside the editor. Wanna save?' although not changed is removed now. * further work on toggling tree and output views on/off (needs update to latest kdeui library) 2001-05-05 F@lk Brettschneider * bugfix: avoid crash when closing the app during project loading. 2001-05-01 jbb * Optionally send Tools ouput to message view patch from Harald Fernengel 2001-05-04 rokrau@yahoo.com * some more polishing on the CTags search functionality. * added an option to switch between header and source files per RMC 2001-05-04 F@lk Brettschneider * prevent project session loading from flicker 2001-05-03 rokrau@yahoo.com * Applied Harald Fernengel second set of patches for the grepdialog. 2001-05-03 F@lk Brettschneider * bad behaviour fixed: avoid flickering when adding new maximized MDI views to the MDI system * bugfix: proper reinsertion of items in mainframe's fillWindowMenu() 2001-05-01 jbb * Vertical scrollbar improvements patch from Jens Zurheide 2001-05-01 jbb * grep dialog and write access patches from Harald Fernengel 2001-04-30 F@lk Brettschneider * improved menu stuff for tree and output tool views 2001-04-28 F@lk Brettschneider * on/off switch for certain single tool views improved (common behaviour now, new popupmenus, delayed buttons) (Note: requires latest KDE version from cvs!) 2001-04-25 F@lk Brettschneider * bugfix: there was a bloody event cycle in layoutTaskBar() 2001-04-21 rokrau@yahoo.com * I have the first "working" draft of ctags support done now. It's still mostly a proof of concept but I will polish it a bit over time now. Select an include file and RMC will let you open the file through its location in the tags file. 2001-04-20 F@lk Brettschneider * bugfix: crash at Windows->CloseAll+Windows->Close * nice icon for the MDI views * 2 steps of reactivating the trees-on/off button - now for a compound group of dockwidgets 2001-04-19 F@lk Brettschneider * improved Options->KDevelop->User_interface page 2001-04-18 jbb * Horizontal scroll bar patch from Jens Zurheide * null pointer test in closeWindow() 2001-04-17 rokrau@yahoo.com * fixed one crash in docviewman.cpp * some more integration work on the ctags support 2001-04-18 F@lk Brettschneider * moved the MDI mode selection to Options->KDevelop->user_interface * bugfix: concerning the visibility of the MDI view taskbar 2001-04-17 F@lk Brettschneider * likely the bugfix for the crash when closing an MDI view 2001-04-16 rokrau@yahoo.com * Added preliminary ctags support, not functional yet but good enough for benchmarking. 2001-04-16 F@lk Brettschneider * supported set/get the setting if the mainframe is in 'maximized Childframe mode' added loading of that in CKDevelop::readOptions() 2001-04-12 F@lk Brettschneider * bugfix: switching in View->Tab_Text works again but not completely right, use latest KDE sources from HEAD (12/04/2001) 2001-04-10 rokrau@yahoo.com * some small changes that should make analysing print problems easier, e.g. printing is handled by its own KShellProcess now. 2001-04-10 F@lk Brettschneider * splitted tree tab view and output tab view into single tool views. Still unfinished, but ready to play with it. (It's a trial. If that is too complex, maybe we could replace it by the old version again later. I hope we needn't to do that.) 2001-04-08 F@lk Brettschneider * added MDI-view taskbar entry to "View" menu, actually it should work but it doesn't yet. :-( That taskbar problem will tear me down 6 foot deep... 2001-04-07 Christian Couder * Fix a bug due to the last modified attribute of the kwritedoc not initialised. When we create a kwritedoc, now we check if the file exists and if this is true the we set the last modified date. 2001-04-08 jbb * Add manpage display to menu 2001-04-07 F@lk Brettschneider * bugfix: ignore queryClose() and queryExit() at application startup time (which actually belongs to the closing of the KMessageBox widget), this also speeds up the startup of KDevelop because we don't save the whole program state to KConfig any more which is useless. And this seems to fix the problem with saving toolbar states (QextMdiTaskBar) that aint already processed but are only pending in this moment. * bugfix: added missing flag WDestructiveClose in the QextMdiMainFrm constructor * bugfix: remove the according MDI covers from their control list when closing views 2001-04-07 Christian Couder * Clean the DocViewManager class. 2001-04-06 jbb * Add manpage display 2001-04-04 jbb * More improvements in class parser (handle throw() better) from * Daniel Engelschalt 2001-03-31 F@lk Brettschneider * cleaned up a little bit * 0L pointer checks for m_docViewManager->currentEditView() added in many slots * HTML docu views are saved/load to/from .kdevses * bugfix: in doCloseAllDocs(): iterator got confused because of removing a doc reference from the doc list 2001-03-30 F@lk Brettschneider * implemented KDevelop's XML-based session loading&saving (currently MDI stuff, only) in a *.kdevses file * why? Answer: To separate stuff from the project which causes CVS merge conflicts when working in teams * therefore is class KDevSession now * it's not finished yet for docu stuff, but works for KWriteDocs and CEditViews * TODO: session of mainframe window and geometry of trees and output widgets 2001-03-29 jbb * Improved struct handling in class parser from * Daniel Engelschalt * use $(LIB_QT) $(LIB_KDECORE) etc where appropriate 2001-03-25 F@lk Brettschneider * bugfix: repaired design mistake in rewritten DocViewMan: KWrite docs can have several views, consider that at closing * that's why I added 2 methods KWriteDoc::viewCount() and KWriteDoc::viewList() 2001-03-25 F@lk Brettschneider * bugfix: CKDevelop::doActivateView() removed; QWidget::setFocus() does the job ;) 2001-03-25 Christian Couder * Bid rewrite if the DocViewManager stuff. * Removed the TEditInfo and DocViewNode structs. 2001-03-11 bretzel * Added: Instanciate new static attributes in cpp file. * Added: New feature: Read-Write property for new attribute and Automaticly implement properties methods in cpp file. * Fixed: Disabled unused undo button in Classproperties dialog - No code yet for it... 2001-03-21 jbb * Fixed: Crash when right click on empty space in watch window. 2001-03-20 F@lk Brettschneider * So this is real MDI now. Create new views for the current document using "Window-->New Window"! * applied bugfixes of Roland Krause . Thanks a lot, Roland! 2001-03-19 F@lk Brettschneider * adapted HTML browser to DocViewMan MDI-mechanism (E.g. removed browser_widget and replaced it with m_docViewManager->currentBrowserDoc()) 2001-03-18 F@lk Brettschneider * bugfix: switched off automatic focus - wtf, (removed enterEvent() from CEditWidget) 2001-03-18 Christian Couder * Fix a bug (in switchToFile) in the change I previously commited. * Fix some bookmark bugs. 2001-03-18 F@lk Brettschneider * applied overridden bugfix again: DocViewMan::slotFileSaveAll doesn't crash any more * bugfix: possible crash in KWriteDoc::currentColumn(..) 2001-03-18 Christian Couder * Moved all the edit_info stuff from the CKDevelop class to the DocViewMan class. * Code simplified in many places in ckdevelop files. 2001-03-17 jbb * Re-write message_widget to have coloured error messages - removed * cerrormessageparser.cpp .h 2001-03-18 F@lk Brettschneider * bugfix: added focusNextPrevChild(..) to avoid a focusOut, this enables the Tab key again, switched off subwidget focus loop * bugfix: CKDevelop::slotFileSaveAll doesn't crash any more 2001-03-17 jbb * add dialog for library settings - it's a bit crude :( 2001-03-16 Christian Couder * global bookmarks, there are still bugs and the implementation will probably change. 2001-03-16 F@lk Brettschneider * Closing and reopen edit files should work now without crash. * There were bugs in the DocViewMan... 2001-03-14 F@lk Brettschneider * now QextMDI can look like an SDI application! :-) (the 4. MDI mode we have got) * new QextMdiChildView constructor added (by Eva Brucherseifer, Thanks!) * some 0L pointer access bugfixes * bugfix: raise on click works now also for afterwards inserted child widgets * setPixmap in childview calls setPixmap in childframe as expected * taskbar button count == 0L works properly now 2001-03-14 F@lk Brettschneider * got rid of s_tab_view, DocViewMan::currentDocType() added and used * some bugfixes (Roland Krause's crash on startup as well) * switch of tree views adapted 2001-03-12 F@lk Brettschneider * bugfixes: crash on exit (wrong type casts, forgot to remove browser view from MDI control) 2001-03-12 F@lk Brettschneider * further work on MDI, some connect()s from init...() moved to DocViewMan::createView() * some bugfixes in the DocViewMan 2001-03-11 F@lk Brettschneider * clearBookmarks() is a KWriteDoc method now, KWrite::clearBookmark() just calls its KWriteDoc * KWriteDoc: setFileName(), setModified(), setText(), isModified() is public now (for direct access of the document (documents are the central place in an MDI architecture)) * architecture changed in a way that cpp_widget and header_widget is away now, use CKDevelop::m_docViewManager for those things now 2001-03-11 F@lk Brettschneider * DocViewMan bugfixes * adapted these CKDevelop slots: slotOptionsEditor, slotOptionsEditorColors, slotOptionsSyntaxHighlightingDefaults, slotOptionsSyntaxHighlighting 2001-03-10 F@lk Brettschneider * DocViewMan improved (set/get current doc and view, delete views) * replaced all edit_widget in CKDevelop by m_docViewManager->currentEditView() * other MDI stuff 2001-03-07 jbb * add sharedlib_rootname and sharedlib_LDFLAGS to project file. These can be set against each sharedlib, which allows us to use kdevelop to regenerate the Makefile.am for kdevelop. Regenerate the Makefile.ams and restore the project file. Add Roland's buildmake patch. This tidies up the buildmake process a good deal. 2001-03-06 F@lk Brettschneider * initial code for QextMDI-based MDI feature added: - The DocViewMan is the MDI manager which is responsible for creating documents and multiple views on such documents ; - CKDevelop::initView() adapted - CKDevelop::switchToFile(..) adapted - CEditWidget adapted a little bit, some methods are public now in KWriteDoc, KWriteView and KWrite * the whole thing is very unusable, I just give other developers the chance to contribute, stay tuned for further development... 2001-03-06 jbb * Fixed: Dirs containing "++" would cause kimport to fail. 2001-02-26 jbb * Fixed: Window placement at startup was wrong Screen width missed iconBorder width adjustment. patch Jens Zurheide 2001-02-25 jbb * Fixed: CPrint dialog had problems with null params. based on patch from Ravikiran Rajagopal 2001-02-25 jbb * Fixed: Creating a cpp project didn't work. 2001-02-24 jbb * Fixed: kimport was run directly requiring perl to be in /usr/bin. This was incorrect. When this failed it revealed a crash in the classparser which should not be called if reading the project files failed. 2001-02-24 jbb * Remove restriction on version numbers 2001-02-24 jbb * Fixed: after a distclean if the qt dir wasn't entered then the configure args ended up being "--with-qt-dir= ". This failed the qt configure test. 2001-02-23 jbb * Fixed Multiple tools beng started after adding a tool grep support for Solaris - find params needed adjusting Update of QExtMDI template. 2001-02-20ish * kdevelop1.4 tagged for release as KDE_2_1_RELEASE. If you want bug fixes and other small enhancements then continue to extract kdevelop using the branch of KDEVELOP_1_4. 2000-12-30 jbb * Ported 1.3 to kde2 - This is an interim version that allows users to do away with kde1 whilst kdevelop2.0 is being developed. Index: branches/KDEVELOP_1_4/kdevelop/kdevelop/coutputwidget.cpp =================================================================== --- branches/KDEVELOP_1_4/kdevelop/kdevelop/coutputwidget.cpp (revision 100290) +++ branches/KDEVELOP_1_4/kdevelop/kdevelop/coutputwidget.cpp (revision 100291) @@ -1,512 +1,519 @@ /*************************************************************************** coutputwidget.cpp - the output window in KDevelop ------------------- begin : 5 Aug 1998 copyright : (C) 1998 by Sandy Meier email : smeier@rz.uni-potsdam.de ***************************************************************************/ /*************************************************************************** * * * 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 "coutputwidget.h" #include #include #include #include #include COutputWidget::COutputWidget(QWidget* parent, const char* name) : // KEdit(parent,name) QMultiLineEdit(parent, name) { } void COutputWidget::insertAtEnd(const QString& s) { int row = (numLines() < 1)? 0 : numLines()-1; // correct workaround for QMultilineEdit // the string inside could be NULL, and so QMultilineEdit fails int col = qstrlen(textLine(row)); if (s.left(1) == "\n" && row == 0 && col == 0) insertAt(" "+s, row, col); else insertAt(s, row, col); } // --------------------------------------------------------------------------- // This widget processes the makefile output and displays the error lines in // garish colours. // // All lines output from make to strerr are blue. If _any_ line contains a // file:linenumber then they are red. // // Keys F4 and SHIFT-F4 go to next/previous error lines. // Pressing ENTER or RETURN or a left mouse click on an error line will display // the file/linenumber in the editor. // // By default we display the last output in the widget. When the user moves off the // last character then the display is "held" at that point. Moving the cursor to the // last character will start the widget following the last text again. // // It was useful to use the QMultiLineEdit code as it supports text selection within // the widget, especially multiline text selection. Using a QListView as we were // previously, was also a problem as it slowed down significantly when the list -// became large and we we're displaying the newly appended text. +// became large and we were displaying the newly appended text. // // Not the most wonderful code in the world :(( // A big chunk of QMultiLineEdit was copied here and modified so that we can // have coloured output lines. Unfortunately, I couldn't find any other way to // achieve this as QMultiLineEdit changes pens internally and when trying to modify // the colorgroup externally it just seemed to change all text rather than the line :(( // I'm sure it is possible but I gave in... // --------------------------------------------------------------------------- CMakeOutputWidget::CMakeOutputWidget(QWidget* parent, const char* name) : QMultiLineEdit(parent, name), m_buf(), m_enterDir("[^\n]*: Entering directory `(.*)'\n"), m_leaveDir("[^\n]*: Leaving directory `([^\n]*)'\n"), m_errorGcc("([^: \t]+):([0-9]+)[:,].*") { + it = m_errorMap.begin(); // setReadOnly(true); } // --------------------------------------------------------------------------- void CMakeOutputWidget::insertAtEnd(const QString& text, MakeOutputErrorType defaultType) { m_buf += text; int pos; while ( (pos = m_buf.find('\n')) != -1) { QString line = m_buf.left(pos+1); m_buf.remove(0, pos+1); // extract file info from this line - if any processLine(line, defaultType); // add to the end of the text - highlighting is done in the // paint routine. int row = (numLines() < 1)? 0 : numLines()-1; int col = qstrlen(textLine(row)); bool displayAdditions=atEnd(); insertAt(line, row, col); if (displayAdditions) setCursorPosition(numLines()+1,0); } } // --------------------------------------------------------------------------- void CMakeOutputWidget::start() { clear(); m_dirStack.clear(); m_errorMap.clear(); // dummy needed ? ErrorDetails errorDetails("", -1, Normal); m_errorMap.insert(-1, errorDetails); it = m_errorMap.begin(); } // --------------------------------------------------------------------------- void CMakeOutputWidget::processLine(const QString& line, MakeOutputErrorType type) { QString fileInErr = QString::null; int lineInErr = -1; const int errorGccFileGroup = 1; const int errorGccRowGroup = 2; if (m_enterDir.match(line)) { QString *dir = new QString(m_enterDir.group(1)); m_dirStack.push(dir); return; } if (m_leaveDir.match(line)) { QString *dir = m_dirStack.pop(); delete dir; return; } if (m_errorGcc.match(line)) { type = Error; fileInErr = m_errorGcc.group(errorGccFileGroup); lineInErr = QString(m_errorGcc.group(errorGccRowGroup)).toInt()-1; if (fileInErr.left(1) != "/") if (m_dirStack.top()) fileInErr.prepend("/").prepend(*m_dirStack.top()); } if (type != Normal) { // add the error keyed on the line number in the make output widget ErrorDetails errorDetails(fileInErr, lineInErr, type); m_errorMap.insert(numLines()-1, errorDetails); } } // --------------------------------------------------------------------------- void CMakeOutputWidget::viewNextError() { - while (++it != m_errorMap.end()) + if (!m_errorMap.isEmpty()) { - ErrorDetails errorDetails = it.data(); - if (!errorDetails.m_fileName.isEmpty() && errorDetails.m_lineNumber >= 0) + while (++it != m_errorMap.end()) { - selectLine(it.key()); - emit switchToFile(errorDetails.m_fileName, errorDetails.m_lineNumber); - return; + ErrorDetails errorDetails = it.data(); + if (!errorDetails.m_fileName.isEmpty() && errorDetails.m_lineNumber >= 0) + { + selectLine(it.key()); + emit switchToFile(errorDetails.m_fileName, errorDetails.m_lineNumber); + return; + } } } kapp->beep(); } // --------------------------------------------------------------------------- void CMakeOutputWidget::viewPreviousError() { - while (--it != m_errorMap.begin()) + if (!m_errorMap.isEmpty()) { - ErrorDetails errorDetails = it.data(); - if (!errorDetails.m_fileName.isEmpty() && errorDetails.m_lineNumber >= 0) + while (--it != m_errorMap.begin()) { - selectLine(it.key()); - emit switchToFile(errorDetails.m_fileName, errorDetails.m_lineNumber); - return; + ErrorDetails errorDetails = it.data(); + if (!errorDetails.m_fileName.isEmpty() && errorDetails.m_lineNumber >= 0) + { + selectLine(it.key()); + emit switchToFile(errorDetails.m_fileName, errorDetails.m_lineNumber); + return; + } } } kapp->beep(); } // -------------------------------------------------------------------------------- void CMakeOutputWidget::selectLine(int line) { setCursorPosition( line, 255, false ); setCursorPosition( line, 0, true ); } // -------------------------------------------------------------------------------- // override from QMultiLineEdit void CMakeOutputWidget::keyPressEvent( QKeyEvent* event ) { switch (event->key()) { case Key_Enter: case Key_Return: checkForError(); break; default: QMultiLineEdit::keyPressEvent(event); break; } } // -------------------------------------------------------------------------------- void CMakeOutputWidget::mouseReleaseEvent(QMouseEvent* event) { QMultiLineEdit::mouseReleaseEvent(event); checkForError(); } // -------------------------------------------------------------------------------- // Check the current line for errors _and_ do the switch to the file:linenumber. void CMakeOutputWidget::checkForError() { int line,col; getCursorPosition(&line,&col); ErrorMap::Iterator tmp_it; if ((tmp_it = m_errorMap.find(line)) != m_errorMap.end()) { ErrorDetails errorDetails = tmp_it.data(); if (!errorDetails.m_fileName.isEmpty() && errorDetails.m_lineNumber >= 0) { selectLine(line); emit switchToFile(errorDetails.m_fileName, errorDetails.m_lineNumber); it = tmp_it; return; } } tmp_it = m_errorMap.begin(); tmp_it++; if (line > tmp_it.key()) it = m_errorMap.end(); else it = m_errorMap.begin(); } // -------------------------------------------------------------------------------- CMakeOutputWidget::MakeOutputErrorType CMakeOutputWidget::lineType(int line) { ErrorMap::Iterator tmp_it; if ((tmp_it = m_errorMap.find(line)) != m_errorMap.end()) { ErrorDetails errorDetails = tmp_it.data(); return errorDetails.m_type; } return Normal; } // -------------------------------------------------------------------------------- // Below is modified code from QMultiLineEdit that will set the appropriate colours // for the text lines. // // My apoligies for this extremly ugly hacked code :( // -------------------------------------------------------------------------------- static int defTabStop = 8; static int tabStopDist( const QFontMetrics &fm ) { return defTabStop*fm.width( QChar('x') ); } static int textWidthWithTabs( const QFontMetrics &fm, const QString &s, uint start, uint nChars, int align ) { if ( s.isEmpty() ) return 0; int dist = -fm.leftBearing( s[(int)start] ); int i = start; int tabDist = -1; // lazy eval while ( (uint)i < s.length() && (uint)i < start+nChars ) { if ( s[i] == '\t' && align == Qt::AlignLeft ) { if ( tabDist<0 ) tabDist = tabStopDist(fm); dist = ( (dist+tabDist+1)/tabDist ) * tabDist; i++; } else { int ii = i; while ( (uint)i < s.length() && (uint)i < start + nChars && ( align != Qt::AlignLeft || s[i] != '\t' ) ) i++; dist += fm.width( s.mid(ii,i-ii) ); } } return dist; } static QPixmap *buffer = 0; static void cleanupMLBuffer() { delete buffer; buffer = 0; } static QPixmap *getCacheBuffer( QSize sz ) { if ( !buffer ) { qAddPostRoutine( cleanupMLBuffer ); buffer = new QPixmap; } if ( buffer->width() < sz.width() || buffer->height() < sz.height() ) buffer->resize( sz ); return buffer; } /*! Computes the pixel position in line \a line which corresponds to character position \a xIndex */ int CMakeOutputWidget::mapToView( int xIndex, int line ) { int lr_marg = hMargin(); int align = alignment(); QString s = stringShown( line ); xIndex = QMIN( (int)s.length(), xIndex ); QFontMetrics fm( font() ); int wcell = cellWidth() - 2 * lr_marg;// - d->marg_extra; int wrow = textWidth(s); int w = textWidthWithTabs( fm, s, 0, xIndex, align ) - 1; if ( align == Qt::AlignCenter || align == Qt::AlignHCenter ) w += (wcell - wrow) / 2; else if ( align == Qt::AlignRight ) w += wcell - wrow; return lr_marg + w; } // -------------------------------------------------------------------------------- // This is where we paint the lines different colours depending on the type. // -------------------------------------------------------------------------------- void CMakeOutputWidget::paintCell(QPainter* painter, int row, int /*col*/) { int lr_marg = hMargin(); bool markIsOn = hasMarkedText(); int align = alignment(); int cursorX = 0; int cursorY = 0; cursorPosition(&cursorY,&cursorX); const QColorGroup & g = colorGroup(); QFontMetrics fm( painter->font() ); QString s = stringShown(row); if ( s.isNull() ) { qWarning( "QMultiLineEdit::paintCell: (%s) no text at line %d", name( "unnamed" ), row ); return; } QRect updateR = cellUpdateRect(); QPixmap *buffer = getCacheBuffer( updateR.size() ); ASSERT(buffer); buffer->fill ( g.base() ); QPainter p( buffer ); p.setFont( painter->font() ); p.translate( -updateR.left(), -updateR.top() ); p.setTabStops( tabStopDist(fm) ); int yPos = 0; int markX1, markX2; // in x-coordinate pixels markX1 = markX2 = 0; // avoid gcc warning if ( markIsOn ) { int markBeginX, markBeginY; int markEndX, markEndY; getMarkedRegion( &markBeginY, &markBeginX, &markEndY, &markEndX ); if ( row >= markBeginY && row <= markEndY ) { if ( row == markBeginY ) { markX1 = markBeginX; if ( row == markEndY ) // both marks on same row markX2 = markEndX; else markX2 = s.length(); // mark till end of line } else { if ( row == markEndY ) { markX1 = 0; markX2 = markEndX; } else { markX1 = 0; // whole line is marked markX2 = s.length(); // whole line is marked } } } } switch (lineType(row)) { case Error: p.setPen( Qt::darkRed ); break; case Diagnostic: p.setPen( Qt::darkBlue ); break; default: p.setPen( g.text()); break; } int wcell = cellWidth() - 2*lr_marg;// - marg_extra; int wrow = textWidth( s ); int x = lr_marg - p.fontMetrics().leftBearing(s[0]); if ( align == Qt::AlignCenter || align == Qt::AlignHCenter ) x += (wcell - wrow) / 2; else if ( align == Qt::AlignRight ) x += wcell - wrow; p.drawText( x, yPos, cellWidth()-lr_marg-x, cellHeight(), align == AlignLeft?ExpandTabs:0, s ); // if ( !r->newline && BREAK_WITHIN_WORDS ) // p.drawPixmap( x + wrow - lr_marg - marg_extra, yPos, d->arrow ); #if 0 if ( r->newline ) p.drawLine( lr_marg, yPos+cellHeight()-2, cellWidth() - lr_marg, yPos+cellHeight()-2); #endif if ( markX1 != markX2 ) { int sLength = s.length(); int xpos1 = mapToView( markX1, row ); int xpos2 = mapToView( markX2, row ); int fillxpos1 = xpos1; int fillxpos2 = xpos2; if ( markX1 == 0 ) fillxpos1 -= 2; if ( markX2 == sLength ) fillxpos2 += 3; p.setClipping( TRUE ); p.setClipRect( fillxpos1 - updateR.left(), 0, fillxpos2 - fillxpos1, cellHeight(row) ); p.fillRect( fillxpos1, 0, fillxpos2 - fillxpos1, cellHeight(row), g.brush( QColorGroup::Highlight ) ); p.setPen( g.highlightedText() ); p.drawText( x, yPos, cellWidth()-lr_marg-x, cellHeight(), align == AlignLeft?ExpandTabs:0, s ); p.setClipping( FALSE ); } if ( row == cursorY && cursorOn && !isReadOnly() ) { int cursorPos = QMIN( (int)s.length(), cursorX ); int cXPos = mapToView( cursorPos, row ); int cYPos = 0; if ( hasFocus() ) // || d->dnd_forcecursor ) { p.setPen( g.text() ); /* styled? p.drawLine( cXPos - 2, cYPos, cXPos + 2, cYPos ); */ p.drawLine( cXPos, cYPos, cXPos, cYPos + fm.height() - 2); /* styled? p.drawLine( cXPos - 2, cYPos + fm.height() - 2, cXPos + 2, cYPos + fm.height() - 2); */ #ifndef QT_NO_TRANSFORMATIONS // TODO: set it other times, eg. when scrollbar moves view QWMatrix wm = painter->worldMatrix(); setMicroFocusHint( int(wm.dx()+cXPos), int (wm.dy()+cYPos), 1, fm.ascent() ); #else setMicroFocusHint( cXPos, cYPos, 1, fm.ascent() ); #endif } } p.end(); painter->drawPixmap( updateR.left(), updateR.top(), *buffer, 0, 0, updateR.width(), updateR.height() ); } #include "coutputwidget.moc"