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

This commit is contained in:
dt
2010-03-30 12:59:25 +02:00
46 changed files with 478 additions and 559 deletions

View File

@@ -2,7 +2,7 @@
me=$(dirname $0)
for i in $QTDIR/src/declarative/qml/parser/*.{h,cpp,pri}; do
for i in $QTDIR/src/declarative/qml/parser/*.{g,h,cpp,pri}; do
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qdeclarativejs/qmljs/)
done

View File

@@ -65,6 +65,7 @@
%token T_PUBLIC "public"
%token T_IMPORT "import"
%token T_AS "as"
%token T_ON "on"
--- feed tokens
%token T_FEED_UI_PROGRAM
@@ -653,18 +654,15 @@ case $rule_number: {
node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
node->fileNameToken = loc(2);
} else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
QString text;
for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
text += q->name->asString();
if (q->next) text += QLatin1String(".");
}
node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
node->fileNameToken = loc(2);
}
sym(1).Node = node;
if (! node) {
if (node) {
node->importToken = loc(1);
} else {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
QLatin1String("Expected a qualified name id or a string literal")));
@@ -773,6 +771,17 @@ case $rule_number: {
} break;
./
UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ;
/.
case $rule_number: {
AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer);
node->colonToken = loc(2);
node->hasOnToken = true;
sym(1).Node = node;
} break;
./
UiObjectMember: UiQualifiedId T_COLON Block ;
/.case $rule_number:./
@@ -870,8 +879,8 @@ case $rule_number: {
} break;
./
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT T_IDENTIFIER T_SEMICOLON ;
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(4).sval, sym(6).sval);
@@ -885,8 +894,8 @@ case $rule_number: {
} break;
./
UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval);
@@ -898,8 +907,8 @@ case $rule_number: {
} break;
./
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
@@ -913,8 +922,8 @@ case $rule_number: {
} break;
./
UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
@@ -928,8 +937,8 @@ case $rule_number: {
} break;
./
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
@@ -945,8 +954,8 @@ case $rule_number: {
} break;
./
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType T_IDENTIFIER T_COLON Expression T_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON Expression T_SEMICOLON ;
/.
case $rule_number: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
@@ -1005,6 +1014,15 @@ case $rule_number: {
}
./
JsIdentifier: T_ON ;
/.
case $rule_number: {
QString s = QLatin1String(QmlJSGrammar::spell[T_ON]);
sym(1).sval = driver->intern(s.constData(), s.length());
break;
}
./
--------------------------------------------------------------------------------------------------------
-- Expressions
--------------------------------------------------------------------------------------------------------
@@ -1086,6 +1104,9 @@ case $rule_number: {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
return false; // ### remove me
}
loc(1).length = lexer->tokenLength();
AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
node->literalToken = loc(1);
sym(1).Node = node;
@@ -1103,6 +1124,9 @@ case $rule_number: {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
return false;
}
loc(1).length = lexer->tokenLength();
AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
node->literalToken = loc(1);
sym(1).Node = node;

View File

@@ -273,11 +273,6 @@ case 20: {
node = makeAstNode<AST::UiImport>(driver->nodePool(), importIdLiteral->value);
node->fileNameToken = loc(2);
} else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) {
QString text;
for (AST::UiQualifiedId *q = qualifiedId; q; q = q->next) {
text += q->name->asString();
if (q->next) text += QLatin1String(".");
}
node = makeAstNode<AST::UiImport>(driver->nodePool(), qualifiedId);
node->fileNameToken = loc(2);
}
@@ -571,6 +566,9 @@ case 76: {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
return false; // ### remove me
}
loc(1).length = lexer->tokenLength();
AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
node->literalToken = loc(1);
sym(1).Node = node;
@@ -582,6 +580,9 @@ case 77: {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
return false;
}
loc(1).length = lexer->tokenLength();
AST::RegExpLiteral *node = makeAstNode<AST::RegExpLiteral> (driver->nodePool(), lexer->pattern, lexer->flags);
node->literalToken = loc(1);
sym(1).Node = node;

View File

@@ -290,8 +290,8 @@ public:
WizardProgress *m_wizardProgress;
};
Wizard::Wizard(QWidget *parent) :
QWizard(parent), d_ptr(new WizardPrivate)
Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags) :
QWizard(parent, flags), d_ptr(new WizardPrivate)
{
d_ptr->q_ptr = this;
d_ptr->m_wizardProgress = new WizardProgress(this);
@@ -301,6 +301,11 @@ Wizard::Wizard(QWidget *parent) :
setSideWidget(new LinearProgressWidget(d_ptr->m_wizardProgress, this));
}
Wizard::~Wizard()
{
delete d_ptr;
}
bool Wizard::isAutomaticProgressCreationEnabled() const
{
Q_D(const Wizard);
@@ -563,6 +568,7 @@ WizardProgress::~WizardProgress()
delete it.key();
++it;
}
delete d_ptr;
}
WizardProgressItem *WizardProgress::addItem(const QString &title)
@@ -764,7 +770,7 @@ WizardProgressItem::WizardProgressItem(WizardProgress *progress, const QString &
WizardProgressItem::~WizardProgressItem()
{
delete d_ptr;
}
void WizardProgressItem::addPage(int pageId)

View File

@@ -47,7 +47,8 @@ class QTCREATOR_UTILS_EXPORT Wizard : public QWizard
Q_PROPERTY(bool automaticProgressCreationEnabled READ isAutomaticProgressCreationEnabled WRITE setAutomaticProgressCreationEnabled)
public:
explicit Wizard(QWidget *parent = 0);
explicit Wizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
virtual ~Wizard();
bool isAutomaticProgressCreationEnabled() const;
void setAutomaticProgressCreationEnabled(bool enabled);
@@ -66,7 +67,7 @@ private:
Q_DISABLE_COPY(Wizard)
Q_DECLARE_PRIVATE(Wizard)
QScopedPointer<WizardPrivate> d_ptr;
class WizardPrivate *d_ptr;
};
class WizardProgressItem;
@@ -118,7 +119,7 @@ private:
Q_DISABLE_COPY(WizardProgress)
Q_DECLARE_PRIVATE(WizardProgress)
QScopedPointer<WizardProgressPrivate> d_ptr;
class WizardProgressPrivate *d_ptr;
};
class WizardProgressItemPrivate;
@@ -150,7 +151,7 @@ private:
Q_DISABLE_COPY(WizardProgressItem)
Q_DECLARE_PRIVATE(WizardProgressItem)
QScopedPointer<WizardProgressItemPrivate> d_ptr;
class WizardProgressItemPrivate *d_ptr;
};
} // namespace Utils

View File

@@ -64,7 +64,8 @@ namespace Internal {
// ----------- Category model
struct Category {
class Category {
public:
QString id;
QString displayName;
QIcon icon;

View File

@@ -75,7 +75,6 @@ namespace Core {
EditorToolBar::EditorToolBar(QWidget *parent) :
Utils::StyledBar(parent),
m_editorList(new QComboBox(this)),
m_rightToolBar(new QToolBar(this)),
m_closeButton(new QToolButton),
m_lockButton(new QToolButton),
@@ -124,10 +123,6 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
m_forwardButton= new QToolButton(this);
m_forwardButton->setDefaultAction(m_goForwardAction);
m_rightToolBar->setLayoutDirection(Qt::RightToLeft);
m_rightToolBar->addWidget(m_closeButton);
m_rightToolBar->addWidget(m_lockButton);
QHBoxLayout *toplayout = new QHBoxLayout(this);
toplayout->setSpacing(0);
toplayout->setMargin(0);
@@ -135,7 +130,8 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
toplayout->addWidget(m_forwardButton);
toplayout->addWidget(m_editorList);
toplayout->addWidget(m_toolBarPlaceholder, 1); // Custom toolbar stretches
toplayout->addWidget(m_rightToolBar);
toplayout->addWidget(m_lockButton);
toplayout->addWidget(m_closeButton);
setLayout(toplayout);

View File

@@ -111,8 +111,6 @@ private:
IEditor *currentEditor() const;
Core::OpenEditorsModel *m_editorsListModel;
QComboBox *m_editorList;
QToolBar *m_centerToolBar;
QToolBar *m_rightToolBar;
QToolButton *m_closeButton;
QToolButton *m_lockButton;
QAction *m_goBackAction;

View File

@@ -264,31 +264,8 @@ FancyActionBar::FancyActionBar(QWidget *parent)
spacerLayout->setSpacing(0);
setLayout(spacerLayout);
setContentsMargins(0,2,0,0);
m_runButton = m_debugButton = 0;
m_inDebugMode = false;
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(modeChanged(Core::IMode*)));
#ifdef Q_WS_MAC
qApp->installEventFilter(this);
#endif
}
#ifdef Q_WS_MAC
bool FancyActionBar::eventFilter(QObject *, QEvent *e)
{
if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt)
updateRunDebug();
} else if (e->type() == QEvent::WindowDeactivate)
updateRunDebug();
return false;
}
#endif
void FancyActionBar::addProjectSelector(QAction *action)
{
FancyToolButton* toolButton = new FancyToolButton(this);
@@ -300,40 +277,11 @@ void FancyActionBar::addProjectSelector(QAction *action)
void FancyActionBar::insertAction(int index, QAction *action)
{
FancyToolButton *toolButton = new FancyToolButton(this);
if (action->objectName() == QLatin1String("ProjectExplorer.Run"))
m_runButton = toolButton;
if (action->objectName() == QLatin1String("ProjectExplorer.Debug"))
m_debugButton = toolButton;
toolButton->setDefaultAction(action);
connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged()));
m_actionsLayout->insertWidget(index, toolButton);
}
void FancyActionBar::modeChanged(Core::IMode *mode)
{
m_inDebugMode = (mode->id() == QLatin1String("Debugger.Mode.Debug"));
updateRunDebug();
}
void FancyActionBar::updateRunDebug()
{
if (!m_runButton || !m_debugButton)
return;
bool doDebug = m_inDebugMode;
#ifdef Q_WS_MAC
if (QApplication::keyboardModifiers() && Qt::AltModifier)
doDebug = !doDebug;
#endif
layout()->setEnabled(false);
m_runButton->forceVisible(!doDebug);
m_debugButton->forceVisible(doDebug);
layout()->setEnabled(true);
}
QLayout *FancyActionBar::actionsLayout() const
{
return m_actionsLayout;

View File

@@ -75,23 +75,13 @@ class FancyActionBar : public QWidget
public:
FancyActionBar(QWidget *parent = 0);
#ifdef Q_WS_MAC
bool eventFilter(QObject *, QEvent *);
#endif
void paintEvent(QPaintEvent *event);
void insertAction(int index, QAction *action);
void addProjectSelector(QAction *action);
QLayout *actionsLayout() const;
private slots:
void modeChanged(Core::IMode *mode);
private:
void updateRunDebug();
bool m_inDebugMode;
QVBoxLayout *m_actionsLayout;
FancyToolButton *m_runButton;
FancyToolButton *m_debugButton;
};
} // namespace Internal

View File

@@ -48,7 +48,8 @@ enum { debug = 0 };
namespace CodePaster {
CodePasterProtocol::CodePasterProtocol() :
CodePasterProtocol::CodePasterProtocol(const NetworkAccessManagerProxyPtr &nw) :
NetworkProtocol(nw),
m_page(new CodePaster::CodePasterSettingsPage),
m_pasteReply(0),
m_fetchReply(0),
@@ -98,10 +99,7 @@ void CodePasterProtocol::fetch(const QString &id)
link.append(hostName);
link.append("/?format=raw&id=");
link.append(id);
QUrl url(link);
QNetworkRequest r(url);
m_fetchReply = m_manager.get(r);
m_fetchReply = httpGet(link);
connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
m_fetchId = id;
}
@@ -116,9 +114,7 @@ void CodePasterProtocol::list()
QString link = QLatin1String("http://");
link += hostName;
link += QLatin1String("/?command=browse&format=raw");
QUrl url(link);
QNetworkRequest r(url);
m_listReply = m_manager.get(r);
m_listReply = httpGet(link);
connect(m_listReply, SIGNAL(finished()), this, SLOT(listFinished()));
}
@@ -142,9 +138,7 @@ void CodePasterProtocol::paste(const QString &text,
data += "&poster=";
data += CGI::encodeURL(username).toLatin1();
QUrl url(QLatin1String("http://") + hostName);
QNetworkRequest r(url);
m_pasteReply = m_manager.post(r, data);
m_pasteReply = httpPost(QLatin1String("http://") + hostName, data);
connect(m_pasteReply, SIGNAL(finished()), this, SLOT(pasteFinished()));
}

View File

@@ -32,8 +32,6 @@
#include "protocol.h"
#include <QtNetwork/QNetworkAccessManager>
QT_BEGIN_NAMESPACE
class QNetworkReply;
QT_END_NAMESPACE
@@ -42,11 +40,11 @@ namespace CodePaster {
class CodePasterSettingsPage;
class CodePasterProtocol : public Protocol
class CodePasterProtocol : public NetworkProtocol
{
Q_OBJECT
public:
CodePasterProtocol();
explicit CodePasterProtocol(const NetworkAccessManagerProxyPtr &nw);
~CodePasterProtocol();
QString name() const;
@@ -70,7 +68,6 @@ public slots:
private:
bool isValidHostName(const QString& hostName);
CodePasterSettingsPage *m_page;
QNetworkAccessManager m_manager;
QNetworkReply *m_pasteReply;
QNetworkReply *m_fetchReply;
QNetworkReply *m_listReply;

View File

@@ -65,7 +65,9 @@ using namespace CodePaster;
using namespace Core;
using namespace TextEditor;
CodepasterPlugin::CodepasterPlugin() : m_settings(new Settings)
CodepasterPlugin::CodepasterPlugin() :
m_settings(new Settings),
m_postEditorAction(0), m_postClipboardAction(0), m_fetchAction(0)
{
}
@@ -89,9 +91,10 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m
addAutoReleasedObject(settingsPage);
// Create the protocols and append them to the Settings
Protocol *protos[] = { new CodePasterProtocol(),
new PasteBinDotComProtocol(),
new PasteBinDotCaProtocol(),
const QSharedPointer<NetworkAccessManagerProxy> networkAccessMgrProxy(new NetworkAccessManagerProxy);
Protocol *protos[] = { new CodePasterProtocol(networkAccessMgrProxy),
new PasteBinDotComProtocol(networkAccessMgrProxy),
new PasteBinDotCaProtocol(networkAccessMgrProxy),
0};
for(int i=0; protos[i] != 0; ++i) {
connect(protos[i], SIGNAL(pasteDone(QString)), this, SLOT(finishPost(QString)));
@@ -116,10 +119,15 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m
Core::Command *command;
m_postAction = new QAction(tr("Paste Snippet..."), this);
command = actionManager->registerAction(m_postAction, "CodePaster.Post", globalcontext);
m_postEditorAction = new QAction(tr("Paste Snippet..."), this);
command = actionManager->registerAction(m_postEditorAction, "CodePaster.Post", globalcontext);
command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+P")));
connect(m_postAction, SIGNAL(triggered()), this, SLOT(post()));
connect(m_postEditorAction, SIGNAL(triggered()), this, SLOT(postEditor()));
cpContainer->addAction(command);
m_postClipboardAction = new QAction(tr("Paste Clipboard..."), this);
command = actionManager->registerAction(m_postClipboardAction, "CodePaster.PostClipboard", globalcontext);
connect(m_postClipboardAction, SIGNAL(triggered()), this, SLOT(postClipboard()));
cpContainer->addAction(command);
m_fetchAction = new QAction(tr("Fetch Snippet..."), this);
@@ -145,6 +153,28 @@ void CodepasterPlugin::shutdown()
}
}
void CodepasterPlugin::postEditor()
{
const IEditor* editor = EditorManager::instance()->currentEditor();
const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
if (!textEditor)
return;
QString data = textEditor->selectedText();
if (data.isEmpty())
data = textEditor->contents();
if (!data.isEmpty())
post(data, textEditor->editor()->mimeType());
}
void CodepasterPlugin::postClipboard()
{
QString subtype = QLatin1String("plain");
const QString text = qApp->clipboard()->text(subtype, QClipboard::Clipboard);
if (!text.isEmpty())
post(text, QString());
}
static inline void fixSpecialCharacters(QString &data)
{
QChar *uc = data.data();
@@ -167,18 +197,8 @@ static inline void fixSpecialCharacters(QString &data)
}
}
void CodepasterPlugin::post()
void CodepasterPlugin::post(QString data, const QString &mimeType)
{
const IEditor* editor = EditorManager::instance()->currentEditor();
const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
if (!textEditor)
return;
QString data = textEditor->selectedText();
if (data.isEmpty())
data = textEditor->contents();
if (data.isEmpty())
return;
fixSpecialCharacters(data);
FileDataList lst = splitDiffToFiles(data.toLatin1());
QString username = m_settings->username;
@@ -199,7 +219,7 @@ void CodepasterPlugin::post()
protocolName = view.protocol();
foreach(Protocol *protocol, m_protocols) {
if (protocol->name() == protocolName) {
const Protocol::ContentType ct = Protocol::contentType(textEditor->editor()->mimeType());
const Protocol::ContentType ct = Protocol::contentType(mimeType);
protocol->paste(data, ct, username, comment, description);
break;
}

View File

@@ -58,7 +58,8 @@ public:
virtual void shutdown();
public slots:
void post();
void postEditor();
void postClipboard();
void fetch();
void finishPost(const QString &link);
void finishFetch(const QString &titleDescription,
@@ -66,8 +67,11 @@ public slots:
bool error);
private:
void post(QString data, const QString &mimeType);
const QSharedPointer<Settings> m_settings;
QAction *m_postAction;
QAction *m_postEditorAction;
QAction *m_postClipboardAction;
QAction *m_fetchAction;
QList<Protocol*> m_protocols;
QStringList m_fetchedSnippets;

View File

@@ -32,11 +32,13 @@
#include <QtNetwork/QNetworkReply>
using namespace Core;
namespace CodePaster {
PasteBinDotCaProtocol::PasteBinDotCaProtocol()
PasteBinDotCaProtocol::PasteBinDotCaProtocol(const NetworkAccessManagerProxyPtr &nw) :
NetworkProtocol(nw),
m_fetchReply(0),
m_postId(-1)
{
connect(&http, SIGNAL(requestFinished(int,bool)),
connect(&m_http, SIGNAL(requestFinished(int,bool)),
this, SLOT(postRequestFinished(int,bool)));
}
@@ -44,12 +46,9 @@ void PasteBinDotCaProtocol::fetch(const QString &id)
{
QString link = QLatin1String("http://pastebin.ca/raw/");
link.append(id);
QUrl url(link);
QNetworkRequest r(url);
reply = manager.get(r);
connect(reply, SIGNAL(finished()), this, SLOT(fetchFinished()));
fetchId = id;
m_fetchReply = httpGet(link);
connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
m_fetchId = id;
}
void PasteBinDotCaProtocol::paste(const QString &text,
@@ -69,20 +68,20 @@ void PasteBinDotCaProtocol::paste(const QString &text,
QHttpRequestHeader header("POST", "/quiet-paste.php");
header.setValue("host", "pastebin.ca" );
header.setContentType("application/x-www-form-urlencoded");
http.setHost("pastebin.ca", QHttp::ConnectionModeHttp);
m_http.setHost("pastebin.ca", QHttp::ConnectionModeHttp);
header.setValue("User-Agent", "CreatorPastebin");
postId = http.request(header, data.toAscii());
m_postId = m_http.request(header, data.toAscii());
}
void PasteBinDotCaProtocol::postRequestFinished(int id, bool error)
{
QString link;
if (id == postId) {
if (id == m_postId) {
if (!error) {
QByteArray data = http.readAll();
QByteArray data = m_http.readAll();
link = QString::fromLatin1("http://pastebin.ca/") + QString(data).remove("SUCCESS:");
} else
link = http.errorString();
link = m_http.errorString();
emit pasteDone(link);
}
}
@@ -91,15 +90,15 @@ void PasteBinDotCaProtocol::fetchFinished()
{
QString title;
QString content;
bool error = reply->error();
bool error = m_fetchReply->error();
if (error) {
content = reply->errorString();
content = m_fetchReply->errorString();
} else {
title = QString::fromLatin1("Pastebin.ca: %1").arg(fetchId);
content = reply->readAll();
title = QString::fromLatin1("Pastebin.ca: %1").arg(m_fetchId);
content = m_fetchReply->readAll();
}
reply->deleteLater();
reply = 0;
m_fetchReply->deleteLater();
m_fetchReply = 0;
emit fetchDone(title, content, error);
}
} // namespace CodePaster

View File

@@ -32,15 +32,14 @@
#include "protocol.h"
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QHttp>
namespace CodePaster {
class PasteBinDotCaProtocol : public Protocol
class PasteBinDotCaProtocol : public NetworkProtocol
{
Q_OBJECT
public:
PasteBinDotCaProtocol();
explicit PasteBinDotCaProtocol(const NetworkAccessManagerProxyPtr &nw);
QString name() const { return QLatin1String("Pastebin.Ca"); }
bool hasSettings() const { return false; }
@@ -58,12 +57,11 @@ public slots:
void postRequestFinished(int id, bool error);
private:
QNetworkAccessManager manager;
QNetworkReply *reply;
QString fetchId;
QNetworkReply *m_fetchReply;
QString m_fetchId;
QHttp http;
int postId;
QHttp m_http;
int m_postId;
};
} // namespace CodePaster

View File

@@ -38,6 +38,7 @@
#include <QtCore/QTextStream>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamAttributes>
#include <QtCore/QByteArray>
#include <QtNetwork/QNetworkReply>
@@ -47,7 +48,8 @@ static const char pastePhpScriptpC[] = "api_public.php";
static const char fetchPhpScriptpC[] = "raw.php";
namespace CodePaster {
PasteBinDotComProtocol::PasteBinDotComProtocol() :
PasteBinDotComProtocol::PasteBinDotComProtocol(const NetworkAccessManagerProxyPtr &nw) :
NetworkProtocol(nw),
m_settings(new PasteBinDotComSettings),
m_fetchReply(0),
m_pasteReply(0),
@@ -105,31 +107,29 @@ void PasteBinDotComProtocol::paste(const QString &text,
QTC_ASSERT(!m_pasteReply, return;)
// Format body
m_pasteData = format(ct);
if (!m_pasteData.isEmpty())
m_pasteData.append('&');
m_pasteData += "paste_name=";
m_pasteData += QUrl::toPercentEncoding(username);
QByteArray pasteData = format(ct);
if (!pasteData.isEmpty())
pasteData.append('&');
pasteData += "paste_name=";
pasteData += QUrl::toPercentEncoding(username);
const QString subDomain = m_settings->hostPrefix();
if (!subDomain.isEmpty()) {
m_pasteData += "&paste_subdomain=";
m_pasteData += QUrl::toPercentEncoding(subDomain);
pasteData += "&paste_subdomain=";
pasteData += QUrl::toPercentEncoding(subDomain);
}
m_pasteData += "&paste_code=";
m_pasteData += QUrl::toPercentEncoding(fixNewLines(text));
pasteData += "&paste_code=";
pasteData += QUrl::toPercentEncoding(fixNewLines(text));
// fire request
QString link;
QTextStream(&link) << "http://" << hostName(false) << '/' << pastePhpScriptpC;
QUrl url(link);
QNetworkRequest r(url);
m_pasteReply = m_manager.post(r, m_pasteData);
m_pasteReply = httpPost(link, pasteData);
connect(m_pasteReply, SIGNAL(finished()), this, SLOT(pasteFinished()));
if (debug)
qDebug() << "paste: sending " << m_pasteReply << link << m_pasteData;
qDebug() << "paste: sending " << m_pasteReply << link << pasteData;
}
void PasteBinDotComProtocol::pasteFinished()
@@ -164,10 +164,8 @@ void PasteBinDotComProtocol::fetch(const QString &id)
if (debug)
qDebug() << "fetch: sending " << link;
QUrl url(link);
QNetworkRequest r(url);
m_fetchReply = m_manager.get(r);
m_fetchReply = httpGet(link);
connect(m_fetchReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
m_fetchId = id;
}
@@ -212,9 +210,7 @@ void PasteBinDotComProtocol::list()
QTC_ASSERT(!m_listReply, return;)
// fire request
QUrl url(QLatin1String("http://") + hostName(true));
QNetworkRequest r(url);
m_listReply = m_manager.get(r);
m_listReply = httpGet(QLatin1String("http://") + hostName(true));
connect(m_listReply, SIGNAL(finished()), this, SLOT(listFinished()));
if (debug)
qDebug() << "list: sending " << m_listReply;

View File

@@ -32,19 +32,14 @@
#include "protocol.h"
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QHttp>
#include <QtCore/QByteArray>
namespace CodePaster {
class PasteBinDotComSettings;
class PasteBinDotComProtocol : public Protocol
class PasteBinDotComProtocol : public NetworkProtocol
{
Q_OBJECT
public:
PasteBinDotComProtocol();
explicit PasteBinDotComProtocol(const NetworkAccessManagerProxyPtr &nw);
QString name() const { return QLatin1String("Pastebin.Com"); }
@@ -69,11 +64,9 @@ private:
QString hostName(bool withSubDomain) const;
PasteBinDotComSettings *m_settings;
QNetworkAccessManager m_manager;
QNetworkReply *m_fetchReply;
QNetworkReply *m_pasteReply;
QNetworkReply *m_listReply;
QByteArray m_pasteData;
QString m_fetchId;
int m_postId;

View File

@@ -31,6 +31,11 @@
#include <cpptools/cpptoolsconstants.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtCore/QUrl>
namespace CodePaster {
Protocol::Protocol()
@@ -108,4 +113,46 @@ QString Protocol::textFromHtml(QString data)
data.replace(QLatin1String("&amp;"), QString(QLatin1Char('&')));
return data;
}
// ------------ NetworkAccessManagerProxy
NetworkAccessManagerProxy::NetworkAccessManagerProxy()
{
}
NetworkAccessManagerProxy::~NetworkAccessManagerProxy()
{
}
QNetworkReply *NetworkAccessManagerProxy::httpGet(const QString &link)
{
QUrl url(link);
QNetworkRequest r(url);
return networkAccessManager()->get(r);
}
QNetworkReply *NetworkAccessManagerProxy::httpPost(const QString &link, const QByteArray &data)
{
QUrl url(link);
QNetworkRequest r(url);
return networkAccessManager()->post(r, data);
}
QNetworkAccessManager *NetworkAccessManagerProxy::networkAccessManager()
{
if (m_networkAccessManager.isNull())
m_networkAccessManager.reset(new QNetworkAccessManager);
return m_networkAccessManager.data();
}
// --------- NetworkProtocol
NetworkProtocol::NetworkProtocol(const NetworkAccessManagerProxyPtr &nw) :
m_networkAccessManager(nw)
{
}
NetworkProtocol::~NetworkProtocol()
{
}
} //namespace CodePaster

View File

@@ -31,6 +31,13 @@
#define PROTOCOL_H
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
class QNetworkAccessManager;
class QNetworkReply;
QT_END_NAMESPACE
namespace Core {
class IOptionsPage;
@@ -50,7 +57,7 @@ public:
PostCommentCapability = 0x2,
PostDescriptionCapability = 0x4
};
Protocol();
virtual ~Protocol();
virtual QString name() const = 0;
@@ -82,9 +89,54 @@ signals:
void listDone(const QString &name, const QStringList &result);
protected:
Protocol();
static QString textFromHtml(QString data);
static QString fixNewLines(QString in);
};
/* Proxy for NetworkAccessManager that can be shared with
* delayed initialization and conveniences
* for HTTP-requests. */
class NetworkAccessManagerProxy {
Q_DISABLE_COPY(NetworkAccessManagerProxy)
public:
NetworkAccessManagerProxy();
~NetworkAccessManagerProxy();
QNetworkReply *httpGet(const QString &url);
QNetworkReply *httpPost(const QString &link, const QByteArray &data);
QNetworkAccessManager *networkAccessManager();
private:
QScopedPointer<QNetworkAccessManager> m_networkAccessManager;
};
/* Network-based protocol: Provides access with delayed
* initialization to a QNetworkAccessManager and conveniences
* for HTTP-requests. */
class NetworkProtocol : public Protocol {
Q_OBJECT
public:
virtual ~NetworkProtocol();
protected:
typedef QSharedPointer<NetworkAccessManagerProxy> NetworkAccessManagerProxyPtr;
explicit NetworkProtocol(const NetworkAccessManagerProxyPtr &nw);
inline QNetworkReply *httpGet(const QString &url)
{ return m_networkAccessManager->httpGet(url); }
inline QNetworkReply *httpPost(const QString &link, const QByteArray &data)
{ return m_networkAccessManager->httpPost(link, data); }
inline QNetworkAccessManager *networkAccessManager()
{ return m_networkAccessManager->networkAccessManager(); }
private:
const NetworkAccessManagerProxyPtr m_networkAccessManager;
};
} //namespace CodePaster

View File

@@ -615,8 +615,11 @@ void GdbEngine::handleResponse(const QByteArray &buff)
void GdbEngine::readGdbStandardError()
{
QByteArray err = m_gdbProc.readAllStandardError();
debugMessage(_("UNEXPECTED GDB STDERR: " + err));
if (err == "Undefined command: \"bb\". Try \"help\".\n")
return;
if (err.startsWith("BFD: reopening"))
return;
qWarning() << "Unexpected gdb stderr:" << err;
}
@@ -1650,12 +1653,21 @@ void GdbEngine::handleInferiorShutdown(const GdbResponse &response)
if (response.resultClass == GdbResultDone) {
debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN"));
setState(InferiorShutDown);
} else {
QByteArray ba = response.data.findChild("msg").data();
if (ba.contains(": No such file or directory.")) {
// This happens when someone removed the binary behind our back.
// It is not really an error from a user's point of view.
debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN"));
debugMessage(_("NOTE: " + ba));
setState(InferiorShutDown);
} else {
debugMessage(_("INFERIOR SHUTDOWN FAILED"));
setState(InferiorShutdownFailed);
QString msg = m_gdbAdapter->msgInferiorStopFailed(
QString::fromLocal8Bit(response.data.findChild("msg").data()));
showMessageBox(QMessageBox::Critical, tr("Failed to shut down application"), msg);
showMessageBox(QMessageBox::Critical,
tr("Failed to shut down application"),
m_gdbAdapter->msgInferiorStopFailed(QString::fromLocal8Bit(ba)));
}
}
shutdown(); // re-iterate...
}

View File

@@ -29,6 +29,8 @@
#include "outputparser_test.h"
#if defined(WITH_TESTS)
#include <QtTest>
using namespace ProjectExplorer;
@@ -132,7 +134,6 @@ void OutputParserTester::stdError(const QString &line)
void OutputParserTester::appendOutputParser(IOutputParser *parser)
{
Q_ASSERT(!childParser());
Q_ASSERT(!parser->childParser());
IOutputParser::appendOutputParser(parser);
parser->appendOutputParser(this);
@@ -157,3 +158,5 @@ void OutputParserTester::reset()
m_receivedTasks.clear();
m_receivedOutput = QString();
}
#endif

View File

@@ -30,7 +30,10 @@
#ifndef OUTPUTPARSER_TESTER_H
#define OUTPUTPARSER_TESTER_H
#if defined(WITH_TESTS)
#include "projectexplorer_export.h"
#include "metatypedeclarations.h"
#include "ioutputparser.h"
namespace ProjectExplorer {
@@ -86,4 +89,6 @@ private:
Q_DECLARE_METATYPE(ProjectExplorer::OutputParserTester::Channel)
#endif
#endif // OUTPUTPARSER_TESTER_H

View File

@@ -114,6 +114,9 @@ void TargetSettingsPanelWidget::setupUi()
connect(m_selector, SIGNAL(currentChanged(int,int)),
this, SLOT(currentTargetChanged(int,int)));
// Save active target now as it will change when targets are added:
Target *activeTarget = m_project->activeTarget();
foreach (Target *t, m_project->targets())
targetAdded(t);
@@ -122,11 +125,10 @@ void TargetSettingsPanelWidget::setupUi()
connect(m_selector, SIGNAL(removeButtonClicked()),
this, SLOT(removeTarget()));
if (m_project->activeTarget()) {
m_selector->setCurrentIndex(m_targets.indexOf(m_project->activeTarget()));
}
updateTargetAddAndRemoveButtons();
// Restore target originally set:
m_project->setActiveTarget(activeTarget);
}
void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subIndex)
@@ -136,6 +138,16 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
if (subIndex < -1 || subIndex >= 2)
return;
if (targetIndex == -1 || subIndex == -1) { // no more targets!
delete m_panelWidgets[0];
m_panelWidgets[0] = 0;
delete m_panelWidgets[1];
m_panelWidgets[1] = 0;
m_centralWidget->setCurrentWidget(m_noTargetLabel);
return;
}
Target *target = m_targets.at(targetIndex);
// Target was not actually changed:
@@ -147,13 +159,8 @@ void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subInd
return;
}
m_currentTarget = target;
// Target has changed:
if (targetIndex == -1) { // no more targets!
m_centralWidget->setCurrentWidget(m_noTargetLabel);
return;
}
m_currentTarget = target;
PanelsWidget *buildPanel = new PanelsWidget(m_centralWidget);
PanelsWidget *runPanel = new PanelsWidget(m_centralWidget);

View File

@@ -63,10 +63,13 @@ QVariant read(const QString &typeStr, const QString &str, const MetaInfo &metaIn
QVariant read(const QString &typeStr, const QString &str)
{
int type = QMetaType::type(typeStr.toAscii().constData());
if (type == 0)
if (type == 0) {
qWarning() << "Type " << typeStr
<< " is unknown to QMetaType system. Cannot create properly typed QVariant for value "
<< str;
// Fall back to a QVariant of type String
return QVariant(str);
}
return read(type, str);
}
@@ -108,9 +111,9 @@ QVariant read(int variantType, const QString &str)
}
if (!conversionOk) {
value = QVariant();
qWarning() << "Could not convert" << str
<< "to" << QMetaType::typeName(variantType);
value = QVariant(str);
}
return value;

View File

@@ -538,7 +538,7 @@ void RewriterView::qmlTextChanged()
default: {
emitCustomNotification(StartRewriterAmend);
ModelAmender differenceHandler(m_textToModelMerger.data());
if (m_textToModelMerger->load(newQmlText.toUtf8(), differenceHandler)) {
if (m_textToModelMerger->load(newQmlText, differenceHandler)) {
lastCorrectQmlSource = newQmlText;
}
emitCustomNotification(EndRewriterAmend);

View File

@@ -255,8 +255,10 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc,
differenceHandler.importAbsentInQMl(import);
}
bool TextToModelMerger::load(const QByteArray &data, DifferenceHandler &differenceHandler)
bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceHandler)
{
// qDebug() << "TextToModelMerger::load with data:" << data;
const QUrl url = m_rewriterView->model()->fileUrl();
const QStringList importPaths = m_rewriterView->textModifier()->importPaths();
setActive(true);
@@ -266,7 +268,7 @@ bool TextToModelMerger::load(const QByteArray &data, DifferenceHandler &differen
foreach (const QString &importPath, importPaths)
engine.addImportPath(importPath);
QDeclarativeComponent comp(&engine);
comp.setData(data, url);
comp.setData(data.toUtf8(), url);
if (comp.status() == QDeclarativeComponent::Error) {
QList<RewriterView::Error> errors;
foreach (const QDeclarativeError &error, comp.errors())
@@ -288,7 +290,7 @@ bool TextToModelMerger::load(const QByteArray &data, DifferenceHandler &differen
Snapshot snapshot = m_rewriterView->textModifier()->getSnapshot();
const QString fileName = url.toLocalFile();
Document::Ptr doc = Document::create(fileName.isEmpty() ? QLatin1String("<internal>") : fileName);
doc->setSource(QString::fromUtf8(data.constData()));
doc->setSource(data);
doc->parseQml();
snapshot.insert(doc);
ReadingContext ctxt(snapshot, doc, importPaths);
@@ -671,7 +673,14 @@ QVariant TextToModelMerger::convertToVariant(const ModelNode &node,
const PropertyMetaInfo propertyMetaInfo = nodeMetaInfo.property(astName, true);
if (propertyMetaInfo.isValid()) {
return Internal::PropertyParser::read(propertyMetaInfo.variantTypeId(), cleanedValue);
QVariant::Type type = propertyMetaInfo.variantTypeId();
if (type == QVariant::Invalid) {
const QString propType = propertyMetaInfo.type();
// qDebug() << "converting" << cleanedValue << "to" << propType;
return Internal::PropertyParser::read(propType, cleanedValue, node.metaInfo().metaInfo());
} else {
return Internal::PropertyParser::read(type, cleanedValue);
}
} else if (node.type() == QLatin1String("Qt/PropertyChanges")) {
// In the future, we should do the type resolving in a second pass, or delay setting properties until the full file has been parsed.
return QVariant(cleanedValue);
@@ -827,6 +836,10 @@ void ModelAmender::shouldBeNodeListProperty(AbstractProperty &modelProperty,
void ModelAmender::variantValuesDiffer(VariantProperty &modelProperty, const QVariant &qmlVariantValue, const QString &dynamicType)
{
// qDebug()<< "ModelAmender::variantValuesDiffer for property"<<modelProperty.name()
// << "in node" << modelProperty.parentModelNode().id()
// << ", old value:" << modelProperty.value()
// << "new value:" << qmlVariantValue;
if (dynamicType.isEmpty())
modelProperty.setValue(qmlVariantValue);
else

View File

@@ -55,7 +55,7 @@ public:
bool isActive() const;
void setupImports(const QmlJS::Document::Ptr &doc, DifferenceHandler &differenceHandler);
bool load(const QByteArray &data, DifferenceHandler &differenceHandler);
bool load(const QString &data, DifferenceHandler &differenceHandler);
RewriterView *view() const
{ return m_rewriterView; }

View File

@@ -36,8 +36,10 @@
#include <QtCore/QStringList>
#include <QtCore/QMap>
QT_BEGIN_NAMESPACE
class QTimer;
class QFileSystemWatcher;
QT_END_NAMESPACE
namespace QmlProjectManager {

View File

@@ -52,7 +52,7 @@ CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
setIntroDescription(tr("This wizard generates a Qt4 Designer Custom Widget "
"or a Qt4 Designer Custom Widget Collection project."));
addTargetsPage(BaseQt4ProjectWizardDialog::desktopTarget());
addTargetSetupPage(BaseQt4ProjectWizardDialog::desktopTarget());
m_widgetPageId = addPage(m_widgetsPage);
m_pluginPageId = addPage(m_pluginPage);

View File

@@ -174,3 +174,53 @@ void AbldParser::stdError(const QString &line)
}
IOutputParser::stdError(line);
}
// Unit tests:
#ifdef WITH_TESTS
# include <QTest>
# include "qt4projectmanagerplugin.h"
# include "projectexplorer/outputparser_test.h"
using namespace Qt4ProjectManager::Internal;
void Qt4ProjectManagerPlugin::testAbldOutputParsers_data()
{
QTest::addColumn<QString>("input");
QTest::addColumn<OutputParserTester::Channel>("inputChannel");
QTest::addColumn<QString>("childStdOutLines");
QTest::addColumn<QString>("childStdErrLines");
QTest::addColumn<QList<ProjectExplorer::Task> >("tasks");
QTest::addColumn<QString>("outputLines");
QTest::newRow("pass-through stdout")
<< QString::fromLatin1("Sometext") << OutputParserTester::STDOUT
<< QString::fromLatin1("Sometext") << QString()
<< QList<ProjectExplorer::Task>()
<< QString();
QTest::newRow("pass-through stderr")
<< QString::fromLatin1("Sometext") << OutputParserTester::STDERR
<< QString() << QString::fromLatin1("Sometext")
<< QList<ProjectExplorer::Task>()
<< QString();
}
void Qt4ProjectManagerPlugin::testAbldOutputParsers()
{
OutputParserTester testbench;
testbench.appendOutputParser(new AbldParser);
QFETCH(QString, input);
QFETCH(OutputParserTester::Channel, inputChannel);
QFETCH(QList<Task>, tasks);
QFETCH(QString, childStdOutLines);
QFETCH(QString, childStdErrLines);
QFETCH(QString, outputLines);
testbench.testParsing(input, inputChannel,
tasks, childStdOutLines, childStdErrLines,
outputLines);
}
#endif

View File

@@ -27,7 +27,6 @@ HEADERS += qt4projectmanagerplugin.h \
wizards/modulespage.h \
wizards/filespage.h \
wizards/qtwizard.h \
wizards/targetspage.h \
wizards/targetsetuppage.h \
qt4projectmanagerconstants.h \
makestep.h \
@@ -69,7 +68,6 @@ SOURCES += qt4projectmanagerplugin.cpp \
wizards/modulespage.cpp \
wizards/filespage.cpp \
wizards/qtwizard.cpp \
wizards/targetspage.cpp \
wizards/targetsetuppage.cpp \
makestep.cpp \
qmakestep.cpp \

View File

@@ -266,11 +266,6 @@ void Qt4ProjectManagerPlugin::testBasicProjectLoading()
QVERIFY(qt4project->rootProjectNode()->projectType() == ApplicationTemplate);
QVERIFY(m_projectExplorer->currentProject() != 0);
}
void Qt4ProjectManagerPlugin::testNotYetImplemented()
{
QCOMPARE(1+1, 2);
}
#endif
Q_EXPORT_PLUGIN(Qt4ProjectManagerPlugin)

View File

@@ -76,7 +76,9 @@ private slots:
#ifdef WITH_TESTS
void testBasicProjectLoading();
void testNotYetImplemented();
void testAbldOutputParsers_data();
void testAbldOutputParsers();
#endif
private:

View File

@@ -52,7 +52,7 @@ ConsoleAppWizardDialog::ConsoleAppWizardDialog(const QString &templateName,
"provide a GUI."));
addModulesPage();
addTargetsPage();
addTargetSetupPage();
foreach (QWizardPage *p, extensionPages)
addPage(p);

View File

@@ -45,7 +45,7 @@ EmptyProjectWizardDialog::EmptyProjectWizardDialog(const QString &templateName,
setIntroDescription(tr("This wizard generates an empty Qt4 project. "
"Add files to it later on by using the other wizards."));
addTargetsPage();
addTargetSetupPage();
foreach (QWizardPage *p, extensionPages)
addPage(p);

View File

@@ -62,7 +62,7 @@ GuiAppWizardDialog::GuiAppWizardDialog(const QString &templateName,
"and includes an empty widget."));
addModulesPage();
addTargetsPage();
addTargetSetupPage();
m_filesPage->setFormInputCheckable(true);
m_filesPage->setClassTypeComboVisible(false);
@@ -110,12 +110,11 @@ GuiAppParameters GuiAppWizardDialog::parameters() const
rc.formFileName = m_filesPage->formFileName();
rc.designerForm = m_filesPage->formInputChecked();
rc.isMobileApplication = true;
QSet<QString> targets = selectedTargets();
if (targets.contains(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))) {
if (isTargetSelected(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))) {
rc.widgetWidth = 800;
rc.widgetHeight = 480;
} else if (targets.contains(QLatin1String(Constants::S60_DEVICE_TARGET_ID)) ||
targets.contains(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))) {
} else if (isTargetSelected(QLatin1String(Constants::S60_DEVICE_TARGET_ID)) ||
isTargetSelected(QLatin1String(Constants::S60_EMULATOR_TARGET_ID))) {
rc.widgetWidth = 360;
rc.widgetHeight = 640;
} else {

View File

@@ -146,7 +146,7 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
// Use the intro page instead, set up initially
setIntroDescription(tr("This wizard generates a C++ library project."));
m_targetPageId = addTargetsPage();
m_targetPageId = addTargetSetupPage();
m_modulesPageId = addModulesPage();
m_filesPage->setNamespacesEnabled(true);

View File

@@ -30,10 +30,11 @@
#include "qtwizard.h"
#include "qt4project.h"
#include "qt4projectmanager.h"
#include "qt4projectmanagerconstants.h"
#include "qt4target.h"
#include "modulespage.h"
#include "targetspage.h"
#include "targetsetuppage.h"
#include <coreplugin/icore.h>
#include <cpptools/cpptoolsconstants.h>
@@ -164,7 +165,7 @@ QWizard *CustomQt4ProjectWizard::createWizardDialog(QWidget *parent,
initProjectWizardDialog(wizard, defaultPath, extensionPages);
if (wizard->pageIds().contains(targetPageId))
qWarning("CustomQt4ProjectWizard: Unable to insert target page at %d", int(targetPageId));
wizard->addTargetsPage(QSet<QString>(), targetPageId);
wizard->addTargetSetupPage(QSet<QString>(), targetPageId);
return wizard;
}
@@ -182,7 +183,7 @@ void CustomQt4ProjectWizard::registerSelf()
BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage, QWidget *parent) :
ProjectExplorer::BaseProjectWizardDialog(parent),
m_modulesPage(0),
m_targetsPage(0)
m_targetSetupPage(0)
{
init(showModulesPage);
}
@@ -192,15 +193,15 @@ BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage,
int introId, QWidget *parent) :
ProjectExplorer::BaseProjectWizardDialog(introPage, introId, parent),
m_modulesPage(0),
m_targetsPage(0)
m_targetSetupPage(0)
{
init(showModulesPage);
}
BaseQt4ProjectWizardDialog::~BaseQt4ProjectWizardDialog()
{
if (m_targetsPage && !m_targetsPage->parent())
delete m_targetsPage;
if (m_targetSetupPage && !m_targetSetupPage->parent())
delete m_targetSetupPage;
if (m_modulesPage && !m_modulesPage->parent())
delete m_modulesPage;
}
@@ -209,7 +210,6 @@ void BaseQt4ProjectWizardDialog::init(bool showModulesPage)
{
if (showModulesPage)
m_modulesPage = new ModulesPage;
m_targetsPage = new TargetsPage;
}
int BaseQt4ProjectWizardDialog::addModulesPage(int id)
@@ -223,18 +223,26 @@ int BaseQt4ProjectWizardDialog::addModulesPage(int id)
return addPage(m_modulesPage);
}
int BaseQt4ProjectWizardDialog::addTargetsPage(QSet<QString> targets, int id)
int BaseQt4ProjectWizardDialog::addTargetSetupPage(QSet<QString> targets, int id)
{
m_targetsPage->setValidTargets(targets);
m_targetSetupPage = new TargetSetupPage;
QList<TargetSetupPage::ImportInfo> infos = TargetSetupPage::importInfosForKnownQtVersions(0);
if (!targets.isEmpty())
infos = TargetSetupPage::filterImportInfos(targets, infos);
m_targetSetupPage->setImportDirectoryBrowsingEnabled(false);
m_targetSetupPage->setShowLocationInformation(false);
if (!m_targetsPage->needToDisplayPage())
if (infos.count() <= 1)
return -1;
if (id >= 0) {
setPage(id, m_targetsPage);
m_targetSetupPage->setImportInfos(infos);
if (id >= 0)
setPage(id, m_targetSetupPage);
else
id = addPage(m_targetSetupPage);
return id;
}
return addPage(m_targetsPage);
}
QString BaseQt4ProjectWizardDialog::selectedModules() const
@@ -269,18 +277,30 @@ void BaseQt4ProjectWizardDialog::setDeselectedModules(const QString &modules)
}
}
void BaseQt4ProjectWizardDialog::writeUserFile(const QString &proFileName) const
bool BaseQt4ProjectWizardDialog::writeUserFile(const QString &proFileName) const
{
if (m_targetsPage)
m_targetsPage->writeUserFile(proFileName);
if (!m_targetSetupPage)
return false;
Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
Q_ASSERT(manager);
Qt4Project *pro = new Qt4Project(manager, proFileName);
bool success = m_targetSetupPage->setupProject(pro);
if (success)
pro->saveSettings();
delete pro;
return success;
}
QSet<QString> BaseQt4ProjectWizardDialog::selectedTargets() const
bool BaseQt4ProjectWizardDialog::setupProject(Qt4Project *project) const
{
QSet<QString> targets;
if (m_targetsPage)
targets = m_targetsPage->selectedTargets();
return targets;
return m_targetSetupPage->setupProject(project);
}
bool BaseQt4ProjectWizardDialog::isTargetSelected(const QString &targetid) const
{
return m_targetSetupPage->isTargetSelected(targetid);
}
QSet<QString> BaseQt4ProjectWizardDialog::desktopTarget()

View File

@@ -39,10 +39,13 @@
#include <QtCore/QSet>
namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class ModulesPage;
class TargetsPage;
class TargetSetupPage;
/* Base class for wizard creating Qt projects using QtProjectParameters.
* To implement a project wizard, overwrite:
@@ -125,7 +128,7 @@ public:
virtual ~BaseQt4ProjectWizardDialog();
int addModulesPage(int id = -1);
int addTargetsPage(QSet<QString> targets = QSet<QString>(), int id = -1);
int addTargetSetupPage(QSet<QString> targets = QSet<QString>(), int id = -1);
static QSet<QString> desktopTarget();
@@ -135,14 +138,15 @@ public:
QString deselectedModules() const;
void setDeselectedModules(const QString &);
void writeUserFile(const QString &proFileName) const;
QSet<QString> selectedTargets() const;
bool writeUserFile(const QString &proFileName) const;
bool setupProject(Qt4Project *project) const;
bool isTargetSelected(const QString &targetid) const;
private:
inline void init(bool showModulesPage);
ModulesPage *m_modulesPage;
TargetsPage *m_targetsPage;
TargetSetupPage *m_targetSetupPage;
QString m_selectedModules;
QString m_deselectedModules;
};

View File

@@ -1,213 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "targetspage.h"
#include "qt4projectmanager/qt4project.h"
#include "qt4projectmanager/qt4projectmanager.h"
#include "qt4projectmanager/qt4target.h"
#include "qt4projectmanager/qtversionmanager.h"
#include "qt4projectmanager/qt4projectmanagerconstants.h"
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QSet>
#include <QtCore/QString>
#include <QtGui/QTreeWidget>
#include <QtGui/QLabel>
#include <QtGui/QLayout>
using namespace Qt4ProjectManager::Internal;
TargetsPage::TargetsPage(QWidget *parent)
: QWizardPage(parent)
{
setTitle(tr("Choose Qt versions"));
QVBoxLayout *vbox = new QVBoxLayout(this);
setTitle(tr("Select required Qt versions"));
QLabel *label = new QLabel(tr("Select the Qt versions to use in your project."), this);
label->setWordWrap(true);
vbox->addWidget(label);
m_treeWidget = new QTreeWidget(this);
m_treeWidget->setHeaderHidden(true);
vbox->addWidget(m_treeWidget);
QtVersionManager *vm = QtVersionManager::instance();
QStringList targets = vm->supportedTargetIds().toList();
qSort(targets.begin(), targets.end());
Qt4TargetFactory factory;
foreach (const QString &t, targets) {
QTreeWidgetItem *targetItem = new QTreeWidgetItem(m_treeWidget);
targetItem->setText(0, factory.displayNameForId(t));
targetItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
targetItem->setData(0, Qt::UserRole, t);
targetItem->setExpanded(true);
foreach (QtVersion *v, vm->versionsForTargetId(t)) {
QTreeWidgetItem *versionItem = new QTreeWidgetItem(targetItem);
versionItem->setText(0, v->displayName());
versionItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
versionItem->setData(0, Qt::UserRole, v->uniqueId());
versionItem->setCheckState(0, Qt::Unchecked);
}
}
connect(m_treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
this, SLOT(itemWasChanged()));
emit completeChanged();
}
void TargetsPage::setValidTargets(const QSet<QString> &targets)
{
if (targets.isEmpty())
return;
for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem *currentTargetItem = m_treeWidget->topLevelItem(i);
QString currentTarget = currentTargetItem->data(0, Qt::UserRole).toString();
if (targets.contains(currentTarget))
currentTargetItem->setHidden(false);
else
currentTargetItem->setHidden(true);
}
// Make sure we have something checked!
if (selectedTargets().isEmpty()) {
for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem *currentTargetItem = m_treeWidget->topLevelItem(i);
QString currentTarget = currentTargetItem->data(0, Qt::UserRole).toString();
if (targets.contains(currentTarget) && currentTargetItem->childCount() >= 1) {
currentTargetItem->child(0)->setCheckState(0, Qt::Checked);
break;
}
}
}
emit completeChanged();
}
QSet<QString> TargetsPage::selectedTargets() const
{
QSet<QString> result;
for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem * targetItem = m_treeWidget->topLevelItem(i);
QString target = targetItem->data(0, Qt::UserRole).toString();
QList<int> versions = selectedQtVersionIdsForTarget(target);
if (!versions.isEmpty())
result.insert(target);
}
return result;
}
QList<int> TargetsPage::selectedQtVersionIdsForTarget(const QString &t) const
{
QList<int> result;
for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem * current = m_treeWidget->topLevelItem(i);
QString target = current->data(0, Qt::UserRole).toString();
if (t != target || current->isHidden())
continue;
for (int j = 0; j < current->childCount(); ++j) {
QTreeWidgetItem * child = current->child(j);
if (child->checkState(0) != Qt::Checked)
continue;
result.append(child->data(0, Qt::UserRole).toInt());
}
}
return result;
}
void TargetsPage::itemWasChanged()
{
emit completeChanged();
}
bool TargetsPage::isComplete() const
{
return !selectedTargets().isEmpty();
}
bool TargetsPage::needToDisplayPage() const
{
int targetCount = 0;
for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem * current = m_treeWidget->topLevelItem(i);
if (current->isHidden())
continue;
++targetCount;
if (targetCount > 1)
return true;
if (current->childCount() > 1)
return true;
}
return false;
}
void TargetsPage::writeUserFile(const QString &proFileName) const
{
Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
Q_ASSERT(manager);
Qt4Project *pro = new Qt4Project(manager, proFileName);
if (setupProject(pro))
pro->saveSettings();
delete pro;
}
bool TargetsPage::setupProject(Qt4ProjectManager::Qt4Project *project) const
{
if (!project)
return false;
// Generate user settings:
QSet<QString> targets = selectedTargets();
if (targets.isEmpty())
return false;
QtVersionManager *vm = QtVersionManager::instance();
foreach (const QString &targetId, targets) {
QList<int> versionIds = selectedQtVersionIdsForTarget(targetId);
QList<QtVersion *> versions;
foreach (int id, versionIds)
versions.append(vm->version(id));
Qt4Target * target = project->targetFactory()->create(project, targetId, versions);
project->addTarget(target);
}
return true;
}

View File

@@ -1,78 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef TARGETSPAGE_H
#define TARGETSPAGE_H
#include <QtCore/QList>
#include <QtCore/QSet>
#include <QtCore/QString>
#include <QtGui/QWizard>
QT_BEGIN_NAMESPACE
class QTreeWidget;
QT_END_NAMESPACE
namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class TargetsPage : public QWizardPage
{
Q_OBJECT
public:
explicit TargetsPage(QWidget* parent = 0);
void setValidTargets(const QSet<QString> &targets);
QSet<QString> selectedTargets() const;
QList<int> selectedQtVersionIdsForTarget(const QString &) const;
bool isComplete() const;
bool needToDisplayPage() const;
void writeUserFile(const QString &proFileName) const;
bool setupProject(Qt4Project *project) const;
private slots:
void itemWasChanged();
private:
QSet<QString> m_validTargets;
QTreeWidget * m_treeWidget;
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // TARGETSPAGE_H

View File

@@ -60,7 +60,7 @@ TestWizardDialog::TestWizardDialog(const QString &templateName,
setWindowIcon(icon);
setWindowTitle(templateName);
setSelectedModules(QLatin1String("core testlib"), true);
addTargetsPage();
addTargetSetupPage();
m_testPageId = addPage(m_testPage);
m_modulesPageId = addModulesPage();
foreach (QWizardPage *p, extensionPages)

View File

@@ -854,12 +854,19 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node)
}
}
if (_pool != _translationUnit->memoryPool()) {
MemoryPool *pool = _translationUnit->memoryPool();
TemplateArgumentListAST *template_argument_list = node;
for (TemplateArgumentListAST *iter = template_argument_list, **ast_iter = &node;
iter; iter = iter->next, ast_iter = &(*ast_iter)->next)
*ast_iter = new (pool) TemplateArgumentListAST((iter->value) ? iter->value->clone(pool) : 0);
}
_templateArgumentList.insert(std::make_pair(start, TemplateArgumentListEntry(start, cursor(), node)));
return true;
}
_templateArgumentList.insert(std::make_pair(start, TemplateArgumentListEntry(start, cursor(), 0)));
return false;
}

View File

@@ -3192,6 +3192,30 @@ void TestCore::testMetaInfo()
// QVERIFY(graphicsWidgetInfo.hasProperty("enabled")); // from QGraphicsItem
}
void TestCore::testMetaInfoEnums()
{
QScopedPointer<Model> model(Model::create("Qt/Text"));
QVERIFY(model.data());
QScopedPointer<TestView> view(new TestView);
QVERIFY(view.data());
model->attachView(view.data());
QCOMPARE(view->rootModelNode().metaInfo().typeName(), QString("Qt/Text"));
QVERIFY(view->rootModelNode().metaInfo().hasProperty("transformOrigin"));
QVERIFY(view->rootModelNode().metaInfo().property("transformOrigin").isEnumType());
QCOMPARE(view->rootModelNode().metaInfo().property("transformOrigin").type(), QLatin1String("TransformOrigin"));
QVERIFY(view->rootModelNode().metaInfo().property("transformOrigin").enumerator().elementNames().contains(QLatin1String("Bottom")));
QVERIFY(view->rootModelNode().metaInfo().property("transformOrigin").enumerator().elementNames().contains(QLatin1String("Top")));
QVERIFY(view->rootModelNode().metaInfo().property("horizontalAlignment").isEnumType());
QCOMPARE(view->rootModelNode().metaInfo().property("horizontalAlignment").type(), QLatin1String("HAlignment"));
QVERIFY(view->rootModelNode().metaInfo().property("horizontalAlignment").enumerator().elementNames().contains(QLatin1String("AlignLeft")));
QVERIFY(view->rootModelNode().metaInfo().property("horizontalAlignment").enumerator().elementNames().contains(QLatin1String("AlignRight")));
}
void TestCore::testMetaInfoDotProperties()
{
QScopedPointer<Model> model(Model::create("Qt/Text"));

View File

@@ -72,6 +72,7 @@ private slots:
// unit tests MetaInfo, NodeMetaInfo, PropertyMetaInfo
//
void testMetaInfo();
void testMetaInfoEnums();
void testMetaInfoDotProperties();
void testMetaInfoListProperties();