forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanagerinterface.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/fontsettings.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanagerinterface.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <QtCore/qplugin.h>
|
||||
#include <QtCore/QDebug>
|
||||
@@ -68,7 +68,7 @@ void BookmarksPlugin::extensionsInitialized()
|
||||
bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
|
||||
{
|
||||
m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
|
||||
Core::ActionManagerInterface *am = m_core->actionManager();
|
||||
Core::ActionManager *am = m_core->actionManager();
|
||||
|
||||
QList<int> context = QList<int>() << m_core->uniqueIDManager()->
|
||||
uniqueIdentifier(Constants::BOOKMARKS_CONTEXT);
|
||||
@@ -77,17 +77,17 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
|
||||
uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
|
||||
globalcontext << Core::Constants::C_GLOBAL_ID;
|
||||
|
||||
Core::IActionContainer *mtools =
|
||||
Core::ActionContainer *mtools =
|
||||
am->actionContainer(Core::Constants::M_TOOLS);
|
||||
|
||||
Core::IActionContainer *mbm =
|
||||
Core::ActionContainer *mbm =
|
||||
am->createMenu(QLatin1String(BOOKMARKS_MENU));
|
||||
mbm->menu()->setTitle(tr("&Bookmarks"));
|
||||
mtools->addMenu(mbm);
|
||||
|
||||
//Toggle
|
||||
m_toggleAction = new QAction(tr("Toggle Bookmark"), this);
|
||||
Core::ICommand *cmd =
|
||||
Core::Command *cmd =
|
||||
am->registerAction(m_toggleAction, BOOKMARKS_TOGGLE_ACTION, textcontext);
|
||||
#ifndef Q_OS_MAC
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M")));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtGui/QFormLayout>
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
@@ -61,27 +62,39 @@ using namespace CMakeProjectManager::Internal;
|
||||
// Who sets up the environment for cl.exe ? INCLUDEPATH and so on
|
||||
|
||||
|
||||
|
||||
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
||||
: m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName))
|
||||
{
|
||||
|
||||
m_file = new CMakeFile(this, fileName);
|
||||
QDir dir = QFileInfo(m_fileName).absoluteDir();
|
||||
QString cbpFile = findCbpFile(dir);
|
||||
if (cbpFile.isEmpty()) {
|
||||
createCbpFile(dir);
|
||||
cbpFile = findCbpFile(dir);
|
||||
}
|
||||
parseCMakeLists(dir);
|
||||
}
|
||||
|
||||
CMakeProject::~CMakeProject()
|
||||
{
|
||||
delete m_rootNode;
|
||||
}
|
||||
|
||||
// TODO also call this method if the CMakeLists.txt file changed, which is also called if the CMakeList.txt is updated
|
||||
// TODO make this function work even if it is reparsing
|
||||
void CMakeProject::parseCMakeLists(const QDir &directory)
|
||||
{
|
||||
createCbpFile(directory);
|
||||
|
||||
QString cbpFile = findCbpFile(directory);
|
||||
|
||||
//TODO move this parsing to a seperate method, which is also called if the CMakeList.txt is updated
|
||||
CMakeCbpParser cbpparser;
|
||||
qDebug()<<"Parsing file "<<cbpFile;
|
||||
if (cbpparser.parseCbpFile(cbpFile)) {
|
||||
qDebug()<<"Building Tree";
|
||||
// TODO do a intelligent updating of the tree
|
||||
buildTree(m_rootNode, cbpparser.fileList());
|
||||
foreach (ProjectExplorer::FileNode *fn, cbpparser.fileList())
|
||||
m_files.append(fn->path());
|
||||
m_files.sort();
|
||||
|
||||
qDebug()<<"Adding Targets";
|
||||
m_targets = cbpparser.targets();
|
||||
qDebug()<<"Printing targets";
|
||||
foreach(CMakeTarget ct, m_targets) {
|
||||
@@ -91,6 +104,7 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
||||
qDebug()<<"";
|
||||
}
|
||||
|
||||
qDebug()<<"Updating CodeModel";
|
||||
CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
|
||||
if (modelmanager) {
|
||||
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
|
||||
@@ -106,9 +120,12 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
||||
}
|
||||
}
|
||||
|
||||
CMakeProject::~CMakeProject()
|
||||
QStringList CMakeProject::targets() const
|
||||
{
|
||||
delete m_rootNode;
|
||||
QStringList results;
|
||||
foreach(const CMakeTarget &ct, m_targets)
|
||||
results << ct.title;
|
||||
return results;
|
||||
}
|
||||
|
||||
QString CMakeProject::findCbpFile(const QDir &directory)
|
||||
@@ -134,10 +151,12 @@ void CMakeProject::createCbpFile(const QDir &directory)
|
||||
// QtCreator generator, which actually can be very similar to the CodeBlock Generator
|
||||
|
||||
// TODO we need to pass on the same paremeters as the cmakestep
|
||||
qDebug()<<"Creating cbp file";
|
||||
QProcess cmake;
|
||||
cmake.setWorkingDirectory(directory.absolutePath());
|
||||
cmake.start("cmake", QStringList() << "-GCodeBlocks - Unix Makefiles");
|
||||
cmake.waitForFinished();
|
||||
cmake.waitForFinished(-1);
|
||||
qDebug()<<"cmake output: \n"<<cmake.readAll();
|
||||
}
|
||||
|
||||
void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list)
|
||||
@@ -219,14 +238,15 @@ ProjectExplorer::Environment CMakeProject::environment(const QString &buildConfi
|
||||
|
||||
QString CMakeProject::buildDirectory(const QString &buildConfiguration) const
|
||||
{
|
||||
Q_UNUSED(buildConfiguration)
|
||||
//TODO
|
||||
return QFileInfo(m_fileName).absolutePath();
|
||||
QString buildDirectory = value(buildConfiguration, "buildDirectory").toString();
|
||||
if (buildDirectory.isEmpty())
|
||||
buildDirectory = QFileInfo(m_fileName).absolutePath();
|
||||
return buildDirectory;
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *CMakeProject::createConfigWidget()
|
||||
{
|
||||
return new CMakeBuildSettingsWidget;
|
||||
return new CMakeBuildSettingsWidget(this);
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::BuildStepConfigWidget*> CMakeProject::subConfigWidgets()
|
||||
@@ -238,8 +258,8 @@ QList<ProjectExplorer::BuildStepConfigWidget*> CMakeProject::subConfigWidgets()
|
||||
// You should probably set some default values in this method
|
||||
void CMakeProject::newBuildConfiguration(const QString &buildConfiguration)
|
||||
{
|
||||
Q_UNUSED(buildConfiguration);
|
||||
//TODO
|
||||
// Default to all
|
||||
makeStep()->setBuildTarget(buildConfiguration, "all", true);
|
||||
}
|
||||
|
||||
ProjectExplorer::ProjectNode *CMakeProject::rootProjectNode() const
|
||||
@@ -261,6 +281,25 @@ void CMakeProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &w
|
||||
Project::saveSettingsImpl(writer);
|
||||
}
|
||||
|
||||
MakeStep *CMakeProject::makeStep() const
|
||||
{
|
||||
foreach (ProjectExplorer::BuildStep *bs, buildSteps()) {
|
||||
MakeStep *ms = qobject_cast<MakeStep *>(bs);
|
||||
if (ms)
|
||||
return ms;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CMakeStep *CMakeProject::cmakeStep() const
|
||||
{
|
||||
foreach (ProjectExplorer::BuildStep *bs, buildSteps()) {
|
||||
if (CMakeStep *cs = qobject_cast<CMakeStep *>(bs))
|
||||
return cs;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
|
||||
{
|
||||
// TODO
|
||||
@@ -273,14 +312,16 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
|
||||
insertBuildStep(0, cmakeStep);
|
||||
insertBuildStep(1, makeStep);
|
||||
|
||||
addBuildConfiguration("AllTargets");
|
||||
setActiveBuildConfiguration("AllTargets");
|
||||
makeStep->setValue("AllTargets", "buildTargets", QStringList() << "all");
|
||||
addBuildConfiguration("all");
|
||||
setActiveBuildConfiguration("all");
|
||||
makeStep->setBuildTarget("all", "all", true);
|
||||
|
||||
// Create build configurations of m_targets
|
||||
qDebug()<<"Create build configurations of m_targets";
|
||||
// Create run configurations for m_targets
|
||||
qDebug()<<"Create run configurations of m_targets";
|
||||
bool setActive = false;
|
||||
foreach(const CMakeTarget &ct, m_targets) {
|
||||
if (ct.executable.isEmpty())
|
||||
continue;
|
||||
QSharedPointer<ProjectExplorer::RunConfiguration> rc(new CMakeRunConfiguration(this, ct.executable, ct.workingDirectory));
|
||||
addRunConfiguration(rc);
|
||||
// The first one gets the honour of beeing the active one
|
||||
@@ -289,7 +330,6 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
|
||||
setActive = true;
|
||||
}
|
||||
}
|
||||
setActiveBuildConfiguration("all");
|
||||
|
||||
}
|
||||
// Restoring is fine
|
||||
@@ -352,10 +392,19 @@ void CMakeFile::modified(ReloadBehavior *behavior)
|
||||
Q_UNUSED(behavior);
|
||||
}
|
||||
|
||||
|
||||
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget()
|
||||
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeProject *project)
|
||||
: m_project(project)
|
||||
{
|
||||
|
||||
QFormLayout *fl = new QFormLayout(this);
|
||||
setLayout(fl);
|
||||
m_pathChooser = new Core::Utils::PathChooser(this);
|
||||
m_pathChooser->setEnabled(false);
|
||||
// TODO currently doesn't work
|
||||
// since creating the cbp file also creates makefiles
|
||||
// and then cmake builds in that directory instead of shadow building
|
||||
// We need our own generator for that to work
|
||||
connect(m_pathChooser, SIGNAL(changed()), this, SLOT(buildDirectoryChanged()));
|
||||
fl->addRow("Build directory:", m_pathChooser);
|
||||
}
|
||||
|
||||
QString CMakeBuildSettingsWidget::displayName() const
|
||||
@@ -365,10 +414,19 @@ QString CMakeBuildSettingsWidget::displayName() const
|
||||
|
||||
void CMakeBuildSettingsWidget::init(const QString &buildConfiguration)
|
||||
{
|
||||
Q_UNUSED(buildConfiguration);
|
||||
// TODO
|
||||
m_buildConfiguration = buildConfiguration;
|
||||
m_pathChooser->setPath(m_project->buildDirectory(buildConfiguration));
|
||||
}
|
||||
|
||||
void CMakeBuildSettingsWidget::buildDirectoryChanged()
|
||||
{
|
||||
m_project->setValue(m_buildConfiguration, "buildDirectory", m_pathChooser->path());
|
||||
}
|
||||
|
||||
/////
|
||||
// CMakeCbpParser
|
||||
////
|
||||
|
||||
bool CMakeCbpParser::parseCbpFile(const QString &fileName)
|
||||
{
|
||||
QFile fi(fileName);
|
||||
@@ -445,7 +503,7 @@ void CMakeCbpParser::parseTarget()
|
||||
while (!atEnd()) {
|
||||
readNext();
|
||||
if (isEndElement()) {
|
||||
if (m_targetType || m_target.title == "all") {
|
||||
if (m_targetType || m_target.title == "all" || m_target.title == "install") {
|
||||
m_targets.append(m_target);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -36,11 +36,14 @@
|
||||
|
||||
#include "cmakeprojectmanager.h"
|
||||
#include "cmakeprojectnodes.h"
|
||||
#include "makestep.h"
|
||||
#include "cmakestep.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
|
||||
@@ -99,8 +102,12 @@ public:
|
||||
// virtual Node *nodeForFile(const QString &filePath) const = 0;
|
||||
|
||||
virtual QStringList files(FilesMode fileMode) const;
|
||||
MakeStep *makeStep() const;
|
||||
CMakeStep *cmakeStep() const;
|
||||
QStringList targets() const;
|
||||
|
||||
private:
|
||||
void parseCMakeLists(const QDir &directory);
|
||||
QString findCbpFile(const QDir &);
|
||||
void createCbpFile(const QDir &);
|
||||
|
||||
@@ -177,13 +184,20 @@ private:
|
||||
|
||||
class CMakeBuildSettingsWidget : public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeBuildSettingsWidget();
|
||||
CMakeBuildSettingsWidget(CMakeProject *project);
|
||||
virtual QString displayName() const;
|
||||
|
||||
// This is called to set up the config widget before showing it
|
||||
// buildConfiguration is QString::null for the non buildConfiguration specific page
|
||||
virtual void init(const QString &buildConfiguration);
|
||||
private slots:
|
||||
void buildDirectoryChanged();
|
||||
private:
|
||||
CMakeProject *m_project;
|
||||
Core::Utils::PathChooser *m_pathChooser;
|
||||
QString m_buildConfiguration;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakeprojectmanager.h"
|
||||
#include "cmakerunconfiguration.h"
|
||||
#include "cmakestep.h"
|
||||
#include "makestep.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
@@ -58,6 +60,8 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
|
||||
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
addAutoReleasedObject(new CMakeManager());
|
||||
addAutoReleasedObject(new CMakeBuildStepFactory());
|
||||
addAutoReleasedObject(new MakeBuildStepFactory());
|
||||
addAutoReleasedObject(new CMakeRunConfigurationFactory());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
* QString nameForType(const QString&) are used to generate a list of creatable
|
||||
* RunConfigurations, and create(..) is used to create it.
|
||||
*/
|
||||
class CMakeRunConfigurationFactory : public QObject
|
||||
class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "cmakeprojectconstants.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QLineEdit>
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
@@ -55,7 +57,14 @@ bool CMakeStep::init(const QString &buildConfiguration)
|
||||
setEnabled(buildConfiguration, true);
|
||||
setWorkingDirectory(buildConfiguration, m_pro->buildDirectory(buildConfiguration));
|
||||
setCommand(buildConfiguration, "cmake"); // TODO give full path here?
|
||||
setArguments(buildConfiguration, QStringList() << "-GUnix Makefiles"); // TODO
|
||||
|
||||
QString sourceDir = QFileInfo(m_pro->file()->fileName()).absolutePath();
|
||||
setArguments(buildConfiguration,
|
||||
QStringList()
|
||||
<< sourceDir
|
||||
<< "-GUnix Makefiles"
|
||||
<< value(buildConfiguration, "userArguments").toStringList()); // TODO
|
||||
|
||||
setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
|
||||
return AbstractProcessStep::init(buildConfiguration);
|
||||
}
|
||||
@@ -72,17 +81,17 @@ void CMakeStep::run(QFutureInterface<bool> &fi)
|
||||
|
||||
QString CMakeStep::name()
|
||||
{
|
||||
return "CMake";
|
||||
return Constants::CMAKESTEP;
|
||||
}
|
||||
|
||||
QString CMakeStep::displayName()
|
||||
{
|
||||
return Constants::CMAKESTEP;
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *CMakeStep::createConfigWidget()
|
||||
{
|
||||
return new CMakeBuildStepConfigWidget();
|
||||
return new CMakeBuildStepConfigWidget(this);
|
||||
}
|
||||
|
||||
bool CMakeStep::immutable() const
|
||||
@@ -90,18 +99,46 @@ bool CMakeStep::immutable() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CMakeStep::userArguments(const QString &buildConfiguration) const
|
||||
{
|
||||
return ProjectExplorer::Environment::joinArgumentList(value(buildConfiguration, "userArguments").toStringList());
|
||||
}
|
||||
|
||||
void CMakeStep::setUserArguments(const QString &buildConfiguration, const QString &arguments)
|
||||
{
|
||||
setValue(buildConfiguration, "userArguments", ProjectExplorer::Environment::parseCombinedArgString(arguments));
|
||||
}
|
||||
|
||||
//
|
||||
// CMakeBuildStepConfigWidget
|
||||
//
|
||||
|
||||
CMakeBuildStepConfigWidget::CMakeBuildStepConfigWidget(CMakeStep *cmakeStep)
|
||||
: m_cmakeStep(cmakeStep)
|
||||
{
|
||||
QFormLayout *fl = new QFormLayout(this);
|
||||
setLayout(fl);
|
||||
m_arguments = new QLineEdit(this);
|
||||
fl->addRow("Additional arguments", m_arguments);
|
||||
connect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
}
|
||||
|
||||
QString CMakeBuildStepConfigWidget::displayName() const
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
void CMakeBuildStepConfigWidget::init(const QString & /*buildConfiguration */)
|
||||
void CMakeBuildStepConfigWidget::init(const QString &buildConfiguration)
|
||||
{
|
||||
// TODO
|
||||
m_buildConfiguration = buildConfiguration;
|
||||
disconnect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
m_arguments->setText(m_cmakeStep->userArguments(buildConfiguration));
|
||||
connect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
}
|
||||
|
||||
void CMakeBuildStepConfigWidget::argumentsLineEditChanged()
|
||||
{
|
||||
m_cmakeStep->setUserArguments(m_buildConfiguration, m_arguments->text());
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -37,6 +37,10 @@
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/abstractprocessstep.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -46,6 +50,7 @@ class CMakeBuildStepConfigWidget;
|
||||
|
||||
class CMakeStep : public ProjectExplorer::AbstractProcessStep
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeStep(CMakeProject *pro);
|
||||
~CMakeStep();
|
||||
@@ -57,15 +62,26 @@ public:
|
||||
virtual QString displayName();
|
||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||
virtual bool immutable() const;
|
||||
|
||||
void setUserArguments(const QString &buildConfiguration, const QString &arguments);
|
||||
QString userArguments(const QString &buildConfiguration) const;
|
||||
private:
|
||||
CMakeProject *m_pro;
|
||||
};
|
||||
|
||||
class CMakeBuildStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeBuildStepConfigWidget(CMakeStep *cmakeStep);
|
||||
virtual QString displayName() const;
|
||||
virtual void init(const QString &buildConfiguration);
|
||||
private slots:
|
||||
void argumentsLineEditChanged();
|
||||
private:
|
||||
CMakeStep *m_cmakeStep;
|
||||
QString m_buildConfiguration;
|
||||
QLineEdit *m_arguments;
|
||||
};
|
||||
|
||||
class CMakeBuildStepFactory : public ProjectExplorer::IBuildStepFactory
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -36,6 +36,11 @@
|
||||
#include "cmakeproject.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QGroupBox>
|
||||
#include <QtGui/QCheckBox>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QListWidget>
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
@@ -66,17 +71,17 @@ void MakeStep::run(QFutureInterface<bool> &fi)
|
||||
|
||||
QString MakeStep::name()
|
||||
{
|
||||
return "Make";
|
||||
return Constants::MAKESTEP;
|
||||
}
|
||||
|
||||
QString MakeStep::displayName()
|
||||
{
|
||||
return Constants::CMAKESTEP;
|
||||
return "Make";
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *MakeStep::createConfigWidget()
|
||||
{
|
||||
return new MakeBuildStepConfigWidget();
|
||||
return new MakeBuildStepConfigWidget(this);
|
||||
}
|
||||
|
||||
bool MakeStep::immutable() const
|
||||
@@ -84,18 +89,72 @@ bool MakeStep::immutable() const
|
||||
return true;
|
||||
}
|
||||
|
||||
CMakeProject *MakeStep::project() const
|
||||
{
|
||||
return m_pro;
|
||||
}
|
||||
|
||||
bool MakeStep::buildsTarget(const QString &buildConfiguration, const QString &target) const
|
||||
{
|
||||
return value(buildConfiguration, "buildTargets").toStringList().contains(target);
|
||||
}
|
||||
|
||||
void MakeStep::setBuildTarget(const QString &buildConfiguration, const QString &target, bool on)
|
||||
{
|
||||
QStringList old = value(buildConfiguration, "buildTargets").toStringList();
|
||||
if (on && !old.contains(target))
|
||||
setValue(buildConfiguration, "buildTargets", old << target);
|
||||
else if(!on && old.contains(target))
|
||||
setValue(buildConfiguration, "buildTargets", old.removeOne(target));
|
||||
}
|
||||
|
||||
//
|
||||
// CMakeBuildStepConfigWidget
|
||||
//
|
||||
MakeBuildStepConfigWidget::MakeBuildStepConfigWidget(MakeStep *makeStep)
|
||||
: m_makeStep(makeStep)
|
||||
{
|
||||
QFormLayout *fl = new QFormLayout(this);
|
||||
setLayout(fl);
|
||||
|
||||
m_targetsList = new QListWidget;
|
||||
fl->addRow("Targets:", m_targetsList);
|
||||
|
||||
// TODO update this list also on rescans of the CMakeLists.txt
|
||||
CMakeProject *pro = m_makeStep->project();
|
||||
foreach(const QString& target, pro->targets()) {
|
||||
QListWidgetItem *item = new QListWidgetItem(target, m_targetsList);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void MakeBuildStepConfigWidget::itemChanged(QListWidgetItem *item)
|
||||
{
|
||||
m_makeStep->setBuildTarget(m_buildConfiguration, item->text(), item->checkState() & Qt::Checked);
|
||||
}
|
||||
|
||||
QString MakeBuildStepConfigWidget::displayName() const
|
||||
{
|
||||
return "Make";
|
||||
}
|
||||
|
||||
void MakeBuildStepConfigWidget::init(const QString & /* buildConfiguration */)
|
||||
void MakeBuildStepConfigWidget::init(const QString &buildConfiguration)
|
||||
{
|
||||
// TODO
|
||||
|
||||
// disconnect to make the changes to the items
|
||||
disconnect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
m_buildConfiguration = buildConfiguration;
|
||||
int count = m_targetsList->count();
|
||||
for(int i = 0; i < count; ++i) {
|
||||
QListWidgetItem *item = m_targetsList->item(i);
|
||||
item->setCheckState(m_makeStep->buildsTarget(buildConfiguration, item->text()) ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
// and connect again
|
||||
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -36,6 +36,12 @@
|
||||
|
||||
#include <projectexplorer/abstractprocessstep.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLineEdit;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -43,6 +49,7 @@ class CMakeProject;
|
||||
|
||||
class MakeStep : public ProjectExplorer::AbstractProcessStep
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MakeStep(CMakeProject *pro);
|
||||
~MakeStep();
|
||||
@@ -54,15 +61,26 @@ public:
|
||||
virtual QString displayName();
|
||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||
virtual bool immutable() const;
|
||||
CMakeProject *project() const;
|
||||
bool buildsTarget(const QString &buildConfiguration, const QString &target) const;
|
||||
void setBuildTarget(const QString &buildConfiguration, const QString &target, bool on);
|
||||
private:
|
||||
CMakeProject *m_pro;
|
||||
};
|
||||
|
||||
class MakeBuildStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MakeBuildStepConfigWidget(MakeStep *makeStep);
|
||||
virtual QString displayName() const;
|
||||
virtual void init(const QString &buildConfiguration);
|
||||
private slots:
|
||||
void itemChanged(QListWidgetItem*);
|
||||
private:
|
||||
QString m_buildConfiguration;
|
||||
MakeStep * m_makeStep;
|
||||
QListWidget *m_targetsList;
|
||||
};
|
||||
|
||||
class MakeBuildStepFactory : public ProjectExplorer::IBuildStepFactory
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -31,8 +31,10 @@
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#include "actioncontainer.h"
|
||||
#include "command.h"
|
||||
#include "actioncontainer_p.h"
|
||||
#include "actionmanager_p.h"
|
||||
|
||||
#include "command_p.h"
|
||||
#include "coreimpl.h"
|
||||
|
||||
#include "coreconstants.h"
|
||||
@@ -48,146 +50,112 @@ Q_DECLARE_METATYPE(Core::Internal::MenuActionContainer*)
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
/*!
|
||||
\class IActionContainer
|
||||
\mainclass
|
||||
\ingroup qwb
|
||||
\inheaderfile iactioncontainer.h
|
||||
|
||||
\brief The class...
|
||||
|
||||
The Action Container interface...
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum IActionContainer::ContainerType
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum IActionContainer::EmptyAction
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual IActionContainer::setEmptyAction(EmptyAction ea)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int IActionContainer::id() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ContainerType IActionContainer::type() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QMenu *IActionContainer::menu() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QToolBar *IActionContainer::toolBar() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QMenuBar *IActionContainer::menuBar() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QAction *IActionContainer::insertLocation(const QString &group) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void IActionContainer::appendGroup(const QString &group, bool global)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void IActionContainer::addAction(Core::ICommand *action, const QString &group)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void IActionContainer::addMenu(Core::IActionContainer *menu, const QString &group)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool IActionContainer::update()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual IActionContainer::~IActionContainer()
|
||||
*/
|
||||
|
||||
// ---------- ActionContainer ------------
|
||||
|
||||
/*!
|
||||
\class ActionContainer
|
||||
\ingroup qwb
|
||||
\inheaderfile actioncontainer.h
|
||||
\mainclass
|
||||
|
||||
\brief The ActionContainer class represents a menu or menu bar in Qt Creator.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum ActionContainer::ContainerState
|
||||
\enum ActionContainer::ContainerType
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ActionContainer::ActionContainer(ContainerType type, int id)
|
||||
\enum ActionContainer::EmptyAction
|
||||
*/
|
||||
ActionContainer::ActionContainer(ContainerType type, int id)
|
||||
: m_data(CS_None), m_type(type), m_id(id)
|
||||
{
|
||||
|
||||
}
|
||||
/*!
|
||||
\fn virtual ActionContainer::setEmptyAction(EmptyAction ea)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int ActionContainer::id() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ContainerType ActionContainer::type() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QMenu *ActionContainer::menu() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QToolBar *ActionContainer::toolBar() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QMenuBar *ActionContainer::menuBar() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QAction *ActionContainer::insertLocation(const QString &group) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ActionContainer::appendGroup(const QString &group, bool global)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ActionContainer::addAction(Core::Command *action, const QString &group)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ActionContainer::addMenu(Core::ActionContainer *menu, const QString &group)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool ActionContainer::update()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ActionContainer::~ActionContainer()
|
||||
*/
|
||||
|
||||
// ---------- ActionContainerPrivate ------------
|
||||
|
||||
/*!
|
||||
...
|
||||
\class Core::Internal::ActionContainerPrivate
|
||||
\internal
|
||||
*/
|
||||
void ActionContainer::setEmptyAction(EmptyAction ea)
|
||||
|
||||
ActionContainerPrivate::ActionContainerPrivate(int id)
|
||||
: m_data(CS_None), m_id(id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::setEmptyAction(EmptyAction ea)
|
||||
{
|
||||
m_data = ((m_data & ~EA_Mask) | ea);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool ActionContainer::hasEmptyAction(EmptyAction ea) const
|
||||
bool ActionContainerPrivate::hasEmptyAction(EmptyAction ea) const
|
||||
{
|
||||
return (m_data & EA_Mask) == ea;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionContainer::setState(ContainerState state)
|
||||
void ActionContainerPrivate::setState(ContainerState state)
|
||||
{
|
||||
m_data |= state;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool ActionContainer::hasState(ContainerState state) const
|
||||
bool ActionContainerPrivate::hasState(ContainerState state) const
|
||||
{
|
||||
return (m_data & state);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionContainer::appendGroup(const QString &group, bool global)
|
||||
void ActionContainerPrivate::appendGroup(const QString &group)
|
||||
{
|
||||
UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager();
|
||||
int gid = idmanager->uniqueIdentifier(group);
|
||||
m_groups << gid;
|
||||
if (global)
|
||||
ActionManager::instance()->registerGlobalGroup(gid, m_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QAction *ActionContainer::insertLocation(const QString &group) const
|
||||
QAction *ActionContainerPrivate::insertLocation(const QString &group) const
|
||||
{
|
||||
UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager();
|
||||
int grpid = idmanager->uniqueIdentifier(group);
|
||||
@@ -196,41 +164,22 @@ QAction *ActionContainer::insertLocation(const QString &group) const
|
||||
return beforeAction(pos, &prevKey);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual void ActionContainer::insertAction(QAction *before, QAction *action) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ActionContainer::insertMenu(QAction *before, QMenu *menu) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<ICommand *> ActionContainer::commands() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<IActionContainer *> ActionContainer::subContainers() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionContainer::addAction(ICommand *action, const QString &group)
|
||||
void ActionContainerPrivate::addAction(Command *action, const QString &group)
|
||||
{
|
||||
if (!canAddAction(action))
|
||||
return;
|
||||
|
||||
ActionManager *am = ActionManager::instance();
|
||||
ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
||||
Action *a = static_cast<Action *>(action);
|
||||
if (a->stateFlags() & Command::CS_PreLocation) {
|
||||
if (a->stateFlags() & CommandPrivate::CS_PreLocation) {
|
||||
QList<CommandLocation> locs = a->locations();
|
||||
for (int i=0; i<locs.size(); ++i) {
|
||||
if (IActionContainer *aci = am->actionContainer(locs.at(i).m_container)) {
|
||||
ActionContainer *ac = static_cast<ActionContainer *>(aci);
|
||||
if (ActionContainer *aci = am->actionContainer(locs.at(i).m_container)) {
|
||||
ActionContainerPrivate *ac = static_cast<ActionContainerPrivate *>(aci);
|
||||
ac->addAction(action, locs.at(i).m_position, false);
|
||||
}
|
||||
}
|
||||
a->setStateFlags(a->stateFlags() | Command::CS_Initialized);
|
||||
a->setStateFlags(a->stateFlags() | CommandPrivate::CS_Initialized);
|
||||
} else {
|
||||
UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager();
|
||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||
@@ -243,23 +192,21 @@ void ActionContainer::addAction(ICommand *action, const QString &group)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionContainer::addMenu(IActionContainer *menu, const QString &group)
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group)
|
||||
{
|
||||
if (!canAddMenu(menu))
|
||||
ActionContainerPrivate *container = static_cast<ActionContainerPrivate *>(menu);
|
||||
if (!container->canBeAddedToMenu())
|
||||
return;
|
||||
|
||||
ActionManager *am = ActionManager::instance();
|
||||
ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
||||
MenuActionContainer *mc = static_cast<MenuActionContainer *>(menu);
|
||||
if (mc->hasState(ActionContainer::CS_PreLocation)) {
|
||||
if (mc->hasState(ActionContainerPrivate::CS_PreLocation)) {
|
||||
CommandLocation loc = mc->location();
|
||||
if (IActionContainer *aci = am->actionContainer(loc.m_container)) {
|
||||
ActionContainer *ac = static_cast<ActionContainer *>(aci);
|
||||
if (ActionContainer *aci = am->actionContainer(loc.m_container)) {
|
||||
ActionContainerPrivate *ac = static_cast<ActionContainerPrivate *>(aci);
|
||||
ac->addMenu(menu, loc.m_position, false);
|
||||
}
|
||||
mc->setState(ActionContainer::CS_Initialized);
|
||||
mc->setState(ActionContainerPrivate::CS_Initialized);
|
||||
} else {
|
||||
UniqueIDManager *idmanager = CoreImpl::instance()->uniqueIDManager();
|
||||
int grpid = idmanager->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||
@@ -272,80 +219,34 @@ void ActionContainer::addMenu(IActionContainer *menu, const QString &group)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
int ActionContainer::id() const
|
||||
int ActionContainerPrivate::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
IActionContainer::ContainerType ActionContainer::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QMenu *ActionContainer::menu() const
|
||||
QMenu *ActionContainerPrivate::menu() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QToolBar *ActionContainer::toolBar() const
|
||||
QMenuBar *ActionContainerPrivate::menuBar() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QMenuBar *ActionContainer::menuBar() const
|
||||
bool ActionContainerPrivate::canAddAction(Command *action) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool ActionContainer::canAddAction(ICommand *action) const
|
||||
{
|
||||
if (action->type() != ICommand::CT_OverridableAction)
|
||||
if (action->type() != Command::CT_OverridableAction)
|
||||
return false;
|
||||
|
||||
Command *cmd = static_cast<Command *>(action);
|
||||
if (cmd->stateFlags() & Command::CS_Initialized)
|
||||
CommandPrivate *cmd = static_cast<CommandPrivate *>(action);
|
||||
if (cmd->stateFlags() & CommandPrivate::CS_Initialized)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool ActionContainer::canAddMenu(IActionContainer *menu) const
|
||||
{
|
||||
if (menu->type() != IActionContainer::CT_Menu)
|
||||
return false;
|
||||
|
||||
ActionContainer *container = static_cast<ActionContainer *>(menu);
|
||||
if (container->hasState(ActionContainer::CS_Initialized))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionContainer::addAction(ICommand *action, int pos, bool setpos)
|
||||
void ActionContainerPrivate::addAction(Command *action, int pos, bool setpos)
|
||||
{
|
||||
Action *a = static_cast<Action *>(action);
|
||||
|
||||
@@ -367,10 +268,7 @@ void ActionContainer::addAction(ICommand *action, int pos, bool setpos)
|
||||
insertAction(ba, a->action());
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionContainer::addMenu(IActionContainer *menu, int pos, bool setpos)
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *menu, int pos, bool setpos)
|
||||
{
|
||||
MenuActionContainer *mc = static_cast<MenuActionContainer *>(menu);
|
||||
|
||||
@@ -390,13 +288,9 @@ void ActionContainer::addMenu(IActionContainer *menu, int pos, bool setpos)
|
||||
insertMenu(ba, mc->menu());
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
\internal
|
||||
*/
|
||||
QAction *ActionContainer::beforeAction(int pos, int *prevKey) const
|
||||
QAction *ActionContainerPrivate::beforeAction(int pos, int *prevKey) const
|
||||
{
|
||||
ActionManager *am = ActionManager::instance();
|
||||
ActionManagerPrivate *am = ActionManagerPrivate::instance();
|
||||
|
||||
int baId = -1;
|
||||
|
||||
@@ -415,20 +309,16 @@ QAction *ActionContainer::beforeAction(int pos, int *prevKey) const
|
||||
if (baId == -1)
|
||||
return 0;
|
||||
|
||||
if (ICommand *cmd = am->command(baId))
|
||||
if (Command *cmd = am->command(baId))
|
||||
return cmd->action();
|
||||
if (IActionContainer *container = am->actionContainer(baId))
|
||||
if (ActionContainer *container = am->actionContainer(baId))
|
||||
if (QMenu *menu = container->menu())
|
||||
return menu->menuAction();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
\internal
|
||||
*/
|
||||
int ActionContainer::calcPosition(int pos, int prevKey) const
|
||||
int ActionContainerPrivate::calcPosition(int pos, int prevKey) const
|
||||
{
|
||||
int grp = (pos & 0xFFFF0000);
|
||||
if (prevKey == -1)
|
||||
@@ -445,23 +335,16 @@ int ActionContainer::calcPosition(int pos, int prevKey) const
|
||||
// ---------- MenuActionContainer ------------
|
||||
|
||||
/*!
|
||||
\class MenuActionContainer
|
||||
\ingroup qwb
|
||||
\inheaderfile actioncontainer.h
|
||||
\class Core::Internal::MenuActionContainer
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
MenuActionContainer::MenuActionContainer(int id)
|
||||
: ActionContainer(CT_Menu, id), m_menu(0)
|
||||
: ActionContainerPrivate(id), m_menu(0)
|
||||
{
|
||||
setEmptyAction(EA_Disable);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void MenuActionContainer::setMenu(QMenu *menu)
|
||||
{
|
||||
m_menu = menu;
|
||||
@@ -472,49 +355,31 @@ void MenuActionContainer::setMenu(QMenu *menu)
|
||||
m_menu->menuAction()->setData(v);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QMenu *MenuActionContainer::menu() const
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void MenuActionContainer::insertAction(QAction *before, QAction *action)
|
||||
{
|
||||
m_menu->insertAction(before, action);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void MenuActionContainer::insertMenu(QAction *before, QMenu *menu)
|
||||
{
|
||||
m_menu->insertMenu(before, menu);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void MenuActionContainer::setLocation(const CommandLocation &location)
|
||||
{
|
||||
m_location = location;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
CommandLocation MenuActionContainer::location() const
|
||||
{
|
||||
return m_location;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool MenuActionContainer::update()
|
||||
{
|
||||
if (hasEmptyAction(EA_None))
|
||||
@@ -522,7 +387,7 @@ bool MenuActionContainer::update()
|
||||
|
||||
bool hasitems = false;
|
||||
|
||||
foreach (IActionContainer *container, subContainers()) {
|
||||
foreach (ActionContainer *container, subContainers()) {
|
||||
if (container == this) {
|
||||
qWarning() << Q_FUNC_INFO << "container" << (this->menu() ? this->menu()->title() : "") << "contains itself as subcontainer";
|
||||
continue;
|
||||
@@ -533,7 +398,7 @@ bool MenuActionContainer::update()
|
||||
}
|
||||
}
|
||||
if (!hasitems) {
|
||||
foreach (ICommand *command, commands()) {
|
||||
foreach (Command *command, commands()) {
|
||||
if (command->isActive()) {
|
||||
hasitems = true;
|
||||
break;
|
||||
@@ -549,131 +414,48 @@ bool MenuActionContainer::update()
|
||||
return hasitems;
|
||||
}
|
||||
|
||||
// ---------- ToolBarActionContainer ------------
|
||||
|
||||
/*!
|
||||
\class ToolBarActionContainer
|
||||
\ingroup qwb
|
||||
\inheaderfile actioncontainer.h
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ToolBarActionContainer::ToolBarActionContainer(int id)
|
||||
: ActionContainer(CT_ToolBar, id), m_toolBar(0)
|
||||
bool MenuActionContainer::canBeAddedToMenu() const
|
||||
{
|
||||
setEmptyAction(EA_None);
|
||||
if (hasState(ActionContainerPrivate::CS_Initialized))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ToolBarActionContainer::setToolBar(QToolBar *toolBar)
|
||||
{
|
||||
m_toolBar = toolBar;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QToolBar *ToolBarActionContainer::toolBar() const
|
||||
{
|
||||
return m_toolBar;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ToolBarActionContainer::insertAction(QAction *before, QAction *action)
|
||||
{
|
||||
m_toolBar->insertAction(before, action);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ToolBarActionContainer::insertMenu(QAction *, QMenu *)
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool ToolBarActionContainer::update()
|
||||
{
|
||||
if (hasEmptyAction(EA_None))
|
||||
return true;
|
||||
|
||||
bool hasitems = false;
|
||||
foreach (ICommand *command, commands()) {
|
||||
if (command->isActive()) {
|
||||
hasitems = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasEmptyAction(EA_Hide))
|
||||
m_toolBar->setVisible(hasitems);
|
||||
else if (hasEmptyAction(EA_Disable))
|
||||
m_toolBar->setEnabled(hasitems);
|
||||
|
||||
return hasitems;
|
||||
}
|
||||
|
||||
// ---------- MenuBarActionContainer ------------
|
||||
|
||||
/*!
|
||||
\class MenuBarActionContainer
|
||||
\ingroup qwb
|
||||
\inheaderfile actioncontainer.h
|
||||
\class Core::Internal::MenuBarActionContainer
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
MenuBarActionContainer::MenuBarActionContainer(int id)
|
||||
: ActionContainer(CT_ToolBar, id), m_menuBar(0)
|
||||
: ActionContainerPrivate(id), m_menuBar(0)
|
||||
{
|
||||
setEmptyAction(EA_None);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void MenuBarActionContainer::setMenuBar(QMenuBar *menuBar)
|
||||
{
|
||||
m_menuBar = menuBar;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QMenuBar *MenuBarActionContainer::menuBar() const
|
||||
{
|
||||
return m_menuBar;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void MenuBarActionContainer::insertAction(QAction *before, QAction *action)
|
||||
{
|
||||
m_menuBar->insertAction(before, action);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void MenuBarActionContainer::insertMenu(QAction *before, QMenu *menu)
|
||||
{
|
||||
m_menuBar->insertMenu(before, menu);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool MenuBarActionContainer::update()
|
||||
{
|
||||
if (hasEmptyAction(EA_None))
|
||||
@@ -695,3 +477,9 @@ bool MenuBarActionContainer::update()
|
||||
|
||||
return hasitems;
|
||||
}
|
||||
|
||||
bool MenuBarActionContainer::canBeAddedToMenu() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -34,123 +34,42 @@
|
||||
#ifndef ACTIONCONTAINER_H
|
||||
#define ACTIONCONTAINER_H
|
||||
|
||||
#include "actionmanager.h"
|
||||
|
||||
#include <coreplugin/actionmanager/iactioncontainer.h>
|
||||
#include <coreplugin/actionmanager/icommand.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QtGui/QAction>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class ActionContainer : public Core::IActionContainer
|
||||
class Command;
|
||||
|
||||
class ActionContainer : public QObject
|
||||
{
|
||||
public:
|
||||
enum ContainerState {
|
||||
CS_None = 0x000000,
|
||||
CS_Initialized = 0x010000,
|
||||
CS_PreLocation = 0x020000,
|
||||
CS_UserDefined = 0x040000
|
||||
enum EmptyAction {
|
||||
EA_Mask = 0xFF00,
|
||||
EA_None = 0x0100,
|
||||
EA_Hide = 0x0200,
|
||||
EA_Disable = 0x0300
|
||||
};
|
||||
|
||||
ActionContainer(ContainerType type, int id);
|
||||
virtual void setEmptyAction(EmptyAction ea) = 0;
|
||||
|
||||
virtual int id() const = 0;
|
||||
|
||||
virtual QMenu *menu() const = 0;
|
||||
virtual QMenuBar *menuBar() const = 0;
|
||||
|
||||
virtual QAction *insertLocation(const QString &group) const = 0;
|
||||
virtual void appendGroup(const QString &group) = 0;
|
||||
virtual void addAction(Core::Command *action, const QString &group = QString()) = 0;
|
||||
virtual void addMenu(Core::ActionContainer *menu, const QString &group = QString()) = 0;
|
||||
|
||||
virtual bool update() = 0;
|
||||
virtual ~ActionContainer() {}
|
||||
|
||||
void setEmptyAction(EmptyAction ea);
|
||||
bool hasEmptyAction(EmptyAction ea) const;
|
||||
|
||||
void setState(ContainerState state);
|
||||
bool hasState(ContainerState state) const;
|
||||
|
||||
QAction *insertLocation(const QString &group) const;
|
||||
void appendGroup(const QString &group, bool global = false);
|
||||
void addAction(ICommand *action, const QString &group = QString());
|
||||
void addMenu(IActionContainer *menu, const QString &group = QString());
|
||||
|
||||
int id() const;
|
||||
ContainerType type() const;
|
||||
|
||||
QMenu *menu() const;
|
||||
QToolBar *toolBar() const;
|
||||
QMenuBar *menuBar() const;
|
||||
|
||||
virtual void insertAction(QAction *before, QAction *action) = 0;
|
||||
virtual void insertMenu(QAction *before, QMenu *menu) = 0;
|
||||
|
||||
QList<ICommand *> commands() const { return m_commands; }
|
||||
QList<IActionContainer *> subContainers() const { return m_subContainers; }
|
||||
protected:
|
||||
bool canAddAction(ICommand *action) const;
|
||||
bool canAddMenu(IActionContainer *menu) const;
|
||||
|
||||
void addAction(ICommand *action, int pos, bool setpos);
|
||||
void addMenu(IActionContainer *menu, int pos, bool setpos);
|
||||
|
||||
private:
|
||||
QAction *beforeAction(int pos, int *prevKey) const;
|
||||
int calcPosition(int pos, int prevKey) const;
|
||||
|
||||
QList<int> m_groups;
|
||||
int m_data;
|
||||
ContainerType m_type;
|
||||
int m_id;
|
||||
QMap<int, int> m_posmap;
|
||||
QList<IActionContainer *> m_subContainers;
|
||||
QList<ICommand *> m_commands;
|
||||
};
|
||||
|
||||
class MenuActionContainer : public ActionContainer
|
||||
{
|
||||
public:
|
||||
MenuActionContainer(int id);
|
||||
|
||||
void setMenu(QMenu *menu);
|
||||
QMenu *menu() const;
|
||||
|
||||
void setLocation(const CommandLocation &location);
|
||||
CommandLocation location() const;
|
||||
|
||||
void insertAction(QAction *before, QAction *action);
|
||||
void insertMenu(QAction *before, QMenu *menu);
|
||||
bool update();
|
||||
|
||||
private:
|
||||
QMenu *m_menu;
|
||||
CommandLocation m_location;
|
||||
};
|
||||
|
||||
class ToolBarActionContainer : public ActionContainer
|
||||
{
|
||||
public:
|
||||
ToolBarActionContainer(int id);
|
||||
|
||||
void setToolBar(QToolBar *toolBar);
|
||||
QToolBar *toolBar() const;
|
||||
|
||||
void insertAction(QAction *before, QAction *action);
|
||||
void insertMenu(QAction *before, QMenu *menu);
|
||||
bool update();
|
||||
|
||||
private:
|
||||
QToolBar *m_toolBar;
|
||||
};
|
||||
|
||||
class MenuBarActionContainer : public ActionContainer
|
||||
{
|
||||
public:
|
||||
MenuBarActionContainer(int id);
|
||||
|
||||
void setMenuBar(QMenuBar *menuBar);
|
||||
QMenuBar *menuBar() const;
|
||||
|
||||
void insertAction(QAction *before, QAction *action);
|
||||
void insertMenu(QAction *before, QMenu *menu);
|
||||
bool update();
|
||||
|
||||
private:
|
||||
QMenuBar *m_menuBar;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // ACTIONCONTAINER_H
|
||||
|
||||
142
src/plugins/coreplugin/actionmanager/actioncontainer_p.h
Normal file
142
src/plugins/coreplugin/actionmanager/actioncontainer_p.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ACTIONCONTAINER_P_H
|
||||
#define ACTIONCONTAINER_P_H
|
||||
|
||||
#include "actionmanager_p.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class ActionContainerPrivate : public Core::ActionContainer
|
||||
{
|
||||
public:
|
||||
enum ContainerState {
|
||||
CS_None = 0x000000,
|
||||
CS_Initialized = 0x010000,
|
||||
CS_PreLocation = 0x020000,
|
||||
CS_UserDefined = 0x040000
|
||||
};
|
||||
|
||||
ActionContainerPrivate(int id);
|
||||
virtual ~ActionContainerPrivate() {}
|
||||
|
||||
void setEmptyAction(EmptyAction ea);
|
||||
bool hasEmptyAction(EmptyAction ea) const;
|
||||
|
||||
void setState(ContainerState state);
|
||||
bool hasState(ContainerState state) const;
|
||||
|
||||
QAction *insertLocation(const QString &group) const;
|
||||
void appendGroup(const QString &group);
|
||||
void addAction(Command *action, const QString &group = QString());
|
||||
void addMenu(ActionContainer *menu, const QString &group = QString());
|
||||
|
||||
int id() const;
|
||||
|
||||
QMenu *menu() const;
|
||||
QMenuBar *menuBar() const;
|
||||
|
||||
virtual void insertAction(QAction *before, QAction *action) = 0;
|
||||
virtual void insertMenu(QAction *before, QMenu *menu) = 0;
|
||||
|
||||
QList<Command *> commands() const { return m_commands; }
|
||||
QList<ActionContainer *> subContainers() const { return m_subContainers; }
|
||||
protected:
|
||||
bool canAddAction(Command *action) const;
|
||||
bool canAddMenu(ActionContainer *menu) const;
|
||||
virtual bool canBeAddedToMenu() const = 0;
|
||||
|
||||
void addAction(Command *action, int pos, bool setpos);
|
||||
void addMenu(ActionContainer *menu, int pos, bool setpos);
|
||||
|
||||
private:
|
||||
QAction *beforeAction(int pos, int *prevKey) const;
|
||||
int calcPosition(int pos, int prevKey) const;
|
||||
|
||||
QList<int> m_groups;
|
||||
int m_data;
|
||||
int m_id;
|
||||
QMap<int, int> m_posmap;
|
||||
QList<ActionContainer *> m_subContainers;
|
||||
QList<Command *> m_commands;
|
||||
};
|
||||
|
||||
class MenuActionContainer : public ActionContainerPrivate
|
||||
{
|
||||
public:
|
||||
MenuActionContainer(int id);
|
||||
|
||||
void setMenu(QMenu *menu);
|
||||
QMenu *menu() const;
|
||||
|
||||
void setLocation(const CommandLocation &location);
|
||||
CommandLocation location() const;
|
||||
|
||||
void insertAction(QAction *before, QAction *action);
|
||||
void insertMenu(QAction *before, QMenu *menu);
|
||||
bool update();
|
||||
|
||||
protected:
|
||||
bool canBeAddedToMenu() const;
|
||||
private:
|
||||
QMenu *m_menu;
|
||||
CommandLocation m_location;
|
||||
};
|
||||
|
||||
class MenuBarActionContainer : public ActionContainerPrivate
|
||||
{
|
||||
public:
|
||||
MenuBarActionContainer(int id);
|
||||
|
||||
void setMenuBar(QMenuBar *menuBar);
|
||||
QMenuBar *menuBar() const;
|
||||
|
||||
void insertAction(QAction *before, QAction *action);
|
||||
void insertMenu(QAction *before, QMenu *menu);
|
||||
bool update();
|
||||
|
||||
protected:
|
||||
bool canBeAddedToMenu() const;
|
||||
private:
|
||||
QMenuBar *m_menuBar;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // ACTIONCONTAINER_P_H
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -31,10 +31,10 @@
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#include "actionmanager.h"
|
||||
#include "actionmanager_p.h"
|
||||
#include "mainwindow.h"
|
||||
#include "actioncontainer.h"
|
||||
#include "command.h"
|
||||
#include "actioncontainer_p.h"
|
||||
#include "command_p.h"
|
||||
#include "uniqueidmanager.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QMenuBar>
|
||||
|
||||
namespace {
|
||||
@@ -52,115 +51,163 @@ namespace {
|
||||
}
|
||||
|
||||
/*!
|
||||
\class Core::ActionManagerInterface
|
||||
\class Core::ActionManager
|
||||
\mainclass
|
||||
\ingroup qwb
|
||||
\inheaderfile actionmanagerinterface.h
|
||||
|
||||
\brief All actions should be registered in the ActionManager, since this enables the user to
|
||||
e.g. change their shortcuts at a central place.
|
||||
\brief The action manager is responsible for registration of menus and
|
||||
menu items and keyboard shortcuts.
|
||||
|
||||
The ActionManagerInterface is the central bookkeeper of actions and their shortcuts and layout.
|
||||
You get the only implementation of this class from the core interface (ICore::actionManager()).
|
||||
The ActionManager is the central bookkeeper of actions and their shortcuts and layout.
|
||||
You get the only implementation of this class from the core interface
|
||||
ICore::actionManager() method, e.g.
|
||||
\code
|
||||
ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->actionManager()
|
||||
\endcode
|
||||
|
||||
The main reasons for the need of this class is to provide a central place where the user
|
||||
can specify all his keyboard shortcuts, and to provide a solution for actions that should
|
||||
behave differently in different contexts (like the copy/replace/undo/redo actions).
|
||||
|
||||
All actions that are registered with the same string id (but different context lists)
|
||||
are considered to be overloads of the same command. The action that is visible to the user
|
||||
is the one returned by ICommand::action(). (If you provide yourself a user visible
|
||||
representation of your action be sure to always use ICommand::action() for this.)
|
||||
If this action is invoked by the user, the signal is forwarded to the registered action that
|
||||
is valid for the current context.
|
||||
are considered to be overloads of the same command, represented by an instance
|
||||
of the Command class.
|
||||
The action that is visible to the user is the one returned by Command::action().
|
||||
If you provide yourself a user visible representation of your action you need
|
||||
to use Command::action() for this.
|
||||
When this action is invoked by the user,
|
||||
the signal is forwarded to the registered action that is valid for the current context.
|
||||
|
||||
You use this class also to add items to registered
|
||||
action containers like the applications menu bar. For this you register your action via the
|
||||
So to register a globally active action "My Action"
|
||||
put the following in your plugin's IPlugin::initialize method:
|
||||
\code
|
||||
Core::ActionManager *am = ExtensionSystem::PluginManager::instance()
|
||||
->getObject<Core::ICore>()->actionManager();
|
||||
QAction *myAction = new QAction(tr("My Action"), this);
|
||||
Core::Command *cmd = am->registerAction(myAction,
|
||||
"myplugin.myaction",
|
||||
QList<int>() << C_GLOBAL_ID);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+u")));
|
||||
connect(myAction, SIGNAL(triggered()), this, SLOT(performMyAction()));
|
||||
\endcode
|
||||
|
||||
So the \c connect is done to your own QAction instance. If you create e.g.
|
||||
a tool button that should represent the action you add the action
|
||||
from Command::action() to it:
|
||||
\code
|
||||
QToolButton *myButton = new QToolButton(someParentWidget);
|
||||
myButton->setDefaultAction(cmd->action());
|
||||
\endcode
|
||||
|
||||
Also use the ActionManager to add items to registered
|
||||
action containers like the applications menu bar or menus in that menu bar.
|
||||
To do this, you register your action via the
|
||||
registerAction methods, get the action container for a specific id (like specified in
|
||||
Core::Constants) with a call of
|
||||
the Core::Constants namespace) with a call of
|
||||
actionContainer(const QString&) and add your command to this container.
|
||||
|
||||
Guidelines:
|
||||
Following the example adding "My Action" to the "Tools" menu would be done by
|
||||
\code
|
||||
am->actionContainer(Core::M_TOOLS)->addAction(cmd);
|
||||
\endcode
|
||||
|
||||
Important guidelines:
|
||||
\list
|
||||
\o Always register your actions and shortcuts!
|
||||
\o Register your actions and shortcuts during your plugin's IPlugin::initialize
|
||||
or IPlugin::extensionsInitialized methods, otherwise the shortcuts won't appear
|
||||
in the keyboard settings dialog from the beginning.
|
||||
\o When registering an action with cmd=registerAction(action, id, contexts) be sure to connect
|
||||
your own action connect(action, SIGNAL...) but make cmd->action() visible to the user, i.e.
|
||||
widget->addAction(cmd->action()).
|
||||
\o Use this class to add actions to the applications menus
|
||||
\endlist
|
||||
|
||||
\sa Core::ICore, Core::ICommand
|
||||
\sa Core::IActionContainer
|
||||
\sa Core::ICore
|
||||
\sa Core::Command
|
||||
\sa Core::ActionContainer
|
||||
\sa Core::IContext
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual IActionContainer *ActionManagerInterface::createMenu(const QString &id) = 0
|
||||
...
|
||||
\fn ActionContainer *ActionManager::createMenu(const QString &id)
|
||||
\brief Creates a new menu with the given string \a id.
|
||||
|
||||
Returns a new ActionContainer that you can use to get the QMenu instance
|
||||
or to add menu items to the menu. The ActionManager owns
|
||||
the returned ActionContainer.
|
||||
Add your menu to some other menu or a menu bar via the
|
||||
ActionManager::actionContainer and ActionContainer::addMenu methods.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual IActionContainer *ActionManagerInterface::createMenuBar(const QString &id) = 0
|
||||
...
|
||||
\fn ActionContainer *ActionManager::createMenuBar(const QString &id)
|
||||
\brief Creates a new menu bar with the given string \a id.
|
||||
|
||||
Returns a new ActionContainer that you can use to get the QMenuBar instance
|
||||
or to add menus to the menu bar. The ActionManager owns
|
||||
the returned ActionContainer.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ICommand *ActionManagerInterface::registerAction(QAction *action, const QString &id, const QList<int> &context) = 0
|
||||
...
|
||||
\fn Command *ActionManager::registerAction(QAction *action, const QString &id, const QList<int> &context)
|
||||
\brief Makes an \a action known to the system under the specified string \a id.
|
||||
|
||||
Returns a command object that represents the action in the application and is
|
||||
owned by the ActionManager. You can registered several actions with the
|
||||
same \a id as long as the \a context is different. In this case
|
||||
a trigger of the actual action is forwarded to the registered QAction
|
||||
for the currently active context.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ICommand *ActionManagerInterface::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context) = 0
|
||||
...
|
||||
\fn Command *ActionManager::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
|
||||
\brief Makes a \a shortcut known to the system under the specified string \a id.
|
||||
|
||||
Returns a command object that represents the shortcut in the application and is
|
||||
owned by the ActionManager. You can registered several shortcuts with the
|
||||
same \a id as long as the \a context is different. In this case
|
||||
a trigger of the actual shortcut is forwarded to the registered QShortcut
|
||||
for the currently active context.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ICommand *ActionManagerInterface::registerAction(QAction *action, const QString &id) = 0
|
||||
...
|
||||
\fn Command *ActionManager::command(const QString &id) const
|
||||
\brief Returns the Command object that is known to the system
|
||||
under the given string \a id.
|
||||
|
||||
\sa ActionManager::registerAction()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ActionManagerInterface::addAction(ICommand *action, const QString &globalGroup) = 0
|
||||
...
|
||||
*/
|
||||
\fn ActionContainer *ActionManager::actionContainer(const QString &id) const
|
||||
\brief Returns the IActionContainter object that is know to the system
|
||||
under the given string \a id.
|
||||
|
||||
/*!
|
||||
\fn virtual void ActionManagerInterface::addMenu(IActionContainer *menu, const QString &globalGroup) = 0
|
||||
...
|
||||
\sa ActionManager::createMenu()
|
||||
\sa ActionManager::createMenuBar()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ICommand *ActionManagerInterface::command(const QString &id) const = 0
|
||||
...
|
||||
\fn ActionManager::ActionManager(QObject *parent)
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual IActionContainer *ActionManagerInterface::actionContainer(const QString &id) const = 0
|
||||
...
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ActionManagerInterface::~ActionManagerInterface()
|
||||
...
|
||||
\fn ActionManager::~ActionManager()
|
||||
\internal
|
||||
*/
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
ActionManager* ActionManager::m_instance = 0;
|
||||
ActionManagerPrivate* ActionManagerPrivate::m_instance = 0;
|
||||
|
||||
/*!
|
||||
\class ActionManager
|
||||
\ingroup qwb
|
||||
\inheaderfile actionmanager.h
|
||||
|
||||
\sa ActionContainer
|
||||
\class ActionManagerPrivate
|
||||
\inheaderfile actionmanager_p.h
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ActionManager::ActionManager(MainWindow *mainWnd, UniqueIDManager *uidmgr) :
|
||||
ActionManagerInterface(mainWnd),
|
||||
ActionManagerPrivate::ActionManagerPrivate(MainWindow *mainWnd, UniqueIDManager *uidmgr) :
|
||||
ActionManager(mainWnd),
|
||||
m_mainWnd(mainWnd)
|
||||
{
|
||||
m_defaultGroups << uidmgr->uniqueIdentifier(Constants::G_DEFAULT_ONE);
|
||||
@@ -170,73 +217,38 @@ ActionManager::ActionManager(MainWindow *mainWnd, UniqueIDManager *uidmgr) :
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ActionManager::~ActionManager()
|
||||
ActionManagerPrivate::~ActionManagerPrivate()
|
||||
{
|
||||
qDeleteAll(m_idCmdMap.values());
|
||||
qDeleteAll(m_idContainerMap.values());
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ActionManager* ActionManager::instance()
|
||||
ActionManagerPrivate* ActionManagerPrivate::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QList<int> ActionManager::defaultGroups() const
|
||||
QList<int> ActionManagerPrivate::defaultGroups() const
|
||||
{
|
||||
return m_defaultGroups;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QList<Command *> ActionManager::commands() const
|
||||
QList<CommandPrivate *> ActionManagerPrivate::commands() const
|
||||
{
|
||||
return m_idCmdMap.values();
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QList<ActionContainer *> ActionManager::containers() const
|
||||
QList<ActionContainerPrivate *> ActionManagerPrivate::containers() const
|
||||
{
|
||||
return m_idContainerMap.values();
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionManager::registerGlobalGroup(int groupId, int containerId)
|
||||
{
|
||||
if (m_globalgroups.contains(groupId)) {
|
||||
qWarning() << "registerGlobalGroup: Global group "
|
||||
<< m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(groupId)
|
||||
<< " already registered";
|
||||
} else {
|
||||
m_globalgroups.insert(groupId, containerId);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool ActionManager::hasContext(int context) const
|
||||
bool ActionManagerPrivate::hasContext(int context) const
|
||||
{
|
||||
return m_context.contains(context);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionManager::setContext(const QList<int> &context)
|
||||
void ActionManagerPrivate::setContext(const QList<int> &context)
|
||||
{
|
||||
// here are possibilities for speed optimization if necessary:
|
||||
// let commands (de-)register themselves for contexts
|
||||
@@ -251,10 +263,7 @@ void ActionManager::setContext(const QList<int> &context)
|
||||
it.value()->update();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
bool ActionManager::hasContext(QList<int> context) const
|
||||
bool ActionManagerPrivate::hasContext(QList<int> context) const
|
||||
{
|
||||
for (int i=0; i<m_context.count(); ++i) {
|
||||
if (context.contains(m_context.at(i)))
|
||||
@@ -263,10 +272,7 @@ bool ActionManager::hasContext(QList<int> context) const
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
IActionContainer *ActionManager::createMenu(const QString &id)
|
||||
ActionContainer *ActionManagerPrivate::createMenu(const QString &id)
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
@@ -284,10 +290,7 @@ IActionContainer *ActionManager::createMenu(const QString &id)
|
||||
return mc;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
IActionContainer *ActionManager::createMenuBar(const QString &id)
|
||||
ActionContainer *ActionManagerPrivate::createMenuBar(const QString &id)
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
@@ -305,36 +308,22 @@ IActionContainer *ActionManager::createMenuBar(const QString &id)
|
||||
return mbc;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ICommand *ActionManager::registerAction(QAction *action, const QString &id, const QList<int> &context)
|
||||
Command *ActionManagerPrivate::registerAction(QAction *action, const QString &id, const QList<int> &context)
|
||||
{
|
||||
OverrideableAction *a = 0;
|
||||
ICommand *c = registerOverridableAction(action, id, false);
|
||||
Command *c = registerOverridableAction(action, id, false);
|
||||
a = static_cast<OverrideableAction *>(c);
|
||||
if (a)
|
||||
a->addOverrideAction(action, context);
|
||||
return a;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ICommand *ActionManager::registerAction(QAction *action, const QString &id)
|
||||
{
|
||||
return registerOverridableAction(action, id, true);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
ICommand *ActionManager::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
|
||||
Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
|
||||
{
|
||||
OverrideableAction *a = 0;
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
if (Command *c = m_idCmdMap.value(uid, 0)) {
|
||||
if (c->type() != ICommand::CT_OverridableAction) {
|
||||
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
||||
if (c->type() != Command::CT_OverridableAction) {
|
||||
qWarning() << "registerAction: id" << id << "is registered with a different command type.";
|
||||
return c;
|
||||
}
|
||||
@@ -375,15 +364,12 @@ ICommand *ActionManager::registerOverridableAction(QAction *action, const QStrin
|
||||
return a;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ICommand *ActionManager::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
|
||||
Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
if (Command *c = m_idCmdMap.value(uid, 0)) {
|
||||
if (c->type() != ICommand::CT_Shortcut) {
|
||||
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
||||
if (c->type() != Command::CT_Shortcut) {
|
||||
qWarning() << "registerShortcut: id" << id << "is registered with a different command type.";
|
||||
return c;
|
||||
}
|
||||
@@ -415,98 +401,47 @@ ICommand *ActionManager::registerShortcut(QShortcut *shortcut, const QString &id
|
||||
return sc;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void ActionManager::addAction(Core::ICommand *action, const QString &globalGroup)
|
||||
*/
|
||||
void ActionManager::addAction(ICommand *action, const QString &globalGroup)
|
||||
{
|
||||
const int gid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(globalGroup);
|
||||
if (!m_globalgroups.contains(gid)) {
|
||||
qWarning() << "addAction: Unknown global group " << globalGroup;
|
||||
return;
|
||||
}
|
||||
|
||||
const int cid = m_globalgroups.value(gid);
|
||||
if (IActionContainer *aci = actionContainer(cid)) {
|
||||
aci->addAction(action, globalGroup);
|
||||
} else {
|
||||
qWarning() << "addAction: Cannot find container." << cid << '/' << gid;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void ActionManager::addMenu(Core::IActionContainer *menu, const QString &globalGroup)
|
||||
|
||||
*/
|
||||
void ActionManager::addMenu(IActionContainer *menu, const QString &globalGroup)
|
||||
{
|
||||
const int gid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(globalGroup);
|
||||
if (!m_globalgroups.contains(gid)) {
|
||||
qWarning() << "addAction: Unknown global group " << globalGroup;
|
||||
return;
|
||||
}
|
||||
|
||||
const int cid = m_globalgroups.value(gid);
|
||||
if (IActionContainer *aci = actionContainer(cid)) {
|
||||
aci->addMenu(menu, globalGroup);
|
||||
} else {
|
||||
qWarning() << "addAction: Cannot find container." << cid << '/' << gid;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ICommand *ActionManager::command(const QString &id) const
|
||||
Command *ActionManagerPrivate::command(const QString &id) const
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const IdCmdMap::const_iterator it = m_idCmdMap.constFind(uid);
|
||||
if (it == m_idCmdMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManager::command(): failed to find :" << id << '/' << uid;
|
||||
qWarning() << "ActionManagerPrivate::command(): failed to find :" << id << '/' << uid;
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
IActionContainer *ActionManager::actionContainer(const QString &id) const
|
||||
ActionContainer *ActionManagerPrivate::actionContainer(const QString &id) const
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
if ( it == m_idContainerMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManager::actionContainer(): failed to find :" << id << '/' << uid;
|
||||
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :" << id << '/' << uid;
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
ICommand *ActionManager::command(int uid) const
|
||||
Command *ActionManagerPrivate::command(int uid) const
|
||||
{
|
||||
const IdCmdMap::const_iterator it = m_idCmdMap.constFind(uid);
|
||||
if (it == m_idCmdMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManager::command(): failed to find :" << m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(uid) << '/' << uid;
|
||||
qWarning() << "ActionManagerPrivate::command(): failed to find :" << m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(uid) << '/' << uid;
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
IActionContainer *ActionManager::actionContainer(int uid) const
|
||||
ActionContainer *ActionManagerPrivate::actionContainer(int uid) const
|
||||
{
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
if (it == m_idContainerMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManager::actionContainer(): failed to find :" << m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(uid) << uid;
|
||||
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :" << m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(uid) << uid;
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
@@ -516,10 +451,7 @@ static const char *settingsGroup = "KeyBindings";
|
||||
static const char *idKey = "ID";
|
||||
static const char *sequenceKey = "Keysequence";
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void ActionManager::initialize()
|
||||
void ActionManagerPrivate::initialize()
|
||||
{
|
||||
QSettings *settings = m_mainWnd->settings();
|
||||
const int shortcuts = settings->beginReadArray(QLatin1String(settingsGroup));
|
||||
@@ -529,17 +461,14 @@ void ActionManager::initialize()
|
||||
const QKeySequence key(settings->value(QLatin1String(sequenceKey)).toString());
|
||||
const int id = m_mainWnd->uniqueIDManager()->uniqueIdentifier(sid);
|
||||
|
||||
ICommand *cmd = command(id);
|
||||
Command *cmd = command(id);
|
||||
if (cmd)
|
||||
cmd->setKeySequence(key);
|
||||
}
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void ActionManager::saveSettings(QSettings *settings)
|
||||
void ActionManagerPrivate::saveSettings(QSettings *settings)
|
||||
{
|
||||
settings->beginWriteArray(QLatin1String(settingsGroup));
|
||||
int count = 0;
|
||||
@@ -547,7 +476,7 @@ void ActionManager::saveSettings(QSettings *settings)
|
||||
const IdCmdMap::const_iterator cmdcend = m_idCmdMap.constEnd();
|
||||
for (IdCmdMap::const_iterator j = m_idCmdMap.constBegin(); j != cmdcend; ++j) {
|
||||
const int id = j.key();
|
||||
Command *cmd = j.value();
|
||||
CommandPrivate *cmd = j.value();
|
||||
QKeySequence key = cmd->keySequence();
|
||||
if (key != cmd->defaultKeySequence()) {
|
||||
const QString sid = m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(id);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -34,97 +34,39 @@
|
||||
#ifndef ACTIONMANAGER_H
|
||||
#define ACTIONMANAGER_H
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanagerinterface.h>
|
||||
#include "coreplugin/core_global.h"
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QMultiHash>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
class QAction;
|
||||
class QShortcut;
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
struct CommandLocation
|
||||
{
|
||||
int m_container;
|
||||
int m_position;
|
||||
};
|
||||
|
||||
namespace Core {
|
||||
|
||||
class UniqueIDManager;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class ActionContainer;
|
||||
class MainWindow;
|
||||
class Command;
|
||||
|
||||
class ActionManager : public Core::ActionManagerInterface
|
||||
class CORE_EXPORT ActionManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ActionManager(MainWindow *mainWnd, UniqueIDManager *uidmgr);
|
||||
~ActionManager();
|
||||
ActionManager(QObject *parent = 0) : QObject(parent) {}
|
||||
virtual ~ActionManager() {}
|
||||
|
||||
void setContext(const QList<int> &context);
|
||||
static ActionManager* instance();
|
||||
virtual ActionContainer *createMenu(const QString &id) = 0;
|
||||
virtual ActionContainer *createMenuBar(const QString &id) = 0;
|
||||
|
||||
void saveSettings(QSettings *settings);
|
||||
QList<int> defaultGroups() const;
|
||||
virtual Command *registerAction(QAction *action, const QString &id, const QList<int> &context) = 0;
|
||||
virtual Command *registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context) = 0;
|
||||
|
||||
QList<Command *> commands() const;
|
||||
QList<ActionContainer *> containers() const;
|
||||
|
||||
bool hasContext(int context) const;
|
||||
|
||||
ICommand *command(int uid) const;
|
||||
IActionContainer *actionContainer(int uid) const;
|
||||
|
||||
void registerGlobalGroup(int groupId, int containerId);
|
||||
|
||||
void initialize();
|
||||
|
||||
//ActionManager Interface
|
||||
IActionContainer *createMenu(const QString &id);
|
||||
IActionContainer *createMenuBar(const QString &id);
|
||||
|
||||
ICommand *registerAction(QAction *action, const QString &id,
|
||||
const QList<int> &context);
|
||||
ICommand *registerAction(QAction *action, const QString &id);
|
||||
ICommand *registerShortcut(QShortcut *shortcut, const QString &id,
|
||||
const QList<int> &context);
|
||||
|
||||
void addAction(Core::ICommand *action, const QString &globalGroup);
|
||||
void addMenu(Core::IActionContainer *menu, const QString &globalGroup);
|
||||
|
||||
Core::ICommand *command(const QString &id) const;
|
||||
Core::IActionContainer *actionContainer(const QString &id) const;
|
||||
|
||||
private:
|
||||
bool hasContext(QList<int> context) const;
|
||||
ICommand *registerOverridableAction(QAction *action, const QString &id,
|
||||
bool checkUnique);
|
||||
|
||||
static ActionManager* m_instance;
|
||||
QList<int> m_defaultGroups;
|
||||
|
||||
typedef QHash<int, Command *> IdCmdMap;
|
||||
IdCmdMap m_idCmdMap;
|
||||
|
||||
typedef QHash<int, ActionContainer *> IdContainerMap;
|
||||
IdContainerMap m_idContainerMap;
|
||||
|
||||
typedef QMap<int, int> GlobalGroupMap;
|
||||
GlobalGroupMap m_globalgroups;
|
||||
|
||||
QList<int> m_context;
|
||||
|
||||
MainWindow *m_mainWnd;
|
||||
virtual Command *command(const QString &id) const = 0;
|
||||
virtual ActionContainer *actionContainer(const QString &id) const = 0;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // ACTIONMANAGER_H
|
||||
|
||||
124
src/plugins/coreplugin/actionmanager/actionmanager_p.h
Normal file
124
src/plugins/coreplugin/actionmanager/actionmanager_p.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ACTIONMANAGERPRIVATE_H
|
||||
#define ACTIONMANAGERPRIVATE_H
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QMultiHash>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
struct CommandLocation
|
||||
{
|
||||
int m_container;
|
||||
int m_position;
|
||||
};
|
||||
|
||||
namespace Core {
|
||||
|
||||
class UniqueIDManager;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class ActionContainerPrivate;
|
||||
class MainWindow;
|
||||
class CommandPrivate;
|
||||
|
||||
class ActionManagerPrivate : public Core::ActionManager
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ActionManagerPrivate(MainWindow *mainWnd, UniqueIDManager *uidmgr);
|
||||
~ActionManagerPrivate();
|
||||
|
||||
void setContext(const QList<int> &context);
|
||||
static ActionManagerPrivate* instance();
|
||||
|
||||
void saveSettings(QSettings *settings);
|
||||
QList<int> defaultGroups() const;
|
||||
|
||||
QList<CommandPrivate *> commands() const;
|
||||
QList<ActionContainerPrivate *> containers() const;
|
||||
|
||||
bool hasContext(int context) const;
|
||||
|
||||
Command *command(int uid) const;
|
||||
ActionContainer *actionContainer(int uid) const;
|
||||
|
||||
void initialize();
|
||||
|
||||
//ActionManager Interface
|
||||
ActionContainer *createMenu(const QString &id);
|
||||
ActionContainer *createMenuBar(const QString &id);
|
||||
|
||||
Command *registerAction(QAction *action, const QString &id,
|
||||
const QList<int> &context);
|
||||
Command *registerShortcut(QShortcut *shortcut, const QString &id,
|
||||
const QList<int> &context);
|
||||
|
||||
Core::Command *command(const QString &id) const;
|
||||
Core::ActionContainer *actionContainer(const QString &id) const;
|
||||
|
||||
private:
|
||||
bool hasContext(QList<int> context) const;
|
||||
Command *registerOverridableAction(QAction *action, const QString &id,
|
||||
bool checkUnique);
|
||||
|
||||
static ActionManagerPrivate* m_instance;
|
||||
QList<int> m_defaultGroups;
|
||||
|
||||
typedef QHash<int, CommandPrivate *> IdCmdMap;
|
||||
IdCmdMap m_idCmdMap;
|
||||
|
||||
typedef QHash<int, ActionContainerPrivate *> IdContainerMap;
|
||||
IdContainerMap m_idContainerMap;
|
||||
|
||||
// typedef QMap<int, int> GlobalGroupMap;
|
||||
// GlobalGroupMap m_globalgroups;
|
||||
//
|
||||
QList<int> m_context;
|
||||
|
||||
MainWindow *m_mainWnd;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // ACTIONMANAGERPRIVATE_H
|
||||
@@ -1,77 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ACTIONMANAGERINTERFACE_H
|
||||
#define ACTIONMANAGERINTERFACE_H
|
||||
|
||||
#include "coreplugin/core_global.h"
|
||||
|
||||
#include <coreplugin/actionmanager/iactioncontainer.h>
|
||||
#include <coreplugin/actionmanager/icommand.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QShortcut;
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CORE_EXPORT ActionManagerInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ActionManagerInterface(QObject *parent = 0) : QObject(parent) {}
|
||||
virtual ~ActionManagerInterface() {}
|
||||
|
||||
virtual IActionContainer *createMenu(const QString &id) = 0;
|
||||
virtual IActionContainer *createMenuBar(const QString &id) = 0;
|
||||
|
||||
virtual ICommand *registerAction(QAction *action, const QString &id, const QList<int> &context) = 0;
|
||||
virtual ICommand *registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context) = 0;
|
||||
|
||||
virtual ICommand *registerAction(QAction *action, const QString &id) = 0;
|
||||
|
||||
virtual void addAction(ICommand *action, const QString &globalGroup) = 0;
|
||||
virtual void addMenu(IActionContainer *menu, const QString &globalGroup) = 0;
|
||||
|
||||
virtual ICommand *command(const QString &id) const = 0;
|
||||
virtual IActionContainer *actionContainer(const QString &id) const = 0;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // ACTIONMANAGERINTERFACE_H
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -35,13 +35,12 @@
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QShortcut>
|
||||
|
||||
#include "command.h"
|
||||
#include "command_p.h"
|
||||
|
||||
/*!
|
||||
\class Core::ICommand
|
||||
\class Core::Command
|
||||
\mainclass
|
||||
\ingroup qwb
|
||||
\inheaderfile icommand.h
|
||||
|
||||
\brief The class...
|
||||
|
||||
@@ -49,226 +48,167 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum ICommand::CommandType
|
||||
\enum Command::CommandType
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum ICommand::CommandAttribute
|
||||
\enum Command::CommandAttribute
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICommand::setCategory(const QString &name)
|
||||
\fn void Command::setCategory(const QString &name)
|
||||
|
||||
Sets the category to \a name.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ICommand::setDefaultKeySequence(const QKeySequence &key)
|
||||
\fn virtual void Command::setDefaultKeySequence(const QKeySequence &key)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int ICommand::id() const
|
||||
\fn virtual int Command::id() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual CommandType ICommand::type() const
|
||||
\fn virtual CommandType Command::type() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QAction *ICommand::action() const
|
||||
\fn virtual QAction *Command::action() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QShortcut *ICommand::shortcut() const
|
||||
\fn virtual QShortcut *Command::shortcut() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ICommand::setAttribute(CommandAttribute attr)
|
||||
\fn virtual void Command::setAttribute(CommandAttribute attr)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void ICommand::removeAttribute(CommandAttribute attr)
|
||||
\fn virtual void Command::removeAttribute(CommandAttribute attr)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool ICommand::hasAttribute(CommandAttribute attr) const
|
||||
\fn virtual bool Command::hasAttribute(CommandAttribute attr) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool ICommand::isActive() const
|
||||
\fn virtual bool Command::isActive() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual ICommand::~ICommand()
|
||||
*/
|
||||
|
||||
using namespace Core::Internal;
|
||||
|
||||
/*!
|
||||
\class Command
|
||||
\ingroup qwb
|
||||
\inheaderfile command.h
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum Command::CommandState
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Command::Command(CommandType type, int id)
|
||||
*/
|
||||
Command::Command(CommandType type, int id)
|
||||
: m_type(type), m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual Command::~Command()
|
||||
*/
|
||||
|
||||
using namespace Core::Internal;
|
||||
|
||||
/*!
|
||||
...
|
||||
\class CommandPrivate
|
||||
\inheaderfile command_p.h
|
||||
\internal
|
||||
*/
|
||||
void Command::setStateFlags(int state)
|
||||
|
||||
CommandPrivate::CommandPrivate(CommandType type, int id)
|
||||
: m_type(type), m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
void CommandPrivate::setStateFlags(int state)
|
||||
{
|
||||
m_type |= (state & CS_Mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
int Command::stateFlags() const
|
||||
int CommandPrivate::stateFlags() const
|
||||
{
|
||||
return (m_type & CS_Mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QString Command::name() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void Command::setCategory(const QString &name)
|
||||
void CommandPrivate::setCategory(const QString &name)
|
||||
{
|
||||
m_category = name;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QString Command::category() const
|
||||
QString CommandPrivate::category() const
|
||||
{
|
||||
if (m_category.isEmpty())
|
||||
return QObject::tr("Other");
|
||||
return m_category;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void Command::setDefaultKeySequence(const QKeySequence &key)
|
||||
void CommandPrivate::setDefaultKeySequence(const QKeySequence &key)
|
||||
{
|
||||
m_defaultKey = key;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QKeySequence Command::defaultKeySequence() const
|
||||
QKeySequence CommandPrivate::defaultKeySequence() const
|
||||
{
|
||||
return m_defaultKey;
|
||||
}
|
||||
|
||||
void Command::setDefaultText(const QString &text)
|
||||
void CommandPrivate::setDefaultText(const QString &text)
|
||||
{
|
||||
m_defaultText = text;
|
||||
}
|
||||
|
||||
QString Command::defaultText() const
|
||||
QString CommandPrivate::defaultText() const
|
||||
{
|
||||
return m_defaultText;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
int Command::id() const
|
||||
int CommandPrivate::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
Command::CommandType Command::type() const
|
||||
CommandPrivate::CommandType CommandPrivate::type() const
|
||||
{
|
||||
return (CommandType)(m_type & CT_Mask);
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QAction *Command::action() const
|
||||
QAction *CommandPrivate::action() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
QShortcut *Command::shortcut() const
|
||||
QShortcut *CommandPrivate::shortcut() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void Command::setAttribute(CommandAttribute attr)
|
||||
void CommandPrivate::setAttribute(CommandAttribute attr)
|
||||
{
|
||||
m_type |= attr;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
void Command::removeAttribute(CommandAttribute attr)
|
||||
void CommandPrivate::removeAttribute(CommandAttribute attr)
|
||||
{
|
||||
m_type &= ~attr;
|
||||
}
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
bool Command::hasAttribute(CommandAttribute attr) const
|
||||
bool CommandPrivate::hasAttribute(CommandAttribute attr) const
|
||||
{
|
||||
return (m_type & attr);
|
||||
}
|
||||
|
||||
QString Command::stringWithAppendedShortcut(const QString &str) const
|
||||
QString CommandPrivate::stringWithAppendedShortcut(const QString &str) const
|
||||
{
|
||||
return QString("%1 <span style=\"color: gray; font-size: small\">%2</span>").arg(str).arg(
|
||||
keySequence().toString(QKeySequence::NativeText));
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual bool Command::setCurrentContext(const QList<int> &context) = 0
|
||||
*/
|
||||
|
||||
// ---------- Shortcut ------------
|
||||
|
||||
/*!
|
||||
\class Shortcut
|
||||
\ingroup qwb
|
||||
\inheaderfile command.h
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
Shortcut::Shortcut(int id)
|
||||
: Command(CT_Shortcut, id), m_shortcut(0)
|
||||
: CommandPrivate(CT_Shortcut, id), m_shortcut(0)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -322,7 +262,7 @@ QList<int> Shortcut::context() const
|
||||
void Shortcut::setDefaultKeySequence(const QKeySequence &key)
|
||||
{
|
||||
setKeySequence(key);
|
||||
Command::setDefaultKeySequence(key);
|
||||
CommandPrivate::setDefaultKeySequence(key);
|
||||
}
|
||||
|
||||
void Shortcut::setKeySequence(const QKeySequence &key)
|
||||
@@ -374,14 +314,13 @@ bool Shortcut::isActive() const
|
||||
/*!
|
||||
\class Action
|
||||
\ingroup qwb
|
||||
\inheaderfile command.h
|
||||
*/
|
||||
|
||||
/*!
|
||||
...
|
||||
*/
|
||||
Action::Action(CommandType type, int id)
|
||||
: Command(type, id), m_action(0)
|
||||
: CommandPrivate(type, id), m_action(0)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -439,7 +378,7 @@ QList<CommandLocation> Action::locations() const
|
||||
void Action::setDefaultKeySequence(const QKeySequence &key)
|
||||
{
|
||||
setKeySequence(key);
|
||||
Command::setDefaultKeySequence(key);
|
||||
CommandPrivate::setDefaultKeySequence(key);
|
||||
}
|
||||
|
||||
void Action::setKeySequence(const QKeySequence &key)
|
||||
@@ -467,7 +406,6 @@ QKeySequence Action::keySequence() const
|
||||
/*!
|
||||
\class OverrideableAction
|
||||
\ingroup qwb
|
||||
\inheaderfile command.h
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -34,146 +34,61 @@
|
||||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
#include "icommand.h"
|
||||
#include "actionmanager.h"
|
||||
#include <coreplugin/core_global.h>
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMultiMap>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QKeySequence>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class Command : public Core::ICommand
|
||||
class CORE_EXPORT Command : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum CommandState {
|
||||
CS_PreLocation = 0x020000,
|
||||
CS_LocationChanged = 0x040000,
|
||||
CS_Initialized = 0x080000,
|
||||
CS_Mask = 0xFF0000
|
||||
enum CommandType {
|
||||
CT_Shortcut = 0x0001,
|
||||
CT_OverridableAction = 0x0002,
|
||||
CT_Mask = 0x00FF
|
||||
};
|
||||
|
||||
Command(CommandType type, int id);
|
||||
enum CommandAttribute {
|
||||
CA_Hide = 0x0100,
|
||||
CA_UpdateText = 0x0200,
|
||||
CA_UpdateIcon = 0x0400,
|
||||
CA_NonConfigureable = 0x8000,
|
||||
CA_Mask = 0xFF00
|
||||
};
|
||||
|
||||
virtual void setDefaultKeySequence(const QKeySequence &key) = 0;
|
||||
virtual void setKeySequence(const QKeySequence &key) = 0;
|
||||
virtual QKeySequence defaultKeySequence() const = 0;
|
||||
virtual QKeySequence keySequence() const = 0;
|
||||
virtual void setDefaultText(const QString &text) = 0;
|
||||
virtual QString defaultText() const = 0;
|
||||
|
||||
virtual void setCategory(const QString &name) = 0;
|
||||
|
||||
virtual int id() const = 0;
|
||||
virtual CommandType type() const = 0;
|
||||
|
||||
virtual QAction *action() const = 0;
|
||||
virtual QShortcut *shortcut() const = 0;
|
||||
|
||||
virtual void setAttribute(CommandAttribute attr) = 0;
|
||||
virtual void removeAttribute(CommandAttribute attr) = 0;
|
||||
virtual bool hasAttribute(CommandAttribute attr) const = 0;
|
||||
|
||||
virtual bool isActive() const = 0;
|
||||
|
||||
virtual ~Command() {}
|
||||
|
||||
void setStateFlags(int state);
|
||||
int stateFlags() const;
|
||||
virtual QString stringWithAppendedShortcut(const QString &str) const = 0;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
|
||||
void setCategory(const QString &name);
|
||||
QString category() const;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
QKeySequence defaultKeySequence() const;
|
||||
|
||||
void setDefaultText(const QString &text);
|
||||
QString defaultText() const;
|
||||
|
||||
int id() const;
|
||||
CommandType type() const;
|
||||
|
||||
QAction *action() const;
|
||||
QShortcut *shortcut() const;
|
||||
|
||||
void setAttribute(CommandAttribute attr);
|
||||
void removeAttribute(CommandAttribute attr);
|
||||
bool hasAttribute(CommandAttribute attr) const;
|
||||
|
||||
virtual bool setCurrentContext(const QList<int> &context) = 0;
|
||||
|
||||
QString stringWithAppendedShortcut(const QString &str) const;
|
||||
|
||||
protected:
|
||||
QString m_category;
|
||||
int m_type;
|
||||
int m_id;
|
||||
QKeySequence m_defaultKey;
|
||||
QString m_defaultText;
|
||||
signals:
|
||||
void keySequenceChanged();
|
||||
};
|
||||
|
||||
class Shortcut : public Command
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Shortcut(int id);
|
||||
|
||||
QString name() const;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
void setKeySequence(const QKeySequence &key);
|
||||
QKeySequence keySequence() const;
|
||||
|
||||
virtual void setDefaultText(const QString &key);
|
||||
virtual QString defaultText() const;
|
||||
|
||||
void setShortcut(QShortcut *shortcut);
|
||||
QShortcut *shortcut() const;
|
||||
|
||||
void setContext(const QList<int> &context);
|
||||
QList<int> context() const;
|
||||
bool setCurrentContext(const QList<int> &context);
|
||||
|
||||
bool isActive() const;
|
||||
private:
|
||||
QList<int> m_context;
|
||||
QShortcut *m_shortcut;
|
||||
QString m_defaultText;
|
||||
};
|
||||
|
||||
class Action : public Command
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Action(CommandType type, int id);
|
||||
|
||||
QString name() const;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
void setKeySequence(const QKeySequence &key);
|
||||
QKeySequence keySequence() const;
|
||||
|
||||
virtual void setAction(QAction *action);
|
||||
QAction *action() const;
|
||||
|
||||
void setLocations(const QList<CommandLocation> &locations);
|
||||
QList<CommandLocation> locations() const;
|
||||
|
||||
protected:
|
||||
void updateToolTipWithKeySequence();
|
||||
|
||||
QAction *m_action;
|
||||
QList<CommandLocation> m_locations;
|
||||
QString m_toolTip;
|
||||
};
|
||||
|
||||
class OverrideableAction : public Action
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OverrideableAction(int id);
|
||||
|
||||
void setAction(QAction *action);
|
||||
bool setCurrentContext(const QList<int> &context);
|
||||
void addOverrideAction(QAction *action, const QList<int> &context);
|
||||
bool isActive() const;
|
||||
|
||||
private slots:
|
||||
void actionChanged();
|
||||
|
||||
private:
|
||||
QPointer<QAction> m_currentAction;
|
||||
QList<int> m_context;
|
||||
QMap<int, QPointer<QAction> > m_contextActionMap;
|
||||
bool m_active;
|
||||
bool m_contextInitialized;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // COMMAND_H
|
||||
|
||||
179
src/plugins/coreplugin/actionmanager/command_p.h
Normal file
179
src/plugins/coreplugin/actionmanager/command_p.h
Normal file
@@ -0,0 +1,179 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef COMMAND_P_H
|
||||
#define COMMAND_P_H
|
||||
|
||||
#include "command.h"
|
||||
#include "actionmanager_p.h"
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMultiMap>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QKeySequence>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class CommandPrivate : public Core::Command
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum CommandState {
|
||||
CS_PreLocation = 0x020000,
|
||||
CS_LocationChanged = 0x040000,
|
||||
CS_Initialized = 0x080000,
|
||||
CS_Mask = 0xFF0000
|
||||
};
|
||||
|
||||
CommandPrivate(CommandType type, int id);
|
||||
virtual ~CommandPrivate() {}
|
||||
|
||||
void setStateFlags(int state);
|
||||
int stateFlags() const;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
|
||||
void setCategory(const QString &name);
|
||||
QString category() const;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
QKeySequence defaultKeySequence() const;
|
||||
|
||||
void setDefaultText(const QString &text);
|
||||
QString defaultText() const;
|
||||
|
||||
int id() const;
|
||||
CommandType type() const;
|
||||
|
||||
QAction *action() const;
|
||||
QShortcut *shortcut() const;
|
||||
|
||||
void setAttribute(CommandAttribute attr);
|
||||
void removeAttribute(CommandAttribute attr);
|
||||
bool hasAttribute(CommandAttribute attr) const;
|
||||
|
||||
virtual bool setCurrentContext(const QList<int> &context) = 0;
|
||||
|
||||
QString stringWithAppendedShortcut(const QString &str) const;
|
||||
|
||||
protected:
|
||||
QString m_category;
|
||||
int m_type;
|
||||
int m_id;
|
||||
QKeySequence m_defaultKey;
|
||||
QString m_defaultText;
|
||||
};
|
||||
|
||||
class Shortcut : public CommandPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Shortcut(int id);
|
||||
|
||||
QString name() const;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
void setKeySequence(const QKeySequence &key);
|
||||
QKeySequence keySequence() const;
|
||||
|
||||
virtual void setDefaultText(const QString &key);
|
||||
virtual QString defaultText() const;
|
||||
|
||||
void setShortcut(QShortcut *shortcut);
|
||||
QShortcut *shortcut() const;
|
||||
|
||||
void setContext(const QList<int> &context);
|
||||
QList<int> context() const;
|
||||
bool setCurrentContext(const QList<int> &context);
|
||||
|
||||
bool isActive() const;
|
||||
private:
|
||||
QList<int> m_context;
|
||||
QShortcut *m_shortcut;
|
||||
QString m_defaultText;
|
||||
};
|
||||
|
||||
class Action : public CommandPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Action(CommandType type, int id);
|
||||
|
||||
QString name() const;
|
||||
|
||||
void setDefaultKeySequence(const QKeySequence &key);
|
||||
void setKeySequence(const QKeySequence &key);
|
||||
QKeySequence keySequence() const;
|
||||
|
||||
virtual void setAction(QAction *action);
|
||||
QAction *action() const;
|
||||
|
||||
void setLocations(const QList<CommandLocation> &locations);
|
||||
QList<CommandLocation> locations() const;
|
||||
|
||||
protected:
|
||||
void updateToolTipWithKeySequence();
|
||||
|
||||
QAction *m_action;
|
||||
QList<CommandLocation> m_locations;
|
||||
QString m_toolTip;
|
||||
};
|
||||
|
||||
class OverrideableAction : public Action
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OverrideableAction(int id);
|
||||
|
||||
void setAction(QAction *action);
|
||||
bool setCurrentContext(const QList<int> &context);
|
||||
void addOverrideAction(QAction *action, const QList<int> &context);
|
||||
bool isActive() const;
|
||||
|
||||
private slots:
|
||||
void actionChanged();
|
||||
|
||||
private:
|
||||
QPointer<QAction> m_currentAction;
|
||||
QList<int> m_context;
|
||||
QMap<int, QPointer<QAction> > m_contextActionMap;
|
||||
bool m_active;
|
||||
bool m_contextInitialized;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // COMMAND_P_H
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "coreimpl.h"
|
||||
#include "commandsfile.h"
|
||||
#include "shortcutsettings.h"
|
||||
#include "command.h"
|
||||
#include "command_p.h"
|
||||
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef IACTIONCONTAINER_H
|
||||
#define IACTIONCONTAINER_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QtGui/QAction>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class ICommand;
|
||||
|
||||
class IActionContainer : public QObject
|
||||
{
|
||||
public:
|
||||
enum ContainerType {
|
||||
CT_Mask = 0xFF,
|
||||
CT_Menu = 0x01,
|
||||
CT_ToolBar = 0x02
|
||||
};
|
||||
|
||||
enum EmptyAction {
|
||||
EA_Mask = 0xFF00,
|
||||
EA_None = 0x0100,
|
||||
EA_Hide = 0x0200,
|
||||
EA_Disable = 0x0300
|
||||
};
|
||||
|
||||
virtual void setEmptyAction(EmptyAction ea) = 0;
|
||||
|
||||
virtual int id() const = 0;
|
||||
virtual ContainerType type() const = 0;
|
||||
|
||||
virtual QMenu *menu() const = 0;
|
||||
virtual QToolBar *toolBar() const = 0;
|
||||
virtual QMenuBar *menuBar() const = 0;
|
||||
|
||||
virtual QAction *insertLocation(const QString &group) const = 0;
|
||||
virtual void appendGroup(const QString &group, bool global = false) = 0;
|
||||
virtual void addAction(Core::ICommand *action, const QString &group = QString()) = 0;
|
||||
virtual void addMenu(Core::IActionContainer *menu, const QString &group = QString()) = 0;
|
||||
|
||||
virtual bool update() = 0;
|
||||
virtual ~IActionContainer() {}
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // IACTIONCONTAINER_H
|
||||
@@ -1,94 +0,0 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ICOMMAND_H
|
||||
#define ICOMMAND_H
|
||||
|
||||
#include <coreplugin/core_global.h>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QKeySequence>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CORE_EXPORT ICommand : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum CommandType {
|
||||
CT_Shortcut = 0x0001,
|
||||
CT_OverridableAction = 0x0002,
|
||||
CT_Mask = 0x00FF
|
||||
};
|
||||
|
||||
enum CommandAttribute {
|
||||
CA_Hide = 0x0100,
|
||||
CA_UpdateText = 0x0200,
|
||||
CA_UpdateIcon = 0x0400,
|
||||
CA_NonConfigureable = 0x8000,
|
||||
CA_Mask = 0xFF00
|
||||
};
|
||||
|
||||
virtual void setDefaultKeySequence(const QKeySequence &key) = 0;
|
||||
virtual void setKeySequence(const QKeySequence &key) = 0;
|
||||
virtual QKeySequence defaultKeySequence() const = 0;
|
||||
virtual QKeySequence keySequence() const = 0;
|
||||
virtual void setDefaultText(const QString &text) = 0;
|
||||
virtual QString defaultText() const = 0;
|
||||
|
||||
virtual void setCategory(const QString &name) = 0;
|
||||
|
||||
virtual int id() const = 0;
|
||||
virtual CommandType type() const = 0;
|
||||
|
||||
virtual QAction *action() const = 0;
|
||||
virtual QShortcut *shortcut() const = 0;
|
||||
|
||||
virtual void setAttribute(CommandAttribute attr) = 0;
|
||||
virtual void removeAttribute(CommandAttribute attr) = 0;
|
||||
virtual bool hasAttribute(CommandAttribute attr) const = 0;
|
||||
|
||||
virtual bool isActive() const = 0;
|
||||
|
||||
virtual ~ICommand() {}
|
||||
|
||||
virtual QString stringWithAppendedShortcut(const QString &str) const = 0;
|
||||
|
||||
signals:
|
||||
void keySequenceChanged();
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // ICOMMAND_H
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -82,38 +82,6 @@ BaseMode::BaseMode(QObject *parent):
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn BaseMode::BaseMode(const QString &name,
|
||||
const char * uniqueModeName,
|
||||
const QIcon &icon,
|
||||
int priority,
|
||||
QWidget *widget,
|
||||
QObject *parent)
|
||||
|
||||
Creates a mode with the given properties.
|
||||
|
||||
\a name
|
||||
\a uniqueModeName
|
||||
\a icon
|
||||
\a priority
|
||||
\a widget
|
||||
\a parent
|
||||
*/
|
||||
BaseMode::BaseMode(const QString &name,
|
||||
const char * uniqueModeName,
|
||||
const QIcon &icon,
|
||||
int priority,
|
||||
QWidget *widget,
|
||||
QObject *parent):
|
||||
IMode(parent),
|
||||
m_name(name),
|
||||
m_icon(icon),
|
||||
m_priority(priority),
|
||||
m_widget(widget),
|
||||
m_uniqueModeName(uniqueModeName)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn BaseMode::~BaseMode()
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -49,12 +49,6 @@ class CORE_EXPORT BaseMode
|
||||
|
||||
public:
|
||||
BaseMode(QObject *parent = 0);
|
||||
BaseMode(const QString &name,
|
||||
const char * uniqueModeName,
|
||||
const QIcon &icon,
|
||||
int priority,
|
||||
QWidget *widget,
|
||||
QObject *parent = 0);
|
||||
~BaseMode();
|
||||
|
||||
// IMode
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -64,7 +64,7 @@ void CoreImpl::showOptionsDialog(const QString &group, const QString &page)
|
||||
m_mainwindow->showOptionsDialog(group, page);
|
||||
}
|
||||
|
||||
ActionManagerInterface *CoreImpl::actionManager() const
|
||||
ActionManager *CoreImpl::actionManager() const
|
||||
{
|
||||
return m_mainwindow->actionManager();
|
||||
}
|
||||
@@ -84,11 +84,6 @@ MessageManager *CoreImpl::messageManager() const
|
||||
return m_mainwindow->messageManager();
|
||||
}
|
||||
|
||||
ViewManagerInterface *CoreImpl::viewManager() const
|
||||
{
|
||||
return m_mainwindow->viewManager();
|
||||
}
|
||||
|
||||
ExtensionSystem::PluginManager *CoreImpl::pluginManager() const
|
||||
{
|
||||
return m_mainwindow->pluginManager();
|
||||
@@ -99,12 +94,12 @@ EditorManager *CoreImpl::editorManager() const
|
||||
return m_mainwindow->editorManager();
|
||||
}
|
||||
|
||||
ProgressManagerInterface *CoreImpl::progressManager() const
|
||||
ProgressManager *CoreImpl::progressManager() const
|
||||
{
|
||||
return m_mainwindow->progressManager();
|
||||
}
|
||||
|
||||
ScriptManagerInterface *CoreImpl::scriptManager() const
|
||||
ScriptManager *CoreImpl::scriptManager() const
|
||||
{
|
||||
return m_mainwindow->scriptManager();
|
||||
}
|
||||
@@ -148,15 +143,6 @@ QString CoreImpl::resourcePath() const
|
||||
#endif
|
||||
}
|
||||
|
||||
QString CoreImpl::libraryPath() const
|
||||
{
|
||||
#if defined(Q_OS_MAC)
|
||||
return QDir::cleanPath(QCoreApplication::applicationDirPath()+QLatin1String("/../PlugIns"));
|
||||
#else
|
||||
return QDir::cleanPath(QCoreApplication::applicationDirPath()+QLatin1String("/../lib"));
|
||||
#endif
|
||||
}
|
||||
|
||||
IContext *CoreImpl::currentContextObject() const
|
||||
{
|
||||
return m_mainwindow->currentContextObject();
|
||||
@@ -168,12 +154,6 @@ QMainWindow *CoreImpl::mainWindow() const
|
||||
return m_mainwindow;
|
||||
}
|
||||
|
||||
QStatusBar *CoreImpl::statusBar() const
|
||||
{
|
||||
return m_mainwindow->statusBar();
|
||||
}
|
||||
|
||||
|
||||
// adds and removes additional active contexts, this context is appended to the
|
||||
// currently active contexts. call updateContext after changing
|
||||
void CoreImpl::addAdditionalContext(int context)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -56,15 +56,14 @@ public:
|
||||
void showOptionsDialog(const QString &group = QString(),
|
||||
const QString &page = QString());
|
||||
|
||||
ActionManagerInterface *actionManager() const;
|
||||
ActionManager *actionManager() const;
|
||||
FileManager *fileManager() const ;
|
||||
UniqueIDManager *uniqueIDManager() const;
|
||||
MessageManager *messageManager() const;
|
||||
ViewManagerInterface *viewManager() const;
|
||||
ExtensionSystem::PluginManager *pluginManager() const;
|
||||
EditorManager *editorManager() const;
|
||||
ProgressManagerInterface *progressManager() const;
|
||||
ScriptManagerInterface *scriptManager() const;
|
||||
ProgressManager *progressManager() const;
|
||||
ScriptManager *scriptManager() const;
|
||||
VariableManager *variableManager() const;
|
||||
VCSManager *vcsManager() const;
|
||||
ModeManager *modeManager() const;
|
||||
@@ -74,12 +73,10 @@ public:
|
||||
QPrinter *printer() const;
|
||||
|
||||
QString resourcePath() const;
|
||||
QString libraryPath() const;
|
||||
|
||||
IContext *currentContextObject() const;
|
||||
|
||||
QMainWindow *mainWindow() const;
|
||||
QStatusBar *statusBar() const;
|
||||
|
||||
// adds and removes additional active contexts, this context is appended to the
|
||||
// currently active contexts. call updateContext after changing
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "editormanager.h"
|
||||
#include "mainwindow.h"
|
||||
#include "modemanager.h"
|
||||
#include "viewmanager.h"
|
||||
#include "fileiconprovider.h"
|
||||
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
include(coreplugin_dependencies.pri)
|
||||
|
||||
LIBS *= -l$$qtLibraryTarget(Core)
|
||||
|
||||
@@ -73,7 +73,8 @@ SOURCES += mainwindow.cpp \
|
||||
rightpane.cpp \
|
||||
sidebar.cpp \
|
||||
fileiconprovider.cpp \
|
||||
mimedatabase.cpp
|
||||
mimedatabase.cpp \
|
||||
icore.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
welcomemode.h \
|
||||
editmode.h \
|
||||
@@ -97,12 +98,12 @@ HEADERS += mainwindow.h \
|
||||
editormanager/openeditorswindow.h \
|
||||
editormanager/ieditor.h \
|
||||
editormanager/ieditorfactory.h \
|
||||
actionmanager/iactioncontainer.h \
|
||||
actionmanager/actionmanagerinterface.h \
|
||||
actionmanager/icommand.h \
|
||||
actionmanager/actioncontainer.h \
|
||||
actionmanager/actionmanager.h \
|
||||
actionmanager/command.h \
|
||||
actionmanager/actioncontainer.h \
|
||||
actionmanager/actionmanager_p.h \
|
||||
actionmanager/command_p.h \
|
||||
actionmanager/actioncontainer_p.h \
|
||||
actionmanager/commandsfile.h \
|
||||
dialogs/saveitemsdialog.h \
|
||||
dialogs/newdialog.h \
|
||||
@@ -111,11 +112,11 @@ HEADERS += mainwindow.h \
|
||||
dialogs/openwithdialog.h \
|
||||
dialogs/iwizard.h \
|
||||
dialogs/ioptionspage.h \
|
||||
progressmanager/progressmanager.h \
|
||||
progressmanager/progressmanager_p.h \
|
||||
progressmanager/progressview.h \
|
||||
progressmanager/progresspie.h \
|
||||
progressmanager/futureprogress.h \
|
||||
progressmanager/progressmanagerinterface.h \
|
||||
progressmanager/progressmanager.h \
|
||||
icontext.h \
|
||||
icore.h \
|
||||
ifile.h \
|
||||
@@ -131,8 +132,8 @@ HEADERS += mainwindow.h \
|
||||
versiondialog.h \
|
||||
scriptmanager/metatypedeclarations.h \
|
||||
scriptmanager/qworkbench_wrapper.h \
|
||||
scriptmanager/scriptmanagerinterface.h \
|
||||
scriptmanager/scriptmanager.h \
|
||||
scriptmanager/scriptmanager_p.h \
|
||||
core_global.h \
|
||||
basemode.h \
|
||||
baseview.h \
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -54,7 +54,8 @@ public:
|
||||
virtual QString trCategory() const = 0;
|
||||
|
||||
virtual QWidget *createPage(QWidget *parent) = 0;
|
||||
virtual void finished(bool accepted) = 0;
|
||||
virtual void apply() = 0;
|
||||
virtual void finish() = 0;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -126,20 +126,22 @@ void SettingsDialog::pageSelected(QTreeWidgetItem *)
|
||||
|
||||
void SettingsDialog::accept()
|
||||
{
|
||||
foreach (IOptionsPage *page, m_pages)
|
||||
page->finished(true);
|
||||
foreach (IOptionsPage *page, m_pages) {
|
||||
page->apply();
|
||||
page->finish();
|
||||
}
|
||||
done(QDialog::Accepted);
|
||||
}
|
||||
|
||||
void SettingsDialog::reject()
|
||||
{
|
||||
foreach (IOptionsPage *page, m_pages)
|
||||
page->finished(false);
|
||||
page->finish();
|
||||
done(QDialog::Rejected);
|
||||
}
|
||||
|
||||
void SettingsDialog::apply()
|
||||
{
|
||||
foreach (IOptionsPage *page, m_pages)
|
||||
page->finished(true);
|
||||
page->apply();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -33,15 +33,15 @@
|
||||
|
||||
#include "shortcutsettings.h"
|
||||
#include "ui_shortcutsettings.h"
|
||||
#include "actionmanager.h"
|
||||
#include "command.h"
|
||||
#include "actionmanager_p.h"
|
||||
#include "command_p.h"
|
||||
#include "coreconstants.h"
|
||||
#include "coreimpl.h"
|
||||
#include "commandsfile.h"
|
||||
#include "filemanager.h"
|
||||
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/icommand.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtGui/QShortcut>
|
||||
@@ -120,14 +120,14 @@ QWidget *ShortcutSettings::createPage(QWidget *parent)
|
||||
return w;
|
||||
}
|
||||
|
||||
void ShortcutSettings::finished(bool accepted)
|
||||
void ShortcutSettings::apply()
|
||||
{
|
||||
if (accepted) {
|
||||
foreach (ShortcutItem *item, m_scitems) {
|
||||
item->m_cmd->setKeySequence(item->m_key);
|
||||
}
|
||||
}
|
||||
foreach (ShortcutItem *item, m_scitems)
|
||||
item->m_cmd->setKeySequence(item->m_key);
|
||||
}
|
||||
|
||||
void ShortcutSettings::finish()
|
||||
{
|
||||
qDeleteAll(m_scitems);
|
||||
m_scitems.clear();
|
||||
}
|
||||
@@ -281,14 +281,14 @@ void ShortcutSettings::initialize()
|
||||
{
|
||||
QMap<QString, QTreeWidgetItem *> categories;
|
||||
|
||||
m_am = ActionManager::instance();
|
||||
m_am = ActionManagerPrivate::instance();
|
||||
UniqueIDManager *uidm =
|
||||
CoreImpl::instance()->uniqueIDManager();
|
||||
|
||||
QList<Command *> cmds = m_am->commands();
|
||||
QList<CommandPrivate *> cmds = m_am->commands();
|
||||
for (int i = 0; i < cmds.size(); ++i) {
|
||||
Command *c = cmds.at(i);
|
||||
if (c->hasAttribute(Command::CA_NonConfigureable))
|
||||
CommandPrivate *c = cmds.at(i);
|
||||
if (c->hasAttribute(CommandPrivate::CA_NonConfigureable))
|
||||
continue;
|
||||
if (c->action() && c->action()->isSeparator())
|
||||
continue;
|
||||
@@ -313,7 +313,7 @@ void ShortcutSettings::initialize()
|
||||
item->setText(0, uidm->stringForUniqueIdentifier(c->id()));
|
||||
|
||||
if (c->action()) {
|
||||
QString text = c->hasAttribute(Command::CA_UpdateText) && !c->defaultText().isNull() ? c->defaultText() : c->action()->text();
|
||||
QString text = c->hasAttribute(CommandPrivate::CA_UpdateText) && !c->defaultText().isNull() ? c->defaultText() : c->action()->text();
|
||||
s->m_key = c->action()->shortcut();
|
||||
item->setText(1, text);
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -47,17 +47,16 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class ICommand;
|
||||
class Command;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class ActionManager;
|
||||
class Command;
|
||||
class ActionManagerPrivate;
|
||||
class MainWindow;
|
||||
|
||||
struct ShortcutItem
|
||||
{
|
||||
ICommand *m_cmd;
|
||||
Command *m_cmd;
|
||||
QKeySequence m_key;
|
||||
QTreeWidgetItem *m_item;
|
||||
};
|
||||
@@ -77,7 +76,8 @@ public:
|
||||
QString trCategory() const;
|
||||
|
||||
QWidget *createPage(QWidget *parent);
|
||||
void finished(bool accepted);
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
@@ -101,7 +101,7 @@ private:
|
||||
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
|
||||
|
||||
QList<ShortcutItem *> m_scitems;
|
||||
ActionManager *m_am;
|
||||
ActionManagerPrivate *m_am;
|
||||
int m_key[4], m_keyNum;
|
||||
Ui_ShortcutSettings *m_page;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanagerinterface.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
#include <coreplugin/baseview.h>
|
||||
#include <coreplugin/imode.h>
|
||||
@@ -210,13 +210,13 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
||||
const QList<int> editManagerContext =
|
||||
QList<int>() << m_d->m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_EDITORMANAGER);
|
||||
|
||||
ActionManagerInterface *am = m_d->m_core->actionManager();
|
||||
IActionContainer *mfile = am->actionContainer(Constants::M_FILE);
|
||||
ActionManager *am = m_d->m_core->actionManager();
|
||||
ActionContainer *mfile = am->actionContainer(Constants::M_FILE);
|
||||
|
||||
//Revert to saved
|
||||
ICommand *cmd = am->registerAction(m_d->m_revertToSavedAction,
|
||||
Command *cmd = am->registerAction(m_d->m_revertToSavedAction,
|
||||
Constants::REVERTTOSAVED, editManagerContext);
|
||||
cmd->setAttribute(ICommand::CA_UpdateText);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
cmd->setDefaultText(tr("Revert File to Saved"));
|
||||
mfile->addAction(cmd, Constants::G_FILE_SAVE);
|
||||
connect(m_d->m_revertToSavedAction, SIGNAL(triggered()), this, SLOT(revertToSaved()));
|
||||
@@ -230,7 +230,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
||||
connect(m_d->m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveFileAs()));
|
||||
|
||||
//Window Menu
|
||||
IActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
|
||||
//Window menu separators
|
||||
QAction *tmpaction = new QAction(this);
|
||||
@@ -261,7 +261,7 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
||||
//Close Action
|
||||
cmd = am->registerAction(m_d->m_closeCurrentEditorAction, Constants::CLOSE, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+W")));
|
||||
cmd->setAttribute(Core::ICommand::CA_UpdateText);
|
||||
cmd->setAttribute(Core::Command::CA_UpdateText);
|
||||
cmd->setDefaultText(m_d->m_closeCurrentEditorAction->text());
|
||||
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
|
||||
connect(m_d->m_closeCurrentEditorAction, SIGNAL(triggered()), this, SLOT(closeEditor()));
|
||||
@@ -318,8 +318,8 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
||||
connect(m_d->m_goForwardAction, SIGNAL(triggered()), this, SLOT(goForwardInNavigationHistory()));
|
||||
|
||||
|
||||
IActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
||||
IActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED);
|
||||
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
||||
ActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED);
|
||||
medit->addMenu(advancedMenu, Constants::G_EDIT_FORMAT);
|
||||
advancedMenu->menu()->setTitle(tr("&Advanced"));
|
||||
|
||||
@@ -1403,7 +1403,7 @@ void EditorManager::readSettings(QSettings *settings)
|
||||
if (settings->contains(QLatin1String("EditorManager/DocumentStates")))
|
||||
m_d->m_editorStates = settings->value(QLatin1String("EditorManager/DocumentStates"))
|
||||
.value<QMap<QString, QVariant> >();
|
||||
if (settings->contains(QLatin1String("EditorManager/ExternalEditor")))
|
||||
if (settings->contains(QLatin1String("EditorManager/ExternalEditorCommand")))
|
||||
m_d->m_externalEditor = settings->value(QLatin1String("EditorManager/ExternalEditorCommand")).toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanagerinterface.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -72,9 +72,9 @@ void EditorSplitter::registerActions()
|
||||
const QList<int> editorManagerContext =
|
||||
QList<int>() << m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_EDITORMANAGER);
|
||||
|
||||
ActionManagerInterface *am = m_core->actionManager();
|
||||
IActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
ICommand *cmd;
|
||||
ActionManager *am = m_core->actionManager();
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
Command *cmd;
|
||||
|
||||
//Horizontal Action
|
||||
m_horizontalSplitAction = new QAction(tr("Split Left/Right"), this);
|
||||
@@ -98,7 +98,7 @@ void EditorSplitter::registerActions()
|
||||
this, SLOT(unsplit()));
|
||||
|
||||
//Default Layout menu
|
||||
IActionContainer *mLayout = am->createMenu("QtCreator.Menu.Window.Layout");
|
||||
ActionContainer *mLayout = am->createMenu("QtCreator.Menu.Window.Layout");
|
||||
mwindow->addMenu(mLayout, Constants::G_WINDOW_SPLIT);
|
||||
mLayout->menu()->setTitle(tr("Default Splitter Layout"));
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -81,11 +81,8 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
|
||||
return w;
|
||||
}
|
||||
|
||||
void GeneralSettings::finished(bool accepted)
|
||||
void GeneralSettings::apply()
|
||||
{
|
||||
if (!accepted)
|
||||
return;
|
||||
|
||||
// Apply the new base color if accepted
|
||||
StyleHelper::setBaseColor(m_page->colorButton->color());
|
||||
EditorManager::instance()->setExternalEditor(m_page->externalEditorEdit->text());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -55,7 +55,8 @@ public:
|
||||
QString category() const;
|
||||
QString trCategory() const;
|
||||
QWidget* createPage(QWidget *parent);
|
||||
void finished(bool accepted);
|
||||
void apply();
|
||||
void finish() { }
|
||||
|
||||
private slots:
|
||||
void resetInterfaceColor();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
|
||||
341
src/plugins/coreplugin/icore.cpp
Normal file
341
src/plugins/coreplugin/icore.cpp
Normal file
@@ -0,0 +1,341 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#include "icore.h"
|
||||
|
||||
/*!
|
||||
\namespace Core
|
||||
\brief The Core namespace contains all classes that make up the Core plugin
|
||||
which constitute the basic functionality of Qt Creator.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\namespace Core::Internal
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class Core::ICore
|
||||
\brief The ICore class allows access to the different part that make up
|
||||
the basic functionality of Qt Creator.
|
||||
|
||||
You should never create a subclass of this interface. The one and only
|
||||
instance is created by the Core plugin. You can access this instance
|
||||
from your plugin via the plugin manager, e.g.
|
||||
\code
|
||||
ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
|
||||
\endcode
|
||||
|
||||
\mainclass
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList ICore::showNewItemDialog(const QString &title,
|
||||
const QList<IWizard *> &wizards,
|
||||
const QString &defaultLocation = QString())
|
||||
\brief Opens a dialog where the user can choose from a set of \a wizards that
|
||||
create new files/classes/projects.
|
||||
|
||||
The \a title argument is shown as the dialogs title. The path where the
|
||||
files will be created (if the user doesn't change it) is set
|
||||
in \a defaultLocation. It defaults to the path of the file manager's
|
||||
current file.
|
||||
|
||||
\sa Core::FileManager
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::showOptionsDialog(const QString &group = QString(),
|
||||
const QString &page = QString())
|
||||
\brief Opens the application options/preferences dialog with preselected
|
||||
\a page in a specified \a group.
|
||||
|
||||
The arguments refer to the string IDs of the corresponding IOptionsPage.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ActionManager *ICore::actionManager() const
|
||||
\brief Returns the application's action manager.
|
||||
|
||||
The action manager is responsible for registration of menus and
|
||||
menu items and keyboard shortcuts.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn FileManager *ICore::fileManager() const
|
||||
\brief Returns the application's file manager.
|
||||
|
||||
The file manager keeps track of files for changes outside the application.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn UniqueIDManager *ICore::uniqueIDManager() const
|
||||
\brief Returns the application's id manager.
|
||||
|
||||
The unique ID manager transforms strings in unique integers and the other way round.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn MessageManager *ICore::messageManager() const
|
||||
\brief Returns the application's message manager.
|
||||
|
||||
The message manager is the interface to the "General" output pane for
|
||||
general application debug messages.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ExtensionSystem::PluginManager *ICore::pluginManager() const
|
||||
\brief Returns the application's plugin manager.
|
||||
|
||||
The plugin manager handles the plugin life cycles and manages
|
||||
the common object pool.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn EditorManager *ICore::editorManager() const
|
||||
\brief Returns the application's editor manager.
|
||||
|
||||
The editor manager handles all editor related tasks like opening
|
||||
documents, the stack of currently open documents and the currently
|
||||
active document.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ProgressManager *ICore::progressManager() const
|
||||
\brief Returns the application's progress manager.
|
||||
|
||||
Use the progress manager to register a concurrent task to
|
||||
show a progress bar the way Qt Creator does it.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ScriptManager *ICore::scriptManager() const
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn VariableManager *ICore::variableManager() const
|
||||
\brief Returns the application's variable manager.
|
||||
|
||||
The variable manager is used to register application wide string variables
|
||||
like \c MY_PROJECT_DIR such that strings like \c{somecommand ${MY_PROJECT_DIR}/sub}
|
||||
can be resolved/expanded from anywhere in the application.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn VCSManager *ICore::vcsManager() const
|
||||
\brief Returns the application's vcs manager.
|
||||
|
||||
The vcs manager can be used to e.g. retrieve information about
|
||||
the version control system used for a directory on hard disk.
|
||||
The actual functionality for a specific version control system
|
||||
must be implemented in a IVersionControl object and registered in
|
||||
the plugin manager's object pool.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ModeManager *ICore::modeManager() const
|
||||
\brief Returns the application's mode manager.
|
||||
|
||||
The mode manager handles everything related to the instances of IMode
|
||||
that were added to the plugin manager's object pool as well as their
|
||||
buttons and the tool bar with the round buttons in the lower left
|
||||
corner of Qt Creator.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn MimeDatabase *ICore::mimeDatabase() const
|
||||
\brief Returns the application's mime database.
|
||||
|
||||
Use the mime database to manage mime types.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QSettings *ICore::settings() const
|
||||
\brief Returns the application's main settings object.
|
||||
|
||||
You can use it to retrieve or set application wide settings
|
||||
(in contrast to session or project specific settings).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QPrinter *ICore::printer() const
|
||||
\brief Returns the application's printer object.
|
||||
|
||||
Always use this printer object for printing, so the different parts of the
|
||||
application re-use it's settings.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString ICore::resourcePath() const
|
||||
\brief Returns the absolute path that is used for resources like
|
||||
project templates and the debugger macros.
|
||||
|
||||
This abstraction is needed to avoid platform-specific code all over
|
||||
the place, since e.g. on Mac the resources are part of the application bundle.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMainWindow *ICore::mainWindow() const
|
||||
\brief Returns the main application window.
|
||||
|
||||
For use as dialog parent etc.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn IContext *ICore::currentContextObject() const
|
||||
\brief Returns the context object of the current main context.
|
||||
|
||||
\sa ICore::addAdditionalContext()
|
||||
\sa ICore::addContextObject()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::addAdditionalContext(int context)
|
||||
\brief Register additional context to be currently active.
|
||||
|
||||
Appends the additional \a context to the list of currently active
|
||||
contexts. You need to call ICore::updateContext to make that change
|
||||
take effect.
|
||||
|
||||
\sa ICore::removeAdditionalContext()
|
||||
\sa ICore::hasContext()
|
||||
\sa ICore::updateContext()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::removeAdditionalContext(int context)
|
||||
\brief Removes the given \a context from the list of currently active contexts.
|
||||
|
||||
You need to call ICore::updateContext to make that change
|
||||
take effect.
|
||||
|
||||
\sa ICore::addAdditionalContext()
|
||||
\sa ICore::hasContext()
|
||||
\sa ICore::updateContext()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool ICore::hasContext(int context) const
|
||||
\brief Returns if the given \a context is currently one of the active contexts.
|
||||
|
||||
\sa ICore::addAdditionalContext()
|
||||
\sa ICore::addContextObject()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::addContextObject(IContext *context)
|
||||
\brief Registers an additional \a context object.
|
||||
|
||||
After registration this context object gets automatically the
|
||||
current context object whenever it's widget gets focus.
|
||||
|
||||
\sa ICore::removeContextObject()
|
||||
\sa ICore::addAdditionalContext()
|
||||
\sa ICore::currentContextObject()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::removeContextObject(IContext *context)
|
||||
\brief Unregisters a \a context object from the list of know contexts.
|
||||
|
||||
\sa ICore::addContextObject()
|
||||
\sa ICore::addAdditionalContext()
|
||||
\sa ICore::currentContextObject()
|
||||
}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::updateContext()
|
||||
\brief Update the list of active contexts after adding or removing additional ones.
|
||||
|
||||
\sa ICore::addAdditionalContext()
|
||||
\sa ICore::removeAdditionalContext()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::openFiles(const QStringList &fileNames)
|
||||
\brief Open all files from a list of \a fileNames like it would be
|
||||
done if they were given to Qt Creator on the command line, or
|
||||
they were opened via \gui{File|Open}.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ICore::ICore()
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn ICore::~ICore()
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::coreOpened()
|
||||
\brief Emitted after all plugins have been loaded and the main window shown.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::saveSettingsRequested()
|
||||
\brief Emitted to signal that the user has requested that the global settings
|
||||
should be saved to disk.
|
||||
|
||||
At the moment that happens when the application is closed, and on \gui{Save All}.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::optionsDialogRequested()
|
||||
\brief Signal that allows plugins to perform actions just before the \gui{Tools|Options}
|
||||
dialog is shown.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::coreAboutToClose()
|
||||
\brief Plugins can do some pre-end-of-life actions when they get this signal.
|
||||
|
||||
The application is guaranteed to shut down after this signal is emitted.
|
||||
It's there as an addition to the usual plugin lifecycle methods, namely
|
||||
IPlugin::shutdown(), just for convenience.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::contextAboutToChange(Core::IContext *context)
|
||||
\brief Sent just before a new \a context becomes the current context
|
||||
(meaning that it's widget got focus).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ICore::contextChanged(Core::IContext *context)
|
||||
\brief Sent just after a new \a context became the current context
|
||||
(meaning that it's widget got focus).
|
||||
*/
|
||||
@@ -2,7 +2,7 @@
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
@@ -50,16 +50,15 @@ QT_END_NAMESPACE
|
||||
namespace Core {
|
||||
|
||||
// forward declarations
|
||||
class ActionManagerInterface;
|
||||
class ActionManager;
|
||||
class IFile;
|
||||
class FileManager;
|
||||
class MessageManager;
|
||||
class IEditor;
|
||||
class UniqueIDManager;
|
||||
class ViewManagerInterface;
|
||||
class EditorManager;
|
||||
class ProgressManagerInterface;
|
||||
class ScriptManagerInterface;
|
||||
class ProgressManager;
|
||||
class ScriptManager;
|
||||
class VariableManager;
|
||||
class IContext;
|
||||
class VCSManager;
|
||||
@@ -82,15 +81,14 @@ public:
|
||||
virtual void showOptionsDialog(const QString &group = QString(),
|
||||
const QString &page = QString()) = 0;
|
||||
|
||||
virtual ActionManagerInterface *actionManager() const = 0;
|
||||
virtual ActionManager *actionManager() const = 0;
|
||||
virtual FileManager *fileManager() const = 0;
|
||||
virtual UniqueIDManager *uniqueIDManager() const = 0;
|
||||
virtual MessageManager *messageManager() const = 0;
|
||||
virtual ViewManagerInterface *viewManager() const = 0;
|
||||
virtual ExtensionSystem::PluginManager *pluginManager() const = 0;
|
||||
virtual EditorManager *editorManager() const = 0;
|
||||
virtual ProgressManagerInterface *progressManager() const = 0;
|
||||
virtual ScriptManagerInterface *scriptManager() const = 0;
|
||||
virtual ProgressManager *progressManager() const = 0;
|
||||
virtual ScriptManager *scriptManager() const = 0;
|
||||
virtual VariableManager *variableManager() const = 0;
|
||||
virtual VCSManager *vcsManager() const = 0;
|
||||
virtual ModeManager *modeManager() const = 0;
|
||||
@@ -100,20 +98,17 @@ public:
|
||||
virtual QPrinter *printer() const = 0;
|
||||
|
||||
virtual QString resourcePath() const = 0;
|
||||
virtual QString libraryPath() const = 0;
|
||||
|
||||
virtual IContext *currentContextObject() const = 0;
|
||||
|
||||
virtual QMainWindow *mainWindow() const = 0;
|
||||
virtual QStatusBar *statusBar() const = 0;
|
||||
|
||||
// adds and removes additional active contexts, this context is appended to the
|
||||
// currently active contexts. call updateContext after changing
|
||||
virtual IContext *currentContextObject() const = 0;
|
||||
virtual void addAdditionalContext(int context) = 0;
|
||||
virtual void removeAdditionalContext(int context) = 0;
|
||||
virtual bool hasContext(int context) const = 0;
|
||||
virtual void addContextObject(IContext *contex) = 0;
|
||||
virtual void removeContextObject(IContext *contex) = 0;
|
||||
virtual void addContextObject(IContext *context) = 0;
|
||||
virtual void removeContextObject(IContext *context) = 0;
|
||||
|
||||
virtual void updateContext() = 0;
|
||||
|
||||
@@ -122,7 +117,7 @@ public:
|
||||
signals:
|
||||
void coreOpened();
|
||||
void saveSettingsRequested();
|
||||
void settingsDialogRequested();
|
||||
void optionsDialogRequested();
|
||||
void coreAboutToClose();
|
||||
void contextAboutToChange(Core::IContext *context);
|
||||
void contextChanged(Core::IContext *context);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user