#include "qt4projectmanager.h"
#include "qt4projectmanagerconstants.h"
#include "profileeditorfactory.h"
-#include "addlibrarywizard.h"
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
highlighter->rehighlight();
}
-void ProFileEditorWidget::addLibrary()
-{
- AddLibraryWizard wizard(file()->fileName(), this);
- if (wizard.exec() != QDialog::Accepted)
- return;
-
- TextEditor::BaseTextEditor *editable = editor();
- const int endOfDoc = editable->position(TextEditor::ITextEditor::EndOfDoc);
- editable->setCursorPosition(endOfDoc);
- QString snippet = wizard.snippet();
-
- // add extra \n in case the last line is not empty
- int line, column;
- editable->convertPosition(endOfDoc, &line, &column);
- if (!editable->textAt(endOfDoc - column, column).simplified().isEmpty())
- snippet = QLatin1Char('\n') + snippet;
-
- editable->insert(snippet);
-}
-
void ProFileEditorWidget::jumpToFile()
{
openLink(findLinkAt(textCursor()));
#include "qt4project.h"
#include "qt4target.h"
#include "profilereader.h"
+#include "profileeditor.h"
#include "qmakestep.h"
#include "qt4buildconfiguration.h"
+#include "addlibrarywizard.h"
#include "wizards/qtquickapp.h"
#include "wizards/html5app.h"
return m_contextProject;
}
+void Qt4Manager::addLibrary()
+{
+ Core::EditorManager *em = Core::EditorManager::instance();
+ ProFileEditorWidget *editor = qobject_cast<ProFileEditorWidget*>(em->currentEditor()->widget());
+ if (editor)
+ addLibrary(editor->file()->fileName(), editor);
+}
+
+void Qt4Manager::addLibraryContextMenu()
+{
+ ProjectExplorer::Node *node = ProjectExplorer::ProjectExplorerPlugin::instance()->currentNode();
+ if (qobject_cast<Qt4ProFileNode *>(node))
+ addLibrary(node->path());
+}
+
+void Qt4Manager::addLibrary(const QString &fileName, ProFileEditorWidget *editor)
+{
+ AddLibraryWizard wizard(fileName, Core::EditorManager::instance());
+ if (wizard.exec() != QDialog::Accepted)
+ return;
+
+ TextEditor::BaseTextEditor *editable = 0;
+ if (editor) {
+ editable = editor->editor();
+ } else {
+ Core::EditorManager *em = Core::EditorManager::instance();
+ editable = qobject_cast<TextEditor::BaseTextEditor *>
+ (em->openEditor(fileName, Qt4ProjectManager::Constants::PROFILE_EDITOR_ID));
+ }
+ if (!editable)
+ return;
+
+ const int endOfDoc = editable->position(TextEditor::ITextEditor::EndOfDoc);
+ editable->setCursorPosition(endOfDoc);
+ QString snippet = wizard.snippet();
+
+ // add extra \n in case the last line is not empty
+ int line, column;
+ editable->convertPosition(endOfDoc, &line, &column);
+ if (!editable->textAt(endOfDoc - column, column).simplified().isEmpty())
+ snippet = QLatin1Char('\n') + snippet;
+
+ editable->insert(snippet);
+}
+
+
void Qt4Manager::runQMake()
{
runQMake(projectExplorer()->startupProject(), 0);
{
Q_UNUSED(arguments)
const Core::Context projectContext(Qt4ProjectManager::Constants::PROJECT_ID);
+ Core::Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE);
ProFileParser::initialize();
ProFileEvaluator::initialize();
this, SLOT(buildStateChanged(ProjectExplorer::Project *)));
connect(m_projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
this, SLOT(currentProjectChanged()));
+ connect(m_projectExplorer, SIGNAL(currentNodeChanged(ProjectExplorer::Node*,ProjectExplorer::Project*)),
+ this, SLOT(currentNodeChanged(ProjectExplorer::Node*)));
Core::ActionContainer *contextMenu = am->createMenu(Qt4ProjectManager::Constants::M_CONTEXT);
- Core::Command *cmd;
-
Core::Context proFileEditorContext = Core::Context(Qt4ProjectManager::Constants::C_PROFILEEDITOR);
QAction *jumpToFile = new QAction(tr("Jump to File Under Cursor"), this);
- cmd = am->registerAction(jumpToFile,
+ command = am->registerAction(jumpToFile,
Constants::JUMP_TO_FILE, proFileEditorContext);
- cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
+ command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(jumpToFile, SIGNAL(triggered()),
this, SLOT(jumpToFile()));
- contextMenu->addAction(cmd);
+ contextMenu->addAction(command);
- QAction *addLibrary = new QAction(tr("Add Library..."), this);
- cmd = am->registerAction(addLibrary,
+ m_addLibraryAction = new QAction(tr("Add Library..."), this);
+ command = am->registerAction(m_addLibraryAction,
Constants::ADDLIBRARY, proFileEditorContext);
- connect(addLibrary, SIGNAL(triggered()),
- this, SLOT(addLibrary()));
- contextMenu->addAction(cmd);
+ connect(m_addLibraryAction, SIGNAL(triggered()),
+ m_qt4ProjectManager, SLOT(addLibrary()));
+ contextMenu->addAction(command);
+
+ m_addLibraryActionContextMenu = new QAction(tr("Add Library..."), this);
+ command = am->registerAction(m_addLibraryActionContextMenu,
+ Constants::ADDLIBRARY, projecTreeContext);
+ connect(m_addLibraryActionContextMenu, SIGNAL(triggered()),
+ m_qt4ProjectManager, SLOT(addLibraryContextMenu()));
+ mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES);
+ msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES);
QAction *separator = new QAction(this);
separator->setSeparator(true);
contextMenu->addAction(am->registerAction(separator,
Core::Id(Constants::SEPARATOR), proFileEditorContext));
- cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
- contextMenu->addAction(cmd);
+ command = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
+ contextMenu->addAction(command);
return true;
}
m_runQMakeAction->setEnabled(!m_projectExplorer->buildManager()->isBuilding(m_projectExplorer->currentProject()));
}
+void Qt4ProjectManagerPlugin::currentNodeChanged(ProjectExplorer::Node *node)
+{
+ m_addLibraryActionContextMenu->setEnabled(qobject_cast<Qt4ProFileNode *>(node));
+}
+
void Qt4ProjectManagerPlugin::buildStateChanged(ProjectExplorer::Project *pro)
{
ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject();
m_runQMakeActionContextMenu->setEnabled(!m_projectExplorer->buildManager()->isBuilding(pro));
}
-void Qt4ProjectManagerPlugin::addLibrary()
-{
- Core::EditorManager *em = Core::EditorManager::instance();
- ProFileEditorWidget *editor = qobject_cast<ProFileEditorWidget*>(em->currentEditor()->widget());
- if (editor)
- editor->addLibrary();
-}
-
void Qt4ProjectManagerPlugin::jumpToFile()
{
Core::EditorManager *em = Core::EditorManager::instance();