Commit 43bccb41 authored by con's avatar con
Browse files

Merge commit 'origin/1.3'

Conflicts:
	src/plugins/debugger/debuggermanager.h
	src/plugins/qmleditor/qmleditorplugin.cpp
	src/plugins/qt4projectmanager/qt4runconfiguration.cpp
parents 1a6f2793 8335a06e
......@@ -42,6 +42,7 @@
#include <QtCore/QByteArray>
#include <QtCore/QBitArray>
#include <QtCore/QDir>
#include <QtCore/QtDebug>
/*!
......@@ -108,7 +109,7 @@ private:
Document::Document(const QString &fileName)
: _fileName(fileName),
: _fileName(QDir::cleanPath(fileName)),
_globalNamespace(0),
_revision(0)
{
......@@ -173,7 +174,7 @@ QStringList Document::includedFiles() const
void Document::addIncludeFile(const QString &fileName, unsigned line)
{
_includes.append(Include(fileName, line));
_includes.append(Include(QDir::cleanPath(fileName), line));
}
void Document::appendMacro(const Macro &macro)
......@@ -569,3 +570,8 @@ QStringList Snapshot::dependsOn(const QString &fileName) const
return deps;
}
Document::Ptr Snapshot::value(const QString &fileName) const
{
return QMap<QString, Document::Ptr>::value(QDir::cleanPath(fileName));
}
......@@ -341,6 +341,7 @@ public:
QStringList dependsOn(const QString &fileName) const;
void insert(Document::Ptr doc);
Document::Ptr value(const QString &fileName) const;
using _Base::insert;
......
......@@ -121,8 +121,7 @@ void FindUsages::reportResult(unsigned tokenIndex)
const int len = tk.f.length;
if (_future) {
const QString path = QDir::toNativeSeparators(_doc->fileName());
_future->reportResult(Usage(path, line, lineText, col, len));
_future->reportResult(Usage(_doc->fileName(), line, lineText, col, len));
}
_references.append(tokenIndex);
......
......@@ -35,7 +35,7 @@
namespace Utils {
static QString toAlphaNum(const QString &s)
QTCREATOR_UTILS_EXPORT QString fileNameToCppIdentifier(const QString &s)
{
QString rc;
const int len = s.size();
......@@ -55,9 +55,9 @@ static QString toAlphaNum(const QString &s)
QTCREATOR_UTILS_EXPORT QString headerGuard(const QString &file)
{
const QFileInfo fi(file);
QString rc = toAlphaNum(fi.completeBaseName()).toUpper();
QString rc = fileNameToCppIdentifier(fi.completeBaseName()).toUpper();
rc += QLatin1Char('_');
rc += toAlphaNum(fi.suffix()).toUpper();
rc += fileNameToCppIdentifier(fi.suffix()).toUpper();
return rc;
}
......
......@@ -40,6 +40,10 @@ QT_END_NAMESPACE
namespace Utils {
// Convert a file name to a Cpp identifier (stripping invalid characters
// or replacing them by an underscore).
QTCREATOR_UTILS_EXPORT QString fileNameToCppIdentifier(const QString &s);
QTCREATOR_UTILS_EXPORT QString headerGuard(const QString &file);
QTCREATOR_UTILS_EXPORT
......
......@@ -132,105 +132,122 @@ void StyleHelper::setBaseColor(const QColor &color)
}
}
void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect)
static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect)
{
QString key;
key.sprintf("mh_toolbar %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), StyleHelper::baseColor().rgb());;
QPixmap pixmap;
QPainter *p = painter;
QRect rect = clipRect;
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(clipRect.size());
p = new QPainter(&pixmap);
rect = QRect(0, 0, clipRect.width(), clipRect.height());
}
QColor base = StyleHelper::baseColor();
QLinearGradient grad(spanRect.topRight(), spanRect.topLeft());
grad.setColorAt(0, highlightColor());
grad.setColorAt(0, StyleHelper::highlightColor());
grad.setColorAt(0.301, base);
grad.setColorAt(1, shadowColor());
grad.setColorAt(1, StyleHelper::shadowColor());
p->fillRect(rect, grad);
QColor light(255, 255, 255, 80);
p->setPen(light);
p->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
}
void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect)
{
if (StyleHelper::usePixmapCache()) {
QString key;
key.sprintf("mh_vertical %d %d %d %d %d",
spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), StyleHelper::baseColor().rgb());;
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(clipRect.size());
QPainter p(&pixmap);
QRect rect(0, 0, clipRect.width(), clipRect.height());
verticalGradientHelper(&p, spanRect, rect);
p.end();
QPixmapCache::insert(key, pixmap);
}
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
painter->drawPixmap(clipRect.topLeft(), pixmap);
p->end();
delete p;
QPixmapCache::insert(key, pixmap);
} else {
verticalGradientHelper(painter, spanRect, clipRect);
}
}
void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect)
static void horizontalGradientHelper(QPainter *p, const QRect &spanRect, const
QRect &rect)
{
QString key;
key.sprintf("mh_toolbar %d %d %d %d %d", spanRect.width(), spanRect.height(),
clipRect.width(), clipRect.height(), StyleHelper::baseColor().rgb());
QPixmap pixmap;
QPainter *p = painter;
QRect rect = clipRect;
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(clipRect.size());
p = new QPainter(&pixmap);
rect = QRect(0, 0, clipRect.width(), clipRect.height());
}
QColor base = StyleHelper::baseColor();
QLinearGradient grad(rect.topLeft(), rect.bottomLeft());
grad.setColorAt(0, highlightColor().lighter(120));
if (rect.height() == navigationWidgetHeight()) {
grad.setColorAt(0.4, highlightColor());
grad.setColorAt(0, StyleHelper::highlightColor().lighter(120));
if (rect.height() == StyleHelper::navigationWidgetHeight()) {
grad.setColorAt(0.4, StyleHelper::highlightColor());
grad.setColorAt(0.401, base);
}
grad.setColorAt(1, shadowColor());
grad.setColorAt(1, StyleHelper::shadowColor());
p->fillRect(rect, grad);
QLinearGradient shadowGradient(spanRect.topLeft(), spanRect.topRight());
shadowGradient.setColorAt(0, QColor(0, 0, 0, 30));
QColor highlight = highlightColor().lighter(130);
QColor highlight = StyleHelper::highlightColor().lighter(130);
highlight.setAlpha(100);
shadowGradient.setColorAt(0.7, highlight);
shadowGradient.setColorAt(1, QColor(0, 0, 0, 40));
p->fillRect(rect, shadowGradient);
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
painter->drawPixmap(clipRect.topLeft(), pixmap);
p->end();
delete p;
QPixmapCache::insert(key, pixmap);
}
}
void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect)
void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect)
{
QString key;
key.sprintf("mh_toolbar %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), StyleHelper::baseColor().rgb());;
QPixmap pixmap;
QPainter *p = painter;
QRect rect = clipRect;
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(clipRect.size());
p = new QPainter(&pixmap);
rect = QRect(0, 0, clipRect.width(), clipRect.height());
if (StyleHelper::usePixmapCache()) {
QString key;
key.sprintf("mh_horizontal %d %d %d %d %d",
spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), StyleHelper::baseColor().rgb());
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(clipRect.size());
QPainter p(&pixmap);
QRect rect = QRect(0, 0, clipRect.width(), clipRect.height());
horizontalGradientHelper(&p, spanRect, rect);
p.end();
QPixmapCache::insert(key, pixmap);
}
painter->drawPixmap(clipRect.topLeft(), pixmap);
} else {
horizontalGradientHelper(painter, spanRect, clipRect);
}
}
static void menuGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect)
{
QLinearGradient grad(spanRect.topLeft(), spanRect.bottomLeft());
QColor menuColor = mergedColors(StyleHelper::baseColor(), QColor(244, 244, 244), 25);
QColor menuColor = StyleHelper::mergedColors(StyleHelper::baseColor(), QColor(244, 244, 244), 25);
grad.setColorAt(0, menuColor.lighter(112));
grad.setColorAt(1, menuColor);
p->fillRect(rect, grad);
}
void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect)
{
if (StyleHelper::usePixmapCache()) {
QString key;
key.sprintf("mh_menu %d %d %d %d %d",
spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), StyleHelper::baseColor().rgb());
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(clipRect.size());
QPainter p(&pixmap);
QRect rect = QRect(0, 0, clipRect.width(), clipRect.height());
menuGradientHelper(&p, spanRect, rect);
p.end();
QPixmapCache::insert(key, pixmap);
}
if (StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
painter->drawPixmap(clipRect.topLeft(), pixmap);
p->end();
delete p;
QPixmapCache::insert(key, pixmap);
} else {
menuGradientHelper(painter, spanRect, clipRect);
}
}
......
......@@ -343,6 +343,7 @@ void EditorView::setCurrentEditor(IEditor *editor)
{
if (!editor || m_container->count() <= 0
|| m_container->indexOf(editor->widget()) == -1) {
updateEditorStatus(0);
// ### TODO the combo box m_editorList should show an empty item
return;
}
......@@ -377,6 +378,13 @@ void EditorView::updateEditorStatus(IEditor *editor)
static const QIcon lockedIcon(QLatin1String(":/core/images/locked.png"));
static const QIcon unlockedIcon(QLatin1String(":/core/images/unlocked.png"));
m_lockButton->setVisible(editor != 0);
if (!editor) {
m_editorList->setToolTip(QString());
return;
}
if (editor->file()->isReadOnly()) {
m_lockButton->setIcon(lockedIcon);
m_lockButton->setEnabled(!editor->file()->fileName().isEmpty());
......
......@@ -106,6 +106,10 @@ public:
*/
virtual bool vcsDelete(const QString &filename) = 0;
signals:
void repositoryChanged(const QString &repository);
void filesChanged(const QStringList &files);
// TODO: ADD A WAY TO DETECT WHETHER A FILE IS MANAGED, e.g
// virtual bool sccManaged(const QString &filename) = 0;
};
......
......@@ -126,7 +126,7 @@ MainWindow::MainWindow() :
m_progressManager(new ProgressManagerPrivate()),
m_scriptManager(new ScriptManagerPrivate(this)),
m_variableManager(new VariableManager(this)),
m_vcsManager(new VCSManager()),
m_vcsManager(new VCSManager),
m_viewManager(0),
m_modeManager(0),
m_mimeDatabase(new MimeDatabase),
......@@ -346,6 +346,7 @@ void MainWindow::extensionsInitialized()
OutputPaneManager::instance()->init();
m_actionManager->initialize();
m_vcsManager->extensionsInitialized();
readSettings();
updateContext();
......
......@@ -57,7 +57,8 @@ struct VCSManagerPrivate {
QMap<QString, IVersionControl *> m_cachedMatches;
};
VCSManager::VCSManager() :
VCSManager::VCSManager(QObject *parent) :
QObject(parent),
m_d(new VCSManagerPrivate)
{
}
......@@ -67,6 +68,17 @@ VCSManager::~VCSManager()
delete m_d;
}
void VCSManager::extensionsInitialized()
{
// Change signal connections
foreach (IVersionControl *versionControl, allVersionControls()) {
connect(versionControl, SIGNAL(filesChanged(QStringList)),
this, SIGNAL(filesChanged(QStringList)));
connect(versionControl, SIGNAL(repositoryChanged(QString)),
this, SIGNAL(repositoryChanged(QString)));
}
}
void VCSManager::setVCSEnabled(const QString &directory)
{
if (debug)
......
......@@ -33,6 +33,7 @@
#include "core_global.h"
#include <QtCore/QString>
#include <QtCore/QObject>
namespace Core {
......@@ -49,13 +50,16 @@ class IVersionControl;
// for the topmost directory it manages. This information is cached and
// VCSManager thus knows pretty fast which IVersionControl * is responsible.
class CORE_EXPORT VCSManager
class CORE_EXPORT VCSManager : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(VCSManager)
public:
VCSManager();
explicit VCSManager(QObject *parent = 0);
virtual ~VCSManager();
void extensionsInitialized();
IVersionControl *findVersionControlForDirectory(const QString &directory);
// Enable the VCS managing a certain directory only. This should
......@@ -69,6 +73,10 @@ public:
// if a failure occurs
bool showDeleteDialog(const QString &fileName);
signals:
void repositoryChanged(const QString &repository);
void filesChanged(const QStringList &files);
private:
VCSManagerPrivate *m_d;
};
......
......@@ -41,8 +41,10 @@ const char * const SWITCH_DECLARATION_DEFINITION = "CppEditor.SwitchDeclarationD
const char * const RENAME_SYMBOL_UNDER_CURSOR = "CppEditor.RenameSymbolUnderCursor";
const char * const FIND_USAGES = "CppEditor.FindUsages";
const char * const SEPARATOR = "CppEditor.Separator";
const char * const SEPARATOR2 = "CppEditor.Separator2";
const char * const FIND_REFERENCES = "CppEditor.FindReferences";
const char * const JUMP_TO_DEFINITION = "CppEditor.JumpToDefinition";
const char * const UPDATE_CODEMODEL = "CppEditor.UpdateCodeModel";
const char * const HEADER_FILE_TYPE = "CppHeaderFiles";
const char * const SOURCE_FILE_TYPE = "CppSourceFiles";
......
......@@ -52,6 +52,7 @@
#include <texteditor/texteditorsettings.h>
#include <texteditor/texteditorconstants.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
......@@ -108,11 +109,26 @@ QStringList CppEditorFactory::mimeTypes() const
///////////////////////////////// CppPlugin //////////////////////////////////
static inline
Core::Command *createSeparator(Core::ActionManager *am,
QObject *parent,
const QList<int> &context,
const char *id)
{
QAction *separator = new QAction(parent);
separator->setSeparator(true);
return am->registerAction(separator, QLatin1String(id), context);
}
CppPlugin *CppPlugin::m_instance = 0;
CppPlugin::CppPlugin() :
m_actionHandler(0),
m_sortedMethodOverview(false)
m_sortedMethodOverview(false),
m_renameSymbolUnderCursorAction(0),
m_findUsagesAction(0),
m_updateCodeModelAction(0)
{
m_instance = this;
}
......@@ -192,6 +208,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
Core::ActionContainer *contextMenu= am->createMenu(CppEditor::Constants::M_CONTEXT);
Core::Command *cmd;
Core::ActionContainer *cppToolsMenu = am->actionContainer(QLatin1String(CppTools::Constants::M_TOOLS_CPP));
QAction *jumpToDefinition = new QAction(tr("Follow Symbol under Cursor"), this);
cmd = am->registerAction(jumpToDefinition,
......@@ -200,7 +217,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
connect(jumpToDefinition, SIGNAL(triggered()),
this, SLOT(jumpToDefinition()));
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
cppToolsMenu->addAction(cmd);
QAction *switchDeclarationDefinition = new QAction(tr("Switch between Method Declaration/Definition"), this);
cmd = am->registerAction(switchDeclarationDefinition,
......@@ -209,14 +226,14 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
connect(switchDeclarationDefinition, SIGNAL(triggered()),
this, SLOT(switchDeclarationDefinition()));
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = am->registerAction(m_findUsagesAction, Constants::FIND_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(m_findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
cmd = am->registerAction(m_renameSymbolUnderCursorAction,
......@@ -224,7 +241,17 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R"));
connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
cppToolsMenu->addAction(cmd);
// Update context in global context
QList<int> globalContext;
globalContext.append(Core::Constants::C_GLOBAL_ID);
cppToolsMenu->addAction(createSeparator(am, this, globalContext, CppEditor::Constants::SEPARATOR2));
m_updateCodeModelAction = new QAction(tr("Update code model"), this);
cmd = am->registerAction(m_updateCodeModelAction, QLatin1String(Constants::UPDATE_CODEMODEL), globalContext);
CppTools::CppModelManagerInterface *cppModelManager = CppTools::CppModelManagerInterface::instance();
connect(m_updateCodeModelAction, SIGNAL(triggered()), cppModelManager, SLOT(updateModifiedSourceFiles()));
cppToolsMenu->addAction(cmd);
m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
TextEditor::TextEditorActionHandler::Format
......@@ -233,10 +260,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
m_actionHandler->initializeActions();
QAction *separator = new QAction(this);
separator->setSeparator(true);
cmd = am->registerAction(separator, CppEditor::Constants::SEPARATOR, context);
contextMenu->addAction(cmd);
contextMenu->addAction(createSeparator(am, this, context, CppEditor::Constants::SEPARATOR));
cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION);
contextMenu->addAction(cmd);
......@@ -308,6 +332,7 @@ void CppPlugin::onTaskStarted(const QString &type)
if (type == CppTools::Constants::TASK_INDEX) {
m_renameSymbolUnderCursorAction->setEnabled(false);
m_findUsagesAction->setEnabled(false);
m_updateCodeModelAction->setEnabled(false);
}
}
......@@ -316,6 +341,7 @@ void CppPlugin::onAllTasksFinished(const QString &type)
if (type == CppTools::Constants::TASK_INDEX) {
m_renameSymbolUnderCursorAction->setEnabled(true);
m_findUsagesAction->setEnabled(true);
m_updateCodeModelAction->setEnabled(true);
}
}
......
......@@ -90,6 +90,7 @@ private:
bool m_sortedMethodOverview;
QAction *m_renameSymbolUnderCursorAction;
QAction *m_findUsagesAction;
QAction *m_updateCodeModelAction;
};
class CppEditorFactory : public Core::IEditorFactory
......
......@@ -110,7 +110,6 @@ static void find_helper(QFutureInterface<Usage> &future,
Q_ASSERT(symbolId != 0);
const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
QStringList files(sourceFile);
if (symbol->isClass() || symbol->isForwardClassDeclaration()) {
......@@ -126,9 +125,7 @@ static void find_helper(QFutureInterface<Usage> &future,
} else {
files += snapshot.dependsOn(sourceFile);
}
files.removeDuplicates();
//qDebug() << "done in:" << tm.elapsed() << "number of files to parse:" << files.size();
future.setProgressRange(0, files.size());
......@@ -232,7 +229,6 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
const QMap<QString, QString> wl = _modelManager->workingCopy();
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
QFuture<Usage> result = QtConcurrent::run(&find_helper, wl, snapshot, symbol);
m_watcher.setFuture(result);
......
......@@ -379,8 +379,8 @@ QString CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type)
}
}
foreach (const QString &includePath, m_includePaths) {
QString path = includePath;
for (int i = m_includePaths.size() - 1; i != -1; --i) {
QString path = m_includePaths.at(i);
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
......@@ -532,7 +532,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
return;
QString contents = tryIncludeFile(fileName, type);
fileName = QDir::cleanPath(fileName);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName, line);
......
......@@ -47,6 +47,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/vcsmanager.h>
#include <cppeditor/cppeditorconstants.h>
#include <QtCore/QtConcurrentRun>
......@@ -97,6 +98,11 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
// Objects
m_modelManager = new CppModelManager(this);
Core::VCSManager *vcsManager = core->vcsManager();
connect(vcsManager, SIGNAL(repositoryChanged(QString)),
m_modelManager, SLOT(updateModifiedSourceFiles()));
connect(vcsManager, SIGNAL(filesChanged(QStringList)),
m_modelManager, SLOT(updateModifiedSourceFiles()));
addAutoReleasedObject(m_modelManager);
m_completion = new CppCodeCompletion(m_modelManager);
......
......@@ -96,3 +96,14 @@ QString CVSControl::findTopLevelForDirectory(const QString &directory) const
{
return m_plugin->findTopLevelForDirectory(directory);