Commit f09d7427 authored by Jarek Kobus's avatar Jarek Kobus

Implement (un)commenting selection of .pro files

Reviewed-by: default avatarLeandro Melo <leandro.melo@nokia.com>
Task-number: QTCREATORBUG-119
parent 5a6de0ad
......@@ -34,6 +34,9 @@
#include "qt4projectmanagerconstants.h"
#include "profileeditorfactory.h"
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/uniqueidmanager.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditoractionhandler.h>
......@@ -41,6 +44,7 @@
#include <texteditor/texteditorsettings.h>
#include <QtCore/QFileInfo>
#include <QtGui/QMenu>
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
......@@ -91,17 +95,41 @@ ProFileEditor::ProFileEditor(QWidget *parent, ProFileEditorFactory *factory, Tex
ah->setupActions(this);
baseTextDocument()->setSyntaxHighlighter(new ProFileHighlighter);
m_commentDefinition.clearCommentStyles();
m_commentDefinition.setSingleLine(QString(QLatin1Char('#')));
}
ProFileEditor::~ProFileEditor()
{
}
void ProFileEditor::unCommentSelection()
{
Utils::unCommentSelection(this, m_commentDefinition);
}
TextEditor::BaseTextEditorEditable *ProFileEditor::createEditableInterface()
{
return new ProFileEditorEditable(this);
}
void ProFileEditor::contextMenuEvent(QContextMenuEvent *e)
{
QMenu *menu = new QMenu();
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::ActionContainer *mcontext = am->actionContainer(Qt4ProjectManager::Constants::M_CONTEXT);
QMenu *contextMenu = mcontext->menu();
foreach (QAction *action, contextMenu->actions())
menu->addAction(action);
appendStandardContextMenuActions(menu);
menu->exec(e->globalPos());
delete menu;
}
void ProFileEditor::setFontSettings(const TextEditor::FontSettings &fs)
{
TextEditor::BaseTextEditor::setFontSettings(fs);
......
......@@ -32,6 +32,7 @@
#include <texteditor/basetextdocument.h>
#include <texteditor/basetexteditor.h>
#include <utils/uncommentselection.h>
namespace TextEditor {
class FontSettings;
......@@ -78,8 +79,12 @@ public:
ProFileEditorFactory *factory() { return m_factory; }
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
void unCommentSelection();
protected:
TextEditor::BaseTextEditorEditable *createEditableInterface();
void contextMenuEvent(QContextMenuEvent *);
public slots:
virtual void setFontSettings(const TextEditor::FontSettings &);
......@@ -87,6 +92,7 @@ public slots:
private:
ProFileEditorFactory *m_factory;
TextEditor::TextEditorActionHandler *m_ah;
Utils::CommentDefinition m_commentDefinition;
};
class ProFileDocument : public TextEditor::BaseTextDocument
......
......@@ -39,6 +39,9 @@ namespace Constants {
const char * const C_PROFILEEDITOR = ".pro File Editor";
const char * const C_PROFILEEDITOR_PANEL = ".pro File Editor (embedded)";
// menus
const char * const M_CONTEXT = "ProFileEditor.ContextMenu";
// kinds
const char * const PROJECT_ID = "Qt4.Qt4Project";
const char * const PROFILE_EDITOR_ID = "Qt4.proFileEditor";
......
......@@ -66,6 +66,7 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
#ifdef WITH_TESTS
# include <QTest>
......@@ -117,7 +118,8 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
addObject(m_qt4ProjectManager);
TextEditor::TextEditorActionHandler *editorHandler
= new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR);
= new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR,
TextEditor::TextEditorActionHandler::UnCommentSelection);
m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler);
addObject(m_proFileEditorFactory);
......@@ -222,6 +224,13 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
connect(m_projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
this, SLOT(currentProjectChanged()));
Core::ActionContainer *contextMenu= am->createMenu(Qt4ProjectManager::Constants::M_CONTEXT);
Core::Command *cmd;
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
return true;
}
......
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