Index: trunk/kdeextragear-2/kile/kile/kile.h =================================================================== --- trunk/kdeextragear-2/kile/kile/kile.h (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kile.h (revision 314535) @@ -1,385 +1,351 @@ /*************************************************************************** kile.h - description ------------------- begin : sam jui 13 09:50:06 CEST 2002 copyright : (C) 2003 by Jeroen Wijnhout email : wijnhout@science.uva.nl ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KILE_H #define KILE_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kileappIface.h" #include "docpart.h" #include "symbolview.h" #include "kmultiverttabbar.h" #include "kilefileselect.h" #include "metapostview.h" #include "kileinfo.h" #include "latexoutputinfo.h" #include "latexoutputfilter.h" #include "codecompletion.h" // code completion (dani) #include "kileedit.h" // advanced editor (dani) #include "kilehelp.h" // kile help (dani) #define ID_HINTTEXT 301 #define ID_LINE_COLUMN 302 #define KILERC_VERSION 5 class QFileInfo; class QTimer; class QSignalMapper; class KToolBar; class KActionMenu; class KRecentFilesAction; class KToggleToolBarAction; class KileLyxServer; class KileEventFilter; class KileProject; class KileProjectItem; class KileProjectView; class TemplateItem; class KileEventFilter; class KileAutoSaveJob; class KileSpell; +class KileErrorHandler; namespace KileAction { class TagData; } namespace KileTool { class Manager; class Factory; } namespace KileWidget { class LogMsg; class Output; class Konsole; class Structure; } //TODO remove once we stop supporting pre 1.7 user tools struct userItem { QString name, tag; }; /** * @author Jeroen Wijnhout **/ /** * The Kile main class. It acts as the mainwindow, information manager and DCOP interface. **/ class Kile : public KParts::MainWindow, public KileAppDCOPIface, public KileInfo { Q_OBJECT public: Kile( bool restore = true, QWidget *parent = 0, const char *name = 0 ); ~Kile(); public slots: /** * @param line : Jump to give line in current editor (can be called via DCOP interface). **/ void setLine( const QString &line); void setCursor(int, int); void setActive(); /* actions */ private: void setupActions(); void setupTools(); void setupUserTagActions(); void cleanUpActionList(QPtrList &, const QStringList & tools); KToolBar *m_toolsToolBar; KActionMenu *m_menuUserTags; QValueList m_listUserTags; QValueList m_listUserTools; QPtrList m_listUserTagsActions, m_listQuickActions, m_listCompilerActions, m_listConverterActions, m_listViewerActions, m_listOtherActions; KAction *m_actionEditTag; KToggleToolBarAction *m_paShowMainTB, *m_paShowToolsTB, *m_paShowBuildTB, *m_paShowErrorTB, *m_paShowEditTB, *m_paShowMathTB; KAction *m_paStop, *m_paPrint; KToggleAction *ModeAction, *StructureAction, *MessageAction, *WatchFileAction; KRecentFilesAction *fileOpenRecentAction; /* GUI */ private: //widgets KMultiVertTabBar *ButtonBar; SymbolView *symbol_view; metapostview *mpview; - KileWidget::Output *OutputWidget; - KileWidget::LogMsg *LogWidget; - QTabWidget *Outputview; QFrame *Structview; QHBoxLayout *Structview_layout; QWidgetStack *topWidgetStack; QSplitter *splitter1, *splitter2 ; QWidgetStack *m_tabbarStack; //parts KParts::PartManager *partManager; QString m_wantState, m_currentState; private slots: void ToggleMode(); void ToggleStructView(); void ToggleOutputView(); void ToggleWatchFile(); void ShowOutputView(bool change); void ShowEditorWidget(); void showVertPage(int page); void LatexHelp(); private: bool showoutputview, m_bShowMainTB, m_bShowToolsTB, m_bShowBuildTB, m_bShowErrorTB, m_bShowEditTB, m_bShowMathTB; private slots: void ResetPart(); void ActivePartGUI(KParts::Part * the_part); void showToolBars(const QString &); void enableKileGUI(bool enable); public slots: void prepareForPart(const QString &); /* structure view */ private: bool showstructview; private slots: void ShowStructView(bool change); void ShowStructure(); void RefreshStructure(); /* config */ private: KConfig *config; int split1_right, split1_left, split2_top, split2_bottom, quickmode, lastvtab; QString struct_level1, struct_level2, struct_level3, struct_level4, struct_level5; QString document_class, typeface_size, paper_size, document_encoding, author; QString lastDocument, input_encoding; QStringList recentFilesList, m_listDocsOpenOnStart, m_listProjectsOpenOnStart; bool symbol_present; QStringList userClassList, userPaperList, userEncodingList, userOptionsList; bool m_bCompleteEnvironment, m_bRestore, m_runlyxserver, m_bQuick; signals: /** * Emit this signal when the configuration is changed. Classes that read and write to the global KConfig object * should connect to this signal so they can update their settings. **/ void configChanged(); private slots: void restore(); void ReadSettings(); void ReadRecentFileSettings(); void SaveSettings(); void readConfig(); void GeneralOptions(); void ConfigureKeys(); void ConfigureToolbars(); /* views */ protected: /** * This event filter captures WindowActivate events. On window activating it checks if * any files were modified on disc. This function will be obsolete once we decide to use * KDE3.2. **/ bool eventFilter (QObject* o, QEvent* e); bool m_bBlockWindowActivateEvents; private slots: /** * Activates (sets up the GUI for the editor part) the view. * @param checkModified If true, check if the document that corresponds to this view is modified on disc. * @param updateStruct If true, force an update of the structure view. **/ void activateView(QWidget* view , bool checkModified = true, bool updateStruct = true); void focusLog(); void focusOutput(); void focusKonsole(); void focusEditor(); /* document handling */ public slots: /** * Creates a document/view pair and loads the URL with the specified encoding * (default encoding is the encoding corresponding to the current locale). * * @returns pointer to the new view **/ void load(const QString &path); public slots: void fileSelected(const QString & url); bool queryExit(); bool queryClose(); void changeInputEncoding(); void newStatus(const QString& = QString::null); void updateModeStatus(); void newCaption(); public slots: void projectOpen(const QString& proj); private: KRecentFilesAction *m_actRecentProjects; // // documentinfo // private slots: void showDocInfo(Kate::Document *doc = 0); void convertToASCII(Kate::Document *doc = 0); void convertToEnc(Kate::Document *doc = 0); // // implementation of: // KileInfo // public: - const QStringList* labels(KileDocument::Info * info = 0); - const QStringList* bibItems(KileDocument::Info * info = 0); - const QStringList* bibliographies(KileDocument::Info * info = 0); - int lineNumber(); -private: - const QStringList* retrieveList(const QStringList* (KileDocument::Info::*getit)() const, KileDocument::Info * docinfo = 0); - QStringList m_listTemp; - /* autosave */ private slots: void autoSaveAll(); void enableAutosave(bool); void setAutosaveInterval(long interval) { autosaveinterval=interval;} private: QTimer *m_AutosaveTimer; private: long autosaveinterval; bool autosave; private slots: void runTool(); void CleanAll(KileDocument::Info *docinfo = 0, bool silent = false); void CleanBib(); void FindInFiles(); void GrepItemSelected(const QString &abs_filename, int line); -/* log view, error handling */ -private slots: - void ViewLog(); - void NextError(); - void PreviousError(); - void NextWarning(); - void PreviousWarning(); - void NextBadBox(); - void PreviousBadBox(); - -private: - void jumpToProblem(int type, bool); - void jumpToProblem(OutputInfo *); - -public slots: - void jumpToFirstError(); - -private: - int m_nCurrentError; - bool logpresent; - - bool m_bCheckForLaTeXErrors; - bool m_bNewInfolist; - /* insert tags */ private slots: /** * @param td Inserts the TagData td into the current editor. * * It can wrap a tag around selected text. **/ void insertTag(const KileAction::TagData& td); /** * An overloaded member function, behaves essentially as above. **/ void insertTag(const QString& tagB, const QString& tagE, int dx, int dy); void QuickTabular(); void QuickArray(); void QuickTabbing(); void QuickDocument(); void insertSymbol(QIconViewItem*); void InsertMetaPost(QListBoxItem *); // void insertUserTag(int i); // void insertUserTag(const KileAction::TagData& td); void EditUserMenu(); void includeGraphics(); private: KileLyxServer *m_lyxserver; bool m_bShowUserMovedMessage; private: KileHelp::Help *m_help; - + KileErrorHandler *m_errorHandler; KileSpell *m_spell; }; #endif Index: trunk/kdeextragear-2/kile/kile/kileinfo.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kileinfo.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kileinfo.cpp (revision 314535) @@ -1,248 +1,342 @@ /*************************************************************************** kileinfointerface.cpp - description ------------------- begin : Thu Jul 17 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 #include #include #include #include #include "kilefileselect.h" #include "kilestructurewidget.h" #include "kiledocmanager.h" #include "kileviewmanager.h" #include "kiledocumentinfo.h" #include "kileproject.h" #include "kileinfo.h" KileInfo::KileInfo(QWidget *parent) : m_manager(0L), m_toolFactory(0L), m_texKonsole(0L), m_edit(0L), m_parentWidget(parent), m_currentTarget(QString::null) { m_docManager = new KileDocument::Manager(this, parent, "KileDocument::Manager"); m_viewManager= new KileView::Manager(this, parent, "KileView::Manager"); } KileInfo::~KileInfo() { } Kate::Document * KileInfo::activeDocument() const { Kate::View *view = viewManager()->currentView(); if (view) return view->getDoc(); else return 0L; } QString KileInfo::getName(Kate::Document *doc, bool shrt) { QString title; if (doc == 0) doc = activeDocument(); if (doc) { //kdDebug() << "getName: url " << doc->url().path() << " name " << doc->docName() << endl; title = shrt ? doc->url().fileName() : doc->url().path(); if (title == "") title = i18n("Untitled"); } else title=QString::null; return title; } QString KileInfo::getCompileName(bool shrt /* = false */) { KileProject *project = docManager()->activeProject(); //TODO: handle the case where no master document is specified in a project (sick) if (project) { if (project->masterDocument().length() > 0) { KURL master = KURL::fromPathOrURL(project->masterDocument()); if (shrt) return master.fileName(); else return master.path(); } else { KileProjectItem *item = project->rootItem(docManager()->activeProjectItem()); if (item) { KURL url = item->url(); if (shrt) return url.fileName(); else return url.path(); } else return QString::null; } } else { if (m_singlemode) return getName(activeDocument(), shrt); else { QFileInfo fi(m_masterName); if (shrt) return fi.fileName(); else return m_masterName; } } } QString KileInfo::getFullFromPrettyName(const QString & name) { QString file = name; if (file.left(2) == "./" ) { file = QFileInfo(outputFilter()->source()).dirPath(true) + "/" + file.mid(2); } if (file[0] != '/' ) { file = QFileInfo(outputFilter()->source()).dirPath(true) + "/" + file; } QFileInfo fi(file); if ( (file == QString::null) || fi.isDir() || (! fi.exists()) || (! fi.isReadable())) { if ( QFileInfo(file+".tex").exists() ) { file += ".tex"; fi.setFile(file); } else file = QString::null; } if ( ! fi.isReadable() ) return QString::null; return file; } +const QStringList* KileInfo::retrieveList(const QStringList* (KileDocument::Info::*getit)() const, KileDocument::Info * docinfo /* = 0L */) +{ + m_listTemp.clear(); + + if (docinfo == 0L) docinfo = docManager()->getInfo(); + KileProjectItem *item = docManager()->itemFor(docinfo, docManager()->activeProject()); + + kdDebug() << "Kile::retrieveList()" << endl; + if (item) + { + const KileProject *project = item->project(); + const KileProjectItem *root = project->rootItem(item); + if (root) + { + kdDebug() << "\tusing root item " << root->url().fileName() << endl; + + QPtrList children; + children.append(root); + root->allChildren(&children); + + const QStringList *list; + + for (uint i=0; i < children.count(); i++) + { + kdDebug() << "\t" << children.at(i)->url().fileName() << endl; + list = (children.at(i)->getInfo()->*getit)(); + if (list) + { + for (uint i=0; i < list->count(); i++) + m_listTemp << (*list)[i]; + } + } + + return &m_listTemp; + } + else + return &m_listTemp; + } + else if (docinfo) + { + m_listTemp = *((docinfo->*getit)()); + return &m_listTemp; + } + else + return &m_listTemp; +} + +const QStringList* KileInfo::allLabels(KileDocument::Info * info) +{ + kdDebug() << "Kile::allLabels()" << endl; + const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::labels; + const QStringList* list = retrieveList(p, info); + return list; +} + +const QStringList* KileInfo::allBibItems(KileDocument::Info * info) +{ + kdDebug() << "Kile::allBibItems()" << endl; + const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::bibItems; + const QStringList* list = retrieveList(p, info); + return list; +} + +const QStringList* KileInfo::allBibliographies(KileDocument::Info * info) +{ + kdDebug() << "Kile::bibliographies()" << endl; + const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::bibliographies; + const QStringList* list = retrieveList(p, info); + return list; +} + +const QStringList* KileInfo::allDependencies(KileDocument::Info * info) +{ + kdDebug() << "Kile::dependencies()" << endl; + const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::dependencies; + const QStringList* list = retrieveList(p, info); + return list; +} + +const QStringList* KileInfo::allNewCommands(KileDocument::Info * info) +{ + kdDebug() << "Kile::newCommands()" << endl; + const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::newCommands; + const QStringList* list = retrieveList(p, info); + return list; +} + +QString KileInfo::lastModifiedFile(KileDocument::Info * info) +{ + if (info == 0) info = docManager()->getInfo(); + const QStringList *list = allDependencies(info); + return info->lastModifiedFile(list); +} + bool KileInfo::isOpen(const KURL & url) { kdDebug() << "==bool KileInfo::isOpen(const KURL & url)=============" << endl; uint cnt = viewManager()->views().count(); kdDebug() << "\t" << cnt << " views" << endl; for ( uint i = 0; i < cnt; i++) { kdDebug() << "\t" << i << " " << viewManager()->view(i) << " url " << &url << endl; if ( viewManager()->view(i)->getDoc() && (url == viewManager()->view(i)->getDoc()->url()) ) return true; } return false; } bool KileInfo::projectIsOpen(const KURL & url) { KileProject *project = docManager()->projectFor(url); return project != 0 ; } QString KileInfo::getSelection() const { Kate::Document *doc = activeDocument(); if (doc && doc->hasSelection()) { return doc->selection(); } return QString::null; } void KileInfo::clearSelection() const { Kate::Document *doc = activeDocument(); if (doc && doc->hasSelection()) { doc->removeSelectedText(); } } QString KileInfo::relativePath(const QString basepath, const QString & file) { KURL url = KURL::fromPathOrURL(file); QString path = url.directory(); QString filename = url.fileName(); kdDebug() <<"===findRelativeURL==================" << endl; kdDebug() << "\tbasepath : " << basepath << " path: " << path << endl; QStringList basedirs = QStringList::split("/", basepath, false); QStringList dirs = QStringList::split("/", path, false); uint nDirs = dirs.count(); //uint nBaseDirs = basedirs.count(); while ( dirs.count() > 0 && basedirs.count() > 0 && dirs[0] == basedirs[0] ) { dirs.pop_front(); basedirs.pop_front(); } /*kdDebug() << "\tafter" << endl; for (uint i=0; i < basedirs.count(); i++) { kdDebug() << "\t\tbasedirs " << i << ": " << basedirs[i] << endl; } for (uint i=0; i < dirs.count(); i++) { kdDebug() << "\t\tdirs " << i << ": " << dirs[i] << endl; }*/ if (nDirs != dirs.count() ) { path = dirs.join("/"); //kdDebug() << "\tpath : " << path << endl; if (basedirs.count() > 0) { for (uint j=0; j < basedirs.count(); j++) { path = "../" + path; } } if ( path.length()>0 && path.right(1) != "/" ) path = path + "/"; path = path+filename; } else //assume an absolute path was requested { path = url.path(); } kdDebug() << "\trelative path : " << path << endl; return path; } Index: trunk/kdeextragear-2/kile/kile/codecompletion.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/codecompletion.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/codecompletion.cpp (revision 314535) @@ -1,833 +1,854 @@ /*************************************************************************** codecompletion.cpp ---------------------------------------------------------------------------- date : Jan 24 2004 version : 0.10.3 copyright : (C) 2004 by Holger Danielsson email : holger.danielsson@t-online.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 #include #include #include #include #include #include #include #include #include #include "kileinfo.h" #include "kileviewmanager.h" #include "codecompletion.h" #include "kileconfig.h" -#define BULLET QString("×") - namespace KileDocument { CodeCompletion::CodeCompletion(KileInfo *info) : m_ki(info), m_view(0L) { m_firstconfig = true; m_inprogress = false; m_undo = false; // default bullet char m_bullet = BULLET; m_completeTimer = new QTimer( this ); connect(m_completeTimer, SIGNAL( timeout() ), this, SLOT( slotCompleteValueList() ) ); } CodeCompletion::~CodeCompletion() {} bool CodeCompletion::isActive() { return m_isenabled; } bool CodeCompletion::inProgress() { return m_inprogress; } bool CodeCompletion::autoComplete() { return m_autocomplete; } const QString CodeCompletion::getBullet() { return m_bullet; } CodeCompletion::Type CodeCompletion::getType() { return m_type; } CodeCompletion::Type CodeCompletion::getType( const QString &text ) { - if ( text.left( 5 ) == "\\ref{" || text.left( 9 ) == "\\pageref{" ) + static QRegExp::QRegExp reRef("^\\\\(pageref|ref)\\{"); + static QRegExp::QRegExp reCite("^\\\\(c|C)(ite|itep|itet|itealt|itealp|iteauthor|iteyear|iteyearpar|itetext)\\{"); + if ( text.find( reRef ) != -1 ) return CodeCompletion::ctReference; - else if ( text.left( 6 ) == "\\cite{" ) + else if ( text.find( reCite ) != -1 ) return CodeCompletion::ctCitation; else return CodeCompletion::ctNone; } CodeCompletion::Mode CodeCompletion::getMode() { return m_mode; } //////////////////// configuration //////////////////// void CodeCompletion::readConfig(void) { kdDebug() << "=== CodeCompletion::readConfig ===================" << endl; // save normal parameter kdDebug() << " read bool entries" << endl; m_isenabled = KileConfig::completeEnabled(); m_setcursor = KileConfig::completeCursor(); m_setbullets = KileConfig::completeBullets(); m_closeenv = KileConfig::completeCloseEnv(); m_autocomplete = KileConfig::completeAuto(); // reading the wordlists is only necessary at the first start // and when the list of files changes if ( m_firstconfig || KileConfig::completeChangedLists() ) { kdDebug() << " read wordlists..." << endl; // wordlists for Tex/Latex mode QStringList files = KileConfig::completeTex(); setWordlist( files, "tex", &m_texlist ); // wordlist for dictionary mode files = KileConfig::completeDict(); setWordlist( files, "dictionary", &m_dictlist ); // wordlist for abbreviation mode files = KileConfig::completeAbbrev(); setWordlist( files, "abbreviation", &m_abbrevlist ); // remember changed lists m_firstconfig = false; KileConfig::setCompleteChangedLists(false); } } void CodeCompletion::setWordlist( const QStringList &files, const QString &dir, QValueList *entrylist ) { QStringList wordlist; for ( uint i = 0; i < files.count(); i++ ) { // if checked, the wordlist has to be read if ( files[ i ].at( 0 ) == '1' ) { readWordlist( wordlist, dir + "/" + files[ i ].right( files[ i ].length() - 2 ) + ".cwl" ); } } // sort the wordlist // wordlist.sort(); // build all completion entries setCompletionEntries( entrylist, wordlist ); } //////////////////// completion box //////////////////// void CodeCompletion::completeWord(const QString &text, CodeCompletion::Mode mode) { if ( !m_view) return; // remember all parameters (view, pattern, length of pattern, mode) m_text = text; m_textlen = text.length(); m_mode = mode; // and the current cursor position m_view->cursorPositionReal( &m_ycursor, &m_xcursor ); m_xstart = m_xcursor - m_textlen; // and the current document Kate::Document *doc = m_view->getDoc(); // determine the current list QValueList list; switch ( m_mode ) { case cmLatex: case cmEnvironment: list = m_texlist; + appendNewCommands(list); break; case cmDictionary: list = m_dictlist; break; case cmAbbreviation: list = m_abbrevlist; break; case cmLabel: list = m_labellist; break; } // is it necessary to show the complete dialog? QString entry, type; QString pattern = ( m_mode != cmEnvironment ) ? text : "\\begin{" + text; uint n = countEntries( pattern, &list, &entry, &type ); // nothing to do if ( n == 0 ) return ; // Add a prefix ('\\begin{', length=7) in cmEnvironment mode, // because KateCompletion reads from the current line, This also // means that the original text has to be restored, if the user // aborts the completion dialog if ( m_mode == cmEnvironment ) { doc->removeText( m_ycursor, m_xstart, m_ycursor, m_xcursor ); doc->insertText( m_ycursor, m_xstart, "\\begin{" + m_text ); // set the cursor to the new position m_textlen += 7; m_xcursor += 7; m_view->setCursorPositionReal( m_ycursor, m_xcursor ); // set restore mode m_undo = true; } // set restore mode if ( m_mode == cmAbbreviation ) { m_undo = true; } if ( m_mode == cmLabel ) { - doc->insertText( m_ycursor, m_xstart, " " ); +// doc->insertText( m_ycursor, m_xstart, " " ); // set the cursor to the new position - m_textlen++; - m_xcursor++; - m_view->setCursorPositionReal( m_ycursor, m_xcursor ); +// m_textlen++; +// m_xcursor++; +// m_view->setCursorPositionReal( m_ycursor, m_xcursor ); // set restore mode m_undo = true; } // show the completion dialog m_inprogress = true; KTextEditor::CodeCompletionInterface *iface; iface = dynamic_cast( m_view ); iface->showCompletionBox( list, m_textlen ); } + void CodeCompletion::appendNewCommands(QValueList & list) + { + KTextEditor::CompletionEntry e; + const QStringList *ncommands = m_ki->allNewCommands(); + QStringList::ConstIterator it; + QStringList::ConstIterator itend(ncommands->end()); + for ( it = ncommands->begin(); it != itend; ++it ) + { + e.text = *it; + list.prepend(e); + } + } + void CodeCompletion::completeFromList(const QStringList *list ) { KTextEditor::CompletionEntry e; m_labellist.clear(); QStringList::ConstIterator it; - for ( it = list->begin(); it != list->end(); ++it ) + QStringList::ConstIterator itend(list->end()); + for ( it = list->begin(); it != itend; ++it ) { - e.text = QString( " " ) + ( *it ); - m_labellist.append( e ); + e.text = *it; + m_labellist.append( e ); } completeWord("", cmLabel); } //////////////////// completion was done //////////////////// void CodeCompletion::CompletionDone() { // is there a new cursor position? if ( m_setcursor && ( m_xoffset != 0 || m_yoffset != 0 ) && m_view ) { + int newx = m_xcursor, newy = m_ycursor; + if ( m_yoffset == 0 ) - m_view->setCursorPositionReal( m_ycursor, m_xcursor + m_xoffset - m_textlen ); + newx = m_xcursor + m_xoffset - m_textlen; else - m_view->setCursorPositionReal( m_ycursor + m_yoffset, m_xoffset ); + newy = m_ycursor + m_yoffset; + + m_view->setCursorPositionReal( newy, newx ); } m_inprogress = false; m_view = 0L; } void CodeCompletion::CompletionAborted() { if ( m_undo && m_view ) { uint row, col; m_view->cursorPositionReal( &row, &col ); Kate::Document *doc = m_view->getDoc(); doc->removeText( m_ycursor, m_xstart, m_ycursor, col ); doc->insertText( m_ycursor, m_xstart, m_text ); m_view->setCursorPositionReal( m_ycursor, m_xstart + m_text.length() ); m_undo = false; } m_inprogress = false; } //////////////////// build the text for completion //////////////////// // parse an entry: // - delete arguments/parameters // - set cursor position // - insert bullets QString CodeCompletion::filterCompletionText( const QString &text, const QString &type ) { kdDebug() << " complete filter: " << text << endl; m_type = getType( text ); // remember current type // check the cursor position, because the user may have // typed some characters or the backspace key. This also // changes the length of the current pattern. uint row, col; m_view->cursorPositionReal( &row, &col ); if ( m_xcursor != col ) { m_textlen += ( col - m_xcursor ); m_xcursor = col; } // initialize offset for the new cursorposition m_xoffset = m_yoffset = 0; // build the text QString s; switch ( m_mode ) { case cmLatex: if ( text.left( 7 ) == "\\begin{" ) //FIXME replace with a regexp s = buildEnvironmentText( text, type, m_yoffset, m_xoffset ); else s = buildLatexText( text, m_yoffset, m_xoffset ); break; case cmEnvironment: s = buildEnvironmentText( text, type, m_yoffset, m_xoffset ); m_undo = false; break; case cmDictionary: s = text; break; case cmAbbreviation: s = buildAbbreviationText( text ); m_undo = false; break; case cmLabel: s = buildLabelText( text ); m_undo = false; break; } if ( s.length() > m_textlen ) return s.right( s.length() - m_textlen ); else return ""; } //////////////////// text in cmLatex mode //////////////////// QString CodeCompletion::buildLatexText( const QString &text, uint &ypos, uint &xpos ) { return parseText( stripParameter( text ), ypos, xpos, true ); } //////////////////// text in cmEnvironment mode //////////////////// QString CodeCompletion::buildEnvironmentText( const QString &text, const QString &type, uint &ypos, uint &xpos ) { // die erste Klammer '}' suchen int pos = text.find( '}' ); if ( pos == -1 ) return ""; // Namen des Environments extrahieren QString envname = text.mid( 7, pos - 7 ); QString parameter = stripParameter( text.mid( pos + 1, text.length() - pos ) ); // ev. die Parameter aufbereiten if ( ! parameter.isEmpty() ) parameter = parseText( parameter, ypos, xpos, false ); // list environment ? bool item = ( type == "\\item" ) ? true : false; // Ergebnis zusammensetzen: 1. Zeile QString s = "\\begin{" + envname + '}' + parameter + '\n'; // 2. Zeile if ( item ) s += "\\item "; if ( m_setbullets && !parameter.isEmpty() ) s += getBullet(); s += '\n'; // 3. Zeile if ( m_closeenv ) s += "\\end{" + envname + "}\n"; // Cursor positionieren if ( m_setcursor ) { if ( parameter.isEmpty() ) { ypos = 1; xpos = ( item ) ? 6 : 0; } else { ypos = 0; xpos = 9 + envname.length(); } } // Ergebnis return s; } //////////////////// text in cmAbbreviation mode //////////////////// QString CodeCompletion::buildAbbreviationText( const QString &text ) { QString s; int index = text.find( '=' ); if ( index >= 0 ) { // determine text to insert s = text.right( text.length() - index - 1 ); // delete abbreviation Kate::Document *doc = m_view->getDoc(); doc->removeText( m_ycursor, m_xstart, m_ycursor, m_xcursor ); m_view->setCursorPositionReal( m_ycursor, m_xstart ); m_xcursor = m_xstart; m_textlen = 0; } else s = ""; return s; } //////////////////// text in cmLabel mode //////////////////// QString CodeCompletion::buildLabelText( const QString &text ) { if ( text.at( 0 ) == ' ' ) { // delete space Kate::Document * doc = m_view->getDoc(); doc->removeText( m_ycursor, m_xstart, m_ycursor, m_xstart + 1 ); m_view->setCursorPositionReal( m_ycursor, m_xstart ); m_xcursor = m_xstart; m_textlen = 0; return text.right( text.length() - 1 ); } else return text; } //////////////////// Hilfsroutinen //////////////////// QString CodeCompletion::parseText( const QString &text, uint &ypos, uint &xpos, bool checkgroup ) { bool foundgroup = false; QString s = ""; xpos = ypos = 0; for ( uint i = 0; i < text.length(); i++ ) { switch ( text[ i ] ) { case '{': case '(': case '[': // Zeichen einfügen s += text[ i ]; if ( xpos == 0 ) { // hinter der ersten Klammer die Cursorposition merken xpos = i + 1; // ein Bullet nur dann einfügen, wenn der Cursor // nicht hierhin gesetzt werden soll if ( ( ! m_setcursor ) && m_setbullets ) s += getBullet(); } // an allen weiteren Klammern ev. ein Bullet einfügen else if ( m_setbullets ) s += getBullet(); break; case '}': case ')': case ']': // Zeichen einfügen s += text[ i ]; break; case ',': // Zeichen einfügen s += text[ i ]; // ev. Bullet einfügen if ( m_setbullets ) s += getBullet(); break; case '.': // wenn das letzte Zeichen auch ein Punkt ist, also ein // Bereichsoperator angegeben ist, wird dieser ersetzt und // durch ein einzelnes Leerzeichen oder durch ein von // Leerzeichen umgebenden Bullet ersetzt if ( checkgroup && ( s.right( 1 ) == "." ) ) { foundgroup = true; s.truncate( s.length() - 1 ); if ( m_setbullets ) s += " " + getBullet() + " "; else s += " "; } else s += text[ i ]; break; default: // alle anderen Zeichen ausgeben s += text[ i ]; break; } } // bei einer Gruppe wird noch nachbearbeitet, wenn auch Bullets // eingefügt werden sollen if ( checkgroup && foundgroup && ( m_setbullets | m_setcursor ) ) { int pos = 0; // Klammerbefehl suchen switch ( QChar( s[ 1 ] ) ) { case 'l' : if ( s.left( 6 ) == "\\left " ) pos = 5; break; case 'b' : if ( s.left( 6 ) == "\\bigl " ) pos = 5; else if ( s.left( 7 ) == "\\biggl " ) pos = 6; break; case 'B' : if ( s.left( 6 ) == "\\Bigl " ) pos = 5; else if ( s.left( 7 ) == "\\Biggl " ) pos = 6; break; } // Position des Cursors und Bullets if ( pos > 0 ) { if ( m_setcursor ) xpos = pos; if ( m_setbullets ) { if ( ! m_setcursor ) s.insert( pos, getBullet() ); s.append( getBullet() ); } } } // Ergebnis return s; } // alle in Klammern eingeschlossenene Parameternamen entfernen QString CodeCompletion::stripParameter( const QString &text ) { QString s = ""; const QChar *ch = text.unicode(); bool ignore = false; for ( uint i = 0; i < text.length(); i++ ) { switch ( *ch ) { case '{': case '(': case '[': s += *ch; ignore = true; break; case '}': case ')': case ']': s += *ch; ignore = false; break; case ',': s += *ch; break; default: if ( ! ignore ) s += *ch; break; } ch++; } return s; } //////////////////// Daten für CodeCompletion lesen //////////////////// void CodeCompletion::readWordlist( QStringList &wordlist, const QString &filename ) { QString file = KGlobal::dirs() ->findResource( "appdata", "complete/" + filename ); if ( file.isEmpty() ) return; QFile f( file ); if ( f.open( IO_ReadOnly ) ) { // file opened successfully QTextStream t( &f ); // use a text stream while ( ! t.eof() ) { // until end of file... QString s = t.readLine().stripWhiteSpace(); // line of text excluding '\n' if ( ! ( s.isEmpty() || s.at( 0 ) == '#' ) ) { wordlist.append( s ); } } f.close(); } } void CodeCompletion::setCompletionEntries( QValueList *list, const QStringList &wordlist ) { // clear the whole list list->clear(); KTextEditor::CompletionEntry e; // build new entries: if the last 5 chars of an environment are '\item', // it is a list environment, where the '\item' tag is also inserted for ( uint i = 0; i < wordlist.count(); i++ ) { QString s = wordlist[ i ]; if ( s.left( 7 ) == "\\begin{" && s.right( 5 ) == "\\item" ) { e.text = s.left( s.length() - 5 ); // list environment entry e.type = "\\item"; } else { e.text = s; // normal entry e.type = ""; } // add new entry list->append( e ); } } //////////////////// Anzahl der Einträge lesen //////////////////// // Count the number of entries. Stop, wenn there are 2 entries, // because special functions are only called, when there are 0 // or 1 entries. uint CodeCompletion::countEntries( const QString &pattern, QValueList *list, QString *entry, QString *type ) { QValueList::Iterator it; uint n = 0; for ( it = list->begin(); it != list->end() && n < 2; ++it ) { if ( ( *it ).text.startsWith( pattern ) ) { *entry = ( *it ).text; *type = ( *it ).type; n++; } } return n; } void CodeCompletion::editComplete(Kate::View *view, Mode mode) { m_view = view; if ( !m_view || !isActive() || inProgress() ) return ; QString word; Type type; if ( getCompleteWord(( mode == cmLatex ) ? true : false, word, type ) ) { if ( mode == cmLatex && word.at( 0 ) != '\\' ) { mode = cmDictionary; } if ( type == ctNone ) completeWord(word, mode); else editCompleteList(type); } } void CodeCompletion::editCompleteList(Type type ) { if ( type == ctReference ) - completeFromList(info()->labels()); + completeFromList(info()->allLabels()); else if ( type == ctCitation ) - completeFromList(info()->bibItems()); + completeFromList(info()->allBibItems()); } //////////////////// slots for code completion //////////////////// void CodeCompletion::slotCompletionDone() { CompletionDone(); if ( getMode() == cmLatex ) { m_completeTimer->start( 0, false ); } } void CodeCompletion::slotCompleteValueList() { m_completeTimer->stop(); editCompleteList(getType()); } void CodeCompletion::slotCompletionAborted() { CompletionAborted(); } void CodeCompletion::slotFilterCompletion( KTextEditor::CompletionEntry* c, QString *s ) { + kdDebug() << "==CodeCompletion::slotFilterCompletion( KTextEditor::CompletionEntry* c, QString *s )==" << endl; + kdDebug() << "\ts = " << *s << " type = " << c->type << " text = " << c->text << " prefix = " << c->prefix << " postfix = " << c->postfix << " comment = " << c->comment << endl; *s = filterCompletionText( c->text, c->type ); } void CodeCompletion::slotCharactersInserted(int, int, const QString& string ) { if ( !isActive() || !autoComplete() ) return ; //FIXME this is not very efficient m_view = info()->viewManager()->currentView(); QString word; Type type; if ( getCompleteWord(true, word, type ) && word.at( 0 ) == '\\' ) { kdDebug() << " auto completion: word=" << word << endl; if ( string.at( 0 ).isLetter() ) { completeWord(word, cmLatex); } else if ( string.at( 0 ) == '{' ) { editCompleteList(type); } } } //////////////////// testing characters (dani) //////////////////// static bool isBackslash ( QChar ch ) { return ( ch == '\\' ); } bool CodeCompletion::getCompleteWord(bool latexmode, QString &text, Type &type ) { if ( !m_view ) return false; uint row, col; QChar ch; // get current position m_view->cursorPositionReal( &row, &col ); // there must be et least one sign if ( col < 1 ) return ""; // get current text line QString textline = m_view->getDoc()->textLine( row ); // int n = 0; // number of characters int index = col; // go back from here while ( --index >= 0 ) { // get current character ch = textline.at( index ); if ( ch.isLetter() || ( latexmode && ( index + 1 == ( int ) col ) && ch == '{' ) ) n++; // accept letters and '{' as first character in latexmode else { if ( latexmode && isBackslash( ch ) && oddBackslashes( textline, index ) ) // Backslash? n++; break; // stop when a backslash was found } } // select pattern and set type of match text = textline.mid( col - n, n ); type = getType( text ); return !text.isEmpty(); } //////////////////// counting backslashes (dani) //////////////////// bool CodeCompletion::oddBackslashes( const QString& text, int index ) { uint n = 0; while ( index >= 0 && isBackslash( text.at( index ) ) ) { n++; index--; } return ( n % 2 ) ? true : false; } } #include "codecompletion.moc" Index: trunk/kdeextragear-2/kile/kile/kiletoolmanager.h =================================================================== --- trunk/kdeextragear-2/kile/kile/kiletoolmanager.h (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kiletoolmanager.h (revision 314535) @@ -1,151 +1,152 @@ /*************************************************************************** kiletoolmanager.h - description ------------------- begin : Tue Nov 25 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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. * * * ****************************************************************************/ #ifndef KILETOOLMANAGER_H #define KILETOOLMANAGER_H #include #include #include #include "kiletool.h" class QTimer; class QWidgetStack; class KConfig; class KTextEdit; class KAction; namespace KParts { class PartManager; } class KileInfo; namespace KileWidget { class LogMsg; class Output; } namespace KileTool { class Factory; class QueueItem { public: QueueItem(Base *tool, const QString & cfg = QString::null); ~QueueItem(); Base* tool() const { return m_tool; } const QString cfg() const { return m_cfg; } private: Base *m_tool; QString m_cfg; }; class Queue : public QPtrQueue { public: Base* tool() const; const QString cfg() const; void enqueueNext(QueueItem *); }; class Manager : public QObject { Q_OBJECT public: Manager(KileInfo *ki, KConfig *config, KileWidget::LogMsg *log, KileWidget::Output *output, KParts::PartManager *, QWidgetStack *, KAction *, uint to); ~Manager(); public: void initTool(Base*); bool configure(Base*); bool retrieveEntryMap(const QString & name, Config & map, bool usequeue = true, bool useproject = true); void saveEntryMap(const QString & name, Config & map, bool usequeue = true); QString currentGroup(const QString &name, bool usequeue = true); //QString configName(const QString & tool); //void setConfigName(const QString & tool, const QString & name); void wantGUIState(const QString &); KParts::PartManager * partManager() { return m_pm; } QWidgetStack * widgetStack() { return m_stack; } KileInfo * info() { return m_ki; } KConfig * config() { return m_config; } void setFactory(Factory* fac) { m_factory = fac; } Factory* factory() { return m_factory; } bool queryContinue(const QString & question, const QString & caption = QString::null); public slots: void started(Base*); void done(Base *, int); int run(const QString &, const QString & = QString::null, bool insertAtTop = false); int run(Base *, const QString & = QString::null, bool insertAtTop = false); int runNext(const QString & t , const QString & c = QString::null) { return run(t,c,true); } int runNext(Base * t, const QString & c = QString::null) { return run(t,c,true); } void stop(); //should be a slot that stops the active tool and clears the queue private slots: int runNextInQueue(); void enableClear(); signals: void requestGUIState(const QString &); void requestSaveAll(); void jumpToFirstError(); + void toolStarted(); private: KileInfo *m_ki; KConfig *m_config; KileWidget::LogMsg *m_log; KileWidget::Output *m_output; KParts::PartManager *m_pm; QWidgetStack *m_stack; KAction *m_stop; Factory *m_factory; Queue m_queue; QTimer *m_timer; bool m_bClear; uint m_nTimeout; }; QStringList toolList(KConfig *config, bool menuOnly = false); QStringList configNames(const QString &tool, KConfig *config); QString configName(const QString & tool, KConfig *); void setConfigName(const QString & tool, const QString & name, KConfig *); QString groupFor(const QString & tool, KConfig *); QString groupFor(const QString & tool, const QString & cfg = "Default" ); void extract(const QString &str, QString &tool, QString &cfg); QString format(const QString & tool, const QString &cfg); QString menuFor(const QString &tool, KConfig *config); QString iconFor(const QString &tool, KConfig *config); QString categoryFor(const QString &clss); void setGUIOptions(const QString &tool, const QString &menu, const QString &icon, KConfig *config); } #endif Index: trunk/kdeextragear-2/kile/kile/kile.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kile.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kile.cpp (revision 314535) @@ -1,2219 +1,1998 @@ /*************************************************************************** kile.cpp - description ------------------- begin : sam jui 13 09:50:06 CEST 2002 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 "kile.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kileapplication.h" #include "kiledocumentinfo.h" #include "kileactions.h" #include "kilestdactions.h" #include "usermenudialog.h" #include "kileconfigdialog.h" #include "kileproject.h" #include "kileprojectview.h" #include "kileprojectdlgs.h" #include "kilelistselector.h" #include "kilelyxserver.h" #include "kilegrepdialog.h" #include "kiletool_enums.h" #include "kiletool.h" #include "kiletoolmanager.h" #include "kilestdtools.h" #include "kilelogwidget.h" #include "kileoutputwidget.h" #include "kilekonsolewidget.h" #include "quickdocumentdialog.h" #include "tabdialog.h" #include "arraydialog.h" #include "tabbingdialog.h" #include "kilestructurewidget.h" #include "convert.h" #include "includegraphicsdialog.h" #include "cleandialog.h" #include "kiledocmanager.h" #include "kileviewmanager.h" #include "kileeventfilter.h" #include "kileautosavejob.h" #include "kileconfig.h" #include "kxtrcconverter.h" +#include "kileerrorhandler.h" #include "kilespell.h" #include "kilespell2.h" Kile::Kile( bool rest, QWidget *parent, const char *name ) : DCOPObject( "Kile" ), KParts::MainWindow( parent, name), KileInfo(this), m_paPrint(0L), m_bQuick(false), - m_nCurrentError(-1), m_bShowUserMovedMessage(false) { // do initializations first - m_currentState=m_wantState="Editor"; - m_bWatchFile=false; - m_bNewInfolist=true; - m_bCheckForLaTeXErrors=false; - m_bBlockWindowActivateEvents=false; + m_currentState = m_wantState="Editor"; + m_bWatchFile = m_bBlockWindowActivateEvents = m_logPresent = false; m_spell = new KileSpell(this, this, "kilespell"); symbol_view = 0L; symbol_present=false; viewManager()->setClient(this, this); partManager = new KParts::PartManager( this ); connect( partManager, SIGNAL( activePartChanged( KParts::Part * ) ), this, SLOT(ActivePartGUI ( KParts::Part * ) ) ); m_AutosaveTimer= new QTimer(); connect(m_AutosaveTimer,SIGNAL(timeout()),this,SLOT(autoSaveAll())); m_eventFilter = new KileEventFilter(); connect(this,SIGNAL(configChanged()), m_eventFilter, SLOT(readConfig())); + m_errorHandler = new KileErrorHandler(this, this); + statusBar()->insertItem(i18n("Line: 1 Col: 1"), ID_LINE_COLUMN, 0, true); statusBar()->setItemAlignment( ID_LINE_COLUMN, AlignLeft|AlignVCenter ); statusBar()->insertItem(i18n("Normal mode"), ID_HINTTEXT,10); statusBar()->setItemAlignment( ID_HINTTEXT, AlignLeft|AlignVCenter ); topWidgetStack = new QWidgetStack( this ); topWidgetStack->setFocusPolicy(QWidget::NoFocus); splitter1=new QSplitter(QSplitter::Horizontal,topWidgetStack, "splitter1" ); Structview_layout=0; Structview=new QFrame(splitter1); Structview->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); Structview->setLineWidth( 2 ); Structview_layout=0; ButtonBar=new KMultiVertTabBar(Structview); ButtonBar->insertTab(SmallIcon("fileopen"),0,i18n("Open File")); connect(ButtonBar->getTab(0),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); KileFS= new KileFileSelect(Structview,"File Selector"); connect(KileFS,SIGNAL(fileSelected(const KFileItem*)), docManager(), SLOT(fileSelected(const KFileItem*))); connect(KileFS->comboEncoding, SIGNAL(activated(int)),this,SLOT(changeInputEncoding())); KileFS->comboEncoding->lineEdit()->setText(input_encoding); KileProjectView *projectview = new KileProjectView(Structview, this); viewManager()->setProjectView(projectview); ButtonBar->insertTab( SmallIcon("editcopy"),9,i18n("Files and Projects")); connect(ButtonBar->getTab(9),SIGNAL(clicked(int)), this,SLOT(showVertPage(int))); connect(projectview, SIGNAL(fileSelected(const KileProjectItem *)), docManager(), SLOT(fileSelected(const KileProjectItem *))); connect(projectview, SIGNAL(fileSelected(const KURL &)), docManager(), SLOT(fileSelected(const KURL &))); connect(projectview, SIGNAL(closeURL(const KURL&)), docManager(), SLOT(fileClose(const KURL&))); connect(projectview, SIGNAL(closeProject(const KURL&)), docManager(), SLOT(projectClose(const KURL&))); connect(projectview, SIGNAL(projectOptions(const KURL&)), docManager(), SLOT(projectOptions(const KURL&))); connect(projectview, SIGNAL(projectArchive(const KURL&)), docManager(), SLOT(projectArchive(const KURL&))); connect(projectview, SIGNAL(removeFromProject(const KileProjectItem *)), docManager(), SLOT(removeFromProject(const KileProjectItem *))); connect(projectview, SIGNAL(addFiles(const KURL &)), docManager(), SLOT(projectAddFiles(const KURL &))); connect(projectview, SIGNAL(toggleArchive(KileProjectItem *)), docManager(), SLOT(toggleArchive(KileProjectItem *))); connect(projectview, SIGNAL(addToProject(const KURL &)), docManager(), SLOT(addToProject(const KURL &))); connect(projectview, SIGNAL(saveURL(const KURL &)), docManager(), SLOT(saveURL(const KURL &))); connect(projectview, SIGNAL(buildProjectTree(const KURL &)), docManager(), SLOT(buildProjectTree(const KURL &))); connect(docManager(), SIGNAL(projectTreeChanged(const KileProject *)), projectview, SLOT(refreshProjectTree(const KileProject *))); ButtonBar->insertTab( SmallIcon("structure"),1,i18n("Structure")); connect(ButtonBar->getTab(1),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); m_kwStructure = new KileWidget::Structure(this, Structview); m_kwStructure->setFocusPolicy(QWidget::ClickFocus); connect(m_kwStructure, SIGNAL(setCursor(int,int)), this, SLOT(setCursor(int,int))); connect(m_kwStructure, SIGNAL(fileOpen(const KURL&, const QString & )), docManager(), SLOT(fileOpen(const KURL&, const QString& ))); connect(m_kwStructure, SIGNAL(fileNew(const KURL&)), docManager(), SLOT(fileNew(const KURL&))); QToolTip::add(m_kwStructure, i18n("Click to jump to the line")); mpview = new metapostview( Structview ); connect(mpview, SIGNAL(clicked(QListBoxItem *)), SLOT(InsertMetaPost(QListBoxItem *))); m_edit = new KileDocument::EditorExtension(this); m_help = new KileHelp::Help(m_edit); config = KGlobal::config(); // check requirements for IncludeGraphicsDialog (dani) KileConfig::setImagemagick(!(KStandardDirs::findExe("identify") == QString::null)); //workaround for kdvi crash when started with Tooltips KileConfig::setRunOnStart(false); KileFS->readConfig(); setXMLFile( "kileui.rc" ); ReadSettings(); setupActions(); // ReadRecentFileSettings should be after setupActions() because fileOpenRecentAction needs to be // initialized before calling ReadSettnigs(). ReadRecentFileSettings(); ButtonBar->insertTab(SmallIcon("math1"),2,i18n("Relation Symbols")); connect(ButtonBar->getTab(2),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); ButtonBar->insertTab(SmallIcon("math2"),3,i18n("Arrow Symbols")); connect(ButtonBar->getTab(3),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); ButtonBar->insertTab(SmallIcon("math3"),4,i18n("Miscellaneous Symbols")); connect(ButtonBar->getTab(4),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); ButtonBar->insertTab(SmallIcon("math4"),5,i18n("Delimiters")); connect(ButtonBar->getTab(5),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); ButtonBar->insertTab(SmallIcon("math5"),6,i18n("Greek Letters")); connect(ButtonBar->getTab(6),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); - ButtonBar->insertTab(SmallIcon("math6"),7,i18n("Foreign characters")); + ButtonBar->insertTab(SmallIcon("math6"),7,i18n("Special characters")); connect(ButtonBar->getTab(7),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); ButtonBar->insertTab(SmallIcon("metapost"),8,i18n("MetaPost Commands")); connect(ButtonBar->getTab(8),SIGNAL(clicked(int)),this,SLOT(showVertPage(int))); splitter2=new QSplitter(QSplitter::Vertical, splitter1, "splitter2"); viewManager()->createTabs(splitter2); connect(viewManager(), SIGNAL(activateView(QWidget*, bool, bool )), this, SLOT(activateView(QWidget*, bool, bool ))); connect(viewManager(), SIGNAL(prepareForPart(const QString& )), this, SLOT(prepareForPart(const QString& ))); //Log/Messages/KShell widgets - Outputview=new QTabWidget(splitter2); - Outputview->setFocusPolicy(QWidget::ClickFocus); + m_outputView=new QTabWidget(splitter2); + m_outputView->setFocusPolicy(QWidget::ClickFocus); - //LogWidget = new MessageWidget( Outputview ); - LogWidget = new KileWidget::LogMsg( this, Outputview ); - connect(LogWidget, SIGNAL(fileOpen(const KURL&, const QString & )), docManager(), SLOT(fileOpen(const KURL&, const QString& ))); - connect(LogWidget, SIGNAL(setLine(const QString& )), this, SLOT(setLine(const QString& ))); - - LogWidget->setFocusPolicy(QWidget::ClickFocus); - LogWidget->setMinimumHeight(40); - LogWidget->setReadOnly(true); - Outputview->addTab(LogWidget,SmallIcon("viewlog"), i18n("Log/Messages")); - - OutputWidget = new KileWidget::Output(Outputview); - OutputWidget->setFocusPolicy(QWidget::ClickFocus); - OutputWidget->setMinimumHeight(40); - OutputWidget->setReadOnly(true); - Outputview->addTab(OutputWidget,SmallIcon("output_win"), i18n("Output")); + //m_logWidget = new MessageWidget( m_outputView ); + m_logWidget = new KileWidget::LogMsg( this, m_outputView ); + connect(m_logWidget, SIGNAL(fileOpen(const KURL&, const QString & )), docManager(), SLOT(fileOpen(const KURL&, const QString& ))); + connect(m_logWidget, SIGNAL(setLine(const QString& )), this, SLOT(setLine(const QString& ))); + + m_logWidget->setFocusPolicy(QWidget::ClickFocus); + m_logWidget->setMinimumHeight(40); + m_logWidget->setReadOnly(true); + m_outputView->addTab(m_logWidget,SmallIcon("viewlog"), i18n("Log/Messages")); + + m_outputWidget = new KileWidget::Output(m_outputView); + m_outputWidget->setFocusPolicy(QWidget::ClickFocus); + m_outputWidget->setMinimumHeight(40); + m_outputWidget->setReadOnly(true); + m_outputView->addTab(m_outputWidget,SmallIcon("output_win"), i18n("Output")); - logpresent=false; m_outputInfo=new LatexOutputInfoArray(); m_outputFilter=new LatexOutputFilter(m_outputInfo); - connect(m_outputFilter, SIGNAL(problem(int, const QString& )), LogWidget, SLOT(printProblem(int, const QString& ))); + connect(m_outputFilter, SIGNAL(problem(int, const QString& )), m_logWidget, SLOT(printProblem(int, const QString& ))); - m_texKonsole=new KileWidget::Konsole(this, Outputview,"konsole"); - Outputview->addTab(m_texKonsole,SmallIcon("konsole"),i18n("Konsole")); + m_texKonsole=new KileWidget::Konsole(this, m_outputView,"konsole"); + m_outputView->addTab(m_texKonsole,SmallIcon("konsole"),i18n("Konsole")); QValueList sizes; sizes << split2_top << split2_bottom; splitter2->setSizes( sizes ); sizes.clear(); sizes << split1_left << split1_right; splitter1->setSizes( sizes ); topWidgetStack->addWidget(splitter1 , 0); setCentralWidget(topWidgetStack); ShowOutputView(false); ShowStructView(false); - Outputview->showPage(LogWidget); + m_outputView->showPage(m_logWidget); lastvtab=1; newCaption(); showVertPage(0); m_singlemode=true; m_masterName=getName(); partManager->setActivePart( 0L ); m_lyxserver = new KileLyxServer(m_runlyxserver); connect(m_lyxserver, SIGNAL(insert(const KileAction::TagData &)), this, SLOT(insertTag(const KileAction::TagData &))); KileApplication::closeSplash(); show(); - connect(Outputview, SIGNAL( currentChanged( QWidget * ) ), m_texKonsole, SLOT(sync())); + connect(m_outputView, SIGNAL( currentChanged( QWidget * ) ), m_texKonsole, SLOT(sync())); applyMainWindowSettings(config, "KileMainWindow" ); - m_manager = new KileTool::Manager(this, config, LogWidget, OutputWidget, partManager, topWidgetStack, m_paStop, 10000); //FIXME make timeout configurable + m_manager = new KileTool::Manager(this, config, m_logWidget, m_outputWidget, partManager, topWidgetStack, m_paStop, 10000); //FIXME make timeout configurable connect(m_manager, SIGNAL(requestGUIState(const QString &)), this, SLOT(prepareForPart(const QString &))); connect(m_manager, SIGNAL(requestSaveAll()), docManager(), SLOT(fileSaveAll())); - connect(m_manager, SIGNAL(jumpToFirstError()), this, SLOT(jumpToFirstError())); + connect(m_manager, SIGNAL(jumpToFirstError()), m_errorHandler, SLOT(jumpToFirstError())); + connect(m_manager, SIGNAL(toolStarted()), m_errorHandler, SLOT(reset())); m_toolFactory = new KileTool::Factory(m_manager, config); m_manager->setFactory(m_toolFactory); m_help->setManager(m_manager); // kile help (dani) if ( m_listUserTools.count() > 0 ) { KMessageBox::information(0, i18n("You have defined some tools in the User menu. From now on these tools will be available from the Build->Other menu and can be configured in the configuration dialog (go to the Settings menu and choose Configure Kile). This has some advantages; your own tools can now be used in a QuickBuild command if you wish."), i18n("User Tools Detected")); m_listUserTools.clear(); } if (m_bShowUserMovedMessage) { KMessageBox::information(0, i18n("Please note that the 'User' menu, which holds the (La)TeX tags you have defined, is moved to the LaTeX menu.")); } connect(docManager(), SIGNAL(updateModeStatus()), this, SLOT(updateModeStatus())); connect(docManager(), SIGNAL(updateStructure(bool, KileDocument::Info*)), viewManager(), SLOT(updateStructure(bool, KileDocument::Info*))); connect(docManager(), SIGNAL(closingDocument(KileDocument::Info* )), m_kwStructure, SLOT(closeDocumentInfo(KileDocument::Info *))); connect(docManager(), SIGNAL(documentInfoCreated(KileDocument::Info* )), m_kwStructure, SLOT(addDocumentInfo(KileDocument::Info* ))); // connect(viewManager(), SIGNAL(updateStructure(bool, KileDocument::Info*)), this, SLOT(UpdateStructure(bool, KileDocument::Info*))); if (rest) restore(); } Kile::~Kile() { kdDebug() << "cleaning up..." << endl; // CodeCompletion and edvanced editor (dani) delete m_edit; delete m_AutosaveTimer; } void Kile::setupActions() { m_paPrint = KStdAction::print(0,0, actionCollection(), "print"); (void) KStdAction::openNew(docManager(), SLOT(fileNew()), actionCollection(), "file_new" ); (void) KStdAction::open(docManager(), SLOT(fileOpen()), actionCollection(),"file_open" ); fileOpenRecentAction = KStdAction::openRecent(docManager(), SLOT(fileOpen(const KURL&)), actionCollection(), "file_open_recent"); connect(docManager(), SIGNAL(addToRecentFiles(const KURL& )), fileOpenRecentAction, SLOT(addURL(const KURL& ))); (void) new KAction(i18n("Save All"),"save_all", 0, docManager(), SLOT(fileSaveAll()), actionCollection(),"file_save_all" ); (void) new KAction(i18n("Create Template From Document..."), 0, docManager(), SLOT(createTemplate()), actionCollection(),"CreateTemplate"); (void) KStdAction::close(docManager(), SLOT(fileClose()), actionCollection(),"file_close" ); (void) new KAction(i18n("Close All"), 0, docManager(), SLOT(fileCloseAll()), actionCollection(),"file_close_all" ); (void) new KAction(i18n("S&tatistics"), 0, this, SLOT(showDocInfo()), actionCollection(), "Statistics" ); (void) new KAction(i18n("&ASCII"), 0, this, SLOT(convertToASCII()), actionCollection(), "file_export_ascii" ); (void) new KAction(i18n("Latin-&1 (iso 8859-1)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_latin1" ); (void) new KAction(i18n("Latin-&2 (iso 8859-2)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_latin2" ); (void) new KAction(i18n("Latin-&3 (iso 8859-3)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_latin3" ); (void) new KAction(i18n("Latin-&4 (iso 8859-4)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_latin4" ); (void) new KAction(i18n("Latin-&5 (iso 8859-5)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_latin5" ); (void) new KAction(i18n("Latin-&9 (iso 8859-9)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_latin9" ); (void) new KAction(i18n("&Central European (cp-1250)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_cp1250" ); (void) new KAction(i18n("&Western European (cp-1252)"), 0, this, SLOT(convertToEnc()), actionCollection(), "file_export_cp1252" ); (void) KStdAction::quit(this, SLOT(close()), actionCollection(),"file_quit" ); (void) new KAction(i18n("Find &in files..."), ALT+SHIFT+Key_F, this, SLOT(FindInFiles()), actionCollection(),"FindInFiles" ); kdDebug() << "CONNECTING SPELLCHECKER" << endl; connect ( viewManager(), SIGNAL(startSpellCheck()), m_spell, SLOT(spellcheck()) ); (void) new KAction(i18n("Refresh Structure"), "structure", 0, this, SLOT(RefreshStructure()), actionCollection(),"RefreshStructure" ); //project actions (void) new KAction(i18n("&New Project..."), "filenew", 0, docManager(), SLOT(projectNew()), actionCollection(), "project_new"); (void) new KAction(i18n("&Open Project..."), "fileopen", 0, docManager(), SLOT(projectOpen()), actionCollection(), "project_open"); m_actRecentProjects = new KRecentFilesAction(i18n("Open &Recent Project..."), 0, docManager(), SLOT(projectOpen(const KURL &)), actionCollection(), "project_openrecent"); connect(docManager(), SIGNAL(removeFromRecentProjects(const KURL& )), m_actRecentProjects, SLOT(removeURL(const KURL& ))); connect(docManager(), SIGNAL(addToRecentProjects(const KURL& )), m_actRecentProjects, SLOT(addURL(const KURL& ))); (void) new KAction(i18n("A&dd files to project..."), 0, docManager(), SLOT(projectAddFiles()), actionCollection(), "project_add"); (void) new KAction(i18n("Refresh Project &Tree"), "relation", 0, docManager(), SLOT(buildProjectTree()), actionCollection(), "project_buildtree"); (void) new KAction(i18n("&Archive"), "package", 0, docManager(), SLOT(projectArchive()), actionCollection(), "project_archive"); (void) new KAction(i18n("Project &Options..."), "configure", 0, docManager(), SLOT(projectOptions()), actionCollection(), "project_options"); (void) new KAction(i18n("&Close Project"), "fileclose", 0, docManager(), SLOT(projectClose()), actionCollection(), "project_close"); //build actions (void) new KAction(i18n("Clean"),0 , this, SLOT(CleanAll()), actionCollection(),"CleanAll" ); - (void) new KAction(i18n("View Log File"),"viewlog", ALT+Key_0, this, SLOT(ViewLog()), actionCollection(),"ViewLog" ); - (void) new KAction(i18n("Previous LaTeX Error"),"errorprev", 0, this, SLOT(PreviousError()), actionCollection(),"PreviousError" ); - (void) new KAction(i18n("Next LaTeX Error"),"errornext", 0, this, SLOT(NextError()), actionCollection(),"NextError" ); - (void) new KAction(i18n("Previous LaTeX Warning"),"warnprev", 0, this, SLOT(PreviousWarning()), actionCollection(),"PreviousWarning" ); - (void) new KAction(i18n("Next LaTeX Warning"),"warnnext", 0, this, SLOT(NextWarning()), actionCollection(),"NextWarning" ); - (void) new KAction(i18n("Previous LaTeX BadBox"),"bboxprev", 0, this, SLOT(PreviousBadBox()), actionCollection(),"PreviousBadBox" ); - (void) new KAction(i18n("Next LaTeX BadBox"),"bboxnext", 0, this, SLOT(NextBadBox()), actionCollection(),"NextBadBox" ); + (void) new KAction(i18n("View Log File"),"viewlog", ALT+Key_0, m_errorHandler, SLOT(ViewLog()), actionCollection(),"ViewLog" ); + (void) new KAction(i18n("Previous LaTeX Error"),"errorprev", 0, m_errorHandler, SLOT(PreviousError()), actionCollection(),"PreviousError" ); + (void) new KAction(i18n("Next LaTeX Error"),"errornext", 0, m_errorHandler, SLOT(NextError()), actionCollection(),"NextError" ); + (void) new KAction(i18n("Previous LaTeX Warning"),"warnprev", 0, m_errorHandler, SLOT(PreviousWarning()), actionCollection(),"PreviousWarning" ); + (void) new KAction(i18n("Next LaTeX Warning"),"warnnext", 0, m_errorHandler, SLOT(NextWarning()), actionCollection(),"NextWarning" ); + (void) new KAction(i18n("Previous LaTeX BadBox"),"bboxprev", 0, m_errorHandler, SLOT(PreviousBadBox()), actionCollection(),"PreviousBadBox" ); + (void) new KAction(i18n("Next LaTeX BadBox"),"bboxnext", 0, m_errorHandler, SLOT(NextBadBox()), actionCollection(),"NextBadBox" ); m_paStop = new KAction(i18n("&Stop"),"stop",Key_Escape,0,0,actionCollection(),"Stop"); m_paStop->setEnabled(false); setupTools(); (void) new KAction(i18n("Editor View"),"edit",CTRL+Key_E , this, SLOT(ShowEditorWidget()), actionCollection(),"EditorView" ); (void) new KAction(i18n("Next Document"),"forward",ALT+Key_Right, viewManager(), SLOT(gotoNextView()), actionCollection(), "gotoNextDocument" ); (void) new KAction(i18n("Previous Document"),"back",ALT+Key_Left, viewManager(), SLOT(gotoPrevView()), actionCollection(), "gotoPrevDocument" ); (void) new KAction(i18n("Focus Log/Messages view"), CTRL+ALT+Key_M, this, SLOT(focusLog()), actionCollection(), "focus_log"); (void) new KAction(i18n("Focus Output view"), CTRL+ALT+Key_O, this, SLOT(focusOutput()), actionCollection(), "focus_output"); (void) new KAction(i18n("Focus Konsole view"), CTRL+ALT+Key_K, this, SLOT(focusKonsole()), actionCollection(), "focus_konsole"); (void) new KAction(i18n("Focus Editor view"), CTRL+ALT+Key_E, this, SLOT(focusEditor()), actionCollection(), "focus_editor"); // CodeCompletion (dani) (void) new KAction(i18n("La(TeX) Command"),"complete1",CTRL+Key_Space, m_edit, SLOT(completeWord()), actionCollection(), "edit_complete_word"); (void) new KAction(i18n("Environment"),"complete2",ALT+Key_Space, m_edit, SLOT(completeEnvironment()), actionCollection(), "edit_complete_env"); (void) new KAction(i18n("Abbreviation"),"complete3",CTRL+ALT+Key_Space, m_edit, SLOT(completeAbbreviation()), actionCollection(), "edit_complete_abbrev"); (void) new KAction(i18n("Next Bullet"),"nextbullet",CTRL+ALT+Key_Right, m_edit, SLOT(nextBullet()), actionCollection(), "edit_next_bullet"); (void) new KAction(i18n("Prev Bullet"),"prevbullet",CTRL+ALT+Key_Left, m_edit, SLOT(prevBullet()), actionCollection(), "edit_prev_bullet"); // advanced editor (dani) (void) new KAction(i18n("Environment (inside)"),KShortcut("CTRL+Alt+S,E"), m_edit, SLOT(selectEnvInside()), actionCollection(), "edit_select_inside_env"); (void) new KAction(i18n("Environment (outside)"),KShortcut("CTRL+Alt+S,F"), m_edit, SLOT(selectEnvOutside()), actionCollection(), "edit_select_outside_env"); (void) new KAction(i18n("TeX Group (inside)"),"selgroup_i",KShortcut("CTRL+Alt+S,T"), m_edit, SLOT(selectTexgroupInside()), actionCollection(), "edit_select_inside_group"); (void) new KAction(i18n("TeX Group (outside)"),"selgroup_o",KShortcut("CTRL+Alt+S,U"),m_edit, SLOT(selectTexgroupOutside()), actionCollection(), "edit_select_outside_group"); (void) new KAction(i18n("Paragraph"),KShortcut("CTRL+Alt+S,P"),m_edit, SLOT(selectParagraph()), actionCollection(), "edit_select_paragraph"); (void) new KAction(i18n("Line"),KShortcut("CTRL+Alt+S,L"),m_edit, SLOT(selectLine()), actionCollection(), "edit_select_line"); (void) new KAction(i18n("TeX word"),KShortcut("CTRL+Alt+S,W"),m_edit, SLOT(selectWord()), actionCollection(), "edit_select_word"); (void) new KAction(i18n("Environment (inside)"),KShortcut("CTRL+Alt+D,E"), m_edit, SLOT(deleteEnvInside()), actionCollection(), "edit_delete_inside_env"); (void) new KAction(i18n("Environment (outside)"),KShortcut("CTRL+Alt+D,F"),m_edit, SLOT(deleteEnvOutside()), actionCollection(), "edit_delete_outside_env"); (void) new KAction(i18n("TeX Group (inside)"),KShortcut("CTRL+Alt+D,T"), m_edit, SLOT(deleteTexgroupInside()), actionCollection(), "edit_delete_inside_group"); (void) new KAction(i18n("TeX Group (outside)"),KShortcut("CTRL+Alt+D,U"),m_edit, SLOT(deleteTexgroupInside()), actionCollection(), "edit_delete_outside_group"); (void) new KAction(i18n("Paragraph"),KShortcut("CTRL+Alt+D,P"),m_edit, SLOT(deleteParagraph()), actionCollection(), "edit_delete_paragraph"); (void) new KAction(i18n("TeX word"),KShortcut("CTRL+Alt+D,W"),m_edit, SLOT(deleteWord()), actionCollection(), "edit_delete_word"); (void) new KAction(i18n("Goto Begin"),KShortcut("CTRL+Alt+E,B"), m_edit, SLOT(gotoBeginEnv()), actionCollection(), "edit_begin_env"); (void) new KAction(i18n("Goto End"),KShortcut("CTRL+Alt+E,E"), m_edit, SLOT(gotoEndEnv()), actionCollection(), "edit_end_env"); (void) new KAction(i18n("Match"),"matchenv",KShortcut("CTRL+Alt+E,M"), m_edit, SLOT(matchEnv()), actionCollection(), "edit_match_env"); (void) new KAction(i18n("Close"),"closeenv",KShortcut("CTRL+Alt+E,C"), m_edit, SLOT(closeEnv()), actionCollection(), "edit_close_env"); (void) new KAction(i18n("Goto Begin"),KShortcut("CTRL+Alt+G,B"), m_edit, SLOT(gotoBeginTexgroup()), actionCollection(), "edit_begin_group"); (void) new KAction(i18n("Goto End"),KShortcut("CTRL+Alt+G,E"), m_edit, SLOT(gotoEndTexgroup()), actionCollection(), "edit_end_group"); (void) new KAction(i18n("Match"),"matchgroup",KShortcut("CTRL+Alt+G,M"), m_edit, SLOT(matchTexgroup()), actionCollection(), "edit_match_group"); (void) new KAction(i18n("Close"),"closegroup",KShortcut("CTRL+Alt+G,C"), m_edit, SLOT(closeTexgroup()), actionCollection(), "edit_close_group"); (void) new KAction(i18n("teTeX Guide"),KShortcut("CTRL+Alt+H,T"), m_help, SLOT(helpTetexGuide()), actionCollection(), "edit_help_tetex_guide"); (void) new KAction(i18n("teTeX Doc"),KShortcut("CTRL+Alt+H,T"), m_help, SLOT(helpTetexDoc()), actionCollection(), "edit_help_tetex_doc"); (void) new KAction(i18n("LaTeX"),KShortcut("CTRL+Alt+H,L"), m_help, SLOT(helpLatexIndex()), actionCollection(), "edit_help_latex_index"); (void) new KAction(i18n("LaTeX Command"),KShortcut("CTRL+Alt+H,C"), m_help, SLOT(helpLatexCommand()), actionCollection(), "edit_help_latex_command"); (void) new KAction(i18n("LaTeX Subject"),KShortcut("CTRL+Alt+H,S"), m_help, SLOT(helpLatexSubject()), actionCollection(), "edit_help_latex_subject"); (void) new KAction(i18n("LaTeX Env"),KShortcut("CTRL+Alt+H,E"), m_help, SLOT(helpLatexEnvironment()), actionCollection(), "edit_help_latex_env"); (void) new KAction(i18n("Context Help"),KShortcut("CTRL+Alt+H,K"), m_help, SLOT(helpKeyword()), actionCollection(), "edit_help_context"); KileStdActions::setupStdTags(this,this); KileStdActions::setupMathTags(this); KileStdActions::setupBibTags(this); (void) new KAction(i18n("Quick Start"),"wizard",0 , this, SLOT(QuickDocument()), actionCollection(),"127" ); connect(docManager(), SIGNAL(startWizard()), this, SLOT(QuickDocument())); (void) new KAction(i18n("Tabular"),"wizard",0 , this, SLOT(QuickTabular()), actionCollection(),"129" ); (void) new KAction(i18n("Tabbing"),"wizard",0 , this, SLOT(QuickTabbing()), actionCollection(),"149" ); (void) new KAction(i18n("Array"),"wizard",0 , this, SLOT(QuickArray()), actionCollection(),"130" ); (void) new KAction(i18n("Clean"),0 , this, SLOT(CleanBib()), actionCollection(),"CleanBib" ); ModeAction=new KToggleAction(i18n("Define Current Document as 'Master Document'"),"master",0 , this, SLOT(ToggleMode()), actionCollection(),"Mode" ); StructureAction=new KToggleAction(i18n("Show Structure View"),0 , this, SLOT(ToggleStructView()), actionCollection(),"StructureView" ); MessageAction=new KToggleAction(i18n("Show Messages View"),0 , this, SLOT(ToggleOutputView()), actionCollection(),"MessageView" ); //FIXME: obsolete for KDE 4 m_paShowMainTB = new KToggleToolBarAction("mainToolBar", i18n("Main"), actionCollection(), "ShowMainToolbar"); m_paShowToolsTB = new KToggleToolBarAction("toolsToolBar", i18n("Tools"), actionCollection(), "ShowToolsToolbar"); m_paShowBuildTB = new KToggleToolBarAction("buildToolBar", i18n("Build"), actionCollection(), "ShowQuickToolbar"); m_paShowErrorTB = new KToggleToolBarAction("errorToolBar", i18n("Error"), actionCollection(), "ShowErrorToolbar"); m_paShowEditTB = new KToggleToolBarAction("editToolBar", i18n("Edit"), actionCollection(), "ShowEditToolbar"); m_paShowMathTB = new KToggleToolBarAction("mathToolBar", i18n("Math"), actionCollection(), "ShowMathToolbar"); //Save the toolbar settings, we need to know if the toolbars should be visible or not. We can't use KToggleToolBarAction->isChecked() //since this will return false if we hide the toolbar when switching to Viewer mode for example. m_bShowMainTB = m_paShowMainTB->isChecked(); m_bShowToolsTB = m_paShowToolsTB->isChecked(); m_bShowErrorTB = m_paShowErrorTB->isChecked(); m_bShowBuildTB = m_paShowBuildTB->isChecked(); m_bShowEditTB = m_paShowEditTB->isChecked(); m_bShowMathTB = m_paShowMathTB->isChecked(); if (m_singlemode) {ModeAction->setChecked(false);} else {ModeAction->setChecked(true);} if (showstructview) {StructureAction->setChecked(true);} else {StructureAction->setChecked(false);} if (showoutputview) {MessageAction->setChecked(true);} else {MessageAction->setChecked(false);} (void) new KAction(i18n("Remove Template..."),0, docManager(), SLOT(removeTemplate()), actionCollection(), "removetemplates"); WatchFileAction=new KToggleAction(i18n("Watch File Mode"),"watchfile",0 , this, SLOT(ToggleWatchFile()), actionCollection(), "WatchFile"); if (m_bWatchFile) {WatchFileAction->setChecked(true);} else {WatchFileAction->setChecked(false);} setHelpMenuEnabled(false); const KAboutData *aboutData = KGlobal::instance()->aboutData(); KHelpMenu *help_menu = new KHelpMenu( this, aboutData); (void) new KAction(i18n("LaTeX Reference"),"help",0 , this, SLOT(LatexHelp()), actionCollection(),"help1" ); (void) KStdAction::helpContents(help_menu, SLOT(appHelpActivated()), actionCollection(), "help2"); (void) KStdAction::reportBug (help_menu, SLOT(reportBug()), actionCollection(), "report_bug"); (void) KStdAction::aboutApp(help_menu, SLOT(aboutApplication()), actionCollection(),"help4" ); (void) KStdAction::aboutKDE(help_menu, SLOT(aboutKDE()), actionCollection(),"help5" ); (void) KStdAction::preferences(this, SLOT(GeneralOptions()), actionCollection(),"settings_configure" ); (void) KStdAction::keyBindings(this, SLOT(ConfigureKeys()), actionCollection(),"147" ); (void) KStdAction::configureToolbars(this, SLOT(ConfigureToolbars()), actionCollection(),"148" ); m_menuUserTags = new KActionMenu(i18n("User Tags"), SmallIcon("label"), actionCollection(),"menuUserTags"); m_menuUserTags->setDelayed(false); setupUserTagActions(); actionCollection()->readShortcutSettings(); } void Kile::setupTools() { kdDebug() << "==Kile::setupTools()===================" << endl; QStringList tools = KileTool::toolList(config); QString toolMenu; QPtrList *pl; unplugActionList("list_compilers"); unplugActionList("list_converters"); unplugActionList("list_quickies"); unplugActionList("list_viewers"); unplugActionList("list_other"); for ( uint i = 0; i < tools.count(); i++) { QString grp = KileTool::groupFor(tools[i], config); kdDebug() << tools[i] << " is using group: " << grp << endl; config->setGroup(KileTool::groupFor(tools[i], config)); toolMenu = KileTool::menuFor(tools[i], config); if ( toolMenu == "none" ) continue; if ( toolMenu == "Compile" ) pl = &m_listCompilerActions; else if ( toolMenu == "View" ) pl = &m_listViewerActions; else if ( toolMenu == "Convert" ) pl = &m_listConverterActions; else if ( toolMenu == "Quick" ) pl = &m_listQuickActions; else pl = &m_listOtherActions; kdDebug() << "\tadding " << tools[i] << " " << toolMenu << " #" << pl->count() << endl; if ( action(QString("tool_"+tools[i]).ascii()) == 0L ) { KAction *act = new KAction(tools[i], KileTool::iconFor(tools[i], config), KShortcut(), this, SLOT(runTool()), actionCollection(), QString("tool_"+tools[i]).ascii()); pl->append(act); } } cleanUpActionList(m_listCompilerActions, tools); cleanUpActionList(m_listViewerActions, tools); cleanUpActionList(m_listConverterActions, tools); cleanUpActionList(m_listQuickActions, tools); cleanUpActionList(m_listOtherActions, tools); plugActionList("list_compilers", m_listCompilerActions); plugActionList("list_viewers", m_listViewerActions); plugActionList("list_converters", m_listConverterActions); plugActionList("list_quickies", m_listQuickActions); plugActionList("list_other", m_listOtherActions); actionCollection()->readShortcutSettings("Shortcuts", config); } void Kile::cleanUpActionList(QPtrList &list, const QStringList & tools) { for ( KAction *act = list.first(); act; act = list.next() ) { if ( action(act->name()) != 0L && !tools.contains(QString(act->name()).mid(5)) ) { list.remove(act); if ( act->isPlugged(toolBar("toolsToolBar")) ) act->unplug(toolBar("toolsToolBar")); } } } void Kile::setupUserTagActions() { KShortcut tagaccels[10] = {CTRL+SHIFT+Key_1, CTRL+SHIFT+Key_2,CTRL+SHIFT+Key_3,CTRL+SHIFT+Key_4,CTRL+SHIFT+Key_5,CTRL+SHIFT+Key_6,CTRL+SHIFT+Key_7, CTRL+SHIFT+Key_8,CTRL+SHIFT+Key_9,CTRL+SHIFT+Key_0}; m_actionEditTag = new KAction(i18n("Edit User Tags"),0 , this, SLOT(EditUserMenu()), m_menuUserTags,"EditUserMenu" ); m_menuUserTags->insert(m_actionEditTag); for (uint i=0; iinsert(menuItem); } actionCollection()->readShortcutSettings("Shortcuts", config); } void Kile::restore() { if (!m_bRestore) return; QFileInfo fi; for (uint i=0; i < m_listProjectsOpenOnStart.count(); i++) { kdDebug() << "restoring " << m_listProjectsOpenOnStart[i] << endl; fi.setFile(m_listProjectsOpenOnStart[i]); if (fi.isReadable()) docManager()->projectOpen(KURL::fromPathOrURL(m_listProjectsOpenOnStart[i]), i, m_listProjectsOpenOnStart.count()); } for (uint i=0; i < m_listDocsOpenOnStart.count(); i++) { kdDebug() << "restoring " << m_listDocsOpenOnStart[i] << endl; fi.setFile(m_listDocsOpenOnStart[i]); if (fi.isReadable()) docManager()->fileOpen(KURL::fromPathOrURL(m_listDocsOpenOnStart[i])); } m_masterName = KileConfig::master(); m_singlemode = (m_masterName == ""); if (ModeAction) ModeAction->setChecked(!m_singlemode); updateModeStatus(); m_listProjectsOpenOnStart.clear(); m_listDocsOpenOnStart.clear(); Kate::Document *doc = docManager()->docFor(KURL::fromPathOrURL(lastDocument)); if (doc) activateView(doc->views().first()); } void Kile::setActive() { kdDebug() << "ACTIVATING" << endl; kapp->mainWidget()->raise(); kapp->mainWidget()->setActiveWindow(); } ////////////////////////////// FILE ///////////////////////////// void Kile::setLine( const QString &line ) { bool ok; uint l=line.toUInt(&ok,10); Kate::View *view = viewManager()->currentView(); if (view && ok) { this->show(); this->raise(); view->setFocus(); view->gotoLineNumber(l); ShowEditorWidget(); newStatus(); } } void Kile::setCursor(int parag, int index) { Kate::View *view = viewManager()->currentView(); if (view) { view->setCursorPositionReal(parag, index); view->setFocus(); } } void Kile::load(const QString &path) { docManager()->load(KURL::fromPathOrURL(path)); } //FIXME: connect to modifiedondisc() when using KDE 3.2 bool Kile::eventFilter(QObject* o, QEvent* e) { if ( (!m_bBlockWindowActivateEvents) && e->type() == QEvent::WindowActivate && o == this ) { //block windowactivate events since the popup window (isModOnHD) takes focus //away from the mainwindow m_bBlockWindowActivateEvents = true; for (uint i=0; i < viewManager()->views().count(); i++) { viewManager()->view(i)->getDoc()->isModOnHD(); } m_bBlockWindowActivateEvents = false; } return QWidget::eventFilter(o,e); } //TODO: move to KileView::Manager void Kile::activateView(QWidget* w ,bool checkModified /*= true*/, bool updateStruct /* = true */ ) //Needs to be QWidget because of QTabWidget::currentChanged { //kdDebug() << "==Kile::activateView==========================" << endl; if (!w->inherits("Kate::View")) return; Kate::View* view = (Kate::View*)w; for (uint i=0; i< viewManager()->views().count(); i++) { guiFactory()->removeClient(viewManager()->view(i)); viewManager()->view(i)->setActive(false); } toolBar ()->setUpdatesEnabled (false); guiFactory()->addClient(view); view->setActive( true ); //KParts::GUIActivateEvent ev( true ); //QApplication::sendEvent( view, &ev ); if( checkModified ) if (view) view->getDoc()->isModOnHD(); if (updateStruct) viewManager()->updateStructure(); toolBar ()->setUpdatesEnabled (true); } void Kile::updateModeStatus() { KileProject *project = docManager()->activeProject(); if (project) { statusBar()->changeItem(i18n("Project: %1").arg(project->name()), ID_HINTTEXT); } else { if (m_singlemode) { statusBar()->changeItem(i18n("Normal mode"), ID_HINTTEXT); } else { QString shortName = m_masterName; int pos = shortName.findRev('/'); shortName.remove(0,pos+1); statusBar()->changeItem(i18n("Master document: %1").arg(shortName), ID_HINTTEXT); } } } void Kile::fileSelected(const QString & url) { docManager()->fileSelected(KURL::fromPathOrURL(url)); } void Kile::autoSaveAll() { docManager()->fileSaveAll(true); } void Kile::enableAutosave(bool as) { autosave=as; if (as) { //paranoia pays, we're really screwed if somehow autosaveinterval equals zero if ( autosaveinterval < 1 ) autosaveinterval = 10; m_AutosaveTimer->start(autosaveinterval * 60000); } else m_AutosaveTimer->stop(); } void Kile::projectOpen(const QString& proj) { docManager()->projectOpen(KURL::fromPathOrURL(proj)); } void Kile::focusLog() { - Outputview->showPage(LogWidget); + m_outputView->showPage(m_logWidget); } void Kile::focusOutput() { - Outputview->showPage(OutputWidget); + m_outputView->showPage(m_outputWidget); } void Kile::focusKonsole() { - Outputview->showPage(m_texKonsole); + m_outputView->showPage(m_texKonsole); } void Kile::focusEditor() { Kate::View *view = viewManager()->currentView(); if (view) view->setFocus(); } bool Kile::queryExit() { SaveSettings(); return true; } bool Kile::queryClose() { //don't close Kile if embedded viewers are present if ( m_currentState != "Editor" ) { ResetPart(); return false; } Kate::View *view = viewManager()->currentView(); if (view) lastDocument = view->getDoc()->url().path(); m_listProjectsOpenOnStart.clear(); m_listDocsOpenOnStart.clear(); kdDebug() << "#projects = " << docManager()->projects()->count() << endl; for (uint i=0; i < docManager()->projects()->count(); i++) { m_listProjectsOpenOnStart.append(docManager()->projects()->at(i)->url().path()); } bool stage1 = docManager()->projectCloseAll(); bool stage2 = true; if (stage1) { for (uint i=0; i < viewManager()->views().count(); i++) { m_listDocsOpenOnStart.append(viewManager()->view(i)->getDoc()->url().path()); } stage2 =docManager()->fileCloseAll(); } return stage1 && stage2; } void Kile::showDocInfo(Kate::Document *doc) { if (doc == 0) { Kate::View *view = viewManager()->currentView(); if (view) doc = view->getDoc(); else return; } KileDocument::Info *docinfo = docManager()->infoFor(doc); if (docinfo) { KileDocInfoDlg *dlg = new KileDocInfoDlg(docinfo, this, 0, i18n("Summary for document : %1").arg(getShortName(doc))); dlg->exec(); } else kdWarning() << "There is know KileDocument::Info object belonging to this document!" << endl; } void Kile::convertToASCII(Kate::Document *doc) { if (doc == 0) { Kate::View *view = viewManager()->currentView(); if (view) doc = view->getDoc(); else return; } ConvertIO io(doc); ConvertEncToASCII conv = ConvertEncToASCII(doc->encoding(), &io); doc->setEncoding("ISO 8859-1"); conv.convert(); } void Kile::convertToEnc(Kate::Document *doc) { if (doc == 0) { Kate::View *view = viewManager()->currentView(); if (view) doc = view->getDoc(); else return; } if (sender()) { ConvertIO io(doc); QString name = QString(sender()->name()).section('_', -1); ConvertASCIIToEnc conv = ConvertASCIIToEnc(name, &io); conv.convert(); doc->setEncoding(ConvertMap::encodingNameFor(name)); } } ////////////////// GENERAL SLOTS ////////////// void Kile::newStatus(const QString & msg) { statusBar()->changeItem(msg,ID_LINE_COLUMN); } -const QStringList* Kile::retrieveList(const QStringList* (KileDocument::Info::*getit)() const, KileDocument::Info * docinfo /* = 0 */) -{ - m_listTemp.clear(); - - if (docinfo == 0) - { - docinfo = docManager()->getInfo(); - } - KileProjectItem *item = docManager()->itemFor(docinfo, docManager()->activeProject()); - - kdDebug() << "Kile::retrieveList()" << endl; - if (item) - { - const KileProject *project = item->project(); - const KileProjectItem *root = project->rootItem(item); - if (root) - { - kdDebug() << "\tusing root item " << root->url().fileName() << endl; - - QPtrList children; - children.append(root); - root->allChildren(&children); - - const QStringList *list; - - for (uint i=0; i < children.count(); i++) - { - kdDebug() << "\t" << children.at(i)->url().fileName() << endl; - list = (children.at(i)->getInfo()->*getit)(); - if (list) - { - for (uint i=0; i < list->count(); i++) - m_listTemp << (*list)[i]; - } - } - - return &m_listTemp; - } - else - return &m_listTemp; - } - else if (docinfo) - { - m_listTemp = *((docinfo->*getit)()); - return &m_listTemp; - } - else - return &m_listTemp; -} - -const QStringList* Kile::labels(KileDocument::Info * info) -{ - kdDebug() << "Kile::labels()" << endl; - const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::labels; - const QStringList* list = retrieveList(p, info); - return list; -} - -const QStringList* Kile::bibItems(KileDocument::Info * info) -{ - kdDebug() << "Kile::bibItems()" << endl; - const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::bibItems; - const QStringList* list = retrieveList(p, info); - return list; -} - -const QStringList* Kile::bibliographies(KileDocument::Info * info) -{ - kdDebug() << "Kile::bibliographies()" << endl; - const QStringList* (KileDocument::Info::*p)() const=&KileDocument::Info::bibliographies; - const QStringList* list = retrieveList(p, info); - return list; -} - int Kile::lineNumber() { Kate::View *view = viewManager()->currentView(); int para = 0; if (view) { para = view->cursorLine(); } return para; } void Kile::newCaption() { Kate::View *view = viewManager()->currentView(); if (view) { setCaption(i18n("Document: %1").arg(getName(view->getDoc()))); - if (Outputview->currentPage()->inherits("KileWidget::Konsole")) m_texKonsole->sync(); + if (m_outputView->currentPage()->inherits("KileWidget::Konsole")) m_texKonsole->sync(); } } void Kile::GrepItemSelected(const QString &abs_filename, int line) { kdDebug() << "Open file: " << abs_filename << " (" << line << ")" << endl; docManager()->fileOpen(KURL::fromPathOrURL(abs_filename)); setLine(QString::number(line)); } void Kile::FindInFiles() { static KileGrepDialog *dlg = 0; if (dlg != 0) { if (!dlg->isVisible()) dlg->setDirName((docManager()->activeProject() != 0) ? docManager()->activeProject()->baseURL().path() : QDir::home().absPath() + "/"); dlg->show(); return; } dlg = new KileGrepDialog ((docManager()->activeProject() != 0) ? docManager()->activeProject()->baseURL().path() : QDir::home().absPath() + "/"); QString filter(SOURCE_EXTENSIONS); filter.append(" "); filter.append(PACKAGE_EXTENSIONS); filter.replace(".", "*."); filter.replace(" ", ","); filter.append("|"); filter.append(i18n("TeX files")); filter.append("\n*|"); filter.append(i18n("All files")); dlg->setFilter(filter); dlg->show(); connect(dlg, SIGNAL(itemSelected(const QString &, int)), this, SLOT(GrepItemSelected(const QString &, int))); } /////////////////// PART & EDITOR WIDGET ////////// void Kile::ShowEditorWidget() { ResetPart(); setCentralWidget(topWidgetStack); topWidgetStack->show(); splitter1->show(); splitter2->show(); if (showstructview) Structview->show(); - if (showoutputview) Outputview->show(); + if (showoutputview) m_outputView->show(); Kate::View *view = viewManager()->currentView(); if (view) view->setFocus(); newStatus(); newCaption(); } void Kile::ResetPart() { kdDebug() << "==Kile::ResetPart()=============================" << endl; kdDebug() << "\tcurrent state " << m_currentState << endl; kdDebug() << "\twant state " << m_wantState << endl; KParts::ReadOnlyPart *part = (KParts::ReadOnlyPart*)partManager->activePart(); if (part && m_currentState != "Editor") { kdDebug() << "\tclosing current part" << endl; part->closeURL(); partManager->removePart(part) ; topWidgetStack->removeWidget(part->widget()); delete part; } m_currentState = "Editor"; m_wantState = "Editor"; partManager->setActivePart( 0L); } void Kile::ActivePartGUI(KParts::Part * part) { kdDebug() << "==Kile::ActivePartGUI()=============================" << endl; kdDebug() << "\tcurrent state " << m_currentState << endl; kdDebug() << "\twant state " << m_wantState << endl; //save the toolbar state if ( m_wantState == "HTMLpreview" || m_wantState == "Viewer" ) { kdDebug() << "\tsaving toolbar status" << endl; m_bShowMainTB = m_paShowMainTB->isChecked(); m_bShowToolsTB = m_paShowToolsTB->isChecked(); m_bShowBuildTB = m_paShowBuildTB->isChecked(); m_bShowErrorTB = m_paShowErrorTB->isChecked(); m_bShowEditTB = m_paShowEditTB->isChecked(); m_bShowMathTB = m_paShowMathTB->isChecked(); } createGUI(part); unplugActionList("list_quickies"); plugActionList("list_quickies", m_listQuickActions); unplugActionList("list_compilers"); plugActionList("list_compilers", m_listCompilerActions); unplugActionList("list_converters"); plugActionList("list_converters", m_listConverterActions); unplugActionList("list_viewers"); plugActionList("list_viewers", m_listViewerActions); unplugActionList("list_other"); plugActionList("list_other", m_listOtherActions); showToolBars(m_wantState); KParts::BrowserExtension *ext = KParts::BrowserExtension::childObject(part); if (ext && ext->metaObject()->slotNames().contains( "print()" ) ) //part is a BrowserExtension, connect printAction() { // kdDebug() << "HAS BrowserExtension + print" << endl; connect(m_paPrint, SIGNAL(activated()), ext, SLOT(print())); m_paPrint->plug(toolBar("mainToolBar"),3); //plug this action into its default location m_paPrint->setEnabled(true); } else { // kdDebug() << "NO BrowserExtension + print" << endl; if (m_paPrint->isPlugged(toolBar("mainToolBar"))) m_paPrint->unplug(toolBar("mainToolBar")); m_paPrint->setEnabled(false); } //set the current state m_currentState = m_wantState; m_wantState = "Editor"; } void Kile::showToolBars(const QString & wantState) { if ( wantState == "HTMLpreview" ) { // kdDebug() << "\tchanged to: HTMLpreview" << endl; stateChanged( "HTMLpreview"); toolBar("mainToolBar")->hide(); toolBar("toolsToolBar")->hide(); toolBar("buildToolBar")->hide(); toolBar("errorToolBar")->hide(); toolBar("editToolBar")->hide(); toolBar("mathToolBar")->hide(); toolBar("extraToolBar")->show(); enableKileGUI(false); } else if ( wantState == "Viewer" ) { // kdDebug() << "\tchanged to: Viewer" << endl; stateChanged( "Viewer" ); toolBar("mainToolBar")->show(); toolBar("toolsToolBar")->hide(); toolBar("buildToolBar")->hide(); toolBar("errorToolBar")->hide(); toolBar("mathToolBar")->hide(); toolBar("extraToolBar")->show(); toolBar("editToolBar")->hide(); enableKileGUI(false); } else { // kdDebug() << "\tchanged to: Editor" << endl; stateChanged( "Editor" ); m_wantState="Editor"; topWidgetStack->raiseWidget(0); if (m_bShowMainTB) toolBar("mainToolBar")->show(); if (m_bShowEditTB) toolBar("editToolBar")->show(); if (m_bShowToolsTB) toolBar("toolsToolBar")->show(); if (m_bShowBuildTB) toolBar("buildToolBar")->show(); if (m_bShowErrorTB) toolBar("errorToolBar")->show(); if (m_bShowMathTB) toolBar("mathToolBar")->show(); toolBar("extraToolBar")->hide(); enableKileGUI(true); } } void Kile::enableKileGUI(bool enable) { int id; QString text; for (uint i=0; i < menuBar()->count(); i++) { id = menuBar()->idAt(i); text = menuBar()->text(id); if ( text == i18n("&Build") || text == i18n("&Project") || text == i18n("&LaTeX") || text == i18n("&Wizard") || text == i18n("&User") || text == i18n("&Graph") || text == i18n("&Tools") ) menuBar()->setItemEnabled(id, enable); } } //TODO: move to KileView::Manager void Kile::prepareForPart(const QString & state) { // kdDebug() << "==Kile::prepareForPart====================" << endl; if ( state == m_currentState ) return; ResetPart(); m_wantState = state; //deactivate kateparts for (uint i=0; iviews().count(); i++) { guiFactory()->removeClient(viewManager()->view(i)); viewManager()->view(i)->setActive(false); } } void Kile::runTool() { // kdDebug() << "==Kile::runTool()============" << endl; QString name = sender()->name(); kdDebug() << "\tname: " << name << endl; name.replace(QRegExp("^.*tool_"), ""); kdDebug() << "\ttool: " << name << endl; m_manager->run(name); } // changed clean dialog with selectable items (dani) void Kile::CleanAll(KileDocument::Info *docinfo, bool silent) { static QString noactivedoc = i18n("There is no active document or it is not saved."); if (docinfo == 0) { Kate::Document *doc = activeDocument(); if (doc) docinfo = docManager()->infoFor(doc); else { - LogWidget->printMsg(KileTool::Error, noactivedoc, i18n("Clean")); + m_logWidget->printMsg(KileTool::Error, noactivedoc, i18n("Clean")); return; } } if (docinfo) { QStringList extlist; QStringList templist = QStringList::split(" ", KileConfig::cleanUpFileExtensions()); QString str; QFileInfo file(docinfo->url().path()), fi; for (uint i=0; i < templist.count(); i++) { str = file.dirPath(true) + "/" + file.baseName(true) + templist[i]; fi.setFile(str); if ( fi.exists() ) extlist.append(templist[i]); } str = file.fileName(); if (!silent && (str==i18n("Untitled") || str == "" ) ) { - LogWidget->printMsg(KileTool::Error, noactivedoc, i18n("Clean")); + m_logWidget->printMsg(KileTool::Error, noactivedoc, i18n("Clean")); return; } if (!silent && extlist.count() > 0 ) { kdDebug() << "\tnot silent" << endl; KileDialog::Clean *dialog = new KileDialog::Clean(this, str, extlist); if ( dialog->exec() ) extlist = dialog->getCleanlist(); else { delete dialog; return; } delete dialog; } if ( extlist.count() == 0 ) { - LogWidget->printMsg(KileTool::Warning, i18n("Nothing to clean for %1").arg(str), i18n("Clean")); + m_logWidget->printMsg(KileTool::Warning, i18n("Nothing to clean for %1").arg(str), i18n("Clean")); return; } - LogWidget->printMsg(KileTool::Info, i18n("cleaning %1 : %2").arg(str).arg(extlist.join(" ")), i18n("Clean")); + m_logWidget->printMsg(KileTool::Info, i18n("cleaning %1 : %2").arg(str).arg(extlist.join(" ")), i18n("Clean")); docinfo->cleanTempFiles(extlist); } } ////////////////// STRUCTURE /////////////////// void Kile::ShowStructure() { showVertPage(1); } void Kile::RefreshStructure() { showVertPage(1); viewManager()->updateStructure(true); } -//////////////// MESSAGES - LOG FILE/////////////////////// -void Kile::ViewLog() -{ - Outputview->showPage(LogWidget); - logpresent=false; - - QString cn = getCompileName(); - if ( m_outputFilter->source() != cn ) - { - m_outputFilter->setSource(cn); - m_outputFilter->Run(cn.replace(QRegExp("\\..*$"),".log")); - } - - QString log = m_outputFilter->log(); - - if (log != QString::null) - { - LogWidget->setText(log); - LogWidget->highlight(); - LogWidget->scrollToBottom(); - logpresent=true; - } - else - { - LogWidget->printProblem(KileTool::Error, i18n("Cannot open log file! Did you run LaTeX?")); - } -} - -////////////////////////// ERRORS ///////////////////////////// - -void Kile::jumpToFirstError() -{ - int sz = m_outputInfo->size(); - for (int i = 0; i < sz; i++ ) - { - if ( (*m_outputInfo)[i].type() == LatexOutputInfo::itmError ) - { - jumpToProblem(&(*m_outputInfo)[i]); - break; - } - } -} - -void Kile::jumpToProblem(OutputInfo *info) -{ - QString file = getFullFromPrettyName(info->source()); - - if ( file != QString::null ) - { - docManager()->fileOpen(file); - if ( info->sourceLine() > 0 ) - setLine(QString::number(info->sourceLine() - 1)); - } -} - -void Kile::jumpToProblem(int type, bool forward) -{ - static LatexOutputInfoArray::iterator it; - - //if the current log file does not belong to the files the user is viewing - //reparse the correct log file - QString cn = getCompileName(); - bool correctlogfile = (cn == outputFilter()->source()); - if ( ! correctlogfile ) - { - LogWidget->clear(); - outputFilter()->setSource(cn); - QFileInfo fi(cn); - QString lf = fi.dirPath(true) + "/" + fi.baseName(true) + ".log"; - LogWidget->printMsg(KileTool::Info, i18n("Detecting errors (%1), please wait ...").arg(lf), i18n("Log") ); - if ( ! outputFilter()->Run( lf ) ) - { - outputFilter()->setSource(QString::null); - return; - } - } - - if (!m_outputInfo->isEmpty()) - { - int sz = m_outputInfo->size(); - int pl = forward ? 1 : -1; - bool found =false; - - //look for next problem of requested type - for (int i = m_nCurrentError+pl; (i < sz) && (i >= 0); i += pl ) - { - if ( (*m_outputInfo)[i].type() == type ) - { - m_nCurrentError = i; - found = true; - break; - } - } - - if ( !found ) return; - - Outputview->showPage(LogWidget); - - //If the log file is being viewed, use this to jump to the errors, - //otherwise, use the error summary display - if (logpresent) - LogWidget->highlight( (*m_outputInfo)[m_nCurrentError].outputLine(), pl ); - else - LogWidget->highlight( (*m_outputInfo)[m_nCurrentError].source() + ":" + QString::number((*m_outputInfo)[m_nCurrentError].sourceLine()), pl ); - - jumpToProblem(&(*m_outputInfo)[m_nCurrentError]); - } - - if (m_outputInfo->isEmpty() && correctlogfile) - { - LogWidget->append("\n"+ i18n("No LaTeX errors detected!") + ""); - } - - m_bNewInfolist = false; -} - -void Kile::NextError() -{ - jumpToProblem(LatexOutputInfo::itmError, true); -} - -void Kile::PreviousError() -{ - jumpToProblem(LatexOutputInfo::itmError, false); -} - -void Kile::NextWarning() -{ - jumpToProblem(LatexOutputInfo::itmWarning, true); -} - -void Kile::PreviousWarning() -{ - jumpToProblem(LatexOutputInfo::itmWarning, false); -} - -void Kile::NextBadBox() -{ - jumpToProblem(LatexOutputInfo::itmBadBox, true); -} - -void Kile::PreviousBadBox() -{ - jumpToProblem(LatexOutputInfo::itmBadBox, false); -} - /////////////////////// LATEX TAGS /////////////////// void Kile::insertTag(const KileAction::TagData& data) { Kate::View *view = viewManager()->currentView(); int para,index, para_end=0, para_begin, index_begin; if ( !view ) return; view->setFocus(); //whether or not to wrap tag around selection bool wrap = (data.tagEnd != QString::null && view->getDoc()->hasSelection()); //%C before or after the selection bool before = data.tagBegin.contains("%C"); bool after = data.tagEnd.contains("%C"); //save current cursor position para=para_begin=view->cursorLine(); index=index_begin=view->cursorColumnReal(); //if there is a selection act as if cursor is at the beginning of selection if (wrap) { index = view->getDoc()->selStartCol(); para = view->getDoc()->selStartLine(); para_end = view->getDoc()->selEndLine(); } QString ins = data.tagBegin; //cut the selected text if (wrap) { ins += view->getDoc()->selection(); view->getDoc()->removeSelectedText(); } ins += data.tagEnd; //do some replacements QFileInfo fi( view->getDoc()->url().path()); ins.replace("%S", fi.baseName(true)); //insert first part of tag at cursor position //kdDebug() << QString("insertTag: inserting %1 at (%2,%3)").arg(ins).arg(para).arg(index) << endl; view->getDoc()->insertText(para,index,ins); //move cursor to the new position if ( before || after ) { // kdDebug() << "before || after" << endl; int n = data.tagBegin.contains("\n")+ data.tagEnd.contains("\n"); if (wrap) n += para_end > para ? para_end-para : para-para_end; for (int line = para_begin; line <= para_begin+n; line++) { if (view->getDoc()->textLine(line).contains("%C")) { int i=view->getDoc()->textLine(line).find("%C"); view->setCursorPositionReal(line,i); view->getDoc()->removeText(line,i,line,i+2); break; } view->setCursorPositionReal(line,index); } } else { int py = para_begin, px = index_begin; if (wrap) //act as if cursor was at beginning of selected text (which is the point where the tagBegin is inserted) { py = para; px = index; } kdDebug() << "py = " << py << " px = " << px << endl; view->setCursorPositionReal(py+data.dy,px+data.dx); } view->getDoc()->clearSelection(); - LogWidget->clear(); - Outputview->showPage(LogWidget); - logpresent=false; + m_logWidget->clear(); + m_outputView->showPage(m_logWidget); + m_logPresent=false; - LogWidget->append(data.description); + m_logWidget->append(data.description); } void Kile::insertTag(const QString& tagB, const QString& tagE, int dx, int dy) { insertTag(KileAction::TagData(QString::null,tagB,tagE,dx,dy)); } void Kile::QuickDocument() { KileDialog::QuickDocument *dlg = new KileDialog::QuickDocument(config, this,"Quick Start",i18n("Quick Start")); if ( dlg->exec() ) { if ( !viewManager()->currentView() && ( docManager()->createDocumentWithText(QString::null) == 0L ) ) return; insertTag( dlg->tagData() ); } delete dlg; } void Kile::QuickTabular() { if ( !viewManager()->currentView() ) return; KileDialog::QuickTabular *dlg = new KileDialog::QuickTabular(config, this,"Tabular", i18n("Tabular")); if ( dlg->exec() ) { insertTag(dlg->tagData()); } delete dlg; } void Kile::QuickTabbing() { if ( !viewManager()->currentView() ) return; KileDialog::QuickTabbing *dlg = new KileDialog::QuickTabbing(config, this,"Tabbing", i18n("Tabbing")); if ( dlg->exec() ) { insertTag(dlg->tagData()); } delete dlg; } void Kile::QuickArray() { if ( !viewManager()->currentView() ) return; KileDialog::QuickArray *dlg = new KileDialog::QuickArray(config, this,"Array", i18n("Array")); if ( dlg->exec() ) { insertTag(dlg->tagData()); } delete dlg; } //////////////////////////// MATHS TAGS///////////////////////////////////// void Kile::insertSymbol(QIconViewItem *item) { QString code_symbol= item->key(); insertTag(code_symbol,QString::null,code_symbol.length(),0); } void Kile::InsertMetaPost(QListBoxItem *) { QString mpcode=mpview->currentText(); if (mpcode!="----------") insertTag(mpcode,QString::null,mpcode.length(),0); } ////////////////////////// BIBLIOGRAPHY ////////////////////////// //////////////// USER ////////////////// // void Kile::insertUserTag(int i) // { // if (m_listUserTags[i].tag.left(1)=="%") // { // QString t=m_listUserTags[i].tag; // t=t.remove(0,1); // insertTag("\\begin{"+t+"}\n","\n\\end{"+t+"}\n",0,1); // } // else // { // QStringList parts = QStringList::split("%M",m_listUserTags[i].tag); // int dx = parts[0].length(); // if ( parts[1].length() == 0 ) // { // int i = parts[0].find('{'); // if ( i != -1 ) // dx = i + 1; // } // insertTag(parts[0],parts[1], dx, 0); // } // } // void Kile::insertUserTag(const KileAction::TagData& td) // { // QString tag = td.tagBegin; // // if ( tag.left(1)=="%" ) // { // QString t= tag; // t=t.remove(0,1); // insertTag("\\begin{"+t+"}\n","\n\\end{"+t+"}\n",0,1); // } // else // { // QStringList parts = QStringList::split("%M", tag); // int dx = parts[0].length(); // if ( parts[1].length() == 0 ) // { // int i = parts[0].find('{'); // if ( i != -1 ) // dx = i + 1; // } // insertTag(parts[0],parts[1], dx, 0); // } // } //////////////// HELP ///////////////// void Kile::LatexHelp() { QString loc = locate("html","en/kile/latexhelp.html"); KileTool::ViewHTML *tool = dynamic_cast(m_toolFactory->create("ViewHTML")); tool->setSource(loc); tool->setRelativeBaseDir(""); tool->setTarget("latexhelp.html"); m_manager->run(tool); } ///////////////////// USER /////////////// void Kile::EditUserMenu() { KileDialog::UserTags *dlg = new KileDialog::UserTags(m_listUserTags, this, "Edit User Tags", i18n("Edit User Tags")); if ( dlg->exec() ) { //remove all actions uint len = m_listUserTagsActions.count(); for (uint j=0; j< len; j++) { KAction *menuItem = m_listUserTagsActions.getLast(); m_menuUserTags->remove(menuItem); m_listUserTagsActions.removeLast(); delete menuItem; } m_menuUserTags->remove(m_actionEditTag); m_listUserTags = dlg->result(); setupUserTagActions(); } delete dlg; } /////////////// CONFIG //////////////////// void Kile::ReadSettings() { //test for old kilerc int version = KileConfig::rCVersion(); bool old=false; m_bShowUserMovedMessage = (version < 4); //if the kilerc file is old some of the configuration //date must be set by kile, even if the keys are present //in the kilerc file if ( version < KILERC_VERSION ) old=true; if ( version < 4 ) { KileTool::Factory *factory = new KileTool::Factory(0,config); kdDebug() << "WRITING STD TOOL CONFIG" << endl; factory->writeStdConfig(); } //delete old editor key if (config->hasGroup("Editor") ) { config->deleteGroup("Editor"); } config->setGroup( "User" ); int len = config->readNumEntry("nUserTags",0); for (int i = 0; i < len; i++) { m_listUserTags.append(KileDialog::UserTags::splitTag(config->readEntry("userTagName"+QString::number(i),i18n("no name")) , config->readEntry("userTag"+QString::number(i),"") )); } //convert user tools to new KileTool classes userItem tempItem; len= config->readNumEntry("nUserTools",0); for (int i=0; i< len; i++) { tempItem.name=config->readEntry("userToolName"+QString::number(i),i18n("no name")); tempItem.tag =config->readEntry("userTool"+QString::number(i),""); m_listUserTools.append(tempItem); } if ( len > 0 ) { //move the tools config->writeEntry("nUserTools", 0); for ( int i = 0; i < len; i++) { tempItem = m_listUserTools[i]; config->setGroup("Tools"); config->writeEntry(tempItem.name, "Default"); KileTool::setGUIOptions(tempItem.name, "Other", "gear", config); config->setGroup(KileTool::groupFor(tempItem.name, "Default")); QString bin = KRun::binaryName(tempItem.tag, false); config->writeEntry("command", bin); config->writeEntry("options", tempItem.tag.mid(bin.length())); config->writeEntry("class", "Base"); config->writeEntry("type", "Process"); config->writeEntry("from", ""); config->writeEntry("to", ""); if ( i < 10 ) { config->setGroup("Shortcuts"); config->writeEntry("tool_" + tempItem.name, "Alt+Shift+" + QString::number(i + 1) ); //should be alt+shift+ } } } //convert old config names containing spaces to KConfig XT compliant names if((0 != version) && (version < 5)) { KxtRcConverter cvt(config, KILERC_VERSION); cvt.Convert(); } //reads options that can be set in the configuration dialog readConfig(); //now read the other config data m_singlemode=true; QRect screen = QApplication::desktop()->screenGeometry(); resize(KileConfig::mainwindowWidth(), KileConfig::mainwindowHeight()); split1_left = KileConfig::splitter1_left(); split1_right = KileConfig::splitter1_right(); split2_top = KileConfig::splitter2_top(); split2_bottom = KileConfig::splitter2_bottom(); showoutputview = KileConfig::outputview(); showstructview = KileConfig::structureview(); struct_level1 = KileConfig::structureLevel1(); struct_level2 = KileConfig::structureLevel2(); struct_level3 = KileConfig::structureLevel3(); struct_level4 = KileConfig::structureLevel4(); struct_level5 = KileConfig::structureLevel5(); } void Kile::ReadRecentFileSettings() { config->setGroup("FilesOpenOnStart"); int n = config->readNumEntry("NoDOOS", 0); for (int i=0; i < n; i++) m_listDocsOpenOnStart.append(config->readPathEntry("DocsOpenOnStart"+QString::number(i), "")); n = config->readNumEntry("NoPOOS", 0); for (int i=0; i < n; i++) m_listProjectsOpenOnStart.append(config->readPathEntry("ProjectsOpenOnStart"+QString::number(i), "")); lastDocument = KileConfig::lastDocument(); input_encoding = KileConfig::inputEncoding(); // Load recent files from "Recent Files" group // using the KDE standard action for recent files fileOpenRecentAction->loadEntries(config,"Recent Files"); // Now check if user is using an old rc file that has "Recent Files" under // the "Files" group if(config->hasKey("Recent Files")) { // If so, then read the entry in, add it to fileOpenRecentAction QStringList recentFilesList = config->readListEntry("Recent Files", ':'); QStringList::ConstIterator it = recentFilesList.begin(); for ( ; it != recentFilesList.end(); ++it ) { fileOpenRecentAction->addURL(KURL::fromPathOrURL(*it)); } // Now delete this recent files entry as we are now using a separate // group for recent files config->deleteEntry("Recent Files"); } m_actRecentProjects->loadEntries(config,"Projects"); } //reads options that can be set in the configuration dialog void Kile::readConfig() { // kdDebug() << "==Kile::readConfig()=======================" << endl; m_kwStructure->setLevel(KileConfig::defaultLevel()); m_bRestore = KileConfig::restore(); autosave = KileConfig::autosave(); autosaveinterval = KileConfig::autosaveInterval(); enableAutosave(autosave); setAutosaveInterval(autosaveinterval); m_templAuthor = KileConfig::author(); m_templDocClassOpt = KileConfig::documentClassOptions(); m_templEncoding = KileConfig::templateEncoding(); m_runlyxserver = KileConfig::runLyxServer(); //////////////////// code completion (dani) //////////////////// m_edit->complete()->readConfig(); } void Kile::SaveSettings() { ShowEditorWidget(); KileFS->writeConfig(); KileConfig::setLastDocument(lastDocument); input_encoding=KileFS->comboEncoding->lineEdit()->text(); KileConfig::setInputEncoding(input_encoding); // Store recent files fileOpenRecentAction->saveEntries(config,"Recent Files"); m_actRecentProjects->saveEntries(config,"Projects"); config->deleteGroup("FilesOpenOnStart"); kdDebug() << "deleting FilesOpenOnStart" << endl; if (m_bRestore) { kdDebug() << "saving Restore info" << endl; config->setGroup("FilesOpenOnStart"); config->writeEntry("NoDOOS", m_listDocsOpenOnStart.count()); for (uint i=0; i < m_listDocsOpenOnStart.count(); i++) config->writePathEntry("DocsOpenOnStart"+QString::number(i), m_listDocsOpenOnStart[i]); config->writeEntry("NoPOOS", m_listProjectsOpenOnStart.count()); for (uint i=0; i < m_listProjectsOpenOnStart.count(); i++) config->writePathEntry("ProjectsOpenOnStart"+QString::number(i), m_listProjectsOpenOnStart[i]); if (!m_singlemode) KileConfig::setMaster(m_masterName); else KileConfig::setMaster(""); } config->setGroup( "User" ); config->writeEntry("nUserTags",static_cast(m_listUserTags.size())); for (uint i=0; i < m_listUserTags.size(); i++) { KileAction::TagData td( m_listUserTags[i]); config->writeEntry( "userTagName"+QString::number(i), td.text ); config->writeEntry( "userTag"+QString::number(i), KileDialog::UserTags::completeTag(td) ); } actionCollection()->writeShortcutSettings(); saveMainWindowSettings(config, "KileMainWindow" ); KileConfig::setRCVersion(KILERC_VERSION); QValueList sizes; QValueList::Iterator it; KileConfig::setMainwindowWidth(width()); KileConfig::setMainwindowHeight(height()); sizes=splitter1->sizes(); it = sizes.begin(); split1_left=*it; ++it; split1_right=*it; sizes.clear(); sizes=splitter2->sizes(); it = sizes.begin(); split2_top=*it; ++it; split2_bottom=*it; KileConfig::setSplitter1_left(split1_left); KileConfig::setSplitter1_right(split1_right); KileConfig::setSplitter2_top(split2_top); KileConfig::setSplitter2_bottom(split2_bottom); KileConfig::setOutputview(showoutputview); KileConfig::setStructureview(showstructview); KileConfig::setStructureLevel1(struct_level1); KileConfig::setStructureLevel2(struct_level2); KileConfig::setStructureLevel3(struct_level3); KileConfig::setStructureLevel4(struct_level4); KileConfig::setStructureLevel5(struct_level5); KileConfig::writeConfig(); config->sync(); } ///////////////// OPTIONS //////////////////// void Kile::ToggleMode() { if (!m_singlemode) { ModeAction->setText(i18n("Define Current Document as 'Master Document'")); ModeAction->setChecked(false); - logpresent=false; + m_logPresent=false; m_singlemode=true; } else if (m_singlemode && viewManager()->currentView()) { m_masterName=getName(); if (m_masterName==i18n("Untitled") || m_masterName=="") { ModeAction->setChecked(false); KMessageBox::error(this, i18n("In order to define the current document as a master document, it has to be saved first.")); m_masterName=""; return; } QString shortName = m_masterName; int pos; while ( (pos = (int)shortName.find('/')) != -1 ) shortName.remove(0,pos+1); ModeAction->setText(i18n("Normal mode (current master document: %1)").arg(shortName)); ModeAction->setChecked(true); m_singlemode=false; } else ModeAction->setChecked(false); updateModeStatus(); } void Kile::ToggleOutputView() { ShowOutputView(true); } void Kile::ToggleStructView() { ShowStructView(true); } void Kile::ToggleWatchFile() { m_bWatchFile=!m_bWatchFile; if (m_bWatchFile) WatchFileAction->setChecked(true); else WatchFileAction->setChecked(false); } void Kile::ShowOutputView(bool change) { if (change) showoutputview=!showoutputview; if (showoutputview) { MessageAction->setChecked(true); - Outputview->show(); + m_outputView->show(); } else { MessageAction->setChecked(false); - Outputview->hide(); + m_outputView->hide(); } } void Kile::ShowStructView(bool change) { if (change) showstructview=!showstructview; if (showstructview) { StructureAction->setChecked(true); Structview->show(); } else { StructureAction->setChecked(false); Structview->hide(); } } void Kile::GeneralOptions() { KileDialog::Config *dlg = new KileDialog::Config(config, m_manager, this); if (dlg->exec()) { readConfig(); setupTools(); emit(configChanged()); //stop/restart LyX server if necessary if (m_runlyxserver && !m_lyxserver->isRunning()) m_lyxserver->start(); if (!m_runlyxserver && m_lyxserver->isRunning()) m_lyxserver->stop(); } delete dlg; } /////////////// KEYS - TOOLBARS CONFIGURATION //////////////// void Kile::ConfigureKeys() { KKeyDialog dlg( false, this ); QPtrList clients = guiFactory()->clients(); for( QPtrListIterator it( clients ); it.current(); ++it ) { dlg.insert( (*it)->actionCollection() ); } dlg.configure(); actionCollection()->writeShortcutSettings("Shortcuts", config); } void Kile::ConfigureToolbars() { saveMainWindowSettings(config, "KileMainWindow" ); KEditToolbar dlg(factory()); dlg.exec(); showToolBars(m_currentState); } ////////////// VERTICAL TAB ///////////////// void Kile::showVertPage(int page) { ButtonBar->setTab(lastvtab,false); ButtonBar->setTab(page,true); lastvtab=page; if (page==0) { viewManager()->projectView()->hide(); m_kwStructure->hide(); mpview->hide(); if (symbol_view && symbol_present) delete symbol_view; symbol_present=false; if (Structview_layout) delete Structview_layout; Structview_layout=new QHBoxLayout(Structview); Structview_layout->add(KileFS); Structview_layout->add(ButtonBar); ButtonBar->setPosition(KMultiVertTabBar::Right); KileFS->show(); } else if (page==1) { //UpdateStructure(); viewManager()->projectView()->hide(); KileFS->hide(); mpview->hide(); if (symbol_view && symbol_present) delete symbol_view; symbol_present=false; if (Structview_layout) delete Structview_layout; Structview_layout=new QHBoxLayout(Structview); Structview_layout->add(m_kwStructure); Structview_layout->add(ButtonBar); ButtonBar->setPosition(KMultiVertTabBar::Right); m_kwStructure->show(); } else if (page==8) { viewManager()->projectView()->hide(); KileFS->hide(); m_kwStructure->hide(); if (symbol_view && symbol_present) delete symbol_view; symbol_present=false; if (Structview_layout) delete Structview_layout; Structview_layout=new QHBoxLayout(Structview); Structview_layout->add(mpview); Structview_layout->add(ButtonBar); ButtonBar->setPosition(KMultiVertTabBar::Right); mpview->show(); } else if (page==9) { kdDebug() << "SHOWING PROJECTS VIEW" << endl; if (symbol_view && symbol_present) delete symbol_view; symbol_present=false; KileFS->hide(); m_kwStructure->hide(); mpview->hide(); delete Structview_layout; Structview_layout=new QHBoxLayout(Structview); Structview_layout->add(viewManager()->projectView()); Structview_layout->add(ButtonBar); ButtonBar->setPosition(KMultiVertTabBar::Right); viewManager()->projectView()->show(); } else { viewManager()->projectView()->hide(); KileFS->hide(); m_kwStructure->hide(); mpview->hide(); if (symbol_view && symbol_present) delete symbol_view; if (Structview_layout) delete Structview_layout; Structview_layout=new QHBoxLayout(Structview); symbol_view = new SymbolView(page-1,Structview,"Symbols"); connect(symbol_view, SIGNAL(executed(QIconViewItem*)), SLOT(insertSymbol(QIconViewItem*))); symbol_present=true; Structview_layout->add(symbol_view); Structview_layout->add(ButtonBar); ButtonBar->setPosition(KMultiVertTabBar::Right); symbol_view->show(); } } void Kile::changeInputEncoding() { Kate::View *view = viewManager()->currentView(); if (view) { bool modified = view->getDoc()->isModified(); QString encoding=KileFS->comboEncoding->lineEdit()->text(); QString text = view->getDoc()->text(); view->getDoc()->setEncoding(encoding); //reload the document so that the new encoding takes effect view->getDoc()->openURL(view->getDoc()->url()); docManager()->setHighlightMode(view->getDoc()); view->getDoc()->setModified(modified); } } //////////////////// CLEAN BIB ///////////////////// void Kile::CleanBib() { Kate::View *view = viewManager()->currentView(); if ( ! view ) return; uint i=0; QString s; while(i < view->getDoc()->numLines()) { s = view->getDoc()->textLine(i); s=s.left(3); if (s=="OPT" || s=="ALT") { view->getDoc()->removeLine(i ); view->getDoc()->setModified(true); } else i++; } } KileListViewItem::KileListViewItem(QListViewItem * parent, QListViewItem * after, QString title, uint line, uint column, int type) : KListViewItem(parent,after), m_title(title), m_line(line), m_column(column), m_type(type) { this->setText(0, m_title+" (line "+QString::number(m_line)+")"); } void Kile::includeGraphics() { Kate::View *view = viewManager()->currentView(); if ( !view ) return; QFileInfo fi( view->getDoc()->url().path() ); IncludegraphicsDialog *dialog = new IncludegraphicsDialog(this, fi.dirPath(), false); if ( dialog->exec() == QDialog::Accepted ) insertTag( dialog->getTemplate(),"%C",0,0 ); delete dialog; } #include "kile.moc" Index: trunk/kdeextragear-2/kile/kile/Makefile.am =================================================================== --- trunk/kdeextragear-2/kile/kile/Makefile.am (revision 314534) +++ trunk/kdeextragear-2/kile/kile/Makefile.am (revision 314535) @@ -1,72 +1,72 @@ ####### kdevelop will overwrite this part!!! (begin)########## bin_PROGRAMS = kile ## INCLUDES were found outside kdevelop specific part -kile_SOURCES = includegraphicsdialog.cpp newfilewizard.cpp managetemplatesdialog.cpp templates.cpp metapostview.cpp usermenudialog.cpp kileconfigdialog.cpp tabdialog.cpp tabbingdialog.cpp symbolview.cpp structdialog.cpp quickdocumentdialog.cpp kmultiverttabbar.cpp kilefileselect.cpp kileapplication.cpp docpart.cpp arraydialog.cpp kile.cpp main.cpp kileactions.cpp kilestdactions.cpp kileinfo.cpp kiledocumentinfo.cpp kileproject.cpp kileprojectdlgs.cpp kileprojectview.cpp kilelistselector.cpp kilelyxserver.cpp latexoutputfilter.cpp outputinfo.cpp latexoutputinfo.cpp outputfilter.cpp kilegrepdialog.cpp kiletool.cpp kilelauncher.cpp kiletoolmanager.cpp kilestdtools.cpp kilelogwidget.cpp kileoutputwidget.cpp kilekonsolewidget.cpp kilewizard.cpp kilestructurewidget.cpp codecompletion.cpp configcodecompletion.cpp kiletoolconfigwidget.cpp kileedit.cpp cleandialog.cpp kilehelp.cpp configstructure.cpp configenvironment.cpp kileappIface.skel convert.cpp helpconfigwidget.ui kiledocmanager.cpp kileviewmanager.cpp kileeventfilter.cpp kileautosavejob.cpp latexconfigwidget.ui kileconfig.kcfgc generalconfigwidget.ui kxtrcconverter.cpp texfilter.cpp kilespell.cpp kilespell2.cpp +kile_SOURCES = includegraphicsdialog.cpp newfilewizard.cpp managetemplatesdialog.cpp templates.cpp metapostview.cpp usermenudialog.cpp kileconfigdialog.cpp tabdialog.cpp tabbingdialog.cpp symbolview.cpp structdialog.cpp quickdocumentdialog.cpp kmultiverttabbar.cpp kilefileselect.cpp kileapplication.cpp docpart.cpp arraydialog.cpp kile.cpp main.cpp kileactions.cpp kilestdactions.cpp kileinfo.cpp kiledocumentinfo.cpp kileproject.cpp kileprojectdlgs.cpp kileprojectview.cpp kilelistselector.cpp kilelyxserver.cpp latexoutputfilter.cpp outputinfo.cpp latexoutputinfo.cpp outputfilter.cpp kilegrepdialog.cpp kiletool.cpp kilelauncher.cpp kiletoolmanager.cpp kilestdtools.cpp kilelogwidget.cpp kileoutputwidget.cpp kilekonsolewidget.cpp kilewizard.cpp kilestructurewidget.cpp codecompletion.cpp configcodecompletion.cpp kiletoolconfigwidget.cpp kileedit.cpp cleandialog.cpp kilehelp.cpp configstructure.cpp configenvironment.cpp kileappIface.skel convert.cpp helpconfigwidget.ui kiledocmanager.cpp kileviewmanager.cpp kileeventfilter.cpp kileautosavejob.cpp latexconfigwidget.ui kileconfig.kcfgc generalconfigwidget.ui kxtrcconverter.cpp texfilter.cpp kilespell.cpp kilespell2.cpp kileerrorhandler.cpp kile_LDADD = -lkdeprint -lktexteditor $(LIB_KSPELL) $(LIBKSPELL2) $(LIB_KHTML) SUBDIRS = icons pics symbols templates syntax complete help encodings test EXTRA_DIST = main.cpp kile.cpp kile.h arraydialog.cpp arraydialog.h \ docpart.cpp docpart.h kileappIface.h kileapplication.cpp kileapplication.h kile.desktop kilefileselect.cpp kilefileselect.h kileui.rc docpartui.rc kmultiverttabbar.cpp kmultiverttabbar.h letterdialog.cpp letterdialog.h quickdocumentdialog.cpp quickdocumentdialog.h structdialog.cpp structdialog.h symbolview.cpp symbolview.h tabbingdialog.cpp tabbingdialog.h tabdialog.cpp \ tabdialog.h kileconfigdialog.cpp kileconfigdialog.h usermenudialog.cpp \ usermenudialog.h metapostview.cpp metapostview.h \ newfilewizard.cpp newfilewizard.h templates.cpp templates.h managetemplatesdialog.cpp \ managetemplatesdialog.h kileinfo.h kileinfo.cpp kilestdactions.cpp \ kilestdactions.h kileproject.h kileproject.cpp kileprojectdlgs.cpp \ kileprojectdlgs.h kileprojectview.cpp kileprojectview.h \ kilelistselector.cpp kilelistselector.h kilelyxserver.cpp kilelyxserver.h \ latexoutputfilter.cpp outputinfo.cpp latexoutputinfo.cpp \ outputfilter.cpp latexoutputfilter.h outputinfo.h latexoutputinfo.h \ includegraphicsdialog.h includegraphicsdialog.cpp kiletoolconfigwidget.cpp kiletoolconfigwidget.h outputfilter.h kilegrepdialog.cpp kilegrepdialog.h codecompletion.h codecompletion.cpp configcodecompletion.cpp configcodecompletion.h kileedit.cpp cleandialog.cpp kileedit.h cleandialog.h kilehelp.cpp kilehelp.h configstructure.cpp configstructure.h configenvironment.cpp configenvironment.h convert.h convert.cpp xdg_apps_DATA = kile.desktop kde_kcfg_DATA = kile.kcfg KDE_ICON = AUTO ####### kdevelop will overwrite this part!!! (end)############ # These paths are KDE specific. Use them: # kde_appsdir Where your application's menu entry (.desktop) should go to. # kde_icondir Where your icon should go to - better use KDE_ICON. # kde_sounddir Where your sounds should go to. # kde_htmldir Where your docs should go to. (contains lang subdirs) # kde_datadir Where you install application data. (Use a subdir) # kde_locale Where translation files should go to. (contains lang subdirs) # kde_cgidir Where cgi-bin executables should go to. # kde_confdir Where config files should go to (system-wide ones with default values). # kde_mimedir Where mimetypes .desktop files should go to. # kde_servicesdir Where services .desktop files should go to. # kde_servicetypesdir Where servicetypes .desktop files should go to. # kde_toolbardir Where general toolbar icons should go to (deprecated, use KDE_ICON). # kde_wallpaperdir Where general wallpapers should go to. # kde_templatesdir Where templates for the "New" menu (Konqueror/KDesktop) should go to. # kde_bindir Where executables should go to. Use bin_PROGRAMS or bin_SCRIPTS. # kde_libdir Where shared libraries should go to. Use lib_LTLIBRARIES. # kde_moduledir Where modules (e.g. parts) should go to. Use kde_module_LTLIBRARIES. # kde_styledir Where Qt/KDE widget styles should go to (new in KDE 3). # kde_designerdir Where Qt Designer plugins should go to (new in KDE 3). # set the include path for X, qt and KDE INCLUDES = $(all_includes) METASOURCES = AUTO # the library search path. kile_LDFLAGS = $(all_libraries) $(KDE_RPATH) rcdir = $(kde_datadir)/kile rc_DATA = kileui.rc docpartui.rc kilestdtools.rc messages: rc.cpp LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \ if test -n "$$LIST"; then \ $(XGETTEXT) $$LIST -o $(podir)/kile.pot; \ fi syntaxdir = $(kde_appsdir)/katepart/syntax -noinst_HEADERS = kiletool.h kilelauncher.h kiletool_enums.h kiletoolmanager.h kilestdtools.h kilelogwidget.h kileoutputwidget.h kilekonsolewidget.h kilewizard.h kilestructurewidget.h convert.h kiledocmanager.h kileviewmanager.h kileeventfilter.h kileautosavejob.h latexconfigwidget.h kxtrcconverter.h kilespell.h kilespell2.h +noinst_HEADERS = kiletool.h kilelauncher.h kiletool_enums.h kiletoolmanager.h kilestdtools.h kilelogwidget.h kileoutputwidget.h kilekonsolewidget.h kilewizard.h kilestructurewidget.h convert.h kiledocmanager.h kileviewmanager.h kileeventfilter.h kileautosavejob.h latexconfigwidget.h kxtrcconverter.h kilespell.h kilespell2.h kileerrorhandler.h Index: trunk/kdeextragear-2/kile/kile/kiledocumentinfo.h =================================================================== --- trunk/kdeextragear-2/kile/kile/kiledocumentinfo.h (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kiledocumentinfo.h (revision 314535) @@ -1,230 +1,232 @@ /*************************************************************************** kiledocumentinfo.h - description ------------------- begin : Sun Jul 20 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KILEDOCUMENTINFO_H #define KILEDOCUMENTINFO_H #include #include #include #include #include #include #define TEX_CAT0 '\\' #define TEX_CAT1 '{' #define TEX_CAT2 '}' #define TEX_CAT3 '$' #define TEX_CAT4 '&' #define TEX_CAT6 '#' #define TEX_CAT7 '^' #define TEX_CAT8 '_' #define TEX_CAT13 '~' #define TEX_CAT14 '%' namespace KileStruct { enum { None = 0x1, Label = 0x2, Sect = 0x4, Input = 0x8, - BibItem = 0x10, Bibliography = 0x12, Package = 0x14 + BibItem = 0x10, Bibliography = 0x20, Package = 0x40, NewCommand = 0x80 }; } /** * A convenience class to store info about how LaTeX elements should appear in the * structure view. A QMap should be created, so that the * actual LaTeX elements can be mapped to this class. **/ class KileStructData { public: KileStructData(int lvl = 0, int tp = KileStruct::None, QString px = QString::null) : level(lvl), type(tp), pix(px) {} /** At which level the element should be visible **/ int level; /** The type of element (see @ref KileStruct) **/ int type; /** The name of the icon that goes with this element. The icon is located using SmallIcon(pix). **/ QString pix; }; /** * ListView items that can hold some additional information appropriate for the Structure View. The * additional information is: line number, title string. **/ class KileListViewItem : public KListViewItem { public: KileListViewItem(QListViewItem * parent, QListViewItem * after, QString title, uint line, uint m_column, int type); KileListViewItem(QListView * parent, QString label) : KListViewItem(parent,label), m_title(label), m_line(0), m_column(0),m_type(KileStruct::None) {} KileListViewItem(QListViewItem * parent, QString label) : KListViewItem(parent,label), m_title(label), m_line(0), m_column(0), m_type(KileStruct::None) {} /** @returns the title of this element (for a label it return the label), without the (line ...) part **/ const QString& title() { return m_title; } /** @returns the line number of the structure element. **/ const uint line() { return m_line; } /** @returns the column number of the structure element, right after the { **/ const uint column() { return m_column; } /** @returns the type of element, see @ref KileStruct **/ const int type() { return m_type; } private: QString m_title; uint m_line; uint m_column; int m_type; }; /** * KileDocument::Info is a decorator class for the Document class. We can't derive a class from an interface * without implementing the interface, a decorator class is a way to add some functionality to the Document class. **/ namespace KileDocument { struct BracketResult { BracketResult() : option(QString::null), value(QString::null) {} QString option, value; }; class Info : public QObject { Q_OBJECT public: static bool isTeXFile(const KURL &); static bool isBibFile(const KURL &); public: Info(Kate::Document *doc = 0L); ~Info() {kdDebug() << "DELETING DOCINFO" << m_url.path() << endl;} /** * @returns the document for which this class is a decorator **/ Kate::Document* getDoc() const { return m_doc; } void setDoc(Kate::Document *doc) { m_doc = doc; m_url=m_oldurl=doc->url();} void detach() { m_doc = 0L; } /** * Used by @ref KileDocInfoDlg to display statistics of the Document. * @returns an array with some statistical data of the document. * The array is filled as follows: #chars in words, #chars in LaTeX commands, * #chars in whitespace, #words, #commands. **/ virtual const long* getStatistics(); const QStringList* labels() const{ return &m_labels; } const QStringList* bibItems() const { return &m_bibItems; } const QStringList* dependencies() const {return &m_deps; } const QStringList* bibliographies() const { return &m_bibliography; } const QStringList* packages() const { return &m_packages; } + const QStringList* newCommands() const { return &m_newCommands; } - QString lastModifiedFile(); + QString lastModifiedFile(const QStringList *list = 0L); const QString & preamble() const { return m_preamble; } virtual bool isLaTeXRoot() { return m_bIsRoot; } void setURL(const KURL& url) { m_oldurl = m_url; m_url = url; emit nameChanged(url); } const KURL& url() {return m_url;} const KURL& oldURL() {return m_oldurl;} void cleanTempFiles(const QStringList & ); public slots: /** * Never call this function directly, use KileWidget::Structure::update(KileDocument::Info *, bool) instead **/ virtual void updateStruct(); virtual void updateBibItems(); void emitNameChanged(Kate::Document *); signals: void nameChanged(const KURL &); void nameChanged(Kate::Document *); void isrootChanged(bool); void foundItem(const QString &title, uint line, uint column, int type, int level, const QString & pix, const QString & folder); protected: void count(const QString line, long *stat); QString matchBracket(QChar c, uint &, uint &); protected: enum State { stStandard=0, stComment=1, stControlSequence=3, stControlSymbol=4, stCommand=5 }; protected: Kate::Document *m_doc; long *m_arStatistics; bool m_bIsRoot; QStringList m_labels; QStringList m_bibItems; QStringList m_deps; QStringList m_bibliography; QStringList m_packages; + QStringList m_newCommands; QString m_preamble; QMap m_dictStructLevel; KURL m_url, m_oldurl; KConfig *m_config; }; class TeXInfo : public Info { Q_OBJECT public: TeXInfo ( Kate::Document * doc ) : Info(doc) {} public: const long* getStatistics(); public slots: void updateStruct(); private: BracketResult matchBracket(uint &, uint &); }; class BibInfo : public Info { Q_OBJECT public: BibInfo ( Kate::Document * doc ) : Info(doc) {} bool isLaTeXRoot() { return false; } public slots: void updateStruct(); }; } class KileDocInfoDlg : public KDialogBase { public: KileDocInfoDlg(KileDocument::Info* docinfo, QWidget* parent = 0, const char* name = 0, const QString &caption = QString::null); ~KileDocInfoDlg() {} }; #endif Index: trunk/kdeextragear-2/kile/kile/kileautosavejob.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kileautosavejob.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kileautosavejob.cpp (revision 314535) @@ -1,43 +1,44 @@ // // C++ Implementation: kileautosavejob // // Description: // // // Author: Jeroen Wijnhout , (C) 2004 // /*************************************************************************** * * * 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 +#include #include "kileautosavejob.h" KileAutoSaveJob::KileAutoSaveJob(const KURL &url) { KIO::Job *job = KIO::file_copy(url,KURL(KURL::fromPathOrURL(url.path()+".backup")),-1,true,false,false); //let KIO show the error messages - job->setAutoErrorHandlingEnabled(true); + job->setAutoErrorHandlingEnabled(true, kapp->mainWidget()); connect(job, SIGNAL(result(KIO::Job*)), this, SLOT(slotResult(KIO::Job*))); } KileAutoSaveJob::~KileAutoSaveJob() { kdDebug() << "DELETING KileAutoSaveJob" << endl; } void KileAutoSaveJob::slotResult(KIO::Job *job) { if (job->error() == 0) emit(success()); deleteLater(); } #include "kileautosavejob.moc" Index: trunk/kdeextragear-2/kile/kile/kiledocumentinfo.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kiledocumentinfo.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kiledocumentinfo.cpp (revision 314535) @@ -1,603 +1,622 @@ /*************************************************************************** kiledocumentinfo.cpp - description ------------------- begin : Sun Jul 20 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 #include #include #include #include #include #include #include #include +#include "codecompletion.h" #include "kiledocumentinfo.h" namespace KileDocument { bool Info::isTeXFile(const KURL & url) { //TODO use mimetype QString shortName = url.fileName(); return (shortName.right(4) == ".tex" || shortName.right(4) == ".ltx" || shortName.right(6) == ".latex") && (shortName != i18n("Untitled")); } bool Info::isBibFile(const KURL & url) { QString shortName = url.fileName(); return ( shortName.right(4) == ".bib" ); } Info::Info(Kate::Document *doc) : m_doc(doc) { m_config = kapp->config(); if (m_doc) kdDebug() << "Info created for " << m_doc->docName() << endl; m_bIsRoot = false; m_arStatistics = new long[5]; if (m_doc) m_url=m_oldurl = doc->url(); else m_url = m_oldurl = KURL(); //TODO: make this configurable m_dictStructLevel["\\label"]= KileStructData(-1, KileStruct::Label); m_dictStructLevel["\\bibitem"]= KileStructData(-2, KileStruct::BibItem); m_dictStructLevel["\\input"]=KileStructData(0, KileStruct::Input, "include"); m_dictStructLevel["\\Input"]=KileStructData(0, KileStruct::Input, "include"); m_dictStructLevel["\\include"]=KileStructData(0, KileStruct::Input, "include"); m_dictStructLevel["\\part"]=KileStructData(1, KileStruct::Sect, "part"); m_dictStructLevel["\\chapter"]=KileStructData(2, KileStruct::Sect, "chapter"); m_dictStructLevel["\\section"]=KileStructData(3, KileStruct::Sect, "section"); m_dictStructLevel["\\subsection"]=KileStructData(4, KileStruct::Sect, "subsection"); m_dictStructLevel["\\subsubsection"]=KileStructData(5, KileStruct::Sect, "subsubsection"); m_dictStructLevel["\\bibliography"]=KileStructData(0,KileStruct::Bibliography, "bibtex"); m_dictStructLevel["\\usepackage"]=KileStructData(-3,KileStruct::Package); + m_dictStructLevel["\\newcommand"]=KileStructData(-4,KileStruct::NewCommand); } void Info::emitNameChanged(Kate::Document * /*doc*/) { kdDebug() << "==Info::emitNameChanged==========================" << endl; if (m_doc) { kdDebug() << "\tfrom: " << m_url.path() << endl; kdDebug() << "\tto: " << m_doc->url().path() << endl; //don't emit if new URL is empty (i.e. when closing the document) if (!m_doc->url().isEmpty() && (m_url != m_doc->url() ) ) { kdDebug() << "\temitting nameChanged(url)" << endl; setURL(m_doc->url()); //emit(nameChanged(m_url)); emit(nameChanged(m_doc)); } } } void Info::count(const QString line, long *stat) { QChar c; int state = stStandard; bool word = false; for (uint p=0; p < line.length(); p++) { c = line[p]; switch ( state ) { case stStandard : switch ( c ) { case TEX_CAT0 : state = stControlSequence; stat[1]++; stat[4]++; //look ahead to avoid counting words like K\"ahler as two words if (! line[p+1].isPunct() || line[p+1] == '~' || line[p+1] == '^' ) word=false; break; case TEX_CAT14 : p=line.length(); word=false; break; default: if (c.isLetterOrNumber()) { //only start new word if first character is a letter (42test is still counted as a word, but 42.2 not) if (c.isLetter() && !word) { word=true; stat[3]++; } stat[0]++; } else { stat[2]++; word = false; } break; } break; case stControlSequence : if ( c.isLetter() ) state = stCommand; else state = stStandard; stat[1]++; break; case stCommand : if ( c.isLetter() ) { stat[1]++; } else if ( c == TEX_CAT0 ) stat[4]++; else if ( c == TEX_CAT14 ) { p=line.length(); } else { stat[2]++; state = stStandard; } break; default : kdWarning() << "Unhandled state in getStatistics " << state << endl; break; } } } const long* Info::getStatistics() { //#c in words , #c in commands, #c whitespace, #words, #latex_commands m_arStatistics[0]=m_arStatistics[1]=m_arStatistics[2]=m_arStatistics[3]=m_arStatistics[4]=0; return m_arStatistics; } void Info::cleanTempFiles(const QStringList &extlist ) { QString finame = url().fileName(); QFileInfo fic(finame); QString baseName = fic.baseName(true); QStringList fileList; for (uint i=0; i< extlist.count(); i++) { fileList.append(baseName+extlist[i]); } QString path = url().directory(false); for (uint i=0; i < fileList.count(); i++) { QFile file( path + fileList[i] ); kdDebug() << "About to remove file = " << file.name() << endl; file.remove(); } } -QString Info::lastModifiedFile() +QString Info::lastModifiedFile(const QStringList *list /* = 0L */) { kdDebug() << "==QString Info::lastModifiedFile()=====" << endl; QFileInfo fileinfo ( url().path() ); QString basepath = fileinfo.dirPath(true), last = fileinfo.absFilePath(); QDateTime time ( fileinfo.lastModified() ); + if ( list == 0L ) list = &m_deps; + kdDebug() << "\t" << fileinfo.absFilePath() << " : " << time.toString() << endl; - for ( uint i = 0; i < m_deps.count(); i++ ) + for ( uint i = 0; i < list->count(); i++ ) { - fileinfo.setFile( basepath + "/" + m_deps[i]); + fileinfo.setFile( basepath + "/" + (*list)[i] ); kdDebug() << "\t" << fileinfo.absFilePath() << " : " << fileinfo.lastModified().toString() << endl; if ( fileinfo.lastModified() > time ) { time = fileinfo.lastModified(); last = fileinfo.absFilePath(); kdDebug() << "\t\tlater" << endl; } } kdDebug() << "\treturning " << fileinfo.absFilePath() << endl; return last; } // match a { with the corresponding } // pos is the positon of the { QString Info::matchBracket(QChar obracket, uint &l, uint &pos) { QChar cbracket; if ( obracket == '{' ) cbracket = '}'; if ( obracket == '[' ) cbracket = ']'; if ( obracket == '(' ) cbracket = ')'; QString line, grab = ""; int count=0, len; pos++; while ( l <= m_doc->numLines() ) { line = m_doc->textLine(l); len = line.length(); for (int i=pos; i < len; i++) { - if (line[i] == '\\') i++; + if (line[i] == '\\' && ( line[i+1] == obracket || line[i+1] == cbracket) ) i++; else if (line[i] == obracket) count++; else if (line[i] == cbracket) { count--; if (count < 0) return grab; } grab += line[i]; } l++; pos=0; } return QString::null; } void Info::updateStruct() { m_labels.clear(); m_bibItems.clear(); m_deps.clear(); m_bibliography.clear(); m_packages.clear(); + m_newCommands.clear(); m_bIsRoot = false; m_preamble = QString::null; } void Info::updateBibItems() { } const long* TeXInfo::getStatistics() { //#c in words , #c in commands, #c whitespace, #words, #latex_commands m_arStatistics[0]=m_arStatistics[1]=m_arStatistics[2]=m_arStatistics[3]=m_arStatistics[4]=0; QString line; //FIXME : counts environment names as words if ( m_doc && m_doc->hasSelection() ) { line = m_doc->selection(); count(line, m_arStatistics); } else if (m_doc) for (uint l=0; l < m_doc->numLines(); l++) { line = m_doc->textLine(l); kdDebug() << "getStat : line : " << line << endl; count(line, m_arStatistics); } return m_arStatistics; } BracketResult TeXInfo::matchBracket(uint &l, uint &pos) { BracketResult result; if ( m_doc->textLine(l)[pos] == '[' ) { result.option = Info::matchBracket('[', l, pos); int p = 0; while ( l < m_doc->numLines() ) { if ( (p = m_doc->textLine(l).find('{', pos)) != -1 ) { pos = p; break; } else { pos = 0; l++; } } } if ( m_doc->textLine(l)[pos] == '{' ) result.value = Info::matchBracket('{', l, pos); return result; } void TeXInfo::updateStruct() { if ( getDoc() == 0L ) return; Info::updateStruct(); kdDebug() << "==void TeXInfo::updateStruct()=========." << endl; QMapConstIterator it; static QRegExp::QRegExp reCommand("(\\\\[a-zA-Z]+)\\s*\\*?\\s*(\\{|\\[)"); static QRegExp::QRegExp reComments("([^\\\\]%|^%).*$"); static QRegExp::QRegExp reRoot("\\\\documentclass|\\\\documentstyle"); static QRegExp::QRegExp reBD("\\\\begin\\s*\\{\\s*document\\s*\\}"); - static QRegExp::QRegExp reNewCommand("\\\\(re)?newcommand.*$"); + static QRegExp::QRegExp reReNewCommand("\\\\renewcommand.*$"); int teller=0, tagStart, bd = 0; uint tagEnd, tagLine = 0, tagCol = 0; BracketResult result; QString m, s, cap, folder = "root", shorthand; bool foundBD = false; // found \begin { document } bool fire = true; //whether or not we should emit a foundItem signal for(uint i = 0; i < m_doc->numLines(); i++) { tagStart=tagEnd=0; folder = "root"; s=m_doc->textLine(i); fire = true; if (teller > 100) { teller=0; kapp->processEvents(); } else teller++; //remove escaped \ characters s.replace("\\\\", " "); //remove comments s.replace(reComments, ""); - //if the command is a \renewcommand or \newcommand, ignore rest of the line - s.replace(reNewCommand, ""); + //ignore renewcommands + s.replace(reReNewCommand, ""); //find all commands in this line while (tagStart != -1) { if ( (!foundBD) && ( (bd = s.find(reBD, tagEnd)) != -1)) { kdDebug() << "\tfound \\begin{document}" << endl; foundBD = true; if ( bd == 0 ) m_preamble = m_doc->text(0, 0, i - 1, m_doc->textLine(i - 1).length() ); else m_preamble = m_doc->text(0, 0, i, bd); } if ((!foundBD) && (s.find(reRoot, tagEnd) != -1)) { kdDebug() << "\tsetting m_bIsRoot to TRUE" << endl; tagEnd += reRoot.cap(0).length(); m_bIsRoot = true; } tagStart = reCommand.search(s,tagEnd); m=QString::null; shorthand = QString::null; if (tagStart != -1) { //kdDebug() << "Found command " << reCommand.cap(0) << " at " << i << endl; cap = reCommand.cap(1); tagEnd = tagStart + reCommand.cap(0).length()-1; //look up the command in the dictionary it = m_dictStructLevel.find(cap); //if it is was a structure element, find the title (or label) if (it != m_dictStructLevel.end()) { tagLine=i+1; tagCol = tagEnd+1; result = matchBracket(i, static_cast(tagEnd)); m = result.value.stripWhiteSpace(); shorthand = result.option.stripWhiteSpace(); if ( i >= tagLine ) //matching brackets spanned multiple lines s = m_doc->textLine(i); kdDebug() << "\tgrabbed : " << m << endl; } //title (or label) found, add the element to the listview if (m != QString::null) { //update the dependencies if ((*it).type == KileStruct::Input) { QString dep = m; if (dep.right(4) != ".tex") dep += ".tex"; m_deps.append(dep); } //update the referenced Bib files if((*it).type == KileStruct::Bibliography) { kdDebug() << "\tappending Bibiliograph file " << m << endl; QStringList bibs = QStringList::split(",", m); uint cumlen = 0; for (uint b = 0; b < bibs.count(); b++) { m_bibliography.append(bibs[b]); m_deps.append(bibs[b] + ".bib"); emit(foundItem(bibs[b], tagLine, tagCol + cumlen, (*it).type, (*it).level, (*it).pix, folder)); cumlen += bibs[b].length() + 1; } fire = false; } //update the label list if ((*it).type == KileStruct::Label) { m_labels.append(m); folder = "labels"; } //update the bibitem list if ((*it).type == KileStruct::BibItem) { kdDebug() << "\tappending bibitem " << m << endl; m_bibItems.append(m); } //update the package list if ((*it).type == KileStruct::Package) { QStringList pckgs = QStringList::split(",", m); uint cumlen = 0; for (uint p = 0; p < pckgs.count(); p++) { m_packages.append(pckgs[p]); emit(foundItem(pckgs[p], tagLine, tagCol + cumlen, (*it).type, (*it).level, (*it).pix, folder)); cumlen += pckgs[p].length() + 1; } fire = false; } + if ( (*it).type == KileStruct::NewCommand ) + { + bool ok; + int noo = shorthand.toInt(&ok); + if ( ok ) + { + for ( int noo_index = 0; noo_index < noo; noo_index++) + m += "{" + BULLET + "}"; + } + m_newCommands.append(m); + //ignore rest of line + continue; + } + if ( ((*it).type == KileStruct::Sect) && (shorthand != QString::null) ) m = shorthand; kdDebug() << "emitting foundItem " << m << endl; if (fire) emit(foundItem(m, tagLine, tagCol, (*it).type, (*it).level, (*it).pix, folder)); } //if m } // if tagStart } // while tagStart } //for emit(isrootChanged(isLaTeXRoot())); } void BibInfo::updateStruct() { if ( getDoc() == 0L ) return; Info::updateStruct(); kdDebug() << "==void BibInfo::updateStruct()========" << endl; static QRegExp::QRegExp reItem("^(\\s*)@([a-zA-Z]+)"); static QRegExp::QRegExp reSpecial("string|preamble|comment"); QString s, key; int col = 0, startcol, startline; for(uint i = 0; i < m_doc->numLines(); i++) { s = m_doc->textLine(i); if ( (s.find(reItem) != -1) && !reSpecial.exactMatch(reItem.cap(2).lower()) ) { kdDebug() << "found: " << reItem.cap(2) << endl; //start looking for key key = ""; bool keystarted = false; int state = 0; startcol = reItem.cap(1).length(); col = startcol + reItem.cap(2).length(); while ( col < static_cast(s.length()) ) { col++; if ( col == static_cast(s.length()) ) { do { i++; s = m_doc->textLine(i); } while ( (s.length() == 0) && (i < m_doc->numLines()) ); if ( i == m_doc->numLines() ) break; col = 0; } if ( state == 0 ) { if ( s[col] == '{' ) state = 1; else if ( ! s[col].isSpace() ) break; } else if ( state == 1 ) { if ( s[col] == ',' ) { key = key.stripWhiteSpace(); kdDebug() << "found: " << key << endl; m_bibItems.append(key); emit(foundItem(key, startline + 1, startcol, KileStruct::BibItem, 0, "bibtex", reItem.cap(2).lower())); break; } else { key += s[col]; if (!keystarted) { startcol = col; startline = i; } keystarted=true; } } } } } } } /* * * KileDocInfoDlg : a dialog that displays information known about the current document * * */ KileDocInfoDlg::KileDocInfoDlg(KileDocument::Info *docinfo, QWidget* parent, const char* name, const QString &caption) : KDialogBase(parent,name,true,caption,KDialogBase::Ok, KDialogBase::Ok, true) { QWidget *page = new QWidget( this ); setMainWidget(page); QGridLayout *layout = new QGridLayout( page, 8, 3,5,5,""); const long *list = docinfo->getStatistics(); layout->addWidget(new QLabel(i18n("Characters in words"),page), 0,0); layout->addWidget(new QLabel(QString::number(list[0]), page), 0,2); layout->addWidget(new QLabel(i18n("Characters in LaTeX commands"),page), 1,0); layout->addWidget(new QLabel(QString::number(list[1]), page), 1,2); layout->addWidget(new QLabel(i18n("Whitespace/Delimiters/Punctuation Marks"),page), 2,0); layout->addWidget(new QLabel(QString::number(list[2]), page), 2,2); layout->addWidget(new QLabel(i18n("Total"),page), 3,1, Qt::AlignRight); layout->addWidget(new QLabel(QString::number(list[0]+list[1]+list[2]), page), 3,2); layout->addWidget(new QLabel(i18n("Words"),page), 4,0); layout->addWidget(new QLabel(QString::number(list[3]), page), 4,2); layout->addWidget(new QLabel(i18n("LaTeX commands"),page), 5,0); layout->addWidget(new QLabel(QString::number(list[4]), page), 5,2); layout->addWidget(new QLabel(i18n("Total"),page), 6,1, Qt::AlignRight); layout->addWidget(new QLabel(QString::number(list[3]+list[4]), page), 6,2); if (docinfo->getDoc() && docinfo->getDoc()->hasSelection()) layout->addWidget(new QLabel(i18n("WARNING: These are the statistics for the selected text only."),page), 7,0, Qt::AlignRight); } #include "kiledocumentinfo.moc" Index: trunk/kdeextragear-2/kile/kile/kileactions.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kileactions.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kileactions.cpp (revision 314535) @@ -1,402 +1,402 @@ /*************************************************************************** kileactions.cpp - description ------------------- begin : 2003-07-01 17:33:00 CEST 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 #include #include #include #include #include #include #include #include #include #include #include #include "kileactions.h" namespace KileAction { //////////////// // Tag // //////////////// Tag::Tag( const QString &text, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent , const char *name, const QString &tagBegin, const QString &tagEnd , int dx, int dy, const QString &description) : KAction(text, cut, parent, name), m_data(text,tagBegin, tagEnd, dx, dy, description) { init(receiver,slot); } Tag::Tag( const QString &text, const QString& pix, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent , const char *name, const QString &tagBegin, const QString &tagEnd , int dx, int dy, const QString &description) : KAction(text, pix, cut, parent, name), m_data(text,tagBegin, tagEnd, dx, dy, description) { init(receiver,slot); } Tag::Tag( const QString &text, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent , const char *name, const TagData& data) : KAction(text, cut, parent, name), m_data(data) { init(receiver,slot); } Tag::Tag( const QString &text, const QString& pix, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent , const char *name, const TagData& data) : KAction(text, pix, cut, parent, name), m_data(data) { init(receiver,slot); } Tag::~Tag() { } void Tag::init(const QObject *receiver, const char *slot) { connect(this, SIGNAL(activated()), SLOT(emitData())); connect(this, SIGNAL(activated(const KileAction::TagData&)), receiver, slot); } void Tag::emitData() { emit(activated(m_data)); } //////////////// // InputTag // //////////////// InputTag::InputTag(KileInfo* ki, const QString &text, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const char *name, QWidget *wparent, uint options , const QString &tagBegin, const QString &tagEnd , int dx, int dy, const QString &description, const QString &hint, const QString &alter) : Tag(text, cut, receiver, slot, parent, name, tagBegin, tagEnd, dx, dy, description), m_ki(ki), m_parent(wparent), m_options(options), m_hint(hint), m_alter(alter) { init(); } InputTag::InputTag( KileInfo* ki, const QString &text, const QString& pix, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const char *name, QWidget *wparent,uint options , const QString &tagBegin, const QString &tagEnd , int dx, int dy, const QString &description, const QString &hint, const QString &alter) : Tag(text, pix, cut, receiver, slot, parent, name, tagBegin, tagEnd, dx, dy, description), m_ki(ki), m_parent(wparent), m_options(options), m_hint(hint), m_alter(alter) { init(); } InputTag::InputTag( KileInfo* ki, const QString &text, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const char *name, QWidget *wparent,uint options , const TagData& data, const QString &hint, const QString &alter) : Tag(text,cut,receiver, slot, parent, name,data), m_ki(ki), m_parent(wparent), m_options(options), m_hint(hint), m_alter(alter) { init(); } InputTag::InputTag( KileInfo* ki, const QString &text, const QString& pix, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const char *name, QWidget *wparent,uint options , const TagData& data, const QString &hint, const QString &alter) : Tag(text, pix, cut,receiver, slot, parent, name,data), m_ki(ki), m_parent(wparent), m_options(options), m_hint(hint), m_alter(alter) { init(); } InputTag::~InputTag() { } void InputTag::init() { m_history.clear(); } void InputTag::emitData() { kdDebug() << "InputTag::emitData() " << m_ki->getName() << endl; InputDialog *dlg = new InputDialog(m_data.text, m_options, m_history, m_hint, m_alter, m_ki, m_parent, "input_dialog"); if (dlg->exec()) { kdDebug() << "een" << endl; if ( (! dlg->tag().isEmpty()) && hasHistory()) addToHistory(dlg->tag()); kdDebug() << "twee" << endl; TagData td(m_data); td.tagBegin.replace("%R",dlg->tag()); td.tagEnd.replace("%R",dlg->tag()); kdDebug() << "drie" << endl; QString alt = dlg->useAlternative() ? "*" : ""; td.tagBegin.replace("%A", alt); td.tagEnd.replace("%A", alt); kdDebug() << "vier" << endl; if (dlg->usedSelection()) m_ki->clearSelection(); emit(activated(td)); } delete dlg; } //////////////// // InputFigure // //////////////// InputFigure::InputFigure(KileInfo* ki, const QString &text, const KShortcut &cut, const QObject *receiver, const char *slot, KActionCollection *parent, const char *name, QWidget *wparent,uint options , const QString &tagBegin, const QString &tagEnd, int dx, int dy, const QString &description, const QString &hint, const QString &alter) : InputTag(ki, text, cut, receiver, slot, parent, name, wparent, options, tagBegin, tagEnd, dx, dy, description, hint, alter) { init(); } void InputFigure::emitData() { InputDialog *dlg = new InputDialog(m_data.text, m_options, m_history, m_hint, m_alter, m_ki, m_parent, "input_dialog"); if (dlg->exec()) { // kdDebug() << "een" << endl; if ( (! dlg->tag().isEmpty()) && hasHistory()) addToHistory(dlg->tag()); // kdDebug() << "twee" << endl; TagData td(m_data); td.tagBegin.append(dlg->tag()); if(dlg->Env != NULL) if(dlg->Env->isChecked()) { td.tagBegin.prepend("\\begin{figure}\n \\centering\n "); td.tagEnd.append("\n \\caption{"+dlg->figCaption->text()+"}\n \\label{"+dlg->figLabel->text()+"}\n\\end{figure}" ); td.dx += 3; td.dy += 2; } // kdDebug() << "vier" << endl; emit(activated(td)); } delete dlg; } /* InputDialog */ InputDialog::InputDialog(const QString &caption, uint options, const QStringList& history, const QString& hint, const QString& alter, KileInfo *ki, QWidget *parent, const char *name) : KDialogBase (parent, name, true, caption, KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true), m_ki(ki) { Env = 0L; figLabel = 0L; m_usedSelection = false; QWidget *page = new QWidget(this); setMainWidget(page); QGridLayout *gbox = new QGridLayout( page, 3, 4,5,5,""); QLabel *lb = new QLabel(hint, page); gbox->addMultiCellWidget(lb,0,0,0,3); m_tag=QString::null; QWidget *focus; if ( (options & KileAction::KeepHistory) || (options & KileAction::FromLabelList) || (options & KileAction::FromBibItemList) ) { KComboBox *input = new KComboBox(true, page, "input_dialog_input"); input->setCompletionMode(KGlobalSettings::CompletionAuto); focus = input; connect(input, SIGNAL(textChanged(const QString&)), this, SLOT(setTag(const QString&))); connect(this, SIGNAL(setInput(const QString&)), input, SLOT(setEditText(const QString&))); gbox->addMultiCellWidget(input,1,1,0,2); const QStringList *list; if (options & KileAction::FromLabelList) { - list = ki->labels(); + list = ki->allLabels(); input->insertStringList(*list); m_tag = list->first(); } else if (options & KileAction::FromBibItemList) { - list = ki->bibItems(); + list = ki->allBibItems(); input->insertStringList(*list); m_tag = list->first(); } else { if (history.size()>0) { input->insertStringList(history); m_tag = history.first(); } } } else { KLineEdit *input = new KLineEdit(page); focus = input; connect(input, SIGNAL(textChanged(const QString&)), this, SLOT(setTag(const QString&))); connect(this, SIGNAL(setInput(const QString&)), input, SLOT(setText(const QString&))); gbox->addWidget(input,1,0); input->setText(ki->getSelection()); m_usedSelection=true; } if (focus) lb->setBuddy(focus); if ( options & KileAction::ShowBrowseButton) { KPushButton *pbutton = new KPushButton(i18n("Browse..."),page); connect(pbutton, SIGNAL(clicked()), this, SLOT(slotBrowse())); gbox->addWidget(pbutton,1,3); } if ( options & KileAction::ShowAlternative) { QCheckBox * m_checkbox = new QCheckBox(alter, page, "input_dialog_checkbox"); connect(m_checkbox, SIGNAL(clicked()), this, SLOT(slotAltClicked())); m_useAlternative=false; gbox->addMultiCellWidget(m_checkbox,2,2,0,3); } if ( options & KileAction::ShowFigureInput) { Env = new QCheckBox(page, "" ); Env->setText(i18n("with environment") ); Env->setChecked( false ); gbox->addMultiCellWidget( Env,2,2,0,1,1 ); connect( Env, SIGNAL( clicked() ), this, SLOT( slotEnvClicked() ) ); Text2 = new QLabel(page, "" ); Text2->setText(i18n("Label:") ); gbox->addWidget( Text2,3,0 ); figLabel = new QLineEdit(page, "" ); figLabel->setText(""); gbox->addMultiCellWidget( figLabel,3,3,1,3,0 ); Text3 = new QLabel(page, "" ); Text3->setText(i18n("Caption:") ); gbox->addWidget( Text3,4,0 ); figCaption = new QLineEdit(page, "" ); figCaption->setText(""); gbox->addMultiCellWidget( figCaption,4,4,1,3,0 ); slotEnvClicked(); } focus->setFocus(); } InputDialog::~InputDialog() { } void InputDialog::slotBrowse() { QString fn; QFileInfo fi(m_ki->getName()); fn = KFileDialog::getOpenFileName(fi.absFilePath(), QString::null, this,i18n("Select File") ); if ( !fn.isEmpty() ) { setTag(fn); emit(setInput(fn)); } } void InputDialog::slotAltClicked() { m_useAlternative = !m_useAlternative; } void InputDialog::setTag(const QString &tag) { m_tag = tag; if(figLabel != NULL) { QFileInfo picFile( tag ); if(figLabel->text().isEmpty()) figLabel->setText( "fig:"+picFile.baseName() ); } } void InputDialog::slotEnvClicked() { if (Env->isChecked()) { Text2->setEnabled( true ); Text3->setEnabled( true ); figLabel->setEnabled( true ); figCaption->setEnabled( true ); } else { Text2->setDisabled( true ); Text3->setDisabled( true ); figLabel->setDisabled( true ); figCaption->setDisabled( true ); } } ///////////////// // SelectTag // ///////////////// Select::Select(const QString &text, const KShortcut &cut, KActionCollection *parent, const char *name ) : KSelectAction(text,cut,parent,name) { init(); } void Select::init() { connect(this, SIGNAL(activated(const QString&)), SLOT(emitData(const QString &))); } void Select::emitData(const QString & name) { m_dict[name]->activate(); } void Select::setItems(QPtrList& list) { QStringList tmp; for (uint i=0; i < list.count(); i++) { tmp.append(list.at(i)->text()); m_dict.insert(list.at(i)->text(), list.at(i)); } KSelectAction::setItems(tmp); } } #include "kileactions.moc" Index: trunk/kdeextragear-2/kile/kile/kileinfo.h =================================================================== --- trunk/kdeextragear-2/kile/kile/kileinfo.h (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kileinfo.h (revision 314535) @@ -1,134 +1,152 @@ /*************************************************************************** kileinfointerface.h - description ------------------- begin : Thu Jul 17 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef KILEINFO_H #define KILEINFO_H #include #include #include #include +#include #include #include "kiletoolmanager.h" #include "kilestdtools.h" #include "latexoutputfilter.h" #include "latexoutputinfo.h" class QWidget; class KURL; namespace KileDocument { class Info; } class KileProject; class KileProjectItem; class KileProjectItemList; class KileFileSelect; class KileEventFilter; namespace Kate { class Document;} namespace KileDocument { class Manager; class EditorExtension; } namespace KileView { class Manager; } namespace KileWidget { class Structure; class Konsole; } class KileInfo { public: KileInfo(QWidget *parent); virtual ~KileInfo(); public: QString getName(Kate::Document *doc = 0, bool shrt = false); QString getShortName(Kate::Document *doc = 0) { return getName(doc, true); } QString getCompileName(bool shrt = false); QString getFullFromPrettyName(const QString & name); QString getCurrentTarget() const { return m_currentTarget; } void setTarget(const QString &target) { m_currentTarget=target; } virtual Kate::Document* activeDocument() const; QString getSelection() const; void clearSelection() const; - virtual const QStringList* labels(KileDocument::Info * info = 0) =0; - virtual const QStringList* bibItems(KileDocument::Info * info = 0) =0; - virtual const QStringList* bibliographies(KileDocument::Info * info = 0) = 0; + virtual const QStringList* allLabels(KileDocument::Info * info = 0L); + virtual const QStringList* allBibItems(KileDocument::Info * info = 0L); + virtual const QStringList* allBibliographies(KileDocument::Info * info = 0L); + virtual const QStringList* allDependencies(KileDocument::Info * info = 0L); + virtual const QStringList* allNewCommands(KileDocument::Info * info = 0L); + + QString lastModifiedFile(KileDocument::Info * info = 0L); + +private: + const QStringList* retrieveList(const QStringList* (KileDocument::Info::*getit)() const, KileDocument::Info * docinfo = 0L); + QStringList m_listTemp; +public: bool isOpen(const KURL & url); bool projectIsOpen(const KURL & ); bool watchFile() { return m_bWatchFile; } + bool logPresent() { return m_logPresent; } + void setLogPresent(bool pr) { m_logPresent = pr; } LatexOutputFilter * outputFilter() { return m_outputFilter; } LatexOutputInfoArray * outputInfo() { return m_outputInfo; } virtual int lineNumber() = 0; QString relativePath(const QString basepath, const QString & file); KileWidget::Structure *structureWidget() { return m_kwStructure; } KileWidget::Konsole *texKonsole() { return m_texKonsole; } + KileWidget::Output *outputWidget() { return m_outputWidget; } + QTabWidget *outputView() { return m_outputView; } + KileWidget::LogMsg *logWidget() { return m_logWidget; } KileDocument::Manager* docManager() const { return m_docManager; } KileView::Manager* viewManager() const { return m_viewManager; } KileTool::Manager* toolManager() const { return m_manager; } KileTool::Factory* toolFactory() const { return m_toolFactory; } KileDocument::EditorExtension *editorExtension() const { return m_edit; } //FIXME:refactor KileFileSelect* fileSelector() const { return KileFS; } KileEventFilter* eventFilter() const { return m_eventFilter; } QWidget *parentWidget() const { return m_parentWidget; } //FIXME: should be in separate template class const QString & templAuthor() const { return m_templAuthor; } const QString & templDocClassOpt() const { return m_templDocClassOpt; } const QString & templEncoding() const { return m_templEncoding; } protected: KileDocument::Manager *m_docManager; KileView::Manager *m_viewManager; KileTool::Manager *m_manager; KileTool::Factory *m_toolFactory; KileWidget::Konsole *m_texKonsole; + KileWidget::Output *m_outputWidget; + KileWidget::LogMsg *m_logWidget; + QTabWidget *m_outputView; KileDocument::EditorExtension *m_edit; QWidget *m_parentWidget; bool m_singlemode; QString m_masterName; QString m_currentTarget; - bool m_bWatchFile; + bool m_bWatchFile, m_logPresent; LatexOutputFilter *m_outputFilter; LatexOutputInfoArray *m_outputInfo; KileWidget::Structure *m_kwStructure; KileFileSelect *KileFS; KileEventFilter* m_eventFilter; QString m_templAuthor, m_templDocClassOpt, m_templEncoding; }; #endif Index: trunk/kdeextragear-2/kile/kile/codecompletion.h =================================================================== --- trunk/kdeextragear-2/kile/kile/codecompletion.h (revision 314534) +++ trunk/kdeextragear-2/kile/kile/codecompletion.h (revision 314535) @@ -1,156 +1,160 @@ /*************************************************************************** codecompletion.h ---------------------------------------------------------------------------- date : Jan 24 2004 version : 0.10.3 copyright : (C) 2004 by Holger Danielsson email : holger.danielsson@t-online.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. * * * ***************************************************************************/ #ifndef CODECOMPLETION_H #define CODECOMPLETION_H #include #include #include #include +#define BULLET QString("×") + /** *@author Holger Danielsson */ class QTimer; class KileInfo; namespace KileDocument { //FIXME fix the way the Kate::View is passed, I'm not 100% confident m_view doesn't turn into a wild pointer //FIXME refactor the complete class, it's pretty ugly, there are too many methods with similar names suggesting that the code could be more efficient class CodeCompletion : public QObject { Q_OBJECT public: CodeCompletion(KileInfo *ki); ~CodeCompletion(); enum Mode { cmLatex, cmEnvironment, cmDictionary, cmAbbreviation, cmLabel }; enum Type { ctNone, ctReference, ctCitation }; bool isActive(); bool inProgress(); bool autoComplete(); CodeCompletion::Mode getMode(); CodeCompletion::Type getType(); CodeCompletion::Type getType(const QString &text); KileInfo* info() const { return m_ki;} void readConfig(void); public slots: const QString getBullet(); //in these two methods we should set m_view void slotCharactersInserted(int, int, const QString&); void editComplete(Kate::View *view, KileDocument::CodeCompletion::Mode mode); void slotCompletionDone( ); void slotCompleteValueList(); void slotCompletionAborted(); void slotFilterCompletion(KTextEditor::CompletionEntry* c,QString *s); private: void completeWord(const QString &text, CodeCompletion::Mode mode); QString filterCompletionText(const QString &text, const QString &type); void CompletionDone(); void CompletionAborted(); void completeFromList(const QStringList *list); void editCompleteList(KileDocument::CodeCompletion::Type type); bool getCompleteWord(bool latexmode, QString &text, KileDocument::CodeCompletion::Type &type); bool oddBackslashes(const QString& text, int index); + void appendNewCommands(QValueList & list); + private: // wordlists QValueList m_texlist; QValueList m_dictlist; QValueList m_abbrevlist; QValueList m_labellist; KileInfo *m_ki; QTimer *m_completeTimer; // some flags bool m_isenabled; bool m_setcursor; bool m_setbullets; bool m_closeenv; bool m_autocomplete; // state of complete: some flags bool m_firstconfig; bool m_inprogress; // undo text bool m_undo; // character which is used as bullet QString m_bullet; // special types: ref, bib CodeCompletion::Type m_type; // internal parameter Kate::View *m_view; // View QString m_text; // current pattern uint m_textlen; // length of current pattern CodeCompletion::Mode m_mode; // completion mode uint m_ycursor,m_xcursor,m_xstart; // current cursor position uint m_yoffset,m_xoffset; // offset of the new cursor position QString buildLatexText(const QString &text, uint &ypos, uint &xpos); QString buildEnvironmentText(const QString &text, const QString &type, uint &ypos, uint &xpos); QString buildAbbreviationText(const QString &text); QString buildLabelText(const QString &text); QString parseText(const QString &text, uint &ypos, uint &xpos, bool checkgroup); QString stripParameter(const QString &text); void setWordlist(const QStringList &files,const QString &dir, QValueList *entrylist); void readWordlist(QStringList &wordlist, const QString &filename); void setCompletionEntries(QValueList *list, const QStringList &wordlist); uint countEntries(const QString &pattern, QValueList *list, QString *entry, QString *type); }; } #endif Index: trunk/kdeextragear-2/kile/kile/kiletoolmanager.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kiletoolmanager.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kiletoolmanager.cpp (revision 314535) @@ -1,445 +1,449 @@ /*************************************************************************** kiletoolmanager.cpp - description ------------------- begin : Tue Nov 25 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 #include #include #include #include #include #include #include #include #include #include #include #include "kileinfo.h" #include "kileproject.h" #include "kiletoolmanager.h" #include "kiletool_enums.h" #include "kilestdtools.h" #include "kilelogwidget.h" #include "kileoutputwidget.h" #include "kiledocmanager.h" namespace KileTool { QueueItem::QueueItem(Base *tool, const QString & cfg) : m_tool(tool), m_cfg(cfg) { } QueueItem::~QueueItem() { delete m_tool; } Base* Queue::tool() const { if ( head() ) return head()->tool(); else return 0; } const QString Queue::cfg() const { if ( head() ) return head()->cfg(); else return QString::null; } void Queue::enqueueNext(QueueItem *item) { if ( count() < 2 ) enqueue(item); else { QueueItem *headitem = dequeue(); Queue *oldqueue = new Queue(*this); setAutoDelete(false); clear(); kdDebug() << "\tenqueueing: " << headitem->tool()->name() << endl; enqueue(headitem); kdDebug() << "\tenqueueing: " << item->tool()->name() << endl; enqueue(item); while ( oldqueue->head() ) { kdDebug() << "\tenqueueing: " << oldqueue->head()->tool()->name() << endl; enqueue(oldqueue->dequeue()); } } } Manager::Manager(KileInfo *ki, KConfig *config, KileWidget::LogMsg *log, KileWidget::Output *output, KParts::PartManager *manager, QWidgetStack *stack, KAction *stop, uint to) : m_ki(ki), m_config(config), m_log(log), m_output(output), m_pm(manager), m_stack(stack), m_stop(stop), m_bClear(true), m_nTimeout(to) { m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(enableClear())); connect(stop, SIGNAL(activated()), this, SLOT(stop())); } Manager::~Manager() { } void Manager::enableClear() { m_bClear = true; } bool Manager::queryContinue(const QString & question, const QString & caption /*= QString::null*/) { return (KMessageBox::warningContinueCancel(m_stack, question, caption) == KMessageBox::Continue); } int Manager::run(const QString &tool, const QString & cfg, bool insertNext /*= false*/) { if (!m_factory) { m_log->printMsg(Error, i18n("No factory installed, contact the author of Kile.")); return ConfigureFailed; } Base* pTool = m_factory->create(tool); if (!pTool) { m_log->printMsg(Error, i18n("Unknown tool %1.").arg(tool)); return ConfigureFailed; } return run(pTool, cfg, insertNext); } int Manager::run(Base *tool, const QString & cfg, bool insertNext /*= false*/) { kdDebug() << "==KileTool::Manager::run(Base*)============" << endl; if (m_bClear) { m_log->clear(); + m_ki->setLogPresent(false); m_output->clear(); } //FIXME: shouldn't restart timer if a Sequence command takes longer than the 10 secs //restart timer, so we only clear the logs if a tool is started after 10 sec. m_bClear=false; m_timer->start(m_nTimeout); if ( insertNext ) m_queue.enqueueNext(new QueueItem(tool, cfg)); else m_queue.enqueue(new QueueItem(tool, cfg)); kdDebug() << "\tin queue: " << m_queue.count() << endl; if ( m_queue.count() == 1 ) return runNextInQueue(); else if ( m_queue.count() > 1 ) return Running; else return ConfigureFailed; } int Manager::runNextInQueue() { Base *head = m_queue.tool(); if (head) { if (m_log->lines() > 1) m_log->append("\n"); int status; if ( (status=head->run()) != Running ) //tool did not even start, clear queue { stop(); m_queue.setAutoDelete(true); m_queue.clear(); m_queue.setAutoDelete(false); return status; } + + emit(toolStarted()); + return Running; } return ConfigureFailed; } void Manager::initTool(Base *tool) { tool->setInfo(m_ki); tool->setConfig(m_config); connect(tool, SIGNAL(message(int, const QString &, const QString &)), m_log, SLOT(printMsg(int, const QString &, const QString &))); connect(tool, SIGNAL(output(const QString &)), m_output, SLOT(receive(const QString &))); connect(tool, SIGNAL(done(Base*,int)), this, SLOT(done(Base*, int))); connect(tool, SIGNAL(start(Base* )), this, SLOT(started(Base*))); connect(tool, SIGNAL(requestSaveAll()), this, SIGNAL(requestSaveAll())); } void Manager::started(Base *tool) { kdDebug() << "STARTING tool: " << tool->name() << endl; m_stop->setEnabled(true); if (tool->isViewer()) { if ( tool == m_queue.tool() ) m_queue.dequeue(); m_stop->setEnabled(false); runNextInQueue(); } } void Manager::stop() { m_stop->setEnabled(false); if ( m_queue.tool() ) m_queue.tool()->stop(); } void Manager::done(Base *tool, int result) { m_stop->setEnabled(false); if ( tool != m_queue.tool() ) //oops, tool finished async, could happen with view tools { delete tool; return; } delete m_queue.dequeue(); if ( result == Aborted) tool->sendMessage(Error, i18n("Aborted")); if ( result != Success && result != Silent ) //abort execution, delete all remaing tools { m_queue.setAutoDelete(true); m_queue.clear(); m_queue.setAutoDelete(false); } else //continue runNextInQueue(); } QString Manager::currentGroup(const QString &name, bool usequeue) { KileProject *project = m_ki->docManager()->activeProject(); if (project) { QString cfg = configName(name, dynamic_cast(project->config())); if ( cfg.length() > 0 ) return groupFor(name, cfg); } if (usequeue && m_queue.tool() && (m_queue.tool()->name() == name) && (m_queue.cfg() != QString::null) ) return groupFor(name, m_queue.cfg()); else return groupFor(name, m_config); } bool Manager::retrieveEntryMap(const QString & name, Config & map, bool usequeue, bool useproject) { QString group = currentGroup(name, usequeue); kdDebug() << "==KileTool::Manager::retrieveEntryMap=============" << endl; kdDebug() << "\t" << name << " => " << group << endl; if ( m_config->hasGroup(group) ) { map = m_config->entryMap(group); //use project overrides KileProject *project = m_ki->docManager()->activeProject(); if ( useproject && project) { KConfig *prjcfg = dynamic_cast(project->config()); if ( prjcfg ) { QString grp = groupFor(name, prjcfg); Config prjmap = prjcfg->entryMap(grp); for (Config::Iterator it = prjmap.begin(); it != prjmap.end(); ++it) { map[it.key()] = it.data(); } } } } else return false; return true; } void Manager::saveEntryMap(const QString & name, Config & map, bool usequeue) { kdDebug() << "==KileTool::Manager::saveEntryMap=============" << endl; QString group = currentGroup(name, usequeue); kdDebug() << "\t" << name << " => " << group << endl; m_config->setGroup(group); Config::Iterator it; for ( it = map.begin() ; it != map.end(); it ++) { m_config->writeEntry(it.key(), it.data()); } } bool Manager::configure(Base *tool) { kdDebug() << "==KileTool::Manager::configure()===============" << endl; //configure the tool Config map; if ( ! retrieveEntryMap(tool->name(), map) ) { m_log->printMsg(Error, i18n("Can't find the tool %1 in the configuration database.").arg(tool->name())); return false; } tool->setEntryMap(map); return true; } void Manager::wantGUIState(const QString & state) { kdDebug() << "REQUESTED state: " << state << endl; emit(requestGUIState(state)); } QStringList toolList(KConfig *config, bool menuOnly) { kdDebug() << "==KileTool::toolList()==================" << endl; QStringList groups = config->groupList(), tools; QRegExp re = QRegExp("Tool/(.+)/.+"); for ( uint i = 0; i < groups.count(); i++ ) { if ( re.exactMatch(groups[i]) ) { if ( ! groups[i].endsWith(configName(re.cap(1), config)) ) continue; if ( (! menuOnly) || ( menuFor(re.cap(1),config) != "none" ) ) { tools.append(re.cap(1)); } } } tools.sort(); return tools; } QString configName(const QString & tool, KConfig *config) { config->setGroup("Tools"); return config->readEntry(tool, ""); } void setConfigName(const QString & tool, const QString & name, KConfig *config) { kdDebug() << "==KileTool::Manager::setConfigName(" << tool << "," << name << ")===============" << endl; config->setGroup("Tools"); config->writeEntry(tool, name); } QString groupFor(const QString &tool, KConfig *config) { return groupFor(tool, configName(tool, config)); } QString groupFor(const QString & tool, const QString & cfg /* = Default */ ) { return "Tool/" + tool + "/" + cfg; } void extract(const QString &str, QString &tool, QString &cfg) { static QRegExp re("(.*)\\((.*)\\)"); QString lcl = str; lcl.stripWhiteSpace(); cfg = QString::null; if ( re.exactMatch(lcl) ) { tool = re.cap(1).stripWhiteSpace(); cfg = re.cap(2).stripWhiteSpace(); } else tool = lcl; } QString format(const QString & tool, const QString &cfg) { if (cfg != QString::null) return tool+"("+cfg+")"; else return tool; } QStringList configNames(const QString &tool, KConfig *config) { QStringList groups = config->groupList(), configs; QRegExp re = QRegExp("Tool/"+ tool +"/(.+)"); for ( uint i = 0; i < groups.count(); i++ ) { if ( re.exactMatch(groups[i]) ) { configs.append(re.cap(1)); } } return configs; } QString menuFor(const QString &tool, KConfig *config) { config->setGroup("ToolsGUI"); return config->readEntry(tool, "Other,gear").section(',',0,0); } QString iconFor(const QString &tool, KConfig *config) { config->setGroup("ToolsGUI"); return config->readEntry(tool, "Other,gear").section(',',1,1); } void setGUIOptions(const QString &tool, const QString &menu, const QString &icon, KConfig *config) { QString entry = menu + "," + icon; config->setGroup("ToolsGUI"); config->writeEntry(tool, entry); } QString categoryFor(const QString &clss) { if ( clss == "Compile" || clss == "LaTeX" ) return "Compile"; if ( clss == "Convert" ) return "Convert"; if ( clss == "View" || clss == "ViewBib" || clss == "ViewHTML" || clss == "ForwardDVI" ) return "View"; if ( clss == "Sequence" ) return "Sequence"; return "Base"; } } #include "kiletoolmanager.moc" Index: trunk/kdeextragear-2/kile/kile/kilestdtools.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kilestdtools.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kilestdtools.cpp (revision 314535) @@ -1,337 +1,337 @@ /*************************************************************************** kilestdtools.cpp - description ------------------- begin : Thu Nov 27 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 #include #include #include #include #include #include "kiletool.h" #include "kiletoolmanager.h" #include "kiletool_enums.h" #include "kilestdtools.h" #include "kileinfo.h" #include "kilelistselector.h" #include "kiledocmanager.h" #include "kiledocumentinfo.h" #include "latexoutputinfo.h" namespace KileTool { Base* Factory::create(const QString & tool) { //perhaps we can find the tool in the config file if (m_config->hasGroup(groupFor(tool, m_config))) { m_config->setGroup(groupFor(tool, m_config)); QString toolClass = m_config->readEntry("class", ""); if ( toolClass == "LaTeX") return new LaTeX(tool, m_manager); if ( toolClass == "ForwardDVI" ) return new ForwardDVI(tool, m_manager); if ( toolClass == "ViewHTML" ) return new ViewHTML(tool, m_manager); if ( toolClass == "ViewBib" ) return new ViewBib(tool, m_manager); if ( toolClass == "Base" ) return new Base(tool, m_manager); if ( toolClass == "Compile" ) return new Compile(tool, m_manager); if ( toolClass == "Convert" ) return new Convert(tool, m_manager); if ( toolClass == "View" ) return new View(tool, m_manager); if ( toolClass == "Sequence" ) return new Sequence(tool, m_manager); } //unknown tool, return 0 return 0L; } void Factory::writeStdConfig() { QString from_cfg = KGlobal::dirs()->findResource("appdata", "kilestdtools.rc"); QString to_cfg = KGlobal::dirs()->saveLocation("config") + "/kilerc"; KConfig *pCfg = new KConfig(from_cfg, false, false); //FIXME: use copyTo //pCfg->copyTo(to_cfg, m_config); QStringList groups = pCfg->groupList(); for(QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it) { QMap map = pCfg->entryMap(*it); m_config->setGroup(*it); for (QMap::Iterator it2 = map.begin(); it2 != map.end(); ++it2) { m_config->writeEntry(it2.key(), it2.data()); } } } int LaTeX::m_reRun = 0; bool LaTeX::updateBibs() { - KileDocument::Info *info = manager()->info()->docManager()->infoFor(source()); - if ( info ) + KileDocument::Info *docinfo = manager()->info()->docManager()->infoFor(source()); + if ( docinfo ) { - if ( info->bibliographies()->count() > 0 ) - return needsUpdate ( baseDir() + "/" + S() + ".bbl" , info->lastModifiedFile() ); + if ( manager()->info()->allBibliographies()->count() > 0 ) + return needsUpdate ( baseDir() + "/" + S() + ".bbl" , manager()->info()->lastModifiedFile(docinfo) ); } return false; } bool LaTeX::updateIndex() { - KileDocument::Info *info = manager()->info()->docManager()->infoFor(source()); - if ( info ) + KileDocument::Info *docinfo = manager()->info()->docManager()->infoFor(source()); + if ( docinfo ) { - const QStringList *pckgs = info->packages(); + const QStringList *pckgs = docinfo->packages(); for ( uint i = 0; i < pckgs->count(); i++) if ( (*pckgs->at(i)) == "makeidx" ) - return needsUpdate ( baseDir() + "/" + S() + ".ind", info->lastModifiedFile() ); + return needsUpdate ( baseDir() + "/" + S() + ".ind", manager()->info()->lastModifiedFile(docinfo) ); } return false; } bool LaTeX::finish(int r) { kdDebug() << "==bool LaTeX::finish(" << r << ")=====" << endl; manager()->info()->outputFilter()->setSource(source()); QString log = baseDir() + "/" + S() + ".log"; //manager()->info()->outputFilter()->Run( "/home/wijnhout/test.log" ); int nErrors = 0, nWarnings = 0, nBadBoxes = 0; if ( manager()->info()->outputFilter()->Run(log) ) { manager()->info()->outputFilter()->getErrorCount(&nErrors, &nWarnings, &nBadBoxes); QString es = i18n("%n error", "%n errors", nErrors); QString ws = i18n("%n warning", "%n warnings", nWarnings); QString bs = i18n("%n badbox", "%n badboxes", nBadBoxes); sendMessage(Info, es +", " + ws + ", " + bs); //jump to first error if ( nErrors > 0 && (readEntry("jumpToFirstError") == "yes") ) { connect(this, SIGNAL(jumpToFirstError()), manager(), SIGNAL(jumpToFirstError())); emit(jumpToFirstError()); } } if ( readEntry("autoRun") == "yes" ) { //check for "rerun LaTeX" warnings bool reRan = false; if ( (m_reRun < 3) && (nErrors == 0) && (nWarnings > 0) ) { int sz = manager()->info()->outputInfo()->size(); for (int i = 0; i < sz; i++ ) { if ( (*manager()->info()->outputInfo())[i].type() == LatexOutputInfo::itmWarning && (*manager()->info()->outputInfo())[i].message().contains("Rerun") ) { reRan = true; break; } } } if ( reRan ) m_reRun++; else m_reRun = 0; bool bibs = updateBibs(); bool index = updateIndex(); if ( reRan ) { kdDebug() << "\trerunning LaTeX " << m_reRun << endl; Base *tool = manager()->factory()->create(name()); tool->setSource(source()); manager()->runNext(tool); } if ( bibs || index ) { Base *tool = manager()->factory()->create(name()); tool->setSource(source()); manager()->runNext(tool); if ( bibs ) { kdDebug() << "\tneed to run BibTeX" << endl; tool = manager()->factory()->create("BibTeX"); tool->setSource(source()); manager()->runNext(tool); } if ( index ) { tool = manager()->factory()->create("MakeIndex"); tool->setSource(source()); manager()->runNext(tool); } } } return Compile::finish(r); } bool ForwardDVI::determineTarget() { if (!View::determineTarget()) return false; int para = manager()->info()->lineNumber(); Kate::Document *doc = manager()->info()->activeDocument(); QString filepath; if (doc) filepath = doc->url().path(); else return false; QString texfile = manager()->info()->relativePath(baseDir(),filepath); m_urlstr = "file:"+targetDir()+"/"+target()+"#src:"+QString::number(para+1)+texfile; addDict("%dir_target", QString::null); addDict("%target", m_urlstr); kdDebug() << "==KileTool::ForwardDVI::determineTarget()=============\n" << endl; kdDebug() << "\tusing " << m_urlstr << endl; return true; } bool ViewBib::determineSource() { if (!View::determineSource()) return false; QString path = source(true); //get the bibliographies for this source - const QStringList *bibs = manager()->info()->bibliographies(manager()->info()->docManager()->infoFor(path)); + const QStringList *bibs = manager()->info()->allBibliographies(manager()->info()->docManager()->infoFor(path)); if (bibs->count() > 0) { QString bib = bibs->front(); if (bibs->count() > 1) { //show dialog KileListSelector *dlg = new KileListSelector(*bibs, i18n("Select a bibliography"),i18n("Select a bibliography")); if (dlg->exec()) { bib = (*bibs)[dlg->currentItem()]; kdDebug() << "Bibliography selected : " << bib << endl; } else { sendMessage(Warning, i18n("No bibliography selected.")); return false; } delete dlg; } QFileInfo info(path); setSource(info.dirPath()+"/"+bib+".bib"); } else { sendMessage(Error, i18n("No bibliographies found.")); return false; } return true; } bool ViewHTML::determineTarget() { if (target() == QString::null) { //setRelativeBaseDir(S()); QString dir = readEntry("relDir"); QString trg = readEntry("target"); if ( dir != "") { translate(dir); setRelativeBaseDir(dir); } if ( trg != "" ) { translate(trg); setTarget(trg); } //auto-detect the file to view if ( dir == "" && trg == "" ) { QFileInfo file1 = QFileInfo(baseDir() + "/" + S() + "/index.html"); QFileInfo file2 = QFileInfo(baseDir() + "/" + S() + ".html"); bool read1 = file1.isReadable(); bool read2 = file2.isReadable(); if ( !read1 && !read2 ) { sendMessage(Error, i18n("Unable to find %1 or %2; if you are trying to view some other HTML file, go to Settings->Configure Kile->Tools->ViewHTML->Advanced.").arg(file1.absFilePath()).arg(file2.absFilePath())); return false; } //both exist, take most recent if ( read1 && read2 ) { read1 = file1.lastModified() > file2.lastModified(); read2 = !read1; } if ( read1 ) { dir = S(); trg = "index.html"; translate(dir); setRelativeBaseDir(dir); translate(trg); setTarget(trg); } } } return View::determineTarget(); } } #include "kilestdtools.moc" Index: trunk/kdeextragear-2/kile/kile/kilelogwidget.cpp =================================================================== --- trunk/kdeextragear-2/kile/kile/kilelogwidget.cpp (revision 314534) +++ trunk/kdeextragear-2/kile/kile/kilelogwidget.cpp (revision 314535) @@ -1,161 +1,161 @@ /*************************************************************************** kilelogwidget.cpp - description ------------------- begin : Sat Dec 20 2003 copyright : (C) 2003 by Jeroen Wijnhout email : Jeroen.Wijnhout@kdemail.net ***************************************************************************/ /*************************************************************************** * * * 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 "kiletool_enums.h" #include "kilelogwidget.h" #include "kileinfo.h" #include #include #include #include namespace KileWidget { LogMsg::LogMsg(KileInfo *info, QWidget *parent, const char *name ) : KTextEdit(parent,name), m_info(info) { setTabStopWidth(10); connect(this, SIGNAL(clicked(int, int)), this, SLOT(slotClicked(int, int))); } LogMsg::~LogMsg(){ } void LogMsg::highlight() { blockSignals(true); // block signals to avoid recursion setUpdatesEnabled(false); int cursorParagraph, cursorIndex; getCursorPosition( &cursorParagraph, &cursorIndex ); int line=0; for(uint i = 0 ; i < m_info->outputInfo()->size() ; i++ ) { line = (*m_info->outputInfo())[i].outputLine(); setSelection( line,0, line,paragraphLength(line) ); switch ( (*m_info->outputInfo())[i].type() ) { case LatexOutputInfo::itmError : setColor(QColor(0xCC, 0x00, 0x00)); break; case LatexOutputInfo::itmWarning : setColor(QColor(0x00, 0x00, 0xCC )); break; case LatexOutputInfo::itmBadBox : setColor(QColor(0x00, 0x80, 0x00)); break; default : break; } removeSelection(); } setCursorPosition( cursorParagraph, cursorIndex ); setUpdatesEnabled(true); blockSignals(false); // block signals to avoid recursion } void LogMsg::highlight(uint l, int direction /* = 1 */) { setCursorPosition(l + direction * 3 , 0); setSelection(l, 0, l, paragraphLength(l)); } void LogMsg::highlight(const QString & begin, int direction /* = 1 */) { kdDebug() << "==void LogMsg::highlight(" << begin << ", int direction /* = 1 */)========" << endl; int parags = paragraphs(); - for ( int i = 0; i < parags; i++ ) + for ( int i = parags - 1; i >= 0; i-- ) { kdDebug() << "considering : " << text(i) << endl; if ( text(i).startsWith(begin) ) { highlight(i, direction); break; } } } void LogMsg::slotClicked(int parag, int /*index*/) { int l = -1; QString s = text(parag), file = QString::null; static QRegExp reES = QRegExp("(^.*):([0-9]+):.*"); //maybe there is an error summary if ( reES.search(s) != -1 ) { l = reES.cap(2).toInt() - 1; file = reES.cap(1); } else { //look for error at line parag for (uint i=0; i< m_info->outputInfo()->size(); i++) { if ( (*m_info->outputInfo())[i].outputLine() == parag) { file = (*m_info->outputInfo())[i].source(); l = (*m_info->outputInfo())[i].sourceLine() - 1; break; } } } file = m_info->getFullFromPrettyName(file); if ( file != QString::null ) { emit(fileOpen(KURL::fromPathOrURL(file), QString::null)); if ( l >= 0 ) emit(setLine(QString::number(l))); } } void LogMsg::printMsg(int type, const QString & message, const QString &tool) { QString ot = "", ct = ""; switch (type) { case KileTool::Warning : ot = ""; ct = ""; break; case KileTool::Error : ot = ""; ct = ""; break; default : ot = ""; ct = ""; break; } if ( tool == QString::null) append(ot + message + ct); else append(ot + "[" + tool + "] " + message + ct ); scrollToBottom(); } void LogMsg::printProblem(int type, const QString & problem) { kdDebug() << "==KileWidget::LogMsg::printProblem===========" << endl; kdDebug() << "\t" << problem << endl; printMsg(type, problem, QString::null); } } #include "kilelogwidget.moc" Index: trunk/kdeextragear-2/kile/TODO =================================================================== --- trunk/kdeextragear-2/kile/TODO (revision 314534) +++ trunk/kdeextragear-2/kile/TODO (revision 314535) @@ -1,42 +1,45 @@ TODO - add more, improving existing wizards - + + - allow users to set environment variables + - allow users to set a preferred shell + - improving template support - finishing the ASCII <-> encoding converters (convert accented letters into TeX sequences) - create a plain text importer (one that would convert % to \%, $ to \$ etc.) - make a configuration tester, a tool that tests the TeX system, configures the build tools accordingly and makes suggestion if error are encountered - start using the KConfig XT, clean up the current config mess - create a fast powerful (La)TeX parser - need a project manager class, too much of the code is in KileInfo and Kile - probably need a doc manager as well - get rid of the KMultiVertTab code, should be done using standard KDE widgets - use KDirWatch to check for modified files on disk - version control for the kilerc file, now users have to delete the old kilerc file when they upgrade to a new version - inherit QListView for the structureview (current code is very inefficient)  - recursive sectioning: also parse sections that were inserted with    \input or \include (optional)  - Save As: When you do a "save as" for the first time, the directory should    be changed to the one visible in the file_selector.  - file_selector could use a configurable filter. Now only *.tex files are    shown,  some people might use a .ltx extension for their LaTeX files (or   something  completely different).  - It would be nice if the postscript/dvi/pdf files are automatically update    when they are "outdated", similar to the way "make" works.