Commit 722e48c2 authored by Friedemann Kleint's avatar Friedemann Kleint

TextEditor: Some exported header cleanup.

Remove internal markers from exported headers,
introduce private class for BaseTextDocument.
Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent 259f518d
......@@ -72,6 +72,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/fontsettings.h>
#include <texteditor/tabsettings.h>
#include <texteditor/texteditorconstants.h>
#include <QtCore/QDebug>
......
......@@ -56,6 +56,7 @@
#include <QtGui/QMessageBox>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextCursor>
#include <QtGui/QIcon>
#include <limits.h>
......
......@@ -59,6 +59,7 @@
#include <extensionsystem/pluginmanager.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/fontsettings.h>
#include <texteditor/tabsettings.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/syntaxhighlighter.h>
......
This diff is collapsed.
......@@ -31,9 +31,6 @@
#define BASETEXTDOCUMENT_H
#include "texteditor_global.h"
#include "storagesettings.h"
#include "itexteditor.h"
#include "tabsettings.h"
#include <coreplugin/ifile.h>
......@@ -43,26 +40,15 @@ class QTextDocument;
QT_END_NAMESPACE
namespace TextEditor {
namespace Internal {
class DocumentMarker;
}
class ITextMarkable;
class StorageSettings;
class TabSettings;
class SyntaxHighlighter;
class DocumentMarker : public ITextMarkable
{
Q_OBJECT
public:
DocumentMarker(QTextDocument *);
// ITextMarkable
bool addMark(ITextMark *mark, int line);
TextMarks marksAt(int line) const;
void removeMark(ITextMark *mark);
bool hasMark(ITextMark *mark) const;
void updateMark(ITextMark *mark);
private:
QTextDocument *document;
};
class BaseTextDocumentPrivate;
class TEXTEDITOR_EXPORT BaseTextDocument : public Core::IFile
{
......@@ -70,21 +56,22 @@ class TEXTEDITOR_EXPORT BaseTextDocument : public Core::IFile
public:
BaseTextDocument();
~BaseTextDocument();
void setStorageSettings(const StorageSettings &storageSettings) { m_storageSettings = storageSettings; }
void setTabSettings(const TabSettings &tabSettings) { m_tabSettings = tabSettings; }
virtual ~BaseTextDocument();
inline const StorageSettings &storageSettings() const { return m_storageSettings; }
inline const TabSettings &tabSettings() const { return m_tabSettings; }
void setStorageSettings(const StorageSettings &storageSettings);
void setTabSettings(const TabSettings &tabSettings);
DocumentMarker *documentMarker() const { return m_documentMarker; }
const StorageSettings &storageSettings() const;
const TabSettings &tabSettings() const;
ITextMarkable *documentMarker() const;
//IFile
virtual bool save(const QString &fileName = QString());
virtual QString fileName() const { return m_fileName; }
virtual QString fileName() const;
virtual bool isReadOnly() const;
virtual bool isModified() const;
virtual bool isSaveAsAllowed() const { return true; }
virtual bool isSaveAsAllowed() const;
virtual void checkPermissions();
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
void reload(ReloadFlag flag, ChangeType type);
......@@ -92,25 +79,25 @@ public:
void setMimeType(const QString &mt);
virtual void rename(const QString &newName);
virtual QString defaultPath() const { return m_defaultPath; }
virtual QString suggestedFileName() const { return m_suggestedFileName; }
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
void setDefaultPath(const QString &defaultPath) { m_defaultPath = defaultPath; }
void setSuggestedFileName(const QString &suggestedFileName) { m_suggestedFileName = suggestedFileName; }
void setDefaultPath(const QString &defaultPath);
void setSuggestedFileName(const QString &suggestedFileName);
virtual bool open(const QString &fileName = QString());
virtual void reload();
QTextDocument *document() const { return m_document; }
QTextDocument *document() const;
void setSyntaxHighlighter(SyntaxHighlighter *highlighter);
SyntaxHighlighter *syntaxHighlighter() const { return m_highlighter; }
SyntaxHighlighter *syntaxHighlighter() const;
inline bool isBinaryData() const { return m_isBinaryData; }
inline bool hasDecodingError() const { return m_hasDecodingError || m_isBinaryData; }
inline QTextCodec *codec() const { return m_codec; }
inline void setCodec(QTextCodec *c) { m_codec = c; }
inline QByteArray decodingErrorSample() const { return m_decodingErrorSample; }
bool isBinaryData() const;
bool hasDecodingError() const;
QTextCodec *codec() const;
void setCodec(QTextCodec *c);
QByteArray decodingErrorSample() const;
void reload(QTextCodec *codec);
......@@ -120,38 +107,11 @@ signals:
void titleChanged(QString title);
private:
QString m_fileName;
QString m_defaultPath;
QString m_suggestedFileName;
QString m_mimeType;
StorageSettings m_storageSettings;
TabSettings m_tabSettings;
QTextDocument *m_document;
DocumentMarker *m_documentMarker;
SyntaxHighlighter *m_highlighter;
enum LineTerminatorMode {
LFLineTerminator,
CRLFLineTerminator,
NativeLineTerminator =
#if defined (Q_OS_WIN)
CRLFLineTerminator
#else
LFLineTerminator
#endif
};
LineTerminatorMode m_lineTerminatorMode;
QTextCodec *m_codec;
bool m_fileHasUtf8Bom;
bool m_fileIsReadOnly;
bool m_isBinaryData;
bool m_hasDecodingError;
QByteArray m_decodingErrorSample;
void cleanWhitespace(QTextCursor& cursor, bool cleanIndentation, bool inEntireDocument);
void ensureFinalNewLine(QTextCursor& cursor);
void documentClosing();
BaseTextDocumentPrivate *d;
};
} // namespace TextEditor
......
......@@ -28,16 +28,52 @@
**************************************************************************/
#include "basetextmark.h"
#include "itexteditor.h"
#include "basetextdocument.h"
#include <coreplugin/editormanager/editormanager.h>
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QTimer>
#include <QtGui/QIcon>
namespace TextEditor {
namespace Internal {
class InternalMark : public TextEditor::ITextMark
{
public:
explicit InternalMark(BaseTextMark *parent) : m_parent(parent) {}
virtual QIcon icon() const
{
return m_parent->icon();
}
virtual void updateLineNumber(int lineNumber)
{
return m_parent->updateLineNumber(lineNumber);
}
virtual void updateBlock(const QTextBlock &block)
{
return m_parent->updateBlock(block);
}
virtual void removedFromEditor()
{
m_parent->childRemovedFromEditor(this);
}
virtual void documentClosing()
{
m_parent->documentClosingFor(this);
}
private:
BaseTextMark *m_parent;
};
using namespace TextEditor;
using namespace TextEditor::Internal;
} // namespace Internal
BaseTextMark::BaseTextMark(const QString &filename, int line)
: m_markableInterface(0)
......@@ -80,7 +116,7 @@ void BaseTextMark::editorOpened(Core::IEditor *editor)
if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) {
if (m_markableInterface == 0) { // We aren't added to something
m_markableInterface = textEditor->markableInterface();
m_internalMark = new InternalMark(this);
m_internalMark = new Internal::InternalMark(this);
if (m_markableInterface->addMark(m_internalMark, m_line)) {
// Handle reload of text documents, readding the mark as necessary
......@@ -103,13 +139,13 @@ void BaseTextMark::documentReloaded()
return;
m_markableInterface = doc->documentMarker();
m_internalMark = new InternalMark(this);
m_internalMark = new Internal::InternalMark(this);
if (!m_markableInterface->addMark(m_internalMark, m_line))
removeInternalMark();
}
void BaseTextMark::childRemovedFromEditor(InternalMark *mark)
void BaseTextMark::childRemovedFromEditor(Internal::InternalMark *mark)
{
Q_UNUSED(mark)
// m_internalMark was removed from the editor
......@@ -117,7 +153,7 @@ void BaseTextMark::childRemovedFromEditor(InternalMark *mark)
removedFromEditor();
}
void BaseTextMark::documentClosingFor(InternalMark *mark)
void BaseTextMark::documentClosingFor(Internal::InternalMark *mark)
{
Q_UNUSED(mark)
removeInternalMark();
......@@ -155,3 +191,4 @@ void BaseTextMark::moveMark(const QString & /* filename */, int /* line */)
foreach (Core::IEditor *editor, em->openedEditors())
editorOpened(editor);
}
} // namespace TextEditor
......@@ -30,8 +30,17 @@
#ifndef BASETEXTMARK_H
#define BASETEXTMARK_H
#include "itexteditor.h"
#include <QtGui/QIcon>
#include "texteditor_global.h"
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QIcon;
class QTextBlock;
QT_END_NAMESPACE
namespace Core {
class IEditor;
}
namespace TextEditor {
......@@ -47,8 +56,8 @@ class TEXTEDITOR_EXPORT BaseTextMark : public QObject
Q_OBJECT
public:
BaseTextMark(const QString &filename, int line);
~BaseTextMark();
explicit BaseTextMark(const QString &filename, int line);
virtual ~BaseTextMark();
// return your icon here
virtual QIcon icon() const = 0;
......@@ -88,49 +97,6 @@ private:
bool m_init;
};
namespace Internal {
class InternalMark : public ITextMark
{
public:
InternalMark(BaseTextMark *parent)
: m_parent(parent)
{
}
~InternalMark()
{
}
virtual QIcon icon() const
{
return m_parent->icon();
}
virtual void updateLineNumber(int lineNumber)
{
return m_parent->updateLineNumber(lineNumber);
}
virtual void updateBlock(const QTextBlock &block)
{
return m_parent->updateBlock(block);
}
virtual void removedFromEditor()
{
m_parent->childRemovedFromEditor(this);
}
virtual void documentClosing()
{
m_parent->documentClosingFor(this);
}
private:
BaseTextMark *m_parent;
};
} // namespace Internal
} // namespace TextEditor
#endif // BASETEXTMARK_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment