Kate
katedocument.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001-2004 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> 00004 Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de> 00005 Copyright (C) 2006 Hamish Rodda <rodda@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License version 2 as published by the Free Software Foundation. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef _KATE_DOCUMENT_H_ 00023 #define _KATE_DOCUMENT_H_ 00024 00025 #include <QtCore/QLinkedList> 00026 #include <QtCore/QMap> 00027 #include <QtCore/QDate> 00028 #include <QtGui/QClipboard> 00029 #include <QtCore/QStack> 00030 00031 #include <kmimetype.h> 00032 #include <kencodingprober.h> 00033 00034 #include <ktexteditor/document.h> 00035 #include <ktexteditor/sessionconfiginterface.h> 00036 #include <ktexteditor/searchinterface.h> 00037 #include <ktexteditor/markinterface.h> 00038 #include <ktexteditor/variableinterface.h> 00039 #include <ktexteditor/modificationinterface.h> 00040 #include <ktexteditor/configinterface.h> 00041 #include <ktexteditor/annotationinterface.h> 00042 #include <ktexteditor/highlightinterface.h> 00043 #include <ktexteditor/movinginterface.h> 00044 #include <ktexteditor/recoveryinterface.h> 00045 00046 #include "katepartprivate_export.h" 00047 #include "katetextline.h" 00048 #include "katetextcursor.h" 00049 #include "katetextrange.h" 00050 00051 namespace KTextEditor { 00052 class Plugin; 00053 class Attribute; 00054 class TemplateScript; 00055 } 00056 00057 namespace KIO { class TransferJob; } 00058 00059 namespace Kate { class SwapFile; } 00060 00061 class KateCodeFoldingTree; 00062 class KateBuffer; 00063 class KateView; 00064 class KateLineInfo; 00065 class KateDocumentConfig; 00066 class KateHighlighting; 00067 class KateUndoManager; 00068 class KateOnTheFlyChecker; 00069 00070 class KateAutoIndent; 00071 00072 // 00073 // Kate KTextEditor::Document class (and even KTextEditor::Editor ;) 00074 // 00075 class KATEPART_TESTS_EXPORT KateDocument : public KTextEditor::Document, 00076 public KTextEditor::SessionConfigInterface, 00077 public KTextEditor::ParameterizedSessionConfigInterface, 00078 public KTextEditor::SearchInterface, 00079 public KTextEditor::MarkInterface, 00080 public KTextEditor::VariableInterface, 00081 public KTextEditor::ModificationInterface, 00082 public KTextEditor::ConfigInterface, 00083 public KTextEditor::AnnotationInterface, 00084 public KTextEditor::HighlightInterface, 00085 public KTextEditor::MovingInterface, 00086 public KTextEditor::RecoveryInterface, 00087 private KTextEditor::MovingRangeFeedback 00088 { 00089 Q_OBJECT 00090 Q_INTERFACES(KTextEditor::SessionConfigInterface) 00091 Q_INTERFACES(KTextEditor::ParameterizedSessionConfigInterface) 00092 Q_INTERFACES(KTextEditor::SearchInterface) 00093 Q_INTERFACES(KTextEditor::MarkInterface) 00094 Q_INTERFACES(KTextEditor::VariableInterface) 00095 Q_INTERFACES(KTextEditor::ModificationInterface) 00096 Q_INTERFACES(KTextEditor::AnnotationInterface) 00097 Q_INTERFACES(KTextEditor::ConfigInterface) 00098 Q_INTERFACES(KTextEditor::HighlightInterface) 00099 Q_INTERFACES(KTextEditor::MovingInterface) 00100 Q_INTERFACES(KTextEditor::RecoveryInterface) 00101 00102 public: 00103 explicit KateDocument (bool bSingleViewMode=false, bool bBrowserView=false, bool bReadOnly=false, 00104 QWidget *parentWidget = 0, QObject * = 0); 00105 ~KateDocument (); 00106 00107 using ReadWritePart::closeUrl; 00108 virtual bool closeUrl(); 00109 00110 virtual KTextEditor::Editor *editor (); 00111 00112 KTextEditor::Range rangeOnLine(KTextEditor::Range range, int line) const; 00113 00114 /* 00115 * Overload this to have on-demand view creation 00116 */ 00117 public: 00121 virtual QWidget *widget(); 00122 00123 public: 00124 bool readOnly () const { return m_bReadOnly; } 00125 bool browserView () const { return m_bBrowserView; } 00126 bool singleViewMode () const { return m_bSingleViewMode; } 00127 static bool simpleMode (); 00128 00129 private: 00130 // only to make part work, don't change it ! 00131 const bool m_bSingleViewMode; 00132 const bool m_bBrowserView; 00133 const bool m_bReadOnly; 00134 00135 // 00136 // KTextEditor::Document stuff 00137 // 00138 public: 00139 virtual KTextEditor::View *createView( QWidget *parent ); 00140 virtual const QList<KTextEditor::View*> &views () const; 00141 00142 virtual KTextEditor::View* activeView() const { return m_activeView; } 00143 // Invalid covariant returns my a$$... for some reason gcc won't let me return a KateView above! 00144 KateView* activeKateView() const; 00145 00146 private: 00147 QLinkedList<KateView*> m_views; 00148 QList<KTextEditor::View*> m_textEditViews; 00149 KTextEditor::View *m_activeView; 00150 00151 // 00152 // KTextEditor::EditInterface stuff 00153 // 00154 public Q_SLOTS: 00155 virtual bool setText(const QString &); 00156 virtual bool setText(const QStringList& text); 00157 virtual bool clear (); 00158 00159 virtual bool insertText ( const KTextEditor::Cursor &position, const QString &s, bool block = false ); 00160 virtual bool insertText ( const KTextEditor::Cursor &position, const QStringList &text, bool block = false ); 00161 00162 virtual bool insertLine ( int line, const QString &s ); 00163 virtual bool insertLines ( int line, const QStringList &s ); 00164 00165 virtual bool removeText ( const KTextEditor::Range &range, bool block = false ); 00166 virtual bool removeLine ( int line ); 00167 00168 virtual bool replaceText ( const KTextEditor::Range &range, const QString &s, bool block = false ); 00169 00170 // unhide method... 00171 virtual bool replaceText (const KTextEditor::Range &r, const QStringList &l, bool b) 00172 { return KTextEditor::Document::replaceText (r, l, b); } 00173 00174 public: 00175 virtual QString text ( const KTextEditor::Range &range, bool blockwise = false ) const; 00176 virtual QStringList textLines ( const KTextEditor::Range& range, bool block = false ) const; 00177 virtual QString text() const; 00178 virtual QString line(int line) const; 00179 virtual QChar character(const KTextEditor::Cursor& position) const; 00180 virtual int lines() const; 00181 virtual KTextEditor::Cursor documentEnd() const; 00182 int numVisLines() const; 00183 virtual int totalCharacters() const; 00184 virtual int lineLength(int line) const; 00185 00186 Q_SIGNALS: 00187 void charactersSemiInteractivelyInserted(const KTextEditor::Cursor& position, const QString& text); 00188 00189 public: 00190 //BEGIN editStart/editEnd (start, end, undo, cursor update, view update) 00195 void editStart (); 00196 00200 void editBegin () { editStart(); } 00201 00206 void editEnd (); 00207 00208 void pushEditState(); 00209 void popEditState(); 00210 00211 virtual bool startEditing () { editStart (); return true; } 00212 virtual bool endEditing () { editEnd (); return true; } 00213 00214 //END editStart/editEnd 00215 00216 void inputMethodStart(); 00217 void inputMethodEnd(); 00218 00219 //BEGIN LINE BASED INSERT/REMOVE STUFF (editStart() and editEnd() included) 00227 bool editInsertText ( int line, int col, const QString &s ); 00235 bool editRemoveText ( int line, int col, int len ); 00236 00245 bool editMarkLineAutoWrapped ( int line, bool autowrapped ); 00246 00257 bool editWrapLine ( int line, int col, bool newLine = true, bool *newLineAdded = 0 ); 00265 bool editUnWrapLine ( int line, bool removeLine = true, int length = 0 ); 00266 00273 bool editInsertLine ( int line, const QString &s ); 00279 bool editRemoveLine ( int line ); 00280 00281 bool editRemoveLines ( int from, int to ); 00282 00289 bool wrapText (int startLine, int endLine); 00290 //END LINE BASED INSERT/REMOVE STUFF 00291 00292 Q_SIGNALS: 00296 void editLineWrapped ( int line, int col, int len ); 00297 00301 void editLineUnWrapped ( int line, int col ); 00302 00303 public: 00304 bool isEditRunning() const; 00305 00306 void setUndoMergeAllEdits(bool merge); 00307 00308 private: 00309 int editSessionNumber; 00310 QStack<int> editStateStack; 00311 bool editIsRunning; 00312 00313 // 00314 // KTextEditor::UndoInterface stuff 00315 // 00316 public Q_SLOTS: 00317 void undo (); 00318 void redo (); 00319 00320 public: 00321 uint undoCount () const; 00322 uint redoCount () const; 00323 00324 protected: 00325 KateUndoManager* const m_undoManager; 00326 00327 Q_SIGNALS: 00328 void undoChanged (); 00329 00330 // 00331 // KTextEditor::SearchInterface stuff 00332 // 00333 public: 00334 virtual QVector<KTextEditor::Range> searchText( 00335 const KTextEditor::Range & range, 00336 const QString & pattern, 00337 const KTextEditor::Search::SearchOptions options); 00338 00339 virtual KTextEditor::Search::SearchOptions supportedSearchOptions() const; 00340 00341 private: 00345 QWidget * dialogParent(); 00346 00347 /* 00348 * Access to the mode/highlighting subsystem 00349 */ 00350 public: 00356 virtual QString mode() const; 00357 00363 virtual QString highlightingMode() const; 00364 00369 virtual QStringList modes() const; 00370 00375 virtual QStringList highlightingModes() const; 00376 00382 virtual bool setMode(const QString &name); 00383 00389 virtual bool setHighlightingMode(const QString &name); 00396 virtual QString highlightingModeSection( int index ) const; 00397 00404 virtual QString modeSection( int index ) const; 00405 00406 /* 00407 * Helpers.... 00408 */ 00409 public: 00410 void bufferHlChanged(); 00411 00416 void setDontChangeHlOnSave(); 00417 00421 void bomSetByUser(); 00422 00423 // 00424 // KTextEditor::SessionConfigInterface and KTextEditor::ParameterizedSessionConfigInterface stuff 00425 // 00426 public: 00427 virtual void readSessionConfig (const KConfigGroup&); 00428 virtual void writeSessionConfig (KConfigGroup&); 00429 virtual void readParameterizedSessionConfig (const KConfigGroup&, unsigned long configParameters); 00430 virtual void writeParameterizedSessionConfig (KConfigGroup&, unsigned long configParameters); 00431 00432 Q_SIGNALS: 00433 void configChanged(); 00434 00435 // 00436 // KTextEditor::MarkInterface 00437 // 00438 public Q_SLOTS: 00439 virtual void setMark( int line, uint markType ); 00440 virtual void clearMark( int line ); 00441 00442 virtual void addMark( int line, uint markType ); 00443 virtual void removeMark( int line, uint markType ); 00444 00445 virtual void clearMarks(); 00446 00447 void requestMarkTooltip( int line, QPoint position ); 00448 00450 bool handleMarkClick( int line ); 00451 00453 bool handleMarkContextMenu( int line, QPoint position ); 00454 00455 virtual void setMarkPixmap( MarkInterface::MarkTypes, const QPixmap& ); 00456 00457 virtual void setMarkDescription( MarkInterface::MarkTypes, const QString& ); 00458 00459 virtual void setEditableMarks( uint markMask ); 00460 00461 public: 00462 virtual uint mark( int line ); 00463 virtual const QHash<int, KTextEditor::Mark*> &marks (); 00464 virtual QPixmap markPixmap( MarkInterface::MarkTypes ) const; 00465 virtual QString markDescription( MarkInterface::MarkTypes ) const; 00466 virtual QColor markColor( MarkInterface::MarkTypes ) const; 00467 virtual uint editableMarks() const; 00468 00469 Q_SIGNALS: 00470 void markToolTipRequested( KTextEditor::Document* document, KTextEditor::Mark mark, QPoint position, bool& handled ); 00471 00472 void markContextMenuRequested( KTextEditor::Document* document, KTextEditor::Mark mark, QPoint pos, bool& handled ); 00473 00474 void markClicked( KTextEditor::Document* document, KTextEditor::Mark mark, bool& handled ); 00475 00476 void marksChanged( KTextEditor::Document* ); 00477 void markChanged( KTextEditor::Document*, KTextEditor::Mark, KTextEditor::MarkInterface::MarkChangeAction ); 00478 00479 private: 00480 QHash<int, KTextEditor::Mark*> m_marks; 00481 QHash<int,QPixmap> m_markPixmaps; 00482 QHash<int,QString> m_markDescriptions; 00483 uint m_editableMarks; 00484 00485 // 00486 // KTextEditor::PrintInterface 00487 // 00488 public Q_SLOTS: 00489 bool printDialog (); 00490 bool print (); 00491 00492 // 00493 // KTextEditor::DocumentInfoInterface ( ### unfinished ) 00494 // 00495 public: 00503 virtual QString mimeType(); 00504 00511 KMimeType::Ptr mimeTypeForContent(); 00512 00513 // 00514 // KTextEditor::VariableInterface 00515 // 00516 public: 00517 virtual QString variable( const QString &name ) const; 00518 00519 Q_SIGNALS: 00520 void variableChanged( KTextEditor::Document*, const QString &, const QString & ); 00521 00522 private: 00523 QMap<QString, QString> m_storedVariables; 00524 00525 // 00526 // MovingInterface API 00527 // 00528 public: 00535 virtual KTextEditor::MovingCursor *newMovingCursor (const KTextEditor::Cursor &position, KTextEditor::MovingCursor::InsertBehavior insertBehavior = KTextEditor::MovingCursor::MoveOnInsert); 00536 00544 virtual KTextEditor::MovingRange *newMovingRange (const KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors = KTextEditor::MovingRange::DoNotExpand 00545 , KTextEditor::MovingRange::EmptyBehavior emptyBehavior = KTextEditor::MovingRange::AllowEmpty); 00546 00551 virtual qint64 revision () const; 00552 00557 virtual qint64 lastSavedRevision () const; 00558 00564 virtual void lockRevision (qint64 revision); 00565 00570 virtual void unlockRevision (qint64 revision); 00571 00579 virtual void transformCursor (KTextEditor::Cursor &cursor, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1); 00580 00589 virtual void transformCursor (int& line, int& column, KTextEditor::MovingCursor::InsertBehavior insertBehavior, qint64 fromRevision, qint64 toRevision = -1); 00590 00599 virtual void transformRange (KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors, KTextEditor::MovingRange::EmptyBehavior emptyBehavior, qint64 fromRevision, qint64 toRevision = -1); 00600 00601 // 00602 // MovingInterface Signals 00603 // 00604 Q_SIGNALS: 00609 void aboutToDeleteMovingInterfaceContent (KTextEditor::Document *document); 00610 00616 void aboutToInvalidateMovingInterfaceContent (KTextEditor::Document *document); 00617 00618 // 00619 // Annotation Interface 00620 // 00621 public: 00622 00623 virtual void setAnnotationModel( KTextEditor::AnnotationModel* model ); 00624 virtual KTextEditor::AnnotationModel* annotationModel() const; 00625 00626 Q_SIGNALS: 00627 void annotationModelChanged( KTextEditor::AnnotationModel*, KTextEditor::AnnotationModel* ); 00628 00629 private: 00630 KTextEditor::AnnotationModel* m_annotationModel; 00631 00632 // 00633 // KParts::ReadWrite stuff 00634 // 00635 public: 00641 virtual bool openFile (); 00642 00648 virtual bool saveFile (); 00649 00650 virtual void setReadWrite ( bool rw = true ); 00651 00652 virtual void setModified( bool m ); 00653 00654 private: 00655 void activateDirWatch (const QString &useFileName = QString()); 00656 void deactivateDirWatch (); 00657 00658 QString m_dirWatchFile; 00659 00660 public: 00664 bool typeChars ( KateView *type, const QString &chars ); 00665 00669 inline int lastLine() const { return lines()-1; } 00670 00671 // Repaint all of all of the views 00672 void repaintViews(bool paintOnlyDirty = true); 00673 00674 KateHighlighting *highlight () const; 00675 00676 public Q_SLOTS: //please keep prototypes and implementations in same order 00677 void tagLines(int start, int end); 00678 void tagLines(KTextEditor::Cursor start, KTextEditor::Cursor end); 00679 00680 //export feature, obsolute 00681 public Q_SLOTS: 00682 void exportAs(const QString&) { } 00683 00684 Q_SIGNALS: 00685 void preHighlightChanged(uint); 00686 00687 private Q_SLOTS: 00688 void internalHlChanged(); 00689 00690 public: 00691 void addView(KTextEditor::View *); 00698 void removeView(KTextEditor::View *); 00699 void setActiveView(KTextEditor::View*); 00700 00701 bool ownedView(KateView *); 00702 00703 uint toVirtualColumn( const KTextEditor::Cursor& ); 00704 void newLine( KateView*view ); // Changes input 00705 void backspace( KateView *view, const KTextEditor::Cursor& ); 00706 void del( KateView *view, const KTextEditor::Cursor& ); 00707 void transpose( const KTextEditor::Cursor& ); 00708 00709 void paste ( KateView* view, QClipboard::Mode = QClipboard::Clipboard ); 00710 00711 public: 00712 void indent ( KTextEditor::Range range, int change ); 00713 void comment ( KateView *view, uint line, uint column, int change ); 00714 void align ( KateView *view, const KTextEditor::Range &range ); 00715 void insertTab( KateView *view, const KTextEditor::Cursor& ); 00716 00717 enum TextTransform { Uppercase, Lowercase, Capitalize }; 00718 00726 void transform ( KateView *view, const KTextEditor::Cursor &, TextTransform ); 00730 void joinLines( uint first, uint last ); 00731 00732 private: 00733 bool removeStringFromBeginning(int line, const QString &str); 00734 bool removeStringFromEnd(int line, const QString &str); 00735 00745 bool nextNonSpaceCharPos(int &line, int &col); 00746 00754 bool previousNonSpaceCharPos(int &line, int &col); 00755 00760 void addStartLineCommentToSingleLine(int line, int attrib=0); 00765 bool removeStartLineCommentFromSingleLine(int line, int attrib=0); 00766 00770 void addStartStopCommentToSingleLine(int line, int attrib=0); 00774 bool removeStartStopCommentFromSingleLine(int line, int attrib=0); 00778 bool removeStartStopCommentFromRegion(const KTextEditor::Cursor &start, const KTextEditor::Cursor &end, int attrib=0); 00779 00784 void addStartStopCommentToSelection( KateView *view, int attrib=0 ); 00788 void addStartLineCommentToSelection( KateView *view, int attrib=0 ); 00789 00796 bool removeStartStopCommentFromSelection( KateView *view, int attrib=0 ); 00800 bool removeStartLineCommentFromSelection( KateView *view, int attrib=0 ); 00801 00802 public: 00803 QString getWord( const KTextEditor::Cursor& cursor ); 00804 00805 public: 00806 void newBracketMark( const KTextEditor::Cursor& start, KTextEditor::Range& bm, int maxLines = -1 ); 00807 bool findMatchingBracket( KTextEditor::Range& range, int maxLines = -1 ); 00808 00809 public: 00810 virtual const QString &documentName () const { return m_docName; } 00811 00812 void setDocName (QString docName); 00813 00814 void lineInfo (KateLineInfo *info, unsigned int line); 00815 00816 KateCodeFoldingTree *foldingTree (); 00817 00818 public: 00822 bool isModifiedOnDisc() { return m_modOnHd; } 00823 00824 virtual void setModifiedOnDisk( ModifiedOnDiskReason reason ); 00825 00826 virtual void setModifiedOnDiskWarning ( bool on ); 00827 00828 public Q_SLOTS: 00833 virtual void slotModifiedOnDisk( KTextEditor::View *v = 0 ); 00834 00838 virtual bool documentReload (); 00839 00840 virtual bool documentSave (); 00841 virtual bool documentSaveAs (); 00842 00843 virtual bool save(); 00844 public: 00845 virtual bool saveAs( const KUrl &url ); 00846 private: 00847 bool m_saveAs; 00848 Q_SIGNALS: 00855 void modifiedOnDisk (KTextEditor::Document *doc, bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason); 00856 00857 public: 00858 void ignoreModifiedOnDiskOnce(); 00859 00860 private: 00861 int m_isasking; // don't reenter slotModifiedOnDisk when this is true 00862 // -1: ignore once, 0: false, 1: true 00863 00864 public: 00865 virtual bool setEncoding (const QString &e); 00866 virtual const QString &encoding() const; 00867 00868 00869 public Q_SLOTS: 00870 void setWordWrap (bool on); 00871 void setWordWrapAt (uint col); 00872 00873 public: 00874 bool wordWrap() const; 00875 uint wordWrapAt() const; 00876 00877 public Q_SLOTS: 00878 void setPageUpDownMovesCursor(bool on); 00879 00880 public: 00881 bool pageUpDownMovesCursor() const; 00882 00883 // code folding 00884 public: 00885 uint getRealLine(unsigned int virtualLine); 00886 uint getVirtualLine(unsigned int realLine); 00887 uint visibleLines (); 00888 Kate::TextLine kateTextLine(uint i); 00889 Kate::TextLine plainKateTextLine(uint i); 00890 00891 Q_SIGNALS: 00892 void codeFoldingUpdated(); 00893 void aboutToRemoveText(const KTextEditor::Range&); 00894 00895 private Q_SLOTS: 00896 void slotModOnHdDirty (const QString &path); 00897 void slotModOnHdCreated (const QString &path); 00898 void slotModOnHdDeleted (const QString &path); 00899 00900 private: 00908 bool createDigest ( QByteArray &result ); 00909 00913 QString reasonedMOHString() const; 00914 00921 void removeTrailingSpace(int line); 00922 inline void blockRemoveTrailingSpaces(bool block) 00923 { m_blockRemoveTrailingSpaces = block; } 00924 00925 private: 00927 bool m_blockRemoveTrailingSpaces; 00928 00929 public: 00930 void updateFileType (const QString &newType, bool user = false); 00931 00932 QString fileType () const { return m_fileType; } 00933 00939 KateBuffer &buffer () { return *m_buffer; } 00940 00941 // 00942 // REALLY internal data ;) 00943 // 00944 private: 00945 // text buffer 00946 KateBuffer *const m_buffer; 00947 00948 // indenter 00949 KateAutoIndent *const m_indenter; 00950 00951 bool hlSetByUser; 00952 bool m_bomSetByUser; 00953 00954 bool m_modOnHd; 00955 ModifiedOnDiskReason m_modOnHdReason; 00956 QByteArray m_digest; // MD5 digest, updated on load/save 00957 00958 QString m_docName; 00959 int m_docNameNumber; 00960 00961 // file type !!! 00962 QString m_fileType; 00963 bool m_fileTypeSetByUser; 00964 00968 bool m_reloading; 00969 00970 public Q_SLOTS: 00971 void slotQueryClose_save(bool *handled, bool* abortClosing); 00972 00973 public: 00974 virtual bool queryClose(); 00975 00976 void makeAttribs (bool needInvalidate = true); 00977 00978 static bool checkOverwrite( KUrl u, QWidget *parent ); 00979 00983 public: 00984 KateDocumentConfig *config() { return m_config; } 00985 KateDocumentConfig *config() const { return m_config; } 00986 00987 void updateConfig (); 00988 00989 private: 00990 KateDocumentConfig *const m_config; 00991 00996 private: 01000 void readDirConfig (); 01001 01006 void readVariables(bool onlyViewAndRenderer = false); 01007 01012 void readVariableLine( QString t, bool onlyViewAndRenderer = false ); 01016 void setViewVariable( QString var, QString val ); 01022 static bool checkBoolValue( QString value, bool *result ); 01028 static bool checkIntValue( QString value, int *result ); 01033 static bool checkColorValue( QString value, QColor &col ); 01034 01038 static QRegExp kvLine; 01039 static QRegExp kvLineWildcard; 01040 static QRegExp kvLineMime; 01041 static QRegExp kvVar; 01042 01043 bool m_fileChangedDialogsActivated; 01044 01045 // 01046 // KTextEditor::ConfigInterface 01047 // 01048 public: 01049 virtual QStringList configKeys() const; 01050 virtual QVariant configValue(const QString &key); 01051 virtual void setConfigValue(const QString &key, const QVariant &value); 01052 01053 // 01054 // KTextEditor::RecoveryInterface 01055 // 01056 public: 01057 virtual bool isDataRecoveryAvailable() const; 01058 virtual void recoverData(); 01059 virtual void discardDataRecovery(); 01060 01061 // 01062 // KTextEditor::TemplateInterface + KTextEditor::TemplateInterface2 01063 // 01064 public: 01072 virtual bool insertTemplateTextImplementation ( const KTextEditor::Cursor &c, 01073 const QString &templateString, 01074 const QMap<QString,QString> &initialValues, 01075 KTextEditor::TemplateScript* templateScript, 01076 KateView *view); 01077 01078 // 01079 // KTextEditor::HighlightInterface 01080 // 01081 public: 01082 virtual KTextEditor::Attribute::Ptr defaultStyle(const KTextEditor::HighlightInterface::DefaultStyle ds) const; 01083 virtual QList< KTextEditor::HighlightInterface::AttributeBlock > lineAttributes(const unsigned int line); 01084 virtual QStringList embeddedHighlightingModes() const; 01085 virtual QString highlightingModeAt(const KTextEditor::Cursor& position); 01086 01087 protected Q_SLOTS: 01088 void dumpRegionTree(); 01089 01090 private slots: 01091 void slotCompleted(); 01092 void slotCanceled(); 01093 01094 private: 01095 class LoadSaveFilterCheckPlugins; 01096 01097 private: 01098 bool m_savingToUrl; 01099 void setPreSavePostDialogFilterChecks(QStringList plugins) {m_preSavePostDialogFilterChecks=plugins;} 01100 QStringList m_preSavePostDialogFilterChecks; 01101 void setPostSaveFilterChecks(QStringList plugins) {m_postSaveFilterChecks=plugins;} 01102 QStringList m_postSaveFilterChecks; 01103 void setPostLoadFilterChecks(QStringList plugins) {m_postLoadFilterChecks=plugins;} 01104 QStringList m_postLoadFilterChecks; 01105 static LoadSaveFilterCheckPlugins* loadSaveFilterCheckPlugins(); 01106 01107 public: 01108 QString defaultDictionary() const; 01109 QList<QPair<KTextEditor::MovingRange*, QString> > dictionaryRanges() const; 01110 bool isOnTheFlySpellCheckingEnabled() const; 01111 01112 QString dictionaryForMisspelledRange(const KTextEditor::Range& range) const; 01113 void clearMisspellingForWord(const QString& word); 01114 01115 public Q_SLOTS: 01116 void clearDictionaryRanges(); 01117 void setDictionary(const QString& dict, const KTextEditor::Range &range); 01118 void revertToDefaultDictionary(const KTextEditor::Range &range); 01119 void setDefaultDictionary(const QString& dict); 01120 void onTheFlySpellCheckingEnabled(bool enable); 01121 void respellCheckBlock(int start, int end) {respellCheckBlock(this,start,end);} 01122 void refreshOnTheFlyCheck(const KTextEditor::Range &range = KTextEditor::Range::invalid()); 01123 01124 Q_SIGNALS: 01125 void respellCheckBlock(KateDocument *document,int start, int end); 01126 void dictionaryRangesPresent(bool yesNo); 01127 void defaultDictionaryChanged(KateDocument *document); 01128 01129 public: 01130 bool containsCharacterEncoding(const KTextEditor::Range& range); 01131 01132 typedef QList<QPair<int, int> > OffsetList; 01133 01134 int computePositionWrtOffsets(const OffsetList& offsetList, int pos); 01135 01140 QString decodeCharacters(const KTextEditor::Range& range, 01141 KateDocument::OffsetList& decToEncOffsetList, 01142 KateDocument::OffsetList& encToDecOffsetList); 01143 void replaceCharactersByEncoding(const KTextEditor::Range& range); 01144 01145 enum EncodedCharaterInsertionPolicy {EncodeAlways, EncodeWhenPresent, EncodeNever}; 01146 01147 protected: 01148 KateOnTheFlyChecker *m_onTheFlyChecker; 01149 QString m_defaultDictionary; 01150 QList<QPair<KTextEditor::MovingRange*, QString> > m_dictionaryRanges; 01151 01152 // from KTextEditor::MovingRangeFeedback 01153 void rangeInvalid(KTextEditor::MovingRange *movingRange); 01154 void rangeEmpty(KTextEditor::MovingRange *movingRange); 01155 01156 void deleteDictionaryRange(KTextEditor::MovingRange *movingRange); 01157 01158 private: 01159 Kate::SwapFile *m_swapfile; 01160 public: 01161 Kate::SwapFile* swapFile(); 01162 }; 01163 01164 #endif 01165 01166 // kate: space-indent on; indent-width 2; replace-tabs on; 01167
KDE 4.6 API Reference