Commit 16a5aec1 authored by mae's avatar mae
Browse files

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

parents f1302b3b de007635
......@@ -56,6 +56,7 @@ examples/tools/plugandpaint/plugins
include/*
include/*/*
lib/*
lib64/*
plugins/*/*
release
tmp
......
......@@ -33,18 +33,21 @@
#include <QtCore/QTextStream>
#include <QtGui/QMessageBox>
TextFinder::TextFinder(QWidget *parent, Qt::WFlags flags)
: QWidget(parent, flags)
//! [2]
TextFinder::TextFinder(QWidget *parent)
: QWidget(parent), ui(new Ui::TextFinder)
{
ui.setupUi(this);
ui->setupUi(this);
loadTextFile();
isFirstTime = true;
}
//! [2]
TextFinder::~TextFinder()
{
delete ui;
}
//! [0]
void TextFinder::loadTextFile()
{
QFile inputFile(":/input.txt");
......@@ -54,20 +57,16 @@ void TextFinder::loadTextFile()
QString line = in.readAll();
inputFile.close();
ui.textEdit->setPlainText(line);
QTextCursor cursor = ui.textEdit->textCursor();
ui->textEdit->setPlainText(line);
QTextCursor cursor = ui->textEdit->textCursor();
cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1);
}
//! [0]
//! [1]
void TextFinder::on_findButton_clicked()
{
QString searchString = ui.lineEdit->text();
QTextDocument *document = ui.textEdit->document();
bool found = false;
ui.textEdit->find(searchString, QTextDocument::FindWholeWords);
QTextCursor cursor = ui.textEdit->textCursor();
if (!cursor.isNull())
found = true;
QString searchString = ui->lineEdit->text();
ui->textEdit->find(searchString, QTextDocument::FindWholeWords);
}
//! [1]
......@@ -34,29 +34,25 @@
#include <QtGui/QWidget>
class QPushButton;
class QTextEdit;
class QLineEdit;
namespace Ui
{
class TextFinder;
}
class TextFinder : public QWidget
{
Q_OBJECT
public:
TextFinder(QWidget *parent = 0, Qt::WFlags flags = 0);
TextFinder(QWidget *parent = 0);
~TextFinder();
private slots:
void on_findButton_clicked();
private:
Ui::Form ui;
Ui::TextFinder *ui;
void loadTextFile();
QPushButton *ui_findButton;
QTextEdit *ui_textEdit;
QLineEdit *ui_lineEdit;
bool isFirstTime;
};
#endif // TEXTFINDER_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<class>TextFinder</class>
<widget class="QWidget" name="TextFinder">
<property name="geometry">
<rect>
<x>0</x>
......
......@@ -531,9 +531,11 @@
\image qtcreator-textfinder-ui.png
Design the form above using a \l{http://doc.trolltech.com/qlabel.html}
{QLabel}, \l{http://doc.trolltech.com/qlinedit.html}{QLineEdit},
\l{http://doc.trolltech.com/qpushbutton.html}{QPushButton} and a
\l{http://doc.trolltech.com/qtextedit.html}{QTextEdit}. We recommend that
{QLabel}, \l{http://doc.trolltech.com/qlinedit.html}{QLineEdit}
(named lineEdit), \l{http://doc.trolltech.com/qpushbutton.html}{QPushButton}
(named findButton), and a
\l{http://doc.trolltech.com/qtextedit.html}{QTextEdit} (named textEdit).
We recommend that
you use a QGridLayout to lay out the
\l{http://doc.trolltech.com/qlabel.html}{QLabel},
\l{http://doc.trolltech.com/qlinedit.html}{QLineEdit} and
......@@ -559,11 +561,11 @@
void on_findButton_clicked();
private:
Ui::Form ui;
Ui::TextFinder *ui;
void loadTextFile();
\endcode
\note The \c{Ui::Form} object is already provided.
\note The \c{Ui::TextFinder} object is already provided.
\section2 The Source File
......@@ -571,57 +573,36 @@
\c{textfinder.cpp}. We begin by filling in the functionality to load a
text file. The code snippet below describes this:
\code
void TextFinder::loadTextFile()
{
QFile inputFile(":/input.txt");
inputFile.open(QIODevice::ReadOnly);
QTextStream in(&inputFile);
QString line = in.readAll();
inputFile.close();
ui.textEdit->setPlainText(line);
QTextCursor cursor = ui.textEdit->textCursor();
}
\endcode
\snippet example/textfinder/textfinder.cpp 0
Basically, we load a text file using
\l{http://doc.trolltech.com/qfile.html}{QFile}, read it with
\l{http://doc.trolltech.com/qtextstream.html}{QTextStream}, and
then display it on \c{textEdit} with
\l{http://doc.trolltech.com/qtextedit.html#plainText-prop}{setPlainText()}.
\l{http://doc.trolltech.com/qtextedit.html#plainText-prop}{setPlainText()}
which requires adding the following additional #includes to textfinder.cpp:
\code
#include <QtCore/QFile>
#include <QtCore/QTextStream>
\endcode
For the \c{on_findButton_clicked()} slot, we extract the search string and
use the \l{http://doc.trolltech.com/qtextedit.html#find}{find()} function
to look for the search string within the text file. The code snippet below
further describes it:
\code
void TextFinder::on_findButton_clicked()
{
QString searchString = ui.lineEdit->text();
ui.textEdit->find(searchString, QTextDocument::FindWholeWords);
}
\endcode
\snippet example/textfinder/textfinder.cpp 1
Once we have both these functions complete, we call \c{loadTextFile()} in
our constructor.
\code
TextFinder::TextFinder(QWidget *parent, Qt::WFlags flags)
: QWidget(parent, flags)
{
ui.setupUi(this);
loadTextFile();
}
\endcode
\snippet example/textfinder/textfinder.cpp 2
The \c{on_findButton_clicked()} slot will be called automatically due to
this line of code:
\code
QMetaObject::connectSlotsByName(Form);
QMetaObject::connectSlotsByName(TextFinder);
\endcode
in the uic generated \c{ui_textfinder.h} file.
......@@ -795,6 +776,40 @@
\image qtcreator-vcs-gitbranch.png
\endtable
\section2 Common options
The \gui{Version Control/Common} settings page features common settings for
version control systems, such as commit message line wrapping and checking options.
\gui{Submit message checking script} is a script or program that can be used to
perform checks on the submit message before submitting. It is passed the
submit message as first parameter. On error, it should output a message on standard error and
return an exit code different from 0.
\gui{User/alias configuration file} takes a file in a mailmap format that lists
user names and aliases:
\code
Jon Doe <Jon.Doe@company.com>
Hans Mustermann <Hans.Mustermann@company.com> hm <info@company.com>
\endcode
The second line specifies that the alias \e{hm} and the corresponding email address should
be used for \e{Hans Mustermann}. If the file is present, the submit editor will feature
a context menu option \gui{Insert name...} that will pop up a dialog letting the user
choose a name to be inserted.
\gui{User field configuration file} is a simple text file consisting of lines specifying submit message fields that take user names, for example:
\code
Reviewed-by:
Signed-off-by:
\endcode
The fields will appear below the submit message. They provide completion on the
aliases/public user names specified in the \e{User/alias configuration file} and an additional
button that opens the aforementioned user name dialog.
*/
......@@ -1197,13 +1212,13 @@
\code
void TextFinder::on_findButton_clicked()
{
QString searchString = ui.lineEdit->text();
QString searchString = ui->lineEdit->text();
QTextDocument *document = ui.textEdit->document();
QTextCursor cursor = ui.textEdit->textCursor();
QTextDocument *document = ui->textEdit->document();
QTextCursor cursor = ui->textEdit->textCursor();
cursor = document->find(searchString, cursor,
QTextDocument::FindWholeWords);
ui.textEdit->setTextCursor(cursor);
ui->textEdit->setTextCursor(cursor);
bool found = cursor.isNull();
......@@ -1216,7 +1231,7 @@
if (ret == QMessageBox::Yes) {
cursor = document->find(searchString,
QTextDocument::FindWholeWords);
ui.textEdit->setTextCursor(cursor);
ui->textEdit->setTextCursor(cursor);
} else
return;
}
......
......@@ -8,6 +8,7 @@ sourcedirs =
sourcedirs = $SRCDIR
imagedirs = $SRCDIR
outputdir = $OUTDIR
exampledirs = $SRCDIR
extraimages.HTML = qt-logo \
trolltech-logo
......
......@@ -2013,7 +2013,7 @@ static void qDumpQVariantHelper(const void *data, QString *value,
*numchild = 0;
break;
case QVariant::StringList:
*exp = QString(QLatin1String("((QVariant*)%1)->d.data.c"))
*exp = QString(QLatin1String("(*('"NS"QStringList'*)%1)"))
.arg((quintptr)data);
*numchild = v.toStringList().size();
break;
......@@ -2057,7 +2057,7 @@ static void qDumpQVariant(QDumper &d)
ba += ") ";
ba += qPrintable(value);
P(d, "value", ba);
P(d, "valueencoded", "1");
P(d, "valueencoded", "4");
}
P(d, "type", NS"QVariant");
P(d, "numchild", (isInvalid ? "0" : "1"));
......@@ -2069,7 +2069,7 @@ static void qDumpQVariant(QDumper &d)
P(d, "exp", qPrintable(exp));
if (!value.isEmpty()) {
P(d, "value", value);
P(d, "valueencoded", "1");
P(d, "valueencoded", "4");
}
P(d, "type", v.typeName());
P(d, "numchild", numchild);
......
......@@ -190,7 +190,10 @@ int ExpressionUnderCursor::previousBlockState(const QTextBlock &block)
return 0;
}
QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
void ExpressionUnderCursor::init(const QTextCursor &cursor,
QList<SimpleToken> *tokens,
QString *text,
int *startPosition)
{
enum { MAX_BLOCK_COUNT = 5 };
......@@ -203,8 +206,6 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
initialBlock = initialBlock.previous();
}
QString text;
QTextBlock it = initialBlock;
for (; it.isValid(); it = it.next()) {
QString textBlock = it.text();
......@@ -212,18 +213,29 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
if (it == block)
textBlock = textBlock.left(cursor.position() - cursor.block().position());
text += textBlock;
text->append(textBlock);
if (it == block)
break;
text += QLatin1Char('\n');
text->append(QLatin1Char('\n'));
}
SimpleLexer tokenize;
tokenize.setSkipComments(true);
QList<SimpleToken> tokens = tokenize(text, previousBlockState(initialBlock));
tokens.prepend(SimpleToken()); // sentinel
tokens->append(tokenize(*text, previousBlockState(initialBlock)));
tokens->prepend(SimpleToken()); // sentinel
if (startPosition)
*startPosition = initialBlock.position();
}
QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
{
QList<SimpleToken> tokens;
QString text;
init(cursor, &tokens, &text);
_jumpedComma = false;
......@@ -236,3 +248,28 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
- tokens.at(i).position());
}
int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor)
{
QList<SimpleToken> tokens;
QString text;
int startPosition;
init(cursor, &tokens, &text, &startPosition);
int index = tokens.size();
forever {
const SimpleToken &tk = tokens.at(index - 1);
if (tk.is(T_EOF_SYMBOL))
break;
else if (tk.is(T_LPAREN))
return startPosition + tk.position();
else if (tk.is(T_RPAREN))
index = startOfMatchingBrace(tokens, index);
else
--index;
}
return -1;
}
......@@ -50,8 +50,14 @@ public:
~ExpressionUnderCursor();
QString operator()(const QTextCursor &cursor);
int startOfFunctionCall(const QTextCursor &cursor);
private:
void init(const QTextCursor &cursor,
QList<SimpleToken> *tokens,
QString *text,
int *startPosition = 0);
int startOfMatchingBrace(const QList<SimpleToken> &tk, int index);
int startOfExpression(const QList<SimpleToken> &tk, int index);
int previousBlockState(const QTextBlock &block);
......
......@@ -223,9 +223,14 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
continue;
if (q->nameCount() > 1) {
Name *classOrNamespaceName =
control()->qualifiedNameId(q->names(),
q->nameCount() - 1);
Name *classOrNamespaceName = 0;
if (q->nameCount() == 1)
classOrNamespaceName = q->nameAt(0);
else
classOrNamespaceName = control()->qualifiedNameId(q->names(),
q->nameCount() - 1);
const QList<Symbol *> resolvedClassOrNamespace =
resolveClassOrNamespace(classOrNamespaceName, visibleScopes);
......
......@@ -1388,6 +1388,10 @@ bool Preprocessor::isQtReservedWord(const QByteArray &macroId) const
return true;
else if (size == 7 && macroId.at(0) == 'Q' && macroId == "Q_SLOTS")
return true;
else if (size == 8 && macroId.at(0) == 'Q' && macroId == "Q_SIGNAL")
return true;
else if (size == 6 && macroId.at(0) == 'Q' && macroId == "Q_SLOT")
return true;
else if (size == 6 && macroId.at(0) == 'S' && macroId == "SIGNAL")
return true;
else if (size == 4 && macroId.at(0) == 'S' && macroId == "SLOT")
......
......@@ -41,8 +41,10 @@
#ifdef Q_OS_WIN
#include <windows.h>
QT_BEGIN_NAMESPACE
class QWinEventNotifier;
class QTemporaryFile;
QT_END_NAMESPACE
#endif
namespace Core {
......
......@@ -147,6 +147,7 @@ SubmitEditorWidget::SubmitEditorWidget(QWidget *parent) :
m_d->m_ui.setupUi(this);
m_d->m_ui.description->setContextMenuPolicy(Qt::CustomContextMenu);
m_d->m_ui.description->setLineWrapMode(QTextEdit::NoWrap);
m_d->m_ui.description->setWordWrapMode(QTextOption::WordWrap);
connect(m_d->m_ui.description, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(editorCustomContextMenuRequested(QPoint)));
......@@ -156,9 +157,6 @@ SubmitEditorWidget::SubmitEditorWidget(QWidget *parent) :
connect(m_d->m_ui.fileView, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(diffActivated(QModelIndex)));
// Text
m_d->m_ui.description->setFont(QFont(QLatin1String("Courier")));
setFocusPolicy(Qt::StrongFocus);
setFocusProxy(m_d->m_ui.description);
}
......@@ -168,7 +166,7 @@ SubmitEditorWidget::~SubmitEditorWidget()
delete m_d;
}
void SubmitEditorWidget::registerActions(QAction *editorUndoAction, QAction *editorRedoAction,
void SubmitEditorWidget::registerActions(QAction *editorUndoAction, QAction *editorRedoAction,
QAction *submitAction, QAction *diffAction)
{
if (editorUndoAction) {
......
......@@ -40,6 +40,8 @@
#include <QtCore/QtConcurrentRun>
#include <QtCore/QSettings>
#include <QtGui/QFormLayout>
#include <QtGui/QDesktopServices>
#include <QtGui/QApplication>
using namespace CMakeProjectManager::Internal;
......@@ -134,7 +136,83 @@ QString CMakeManager::findCbpFile(const QDir &directory)
return QString::null;
}
// This code is duplicated from qtversionmanager
QString CMakeManager::qtVersionForQMake(const QString &qmakePath)
{
QProcess qmake;
qmake.start(qmakePath, QStringList()<<"--version");
if (!qmake.waitForFinished())
return false;
QString output = qmake.readAllStandardOutput();
QRegExp regexp("(QMake version|Qmake version:)[\\s]*([\\d.]*)");
regexp.indexIn(output);
if (regexp.cap(2).startsWith("2.")) {
QRegExp regexp2("Using Qt version[\\s]*([\\d\\.]*)");
regexp2.indexIn(output);
return regexp2.cap(1);
}
return QString();
}
QString CMakeManager::findQtDir(const ProjectExplorer::Environment &env)
{
QStringList possibleCommands;
// On windows noone has renamed qmake, right?
#ifdef Q_OS_WIN
possibleCommands << "qmake.exe";
#endif
// On unix some distributions renamed qmake to avoid clashes
possibleCommands << "qmake-qt4" << "qmake4" << "qmake";
QStringList paths = env.path();
foreach (const QString &path, paths) {
foreach (const QString &possibleCommand, possibleCommands) {
QFileInfo qmake(path + "/" + possibleCommand);
if (qmake.exists()) {
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) {
QDir dir(qmake.absoluteDir());
dir.cdUp();
return dir.absolutePath();
}
}
}
}
return QString();
}
// This code is more or less duplicated in qtversionmanager
QString CMakeManager::findDumperLibrary(const ProjectExplorer::Environment &env)
{
static ProjectExplorer::Environment lastenv;
static QString lastpath;
if (lastenv == env)
return lastpath;
QString qtdir = findQtDir(env);
if (qtdir.isEmpty())
return QString();
uint hash = qHash(qtdir);
QStringList directories;
directories
<< (qtdir + "/qtc-debugging-helper/")
<< (QApplication::applicationDirPath() + "/../qtc-debugging-helper/" + QString::number(hash)) + "/"
<< (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qtc-debugging-helper/" + QString::number(hash)) + "/";
foreach(const QString &directory, directories) {
#if defined(Q_OS_WIN)
QFileInfo fi(directory + "debug/gdbmacros.dll");
#elif defined(Q_OS_MAC)
QFileInfo fi(directory + "libgdbmacros.dylib");
#else // generic UNIX
QFileInfo fi(directory + "libgdbmacros.so");
#endif
if (fi.exists()) {
lastpath = fi.filePath();
return lastpath;
}
}
lastpath = QString();
return lastpath;
}
/////
// CMakeRunner
......
......@@ -32,6 +32,7 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/iprojectmanager.h>
#include <projectexplorer/environment.h>
#include <utils/pathchooser.h>
#include <QtCore/QFuture>
#include <QtCore/QStringList>
......@@ -60,7 +61,11 @@ public:
QProcess* createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory);
static QString findCbpFile(const QDir &);
static QString findDumperLibrary(const ProjectExplorer::Environment &env);
private:
static QString qtVersionForQMake(const QString &qmakePath);
static QString findQtDir(const ProjectExplorer::Environment &env);
int m_projectContext;
int m_projectLanguage;
CMakeSettingsPage *m_settingsPage;
......
......@@ -34,6 +34,8 @@
#include <projectexplorer/environment.h>
#include <utils/qtcassert.h>
#include <QtGui/QFormLayout>
#include <QtGui/QLineEdit>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
......@@ -74,8 +76,7 @@ QString CMakeRunConfiguration::workingDirectory() const
QStringList CMakeRunConfiguration::commandLineArguments() const
{
// TODO
return QStringList();
return ProjectExplorer::Environment::parseCombinedArgString(m_arguments);
}
ProjectExplorer::Environment CMakeRunConfiguration::environment() const
......@@ -106,6 +107,7 @@ void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writ
writer.saveValue("CMakeRunConfiguration.WorkingDirectory", m_workingDirectory);
writer.saveValue("CMakeRunConfiguration.UseTerminal", m_runMode == Console);
writer.saveValue("CMakeRunConfiguation.Title", m_title);
writer.saveValue("CMakeRunConfiguration.Arguments", m_arguments);