Commit 473b6abb authored by dt's avatar dt
Browse files

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

parents 87e40ac6 1931d22a
......@@ -1436,32 +1436,31 @@
\title Handling External Libraries
Knowing external libraries is not only important for the
underlying build system, but also for Qt Creator itself.
This way, it can support code completion and syntax highlighting
for external libraries as if they were part of the current
project or the Qt library.
The way to add a library to the project depends on the
project type, which influcences the build system used.
The following sections describe the the procedure required
for each project type.
The ability to recognize external libraries is not only important for the
underlying buidl system, but also for Qt Creator itself. This ability
allows Qt Creator to support code completion and syntax highlighting for
external libraries as if they were part of the current project or the Qt
library.
The procedure of adding a library to a project, depends on the type of
project, which influences the build system used. The following sections
describe the the procedure required for each project type.
\section1 QMake Projects (the default)
Open your your (ending in \c{.pro}) file from the
\gui{Projects} pane, which will now show up in the editor.
Follow the description in the
Open your project file (\c{.pro}) from the \gui{Projects} pane. Then,
follow the guidelines in the
\l{http://doc.qtsoftware.com/latest/make-project-files.html#declaring-other-libraries}
{Declaring other Libraries} section of the Qt documentation.
If your project does sucessfully build and link against
the external library, syntax completion and highlighting
should also work.
If your project successfully builds and links against the external library,
syntax completion and highlighting should also work.
\section1 CMake Projects
In CMake, libaries are usually detected using the \c{FIND_PACKAGE()} macro.
In CMake, libraries are usually detected using the \c{FIND_PACKAGE()} macro.
A couple of them are already being shipped with CMake, they can be found in
the \c{Modules} directory of your CMake installation. If you provide
libraries on your own, you will need to provide your own \c{FindFoo.cmake}
......
......@@ -581,7 +581,8 @@ QByteArray Preprocessor::expand(const QByteArray &source)
void Preprocessor::expand(const QByteArray &source, QByteArray *result)
{
_expand(source, result);
if (result)
_expand(source, result);
}
void Preprocessor::expand(const char *first, const char *last, QByteArray *result)
......
......@@ -62,6 +62,7 @@ struct WelcomeModePrivate
Ui::WelcomePage ui;
RSSFetcher *rssFetcher;
WelcomeMode::WelcomePageData lastData;
int currentTip;
};
WelcomeModePrivate::WelcomeModePrivate()
......@@ -104,8 +105,7 @@ WelcomeMode::WelcomeMode() :
l->setMargin(0);
l->setSpacing(0);
l->addWidget(new QToolBar(m_d->m_widget));
// limit to 7 items to avoid scrollbars
m_d->rssFetcher = new RSSFetcher(7, this);
m_d->rssFetcher = new RSSFetcher(8, this);
m_d->m_welcomePage = new QWidget(m_d->m_widget);
m_d->ui.setupUi(m_d->m_welcomePage);
m_d->ui.sessTreeWidget->viewport()->setAutoFillBackground(false);
......@@ -156,7 +156,18 @@ WelcomeMode::WelcomeMode() :
m_d->ui.tutorialTreeWidget->addItem(tr("Writing test cases"),
QLatin1String("qthelp://com.trolltech.qt/qdoc/qtestlib-tutorial.html"));
m_d->ui.didYouKnowTextBrowser->setText(getTipOfTheDay());
srand(QDateTime::currentDateTime().toTime_t());
QStringList tips = tipsOfTheDay();
m_d->currentTip = rand()%tips.count();
QTextDocument *doc = m_d->ui.didYouKnowTextBrowser->document();
doc->setDefaultStyleSheet("a:link {color:black;}");
m_d->ui.didYouKnowTextBrowser->setDocument(doc);
m_d->ui.didYouKnowTextBrowser->setText(tips.at(m_d->currentTip));
connect(m_d->ui.nextTipBtn, SIGNAL(clicked()), this, SLOT(slotNextTip()));
connect(m_d->ui.prevTipBtn, SIGNAL(clicked()), this, SLOT(slotPrevTip()));
QSettings *settings = ICore::instance()->settings();
int id = settings->value("General/WelcomeTab", 0).toInt();
m_d->btnGrp->button(id)->setChecked(true);
......@@ -215,8 +226,7 @@ void WelcomeMode::updateWelcomePage(const WelcomePageData &welcomePageData)
m_d->ui.projTreeWidget->clear();
if (welcomePageData.sessionList.count() > 1) {
// limit list to 7 displayed entries to avoid a scrollbar
foreach (const QString &s, welcomePageData.sessionList.mid(0, 6)) {
foreach (const QString &s, welcomePageData.sessionList) {
QString str = s;
if (s == welcomePageData.previousSession)
str = tr("%1 (last session)").arg(s);
......@@ -229,8 +239,7 @@ void WelcomeMode::updateWelcomePage(const WelcomePageData &welcomePageData)
}
typedef QPair<QString, QString> QStringPair;
// limit list to 8 displayed entries to avoid a scrollbar
foreach (const QStringPair &it, welcomePageData.projectList.mid(0, 7)) {
foreach (const QStringPair &it, welcomePageData.projectList) {
QTreeWidgetItem *item = m_d->ui.projTreeWidget->addItem(it.second, it.first);
const QFileInfo fi(it.first);
item->setToolTip(1, QDir::toNativeSeparators(fi.absolutePath()));
......@@ -282,7 +291,19 @@ void WelcomeMode::slotFeedback()
"http://www.qtsoftware.com/forms/feedback-forms/qt-creator-user-feedback/view")));
}
QString WelcomeMode::getTipOfTheDay()
void WelcomeMode::slotNextTip()
{
QStringList tips = tipsOfTheDay();
m_d->ui.didYouKnowTextBrowser->setText(tips.at((++m_d->currentTip)%tips.count()));
}
void WelcomeMode::slotPrevTip()
{
QStringList tips = tipsOfTheDay();
m_d->ui.didYouKnowTextBrowser->setText(tips.at((--m_d->currentTip)%tips.count()));
}
QStringList WelcomeMode::tipsOfTheDay()
{
static QStringList tips;
if (tips.isEmpty()) {
......@@ -292,17 +313,13 @@ QString WelcomeMode::getTipOfTheDay()
tips.append(tr("You can show and hide the side bar using <tt>Alt+0<tt>."));
tips.append(tr("You can fine tune the <tt>Find</tt> function by selecting &quot;Whole Words&quot; "
"or &quot;Case Sensitive&quot;. Simply click on the icons on the right end of the line edit."));
tips.append(tr("If you add a <a href=\"qthelp://com.nokia.qtcreator/doc/creator-external-library-handling.html\""
tips.append(tr("If you add <a href=\"qthelp://com.nokia.qtcreator/doc/creator-external-library-handling.html\""
">external libraries</a>, Qt Creator will automatically offer syntax highlighting "
"and code completion."));
}
srand(QDateTime::currentDateTime().toTime_t());
return tips.at(rand()%tips.count());
return tips;
}
// --- WelcomeModeButton
WelcomeModeButton::WelcomeModeButton(QWidget *parent) :
......
......@@ -86,10 +86,12 @@ private slots:
void slotSessionClicked(const QString &data);
void slotProjectClicked(const QString &data);
void slotUrlClicked(const QString &data);
void slotNextTip();
void slotPrevTip();
private:
void activateEditMode();
QString getTipOfTheDay();
QStringList tipsOfTheDay();
WelcomeModePrivate *m_d;
};
......
This diff is collapsed.
......@@ -55,14 +55,12 @@ RegisterHandler::RegisterHandler(QObject *parent)
int RegisterHandler::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return m_registers.size();
return parent.isValid() ? 0 : m_registers.size();
}
int RegisterHandler::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 2;
return parent.isValid() ? 0 : 2;
}
QVariant RegisterHandler::data(const QModelIndex &index, int role) const
......
......@@ -40,6 +40,7 @@
#include "watchhandler.h"
#include "watchutils.h"
#include "moduleshandler.h"
#include "gdbmi.h"
#include <utils/qtcassert.h>
......@@ -74,6 +75,21 @@ using namespace Debugger::Constants;
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
#define CB(callback) &TcfEngine::callback, STRINGIFY(callback)
///////////////////////////////////////////////////////////////////////
//
// TcfData
//
///////////////////////////////////////////////////////////////////////
TcfData::TcfData(const QByteArray &data)
{
fromString(data);
qDebug() << "TCF RESPONSE: " << data << " -> " << toString();
}
///////////////////////////////////////////////////////////////////////
//
// TcfEngine
......@@ -119,8 +135,15 @@ void TcfEngine::socketReadyRead()
{
//XSDEBUG("TcfEngine::socketReadyRead()");
m_inbuffer.append(m_socket->readAll());
//handleResponse(QByteArray::fromRawData(m_inbuffer.constData() + start, end - start));
handleResponse(m_inbuffer);
int pos = 0;
while (1) {
int next = m_inbuffer.indexOf("\3\1", pos);
//qDebug() << "pos: " << pos << "next: " << next;
if (next == -1)
break;
handleResponse(m_inbuffer.mid(pos, next - pos));
pos = next + 2;
}
m_inbuffer.clear();
}
......@@ -268,28 +291,61 @@ QList<Symbol> TcfEngine::moduleSymbols(const QString & /*moduleName*/)
}
void TcfEngine::handleResponse(const QByteArray &buf)
void TcfEngine::handleResponse(const QByteArray &response)
{
static QTime lastTime;
//emit tcfOutputAvailable(_(" "), currentTime());
TcfResponse response;
QList<QByteArray> parts = buf.split('\0');
QList<QByteArray> parts = response.split('\0');
if (parts.size() < 2 || !parts.last().isEmpty()) {
qDebug() << "Wrong response packet layout"
<< quoteUnprintableLatin1(response);
return;
}
parts.removeLast(); // always empty
QByteArray tag = parts.at(0);
int n = parts.size();
if (n >= 1)
response.tag = parts.at(0);
if (n >= 2)
response.service = parts.at(1);
if (n >= 3)
response.cmd = parts.at(2);
if (n >= 4)
response.data = parts.at(3);
if (response.cmd != "peerHeartBeat")
emit tcfOutputAvailable(_("\ntcf:"), quoteUnprintableLatin1(buf));
//emit tcfOutputAvailable(_("\ntcf:"), response.toString());
qDebug() << response.toString();
if (response.service == "Locator" && response.cmd == "Hello") {
if (n == 1 && tag == "N") { // unidentified command
qDebug() << "Command not recognized.";
} else if (n == 2 && tag == "N") { // flow control
int congestion = parts.at(1).toInt();
qDebug() << "Congestion: " << congestion;
} else if (n == 4 && tag == "R") { // result data
int token = parts.at(1).toInt();
QByteArray message = parts.at(2);
TcfData data(parts.at(3));
emit tcfOutputAvailable(_("\ntcf R:"), quoteUnprintableLatin1(response));
TcfCommand tcf = m_cookieForToken[token];
TcfData result(data);
//qDebug() << "Good response: " << quoteUnprintableLatin1(response);
if (tcf.callback)
(this->*(tcf.callback))(result, tcf.cookie);
} else if (n == 3 && tag == "P") { // progress data (partial result)
//int token = parts.at(1).toInt();
QByteArray data = parts.at(2);
emit tcfOutputAvailable(_("\ntcf P:"), quoteUnprintableLatin1(response));
} else if (n == 4 && tag == "E") { // an event
QByteArray service = parts.at(1);
QByteArray eventName = parts.at(2);
TcfData data(parts.at(3));
if (eventName != "peerHeartBeat")
emit tcfOutputAvailable(_("\ntcf E:"), quoteUnprintableLatin1(response));
if (service == "Locator" && eventName == "Hello") {
m_services.clear();
foreach (const GdbMi &service, data.children()) {
qDebug() << "Found service: " << service.data();
m_services.append(service.data());
}
QTimer::singleShot(0, this, SLOT(startDebugging()));
}
} else {
qDebug() << "Unknown response packet"
<< quoteUnprintableLatin1(response) << parts;
}
}
void TcfEngine::startDebugging()
{
//postCommand('C', CB(handleRunControlSuspend),
// "RunControl", "suspend", "\"Thread1\"");
//postCommand('C', CB(handleRunControlSuspend),
......@@ -304,12 +360,6 @@ void TcfEngine::handleResponse(const QByteArray &buf)
//postCommand('E', "Locator", "Hello", "");
//postCommand('C', "Locator", "sync", "");
//postCommand("Locator", "redirect", "ID");
return;
}
TcfCommand tcf = m_cookieForToken[1];
if (tcf.callback)
(this->*(tcf.callback))(response, tcf.cookie);
}
void TcfEngine::postCommand(char tag,
......@@ -319,7 +369,7 @@ void TcfEngine::postCommand(char tag,
const QByteArray &cmd,
const QByteArray &args)
{
static int token;
static int token = 50;
++token;
const char delim = 0;
......@@ -330,7 +380,7 @@ void TcfEngine::postCommand(char tag,
QByteArray ba;
ba.append(tag);
ba.append(delim);
ba.append(QString::number(token).toLatin1());
ba.append(QByteArray::number(token));
ba.append(delim);
ba.append(service);
ba.append(delim);
......@@ -353,21 +403,22 @@ void TcfEngine::postCommand(char tag,
emit tcfInputAvailable("send", QString::number(result));
}
void TcfEngine::handleRunControlSuspend(const TcfResponse &response, const QVariant &)
void TcfEngine::handleRunControlSuspend(const TcfData &data, const QVariant &)
{
qDebug() << "HANDLE RESULT";
}
void TcfEngine::handleRunControlGetChildren(const TcfResponse &response, const QVariant &)
void TcfEngine::handleRunControlGetChildren(const TcfData &data, const QVariant &)
{
qDebug() << "HANDLE RESULT" << response.toString();
qDebug() << "HANDLE RUN CONTROL GET CHILDREN" << data.toString();
}
void TcfEngine::handleSysMonitorGetChildren(const TcfResponse &response, const QVariant &)
void TcfEngine::handleSysMonitorGetChildren(const TcfData &data, const QVariant &)
{
qDebug() << "HANDLE RESULT" << response.toString();
qDebug() << "HANDLE RUN CONTROL GET CHILDREN" << data.toString();
}
//////////////////////////////////////////////////////////////////////
//
// Tooltip specific stuff
......
......@@ -47,6 +47,7 @@ QT_END_NAMESPACE
#include "idebuggerengine.h"
#include "debuggermanager.h"
#include "gdbmi.h"
namespace Debugger {
namespace Internal {
......@@ -56,25 +57,10 @@ class IDebuggerManagerAccessForEngines;
class ScriptAgent;
class WatchData;
class TcfResponse
class TcfData : public GdbMi
{
public:
enum ResponseType
{
HelloResponse,
HeartBeatResponse
};
QString toString() const
{
return _("TAG: " + tag + " SERVICE: " + service
+ " CMD: " + cmd + " DATA: " + data);
}
QByteArray tag;
QByteArray service;
QByteArray cmd;
QByteArray data;
TcfData(const QByteArray &data);
};
class TcfEngine : public IDebuggerEngine
......@@ -140,13 +126,15 @@ private:
Q_SLOT void socketReadyRead();
void handleResponse(const QByteArray &ba);
void handleRunControlSuspend(const TcfResponse &response, const QVariant &);
void handleRunControlGetChildren(const TcfResponse &response, const QVariant &);
void handleSysMonitorGetChildren(const TcfResponse &response, const QVariant &);
void handleRunControlSuspend(const TcfData &response, const QVariant &);
void handleRunControlGetChildren(const TcfData &response, const QVariant &);
void handleSysMonitorGetChildren(const TcfData &response, const QVariant &);
private:
Q_SLOT void startDebugging();
typedef void (TcfEngine::*TcfCommandCallback)
(const TcfResponse &record, const QVariant &cookie);
(const TcfData &record, const QVariant &cookie);
struct TcfCommand
{
......@@ -171,6 +159,7 @@ private:
IDebuggerManagerAccessForEngines *qq;
QTcpSocket *m_socket;
QByteArray m_inbuffer;
QStringList m_services;
};
} // namespace Internal
......
#include "duidocument.h"
#include "parser/javascriptast_p.h"
#include "parser/javascriptlexer_p.h"
#include "parser/javascriptparser_p.h"
#include "parser/javascriptengine_p.h"
#include "parser/javascriptnodepool_p.h"
using namespace DuiEditor;
using namespace DuiEditor::Internal;
using namespace JavaScript;
DuiDocument::DuiDocument(const QString &fileName)
: _engine(0), _pool(0), _program(0), _fileName(fileName)
{
}
DuiDocument::~DuiDocument()
{
delete _engine;
delete _pool;
}
DuiDocument::Ptr DuiDocument::create(const QString &fileName)
{
DuiDocument::Ptr doc(new DuiDocument(fileName));
return doc;
}
AST::UiProgram *DuiDocument::program() const
{
return _program;
}
QList<JavaScriptParser::DiagnosticMessage> DuiDocument::diagnosticMessages() const
{
return _diagnosticMessages;
}
void DuiDocument::setSource(const QString &source)
{
_source = source;
}
bool DuiDocument::parse()
{
Q_ASSERT(! _engine);
Q_ASSERT(! _pool);
Q_ASSERT(! _program);
_engine = new JavaScriptEnginePrivate();
_pool = new NodePool(_fileName, _engine);
JavaScriptParser parser;
NodePool nodePool(_fileName, _engine);
_engine->setNodePool(_pool);
Lexer lexer(_engine);
_engine->setLexer(&lexer);
lexer.setCode(_source, /*line = */ 1);
bool parsed = parser.parse(_engine);
_program = parser.ast();
_diagnosticMessages = parser.diagnosticMessages();
return parsed;
}
Snapshot::Snapshot()
{
}
Snapshot::~Snapshot()
{
}
#ifndef DUIDOCUMENT_H
#define DUIDOCUMENT_H
#include <QtCore/QSharedPointer>
#include <QtCore/QMap>
#include <QtCore/QString>
#include "parser/javascriptparser_p.h"
class JavaScriptEnginePrivate;
namespace JavaScript {
class NodePool;
namespace AST {
class UiProgram;
} // end of namespace AST
} // end of namespace JavaScript
namespace DuiEditor {
namespace Internal {
class DuiDocument
{
public:
typedef QSharedPointer<DuiDocument> Ptr;
protected:
DuiDocument(const QString &fileName);
public:
~DuiDocument();
static DuiDocument::Ptr create(const QString &fileName);
JavaScript::AST::UiProgram *program() const;
QList<JavaScriptParser::DiagnosticMessage> diagnosticMessages() const;
void setSource(const QString &source);
bool parse();
private:
JavaScriptEnginePrivate *_engine;
JavaScript::NodePool *_pool;
JavaScript::AST::UiProgram *_program;
QList<JavaScriptParser::DiagnosticMessage> _diagnosticMessages;
QString _fileName;
QString _source;
};
class Snapshot: public QMap<QString, DuiDocument>
{
public:
Snapshot();
~Snapshot();
};
} // end of namespace Internal
} // emd of namespace DuiEditor
#endif // DUIDOCUMENT_H
......@@ -31,15 +31,13 @@
#include "duieditorconstants.h"
#include "duihighlighter.h"
#include "duieditorplugin.h"
#include "duidocument.h"
#include "rewriter/rewriter.h"
#include "parser/javascriptengine_p.h"
#include "parser/javascriptparser_p.h"
#include "parser/javascriptlexer_p.h"
#include "parser/javascriptnodepool_p.h"
#include "parser/javascriptastvisitor_p.h"
#include "parser/javascriptast_p.h"
#include "parser/javascriptengine_p.h"
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
......@@ -435,29 +433,21 @@ void ScriptEditor::updateDocumentNow()
m_updateDocumentTimer->stop();
const QString fileName = file()->fileName();
const QString code = toPlainText();
JavaScriptParser parser;
JavaScriptEnginePrivate driver;
NodePool nodePool(fileName, &driver);