Commit 3e992d5d authored by dt's avatar dt
Browse files

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

parents e21a74cb 573b33d7
......@@ -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.
......@@ -1197,13 +1178,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 +1197,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
......
......@@ -176,7 +176,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
scopes.clear();
foreach (Symbol *candidate, candidates) {
if (ScopedSymbol *scoped = candidate->asScopedSymbol()) {
scopes.append(scoped->members());
expand(scoped->members(), visibleScopes, &scopes);
}
}
}
......@@ -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 {
......
......@@ -156,9 +156,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);
}
......
......@@ -47,6 +47,7 @@
#include <cplusplus/Overview.h>
#include <cplusplus/OverviewModel.h>
#include <cplusplus/SimpleLexer.h>
#include <cplusplus/TokenUnderCursor.h>
#include <cplusplus/TypeOfExpression.h>
#include <cpptools/cppmodelmanagerinterface.h>
......@@ -182,13 +183,13 @@ CPPEditorEditable::CPPEditorEditable(CPPEditor *editor)
CPPEditor::CPPEditor(QWidget *parent)
: TextEditor::BaseTextEditor(parent)
, m_showingLink(false)
{
setParenthesesMatchingEnabled(true);
setMarksVisible(true);
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
baseTextDocument()->setSyntaxHighlighter(new CppHighlighter);
// new QShortcut(QKeySequence("Ctrl+Alt+M"), this, SLOT(foo()), 0, Qt::WidgetShortcut);
#ifdef WITH_TOKEN_MOVE_POSITION
new QShortcut(QKeySequence::MoveToPreviousWord, this, SLOT(moveToPreviousToken()),
......@@ -235,7 +236,7 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
policy.setHorizontalPolicy(QSizePolicy::Expanding);
m_methodCombo->setSizePolicy(policy);
QTreeView *methodView = new OverviewTreeView();
QTreeView *methodView = new OverviewTreeView;
methodView->header()->hide();
methodView->setItemsExpandable(false);
m_methodCombo->setView(methodView);
......@@ -586,7 +587,8 @@ void CPPEditor::switchDeclarationDefinition()
}
}
CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor)
CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
bool lookupDefinition)
{
Link link;
......@@ -627,13 +629,15 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor)
tc.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
const int nameStart = tc.position();
const int nameLength = tc.anchor() - tc.position();
tc.setPosition(endOfName);
// Drop out if we're at a number
if (characterAt(nameStart).isNumber())
// Drop out if we're at a number, string or comment
static TokenUnderCursor tokenUnderCursor;
const SimpleToken tk = tokenUnderCursor(tc);
if (tk.isLiteral() || tk.isComment())
return link;
// Evaluate the type of the expression under the cursor
tc.setPosition(endOfName);
ExpressionUnderCursor expressionUnderCursor;
const QString expression = expressionUnderCursor(tc);
TypeOfExpression typeOfExpression;
......@@ -642,10 +646,22 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor)
typeOfExpression(expression, doc, lastSymbol);
if (!resolvedSymbols.isEmpty()) {
Symbol *symbol = resolvedSymbols.first().second;
if (symbol) {
TypeOfExpression::Result result = resolvedSymbols.first();
if (result.first->isForwardClassDeclarationType()) {
while (! resolvedSymbols.isEmpty()) {
TypeOfExpression::Result r = resolvedSymbols.takeFirst();
if (! r.first->isForwardClassDeclarationType()) {
result = r;
break;
}
}
}
if (Symbol *symbol = result.second) {
Symbol *def = 0;
if (!lastSymbol->isFunction())
if (lookupDefinition && !lastSymbol->isFunction())
def = findDefinition(symbol);
link = linkToSymbol(def ? def : symbol);
......@@ -804,8 +820,7 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e)
void CPPEditor::mouseMoveEvent(QMouseEvent *e)
{
bool hasDestination = false;
Qt::CursorShape cursorShape;
bool linkFound = false;
if (e->modifiers() & Qt::ControlModifier) {
// Link emulation behaviour for 'go to definition'
......@@ -819,33 +834,18 @@ void CPPEditor::mouseMoveEvent(QMouseEvent *e)
onText = cursorRect(nextPos).right() >= e->x();
}
const Link link = findLinkAt(cursor);
const Link link = findLinkAt(cursor, false);
if (onText && !link.fileName.isEmpty()) {
QTextEdit::ExtraSelection sel;
sel.cursor = cursor;
if (link.pos >= 0) {
sel.cursor.setPosition(link.pos);
sel.cursor.setPosition(link.pos + link.length, QTextCursor::KeepAnchor);
} else {
sel.cursor.select(QTextCursor::WordUnderCursor);
}
sel.format.setFontUnderline(true);
sel.format.setForeground(Qt::blue);
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
hasDestination = true;
cursorShape = Qt::PointingHandCursor;
showLink(link);
linkFound = true;
}
}
if (!hasDestination) {
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
cursorShape = Qt::IBeamCursor;
}
if (!linkFound)
clearLink();
TextEditor::BaseTextEditor::mouseMoveEvent(e);
viewport()->setCursor(cursorShape);
}
void CPPEditor::mouseReleaseEvent(QMouseEvent *e)
......@@ -855,8 +855,7 @@ void CPPEditor::mouseReleaseEvent(QMouseEvent *e)
const QTextCursor cursor = cursorForPosition(e->pos());
if (openCppEditorAt(findLinkAt(cursor))) {
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
viewport()->setCursor(Qt::IBeamCursor);
clearLink();
e->accept();
return;
}
......@@ -865,13 +864,42 @@ void CPPEditor::mouseReleaseEvent(QMouseEvent *e)
TextEditor::BaseTextEditor::mouseReleaseEvent(e);
}
void CPPEditor::leaveEvent(QEvent *e)
{
clearLink();
TextEditor::BaseTextEditor::leaveEvent(e);
}
void CPPEditor::keyReleaseEvent(QKeyEvent *e)
{
// Clear link emulation when Ctrl is released
if (e->key() == Qt::Key_Control) {
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
viewport()->setCursor(Qt::IBeamCursor);
}
if (e->key() == Qt::Key_Control)
clearLink();
TextEditor::BaseTextEditor::keyReleaseEvent(e);
}
void CPPEditor::showLink(const Link &link)
{
QTextEdit::ExtraSelection sel;
sel.cursor = textCursor();
sel.cursor.setPosition(link.pos);
sel.cursor.setPosition(link.pos + link.length, QTextCursor::KeepAnchor);
sel.format = m_linkFormat;
sel.format.setFontUnderline(true);
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
viewport()->setCursor(Qt::PointingHandCursor);
m_showingLink = true;
}
void CPPEditor::clearLink()
{
if (!m_showingLink)
return;
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
viewport()->setCursor(Qt::IBeamCursor);
m_showingLink = false;
}
QList<int> CPPEditorEditable::context() const
......@@ -916,6 +944,8 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
highlighter->setFormats(formats.constBegin(), formats.constEnd());
highlighter->rehighlight();
m_linkFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LINK));
}
......
......@@ -99,6 +99,7 @@ protected:
void contextMenuEvent(QContextMenuEvent *);
void mouseMoveEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void leaveEvent(QEvent *);
void keyReleaseEvent(QKeyEvent *);
TextEditor::BaseTextEditorEditable *createEditableInterface();
......@@ -148,9 +149,14 @@ private:
int column; // Target column
};
Link findLinkAt(const QTextCursor &);
void showLink(const Link &);
void clearLink();
bool m_showingLink;
Link findLinkAt(const QTextCursor &, bool lookupDefinition = true);
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
bool openCppEditorAt(const Link &);
QTextCharFormat m_linkFormat;
CppTools::CppModelManagerInterface *m_modelManager;
......
......@@ -101,6 +101,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(act1);
menu.addAction(act2);
menu.addAction(act4);
menu.addSeparator();
menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos());
......
# Detect presence of "Debugging Tools For Windows"
# in case VS compilers are used.
win32 {
# ---- Detect Debugging Tools For Windows
contains(QMAKE_CXX, cl) {
CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows/sdk"
......@@ -26,6 +29,7 @@ SOURCES += \
$$PWD/cdbdebugeventcallback.cpp \
$$PWD/cdbdebugoutput.cpp
} else {
error("Debugging Tools for Windows could not be found in $$CDB_PATH")
message("Debugging Tools for Windows could not be found in $$CDB_PATH")
}
}
}
......@@ -360,6 +360,16 @@ bool CdbDebugEngine::startDebuggerWithExecutable(DebuggerStartMode sm, QString *
return true;
}
void CdbDebugEngine::processTerminated(unsigned long exitCode)
{
if (debugCDB)
qDebug() << Q_FUNC_INFO << exitCode;
m_d->setDebuggeeHandles(0, 0);
m_d->m_debuggerManagerAccess->notifyInferiorExited();
m_d->m_debuggerManager->exitDebugger();
}
void CdbDebugEngine::exitDebugger()
{
if (debugCDB)
......@@ -380,7 +390,9 @@ void CdbDebugEngine::exitDebugger()
break;
case StartExternal:
case StartInternal:
// Terminate and waitr for stop events.
hr = m_d->m_pDebugClient->TerminateCurrentProcess();
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
if (debugCDB)
qDebug() << Q_FUNC_INFO << "terminated" << msgDebugEngineComResult(hr);
......@@ -469,7 +481,7 @@ bool CdbDebugEnginePrivate::updateLocals(int frameIndex,
value = QLatin1String("<unknown>");
}
WatchData wd;
wd.iname = QLatin1String("local");
wd.iname = QLatin1String("local.") + name;
wd.name = name;
wd.value = value;
wd.type = type;
......@@ -592,6 +604,7 @@ void CdbDebugEngine::continueInferior()
m_d->m_debuggerManager->resetLocation();
ULONG executionStatus;
m_d->m_debuggerManagerAccess->notifyInferiorRunningRequested();
HRESULT hr = m_d->m_pDebugControl->GetExecutionStatus(&executionStatus);
if (SUCCEEDED(hr) && executionStatus != DEBUG_STATUS_GO) {
hr = m_d->m_pDebugControl->SetExecutionStatus(DEBUG_STATUS_GO);
......@@ -654,8 +667,10 @@ void CdbDebugEngine::activateFrame(int frameIndex)
if (debugCDB)
qDebug() << Q_FUNC_INFO << frameIndex;
if (m_d->m_debuggerManager->status() != DebuggerInferiorStopped)
if (m_d->m_debuggerManager->status() != DebuggerInferiorStopped) {
qWarning("WARNING %s: invoked while debuggee is running\n", Q_FUNC_INFO);
return;
}
QString errorMessage;
bool success = false;
......@@ -793,7 +808,7 @@ void CdbDebugEngine::timerEvent(QTimerEvent* te)
const HRESULT hr = m_d->m_pDebugControl->WaitForEvent(0, 1);
if (debugCDB)
if (debugCDB > 1 || hr != S_FALSE)
qDebug() << Q_FUNC_INFO << "WaitForEvent" << msgDebugEngineComResult(hr);
qDebug() << Q_FUNC_INFO << "WaitForEvent" << m_d->m_debuggerManager->status() << msgDebugEngineComResult(hr);
switch (hr) {
case S_OK:
......@@ -974,9 +989,10 @@ void CdbDebugEnginePrivate::updateStackTrace()
}