forked from qt-creator/qt-creator
Remove a few TextDocument subclasses
Which only differed in some property settings. Change-Id: Ie844c32709ebe719a5b749fd2ef828b64086ba9a Reviewed-by: hjk <hjk@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -44,22 +44,13 @@
|
|||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
//
|
static TextEditor::TextDocument *createJavaDocument()
|
||||||
// JavaDocument
|
|
||||||
//
|
|
||||||
|
|
||||||
class JavaDocument : public TextEditor::TextDocument
|
|
||||||
{
|
{
|
||||||
public:
|
auto doc = new TextEditor::TextDocument;
|
||||||
JavaDocument();
|
doc->setId(Constants::JAVA_EDITOR_ID);
|
||||||
};
|
doc->setMimeType(QLatin1String(Constants::JAVA_MIMETYPE));
|
||||||
|
doc->setIndenter(new JavaIndenter);
|
||||||
|
return doc;
|
||||||
JavaDocument::JavaDocument()
|
|
||||||
{
|
|
||||||
setId(Constants::JAVA_EDITOR_ID);
|
|
||||||
setMimeType(QLatin1String(Constants::JAVA_MIMETYPE));
|
|
||||||
setIndenter(new JavaIndenter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -72,7 +63,7 @@ JavaEditorFactory::JavaEditorFactory()
|
|||||||
setDisplayName(tr("Java Editor"));
|
setDisplayName(tr("Java Editor"));
|
||||||
addMimeType(Constants::JAVA_MIMETYPE);
|
addMimeType(Constants::JAVA_MIMETYPE);
|
||||||
|
|
||||||
setDocumentCreator([]() { return new JavaDocument; });
|
setDocumentCreator(createJavaDocument);
|
||||||
setUseGenericHighlighter(true);
|
setUseGenericHighlighter(true);
|
||||||
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
||||||
setEditorActionHandlers(TextEditor::TextEditorActionHandler::UnCommentSelection);
|
setEditorActionHandlers(TextEditor::TextEditorActionHandler::UnCommentSelection);
|
||||||
|
|||||||
@@ -196,20 +196,12 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
static TextDocument *createCMakeDocument()
|
||||||
// CMakeDocument
|
|
||||||
//
|
|
||||||
|
|
||||||
class CMakeDocument : public TextDocument
|
|
||||||
{
|
{
|
||||||
public:
|
auto doc = new TextDocument;
|
||||||
CMakeDocument();
|
doc->setId(Constants::CMAKE_EDITOR_ID);
|
||||||
};
|
doc->setMimeType(QLatin1String(Constants::CMAKEMIMETYPE));
|
||||||
|
return doc;
|
||||||
CMakeDocument::CMakeDocument()
|
|
||||||
{
|
|
||||||
setId(Constants::CMAKE_EDITOR_ID);
|
|
||||||
setMimeType(QLatin1String(Constants::CMAKEMIMETYPE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -225,7 +217,7 @@ CMakeEditorFactory::CMakeEditorFactory()
|
|||||||
|
|
||||||
setEditorCreator([]() { return new CMakeEditor; });
|
setEditorCreator([]() { return new CMakeEditor; });
|
||||||
setEditorWidgetCreator([]() { return new CMakeEditorWidget; });
|
setEditorWidgetCreator([]() { return new CMakeEditorWidget; });
|
||||||
setDocumentCreator([]() { return new CMakeDocument; });
|
setDocumentCreator(createCMakeDocument);
|
||||||
setIndenterCreator([]() { return new CMakeIndenter; });
|
setIndenterCreator([]() { return new CMakeIndenter; });
|
||||||
setUseGenericHighlighter(true);
|
setUseGenericHighlighter(true);
|
||||||
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
||||||
|
|||||||
@@ -47,11 +47,10 @@ namespace Internal {
|
|||||||
class TextDocumentPrivate
|
class TextDocumentPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextDocumentPrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {}
|
|
||||||
|
|
||||||
Utils::TextFileFormat m_format;
|
Utils::TextFileFormat m_format;
|
||||||
Utils::TextFileFormat::ReadResult m_readResult;
|
Utils::TextFileFormat::ReadResult m_readResult = Utils::TextFileFormat::ReadSuccess;
|
||||||
QByteArray m_decodingErrorSample;
|
QByteArray m_decodingErrorSample;
|
||||||
|
bool m_supportsUtf8Bom = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -97,6 +96,11 @@ bool BaseTextDocument::write(const QString &fileName, const Utils::TextFileForma
|
|||||||
return format.writeFile(fileName, data, errorMessage);
|
return format.writeFile(fileName, data, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTextDocument::setSupportsUtf8Bom(bool value)
|
||||||
|
{
|
||||||
|
d->m_supportsUtf8Bom = value;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Autodetects format and reads in the text file specified by \a fileName.
|
Autodetects format and reads in the text file specified by \a fileName.
|
||||||
*/
|
*/
|
||||||
@@ -140,6 +144,11 @@ void BaseTextDocument::switchUtf8Bom()
|
|||||||
d->m_format.hasUtf8Bom = !d->m_format.hasUtf8Bom;
|
d->m_format.hasUtf8Bom = !d->m_format.hasUtf8Bom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BaseTextDocument::supportsUtf8Bom() const
|
||||||
|
{
|
||||||
|
return d->m_supportsUtf8Bom;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the format obtained from the last call to \c read().
|
Returns the format obtained from the last call to \c read().
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
const QTextCodec *codec() const;
|
const QTextCodec *codec() const;
|
||||||
void setCodec(const QTextCodec *);
|
void setCodec(const QTextCodec *);
|
||||||
void switchUtf8Bom();
|
void switchUtf8Bom();
|
||||||
virtual bool supportsUtf8Bom() { return true; }
|
bool supportsUtf8Bom() const;
|
||||||
|
|
||||||
ReadResult read(const QString &fileName, QStringList *plainTextList, QString *errorString);
|
ReadResult read(const QString &fileName, QStringList *plainTextList, QString *errorString);
|
||||||
ReadResult read(const QString &fileName, QString *plainText, QString *errorString);
|
ReadResult read(const QString &fileName, QString *plainText, QString *errorString);
|
||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
bool write(const QString &fileName, const QString &data, QString *errorMessage) const;
|
bool write(const QString &fileName, const QString &data, QString *errorMessage) const;
|
||||||
bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const;
|
bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const;
|
||||||
|
|
||||||
|
void setSupportsUtf8Bom(bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Internal::TextDocumentPrivate *d;
|
Internal::TextDocumentPrivate *d;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -153,24 +153,15 @@ void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
showDefaultContextMenu(e, Constants::M_CONTEXT);
|
showDefaultContextMenu(e, Constants::M_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
static TextDocument *createProFileDocument()
|
||||||
// ProFileDocument
|
|
||||||
//
|
|
||||||
|
|
||||||
class ProFileDocument : public TextDocument
|
|
||||||
{
|
{
|
||||||
public:
|
auto doc = new TextDocument;
|
||||||
ProFileDocument();
|
doc->setId(Constants::PROFILE_EDITOR_ID);
|
||||||
|
doc->setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
|
||||||
// qmake project files doesn't support UTF8-BOM
|
// qmake project files do not support UTF8-BOM
|
||||||
// If the BOM would be added qmake would fail and QtCreator couldn't parse the project file
|
// If the BOM would be added qmake would fail and Qt Creator couldn't parse the project file
|
||||||
bool supportsUtf8Bom() override { return false; }
|
doc->setSupportsUtf8Bom(false);
|
||||||
};
|
return doc;
|
||||||
|
|
||||||
ProFileDocument::ProFileDocument()
|
|
||||||
{
|
|
||||||
setId(Constants::PROFILE_EDITOR_ID);
|
|
||||||
setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -188,7 +179,7 @@ ProFileEditorFactory::ProFileEditorFactory()
|
|||||||
addMimeType(Constants::PROCACHEFILE_MIMETYPE);
|
addMimeType(Constants::PROCACHEFILE_MIMETYPE);
|
||||||
addMimeType(Constants::PROSTASHFILE_MIMETYPE);
|
addMimeType(Constants::PROSTASHFILE_MIMETYPE);
|
||||||
|
|
||||||
setDocumentCreator([]() { return new ProFileDocument; });
|
setDocumentCreator(createProFileDocument);
|
||||||
setEditorWidgetCreator([]() { return new ProFileEditorWidget; });
|
setEditorWidgetCreator([]() { return new ProFileEditorWidget; });
|
||||||
|
|
||||||
ProFileCompletionAssistProvider *pcap = new ProFileCompletionAssistProvider;
|
ProFileCompletionAssistProvider *pcap = new ProFileCompletionAssistProvider;
|
||||||
|
|||||||
Reference in New Issue
Block a user