Commit 5042515c authored by dt's avatar dt
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents a79a26c7 40a4dc25
......@@ -178,19 +178,19 @@ static inline QStringList getPluginPaths()
// Figure out root: Up one from 'bin'
QDir rootDir = QApplication::applicationDirPath();
rootDir.cdUp();
const QString rootDirPath = QDir::toNativeSeparators(rootDir.canonicalPath());
const QString rootDirPath = rootDir.canonicalPath();
// 1) "plugins" (Win/Linux)
QString pluginPath = rootDirPath;
pluginPath += QDir::separator();
pluginPath += '/';
pluginPath += QLatin1String(IDE_LIBRARY_BASENAME);
pluginPath += QDir::separator();
pluginPath += '/';
pluginPath += QLatin1String("qtcreator");
pluginPath += QDir::separator();
pluginPath += '/';
pluginPath += QLatin1String("plugins");
rc.push_back(pluginPath);
// 2) "PlugIns" (OS X)
pluginPath = rootDirPath;
pluginPath += QDir::separator();
pluginPath += '/';
pluginPath += QLatin1String("PlugIns");
rc.push_back(pluginPath);
return rc;
......@@ -269,7 +269,8 @@ int main(int argc, char **argv)
}
}
if (!coreplugin) {
const QString reason = QCoreApplication::translate("Application", "Couldn't find 'Core.pluginspec' in %1").arg(pluginPaths.join(QLatin1String(",")));
QString nativePaths = QDir::toNativeSeparators(pluginPaths.join(QLatin1String(",")));
const QString reason = QCoreApplication::translate("Application", "Couldn't find 'Core.pluginspec' in %1").arg(nativePaths);
displayError(msgCoreLoadFailure(reason));
return 1;
}
......
......@@ -51,7 +51,8 @@ SimpleToken TokenUnderCursor::operator()(const QTextCursor &cursor, QTextBlock *
QTextBlock block = cursor.block();
int column = cursor.columnNumber();
_tokens = tokenize(block.text(), previousBlockState(block));
_text = block.text();
_tokens = tokenize(_text, previousBlockState(block));
for (int index = _tokens.size() - 1; index != -1; --index) {
const SimpleToken &tk = _tokens.at(index);
if (tk.position() < column) {
......
......@@ -55,6 +55,7 @@ private:
int previousBlockState(const QTextBlock &block) const;
QList<SimpleToken> _tokens;
QString _text;
};
} // end of namespace CPlusPlus
......
......@@ -43,19 +43,13 @@ CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project)
: BuildStepConfigWidget(), m_pro(project)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
m_clearSystemEnvironmentCheckBox = new QCheckBox(this);
m_clearSystemEnvironmentCheckBox->setText("Clear system environment");
m_clearSystemEnvironmentCheckBox->setVisible(false);
vbox->addWidget(m_clearSystemEnvironmentCheckBox);
m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this);
m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this, m_clearSystemEnvironmentCheckBox);
vbox->addWidget(m_buildEnvironmentWidget);
connect(m_buildEnvironmentWidget, SIGNAL(switchedToDetails()),
m_clearSystemEnvironmentCheckBox, SLOT(show()));
connect(m_buildEnvironmentWidget, SIGNAL(switchedToSummary()),
m_clearSystemEnvironmentCheckBox, SLOT(hide()));
connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()),
this, SLOT(environmentModelUserChangesUpdated()));
connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),
......
......@@ -713,6 +713,8 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeProject *project)
: m_project(project)
{
QFormLayout *fl = new QFormLayout(this);
fl->setContentsMargins(0, -1, 0, -1);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
m_pathLineEdit = new QLineEdit(this);
m_pathLineEdit->setReadOnly(true);
......
......@@ -237,6 +237,8 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
{
QFormLayout *fl = new QFormLayout();
fl->setMargin(0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
QLineEdit *argumentsLineEdit = new QLineEdit();
argumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(cmakeRunConfiguration->commandLineArguments()));
connect(argumentsLineEdit, SIGNAL(textChanged(QString)),
......@@ -259,6 +261,7 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
fl->addRow(tr("Working Directory:"), boxlayout);
QVBoxLayout *vbx = new QVBoxLayout(this);
vbx->setContentsMargins(0, -1, 0, -1);
vbx->addLayout(fl);
QLabel *environmentLabel = new QLabel(this);
......@@ -269,25 +272,21 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
environmentLabel->setFont(f);
vbx->addWidget(environmentLabel);
QFormLayout *formlayout = new QFormLayout();
QWidget *baseEnvironmentWidget = new QWidget;
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
baseEnvironmentLayout->setMargin(0);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
baseEnvironmentLayout->addWidget(label);
m_baseEnvironmentComboBox = new QComboBox(this);
m_baseEnvironmentComboBox->addItems(QStringList()
<< tr("Clean Environment")
<< tr("System Environment")
<< tr("Build Environment"));
formlayout->addRow(label, m_baseEnvironmentComboBox);
vbx->addLayout(formlayout);
label->setVisible(false);
m_baseEnvironmentComboBox->setVisible(false);
m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase());
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(baseEnvironmentComboBoxChanged(int)));
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
baseEnvironmentLayout->addStretch(10);
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
this, SLOT(setWorkingDirectory()));
......@@ -295,20 +294,10 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
connect(resetButton, SIGNAL(clicked()),
this, SLOT(resetWorkingDirectory()));
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this);
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
m_baseEnvironmentComboBox, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
m_baseEnvironmentComboBox, SLOT(show()));
connect(m_environmentWidget, SIGNAL(switchedToSummary()),
label, SLOT(hide()));
connect(m_environmentWidget, SIGNAL(switchedToDetails()),
label, SLOT(show()));
vbx->addWidget(m_environmentWidget);
connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
......
......@@ -153,6 +153,8 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
: m_makeStep(makeStep)
{
QFormLayout *fl = new QFormLayout(this);
fl->setMargin(0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
m_additionalArguments = new QLineEdit(this);
......
......@@ -52,10 +52,12 @@
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/mimedatabase.h>
#include <texteditor/itexteditor.h>
#include <texteditor/itexteditable.h>
#include <utils/qtcassert.h>
#include <texteditor/basetexteditor.h>
#include <projectexplorer/projectexplorer.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QMap>
......@@ -585,6 +587,15 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
} else if ((ch2.isNull() || ch2.isSpace()) && (ch == QLatin1Char('@') || ch == QLatin1Char('\\'))) {
k = T_DOXY_COMMENT;
--start;
} else if (ch == QLatin1Char('<')) {
k = T_ANGLE_STRING_LITERAL;
--start;
} else if (ch == QLatin1Char('"')) {
k = T_STRING_LITERAL;
--start;
} else if (ch == QLatin1Char('/')) {
k = T_SLASH;
--start;
}
if (start == pos)
......@@ -594,6 +605,17 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
QTextCursor tc(edit->textCursor());
tc.setPosition(pos);
// Include completion: make sure the quote character is the first one on the line
if (k == T_STRING_LITERAL) {
QTextCursor s = tc;
s.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
QString sel = s.selectedText();
if (sel.indexOf(QLatin1Char('"')) < sel.length() - 1) {
k = T_EOF_SYMBOL;
start = pos;
}
}
static CPlusPlus::TokenUnderCursor tokenUnderCursor;
const SimpleToken tk = tokenUnderCursor(tc);
......@@ -601,7 +623,16 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
k = T_EOF_SYMBOL;
start = pos;
}
else if (tk.is(T_COMMENT) || tk.isLiteral()) {
// Don't complete in comments or strings, but still check for include completion
else if (tk.is(T_COMMENT) || (tk.isLiteral() &&
(k != T_STRING_LITERAL
&& k != T_ANGLE_STRING_LITERAL
&& k != T_SLASH))) {
k = T_EOF_SYMBOL;
start = pos;
}
// Include completion: can be triggered by slash, but only in a string
else if (k == T_SLASH && (tk.isNot(T_STRING_LITERAL) && tk.isNot(T_ANGLE_STRING_LITERAL))) {
k = T_EOF_SYMBOL;
start = pos;
}
......@@ -627,6 +658,32 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
}
}
// Check for include preprocessor directive
if (k == T_STRING_LITERAL || k == T_ANGLE_STRING_LITERAL || k == T_SLASH) {
const QList<SimpleToken> &tokens = tokenUnderCursor.tokens();
int i = 0;
bool include = false;
for (; i < tokens.size(); ++i) {
const SimpleToken &token = tokens.at(i);
if (token.position() == tk.position()) {
if (i == 0) // no token on the left, but might be on a previous line
break;
const SimpleToken &previousToken = tokens.at(i - 1);
if (previousToken.is(T_IDENTIFIER)) {
if (previousToken.text() == QLatin1String("include")) {
include = true;
break;
}
}
}
}
if (!include) {
k = T_EOF_SYMBOL;
start = pos;
}
}
if (kind)
*kind = k;
......@@ -685,6 +742,18 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
return m_startPosition;
}
// Include completion
if (m_completionOperator == T_STRING_LITERAL
|| m_completionOperator == T_ANGLE_STRING_LITERAL
|| m_completionOperator == T_SLASH) {
QTextCursor c = edit->textCursor();
c.setPosition(endOfExpression);
if (completeInclude(c))
m_startPosition = startOfName;
return m_startPosition;
}
ExpressionUnderCursor expressionUnderCursor;
QTextCursor tc(edit->document());
......@@ -1121,6 +1190,72 @@ void CppCodeCompletion::addCompletionItem(Symbol *symbol)
m_completions.append(item);
}
bool CppCodeCompletion::completeInclude(const QTextCursor &cursor)
{
QString directoryPrefix;
if (m_completionOperator == T_SLASH) {
QTextCursor c = cursor;
c.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
QString sel = c.selectedText();
int startCharPos = sel.indexOf(QLatin1Char('"'));
if (startCharPos == -1) {
startCharPos = sel.indexOf(QLatin1Char('<'));
m_completionOperator = T_ANGLE_STRING_LITERAL;
} else {
m_completionOperator = T_STRING_LITERAL;
}
if (startCharPos != -1)
directoryPrefix = sel.mid(startCharPos + 1, sel.length() - 1);
}
// Make completion for all relevant includes
if (ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject()) {
QStringList items;
QStringList includePaths = m_manager->projectInfo(project).includePaths;
const QString currentFilePath = QFileInfo(m_editor->file()->fileName()).path();
if (!includePaths.contains(currentFilePath))
includePaths.append(currentFilePath);
const Core::MimeDatabase *mimeDatabase = Core::ICore::instance()->mimeDatabase();
const Core::MimeType mimeType = mimeDatabase->findByType(QLatin1String("text/x-c++hdr"));
const QStringList suffixes = mimeType.suffixes();
foreach (const QString &includePath, includePaths) {
QString realPath = includePath;
if (!directoryPrefix.isEmpty()) {
realPath += QLatin1Char('/');
realPath += directoryPrefix;
}
// TODO: This should be cached
QDirIterator i(realPath, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
while (i.hasNext()) {
const QString fileName = i.next();
const QFileInfo fileInfo = i.fileInfo();
const QString suffix = fileInfo.suffix();
if (suffix.isEmpty() || suffixes.contains(suffix)) {
QString text = fileName.mid(realPath.length() + 1);
if (fileInfo.isDir())
text += QLatin1Char('/');
items.append(text);
}
}
}
if (!items.isEmpty()) {
foreach (const QString &itemText, items) {
TextEditor::CompletionItem item(this);
item.m_text += itemText;
// TODO: Icon for include files
item.m_icon = m_icons.keywordIcon();
m_completions.append(item);
}
return true;
}
}
return false;
}
void CppCodeCompletion::completeNamespace(const QList<Symbol *> &candidates,
const LookupContext &context)
{
......@@ -1324,16 +1459,18 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
if (item.m_data.isValid())
symbol = item.m_data.value<Symbol *>();
QString toInsert;
int extraLength = 0;
if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT) {
QString toInsert = item.m_text;
toInsert = item.m_text;
toInsert += QLatin1Char(')');
// Insert the remainder of the name
int length = m_editor->position() - m_startPosition;
m_editor->setCurPos(m_startPosition);
m_editor->replace(length, toInsert);
} else if (m_completionOperator == T_STRING_LITERAL || m_completionOperator == T_ANGLE_STRING_LITERAL) {
toInsert = item.m_text;
if (!toInsert.endsWith(QLatin1Char('/')))
toInsert += QLatin1Char((m_completionOperator == T_ANGLE_STRING_LITERAL) ? '>' : '"');
} else {
QString toInsert = item.m_text;
int extraLength = 0;
toInsert = item.m_text;
//qDebug() << "current symbol:" << overview.prettyName(symbol->name())
//<< overview.prettyType(symbol->type());
......@@ -1381,11 +1518,12 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
toInsert += extraChars;
}
// Insert the remainder of the name
int length = m_editor->position() - m_startPosition + extraLength;
m_editor->setCurPos(m_startPosition);
m_editor->replace(length, toInsert);
}
// Insert the remainder of the name
int length = m_editor->position() - m_startPosition + extraLength;
m_editor->setCurPos(m_startPosition);
m_editor->replace(length, toInsert);
}
bool CppCodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem> &completionItems)
......
......@@ -41,6 +41,9 @@
#include <QtCore/QObject>
#include <QtCore/QPointer>
QT_BEGIN_NAMESPACE
class QTextCursor;
QT_END_NAMESPACE
namespace TextEditor {
class ITextEditor;
......@@ -108,6 +111,8 @@ private:
QSet<QString> *definedMacros);
void addCompletionItem(CPlusPlus::Symbol *symbol);
bool completeInclude(const QTextCursor &cursor);
bool completeConstructorOrFunction(const QList<CPlusPlus::TypeOfExpression::Result> &);
bool completeMember(const QList<CPlusPlus::TypeOfExpression::Result> &,
......
......@@ -3032,13 +3032,19 @@ void GdbEngine::updateSubItem(const WatchData &data0)
qDebug() << "IT'S A POINTER";
#endif
#if 1
insertData(data.pointerChildPlaceHolder());
data.setChildrenUnneeded();
insertData(data);
WatchData data1;
data1.iname = data.iname + QLatin1String(".*");
data1.name = QLatin1Char('*') + data.name;
data1.exp = QLatin1String("(*(") + data.exp + QLatin1String("))");
data1.type = stripPointerType(data.type);
data1.setValueNeeded();
insertData(data1);
#else
// Try automatic dereferentiation
data.exp = "*(" + data.exp + ")";
data.type = data.type + "."; // FIXME: fragile HACK to avoid recursion
data.exp = _("*(") + data.exp + _(")");
data.type = data.type + _("."); // FIXME: fragile HACK to avoid recursion
insertData(data);
#endif
return;
......
......@@ -198,17 +198,6 @@ void WatchData::setAddress(const QString &str)
addr = str;
}
WatchData WatchData::pointerChildPlaceHolder() const
{
WatchData data1;
data1.iname = iname + QLatin1String(".*");
data1.name = QLatin1Char('*') + name;
data1.exp = QLatin1String("(*(") + exp + QLatin1String("))");
data1.type = stripPointerType(type);
data1.setValueNeeded();
return data1;
}
QString WatchData::toString() const
{
const char *doubleQuoteComma = "\",";
......
......@@ -102,8 +102,6 @@ public:
void setHasChildren(bool c) { hasChildren = c; setHasChildrenUnneeded();
if (!c) setChildrenUnneeded(); }
WatchData pointerChildPlaceHolder() const;
QString toString() const;
QString toToolTip() const;
bool isLocal() const { return iname.startsWith(QLatin1String("local.")); }
......
......@@ -6,12 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>274</width>
<height>392</height>
<width>399</width>
<height>279</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="makeLabel">
<property name="text">
<string>Override %1:</string>
......@@ -21,10 +27,10 @@
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QLineEdit" name="makeLineEdit"/>
</item>
<item>
<item row="1" column="0">
<widget class="QLabel" name="makeArgumentsLabel">
<property name="text">
<string>Make arguments:</string>
......@@ -34,10 +40,10 @@
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QLineEdit" name="makeArgumentsLineEdit"/>
</item>
<item>
<item row="2" column="0">
<widget class="QLabel" name="targetsLabel">
<property name="text">
<string>Targets:</string>
......@@ -47,22 +53,9 @@
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QListWidget" name="targetsList"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
......
......@@ -519,6 +519,8 @@ GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project)
: m_project(project)
{
QFormLayout *fl = new QFormLayout(this);
fl->setContentsMargins(0, -1, 0, -1);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
// build directory
m_pathChooser = new Core::Utils::PathChooser(this);
......@@ -528,6 +530,7 @@ GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project)
// tool chain
QComboBox *toolChainChooser = new QComboBox;
toolChainChooser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
toolChainChooser->addItems(ProjectExplorer::ToolChain::supportedToolChains());
toolChainChooser->setCurrentIndex(toolChainChooser->findText(m_project->toolChainId()));
fl->addRow(tr("Toolchain:"), toolChainChooser);
......
......@@ -62,7 +62,7 @@
</sizepolicy>
</property>
<property name="title">
<string>GroupBox</string>
<string>No step selected</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
......
......@@ -90,6 +90,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
layout->addRow(QString(), m_useTerminalCheck);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, -1, 0, -1);
vbox->addLayout(layout);
QLabel *environmentLabel = new QLabel(this);
......@@ -100,41 +101,27 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
environmentLabel->setFont(f);
vbox->addWidget(environmentLabel);
QFormLayout *formlayout = new QFormLayout();
QWidget *baseEnvironmentWidget = new QWidget;
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
baseEnvironmentLayout->setMargin(0);
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
baseEnvironmentLayout->addWidget(label);