//
//     Copyright 2007 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2006 Jim Bublitz also apply


//                 Generated by preSip


// This file is part of PyKDE4.

// PyKDE4 is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.

// PyKDE4 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

namespace KTextEditor
{

class Document : KParts::ReadWritePart
{
%TypeHeaderCode
#include <ktexteditor/document.h>

#include <ktexteditor/modificationinterface.h>
#include <ktexteditor/markinterface.h>
#include <ktexteditor/searchinterface.h>
#include <ktexteditor/sessionconfiginterface.h>
#include <ktexteditor/smartinterface.h>
#include <ktexteditor/templateinterface.h>
#include <ktexteditor/variableinterface.h>
%End


public:
                         Document (QObject* = 0);

public:
    virtual KTextEditor::Editor* editor ()  = 0;
    virtual KTextEditor::View* createView (QWidget*)  = 0;
    virtual KTextEditor::View* activeView () const = 0;
    virtual const QList<KTextEditor::View*>& views () const = 0;

signals:
    void                 viewCreated (KTextEditor::Document*, KTextEditor::View*);

public:
    virtual const QString& documentName () const = 0;
    virtual QString      mimeType ()  = 0;

signals:
    void                 documentNameChanged (KTextEditor::Document*);
    void                 documentUrlChanged (KTextEditor::Document*);
    void                 modifiedChanged (KTextEditor::Document*);

public:
    virtual bool         setEncoding (const QString&)  = 0;
    virtual const QString& encoding () const = 0;

public:
    virtual bool         documentReload ()  = 0;
    virtual bool         documentSave ()  = 0;
    virtual bool         documentSaveAs ()  = 0;

public:
    virtual bool         startEditing ()  = 0;
    virtual bool         endEditing ()  = 0;

public:
    virtual QString      text () const = 0;
    virtual QString      text (const KTextEditor::Range&, bool = 0) const = 0;
    virtual QChar        character (const KTextEditor::Cursor&) const = 0;
    virtual QStringList  textLines (const KTextEditor::Range&, bool = 0) const = 0;
    virtual QString      line (int) const = 0;
    virtual int          lines () const = 0;
    virtual KTextEditor::Cursor documentEnd () const = 0;
    KTextEditor::Range   documentRange () const;
    virtual int          totalCharacters () const = 0;
    virtual bool         isEmpty () const;
    virtual int          lineLength (int) const = 0;
    KTextEditor::Cursor  endOfLine (int) const;
    virtual bool         setText (const QString&)  = 0;
    virtual bool         setText (const QStringList&)  = 0;
    virtual bool         clear ()  = 0;
    virtual bool         insertText (const KTextEditor::Cursor&, const QString&, bool = 0)  = 0;
    virtual bool         insertText (const KTextEditor::Cursor&, const QStringList&, bool = 0)  = 0;
    virtual bool         replaceText (const KTextEditor::Range&, const QString&, bool = 0);
    virtual bool         replaceText (const KTextEditor::Range&, const QStringList&, bool = 0);
    virtual bool         removeText (const KTextEditor::Range&, bool = 0)  = 0;
    virtual bool         cursorInText (const KTextEditor::Cursor&);
    virtual bool         insertLine (int, const QString&)  = 0;
    virtual bool         insertLines (int, const QStringList&)  = 0;
    virtual bool         removeLine (int)  = 0;

signals:
    void                 textChanged (KTextEditor::Document*);
    void                 textInserted (KTextEditor::Document*, const KTextEditor::Range&);
    void                 textRemoved (KTextEditor::Document*, const KTextEditor::Range&);
    void                 textChanged (KTextEditor::Document*, const KTextEditor::Range&, const KTextEditor::Range&);
    void                 aboutToClose (KTextEditor::Document*);

public:
    virtual QString      mode () const = 0;
    virtual QString      highlightingMode () const = 0;
    virtual QStringList  modes () const = 0;
    virtual QStringList  highlightingModes () const = 0;
    virtual bool         setMode (const QString&)  = 0;
    virtual bool         setHighlightingMode (const QString&)  = 0;

    virtual QString      highlightingModeSection (int) const = 0;
    virtual QString      modeSection (int) const = 0;


signals:
    void                 modeChanged (KTextEditor::Document*);
    void                 highlightingModeChanged (KTextEditor::Document*);

public:
    void                 setSuppressOpeningErrorDialogs (bool);
    bool                 suppressOpeningErrorDialogs () const;
    bool                 openingError () const;
    QString              openingErrorMessage () const;

protected:
    void                 setOpeningError (bool);
    void                 setOpeningErrorMessage (const QString&);

public:
    // Python cannot dynamic_cast, so methods are provided that attempt
    // to convert the Document to the required interface. They return
    // None on failure.
//     Why no annotationinterface.sip?
//     KTextEditor::AnnotationInterface *annotationInterface();
// %MethodCode
//     Py_BEGIN_ALLOW_THREADS
//     sipRes = dynamic_cast<KTextEditor::AnnotationInterface*>(sipCpp);
//     Py_END_ALLOW_THREADS
// %End
    
    KTextEditor::MarkInterface *markInterface();
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = dynamic_cast<KTextEditor::MarkInterface*>(sipCpp);
    Py_END_ALLOW_THREADS
%End
    
    KTextEditor::ModificationInterface *modificationInterface();
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = dynamic_cast<KTextEditor::ModificationInterface*>(sipCpp);
    Py_END_ALLOW_THREADS
%End
    
    KTextEditor::SearchInterface *searchInterface();
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = dynamic_cast<KTextEditor::SearchInterface*>(sipCpp);
    Py_END_ALLOW_THREADS
%End
    
    KTextEditor::SmartInterface *smartInterface();
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = dynamic_cast<KTextEditor::SmartInterface*>(sipCpp);
    Py_END_ALLOW_THREADS
%End
    
    KTextEditor::TemplateInterface *templateInterface();
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = dynamic_cast<KTextEditor::TemplateInterface*>(sipCpp);
    Py_END_ALLOW_THREADS
%End
    
    KTextEditor::TextHintInterface *textHintInterface();
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = dynamic_cast<KTextEditor::TextHintInterface*>(sipCpp);
    Py_END_ALLOW_THREADS
%End
    
    KTextEditor::VariableInterface *variableInterface();
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = dynamic_cast<KTextEditor::VariableInterface*>(sipCpp);
    Py_END_ALLOW_THREADS
%End

};  // class Document

};  // namespace KTextEditor

