forked from qt-creator/qt-creator
Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta
This commit is contained in:
246
doc/coding-style.qdoc
Normal file
246
doc/coding-style.qdoc
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
/*!
|
||||||
|
|
||||||
|
\contentpage{index.html}{Qt Creator}
|
||||||
|
\page coding-style.html
|
||||||
|
|
||||||
|
\title Qt Creator Coding Rules
|
||||||
|
|
||||||
|
THIS IS PRELIMINARY.
|
||||||
|
|
||||||
|
\section1 Introduction
|
||||||
|
|
||||||
|
The aim of this section is to serve as a guide for the developers, to aid us
|
||||||
|
to build understandable and maintainable code, to create less confusion and
|
||||||
|
surprises when working on Qt Creator.
|
||||||
|
|
||||||
|
As usual: Rules are not set in stone. If there's a good reason to break one,
|
||||||
|
do it, preferably after making sure that there are others agreeing.
|
||||||
|
|
||||||
|
This document is incomplete.
|
||||||
|
|
||||||
|
In general, if you want to contribute to the main source, we expect at least
|
||||||
|
that you:
|
||||||
|
|
||||||
|
\list 1
|
||||||
|
\o The most important rule first: KISS (keep it simple ...): always
|
||||||
|
use a simple implementation in favor of a more complicated one.
|
||||||
|
This eases maintenance a lot.
|
||||||
|
\o Write good C++ code: Readable, well commented when necessary,
|
||||||
|
and taking advantage of the OO model. Follow the \l{Formatting} guidelines.
|
||||||
|
There are also certain \l{Code Constructs} that we try to follow.
|
||||||
|
\o Adapt the code to the structures already existing in Qt Creator, or in
|
||||||
|
the case that you have better ideas, discuss them with other developers
|
||||||
|
before writing the code.
|
||||||
|
\o Take advantage of Qt. Don't re-invent the wheel. Think about what parts
|
||||||
|
of your code are generic enough that they might be incorporated into
|
||||||
|
Qt proper.
|
||||||
|
\o Document interfaces. Right now we use qdoc, but changing to doxygen
|
||||||
|
is being considered.
|
||||||
|
\endlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Submitting Code
|
||||||
|
|
||||||
|
It is implicitly understood that all patches contributed to The Qt Creator
|
||||||
|
Project are made under under the Gnu General Public License, version 2 or later
|
||||||
|
and
|
||||||
|
|
||||||
|
If you have a problem with that, don't contribute code.
|
||||||
|
|
||||||
|
Also please don't just pop up out of the blue with a huge patch (or
|
||||||
|
small) that changes something substantial in Qt Creator. Always discuss your
|
||||||
|
ideas with the other developers on mailing list first.
|
||||||
|
|
||||||
|
When you create the patch, please use git or use "diff -up" since we find
|
||||||
|
that a lot easier to read than the other diff formats. Also please do not
|
||||||
|
send patches that implements or fixes several different things; several
|
||||||
|
patches is a much better option.
|
||||||
|
|
||||||
|
We also require you to provide a commit message entry with every patch,
|
||||||
|
this describes in detail what the patch is doing.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Code Constructs
|
||||||
|
|
||||||
|
We have several guidelines on code constructs, some of these exist to
|
||||||
|
make the code faster, others to make the code clearer. Yet others
|
||||||
|
exist to allow us to take advantage of the strong type checking
|
||||||
|
in C++.
|
||||||
|
|
||||||
|
\list 1
|
||||||
|
\o Declaration of variables should wait as long as possible. The rule
|
||||||
|
is: "Don't declare it until you need it." In C++ there are a lot of
|
||||||
|
user defined types, and these can very often be expensive to
|
||||||
|
initialize. This rule connects to the next rule too.
|
||||||
|
|
||||||
|
\o Make the scope of a variable as small as possible.
|
||||||
|
|
||||||
|
\o Prefer preincrement to postincrement whenever possible.
|
||||||
|
Preincrement has potential of being faster than postincrement. Just
|
||||||
|
think about the obvious implementations of pre/post-increment. This
|
||||||
|
rule applies to decrement too.
|
||||||
|
|
||||||
|
\code
|
||||||
|
++T;
|
||||||
|
--U;
|
||||||
|
-NOT-
|
||||||
|
T++; // not used in Qt Creator
|
||||||
|
U--; // not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
\o Try to minimize evaluation of the same code over and over. This is
|
||||||
|
aimed especially at loops.
|
||||||
|
|
||||||
|
\code
|
||||||
|
|
||||||
|
Container::iterator end = large.end();
|
||||||
|
for (Container::iterator it = large.begin(); it != end; ++it) {
|
||||||
|
...;
|
||||||
|
}
|
||||||
|
-NOT-
|
||||||
|
for (Container::iterator it = large.begin();
|
||||||
|
it != large.end(); ++it) {
|
||||||
|
...;
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section1 Formatting
|
||||||
|
|
||||||
|
\section2 Declarations
|
||||||
|
|
||||||
|
Only one declaration on each line.
|
||||||
|
\code
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
-NOT-
|
||||||
|
int a, b; // not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
This is especially important when initialization is done at the same
|
||||||
|
time.
|
||||||
|
\code
|
||||||
|
QString a = "Joe";
|
||||||
|
QString b = "Foo";
|
||||||
|
-NOT-
|
||||||
|
QString a = "Joe", b = "Foo"; // not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
[Note that 'QString a = "Joe"' is formally calling a copy constructor
|
||||||
|
on a temporary constructed from a string literal and therefore has the
|
||||||
|
potential of being more expensive then direct construction by
|
||||||
|
'QString a("joe")'. However the compiler is allowed to elide the copy
|
||||||
|
(even if it had side effects), and modern compilers typically do so.
|
||||||
|
Given these equal costs, Qt Creator code favours the '=' idiom as it is in
|
||||||
|
line with the traditional C-style initialization, _and_ cannot be
|
||||||
|
mistaken as function declaration, _and_ reduces the level of nested
|
||||||
|
parantheses in more initializations.]
|
||||||
|
|
||||||
|
|
||||||
|
\section2 Pointers and references
|
||||||
|
|
||||||
|
\code
|
||||||
|
char *p = "flop";
|
||||||
|
char &c = *p;
|
||||||
|
-NOT-
|
||||||
|
char* p = "flop"; // not used in Qt Creator
|
||||||
|
char & c = *p; // not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
This is simply in line with the official Qt guide lines.
|
||||||
|
|
||||||
|
Also note that we will have:
|
||||||
|
\code
|
||||||
|
const char *p;
|
||||||
|
-NOT-
|
||||||
|
char const * p; // not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
|
||||||
|
Using a plain 0 for Null pointer constants is always correct and least effort
|
||||||
|
to type. So:
|
||||||
|
\code
|
||||||
|
void *p = 0;
|
||||||
|
-NOT-
|
||||||
|
void *p = NULL; // not used in Qt Creator
|
||||||
|
-NOT-
|
||||||
|
void *p = '\0'; // not used in Qt Creator
|
||||||
|
-NOT-
|
||||||
|
void *p = 42 - 7 * 6; // also not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
Note: As an exception, imported third party code as well as code
|
||||||
|
interfacing the "native" APIs (src/support/os_*) can use NULL.
|
||||||
|
|
||||||
|
|
||||||
|
\section2 Operator names and parentheses
|
||||||
|
\code
|
||||||
|
operator==(type)
|
||||||
|
-NOT-
|
||||||
|
operator == (type) // not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
The == is part of the function name, separating it makes the
|
||||||
|
declaration look like an expression.
|
||||||
|
|
||||||
|
|
||||||
|
\section2 Function names and parentheses
|
||||||
|
\code
|
||||||
|
void mangle()
|
||||||
|
-NOT-
|
||||||
|
void mangle () // not used in Qt Creator
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section2 Naming rules
|
||||||
|
|
||||||
|
Simply follow the style of Qt proper. As examples:
|
||||||
|
\list
|
||||||
|
\o Use descriptive but simple and short names. Do not abbreviate.
|
||||||
|
|
||||||
|
\o Class names are capitalized, and function names lowercased.
|
||||||
|
Enums are named like Classes, values are in lower-case.
|
||||||
|
\endlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section2 Formatting
|
||||||
|
|
||||||
|
Adapt the formatting of your code to the one used in the
|
||||||
|
other parts of Qt Creator. In case there is different formatting for
|
||||||
|
the same construct, use the one used more often.
|
||||||
|
|
||||||
|
|
||||||
|
\section2 Declarations
|
||||||
|
|
||||||
|
- Use this order for the access sections of your class: public,
|
||||||
|
protected, private. The public section is interesting for every
|
||||||
|
user of the class. The private section is only of interest for the
|
||||||
|
implementors of the class (you). [Obviously not true since this is
|
||||||
|
for developers, and we do not want one developer only to be able to
|
||||||
|
read and understand the implementation of class internals. Lgb]
|
||||||
|
|
||||||
|
- Avoid declaring global objects in the declaration file of the class.
|
||||||
|
If the same variable is used for all objects, use a static member.
|
||||||
|
|
||||||
|
- Avoid global or static variables.
|
||||||
|
|
||||||
|
|
||||||
|
\section2 File headers
|
||||||
|
|
||||||
|
If you create a new file, the top of the file should include a
|
||||||
|
header comment equal to the one found in other source files of Qt Creator.
|
||||||
|
|
||||||
|
\section2 Documentation
|
||||||
|
|
||||||
|
The documentation is generated from source and header files.
|
||||||
|
You document for the other developers, not for yourself.
|
||||||
|
In the header you should document interfaces, i.e. what the function does,
|
||||||
|
not the implementation.
|
||||||
|
In the .cpp files you document the implementation if the implementation
|
||||||
|
in non-obvious.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QMap>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@@ -236,6 +236,16 @@ private:
|
|||||||
QList<MacroUse> _macroUses;
|
QList<MacroUse> _macroUses;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CPLUSPLUS_EXPORT Snapshot: public QMap<QString, Document::Ptr>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Snapshot()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
~Snapshot()
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
} // end of namespace CPlusPlus
|
} // end of namespace CPlusPlus
|
||||||
|
|
||||||
#endif // CPPDOCUMENT_H
|
#endif // CPPDOCUMENT_H
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ LookupContext::LookupContext(Control *control)
|
|||||||
LookupContext::LookupContext(Symbol *symbol,
|
LookupContext::LookupContext(Symbol *symbol,
|
||||||
Document::Ptr expressionDocument,
|
Document::Ptr expressionDocument,
|
||||||
Document::Ptr thisDocument,
|
Document::Ptr thisDocument,
|
||||||
const QMap<QString, Document::Ptr> &documents)
|
const Snapshot &documents)
|
||||||
: _symbol(symbol),
|
: _symbol(symbol),
|
||||||
_expressionDocument(expressionDocument),
|
_expressionDocument(expressionDocument),
|
||||||
_thisDocument(thisDocument),
|
_thisDocument(thisDocument),
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
LookupContext(Symbol *symbol,
|
LookupContext(Symbol *symbol,
|
||||||
Document::Ptr expressionDocument,
|
Document::Ptr expressionDocument,
|
||||||
Document::Ptr thisDocument,
|
Document::Ptr thisDocument,
|
||||||
const QMap<QString, Document::Ptr> &documents);
|
const Snapshot &documents);
|
||||||
|
|
||||||
LookupContext(Symbol *symbol,
|
LookupContext(Symbol *symbol,
|
||||||
const LookupContext &context);
|
const LookupContext &context);
|
||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
QList<Symbol *> resolveClassOrNamespace(Name *name) const
|
QList<Symbol *> resolveClassOrNamespace(Name *name) const
|
||||||
{ return resolveClassOrNamespace(name, visibleScopes()); }
|
{ return resolveClassOrNamespace(name, visibleScopes()); }
|
||||||
|
|
||||||
QMap<QString, Document::Ptr> documents() const
|
Snapshot snapshot() const
|
||||||
{ return _documents; }
|
{ return _documents; }
|
||||||
|
|
||||||
enum ResolveMode {
|
enum ResolveMode {
|
||||||
@@ -140,7 +140,7 @@ private:
|
|||||||
Document::Ptr _thisDocument;
|
Document::Ptr _thisDocument;
|
||||||
|
|
||||||
// All documents.
|
// All documents.
|
||||||
QMap<QString, Document::Ptr> _documents;
|
Snapshot _documents;
|
||||||
|
|
||||||
// Visible scopes.
|
// Visible scopes.
|
||||||
QList<Scope *> _visibleScopes;
|
QList<Scope *> _visibleScopes;
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ TypeOfExpression::TypeOfExpression():
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypeOfExpression::setDocuments(const QMap<QString, Document::Ptr> &documents)
|
void TypeOfExpression::setSnapshot(const Snapshot &documents)
|
||||||
{
|
{
|
||||||
m_documents = documents;
|
m_snapshot = documents;
|
||||||
m_lookupContext = LookupContext();
|
m_lookupContext = LookupContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,12 +59,12 @@ QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expr
|
|||||||
{
|
{
|
||||||
QString code = expression;
|
QString code = expression;
|
||||||
if (mode == Preprocess)
|
if (mode == Preprocess)
|
||||||
code = preprocessedExpression(expression, m_documents, document);
|
code = preprocessedExpression(expression, m_snapshot, document);
|
||||||
Document::Ptr expressionDoc = documentForExpression(code);
|
Document::Ptr expressionDoc = documentForExpression(code);
|
||||||
m_ast = extractExpressionAST(expressionDoc);
|
m_ast = extractExpressionAST(expressionDoc);
|
||||||
|
|
||||||
m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc,
|
m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc,
|
||||||
document, m_documents);
|
document, m_snapshot);
|
||||||
|
|
||||||
ResolveExpression resolveExpression(m_lookupContext);
|
ResolveExpression resolveExpression(m_lookupContext);
|
||||||
return resolveExpression(m_ast);
|
return resolveExpression(m_ast);
|
||||||
@@ -103,10 +103,12 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression)
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypeOfExpression::processEnvironment(QMap<QString, Document::Ptr> documents,
|
void TypeOfExpression::processEnvironment(Snapshot documents,
|
||||||
Document::Ptr doc, Environment *env,
|
Document::Ptr doc, Environment *env,
|
||||||
QSet<QString> *processed) const
|
QSet<QString> *processed) const
|
||||||
{
|
{
|
||||||
|
if (! doc)
|
||||||
|
return;
|
||||||
if (processed->contains(doc->fileName()))
|
if (processed->contains(doc->fileName()))
|
||||||
return;
|
return;
|
||||||
processed->insert(doc->fileName());
|
processed->insert(doc->fileName());
|
||||||
@@ -120,7 +122,7 @@ void TypeOfExpression::processEnvironment(QMap<QString, Document::Ptr> documents
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString TypeOfExpression::preprocessedExpression(const QString &expression,
|
QString TypeOfExpression::preprocessedExpression(const QString &expression,
|
||||||
QMap<QString, Document::Ptr> documents,
|
Snapshot documents,
|
||||||
Document::Ptr thisDocument) const
|
Document::Ptr thisDocument) const
|
||||||
{
|
{
|
||||||
Environment env;
|
Environment env;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
* Also clears the lookup context, so can be used to make sure references
|
* Also clears the lookup context, so can be used to make sure references
|
||||||
* to the documents previously used are removed.
|
* to the documents previously used are removed.
|
||||||
*/
|
*/
|
||||||
void setDocuments(const QMap<QString, Document::Ptr> &documents);
|
void setSnapshot(const Snapshot &documents);
|
||||||
|
|
||||||
enum PreprocessMode {
|
enum PreprocessMode {
|
||||||
NoPreprocess,
|
NoPreprocess,
|
||||||
@@ -100,15 +100,15 @@ private:
|
|||||||
ExpressionAST *extractExpressionAST(Document::Ptr doc) const;
|
ExpressionAST *extractExpressionAST(Document::Ptr doc) const;
|
||||||
Document::Ptr documentForExpression(const QString &expression) const;
|
Document::Ptr documentForExpression(const QString &expression) const;
|
||||||
|
|
||||||
void processEnvironment(QMap<QString, CPlusPlus::Document::Ptr> documents,
|
void processEnvironment(CPlusPlus::Snapshot documents,
|
||||||
CPlusPlus::Document::Ptr doc, CPlusPlus::Environment *env,
|
CPlusPlus::Document::Ptr doc, CPlusPlus::Environment *env,
|
||||||
QSet<QString> *processed) const;
|
QSet<QString> *processed) const;
|
||||||
|
|
||||||
QString preprocessedExpression(const QString &expression,
|
QString preprocessedExpression(const QString &expression,
|
||||||
QMap<QString, CPlusPlus::Document::Ptr> documents,
|
CPlusPlus::Snapshot documents,
|
||||||
CPlusPlus::Document::Ptr thisDocument) const;
|
CPlusPlus::Document::Ptr thisDocument) const;
|
||||||
|
|
||||||
QMap<QString, Document::Ptr> m_documents;
|
Snapshot m_snapshot;
|
||||||
ExpressionAST *m_ast;
|
ExpressionAST *m_ast;
|
||||||
LookupContext m_lookupContext;
|
LookupContext m_lookupContext;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,11 +46,12 @@
|
|||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QLineEdit>
|
#include <QtGui/QLineEdit>
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
#ifdef Q_OS_OSX
|
#ifdef Q_OS_MAC
|
||||||
/*static*/ const char * const PathChooser::browseButtonLabel = "Choose...";
|
/*static*/ const char * const PathChooser::browseButtonLabel = "Choose...";
|
||||||
#else
|
#else
|
||||||
/*static*/ const char * const PathChooser::browseButtonLabel = "Browse...";
|
/*static*/ const char * const PathChooser::browseButtonLabel = "Browse...";
|
||||||
@@ -112,7 +113,11 @@ PathChooser::PathChooser(QWidget *parent) :
|
|||||||
hLayout->addWidget(m_d->m_lineEdit);
|
hLayout->addWidget(m_d->m_lineEdit);
|
||||||
hLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
hLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
QPushButton *browseButton = new QPushButton;
|
||||||
|
#else
|
||||||
QToolButton *browseButton = new QToolButton;
|
QToolButton *browseButton = new QToolButton;
|
||||||
|
#endif
|
||||||
browseButton->setText(tr(browseButtonLabel));
|
browseButton->setText(tr(browseButtonLabel));
|
||||||
connect(browseButton, SIGNAL(clicked()), this, SLOT(slotBrowse()));
|
connect(browseButton, SIGNAL(clicked()), this, SLOT(slotBrowse()));
|
||||||
|
|
||||||
|
|||||||
@@ -342,6 +342,10 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget)
|
|||||||
|
|
||||||
m_navigationComboBox = new NavComboBox(this);
|
m_navigationComboBox = new NavComboBox(this);
|
||||||
m_navigationWidget = 0;
|
m_navigationWidget = 0;
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
// this is to avoid ugly tool bar behavior
|
||||||
|
m_navigationComboBox->setMaximumWidth(130);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_toolbar = new QToolBar(this);
|
m_toolbar = new QToolBar(this);
|
||||||
m_toolbar->setContentsMargins(0, 0, 0, 0);
|
m_toolbar->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ VersionDialog::VersionDialog(QWidget *parent)
|
|||||||
"<br/>"
|
"<br/>"
|
||||||
"Built on " __DATE__ " at " __TIME__ "<br />"
|
"Built on " __DATE__ " at " __TIME__ "<br />"
|
||||||
#ifdef IDE_REVISION
|
#ifdef IDE_REVISION
|
||||||
"Using revision %5<br/>"
|
"From revision %5<br/>"
|
||||||
#endif
|
#endif
|
||||||
"<br/>"
|
"<br/>"
|
||||||
"<br/>"
|
"<br/>"
|
||||||
|
|||||||
@@ -427,7 +427,9 @@ void CPPEditor::switchDeclarationDefinition()
|
|||||||
if (!m_modelManager)
|
if (!m_modelManager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Document::Ptr doc = m_modelManager->document(file()->fileName());
|
const Snapshot snapshot = m_modelManager->snapshot();
|
||||||
|
|
||||||
|
Document::Ptr doc = snapshot.value(file()->fileName());
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
Symbol *lastSymbol = doc->findSymbolAt(line, column);
|
Symbol *lastSymbol = doc->findSymbolAt(line, column);
|
||||||
@@ -445,7 +447,7 @@ void CPPEditor::switchDeclarationDefinition()
|
|||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
TypeOfExpression typeOfExpression;
|
TypeOfExpression typeOfExpression;
|
||||||
typeOfExpression.setDocuments(m_modelManager->documents());
|
typeOfExpression.setSnapshot(m_modelManager->snapshot());
|
||||||
QList<TypeOfExpression::Result> resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol);
|
QList<TypeOfExpression::Result> resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol);
|
||||||
const LookupContext &context = typeOfExpression.lookupContext();
|
const LookupContext &context = typeOfExpression.lookupContext();
|
||||||
|
|
||||||
@@ -474,10 +476,12 @@ void CPPEditor::jumpToDefinition()
|
|||||||
if (!m_modelManager)
|
if (!m_modelManager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const Snapshot snapshot = m_modelManager->snapshot();
|
||||||
|
|
||||||
// Find the last symbol up to the cursor position
|
// Find the last symbol up to the cursor position
|
||||||
int line = 0, column = 0;
|
int line = 0, column = 0;
|
||||||
convertPosition(position(), &line, &column);
|
convertPosition(position(), &line, &column);
|
||||||
Document::Ptr doc = m_modelManager->document(file()->fileName());
|
Document::Ptr doc = snapshot.value(file()->fileName());
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -503,7 +507,7 @@ void CPPEditor::jumpToDefinition()
|
|||||||
|
|
||||||
// Evaluate the type of the expression
|
// Evaluate the type of the expression
|
||||||
TypeOfExpression typeOfExpression;
|
TypeOfExpression typeOfExpression;
|
||||||
typeOfExpression.setDocuments(m_modelManager->documents());
|
typeOfExpression.setSnapshot(m_modelManager->snapshot());
|
||||||
QList<TypeOfExpression::Result> resolvedSymbols =
|
QList<TypeOfExpression::Result> resolvedSymbols =
|
||||||
typeOfExpression(expression, doc, lastSymbol);
|
typeOfExpression(expression, doc, lastSymbol);
|
||||||
|
|
||||||
@@ -572,7 +576,7 @@ Symbol *CPPEditor::findDefinition(Symbol *lastSymbol)
|
|||||||
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
|
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
|
||||||
LookupContext context(&control);
|
LookupContext context(&control);
|
||||||
|
|
||||||
const QMap<QString, Document::Ptr> documents = m_modelManager->documents();
|
const Snapshot documents = m_modelManager->snapshot();
|
||||||
foreach (Document::Ptr doc, documents) {
|
foreach (Document::Ptr doc, documents) {
|
||||||
QList<Scope *> visibleScopes;
|
QList<Scope *> visibleScopes;
|
||||||
visibleScopes.append(doc->globalSymbols());
|
visibleScopes.append(doc->globalSymbols());
|
||||||
@@ -744,7 +748,8 @@ void CPPEditor::unCommentSelection()
|
|||||||
|
|
||||||
QString endText = endBlock.text();
|
QString endText = endBlock.text();
|
||||||
int endPos = end - endBlock.position();
|
int endPos = end - endBlock.position();
|
||||||
bool hasTrailingCharacters = !endText.mid(endPos).trimmed().isEmpty();
|
bool hasTrailingCharacters = !endText.left(endPos).remove(QLatin1String("//")).trimmed().isEmpty()
|
||||||
|
&& !endText.mid(endPos).trimmed().isEmpty();
|
||||||
if ((endPos <= endText.length() - 2
|
if ((endPos <= endText.length() - 2
|
||||||
&& endText.at(endPos) == QLatin1Char('*')
|
&& endText.at(endPos) == QLatin1Char('*')
|
||||||
&& endText.at(endPos+1) == QLatin1Char('/'))) {
|
&& endText.at(endPos+1) == QLatin1Char('/'))) {
|
||||||
|
|||||||
@@ -434,10 +434,12 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
|||||||
//if (! expression.isEmpty())
|
//if (! expression.isEmpty())
|
||||||
//qDebug() << "***** expression:" << expression;
|
//qDebug() << "***** expression:" << expression;
|
||||||
|
|
||||||
if (Document::Ptr thisDocument = m_manager->document(fileName)) {
|
const Snapshot snapshot = m_manager->snapshot();
|
||||||
|
|
||||||
|
if (Document::Ptr thisDocument = snapshot.value(fileName)) {
|
||||||
Symbol *symbol = thisDocument->findSymbolAt(line, column);
|
Symbol *symbol = thisDocument->findSymbolAt(line, column);
|
||||||
|
|
||||||
typeOfExpression.setDocuments(m_manager->documents());
|
typeOfExpression.setSnapshot(m_manager->snapshot());
|
||||||
|
|
||||||
QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol,
|
QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol,
|
||||||
TypeOfExpression::Preprocess);
|
TypeOfExpression::Preprocess);
|
||||||
@@ -964,8 +966,10 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
|
|||||||
if (Function *function = symbol->type()->asFunction()) {
|
if (Function *function = symbol->type()->asFunction()) {
|
||||||
// If the member is a function, automatically place the opening parenthesis,
|
// If the member is a function, automatically place the opening parenthesis,
|
||||||
// except when it might take template parameters.
|
// except when it might take template parameters.
|
||||||
if (!function->returnType().isValid()
|
const bool hasReturnType = function->returnType().isValid() ||
|
||||||
&& (function->identity() && !function->identity()->isDestructorNameId())) {
|
function->returnType().isSigned() ||
|
||||||
|
function->returnType().isUnsigned();
|
||||||
|
if (! hasReturnType && (function->identity() && !function->identity()->isDestructorNameId())) {
|
||||||
// Don't insert any magic, since the user might have just wanted to select the class
|
// Don't insert any magic, since the user might have just wanted to select the class
|
||||||
|
|
||||||
} else if (function->templateParameterCount() != 0) {
|
} else if (function->templateParameterCount() != 0) {
|
||||||
@@ -1034,7 +1038,7 @@ void CppCodeCompletion::cleanup()
|
|||||||
|
|
||||||
// Set empty map in order to avoid referencing old versions of the documents
|
// Set empty map in order to avoid referencing old versions of the documents
|
||||||
// until the next completion
|
// until the next completion
|
||||||
typeOfExpression.setDocuments(QMap<QString, Document::Ptr>());
|
typeOfExpression.setSnapshot(Snapshot());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor)
|
int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor)
|
||||||
|
|||||||
@@ -165,9 +165,11 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
|
|||||||
QTextCursor tc(edit->document());
|
QTextCursor tc(edit->document());
|
||||||
tc.setPosition(pos);
|
tc.setPosition(pos);
|
||||||
|
|
||||||
|
const Snapshot documents = m_manager->snapshot();
|
||||||
|
|
||||||
const int lineNumber = tc.block().blockNumber() + 1;
|
const int lineNumber = tc.block().blockNumber() + 1;
|
||||||
const QString fileName = editor->file()->fileName();
|
const QString fileName = editor->file()->fileName();
|
||||||
Document::Ptr doc = m_manager->document(fileName);
|
Document::Ptr doc = documents.value(fileName);
|
||||||
if (doc) {
|
if (doc) {
|
||||||
foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) {
|
foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) {
|
||||||
if (m.line() == lineNumber) {
|
if (m.line() == lineNumber) {
|
||||||
@@ -212,7 +214,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
|
|||||||
Symbol *lastSymbol = doc->findSymbolAt(line, column);
|
Symbol *lastSymbol = doc->findSymbolAt(line, column);
|
||||||
|
|
||||||
TypeOfExpression typeOfExpression;
|
TypeOfExpression typeOfExpression;
|
||||||
typeOfExpression.setDocuments(m_manager->documents());
|
typeOfExpression.setSnapshot(documents);
|
||||||
QList<TypeOfExpression::Result> types = typeOfExpression(expression, doc, lastSymbol);
|
QList<TypeOfExpression::Result> types = typeOfExpression(expression, doc, lastSymbol);
|
||||||
|
|
||||||
if (!types.isEmpty()) {
|
if (!types.isEmpty()) {
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<CppModelManager> m_modelManager;
|
QPointer<CppModelManager> m_modelManager;
|
||||||
CppModelManager::DocumentTable m_documents;
|
Snapshot m_snapshot;
|
||||||
Environment env;
|
Environment env;
|
||||||
pp m_proc;
|
pp m_proc;
|
||||||
QStringList m_includePaths;
|
QStringList m_includePaths;
|
||||||
@@ -160,7 +160,7 @@ private:
|
|||||||
|
|
||||||
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
|
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
|
||||||
: m_modelManager(modelManager),
|
: m_modelManager(modelManager),
|
||||||
m_documents(modelManager->documents()),
|
m_snapshot(modelManager->snapshot()),
|
||||||
m_proc(this, env)
|
m_proc(this, env)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ void CppPreprocessor::mergeEnvironment(Document::Ptr doc, QSet<QString> *process
|
|||||||
processed->insert(fn);
|
processed->insert(fn);
|
||||||
|
|
||||||
foreach (QString includedFile, doc->includedFiles()) {
|
foreach (QString includedFile, doc->includedFiles()) {
|
||||||
mergeEnvironment(m_documents.value(includedFile), processed);
|
mergeEnvironment(m_snapshot.value(includedFile), processed);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const Macro macro, doc->definedMacros()) {
|
foreach (const Macro macro, doc->definedMacros()) {
|
||||||
@@ -386,7 +386,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! contents.isEmpty()) {
|
if (! contents.isEmpty()) {
|
||||||
Document::Ptr cachedDoc = m_documents.value(fileName);
|
Document::Ptr cachedDoc = m_snapshot.value(fileName);
|
||||||
if (cachedDoc && m_currentDoc) {
|
if (cachedDoc && m_currentDoc) {
|
||||||
mergeEnvironment(cachedDoc);
|
mergeEnvironment(cachedDoc);
|
||||||
} else {
|
} else {
|
||||||
@@ -477,11 +477,8 @@ CppModelManager::CppModelManager(QObject *parent) :
|
|||||||
CppModelManager::~CppModelManager()
|
CppModelManager::~CppModelManager()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Document::Ptr CppModelManager::document(const QString &fileName) const
|
Snapshot CppModelManager::snapshot() const
|
||||||
{ return m_documents.value(fileName); }
|
{ return m_snapshot; }
|
||||||
|
|
||||||
CppModelManager::DocumentTable CppModelManager::documents() const
|
|
||||||
{ return m_documents; }
|
|
||||||
|
|
||||||
void CppModelManager::ensureUpdated()
|
void CppModelManager::ensureUpdated()
|
||||||
{
|
{
|
||||||
@@ -672,7 +669,7 @@ void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
|
|||||||
void CppModelManager::onDocumentUpdated(Document::Ptr doc)
|
void CppModelManager::onDocumentUpdated(Document::Ptr doc)
|
||||||
{
|
{
|
||||||
const QString fileName = doc->fileName();
|
const QString fileName = doc->fileName();
|
||||||
m_documents[fileName] = doc;
|
m_snapshot[fileName] = doc;
|
||||||
QList<Core::IEditor *> openedEditors = m_core->editorManager()->openedEditors();
|
QList<Core::IEditor *> openedEditors = m_core->editorManager()->openedEditors();
|
||||||
foreach (Core::IEditor *editor, openedEditors) {
|
foreach (Core::IEditor *editor, openedEditors) {
|
||||||
if (editor->file()->fileName() == fileName) {
|
if (editor->file()->fileName() == fileName) {
|
||||||
@@ -837,7 +834,7 @@ void CppModelManager::parse(QFutureInterface<void> &future,
|
|||||||
|
|
||||||
void CppModelManager::GC()
|
void CppModelManager::GC()
|
||||||
{
|
{
|
||||||
DocumentTable documents = m_documents;
|
Snapshot documents = m_snapshot;
|
||||||
|
|
||||||
QSet<QString> processed;
|
QSet<QString> processed;
|
||||||
QStringList todo = projectFiles();
|
QStringList todo = projectFiles();
|
||||||
@@ -868,7 +865,7 @@ void CppModelManager::GC()
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit aboutToRemoveFiles(removedFiles);
|
emit aboutToRemoveFiles(removedFiles);
|
||||||
m_documents = documents;
|
m_snapshot = documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ public:
|
|||||||
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
|
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
|
||||||
virtual void updateProjectInfo(const ProjectInfo &pinfo);
|
virtual void updateProjectInfo(const ProjectInfo &pinfo);
|
||||||
|
|
||||||
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const;
|
virtual CPlusPlus::Snapshot snapshot() const;
|
||||||
virtual DocumentTable documents() const;
|
|
||||||
virtual void GC();
|
virtual void GC();
|
||||||
|
|
||||||
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
|
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
|
||||||
@@ -146,7 +145,7 @@ private:
|
|||||||
Core::ICore *m_core;
|
Core::ICore *m_core;
|
||||||
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
|
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
|
||||||
CppHoverHandler *m_hoverHandler;
|
CppHoverHandler *m_hoverHandler;
|
||||||
DocumentTable m_documents;
|
CPlusPlus::Snapshot m_snapshot;
|
||||||
|
|
||||||
// cache
|
// cache
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
|||||||
@@ -46,14 +46,11 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
class CPPTOOLS_EXPORT CppModelManagerInterface
|
class CPPTOOLS_EXPORT CppModelManagerInterface: public QObject
|
||||||
: public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable; // ### remove me
|
|
||||||
|
|
||||||
class ProjectInfo
|
class ProjectInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -89,8 +86,7 @@ public:
|
|||||||
virtual void GC() = 0;
|
virtual void GC() = 0;
|
||||||
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
|
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
|
||||||
|
|
||||||
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const = 0;
|
virtual CPlusPlus::Snapshot snapshot() const = 0;
|
||||||
virtual DocumentTable documents() const = 0;
|
|
||||||
|
|
||||||
virtual QList<ProjectInfo> projectInfos() const = 0;
|
virtual QList<ProjectInfo> projectInfos() const = 0;
|
||||||
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
|
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ include(cpptools_dependencies.pri)
|
|||||||
|
|
||||||
# DEFINES += QT_NO_CAST_FROM_ASCII
|
# DEFINES += QT_NO_CAST_FROM_ASCII
|
||||||
DEFINES += QT_NO_CAST_TO_ASCII
|
DEFINES += QT_NO_CAST_TO_ASCII
|
||||||
unix:QMAKE_CXXFLAGS_DEBUG += -O3
|
|
||||||
INCLUDEPATH += .
|
INCLUDEPATH += .
|
||||||
DEFINES += CPPTOOLS_LIBRARY
|
DEFINES += CPPTOOLS_LIBRARY
|
||||||
CONFIG += help
|
CONFIG += help
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ SOURCES += attachexternaldialog.cpp \
|
|||||||
gdbengine.cpp \
|
gdbengine.cpp \
|
||||||
gdbmi.cpp \
|
gdbmi.cpp \
|
||||||
gdboptionpage.cpp \
|
gdboptionpage.cpp \
|
||||||
gdbtypemacros.cpp \
|
|
||||||
gdbengine.h \
|
gdbengine.h \
|
||||||
moduleshandler.cpp \
|
moduleshandler.cpp \
|
||||||
moduleswindow.cpp \
|
moduleswindow.cpp \
|
||||||
@@ -79,7 +78,6 @@ FORMS += attachexternaldialog.ui \
|
|||||||
breakcondition.ui \
|
breakcondition.ui \
|
||||||
mode.ui \
|
mode.ui \
|
||||||
gdboptionpage.ui \
|
gdboptionpage.ui \
|
||||||
gdbtypemacros.ui \
|
|
||||||
startexternaldialog.ui \
|
startexternaldialog.ui \
|
||||||
|
|
||||||
RESOURCES += debugger.qrc
|
RESOURCES += debugger.qrc
|
||||||
|
|||||||
@@ -183,7 +183,6 @@ DebuggerPlugin::DebuggerPlugin()
|
|||||||
{
|
{
|
||||||
m_pm = 0;
|
m_pm = 0;
|
||||||
m_generalOptionPage = 0;
|
m_generalOptionPage = 0;
|
||||||
m_typeMacroPage = 0;
|
|
||||||
m_locationMark = 0;
|
m_locationMark = 0;
|
||||||
m_manager = 0;
|
m_manager = 0;
|
||||||
}
|
}
|
||||||
@@ -202,7 +201,6 @@ void DebuggerPlugin::shutdown()
|
|||||||
//qDebug() << "DebuggerPlugin::~DebuggerPlugin";
|
//qDebug() << "DebuggerPlugin::~DebuggerPlugin";
|
||||||
removeObject(m_debugMode);
|
removeObject(m_debugMode);
|
||||||
removeObject(m_generalOptionPage);
|
removeObject(m_generalOptionPage);
|
||||||
removeObject(m_typeMacroPage);
|
|
||||||
|
|
||||||
// FIXME: when using the line below, BreakWindow etc gets deleted twice.
|
// FIXME: when using the line below, BreakWindow etc gets deleted twice.
|
||||||
// so better leak for now...
|
// so better leak for now...
|
||||||
@@ -212,9 +210,6 @@ void DebuggerPlugin::shutdown()
|
|||||||
delete m_generalOptionPage;
|
delete m_generalOptionPage;
|
||||||
m_generalOptionPage = 0;
|
m_generalOptionPage = 0;
|
||||||
|
|
||||||
delete m_typeMacroPage;
|
|
||||||
m_typeMacroPage = 0;
|
|
||||||
|
|
||||||
delete m_locationMark;
|
delete m_locationMark;
|
||||||
m_locationMark = 0;
|
m_locationMark = 0;
|
||||||
|
|
||||||
@@ -409,13 +404,10 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
|
|||||||
mdebug->addAction(cmd);
|
mdebug->addAction(cmd);
|
||||||
|
|
||||||
m_generalOptionPage = 0;
|
m_generalOptionPage = 0;
|
||||||
m_typeMacroPage = 0;
|
|
||||||
|
|
||||||
// FIXME:
|
// FIXME:
|
||||||
m_generalOptionPage = new GdbOptionPage(&theGdbSettings());
|
m_generalOptionPage = new GdbOptionPage(&theGdbSettings());
|
||||||
addObject(m_generalOptionPage);
|
addObject(m_generalOptionPage);
|
||||||
m_typeMacroPage = new TypeMacroPage(&theGdbSettings());
|
|
||||||
addObject(m_typeMacroPage);
|
|
||||||
|
|
||||||
m_locationMark = 0;
|
m_locationMark = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ namespace Internal {
|
|||||||
class DebuggerManager;
|
class DebuggerManager;
|
||||||
class DebugMode;
|
class DebugMode;
|
||||||
class GdbOptionPage;
|
class GdbOptionPage;
|
||||||
class TypeMacroPage;
|
|
||||||
class LocationMark;
|
class LocationMark;
|
||||||
|
|
||||||
class DebuggerPlugin : public ExtensionSystem::IPlugin
|
class DebuggerPlugin : public ExtensionSystem::IPlugin
|
||||||
@@ -103,7 +102,6 @@ private:
|
|||||||
|
|
||||||
ExtensionSystem::PluginManager *m_pm;
|
ExtensionSystem::PluginManager *m_pm;
|
||||||
GdbOptionPage *m_generalOptionPage;
|
GdbOptionPage *m_generalOptionPage;
|
||||||
TypeMacroPage *m_typeMacroPage;
|
|
||||||
|
|
||||||
QString m_previousMode;
|
QString m_previousMode;
|
||||||
LocationMark *m_locationMark;
|
LocationMark *m_locationMark;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ enum DataDumperState
|
|||||||
DataDumperUnavailable,
|
DataDumperUnavailable,
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Move to extra file?
|
|
||||||
class GdbSettings
|
class GdbSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ GdbOptionPage::GdbOptionPage(GdbSettings *settings)
|
|||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
defaultCommand.append(".exe");
|
defaultCommand.append(".exe");
|
||||||
#endif
|
#endif
|
||||||
|
QString defaultScript = coreIFace->resourcePath() +
|
||||||
|
QLatin1String("/gdb/qt4macros");
|
||||||
|
|
||||||
m_settings->m_gdbCmd = s->value("Location", defaultCommand).toString();
|
m_settings->m_gdbCmd = s->value("Location", defaultCommand).toString();
|
||||||
|
m_settings->m_scriptFile= s->value("ScriptFile", defaultScript).toString();
|
||||||
m_settings->m_gdbEnv = s->value("Environment", "").toString();
|
m_settings->m_gdbEnv = s->value("Environment", "").toString();
|
||||||
m_settings->m_autoRun = s->value("AutoRun", true).toBool();
|
m_settings->m_autoRun = s->value("AutoRun", true).toBool();
|
||||||
m_settings->m_autoQuit = s->value("AutoQuit", true).toBool();
|
m_settings->m_autoQuit = s->value("AutoQuit", true).toBool();
|
||||||
@@ -72,36 +76,50 @@ QString GdbOptionPage::name() const
|
|||||||
|
|
||||||
QString GdbOptionPage::category() const
|
QString GdbOptionPage::category() const
|
||||||
{
|
{
|
||||||
return "Debugger|Gdb";
|
return "Debugger";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbOptionPage::trCategory() const
|
QString GdbOptionPage::trCategory() const
|
||||||
{
|
{
|
||||||
return tr("Debugger|Gdb");
|
return tr("Debugger");
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *GdbOptionPage::createPage(QWidget *parent)
|
QWidget *GdbOptionPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
QWidget *w = new QWidget(parent);
|
QWidget *w = new QWidget(parent);
|
||||||
m_ui.setupUi(w);
|
m_ui.setupUi(w);
|
||||||
m_ui.gdbEdit->setText(m_settings->m_gdbCmd);
|
m_ui.gdbLocationChooser->setExpectedKind(Core::Utils::PathChooser::Command);
|
||||||
m_ui.envEdit->setText(m_settings->m_gdbEnv);
|
m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location"));
|
||||||
|
m_ui.gdbLocationChooser->setPath(m_settings->m_gdbCmd);
|
||||||
|
m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File);
|
||||||
|
m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File"));
|
||||||
|
m_ui.scriptFileChooser->setPath(m_settings->m_scriptFile);
|
||||||
|
m_ui.environmentEdit->setText(m_settings->m_gdbEnv);
|
||||||
m_ui.autoStartBox->setChecked(m_settings->m_autoRun);
|
m_ui.autoStartBox->setChecked(m_settings->m_autoRun);
|
||||||
m_ui.autoQuitBox->setChecked(m_settings->m_autoQuit);
|
m_ui.autoQuitBox->setChecked(m_settings->m_autoQuit);
|
||||||
connect(m_ui.pushButtonBrowse, SIGNAL(clicked()),
|
|
||||||
this, SLOT(browse()));
|
// FIXME
|
||||||
|
m_ui.autoStartBox->hide();
|
||||||
|
m_ui.autoQuitBox->hide();
|
||||||
|
m_ui.environmentEdit->hide();
|
||||||
|
m_ui.labelEnvironment->hide();
|
||||||
|
|
||||||
|
connect(m_ui.gdbLocationChooser, SIGNAL(changed()),
|
||||||
|
this, SLOT(onGdbLocationChanged()));
|
||||||
|
connect(m_ui.scriptFileChooser, SIGNAL(changed()),
|
||||||
|
this, SLOT(onScriptFileChanged()));
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbOptionPage::browse()
|
void GdbOptionPage::onGdbLocationChanged()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(m_ui.pushButtonBrowse,
|
m_settings->m_gdbCmd = m_ui.gdbLocationChooser->path();
|
||||||
"Browse for gdb executable");
|
}
|
||||||
if (fileName.isEmpty())
|
|
||||||
return;
|
void GdbOptionPage::onScriptFileChanged()
|
||||||
m_settings->m_gdbCmd = fileName;
|
{
|
||||||
m_ui.gdbEdit->setText(fileName);
|
m_settings->m_scriptFile = m_ui.scriptFileChooser->path();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbOptionPage::finished(bool accepted)
|
void GdbOptionPage::finished(bool accepted)
|
||||||
@@ -109,10 +127,11 @@ void GdbOptionPage::finished(bool accepted)
|
|||||||
if (!accepted)
|
if (!accepted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_settings->m_gdbCmd = m_ui.gdbEdit->text();
|
m_settings->m_gdbCmd = m_ui.gdbLocationChooser->path();
|
||||||
m_settings->m_gdbEnv = m_ui.envEdit->text();
|
m_settings->m_gdbEnv = m_ui.environmentEdit->text();
|
||||||
m_settings->m_autoRun = m_ui.autoStartBox->isChecked();
|
m_settings->m_autoRun = m_ui.autoStartBox->isChecked();
|
||||||
m_settings->m_autoQuit = m_ui.autoQuitBox->isChecked();
|
m_settings->m_autoQuit = m_ui.autoQuitBox->isChecked();
|
||||||
|
m_settings->m_scriptFile = m_ui.scriptFileChooser->path();
|
||||||
|
|
||||||
Core::ICore *coreIFace = m_pm->getObject<Core::ICore>();
|
Core::ICore *coreIFace = m_pm->getObject<Core::ICore>();
|
||||||
if (!coreIFace || !coreIFace->settings())
|
if (!coreIFace || !coreIFace->settings())
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
#define GDBOPTIONPAGE_H
|
#define GDBOPTIONPAGE_H
|
||||||
|
|
||||||
#include "ui_gdboptionpage.h"
|
#include "ui_gdboptionpage.h"
|
||||||
#include "ui_gdbtypemacros.h"
|
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
@@ -63,7 +62,8 @@ public:
|
|||||||
void finished(bool accepted);
|
void finished(bool accepted);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void browse();
|
void onGdbLocationChanged();
|
||||||
|
void onScriptFileChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExtensionSystem::PluginManager *m_pm;
|
ExtensionSystem::PluginManager *m_pm;
|
||||||
@@ -72,6 +72,7 @@ private:
|
|||||||
GdbSettings *m_settings;
|
GdbSettings *m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
class TypeMacroPage : public Core::IOptionsPage
|
class TypeMacroPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -87,7 +88,6 @@ public:
|
|||||||
void finished(bool accepted);
|
void finished(bool accepted);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onScriptButton();
|
|
||||||
void onAddButton();
|
void onAddButton();
|
||||||
void onDelButton();
|
void onDelButton();
|
||||||
void currentItemChanged(QTreeWidgetItem *item);
|
void currentItemChanged(QTreeWidgetItem *item);
|
||||||
@@ -100,6 +100,7 @@ private:
|
|||||||
GdbSettings *m_settings;
|
GdbSettings *m_settings;
|
||||||
QWidget *m_widget;
|
QWidget *m_widget;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>433</width>
|
<width>433</width>
|
||||||
<height>216</height>
|
<height>233</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Gdb Debug Options</string>
|
<string>Locations</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
@@ -32,46 +32,45 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="gdbEdit"/>
|
<widget class="QLineEdit" name="environmentEdit"/>
|
||||||
</item>
|
|
||||||
<item row="1" column="1" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="envEdit"/>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="labelGdbLocaltion">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>This is either a full abolute path leading to the gdb binary you intend to use or the name of a gdb binary that wiull be searched in your PATH.</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Gdb Location:</string>
|
<string>Gdb Location:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
|
||||||
<cstring>gdbEdit</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="labelEnvironment">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Environment:</string>
|
<string>Environment:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>envEdit</cstring>
|
<cstring>environmentEdit</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="2" column="0">
|
||||||
<widget class="QPushButton" name="pushButtonBrowse">
|
<widget class="QLabel" name="labelGdbStartupScript">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>This is either empty or points to a file containing gdb commands that will be executed immediately after gdb starts up.</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Gdb Startup Script:</string>
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../coreplugin/core.qrc">
|
|
||||||
<normaloff>:/qworkbench/images/fileopen.png</normaloff>:/qworkbench/images/fileopen.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="Core::Utils::PathChooser" name="scriptFileChooser" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="Core::Utils::PathChooser" name="gdbLocationChooser" native="true"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -104,6 +103,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Core::Utils::PathChooser</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">utils/pathchooser.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../coreplugin/core.qrc"/>
|
<include location="../coreplugin/core.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
|
|||||||
|
|
||||||
m_widget = new QWidget(parent);
|
m_widget = new QWidget(parent);
|
||||||
m_ui.setupUi(m_widget);
|
m_ui.setupUi(m_widget);
|
||||||
|
m_ui.scriptFile->setPromptDialogTitle(tr("Select Gdb Script"));
|
||||||
|
m_ui.scriptFile->setExpectedKind(Core::Utils::PathChooser::File);
|
||||||
|
|
||||||
connect(m_ui.addButton, SIGNAL(clicked()),
|
connect(m_ui.addButton, SIGNAL(clicked()),
|
||||||
this, SLOT(onAddButton()));
|
this, SLOT(onAddButton()));
|
||||||
@@ -116,8 +118,8 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
|
|||||||
connect(m_ui.delButton, SIGNAL(clicked()),
|
connect(m_ui.delButton, SIGNAL(clicked()),
|
||||||
this, SLOT(onDelButton()));
|
this, SLOT(onDelButton()));
|
||||||
|
|
||||||
connect(m_ui.scriptButton, SIGNAL(clicked()),
|
connect(m_ui.scriptFile, SIGNAL(validChanged()),
|
||||||
this, SLOT(onScriptButton()));
|
this, SLOT(updateButtonState()));
|
||||||
|
|
||||||
connect(m_ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
connect(m_ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||||
this, SLOT(currentItemChanged(QTreeWidgetItem *)));
|
this, SLOT(currentItemChanged(QTreeWidgetItem *)));
|
||||||
@@ -139,7 +141,7 @@ QWidget *TypeMacroPage::createPage(QWidget *parent)
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui.scriptEdit->setText(m_settings->m_scriptFile);
|
m_ui.scriptFile->setPath(m_settings->m_scriptFile);
|
||||||
|
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
|
|
||||||
@@ -152,7 +154,7 @@ void TypeMacroPage::finished(bool accepted)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_settings->m_typeMacros.clear();
|
m_settings->m_typeMacros.clear();
|
||||||
m_settings->m_scriptFile = m_ui.scriptEdit->text();
|
m_settings->m_scriptFile = m_ui.scriptFile->path();
|
||||||
|
|
||||||
for (int i = 0; i < m_ui.treeWidget->topLevelItemCount(); ++i) {
|
for (int i = 0; i < m_ui.treeWidget->topLevelItemCount(); ++i) {
|
||||||
QTreeWidgetItem *item = m_ui.treeWidget->topLevelItem(i);
|
QTreeWidgetItem *item = m_ui.treeWidget->topLevelItem(i);
|
||||||
@@ -172,13 +174,6 @@ void TypeMacroPage::finished(bool accepted)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypeMacroPage::onScriptButton()
|
|
||||||
{
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(m_widget, tr("Select Gdb Script"));
|
|
||||||
m_ui.scriptEdit->setText(fileName);
|
|
||||||
updateButtonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TypeMacroPage::onAddButton()
|
void TypeMacroPage::onAddButton()
|
||||||
{
|
{
|
||||||
if (m_ui.typeEdit->text().isEmpty() || m_ui.macroEdit->text().isEmpty())
|
if (m_ui.typeEdit->text().isEmpty() || m_ui.macroEdit->text().isEmpty())
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<author></author>
|
|
||||||
<comment></comment>
|
|
||||||
<exportmacro></exportmacro>
|
|
||||||
<class>TypeMacroPage</class>
|
<class>TypeMacroPage</class>
|
||||||
<widget class="QWidget" name="TypeMacroPage">
|
<widget class="QWidget" name="TypeMacroPage">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@@ -9,50 +7,19 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>519</width>
|
<width>519</width>
|
||||||
<height>238</height>
|
<height>263</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout">
|
||||||
<property name="margin" >
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox" >
|
|
||||||
<property name="title" >
|
|
||||||
<string>Script File</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing" >
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="scriptEdit" />
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="scriptButton" >
|
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>21</width>
|
|
||||||
<height>23</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
@@ -90,7 +57,8 @@
|
|||||||
<string>+</string>
|
<string>+</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="gdbdebugger.qrc" >:/gdbdebugger/images/newitem.png</iconset>
|
<iconset>
|
||||||
|
<normaloff>:/gdbdebugger/images/newitem.png</normaloff>:/gdbdebugger/images/newitem.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -113,10 +81,10 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout">
|
||||||
<property name="margin" >
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing" >
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@@ -131,7 +99,8 @@
|
|||||||
<string>-</string>
|
<string>-</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="gdbdebugger.qrc" >:/gdbdebugger/images/delete.png</iconset>
|
<iconset>
|
||||||
|
<normaloff>:/gdbdebugger/images/delete.png</normaloff>:/gdbdebugger/images/delete.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -140,7 +109,7 @@
|
|||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
<height>40</height>
|
<height>40</height>
|
||||||
@@ -178,7 +147,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<pixmapfunction></pixmapfunction>
|
|
||||||
<resources>
|
<resources>
|
||||||
<include location="gdbdebugger.qrc"/>
|
<include location="gdbdebugger.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ static QString niceType(QString type)
|
|||||||
"std::allocator<wchar_t> >", "std::wstring");
|
"std::allocator<wchar_t> >", "std::wstring");
|
||||||
|
|
||||||
// std::vector
|
// std::vector
|
||||||
static QRegExp re1("std::vector<(.*)\\s*,std::allocator<(.*)>\\s*>");
|
static QRegExp re1("std::vector<(.*), std::allocator<(.*)>\\s*>");
|
||||||
re1.setMinimal(true);
|
re1.setMinimal(true);
|
||||||
for (int i = 0; i != 10; ++i) {
|
for (int i = 0; i != 10; ++i) {
|
||||||
if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2))
|
if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2))
|
||||||
@@ -420,7 +420,7 @@ static QString niceType(QString type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// std::list
|
// std::list
|
||||||
static QRegExp re2("std::list<(.*)\\s*,std::allocator<(.*)>\\s*>");
|
static QRegExp re2("std::list<(.*), std::allocator<(.*)>\\s*>");
|
||||||
re2.setMinimal(true);
|
re2.setMinimal(true);
|
||||||
for (int i = 0; i != 10; ++i) {
|
for (int i = 0; i != 10; ++i) {
|
||||||
if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2))
|
if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2))
|
||||||
@@ -428,6 +428,17 @@ static QString niceType(QString type)
|
|||||||
type.replace(re2.cap(0), "std::list<" + re2.cap(1) + ">");
|
type.replace(re2.cap(0), "std::list<" + re2.cap(1) + ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// std::map
|
||||||
|
static QRegExp re3("std::map<(.*), (.*), std::less<(.*)\\s*>, "
|
||||||
|
"std::allocator<std::pair<const (.*), (.*)\\s*> > >");
|
||||||
|
re3.setMinimal(true);
|
||||||
|
for (int i = 0; i != 10; ++i) {
|
||||||
|
if (re3.indexIn(type) == -1 || re3.cap(1) != re3.cap(3)
|
||||||
|
|| re3.cap(1) != re3.cap(4) || re3.cap(2) != re3.cap(5))
|
||||||
|
break;
|
||||||
|
type.replace(re3.cap(0), "std::map<" + re3.cap(1) + ", " + re3.cap(2) + ">");
|
||||||
|
}
|
||||||
|
|
||||||
type.replace(" >", ">");
|
type.replace(" >", ">");
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ QList<Document::Ptr> WorkbenchIntegration::findDocuments(const QString &uiFileNa
|
|||||||
|
|
||||||
QList<Document::Ptr> docList;
|
QList<Document::Ptr> docList;
|
||||||
// take all docs
|
// take all docs
|
||||||
CppTools::CppModelManagerInterface::DocumentTable docTable = cppModelManager->documents();
|
CPlusPlus::Snapshot docTable = cppModelManager->snapshot();
|
||||||
foreach (Document::Ptr doc, docTable) { // we go through all documents
|
foreach (Document::Ptr doc, docTable) { // we go through all documents
|
||||||
QStringList includes = doc->includedFiles();
|
QStringList includes = doc->includedFiles();
|
||||||
foreach (QString include, includes) {
|
foreach (QString include, includes) {
|
||||||
@@ -253,7 +253,7 @@ Document::Ptr WorkbenchIntegration::findDefinition(Function *functionDeclaration
|
|||||||
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
|
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
|
||||||
LookupContext context(&control);
|
LookupContext context(&control);
|
||||||
|
|
||||||
const QMap<QString, Document::Ptr> documents = cppModelManager->documents();
|
const Snapshot documents = cppModelManager->snapshot();
|
||||||
foreach (Document::Ptr doc, documents) {
|
foreach (Document::Ptr doc, documents) {
|
||||||
QList<Scope *> visibleScopes;
|
QList<Scope *> visibleScopes;
|
||||||
visibleScopes.append(doc->globalSymbols());
|
visibleScopes.append(doc->globalSymbols());
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class AllProjectsFilter : public QuickOpen::BaseFileFilter
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
AllProjectsFilter(ProjectExplorerPlugin *pe, Core::ICore *core);
|
AllProjectsFilter(ProjectExplorerPlugin *pe, Core::ICore *core);
|
||||||
QString trName() const { return tr("File in any project"); }
|
QString trName() const { return tr("Files in any project"); }
|
||||||
QString name() const { return "File in any project"; }
|
QString name() const { return "Files in any project"; }
|
||||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
|
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
|
||||||
void refresh(QFutureInterface<void> &future);
|
void refresh(QFutureInterface<void> &future);
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class CurrentProjectFilter : public QuickOpen::BaseFileFilter
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CurrentProjectFilter(ProjectExplorerPlugin *pe, Core::ICore *core);
|
CurrentProjectFilter(ProjectExplorerPlugin *pe, Core::ICore *core);
|
||||||
QString trName() const { return tr("File in current project"); }
|
QString trName() const { return tr("Files in current project"); }
|
||||||
QString name() const { return "File in current project"; }
|
QString name() const { return "Files in current project"; }
|
||||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
|
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
|
||||||
void refresh(QFutureInterface<void> &future);
|
void refresh(QFutureInterface<void> &future);
|
||||||
|
|
||||||
|
|||||||
@@ -498,12 +498,8 @@ void Qt4Project::updateCodeModel()
|
|||||||
pinfo.sourceFiles = files;
|
pinfo.sourceFiles = files;
|
||||||
|
|
||||||
modelmanager->updateProjectInfo(pinfo);
|
modelmanager->updateProjectInfo(pinfo);
|
||||||
|
|
||||||
modelmanager->GC();
|
|
||||||
modelmanager->updateSourceFiles(pinfo.sourceFiles);
|
modelmanager->updateSourceFiles(pinfo.sourceFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update info
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ QByteArray DirectoryFilter::saveState() const
|
|||||||
out << m_directories;
|
out << m_directories;
|
||||||
out << m_filters;
|
out << m_filters;
|
||||||
out << shortcutString();
|
out << shortcutString();
|
||||||
out << defaultActiveState();
|
out << isIncludedByDefault();
|
||||||
out << m_files;
|
out << m_files;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
|||||||
m_ui.directoryList->addItems(m_directories);
|
m_ui.directoryList->addItems(m_directories);
|
||||||
m_ui.fileTypeEdit->setText(m_filters.join(tr(",")));
|
m_ui.fileTypeEdit->setText(m_filters.join(tr(",")));
|
||||||
m_ui.shortcutEdit->setText(shortcutString());
|
m_ui.shortcutEdit->setText(shortcutString());
|
||||||
m_ui.defaultFlag->setChecked(!defaultActiveState());
|
m_ui.defaultFlag->setChecked(!isIncludedByDefault());
|
||||||
updateOptionButtons();
|
updateOptionButtons();
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
QMutexLocker locker(&m_lock);
|
QMutexLocker locker(&m_lock);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
|||||||
ui.setupUi(&dialog);
|
ui.setupUi(&dialog);
|
||||||
|
|
||||||
ui.hiddenFilesFlag->setChecked(m_includeHidden);
|
ui.hiddenFilesFlag->setChecked(m_includeHidden);
|
||||||
ui.limitCheck->setChecked(!defaultActiveState());
|
ui.limitCheck->setChecked(!isIncludedByDefault());
|
||||||
ui.shortcutEdit->setText(shortcutString());
|
ui.shortcutEdit->setText(shortcutString());
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
@@ -132,7 +132,7 @@ QByteArray FileSystemFilter::saveState() const
|
|||||||
QDataStream out(&value, QIODevice::WriteOnly);
|
QDataStream out(&value, QIODevice::WriteOnly);
|
||||||
out << m_includeHidden;
|
out << m_includeHidden;
|
||||||
out << shortcutString();
|
out << shortcutString();
|
||||||
out << defaultActiveState();
|
out << isIncludedByDefault();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ class FileSystemFilter : public QuickOpen::IQuickOpenFilter
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FileSystemFilter(Core::EditorManager *editorManager, QuickOpenToolWindow *toolWindow);
|
FileSystemFilter(Core::EditorManager *editorManager, QuickOpenToolWindow *toolWindow);
|
||||||
QString trName() const { return tr("File in file system"); }
|
QString trName() const { return tr("Files in file system"); }
|
||||||
QString name() const { return "File in file system"; }
|
QString name() const { return "Files in file system"; }
|
||||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
|
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
|
||||||
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
||||||
void accept(QuickOpen::FilterEntry selection) const;
|
void accept(QuickOpen::FilterEntry selection) const;
|
||||||
|
|||||||
@@ -43,7 +43,9 @@
|
|||||||
using namespace QuickOpen;
|
using namespace QuickOpen;
|
||||||
|
|
||||||
IQuickOpenFilter::IQuickOpenFilter(QObject *parent):
|
IQuickOpenFilter::IQuickOpenFilter(QObject *parent):
|
||||||
QObject(parent)
|
QObject(parent),
|
||||||
|
m_includedByDefault(false),
|
||||||
|
m_hidden(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ QByteArray IQuickOpenFilter::saveState() const
|
|||||||
QByteArray value;
|
QByteArray value;
|
||||||
QDataStream out(&value, QIODevice::WriteOnly);
|
QDataStream out(&value, QIODevice::WriteOnly);
|
||||||
out << shortcutString();
|
out << shortcutString();
|
||||||
out << defaultActiveState();
|
out << isIncludedByDefault();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +93,7 @@ bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
|||||||
QHBoxLayout *hlayout = new QHBoxLayout;
|
QHBoxLayout *hlayout = new QHBoxLayout;
|
||||||
QLineEdit *shortcutEdit = new QLineEdit(shortcutString());
|
QLineEdit *shortcutEdit = new QLineEdit(shortcutString());
|
||||||
QCheckBox *limitCheck = new QCheckBox(tr("Limit to prefix"));
|
QCheckBox *limitCheck = new QCheckBox(tr("Limit to prefix"));
|
||||||
limitCheck->setChecked(!defaultActiveState());
|
limitCheck->setChecked(!isIncludedByDefault());
|
||||||
|
|
||||||
hlayout->addWidget(new QLabel(tr("Prefix:")));
|
hlayout->addWidget(new QLabel(tr("Prefix:")));
|
||||||
hlayout->addWidget(shortcutEdit);
|
hlayout->addWidget(shortcutEdit);
|
||||||
@@ -120,12 +122,22 @@ bool IQuickOpenFilter::isConfigurable() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IQuickOpenFilter::defaultActiveState() const
|
bool IQuickOpenFilter::isIncludedByDefault() const
|
||||||
{
|
{
|
||||||
return m_default;
|
return m_includedByDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IQuickOpenFilter::setIncludedByDefault(bool includedByDefault)
|
void IQuickOpenFilter::setIncludedByDefault(bool includedByDefault)
|
||||||
{
|
{
|
||||||
m_default = includedByDefault;
|
m_includedByDefault = includedByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IQuickOpenFilter::isHidden() const
|
||||||
|
{
|
||||||
|
return m_hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IQuickOpenFilter::setHidden(bool hidden)
|
||||||
|
{
|
||||||
|
m_hidden = hidden;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,26 +87,25 @@ public:
|
|||||||
IQuickOpenFilter(QObject *parent = 0);
|
IQuickOpenFilter(QObject *parent = 0);
|
||||||
virtual ~IQuickOpenFilter() {}
|
virtual ~IQuickOpenFilter() {}
|
||||||
|
|
||||||
/* visible name */
|
/* Visible name. */
|
||||||
virtual QString trName() const = 0;
|
virtual QString trName() const = 0;
|
||||||
|
|
||||||
/* internal name */
|
/* Internal name. */
|
||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
|
|
||||||
/* selection list order in case of multiple active filters (high goes on top) */
|
/* Selection list order in case of multiple active filters (high goes on top). */
|
||||||
virtual Priority priority() const = 0;
|
virtual Priority priority() const = 0;
|
||||||
|
|
||||||
/* string to type to use this filter exclusively */
|
/* String to type to use this filter exclusively. */
|
||||||
virtual QString shortcutString() const;
|
QString shortcutString() const;
|
||||||
void setShortcutString(const QString &shortcut);
|
|
||||||
|
|
||||||
/* list of matches for the given user entry */
|
/* List of matches for the given user entry. */
|
||||||
virtual QList<FilterEntry> matchesFor(const QString &entry) = 0;
|
virtual QList<FilterEntry> matchesFor(const QString &entry) = 0;
|
||||||
|
|
||||||
/* user has selected the given entry that belongs to this filter */
|
/* User has selected the given entry that belongs to this filter. */
|
||||||
virtual void accept(FilterEntry selection) const = 0;
|
virtual void accept(FilterEntry selection) const = 0;
|
||||||
|
|
||||||
/* implement to update caches on user request, if that's a long operation */
|
/* Implement to update caches on user request, if that's a long operation. */
|
||||||
virtual void refresh(QFutureInterface<void> &future) = 0;
|
virtual void refresh(QFutureInterface<void> &future) = 0;
|
||||||
|
|
||||||
/* Saved state is used to restore the filter at start up. */
|
/* Saved state is used to restore the filter at start up. */
|
||||||
@@ -126,9 +125,11 @@ public:
|
|||||||
* implementation returns true. */
|
* implementation returns true. */
|
||||||
virtual bool isConfigurable() const;
|
virtual bool isConfigurable() const;
|
||||||
|
|
||||||
/* is this filter used also when the shortcutString is not used? */
|
/* Is this filter used also when the shortcutString is not used? */
|
||||||
virtual bool defaultActiveState() const;
|
bool isIncludedByDefault() const;
|
||||||
void setIncludedByDefault(bool includedByDefault);
|
|
||||||
|
/* Returns whether the filter should be hidden from configuration and menus. */
|
||||||
|
bool isHidden() const;
|
||||||
|
|
||||||
static QString trimWildcards(const QString &str) {
|
static QString trimWildcards(const QString &str) {
|
||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
@@ -143,9 +144,15 @@ public:
|
|||||||
return str.mid(first, last-first+1);
|
return str.mid(first, last-first+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setShortcutString(const QString &shortcut);
|
||||||
|
void setIncludedByDefault(bool includedByDefault);
|
||||||
|
void setHidden(bool hidden);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_shortcut;
|
QString m_shortcut;
|
||||||
bool m_default;
|
bool m_includedByDefault;
|
||||||
|
bool m_hidden;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QuickOpen
|
} // namespace QuickOpen
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ class OpenDocumentsFilter : public QuickOpen::IQuickOpenFilter
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
OpenDocumentsFilter(Core::EditorManager *editorManager);
|
OpenDocumentsFilter(Core::EditorManager *editorManager);
|
||||||
QString trName() const { return tr("Open document"); }
|
QString trName() const { return tr("Open documents"); }
|
||||||
QString name() const { return "Open document"; }
|
QString name() const { return "Open documents"; }
|
||||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
|
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
|
||||||
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
||||||
void accept(QuickOpen::FilterEntry selection) const;
|
void accept(QuickOpen::FilterEntry selection) const;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ QuickOpenFiltersFilter::QuickOpenFiltersFilter(QuickOpenPlugin *plugin,
|
|||||||
m_icon(QIcon(Core::Constants::ICON_NEXT))
|
m_icon(QIcon(Core::Constants::ICON_NEXT))
|
||||||
{
|
{
|
||||||
setIncludedByDefault(true);
|
setIncludedByDefault(true);
|
||||||
setShortcutString(QString());
|
setHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QuickOpenFiltersFilter::trName() const
|
QString QuickOpenFiltersFilter::trName() const
|
||||||
@@ -72,7 +72,7 @@ QList<FilterEntry> QuickOpenFiltersFilter::matchesFor(const QString &entry)
|
|||||||
QList<FilterEntry> entries;
|
QList<FilterEntry> entries;
|
||||||
if (entry.isEmpty()) {
|
if (entry.isEmpty()) {
|
||||||
foreach (IQuickOpenFilter *filter, m_plugin->filter()) {
|
foreach (IQuickOpenFilter *filter, m_plugin->filter()) {
|
||||||
if (!filter->shortcutString().isEmpty()) {
|
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
|
||||||
FilterEntry entry(this,
|
FilterEntry entry(this,
|
||||||
filter->shortcutString(),
|
filter->shortcutString(),
|
||||||
QVariant::fromValue(filter),
|
QVariant::fromValue(filter),
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ void QuickOpenToolWindow::updateFilterList()
|
|||||||
{
|
{
|
||||||
m_filterMenu->clear();
|
m_filterMenu->clear();
|
||||||
foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filter()) {
|
foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filter()) {
|
||||||
if (!filter->shortcutString().isEmpty()) {
|
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
|
||||||
QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected()));
|
QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected()));
|
||||||
action->setData(qVariantFromValue(filter));
|
action->setData(qVariantFromValue(filter));
|
||||||
}
|
}
|
||||||
@@ -396,7 +396,7 @@ QList<IQuickOpenFilter*> QuickOpenToolWindow::filtersFor(const QString &text, QS
|
|||||||
searchText = text;
|
searchText = text;
|
||||||
QList<IQuickOpenFilter*> activeFilters;
|
QList<IQuickOpenFilter*> activeFilters;
|
||||||
foreach (IQuickOpenFilter *filter, filters)
|
foreach (IQuickOpenFilter *filter, filters)
|
||||||
if (filter->defaultActiveState())
|
if (filter->isIncludedByDefault())
|
||||||
activeFilters << filter;
|
activeFilters << filter;
|
||||||
return activeFilters;
|
return activeFilters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,8 +121,11 @@ void SettingsPage::updateFilterList()
|
|||||||
{
|
{
|
||||||
m_ui.filterList->clear();
|
m_ui.filterList->clear();
|
||||||
foreach (IQuickOpenFilter *filter, m_filters) {
|
foreach (IQuickOpenFilter *filter, m_filters) {
|
||||||
|
if (filter->isHidden())
|
||||||
|
continue;
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
if (filter->defaultActiveState())
|
if (filter->isIncludedByDefault())
|
||||||
title = filter->trName();
|
title = filter->trName();
|
||||||
else
|
else
|
||||||
title = tr("%1 (Prefix: %2)").arg(filter->trName()).arg(filter->shortcutString());
|
title = tr("%1 (Prefix: %2)").arg(filter->trName()).arg(filter->shortcutString());
|
||||||
|
|||||||
@@ -735,12 +735,15 @@ void BaseTextEditor::moveLineUpDown(bool up)
|
|||||||
move.clearSelection();
|
move.clearSelection();
|
||||||
move.insertText(text);
|
move.insertText(text);
|
||||||
int end = move.position();
|
int end = move.position();
|
||||||
move.endEditBlock();
|
|
||||||
if (hasSelection) {
|
if (hasSelection) {
|
||||||
move.setPosition(start);
|
move.setPosition(start);
|
||||||
move.setPosition(end, QTextCursor::KeepAnchor);
|
move.setPosition(end, QTextCursor::KeepAnchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indent(document(), move, QChar::Null);
|
||||||
|
move.endEditBlock();
|
||||||
|
|
||||||
setTextCursor(move);
|
setTextCursor(move);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2514,7 +2517,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
}
|
}
|
||||||
} else if (e->button() == Qt::RightButton) {
|
} else if (e->button() == Qt::RightButton) {
|
||||||
QMenu * contextMenu = new QMenu(this);
|
QMenu * contextMenu = new QMenu(this);
|
||||||
emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber(), contextMenu);
|
emit d->m_editable->markContextMenuRequested(editableInterface(), cursor.blockNumber() + 1, contextMenu);
|
||||||
if (!contextMenu->isEmpty())
|
if (!contextMenu->isEmpty())
|
||||||
contextMenu->exec(e->globalPos());
|
contextMenu->exec(e->globalPos());
|
||||||
delete contextMenu;
|
delete contextMenu;
|
||||||
@@ -2765,6 +2768,8 @@ void BaseTextEditor::handleHomeKey(bool anchor)
|
|||||||
|
|
||||||
while (character == tab || character.category() == QChar::Separator_Space) {
|
while (character == tab || character.category() == QChar::Separator_Space) {
|
||||||
++pos;
|
++pos;
|
||||||
|
if (pos == initpos)
|
||||||
|
break;
|
||||||
character = characterAt(pos);
|
character = characterAt(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2952,12 +2957,13 @@ void BaseTextEditor::markBlocksAsChanged(QList<int> blockNumbers) {
|
|||||||
|
|
||||||
TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor *cursor, QChar c)
|
TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor *cursor, QChar c)
|
||||||
{
|
{
|
||||||
if (!TextEditDocumentLayout::hasParentheses(cursor->block()))
|
QTextBlock block = cursor->block();
|
||||||
|
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
|
||||||
return NoMatch;
|
return NoMatch;
|
||||||
|
|
||||||
Parentheses parenList = TextEditDocumentLayout::parentheses(cursor->block());
|
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
|
||||||
Parenthesis openParen, closedParen;
|
Parenthesis openParen, closedParen;
|
||||||
QTextBlock closedParenParag = cursor->block();
|
QTextBlock closedParenParag = block;
|
||||||
|
|
||||||
const int cursorPos = cursor->position() - closedParenParag.position();
|
const int cursorPos = cursor->position() - closedParenParag.position();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -2982,7 +2988,8 @@ TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor
|
|||||||
closedParenParag = closedParenParag.next();
|
closedParenParag = closedParenParag.next();
|
||||||
if (!closedParenParag.isValid())
|
if (!closedParenParag.isValid())
|
||||||
return NoMatch;
|
return NoMatch;
|
||||||
if (TextEditDocumentLayout::hasParentheses(closedParenParag)) {
|
if (TextEditDocumentLayout::hasParentheses(closedParenParag)
|
||||||
|
&& !TextEditDocumentLayout::ifdefedOut(closedParenParag)) {
|
||||||
parenList = TextEditDocumentLayout::parentheses(closedParenParag);
|
parenList = TextEditDocumentLayout::parentheses(closedParenParag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3019,12 +3026,13 @@ TextBlockUserData::MatchType TextBlockUserData::checkOpenParenthesis(QTextCursor
|
|||||||
|
|
||||||
TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCursor *cursor, QChar c)
|
TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCursor *cursor, QChar c)
|
||||||
{
|
{
|
||||||
if (!TextEditDocumentLayout::hasParentheses(cursor->block()))
|
QTextBlock block = cursor->block();
|
||||||
|
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
|
||||||
return NoMatch;
|
return NoMatch;
|
||||||
|
|
||||||
Parentheses parenList = TextEditDocumentLayout::parentheses(cursor->block());
|
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
|
||||||
Parenthesis openParen, closedParen;
|
Parenthesis openParen, closedParen;
|
||||||
QTextBlock openParenParag = cursor->block();
|
QTextBlock openParenParag = block;
|
||||||
|
|
||||||
const int cursorPos = cursor->position() - openParenParag.position();
|
const int cursorPos = cursor->position() - openParenParag.position();
|
||||||
int i = parenList.count() - 1;
|
int i = parenList.count() - 1;
|
||||||
@@ -3050,7 +3058,8 @@ TextBlockUserData::MatchType TextBlockUserData::checkClosedParenthesis(QTextCurs
|
|||||||
if (!openParenParag.isValid())
|
if (!openParenParag.isValid())
|
||||||
return NoMatch;
|
return NoMatch;
|
||||||
|
|
||||||
if (TextEditDocumentLayout::hasParentheses(openParenParag)) {
|
if (TextEditDocumentLayout::hasParentheses(openParenParag)
|
||||||
|
&& !TextEditDocumentLayout::ifdefedOut(openParenParag)) {
|
||||||
parenList = TextEditDocumentLayout::parentheses(openParenParag);
|
parenList = TextEditDocumentLayout::parentheses(openParenParag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3092,7 +3101,7 @@ bool TextBlockUserData::findPreviousOpenParenthesis(QTextCursor *cursor, bool se
|
|||||||
int ignore = 0;
|
int ignore = 0;
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
|
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
|
||||||
if (!parenList.isEmpty()) {
|
if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) {
|
||||||
for (int i = parenList.count()-1; i >= 0; --i) {
|
for (int i = parenList.count()-1; i >= 0; --i) {
|
||||||
Parenthesis paren = parenList.at(i);
|
Parenthesis paren = parenList.at(i);
|
||||||
if (block == cursor->block() && position - block.position() <= paren.pos + 1)
|
if (block == cursor->block() && position - block.position() <= paren.pos + 1)
|
||||||
@@ -3119,7 +3128,7 @@ bool TextBlockUserData::findNextClosingParenthesis(QTextCursor *cursor, bool sel
|
|||||||
int ignore = 0;
|
int ignore = 0;
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
|
Parentheses parenList = TextEditDocumentLayout::parentheses(block);
|
||||||
if (!parenList.isEmpty()) {
|
if (!parenList.isEmpty() && !TextEditDocumentLayout::ifdefedOut(block)) {
|
||||||
for (int i = 0; i < parenList.count(); ++i) {
|
for (int i = 0; i < parenList.count(); ++i) {
|
||||||
Parenthesis paren = parenList.at(i);
|
Parenthesis paren = parenList.at(i);
|
||||||
if (block == cursor->block() && position - block.position() >= paren.pos)
|
if (block == cursor->block() && position - block.position() >= paren.pos)
|
||||||
@@ -3144,7 +3153,7 @@ TextBlockUserData::MatchType TextBlockUserData::matchCursorBackward(QTextCursor
|
|||||||
cursor->clearSelection();
|
cursor->clearSelection();
|
||||||
const QTextBlock block = cursor->block();
|
const QTextBlock block = cursor->block();
|
||||||
|
|
||||||
if (!TextEditDocumentLayout::hasParentheses(block))
|
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
|
||||||
return NoMatch;
|
return NoMatch;
|
||||||
|
|
||||||
const int relPos = cursor->position() - block.position();
|
const int relPos = cursor->position() - block.position();
|
||||||
@@ -3166,7 +3175,7 @@ TextBlockUserData::MatchType TextBlockUserData::matchCursorForward(QTextCursor *
|
|||||||
cursor->clearSelection();
|
cursor->clearSelection();
|
||||||
const QTextBlock block = cursor->block();
|
const QTextBlock block = cursor->block();
|
||||||
|
|
||||||
if (!TextEditDocumentLayout::hasParentheses(block))
|
if (!TextEditDocumentLayout::hasParentheses(block) || TextEditDocumentLayout::ifdefedOut(block))
|
||||||
return NoMatch;
|
return NoMatch;
|
||||||
|
|
||||||
const int relPos = cursor->position() - block.position();
|
const int relPos = cursor->position() - block.position();
|
||||||
|
|||||||
@@ -66,6 +66,9 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>20</number>
|
<number>20</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -132,6 +135,9 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>20</number>
|
<number>20</number>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include <QtNetwork/QHostAddress>
|
#include <QtNetwork/QHostAddress>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -131,7 +132,6 @@ void testArray()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void testQByteArray()
|
void testQByteArray()
|
||||||
{
|
{
|
||||||
QByteArray ba = "Hello";
|
QByteArray ba = "Hello";
|
||||||
@@ -142,7 +142,6 @@ void testQByteArray()
|
|||||||
ba += 2;
|
ba += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void testQHash()
|
void testQHash()
|
||||||
{
|
{
|
||||||
QHash<int, float> hgg0;
|
QHash<int, float> hgg0;
|
||||||
@@ -412,6 +411,41 @@ void testStdList()
|
|||||||
vec.push_back(false);
|
vec.push_back(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testStdMap()
|
||||||
|
{
|
||||||
|
std::map<uint, QStringList> ggl;
|
||||||
|
ggl[11] = QStringList() << "11";
|
||||||
|
ggl[22] = QStringList() << "22";
|
||||||
|
|
||||||
|
typedef std::map<uint, QStringList> T;
|
||||||
|
T ggt;
|
||||||
|
ggt[11] = QStringList() << "11";
|
||||||
|
ggt[22] = QStringList() << "22";
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
std::map<uint, float> gg0;
|
||||||
|
gg0[11] = 11.0;
|
||||||
|
gg0[22] = 22.0;
|
||||||
|
|
||||||
|
|
||||||
|
std::map<QString, float> gg1;
|
||||||
|
gg1["22.0"] = 22.0;
|
||||||
|
|
||||||
|
std::map<int, QString> gg2;
|
||||||
|
gg2[22] = "22.0";
|
||||||
|
|
||||||
|
std::map<QString, Foo> gg3;
|
||||||
|
gg3["22.0"] = Foo(22);
|
||||||
|
gg3["33.0"] = Foo(33);
|
||||||
|
|
||||||
|
QObject ob;
|
||||||
|
std::map<QString, QPointer<QObject> > map;
|
||||||
|
map.insert("Hallo", QPointer<QObject>(&ob));
|
||||||
|
map.insert("Welt", QPointer<QObject>(&ob));
|
||||||
|
map.insert(".", QPointer<QObject>(&ob));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void testStdStack()
|
void testStdStack()
|
||||||
{
|
{
|
||||||
std::stack<int *> plist1;
|
std::stack<int *> plist1;
|
||||||
@@ -795,6 +829,7 @@ int main(int argc, char *argv[])
|
|||||||
testArray();
|
testArray();
|
||||||
|
|
||||||
testStdList();
|
testStdList();
|
||||||
|
testStdMap();
|
||||||
testStdStack();
|
testStdStack();
|
||||||
testStdString();
|
testStdString();
|
||||||
testStdVector();
|
testStdVector();
|
||||||
|
|||||||
Reference in New Issue
Block a user