Commit 4f8fabfe authored by hjk's avatar hjk
Browse files

ProfileEditor: clean up



Change-Id: I35754e7bcc59232f4fa9be9b0f136de3e5365896
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 2af80159
......@@ -34,10 +34,10 @@
#include "qt4projectmanagerconstants.h"
#include "profileeditorfactory.h"
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/id.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
......@@ -45,21 +45,19 @@
#include <QFileInfo>
#include <QDir>
#include <QMenu>
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
namespace Qt4ProjectManager {
namespace Internal {
//
// ProFileEditorEditable
// ProFileEditor
//
ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
: BaseTextEditor(editor)
{
setContext(Core::Context(Qt4ProjectManager::Constants::C_PROFILEEDITOR,
setContext(Core::Context(Constants::C_PROFILEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
// m_contexts << uidm->uniqueIdentifier(Qt4ProjectManager::Constants::PROJECT_KIND);
}
Core::IEditor *ProFileEditor::duplicate(QWidget *parent)
......@@ -73,18 +71,18 @@ Core::IEditor *ProFileEditor::duplicate(QWidget *parent)
Core::Id ProFileEditor::id() const
{
return Core::Id(Qt4ProjectManager::Constants::PROFILE_EDITOR_ID);
return Core::Id(Constants::PROFILE_EDITOR_ID);
}
//
// ProFileEditorEditor
// ProFileEditorWidget
//
ProFileEditorWidget::ProFileEditorWidget(QWidget *parent, ProFileEditorFactory *factory, TextEditor::TextEditorActionHandler *ah)
: BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah)
{
ProFileDocument *doc = new ProFileDocument();
doc->setMimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE));
doc->setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
setBaseTextDocument(doc);
ah->setupActions(this);
......@@ -101,14 +99,12 @@ void ProFileEditorWidget::unCommentSelection()
static bool isValidFileNameChar(const QChar &c)
{
if (c.isLetterOrNumber()
return c.isLetterOrNumber()
|| c == QLatin1Char('.')
|| c == QLatin1Char('_')
|| c == QLatin1Char('-')
|| c == QLatin1Char('/')
|| c == QLatin1Char('\\'))
return true;
return false;
|| c == QLatin1Char('\\');
}
ProFileEditorWidget::Link ProFileEditorWidget::findLinkAt(const QTextCursor &cursor,
......@@ -213,8 +209,7 @@ void ProFileEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
<< TextEditor::C_VISUAL_WHITESPACE;
}
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
highlighter->setFormats(formats.constBegin(), formats.constEnd());
highlighter->setFormats(fs.toTextCharFormats(categories));
highlighter->rehighlight();
}
......@@ -238,3 +233,6 @@ QString ProFileDocument::suggestedFileName() const
QFileInfo fi(fileName());
return fi.fileName();
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -40,15 +40,9 @@ class TextEditorActionHandler;
}
namespace Qt4ProjectManager {
class Qt4Manager;
class Qt4Project;
namespace Internal {
class ProFileEditorFactory;
class ProFileHighlighter;
class ProFileEditorWidget;
class ProFileEditor : public TextEditor::BaseTextEditor
......@@ -78,6 +72,7 @@ public:
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
void unCommentSelection();
protected:
virtual Link findLinkAt(const QTextCursor &, bool resolveTarget = true);
TextEditor::BaseTextEditor *createEditor();
......
......@@ -35,6 +35,7 @@
#include <QtAlgorithms>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QVector>
namespace Qt4ProjectManager {
namespace Internal {
......@@ -52,18 +53,17 @@ public:
};
ProFileHighlighter(QTextDocument *document = 0);
virtual void highlightBlock(const QString &text);
void highlightBlock(const QString &text);
// Set formats from a sequence of type QTextCharFormat
template <class InputIterator>
void setFormats(InputIterator begin, InputIterator end) {
qCopy(begin, end, m_formats);
void setFormats(const QVector<QTextCharFormat> &formats)
{
qCopy(formats.begin(), formats.end(), m_formats);
}
private:
QTextCharFormat m_formats[NumProfileFormats];
TextEditor::Keywords m_keywords;
};
} // namespace Internal
......
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