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