Merge remote branch 'origin/2.0'

Conflicts:
	src/plugins/projectexplorer/miniprojecttargetselector.cpp
	src/plugins/qmldesigner/designercore/model/modeltotextmerger.cpp
	src/plugins/qmldesigner/designercore/model/rewriteactioncompressor.cpp
	src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp
	src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h
	tests/manual/gdbdebugger/simple/app.cpp
This commit is contained in:
hjk
2010-05-27 11:11:53 +02:00
34 changed files with 551 additions and 3031 deletions

View File

@@ -7,8 +7,8 @@ equals(QMAKE_DIR_SEP, /) { # unix, mingw+msys
# The lack of spaces in front of the && is necessary! # The lack of spaces in front of the && is necessary!
QDOC = set SRCDIR=$$PWD&& set OUTDIR=$$OUT_PWD/doc/html&& $$QDOC_BIN QDOC = set SRCDIR=$$PWD&& set OUTDIR=$$OUT_PWD/doc/html&& $$QDOC_BIN
} else { # nmake } else { # nmake
QDOC = set SRCDIR=$$PWD $$escape_expand(\n\t) \ QDOC = set SRCDIR=$$PWD $$escape_expand(\\n\\t) \
set OUTDIR=$$OUT_PWD/doc/html $$escape_expand(\n\t) \ set OUTDIR=$$OUT_PWD/doc/html $$escape_expand(\\n\\t) \
$$QDOC_BIN $$QDOC_BIN
} }

View File

@@ -1,5 +1,5 @@
#version check qt #version check qt
contains(QT_VERSION, ^4\.[0-6]\..*) { contains(QT_VERSION, ^4\\.[0-6]\\..*) {
message("Cannot build Qt Creator with Qt version $${QT_VERSION}.") message("Cannot build Qt Creator with Qt version $${QT_VERSION}.")
error("Use at least Qt 4.7.") error("Use at least Qt 4.7.")
} }

View File

@@ -1384,7 +1384,8 @@ class Dumper:
if len(fields) == 1 and fields[0].name is None: if len(fields) == 1 and fields[0].name is None:
innerType = value.type.target() innerType = value.type.target()
with Children(self, 1, innerType): with Children(self, 1, innerType):
self.putFields(item) child = Item(value, item.iname, None, item.name)
self.putFields(child)
def putFields(self, item, innerType = None): def putFields(self, item, innerType = None):
value = item.value value = item.value

View File

@@ -2053,7 +2053,7 @@ Sollen sie überschrieben werden?</translation>
<message> <message>
<location line="+5"/> <location line="+5"/>
<source>&amp;Options...</source> <source>&amp;Options...</source>
<translation>&amp;Einstellungen</translation> <translation>&amp;Einstellungen...</translation>
</message> </message>
<message> <message>
<location line="+11"/> <location line="+11"/>
@@ -2433,7 +2433,7 @@ Sollen sie überschrieben werden?</translation>
<message> <message>
<location line="+3"/> <location line="+3"/>
<source>&lt;h3&gt;Qt Creator %1 %8&lt;/h3&gt;Based on Qt %2 (%3 bit)&lt;br/&gt;&lt;br/&gt;Built on %4 at %5&lt;br /&gt;&lt;br/&gt;%9&lt;br/&gt;Copyright 2008-%6 %7. All rights reserved.&lt;br/&gt;&lt;br/&gt;The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.&lt;br/&gt;</source> <source>&lt;h3&gt;Qt Creator %1 %8&lt;/h3&gt;Based on Qt %2 (%3 bit)&lt;br/&gt;&lt;br/&gt;Built on %4 at %5&lt;br /&gt;&lt;br/&gt;%9&lt;br/&gt;Copyright 2008-%6 %7. All rights reserved.&lt;br/&gt;&lt;br/&gt;The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.&lt;br/&gt;</source>
<translation>&lt;h3&gt;Qt Creator %1&lt;/h3&gt;Basierend auf Qt %2 (%3 bit)&lt;br/&gt;&lt;br/&gt;Erstellt am %4 um %5&lt;br /&gt;&lt;br/&gt;%8&lt;br/&gt;Copyright 2008-%6 %7. Alle Rechte vorbehalten.&lt;br/&gt;&lt;br/&gt;The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.&lt;br/&gt;</translation> <translation>&lt;h3&gt;Qt Creator %1 %8&lt;/h3&gt;Basierend auf Qt %2 (%3 bit)&lt;br/&gt;&lt;br/&gt;Erstellt am %4 um %5&lt;br /&gt;&lt;br/&gt;%9&lt;br/&gt;Copyright 2008-%6 %7. Alle Rechte vorbehalten.&lt;br/&gt;&lt;br/&gt;The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.&lt;br/&gt;</translation>
</message> </message>
</context> </context>
<context> <context>

File diff suppressed because it is too large Load Diff

View File

@@ -14,26 +14,22 @@ LRELEASE = $$targetPath($$[QT_INSTALL_BINS]/lrelease)
TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/qtcreator_,.ts) TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/qtcreator_,.ts)
MIME_TR_H = $$IDE_DATA_PATH/translations/mime_tr.h MIME_TR_H = $$OUT_PWD/mime_tr.h
CUSTOMWIZARD_TR_H = $$IDE_DATA_PATH/translations/customwizard_tr.h CUSTOMWIZARD_TR_H = $$OUT_PWD/customwizard_tr.h
contains(QT_VERSION, ^4\.[0-6]\..*) { for(dir, $$list($$files($$IDE_SOURCE_TREE/src/plugins/*))):MIMETYPES_FILES += $$files($$dir/*.mimetypes.xml)
ts.commands = @echo This Qt version is too old for the ts target. Need Qt 4.7+. MIMETYPES_FILES = \"$$join(MIMETYPES_FILES, \", \")\"
} else {
for(dir, $$list($$files($$IDE_SOURCE_TREE/src/plugins/*))):MIMETYPES_FILES += $$files($$dir/*.mimetypes.xml)
MIMETYPES_FILES = \"$$join(MIMETYPES_FILES, \", \")\"
for(dir, $$list($$files($$IDE_SOURCE_TREE/share/qtcreator/templates/wizards/*))):CUSTOMWIZARD_FILES += $$files($$dir/wizard.xml) for(dir, $$list($$files($$IDE_SOURCE_TREE/share/qtcreator/templates/wizards/*))):CUSTOMWIZARD_FILES += $$files($$dir/wizard.xml)
CUSTOMWIZARD_FILES = \"$$join(CUSTOMWIZARD_FILES, \", \")\" CUSTOMWIZARD_FILES = \"$$join(CUSTOMWIZARD_FILES, \", \")\"
QMAKE_SUBSTITUTES += extract-mimetypes.xq.in QMAKE_SUBSTITUTES += extract-mimetypes.xq.in
QMAKE_SUBSTITUTES += extract-customwizards.xq.in QMAKE_SUBSTITUTES += extract-customwizards.xq.in
ts.commands += \ ts.commands += \
$$XMLPATTERNS -output $$MIME_TR_H $$PWD/extract-mimetypes.xq && \ $$XMLPATTERNS -output $$MIME_TR_H $$PWD/extract-mimetypes.xq && \
$$XMLPATTERNS -output $$CUSTOMWIZARD_TR_H $$PWD/extract-customwizards.xq && \ $$XMLPATTERNS -output $$CUSTOMWIZARD_TR_H $$PWD/extract-customwizards.xq && \
(cd $$IDE_SOURCE_TREE && $$LUPDATE src share/qtcreator/qmldesigner $$MIME_TR_H $$CUSTOMWIZARD_TR_H -ts $$TRANSLATIONS) && \ (cd $$IDE_SOURCE_TREE && $$LUPDATE src share/qtcreator/qmldesigner $$MIME_TR_H $$CUSTOMWIZARD_TR_H -ts $$TRANSLATIONS) && \
$$QMAKE_DEL_FILE $$MIME_TR_H $$QMAKE_DEL_FILE $$MIME_TR_H
}
QMAKE_EXTRA_TARGETS += ts QMAKE_EXTRA_TARGETS += ts
TEMPLATE = app TEMPLATE = app

View File

@@ -81,6 +81,8 @@ void GdbEngine::updateLocalsPython(const QByteArray &varList)
options += "fancy,"; options += "fancy,";
if (theDebuggerBoolSetting(AutoDerefPointers)) if (theDebuggerBoolSetting(AutoDerefPointers))
options += "autoderef,"; options += "autoderef,";
if (!qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty())
options += "pe,";
if (options.isEmpty()) if (options.isEmpty())
options += "defaults,"; options += "defaults,";
options.chop(1); options.chop(1);

View File

@@ -260,15 +260,19 @@ MiniTargetWidget::MiniTargetWidget(Target *target, QWidget *parent) :
QFormLayout *formLayout = new QFormLayout; QFormLayout *formLayout = new QFormLayout;
formLayout->setLabelAlignment(Qt::AlignRight); formLayout->setLabelAlignment(Qt::AlignRight);
QLabel *lbl; QLabel *lbl;
int indent = 10;
if (hasBuildConfiguration()) { if (hasBuildConfiguration()) {
lbl = new QLabel(tr("Build:")); lbl = new QLabel(tr("Build:"));
lbl->setObjectName(QString::fromUtf8("buildLabel")); lbl->setObjectName(QString::fromUtf8("buildLabel"));
lbl->setIndent(10); lbl->setMinimumWidth(lbl->fontMetrics().width(lbl->text()) + indent + 4);
lbl->setIndent(indent);
formLayout->addRow(lbl, buildHelperLayout); formLayout->addRow(lbl, buildHelperLayout);
} }
lbl = new QLabel(tr("Run:")); lbl = new QLabel(tr("Run:"));
lbl->setObjectName(QString::fromUtf8("runLabel")); lbl->setObjectName(QString::fromUtf8("runLabel"));
lbl->setIndent(10); lbl->setMinimumWidth(lbl->fontMetrics().width(lbl->text()) + indent + 4);
lbl->setIndent(indent);
formLayout->addRow(lbl, runHelperLayout); formLayout->addRow(lbl, runHelperLayout);
gridLayout->addWidget(m_targetName, 0, 0); gridLayout->addWidget(m_targetName, 0, 0);
@@ -316,8 +320,14 @@ void MiniTargetWidget::setActiveRunConfiguration()
void MiniTargetWidget::addRunConfiguration(ProjectExplorer::RunConfiguration* rc) void MiniTargetWidget::addRunConfiguration(ProjectExplorer::RunConfiguration* rc)
{ {
Q_UNUSED(rc); connect(rc, SIGNAL(displayNameChanged()), SLOT(updateDisplayName()));
m_runComboBox->setEnabled(m_target->runConfigurations().count()>1); m_runComboBox->addItem(rc->displayName(), QVariant::fromValue(rc));
m_runComboBox->setItemData(m_runComboBox->findText(rc->displayName()),
rc->displayName(), Qt::ToolTipRole);
if (m_target->activeRunConfiguration() == rc)
m_runComboBox->setCurrentIndex(m_runComboBox->count()-1);
m_runComboBox->setEnabled(m_runComboBox->count()>1);
} }
void MiniTargetWidget::removeRunConfiguration(ProjectExplorer::RunConfiguration* rc) void MiniTargetWidget::removeRunConfiguration(ProjectExplorer::RunConfiguration* rc)
@@ -330,8 +340,14 @@ void MiniTargetWidget::addBuildConfiguration(ProjectExplorer::BuildConfiguration
{ {
Q_UNUSED(bc); Q_UNUSED(bc);
QTC_ASSERT(m_buildComboBox, return); QTC_ASSERT(m_buildComboBox, return);
connect(bc, SIGNAL(displayNameChanged()), SIGNAL(changed()), Qt::UniqueConnection); connect(bc, SIGNAL(displayNameChanged()), SLOT(updateDisplayName()));
m_buildComboBox->setEnabled(m_target->buildConfigurations().count() > 1); m_buildComboBox->addItem(bc->displayName(), QVariant::fromValue(bc));
m_buildComboBox->setItemData(m_buildComboBox->findText(bc->displayName()),
bc->displayName(), Qt::ToolTipRole);
if (m_target->activeBuildConfiguration() == bc)
m_buildComboBox->setCurrentIndex(m_buildComboBox->count()-1);
m_buildComboBox->setEnabled(m_buildComboBox->count() > 1);
} }
void MiniTargetWidget::removeBuildConfiguration(ProjectExplorer::BuildConfiguration* bc) void MiniTargetWidget::removeBuildConfiguration(ProjectExplorer::BuildConfiguration* bc)
@@ -387,7 +403,6 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
m_projectsBox->setProperty("hideborder", true); m_projectsBox->setProperty("hideborder", true);
m_projectsBox->setObjectName(QString::fromUtf8("ProjectsBox")); m_projectsBox->setObjectName(QString::fromUtf8("ProjectsBox"));
m_projectsBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_projectsBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_projectsBox->setMaximumWidth(200);
toolLayout->addWidget(lbl); toolLayout->addWidget(lbl);
toolLayout->addWidget(new Utils::StyledSeparator); toolLayout->addWidget(new Utils::StyledSeparator);
@@ -562,6 +577,10 @@ void MiniProjectTargetSelector::updateAction()
QString runConfig; QString runConfig;
QIcon targetIcon = style()->standardIcon(QStyle::SP_ComputerIcon); QIcon targetIcon = style()->standardIcon(QStyle::SP_ComputerIcon);
const int extrawidth = 110; // Size of margins + icon width
// Some fudge numbers to ensure the menu doesnt grow unbounded
int maxLength = fontMetrics().averageCharWidth() * 140;
if (project) { if (project) {
projectName = project->displayName(); projectName = project->displayName();
@@ -571,10 +590,14 @@ void MiniProjectTargetSelector::updateAction()
} }
if (BuildConfiguration *bc = target->activeBuildConfiguration()) { if (BuildConfiguration *bc = target->activeBuildConfiguration()) {
buildConfig = bc->displayName(); buildConfig = bc->displayName();
int minimumWidth = fontMetrics().width(bc->displayName() + tr("Build:")) + extrawidth;
m_widgetStack->setMinimumWidth(qMin(maxLength, qMax(minimumWidth, m_widgetStack->minimumWidth())));
} }
if (RunConfiguration *rc = target->activeRunConfiguration()) { if (RunConfiguration *rc = target->activeRunConfiguration()) {
runConfig = rc->displayName(); runConfig = rc->displayName();
int minimumWidth = fontMetrics().width(rc->displayName() + tr("Run:")) + extrawidth;
m_widgetStack->setMinimumWidth(qMin(maxLength, qMax(minimumWidth, m_widgetStack->minimumWidth())));
} }
targetToolTipText = target->toolTip(); targetToolTipText = target->toolTip();
targetIcon = createCenteredIcon(target->icon(), target->overlayIcon()); targetIcon = createCenteredIcon(target->icon(), target->overlayIcon());

View File

@@ -53,27 +53,12 @@
#include <QtGui/QMenu> #include <QtGui/QMenu>
namespace { namespace {
const int TASK_ICON_SIZE = 16; const int TASK_ICON_SIZE = 16;
const int TASK_ICON_MARGIN = 2; const int TASK_ICON_MARGIN = 2;
const QIcon ERROR_ICON(":/projectexplorer/images/compile_error.png");
const QIcon WARNING_ICON(":/projectexplorer/images/compile_warning.png");
} }
namespace ProjectExplorer { namespace ProjectExplorer {
QIcon Task::icon() const
{
if (type == ProjectExplorer::Task::Error)
return ERROR_ICON;
else if (type == ProjectExplorer::Task::Warning)
return WARNING_ICON;
else
return QIcon();
}
namespace Internal { namespace Internal {
class TaskView : public QListView class TaskView : public QListView
@@ -141,6 +126,8 @@ public:
enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type, Category, Icon, Task_t }; enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type, Category, Icon, Task_t };
QIcon taskTypeIcon(Task::TaskType t) const;
private: private:
QHash<QString,QString> m_categories; // category id -> display name QHash<QString,QString> m_categories; // category id -> display name
QList<Task> m_tasks; // all tasks (in order of insertion) QList<Task> m_tasks; // all tasks (in order of insertion)
@@ -148,8 +135,8 @@ private:
QHash<QString,bool> m_fileNotFound; QHash<QString,bool> m_fileNotFound;
int m_maxSizeOfFileName; int m_maxSizeOfFileName;
QIcon m_errorIcon; const QIcon m_errorIcon;
QIcon m_warningIcon; const QIcon m_warningIcon;
}; };
class TaskFilterModel : public QSortFilterProxyModel class TaskFilterModel : public QSortFilterProxyModel
@@ -224,11 +211,24 @@ void TaskView::keyPressEvent(QKeyEvent *e)
// TaskModel // TaskModel
///// /////
TaskModel::TaskModel() TaskModel::TaskModel() :
m_maxSizeOfFileName(0),
m_errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png")),
m_warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
{ {
m_maxSizeOfFileName = 0; }
m_errorIcon = QIcon(":/projectexplorer/images/compile_error.png");
m_warningIcon = QIcon(":/projectexplorer/images/compile_warning.png"); QIcon TaskModel::taskTypeIcon(Task::TaskType t) const
{
switch (t) {
case Task::Warning:
return m_warningIcon;
case Task::Error:
return m_errorIcon;
case Task::Unknown:
break;
}
return QIcon();
} }
void TaskModel::addCategory(const QString &categoryId, const QString &categoryName) void TaskModel::addCategory(const QString &categoryId, const QString &categoryName)
@@ -353,7 +353,7 @@ QVariant TaskModel::data(const QModelIndex &index, int role) const
} else if (role == TaskModel::Category) { } else if (role == TaskModel::Category) {
return m_tasks.at(index.row()).category; return m_tasks.at(index.row()).category;
} else if (role == TaskModel::Icon) { } else if (role == TaskModel::Icon) {
return m_tasks.at(index.row()).icon(); return taskTypeIcon(m_tasks.at(index.row()).type);
} else if (role == TaskModel::Task_t) { } else if (role == TaskModel::Task_t) {
return QVariant::fromValue(m_tasks.at(index.row())); return QVariant::fromValue(m_tasks.at(index.row()));
} }
@@ -495,7 +495,7 @@ TaskWindow::TaskWindow()
connect(m_listview, SIGNAL(clicked(QModelIndex)), connect(m_listview, SIGNAL(clicked(QModelIndex)),
this, SLOT(showTaskInFile(QModelIndex))); this, SLOT(showTaskInFile(QModelIndex)));
m_filterWarningsButton = createFilterButton(WARNING_ICON, m_filterWarningsButton = createFilterButton(taskTypeIcon(Task::Warning),
tr("Show Warnings"), tr("Show Warnings"),
this, SLOT(setShowWarnings(bool))); this, SLOT(setShowWarnings(bool)));
@@ -771,6 +771,11 @@ void TaskWindow::updateActions()
m_copyAction->setEnabled(m_model->tasks().count() > 0); m_copyAction->setEnabled(m_model->tasks().count() > 0);
} }
QIcon TaskWindow::taskTypeIcon(Task::TaskType t) const
{
return m_model->taskTypeIcon(t);
}
///// /////
// Delegate // Delegate
///// /////

View File

@@ -86,9 +86,6 @@ struct PROJECTEXPLORER_EXPORT Task {
// doesn't work if you split it up, nor are our parsers // doesn't work if you split it up, nor are our parsers
// anywhere near being that good // anywhere near being that good
QList<QTextLayout::FormatRange> formats; QList<QTextLayout::FormatRange> formats;
/// Get the icon used to represent this task
QIcon icon() const;
}; };
class PROJECTEXPLORER_EXPORT TaskWindow : public Core::IOutputPane class PROJECTEXPLORER_EXPORT TaskWindow : public Core::IOutputPane
@@ -128,6 +125,8 @@ public:
void goToNext(); void goToNext();
void goToPrev(); void goToPrev();
QIcon taskTypeIcon(Task::TaskType t) const;
signals: signals:
void tasksChanged(); void tasksChanged();

View File

@@ -94,7 +94,10 @@ void FormEditorGraphicsView::mouseMoveEvent(QMouseEvent *event)
delete mouseEvent; delete mouseEvent;
} }
m_feedbackOriginPoint = event->pos() + QPoint(50, -80); // Keeps the feedback bubble within screen boundraries
int tx = qMin(width() - 114, qMax(16, event->pos().x() + 50));
int ty = qMin(height() - 45, qMax(10, event->pos().y() - 70));
m_feedbackOriginPoint = QPoint(tx, ty);
} }
void FormEditorGraphicsView::keyPressEvent(QKeyEvent *event) void FormEditorGraphicsView::keyPressEvent(QKeyEvent *event)
@@ -127,6 +130,30 @@ void FormEditorGraphicsView::leaveEvent(QEvent *event)
{ {
m_feedbackOriginPoint = QPoint(); m_feedbackOriginPoint = QPoint();
QGraphicsView::leaveEvent(event); QGraphicsView::leaveEvent(event);
}
static QPixmap createBubblePixmap()
{
QPixmap pixmap(124, 48);
pixmap.fill(Qt::transparent);
QPainter pmPainter(&pixmap);
pmPainter.setRenderHint(QPainter::Antialiasing);
pmPainter.setOpacity(0.85);
pmPainter.translate(0.5, 0.5);
pmPainter.setPen(Qt::NoPen);
pmPainter.setBrush(QColor(0, 0, 0, 40));
pmPainter.drawRoundedRect(QRect(0, 0, 124, 48), 8, 8);
QLinearGradient gradient(QPoint(0, 0), QPoint(0, 44));
gradient.setColorAt(0.0, QColor(70, 70, 70));
gradient.setColorAt(1.0, QColor(10, 10, 10));
pmPainter.setBrush(gradient);
pmPainter.setPen(QColor(60, 60, 60));
pmPainter.drawRoundedRect(QRect(2, 1, 120, 45), 5, 5);
pmPainter.setBrush(Qt::NoBrush);
pmPainter.setPen(QColor(255, 255, 255, 140));
pmPainter.drawRoundedRect(QRect(3, 2, 118, 43), 5, 5);
pmPainter.end();
return pixmap;
} }
void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*rect*/ ) void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*rect*/ )
@@ -138,7 +165,6 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
return; return;
painter->save(); painter->save();
painter->resetTransform(); painter->resetTransform();
painter->translate(m_feedbackOriginPoint); painter->translate(m_feedbackOriginPoint);
@@ -150,18 +176,9 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
font.setPixelSize(12); font.setPixelSize(12);
painter->setFont(font); painter->setFont(font);
painter->save(); if (m_bubblePixmap.isNull())
painter->setOpacity(0.85); m_bubblePixmap = createBubblePixmap();
painter->drawPixmap(-13, -7, m_bubblePixmap);
QLinearGradient gradient(QPoint(0, 0), QPoint(120, 45));
gradient.setColorAt(0.0, Qt::black);
gradient.setColorAt(1.0, Qt::darkGray);
painter->setBrush(gradient);
painter->setPen(Qt::black);
painter->drawRoundedRect(QRect(-1, -1, 120, 45), 5, 5);
painter->restore();
if (m_beginXHasExpression) { if (m_beginXHasExpression) {
if(m_feedbackNode.hasBindingProperty("x")) if(m_feedbackNode.hasBindingProperty("x"))
@@ -175,8 +192,8 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
painter->setPen(defaultColor); painter->setPen(defaultColor);
} }
painter->drawText(QPoint(2.0, 13.0), QString("x:")); painter->drawText(QPoint(8.0, 13.0), QString("x:"));
painter->drawText(QPoint(14.0, 13.0), m_feedbackNode.instanceValue("x").toString()); painter->drawText(QPoint(22.0, 13.0), m_feedbackNode.instanceValue("x").toString());
if (m_beginYHasExpression) { if (m_beginYHasExpression) {
@@ -192,7 +209,7 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
} }
painter->drawText(QPoint(60.0, 13.0), QString("y:")); painter->drawText(QPoint(60.0, 13.0), QString("y:"));
painter->drawText(QPoint(70.0, 13.0), m_feedbackNode.instanceValue("y").toString()); painter->drawText(QPoint(72.0, 13.0), m_feedbackNode.instanceValue("y").toString());
if (m_beginWidthHasExpression) { if (m_beginWidthHasExpression) {
@@ -207,8 +224,8 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
painter->setPen(defaultColor); painter->setPen(defaultColor);
} }
painter->drawText(QPoint(2.0, 26.0), QString("w:")); painter->drawText(QPoint(8.0, 29.0), QString("w:"));
painter->drawText(QPoint(14.0, 26.0), m_feedbackNode.instanceValue("width").toString()); painter->drawText(QPoint(22.0, 29.0), m_feedbackNode.instanceValue("width").toString());
if (m_beginHeightHasExpression) { if (m_beginHeightHasExpression) {
@@ -223,8 +240,8 @@ void FormEditorGraphicsView::drawForeground(QPainter *painter, const QRectF &/*r
painter->setPen(defaultColor); painter->setPen(defaultColor);
} }
painter->drawText(QPoint(60.0, 26.0), QString("h:")); painter->drawText(QPoint(60.0, 29.0), QString("h:"));
painter->drawText(QPoint(70.0, 26.0), m_feedbackNode.instanceValue("height").toString()); painter->drawText(QPoint(72.0, 29.0), m_feedbackNode.instanceValue("height").toString());
if (m_parentNode != m_feedbackNode.instanceParent()) { if (m_parentNode != m_feedbackNode.instanceParent()) {
painter->setPen(changeColor); painter->setPen(changeColor);

View File

@@ -67,6 +67,7 @@ private:
bool m_beginWidthHasExpression; bool m_beginWidthHasExpression;
bool m_beginHeightHasExpression; bool m_beginHeightHasExpression;
QPoint m_feedbackOriginPoint; QPoint m_feedbackOriginPoint;
QPixmap m_bubblePixmap;
}; };
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -43,7 +43,7 @@ NavigatorTreeModel::NavigatorTreeModel(QObject *parent)
: QStandardItemModel(parent), : QStandardItemModel(parent),
m_blockItemChangedSignal(false) m_blockItemChangedSignal(false)
{ {
invisibleRootItem()->setFlags(Qt::NoItemFlags); invisibleRootItem()->setFlags(Qt::ItemIsDropEnabled);
#ifdef _LOCK_ITEMS_ #ifdef _LOCK_ITEMS_
setColumnCount(3); setColumnCount(3);

View File

@@ -39,6 +39,8 @@ namespace QmlDesigner {
class ModelNode; class ModelNode;
class NodeState; class NodeState;
const QString auxDataString = QLatin1String("anchors_");
namespace Internal { namespace Internal {
QmlAnchorBindingProxy::QmlAnchorBindingProxy(QObject *parent) : QmlAnchorBindingProxy::QmlAnchorBindingProxy(QObject *parent) :
@@ -269,6 +271,15 @@ void QmlAnchorBindingProxy::resetLayout() {
m_fxItemNode.anchors().removeAnchors(); m_fxItemNode.anchors().removeAnchors();
m_fxItemNode.anchors().removeMargins(); m_fxItemNode.anchors().removeMargins();
if (qFuzzyCompare(m_fxItemNode.instancePosition().x(), 0.0))
m_fxItemNode.setVariantProperty("x", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "x"));
if (qFuzzyCompare(m_fxItemNode.instancePosition().y(), 0.0))
m_fxItemNode.setVariantProperty("y", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "y"));
if (qFuzzyCompare(m_fxItemNode.instanceSize().width(), 0.0))
m_fxItemNode.setVariantProperty("width", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "width"));
if (qFuzzyCompare(m_fxItemNode.instanceSize().height(), 0.0))
m_fxItemNode.setVariantProperty("height", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "height"));
emit topAnchorChanged(); emit topAnchorChanged();
emit bottomAnchorChanged(); emit bottomAnchorChanged();
emit leftAnchorChanged(); emit leftAnchorChanged();
@@ -290,6 +301,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
removeBottomAnchor(); removeBottomAnchor();
} else { } else {
calcBottomMargin(); calcBottomMargin();
m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "height", m_fxItemNode.instanceSize().height());
m_fxItemNode.removeVariantProperty("height"); m_fxItemNode.removeVariantProperty("height");
} }
emit bottomAnchorChanged(); emit bottomAnchorChanged();
@@ -312,7 +324,8 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
removeLeftAnchor(); removeLeftAnchor();
} else { } else {
calcLeftMargin(); calcLeftMargin();
m_fxItemNode.removeVariantProperty("width"); m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "x", m_fxItemNode.instancePosition().x());
m_fxItemNode.removeVariantProperty("x");
} }
emit leftAnchorChanged(); emit leftAnchorChanged();
if (hasAnchors() != anchor) if (hasAnchors() != anchor)
@@ -333,7 +346,8 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
removeRightAnchor(); removeRightAnchor();
} else { } else {
calcRightMargin(); calcRightMargin();
m_fxItemNode.removeVariantProperty("x"); m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "width", m_fxItemNode.instanceSize().width());
m_fxItemNode.removeVariantProperty("width");
} }
emit rightAnchorChanged(); emit rightAnchorChanged();
if (hasAnchors() != anchor) if (hasAnchors() != anchor)
@@ -364,13 +378,11 @@ void QmlAnchorBindingProxy::calcTopMargin()
{ {
m_locked = true; m_locked = true;
if (m_topTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) { if (m_topTarget.modelNode() == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
qreal topMargin = transformedBoundingBox().top() - parentBoundingBox().top(); qreal topMargin = transformedBoundingBox().top() - parentBoundingBox().top();
m_fxItemNode.anchors().setMargin( AnchorLine::Top, topMargin); m_fxItemNode.anchors().setMargin( AnchorLine::Top, topMargin);
m_fxItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Top); m_fxItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Top);
} else { } else {
qDebug() << boundingBox(m_fxItemNode).top();
qDebug() << boundingBox(m_topTarget).bottom();
qreal topMargin = boundingBox(m_fxItemNode).top() - boundingBox(m_topTarget).bottom(); qreal topMargin = boundingBox(m_fxItemNode).top() - boundingBox(m_topTarget).bottom();
m_fxItemNode.anchors().setMargin( AnchorLine::Top, topMargin); m_fxItemNode.anchors().setMargin( AnchorLine::Top, topMargin);
m_fxItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Bottom); m_fxItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Bottom);
@@ -383,7 +395,7 @@ void QmlAnchorBindingProxy::calcBottomMargin()
{ {
m_locked = true; m_locked = true;
if (m_bottomTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) { if (m_bottomTarget.modelNode() == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
qreal bottomMargin = parentBoundingBox().bottom() - transformedBoundingBox().bottom(); qreal bottomMargin = parentBoundingBox().bottom() - transformedBoundingBox().bottom();
m_fxItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin); m_fxItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin);
m_fxItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Bottom); m_fxItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Bottom);
@@ -400,7 +412,7 @@ void QmlAnchorBindingProxy::calcLeftMargin()
{ {
m_locked = true; m_locked = true;
if (m_leftTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) { if (m_leftTarget.modelNode() == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
qreal leftMargin = transformedBoundingBox().left() - parentBoundingBox().left(); qreal leftMargin = transformedBoundingBox().left() - parentBoundingBox().left();
m_fxItemNode.anchors().setMargin(AnchorLine::Left, leftMargin); m_fxItemNode.anchors().setMargin(AnchorLine::Left, leftMargin);
m_fxItemNode.anchors().setAnchor(AnchorLine::Left, m_leftTarget, AnchorLine::Left); m_fxItemNode.anchors().setAnchor(AnchorLine::Left, m_leftTarget, AnchorLine::Left);
@@ -417,7 +429,7 @@ void QmlAnchorBindingProxy::calcRightMargin()
{ {
m_locked = true; m_locked = true;
if (m_rightTarget == m_fxItemNode.modelNode().parentProperty().parentModelNode()) { if (m_rightTarget.modelNode() == m_fxItemNode.modelNode().parentProperty().parentModelNode()) {
qreal rightMargin = parentBoundingBox().right() - transformedBoundingBox().right(); qreal rightMargin = parentBoundingBox().right() - transformedBoundingBox().right();
m_fxItemNode.anchors().setMargin( AnchorLine::Right, rightMargin); m_fxItemNode.anchors().setMargin( AnchorLine::Right, rightMargin);
m_fxItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Right); m_fxItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Right);
@@ -444,6 +456,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
removeTopAnchor(); removeTopAnchor();
} else { } else {
calcTopMargin(); calcTopMargin();
m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "y", m_fxItemNode.instancePosition().y());
m_fxItemNode.removeVariantProperty("y"); m_fxItemNode.removeVariantProperty("y");
} }
emit topAnchorChanged(); emit topAnchorChanged();
@@ -456,6 +469,10 @@ void QmlAnchorBindingProxy::removeTopAnchor() {
m_fxItemNode.anchors().removeAnchor(AnchorLine::Top); m_fxItemNode.anchors().removeAnchor(AnchorLine::Top);
m_fxItemNode.anchors().removeMargin(AnchorLine::Top); m_fxItemNode.anchors().removeMargin(AnchorLine::Top);
if (qFuzzyCompare(m_fxItemNode.instancePosition().y(), 0.0) && m_fxItemNode.modelNode().hasAuxiliaryData(auxDataString + "y"))
m_fxItemNode.setVariantProperty("y", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "y"));
} }
void QmlAnchorBindingProxy::removeBottomAnchor() { void QmlAnchorBindingProxy::removeBottomAnchor() {
@@ -463,6 +480,9 @@ void QmlAnchorBindingProxy::removeBottomAnchor() {
m_fxItemNode.anchors().removeAnchor(AnchorLine::Bottom); m_fxItemNode.anchors().removeAnchor(AnchorLine::Bottom);
m_fxItemNode.anchors().removeMargin(AnchorLine::Bottom); m_fxItemNode.anchors().removeMargin(AnchorLine::Bottom);
if (qFuzzyCompare(m_fxItemNode.instanceSize().height(), 0.0) && m_fxItemNode.modelNode().hasAuxiliaryData(auxDataString + "height"))
m_fxItemNode.setVariantProperty("height", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "height"));
} }
void QmlAnchorBindingProxy::removeLeftAnchor() { void QmlAnchorBindingProxy::removeLeftAnchor() {
@@ -470,6 +490,9 @@ void QmlAnchorBindingProxy::removeLeftAnchor() {
m_fxItemNode.anchors().removeAnchor(AnchorLine::Left); m_fxItemNode.anchors().removeAnchor(AnchorLine::Left);
m_fxItemNode.anchors().removeMargin(AnchorLine::Left); m_fxItemNode.anchors().removeMargin(AnchorLine::Left);
if (qFuzzyCompare(m_fxItemNode.instancePosition().x(), 0.0) && m_fxItemNode.modelNode().hasAuxiliaryData(auxDataString + "x"))
m_fxItemNode.setVariantProperty("x", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "x"));
} }
void QmlAnchorBindingProxy::removeRightAnchor() { void QmlAnchorBindingProxy::removeRightAnchor() {
@@ -477,6 +500,9 @@ void QmlAnchorBindingProxy::removeRightAnchor() {
m_fxItemNode.anchors().removeAnchor(AnchorLine::Right); m_fxItemNode.anchors().removeAnchor(AnchorLine::Right);
m_fxItemNode.anchors().removeMargin(AnchorLine::Right); m_fxItemNode.anchors().removeMargin(AnchorLine::Right);
if (qFuzzyCompare(m_fxItemNode.instanceSize().width(), 0.0) && m_fxItemNode.modelNode().hasAuxiliaryData(auxDataString + "width"))
m_fxItemNode.setVariantProperty("width", m_fxItemNode.modelNode().auxiliaryData(auxDataString + "width"));
} }
void QmlAnchorBindingProxy::setVerticalCentered(bool centered) void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
@@ -487,6 +513,8 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
if (verticalCentered() == centered) if (verticalCentered() == centered)
return; return;
m_locked = true;
RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction(); RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction();
if (!centered) { if (!centered) {
@@ -495,6 +523,9 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
} else { } else {
m_fxItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::VerticalCenter); m_fxItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::VerticalCenter);
} }
m_locked = false;
emit centeredVChanged(); emit centeredVChanged();
} }
@@ -506,6 +537,8 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
if (horizontalCentered() == centered) if (horizontalCentered() == centered)
return; return;
m_locked = true;
RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction(); RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction();
if (!centered) { if (!centered) {
@@ -514,6 +547,9 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
} else { } else {
m_fxItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::HorizontalCenter); m_fxItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_fxItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::HorizontalCenter);
} }
m_locked = false;
emit centeredHChanged(); emit centeredHChanged();
} }
@@ -532,6 +568,15 @@ void QmlAnchorBindingProxy::fill()
RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction(); RewriterTransaction transaction = m_fxItemNode.modelNode().view()->beginRewriterTransaction();
m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "x", m_fxItemNode.instancePosition().x());
m_fxItemNode.removeVariantProperty("x");
m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "y", m_fxItemNode.instancePosition().y());
m_fxItemNode.removeVariantProperty("y");
m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "width", m_fxItemNode.instanceSize().width());
m_fxItemNode.removeVariantProperty("width");
m_fxItemNode.modelNode().setAuxiliaryData(auxDataString + "height", m_fxItemNode.instanceSize().height());
m_fxItemNode.removeVariantProperty("height");
m_fxItemNode.anchors().fill(); m_fxItemNode.anchors().fill();
setHorizontalCentered(false); setHorizontalCentered(false);
@@ -542,11 +587,6 @@ void QmlAnchorBindingProxy::fill()
m_fxItemNode.anchors().removeMargin(AnchorLine::Top); m_fxItemNode.anchors().removeMargin(AnchorLine::Top);
m_fxItemNode.anchors().removeMargin(AnchorLine::Bottom); m_fxItemNode.anchors().removeMargin(AnchorLine::Bottom);
m_fxItemNode.removeVariantProperty("x");
m_fxItemNode.removeVariantProperty("y");
m_fxItemNode.removeVariantProperty("width");
m_fxItemNode.removeVariantProperty("height");
emit topAnchorChanged(); emit topAnchorChanged();
emit bottomAnchorChanged(); emit bottomAnchorChanged();
emit leftAnchorChanged(); emit leftAnchorChanged();

View File

@@ -103,6 +103,7 @@ public:
protected: protected:
QmlItemNode qmlItemNode() const; QmlItemNode qmlItemNode() const;
void beautify();
private: private:
QmlItemNode m_qmlItemNode; QmlItemNode m_qmlItemNode;

View File

@@ -101,7 +101,7 @@ void ModelToTextMerger::propertiesChanged(const QList<AbstractProperty>& propert
schedule(new AddPropertyRewriteAction(property, schedule(new AddPropertyRewriteAction(property,
propertyTextValue, propertyTextValue,
propertyType(property), propertyType(property, propertyTextValue),
containedModelNode)); containedModelNode));
break; break;
@@ -111,7 +111,7 @@ void ModelToTextMerger::propertiesChanged(const QList<AbstractProperty>& propert
schedule(new ChangePropertyRewriteAction(property, schedule(new ChangePropertyRewriteAction(property,
propertyTextValue, propertyTextValue,
propertyType(property), propertyType(property, propertyTextValue),
containedModelNode)); containedModelNode));
break; break;
@@ -149,7 +149,10 @@ void ModelToTextMerger::removeImport(const Import &import)
void ModelToTextMerger::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) void ModelToTextMerger::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange)
{ {
if (isInHierarchy(oldPropertyParent) && isInHierarchy(newPropertyParent)) { // the node is moved if (isInHierarchy(oldPropertyParent) && isInHierarchy(newPropertyParent)) { // the node is moved
schedule(new ReparentNodeRewriteAction(node, oldPropertyParent.parentModelNode(), newPropertyParent, propertyType(newPropertyParent))); schedule(new ReparentNodeRewriteAction(node,
oldPropertyParent.parentModelNode(),
newPropertyParent,
propertyType(newPropertyParent)));
} else if (isInHierarchy(oldPropertyParent) && !isInHierarchy(newPropertyParent)) { // the node is removed from hierarchy } else if (isInHierarchy(oldPropertyParent) && !isInHierarchy(newPropertyParent)) { // the node is removed from hierarchy
if (oldPropertyParent.isNodeProperty()) { if (oldPropertyParent.isNodeProperty()) {
// ignore, the subsequent remove property will take care of all // ignore, the subsequent remove property will take care of all
@@ -165,11 +168,17 @@ void ModelToTextMerger::nodeReparented(const ModelNode &node, const NodeAbstract
} else if (!isInHierarchy(oldPropertyParent) && isInHierarchy(newPropertyParent)) { // the node is inserted into to hierarchy } else if (!isInHierarchy(oldPropertyParent) && isInHierarchy(newPropertyParent)) { // the node is inserted into to hierarchy
switch (propertyChange) { switch (propertyChange) {
case AbstractView::PropertiesAdded: case AbstractView::PropertiesAdded:
schedule(new AddPropertyRewriteAction(newPropertyParent, QmlTextGenerator(getPropertyOrder())(node), propertyType(newPropertyParent), node)); schedule(new AddPropertyRewriteAction(newPropertyParent,
QmlTextGenerator(getPropertyOrder())(node),
propertyType(newPropertyParent),
node));
break; break;
case AbstractView::NoAdditionalChanges: case AbstractView::NoAdditionalChanges:
schedule(new ChangePropertyRewriteAction(newPropertyParent, QmlTextGenerator(getPropertyOrder())(node), propertyType(newPropertyParent), node)); schedule(new ChangePropertyRewriteAction(newPropertyParent,
QmlTextGenerator(getPropertyOrder())(node),
propertyType(newPropertyParent),
node));
break; break;
case AbstractView::EmptyPropertiesRemoved: case AbstractView::EmptyPropertiesRemoved:
@@ -307,11 +316,18 @@ void ModelToTextMerger::schedule(RewriteAction *action)
m_rewriteActions.append(action); m_rewriteActions.append(action);
} }
QmlDesigner::QmlRefactoring::PropertyType ModelToTextMerger::propertyType(const AbstractProperty &property) QmlDesigner::QmlRefactoring::PropertyType ModelToTextMerger::propertyType(const AbstractProperty &property, const QString &textValue)
{ {
if (property.isBindingProperty()) if (property.isBindingProperty()) {
return QmlDesigner::QmlRefactoring::ObjectBinding; QString val = textValue.trimmed();
else if (property.isNodeListProperty()) if (val.isEmpty())
return QmlDesigner::QmlRefactoring::ObjectBinding;
const QChar lastChar = val.at(val.size() - 1);
if (lastChar == '}' || lastChar == ';')
return QmlDesigner::QmlRefactoring::ObjectBinding;
else
return QmlDesigner::QmlRefactoring::ScriptBinding;
} else if (property.isNodeListProperty())
return QmlDesigner::QmlRefactoring::ArrayBinding; return QmlDesigner::QmlRefactoring::ArrayBinding;
else if (property.isNodeProperty()) else if (property.isNodeProperty())
return QmlDesigner::QmlRefactoring::ObjectBinding; return QmlDesigner::QmlRefactoring::ObjectBinding;

View File

@@ -89,7 +89,7 @@ protected:
QList<RewriteAction *> scheduledRewriteActions() const QList<RewriteAction *> scheduledRewriteActions() const
{ return m_rewriteActions; } { return m_rewriteActions; }
static QmlDesigner::QmlRefactoring::PropertyType propertyType(const AbstractProperty &property); static QmlDesigner::QmlRefactoring::PropertyType propertyType(const AbstractProperty &property, const QString &textValue = QString());
static QStringList getPropertyOrder(); static QStringList getPropertyOrder();
static bool isInHierarchy(const AbstractProperty &property); static bool isInHierarchy(const AbstractProperty &property);

View File

@@ -130,6 +130,52 @@ bool QmlAnchors::isValid() const
return m_qmlItemNode.isValid(); return m_qmlItemNode.isValid();
} }
void QmlAnchors::beautify()
{
if ((instanceHasAnchor(AnchorLine::Left) &&
instanceHasAnchor(AnchorLine::Right) &&
instanceHasAnchor(AnchorLine::Top) &&
instanceHasAnchor(AnchorLine::Bottom)) &&
(instanceAnchor(AnchorLine::Left).type() == AnchorLine::Left &&
instanceAnchor(AnchorLine::Right).type() == AnchorLine::Right &&
instanceAnchor(AnchorLine::Top).type() == AnchorLine::Top &&
instanceAnchor(AnchorLine::Bottom).type() == AnchorLine::Bottom) &&
(instanceAnchor(AnchorLine::Left).qmlItemNode() ==
instanceAnchor(AnchorLine::Right).qmlItemNode() &&
instanceAnchor(AnchorLine::Top).qmlItemNode() ==
instanceAnchor(AnchorLine::Bottom).qmlItemNode()) &&
(instanceAnchor(AnchorLine::Left).qmlItemNode() ==
instanceAnchor(AnchorLine::Bottom).qmlItemNode())) {
if (instanceHasAnchor(AnchorLine::Fill))
return; //avoid recursion
QmlItemNode targetNode(instanceAnchor(AnchorLine::Left).qmlItemNode());
removeAnchors();
setAnchor(AnchorLine::Fill, targetNode, AnchorLine::Fill);
}
if ((instanceHasAnchor(AnchorLine::VerticalCenter) &&
instanceHasAnchor(AnchorLine::HorizontalCenter)) &&
(instanceAnchor(AnchorLine::VerticalCenter).type() == AnchorLine::VerticalCenter &&
instanceAnchor(AnchorLine::HorizontalCenter).type() == AnchorLine::HorizontalCenter) &&
(instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode() ==
instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode())) {
if (instanceHasAnchor(AnchorLine::Center))
return; //avoid recursion
QmlItemNode targetNode(instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode());
removeAnchors();
setAnchor(AnchorLine::Center, targetNode, AnchorLine::Center);
}
}
void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine, void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine,
const QmlItemNode &targetQmlItemNode, const QmlItemNode &targetQmlItemNode,
AnchorLine::Type targetAnchorLine) AnchorLine::Type targetAnchorLine)
@@ -145,9 +191,11 @@ void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine,
QString targetExpression = targetQmlItemNode.modelNode().validId(); QString targetExpression = targetQmlItemNode.modelNode().validId();
if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode()) if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode())
targetExpression = "parent"; targetExpression = "parent";
targetExpression = targetExpression + QLatin1Char('.') + lineTypeToString(targetAnchorLine); if (sourceAnchorLine != AnchorLine::Center && sourceAnchorLine != AnchorLine::Fill)
targetExpression = targetExpression + QLatin1Char('.') + lineTypeToString(targetAnchorLine);
qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression); qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression);
} }
beautify();
} }
bool detectHorizontalCycle(const ModelNode &node, QList<ModelNode> knownNodeList) bool detectHorizontalCycle(const ModelNode &node, QList<ModelNode> knownNodeList)

View File

@@ -67,6 +67,7 @@ void RewriteActionCompressor::operator()(QList<RewriteAction *> &actions) const
void RewriteActionCompressor::compressImports(QList<RewriteAction *> &actions) const void RewriteActionCompressor::compressImports(QList<RewriteAction *> &actions) const
{ {
QList<RewriteAction *> actionsToRemove;
QHash<Import, RewriteAction *> addedImports; QHash<Import, RewriteAction *> addedImports;
QHash<Import, RewriteAction *> removedImports; QHash<Import, RewriteAction *> removedImports;
@@ -78,36 +79,42 @@ void RewriteActionCompressor::compressImports(QList<RewriteAction *> &actions) c
if (RemoveImportRewriteAction *removeImportAction = action->asRemoveImportRewriteAction()) { if (RemoveImportRewriteAction *removeImportAction = action->asRemoveImportRewriteAction()) {
const Import import = removeImportAction->import(); const Import import = removeImportAction->import();
if (removedImports.contains(import)) { if (removedImports.contains(import)) {
remove(iter); actionsToRemove.append(action);
} else if (RewriteAction *addImportAction = addedImports.value(import, 0)) { } else if (RewriteAction *addImportAction = addedImports.value(import, 0)) {
actions.removeOne(addImportAction); actionsToRemove.append(action);
actionsToRemove.append(addImportAction);
addedImports.remove(import); addedImports.remove(import);
delete addImportAction; delete addImportAction;
remove(iter);
} else { } else {
removedImports.insert(import, action); removedImports.insert(import, action);
} }
} else if (AddImportRewriteAction *addImportAction = action->asAddImportRewriteAction()) { } else if (AddImportRewriteAction *addImportAction = action->asAddImportRewriteAction()) {
const Import import = addImportAction->import(); const Import import = addImportAction->import();
if (RewriteAction *duplicateAction = addedImports.value(import, 0)) { if (RewriteAction *duplicateAction = addedImports.value(import, 0)) {
actions.removeOne(duplicateAction); actionsToRemove.append(duplicateAction);
addedImports.remove(import); addedImports.remove(import);
delete duplicateAction; delete duplicateAction;
addedImports.insert(import, action); addedImports.insert(import, action);
} else if (RewriteAction *removeAction = removedImports.value(import, 0)) { } else if (RewriteAction *removeAction = removedImports.value(import, 0)) {
actions.removeOne(removeAction); actionsToRemove.append(action);
actionsToRemove.append(removeAction);
removedImports.remove(import); removedImports.remove(import);
delete removeAction; delete removeAction;
remove(iter);
} else { } else {
addedImports.insert(import, action); addedImports.insert(import, action);
} }
} }
} }
foreach (RewriteAction *action, actionsToRemove) {
actions.removeOne(action);
delete action;
}
} }
void RewriteActionCompressor::compressRereparentActions(QList<RewriteAction *> &actions) const void RewriteActionCompressor::compressRereparentActions(QList<RewriteAction *> &actions) const
{ {
QList<RewriteAction *> actionsToRemove;
QHash<ModelNode, ReparentNodeRewriteAction *> reparentedNodes; QHash<ModelNode, ReparentNodeRewriteAction *> reparentedNodes;
QMutableListIterator<RewriteAction*> iter(actions); QMutableListIterator<RewriteAction*> iter(actions);
@@ -120,16 +127,22 @@ void RewriteActionCompressor::compressRereparentActions(QList<RewriteAction *> &
if (ReparentNodeRewriteAction *otherAction = reparentedNodes.value(reparentedNode, 0)) { if (ReparentNodeRewriteAction *otherAction = reparentedNodes.value(reparentedNode, 0)) {
otherAction->setOldParent(reparentAction->oldParent()); otherAction->setOldParent(reparentAction->oldParent());
remove(iter); actionsToRemove.append(action);
} else { } else {
reparentedNodes.insert(reparentedNode, reparentAction); reparentedNodes.insert(reparentedNode, reparentAction);
} }
} }
} }
foreach (RewriteAction *action, actionsToRemove) {
actions.removeOne(action);
delete action;
}
} }
void RewriteActionCompressor::compressReparentIntoSameParentActions(QList<RewriteAction *> &actions) const void RewriteActionCompressor::compressReparentIntoSameParentActions(QList<RewriteAction *> &actions) const
{ {
QList<RewriteAction *> actionsToRemove;
QMutableListIterator<RewriteAction *> iter(actions); QMutableListIterator<RewriteAction *> iter(actions);
iter.toBack(); iter.toBack();
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
@@ -139,15 +152,20 @@ void RewriteActionCompressor::compressReparentIntoSameParentActions(QList<Rewrit
const ModelNode targetNode = reparentAction->targetProperty().parentModelNode(); const ModelNode targetNode = reparentAction->targetProperty().parentModelNode();
const ModelNode oldParent = reparentAction->oldParent(); const ModelNode oldParent = reparentAction->oldParent();
if (targetNode == oldParent) if (targetNode == oldParent)
remove(iter); actionsToRemove.append(action);
} }
} }
foreach (RewriteAction *action, actionsToRemove) {
actions.removeOne(action);
delete action;
}
} }
void RewriteActionCompressor::compressAddEditRemoveNodeActions(QList<RewriteAction *> &actions) const void RewriteActionCompressor::compressAddEditRemoveNodeActions(QList<RewriteAction *> &actions) const
{ {
QList<RewriteAction *> actionsToRemove;
QHash<ModelNode, RewriteAction *> removedNodes; QHash<ModelNode, RewriteAction *> removedNodes;
QSet<RewriteAction *> removeActionsToRemove;
QMutableListIterator<RewriteAction*> iter(actions); QMutableListIterator<RewriteAction*> iter(actions);
iter.toBack(); iter.toBack();
@@ -158,7 +176,7 @@ void RewriteActionCompressor::compressAddEditRemoveNodeActions(QList<RewriteActi
const ModelNode modelNode = removeNodeAction->node(); const ModelNode modelNode = removeNodeAction->node();
if (removedNodes.contains(modelNode)) if (removedNodes.contains(modelNode))
remove(iter); actionsToRemove.append(action);
else else
removedNodes.insert(modelNode, action); removedNodes.insert(modelNode, action);
} else if (action->asAddPropertyRewriteAction() || action->asChangePropertyRewriteAction()) { } else if (action->asAddPropertyRewriteAction() || action->asChangePropertyRewriteAction()) {
@@ -172,30 +190,30 @@ void RewriteActionCompressor::compressAddEditRemoveNodeActions(QList<RewriteActi
containedModelNode = action->asChangePropertyRewriteAction()->containedModelNode(); containedModelNode = action->asChangePropertyRewriteAction()->containedModelNode();
} }
if (removedNodes.contains(property.parentModelNode())) if (removedNodes.contains(property.parentModelNode())) {
remove(iter); actionsToRemove.append(action);
else if (removedNodes.contains(containedModelNode)) { } else if (RewriteAction *removeAction = removedNodes.value(containedModelNode, 0)) {
remove(iter); actionsToRemove.append(action);
removeActionsToRemove.insert(removedNodes[containedModelNode]); actionsToRemove.append(removeAction);
} }
} else if (RemovePropertyRewriteAction *removePropertyAction = action->asRemovePropertyRewriteAction()) { } else if (RemovePropertyRewriteAction *removePropertyAction = action->asRemovePropertyRewriteAction()) {
const AbstractProperty property = removePropertyAction->property(); const AbstractProperty property = removePropertyAction->property();
if (removedNodes.contains(property.parentModelNode())) if (removedNodes.contains(property.parentModelNode()))
remove(iter); actionsToRemove.append(action);
} else if (ChangeIdRewriteAction *changeIdAction = action->asChangeIdRewriteAction()) { } else if (ChangeIdRewriteAction *changeIdAction = action->asChangeIdRewriteAction()) {
if (removedNodes.contains(changeIdAction->node())) if (removedNodes.contains(changeIdAction->node()))
remove(iter); actionsToRemove.append(action);
} else if (ChangeTypeRewriteAction *changeTypeAction = action->asChangeTypeRewriteAction()) { } else if (ChangeTypeRewriteAction *changeTypeAction = action->asChangeTypeRewriteAction()) {
if (removedNodes.contains(changeTypeAction->node())) if (removedNodes.contains(changeTypeAction->node()))
remove(iter); actionsToRemove.append(action);
} else if (ReparentNodeRewriteAction *reparentAction = action->asReparentNodeRewriteAction()) { } else if (ReparentNodeRewriteAction *reparentAction = action->asReparentNodeRewriteAction()) {
if (removedNodes.contains(reparentAction->reparentedNode())) if (removedNodes.contains(reparentAction->reparentedNode()))
remove(iter); actionsToRemove.append(action);
} }
} }
foreach (RewriteAction *action, removeActionsToRemove) { foreach (RewriteAction *action, actionsToRemove) {
actions.removeOne(action); actions.removeOne(action);
delete action; delete action;
} }
@@ -203,6 +221,7 @@ void RewriteActionCompressor::compressAddEditRemoveNodeActions(QList<RewriteActi
void RewriteActionCompressor::compressPropertyActions(QList<RewriteAction *> &actions) const void RewriteActionCompressor::compressPropertyActions(QList<RewriteAction *> &actions) const
{ {
QList<RewriteAction *> actionsToRemove;
QHash<AbstractProperty, RewriteAction *> removedProperties; QHash<AbstractProperty, RewriteAction *> removedProperties;
QHash<AbstractProperty, ChangePropertyRewriteAction *> changedProperties; QHash<AbstractProperty, ChangePropertyRewriteAction *> changedProperties;
QSet<AbstractProperty> addedProperties; QSet<AbstractProperty> addedProperties;
@@ -218,10 +237,10 @@ void RewriteActionCompressor::compressPropertyActions(QList<RewriteAction *> &ac
const AbstractProperty property = changeAction->property(); const AbstractProperty property = changeAction->property();
if (removedProperties.contains(property)) { if (removedProperties.contains(property)) {
remove(iter); actionsToRemove.append(action);
} else if (changedProperties.contains(property)) { } else if (changedProperties.contains(property)) {
if (!property.isValid() || !property.isDefaultProperty()) if (!property.isValid() || !property.isDefaultProperty())
remove(iter); actionsToRemove.append(action);
} else { } else {
changedProperties.insert(property, changeAction); changedProperties.insert(property, changeAction);
} }
@@ -229,10 +248,9 @@ void RewriteActionCompressor::compressPropertyActions(QList<RewriteAction *> &ac
const AbstractProperty property = addAction->property(); const AbstractProperty property = addAction->property();
if (RewriteAction *removeAction = removedProperties.value(property, 0)) { if (RewriteAction *removeAction = removedProperties.value(property, 0)) {
actions.removeOne(removeAction); actionsToRemove.append(action);
actionsToRemove.append(removeAction);
removedProperties.remove(property); removedProperties.remove(property);
delete removeAction;
remove(iter);
} else { } else {
if (changedProperties.contains(property)) if (changedProperties.contains(property))
changedProperties.remove(property); changedProperties.remove(property);
@@ -241,10 +259,16 @@ void RewriteActionCompressor::compressPropertyActions(QList<RewriteAction *> &ac
} }
} }
} }
foreach (RewriteAction *action, actionsToRemove){
actions.removeOne(action);
delete action;
}
} }
void RewriteActionCompressor::compressAddEditActions(QList<RewriteAction *> &actions) const void RewriteActionCompressor::compressAddEditActions(QList<RewriteAction *> &actions) const
{ {
QList<RewriteAction *> actionsToRemove;
QSet<ModelNode> addedNodes; QSet<ModelNode> addedNodes;
QSet<RewriteAction *> dirtyActions; QSet<RewriteAction *> dirtyActions;
@@ -265,7 +289,7 @@ void RewriteActionCompressor::compressAddEditActions(QList<RewriteAction *> &act
} }
if (property.isValid() && addedNodes.contains(property.parentModelNode())) { if (property.isValid() && addedNodes.contains(property.parentModelNode())) {
remove(iter); actionsToRemove.append(action);
continue; continue;
} }
@@ -273,22 +297,27 @@ void RewriteActionCompressor::compressAddEditActions(QList<RewriteAction *> &act
continue; continue;
if (nodeOrParentInSet(containedNode, addedNodes)) { if (nodeOrParentInSet(containedNode, addedNodes)) {
remove(iter); actionsToRemove.append(action);
} else { } else {
addedNodes.insert(containedNode); addedNodes.insert(containedNode);
dirtyActions.insert(action); dirtyActions.insert(action);
} }
} else if (ChangeIdRewriteAction *changeIdAction = action->asChangeIdRewriteAction()) { } else if (ChangeIdRewriteAction *changeIdAction = action->asChangeIdRewriteAction()) {
if (nodeOrParentInSet(changeIdAction->node(), addedNodes)) { if (nodeOrParentInSet(changeIdAction->node(), addedNodes)) {
remove(iter); actionsToRemove.append(action);
} }
} else if (ChangeTypeRewriteAction *changeTypeAction = action->asChangeTypeRewriteAction()) { } else if (ChangeTypeRewriteAction *changeTypeAction = action->asChangeTypeRewriteAction()) {
if (nodeOrParentInSet(changeTypeAction->node(), addedNodes)) { if (nodeOrParentInSet(changeTypeAction->node(), addedNodes)) {
remove(iter); actionsToRemove.append(action);
} }
} }
} }
foreach (RewriteAction *action, actionsToRemove){
actions.removeOne(action);
delete action;
}
QmlTextGenerator gen(m_propertyOrder); QmlTextGenerator gen(m_propertyOrder);
foreach (RewriteAction *action, dirtyActions) { foreach (RewriteAction *action, dirtyActions) {
RewriteAction *newAction = 0; RewriteAction *newAction = 0;
@@ -313,6 +342,7 @@ void RewriteActionCompressor::compressAddEditActions(QList<RewriteAction *> &act
void RewriteActionCompressor::compressAddReparentActions(QList<RewriteAction *> &actions) const void RewriteActionCompressor::compressAddReparentActions(QList<RewriteAction *> &actions) const
{ {
QList<RewriteAction *> actionsToRemove;
QMap<ModelNode, RewriteAction*> addedNodes; QMap<ModelNode, RewriteAction*> addedNodes;
QMutableListIterator<RewriteAction*> iter(actions); QMutableListIterator<RewriteAction*> iter(actions);
@@ -335,7 +365,7 @@ void RewriteActionCompressor::compressAddReparentActions(QList<RewriteAction *>
} else if (ReparentNodeRewriteAction *reparentAction = action->asReparentNodeRewriteAction()) { } else if (ReparentNodeRewriteAction *reparentAction = action->asReparentNodeRewriteAction()) {
if (addedNodes.contains(reparentAction->reparentedNode())) { if (addedNodes.contains(reparentAction->reparentedNode())) {
RewriteAction *previousAction = addedNodes[reparentAction->reparentedNode()]; RewriteAction *previousAction = addedNodes[reparentAction->reparentedNode()];
actions.removeOne(previousAction); actionsToRemove.append(previousAction);
RewriteAction *replacementAction = 0; RewriteAction *replacementAction = 0;
if (AddPropertyRewriteAction *addAction = previousAction->asAddPropertyRewriteAction()) { if (AddPropertyRewriteAction *addAction = previousAction->asAddPropertyRewriteAction()) {
@@ -351,15 +381,13 @@ void RewriteActionCompressor::compressAddReparentActions(QList<RewriteAction *>
} }
iter.setValue(replacementAction); iter.setValue(replacementAction);
delete previousAction;
delete action; delete action;
} }
} }
} }
}
void RewriteActionCompressor::remove(QMutableListIterator<RewriteAction*> &iter) const foreach (RewriteAction *action, actionsToRemove){
{ actions.removeOne(action);
delete iter.value(); delete action;
iter.remove(); }
} }

View File

@@ -54,8 +54,6 @@ private:
void compressAddEditActions(QList<RewriteAction *> &actions) const; void compressAddEditActions(QList<RewriteAction *> &actions) const;
void compressAddReparentActions(QList<RewriteAction *> &actions) const; void compressAddReparentActions(QList<RewriteAction *> &actions) const;
void remove(QMutableListIterator<RewriteAction*> &iter) const;
private: private:
QStringList m_propertyOrder; QStringList m_propertyOrder;
}; };

View File

@@ -46,6 +46,7 @@
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QStringBuilder> #include <QtCore/QStringBuilder>
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtCore/QTimer>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtCore/QXmlStreamReader> #include <QtCore/QXmlStreamReader>
#include <QtGui/QDialogButtonBox> #include <QtGui/QDialogButtonBox>
@@ -94,6 +95,7 @@ GettingStartedWelcomePageWidget::GettingStartedWelcomePageWidget(QWidget *parent
QIcon::fromTheme("document-new", ui->createNewProjectButton->icon())); QIcon::fromTheme("document-new", ui->createNewProjectButton->icon()));
ui->openProjectButton->setIcon( ui->openProjectButton->setIcon(
QIcon::fromTheme("document-open", ui->openProjectButton->icon())); QIcon::fromTheme("document-open", ui->openProjectButton->icon()));
QTimer::singleShot(0, this, SLOT(slotSetPrivateQmlExamples()));
} }
GettingStartedWelcomePageWidget::~GettingStartedWelcomePageWidget() GettingStartedWelcomePageWidget::~GettingStartedWelcomePageWidget()
@@ -101,6 +103,14 @@ GettingStartedWelcomePageWidget::~GettingStartedWelcomePageWidget()
delete ui; delete ui;
} }
void GettingStartedWelcomePageWidget::slotSetPrivateQmlExamples()
{
if (!ui->qmlExamplesButton->menu()) {
const QString resPath = Core::ICore::instance()->resourcePath();
updateQmlExamples(resPath, resPath);
}
}
void GettingStartedWelcomePageWidget::updateCppExamples(const QString &examplePath, void GettingStartedWelcomePageWidget::updateCppExamples(const QString &examplePath,
const QString &sourcePath, const QString &sourcePath,
const QString &demoXml) const QString &demoXml)

View File

@@ -58,6 +58,7 @@ private slots:
void slotNextTip(); void slotNextTip();
void slotPrevTip(); void slotPrevTip();
void slotCreateNewProject(); void slotCreateNewProject();
void slotSetPrivateQmlExamples();
private: private:
QStringList tipsOfTheDay(); QStringList tipsOfTheDay();
@@ -66,7 +67,6 @@ private:
const QString &demoXml); const QString &demoXml);
void updateQmlExamples(const QString &examplePath, void updateQmlExamples(const QString &examplePath,
const QString &sourcePath); const QString &sourcePath);
Ui::GettingStartedWelcomePageWidget *ui; Ui::GettingStartedWelcomePageWidget *ui;
int m_currentTip; int m_currentTip;
}; };

View File

@@ -102,8 +102,8 @@ MaemoSshRunner::MaemoSshRunner(const Core::SshServerInfo &server,
bool MaemoSshRunner::runInternal() bool MaemoSshRunner::runInternal()
{ {
createConnection(); createConnection();
connect(m_connection.data(), SIGNAL(remoteOutputAvailable()), connect(m_connection.data(), SIGNAL(remoteOutput(QByteArray)),
this, SLOT(handleRemoteOutput())); this, SLOT(handleRemoteOutput(QByteArray)));
initState(); initState();
if (!m_connection->start()) if (!m_connection->start())
return false; return false;
@@ -121,7 +121,7 @@ void MaemoSshRunner::initState()
m_potentialEndMarkerPrefix.clear(); m_potentialEndMarkerPrefix.clear();
} }
void MaemoSshRunner::handleRemoteOutput() void MaemoSshRunner::handleRemoteOutput(const QByteArray &curOutput)
{ {
const QByteArray output const QByteArray output
= m_potentialEndMarkerPrefix + m_connection->waitForRemoteOutput(0); = m_potentialEndMarkerPrefix + m_connection->waitForRemoteOutput(0);

View File

@@ -96,7 +96,7 @@ signals:
private: private:
virtual bool runInternal(); virtual bool runInternal();
Q_SLOT void handleRemoteOutput(); Q_SLOT void handleRemoteOutput(const QByteArray &output);
void initState(); void initState();
static const QByteArray EndMarker; static const QByteArray EndMarker;

View File

@@ -228,23 +228,30 @@ void QtVersionManager::updateDocumentation()
void QtVersionManager::updateExamples() void QtVersionManager::updateExamples()
{ {
QList<QtVersion *> versions;
versions.append(m_versions);
QString examplesPath;
QString demosPath;
QtVersion *version = 0; QtVersion *version = 0;
QList<QtVersion*> candidates;
// try to find a version which has both, demos and examples // try to find a version which has both, demos and examples
foreach (version, versions) { foreach (version, m_versions) {
if (version->hasExamples()) if (version->hasExamples() && version->hasDemos())
examplesPath = version->examplesPath(); candidates.append(version);
if (version->hasDemos()) }
demosPath = version->demosPath();
if (!examplesPath.isEmpty() && !demosPath.isEmpty()) { // prefer versions with declarative examples
emit updateExamples(examplesPath, demosPath, version->sourcePath()); foreach (version, candidates) {
if (QDir(version->examplesPath()+"/declarative").exists()) {
emit updateExamples(version->examplesPath(), version->demosPath(), version->sourcePath());
return; return;
} }
} }
if (!candidates.isEmpty()) {
version = candidates.first();
emit updateExamples(version->examplesPath(), version->demosPath(), version->sourcePath());
return;
}
return;
} }
int QtVersionManager::getUniqueId() int QtVersionManager::getUniqueId()

View File

@@ -35,6 +35,9 @@
#include "qt4projectmanagerconstants.h" #include "qt4projectmanagerconstants.h"
#include "qt4target.h" #include "qt4target.h"
#include <utils/qtcassert.h>
#include <extensionsystem/pluginmanager.h>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtGui/QHeaderView> #include <QtGui/QHeaderView>
#include <QtGui/QLabel> #include <QtGui/QLabel>
@@ -442,21 +445,26 @@ QPair<QIcon, QString> TargetSetupPage::reportIssues(Qt4ProjectManager::QtVersion
if (m_proFilePath.isEmpty()) if (m_proFilePath.isEmpty())
return qMakePair(QIcon(), QString()); return qMakePair(QIcon(), QString());
const ProjectExplorer::TaskWindow *taskWindow = ExtensionSystem::PluginManager::instance()
->getObject<ProjectExplorer::TaskWindow>();
QTC_ASSERT(taskWindow, return qMakePair(QIcon(), QString()));
QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath); QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath);
QString text; QString text;
QIcon icon; QIcon icon;
foreach (const ProjectExplorer::Task t, issues) { foreach (const ProjectExplorer::Task &t, issues) {
if (!text.isEmpty()) if (!text.isEmpty())
text.append(QLatin1String("<br>")); text.append(QLatin1String("<br>"));
// set severity: // set severity:
QString severity; QString severity;
if (t.type == ProjectExplorer::Task::Error) { if (t.type == ProjectExplorer::Task::Error) {
icon = t.icon(); icon = taskWindow->taskTypeIcon(t.type);
severity = tr("<b>Error:</b> ", "Severity is Task::Error"); severity = tr("<b>Error:</b> ", "Severity is Task::Error");
} else if (t.type == ProjectExplorer::Task::Warning) { } else if (t.type == ProjectExplorer::Task::Warning) {
if (icon.isNull()) if (icon.isNull())
icon = t.icon(); icon = taskWindow->taskTypeIcon(t.type);
severity = tr("<b>Warning:</b> ", "Severity is Task::Warning"); severity = tr("<b>Warning:</b> ", "Severity is Task::Warning");
} }
text.append(severity + t.description); text.append(severity + t.description);

View File

@@ -425,7 +425,7 @@ void VCSBaseOutputWindow::appendData(const QByteArray &data)
void VCSBaseOutputWindow::appendDataSilently(const QByteArray &data) void VCSBaseOutputWindow::appendDataSilently(const QByteArray &data)
{ {
append(QTextCodec::codecForLocale()->toUnicode(data)); appendSilently(QTextCodec::codecForLocale()->toUnicode(data));
} }
VCSBaseOutputWindow *VCSBaseOutputWindow::instance() VCSBaseOutputWindow *VCSBaseOutputWindow::instance()

View File

@@ -43,6 +43,7 @@
#include <QtGui/QScrollArea> #include <QtGui/QScrollArea>
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
#include <QtGui/QToolButton> #include <QtGui/QToolButton>
#include <QtGui/QPainter>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtCore/QDebug> #include <QtCore/QDebug>
@@ -56,6 +57,24 @@ static const char currentPageSettingsKeyC[] = "General/WelcomeTab";
namespace Welcome { namespace Welcome {
// Helper class introduced to cache the scaled background image
// so we avoid re-scaling for every repaint.
class ImageWidget : public QWidget
{
public:
ImageWidget(const QPixmap &bg, QWidget *parent) : QWidget(parent), m_bg(bg) {}
void paintEvent(QPaintEvent *e) {
QPainter painter(this);
if (m_stretch.size() != size())
m_stretch = m_bg.scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
painter.drawPixmap(rect(), m_stretch);
QWidget::paintEvent(e);
}
private:
QPixmap m_bg;
QPixmap m_stretch;
};
struct WelcomeModePrivate struct WelcomeModePrivate
{ {
typedef QMap<QToolButton*, QWidget*> ToolButtonWidgetMap; typedef QMap<QToolButton*, QWidget*> ToolButtonWidgetMap;
@@ -64,7 +83,7 @@ struct WelcomeModePrivate
QScrollArea *m_scrollArea; QScrollArea *m_scrollArea;
QWidget *m_widget; QWidget *m_widget;
QWidget *m_welcomePage; ImageWidget *m_welcomePage;
ToolButtonWidgetMap buttonMap; ToolButtonWidgetMap buttonMap;
QHBoxLayout * buttonLayout; QHBoxLayout * buttonLayout;
Ui::WelcomeMode ui; Ui::WelcomeMode ui;
@@ -79,7 +98,7 @@ WelcomeMode::WelcomeMode() :
l->setMargin(0); l->setMargin(0);
l->setSpacing(0); l->setSpacing(0);
l->addWidget(new Utils::StyledBar(m_d->m_widget)); l->addWidget(new Utils::StyledBar(m_d->m_widget));
m_d->m_welcomePage = new QWidget(m_d->m_widget); m_d->m_welcomePage = new ImageWidget(QPixmap(":/welcome/images/welcomebg.png"), m_d->m_widget);
m_d->ui.setupUi(m_d->m_welcomePage); m_d->ui.setupUi(m_d->m_welcomePage);
m_d->ui.helpUsLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect); m_d->ui.helpUsLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect);
m_d->ui.feedbackButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); m_d->ui.feedbackButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);

View File

@@ -75,12 +75,6 @@ QToolButton:pressed, QPushButton:pressed{
</property> </property>
<item> <item>
<widget class="QWidget" name="gradientWidget" native="true"> <widget class="QWidget" name="gradientWidget" native="true">
<property name="styleSheet">
<string notr="true">#gradientWidget {
border-image: url(:/welcome/images/welcomebg.png) 0;
}
</string>
</property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>

View File

@@ -4,4 +4,4 @@ TARGET = qtcdebugger
TEMPLATE = app TEMPLATE = app
SOURCES += main.cpp SOURCES += main.cpp
DESTDIR=..\..\..\bin DESTDIR=../../../bin

View File

@@ -1,3 +1,7 @@
#define private public // Give us access to private 'backward' member of QMapNode.
# include <QtCore/QMap>
#undef private
#include "gdb/gdbmi.h" #include "gdb/gdbmi.h"
#include "tcf/json.h" #include "tcf/json.h"
#include "gdbmacros.h" #include "gdbmacros.h"
@@ -1256,9 +1260,8 @@ template <typename T>
const QString typeStr = stripPtrType(typeToString<T>()); const QString typeStr = stripPtrType(typeToString<T>());
const QByteArray addrStr = valToString(curElem); const QByteArray addrStr = valToString(curElem);
if (curElem != 0) { if (curElem != 0) {
expected.append("addr='").append(addrStr).append("',saddr='"). expected.append("addr='").append(addrStr).append("',type='").
append(addrStr).append("',type='").append(typeStr). append(typeStr).append("',value='").
append("',value='").
append(derefValToString(curElem)).append("'"); append(derefValToString(curElem)).append("'");
} else { } else {
expected.append("addr='").append(ptrToBa(&curElem)).append("',type='"). expected.append("addr='").append(ptrToBa(&curElem)).append("',type='").
@@ -1426,9 +1429,9 @@ void tst_Debugger::dumpQList_int_star()
ilist.append(0); ilist.append(0);
testDumper("value='<2 items>',valueeditable='false',numchild='2'," testDumper("value='<2 items>',valueeditable='false',numchild='2',"
"internal='1',childtype='int*',childnumchild='1',children=[" "internal='1',childtype='int*',childnumchild='1',children=["
"{saddr='" + str(&ilist.at(0)) + "',addr='" + str(deref(&ilist.at(0))) + "{addr='" + str(deref(&ilist.at(0))) +
"',type='int',value='1'}," "',type='int',value='1'},"
"{saddr='" + str(&ilist.at(1)) + "',value='<null>',numchild='0'}]", "{value='<null>',numchild='0'}]",
&ilist, NS"QList", true, "int*"); &ilist, NS"QList", true, "int*");
} }
@@ -2327,15 +2330,13 @@ void tst_Debugger::dumpStdVector()
vector.push_back(new std::list<int>(list)); vector.push_back(new std::list<int>(list));
testDumper("value='<1 items>',valueeditable='false',numchild='1'," testDumper("value='<1 items>',valueeditable='false',numchild='1',"
"childtype='" + inner + "',childnumchild='1'," "childtype='" + inner + "',childnumchild='1',"
"children=[{addr='" + str(deref(&vector[0])) + "'," "children=[{addr='" + str(deref(&vector[0])) + "',type='" + innerp + "'}]",
"saddr='" + str(deref(&vector[0])) + "',type='" + innerp + "'}]",
&vector, "std::vector", true, inner, "", sizeof(std::list<int> *)); &vector, "std::vector", true, inner, "", sizeof(std::list<int> *));
vector.push_back(0); vector.push_back(0);
list.push_back(45); list.push_back(45);
testDumper("value='<2 items>',valueeditable='false',numchild='2'," testDumper("value='<2 items>',valueeditable='false',numchild='2',"
"childtype='" + inner + "',childnumchild='1'," "childtype='" + inner + "',childnumchild='1',"
"children=[{addr='" + str(deref(&vector[0])) + "'," "children=[{addr='" + str(deref(&vector[0])) + "',type='" + innerp + "'},"
"saddr='" + str(deref(&vector[0])) + "',type='" + innerp + "'},"
"{addr='" + str(&vector[1]) + "'," "{addr='" + str(&vector[1]) + "',"
"type='" + innerp + "',value='<null>',numchild='0'}]", "type='" + innerp + "',value='<null>',numchild='0'}]",
&vector, "std::vector", true, inner, "", sizeof(std::list<int> *)); &vector, "std::vector", true, inner, "", sizeof(std::list<int> *));

View File

@@ -3343,6 +3343,117 @@ void TestCore::testSubComponentManager()
QVERIFY(myButtonMetaInfo.property("border.width", true).isValid()); QVERIFY(myButtonMetaInfo.property("border.width", true).isValid());
} }
void TestCore::testAnchorsAndRewriting()
{
const QString qmlString("import Qt 4.7\n"
"Rectangle {\n"
" id: root\n"
" x: 10;\n"
" y: 10;\n"
" Rectangle {\n"
" id: rectangle1\n"
" x: 10;\n"
" y: 10;\n"
" }\n"
" Component {\n"
" id: rectangleComponent\n"
" Rectangle {\n"
" x: 100;\n"
" y: 100;\n"
" }\n"
" }\n"
"}");
QPlainTextEdit textEdit;
textEdit.setPlainText(qmlString);
NotIndentingTextEditModifier textModifier(&textEdit);
QScopedPointer<Model> model(Model::create("Qt/Item", 4, 7));
QVERIFY(model.data());
QScopedPointer<TestView> view(new TestView);
model->attachView(view.data());
// read in
QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView());
testRewriterView->setTextModifier(&textModifier);
model->attachView(testRewriterView.data());
ModelNode rootNode = view->rootModelNode();
QVERIFY(rootNode.isValid());
QCOMPARE(rootNode.type(), QLatin1String("Qt/Rectangle"));
QmlItemNode rootItemNode = view->rootQmlItemNode();
QVERIFY(rootItemNode.isValid());
QmlItemNode childNode = rootItemNode.allDirectSubModelNodes().first();
QVERIFY(childNode.isValid());
childNode.anchors().setMargin(AnchorLine::Left, 280);
childNode.anchors().setAnchor(AnchorLine::Left, rootItemNode, AnchorLine::Left);
childNode.anchors().setMargin(AnchorLine::Right, 200);
childNode.anchors().setAnchor(AnchorLine::Right, rootItemNode, AnchorLine::Right);
childNode.anchors().setMargin(AnchorLine::Bottom, 50);
childNode.anchors().setAnchor(AnchorLine::Bottom, rootItemNode, AnchorLine::Bottom);
{
RewriterTransaction transaction = view->beginRewriterTransaction();
childNode.anchors().setMargin(AnchorLine::Top, 100);
childNode.anchors().setAnchor(AnchorLine::Top, rootItemNode, AnchorLine::Top);
}
}
void TestCore::testAnchorsAndRewritingCenter()
{
const QString qmlString("import Qt 4.7\n"
"Rectangle {\n"
" id: root\n"
" x: 10;\n"
" y: 10;\n"
" Rectangle {\n"
" id: rectangle1\n"
" x: 10;\n"
" y: 10;\n"
" }\n"
" Component {\n"
" id: rectangleComponent\n"
" Rectangle {\n"
" x: 100;\n"
" y: 100;\n"
" }\n"
" }\n"
"}");
QPlainTextEdit textEdit;
textEdit.setPlainText(qmlString);
NotIndentingTextEditModifier textModifier(&textEdit);
QScopedPointer<Model> model(Model::create("Qt/Item", 4, 7));
QVERIFY(model.data());
QScopedPointer<TestView> view(new TestView);
model->attachView(view.data());
// read in
QScopedPointer<TestRewriterView> testRewriterView(new TestRewriterView());
testRewriterView->setTextModifier(&textModifier);
model->attachView(testRewriterView.data());
ModelNode rootNode = view->rootModelNode();
QVERIFY(rootNode.isValid());
QCOMPARE(rootNode.type(), QLatin1String("Qt/Rectangle"));
QmlItemNode rootItemNode = view->rootQmlItemNode();
QVERIFY(rootItemNode.isValid());
QmlItemNode childNode = rootItemNode.allDirectSubModelNodes().first();
QVERIFY(childNode.isValid());
childNode.anchors().setAnchor(AnchorLine::VerticalCenter, rootItemNode, AnchorLine::VerticalCenter);
childNode.anchors().setAnchor(AnchorLine::HorizontalCenter, rootItemNode, AnchorLine::HorizontalCenter);
}
void TestCore::loadQml() void TestCore::loadQml()
{ {
char qmlString[] = "import Qt 4.7\n" char qmlString[] = "import Qt 4.7\n"

View File

@@ -164,6 +164,8 @@ private slots:
void testCopyModelRewriter1(); void testCopyModelRewriter1();
void testCopyModelRewriter2(); void testCopyModelRewriter2();
void testSubComponentManager(); void testSubComponentManager();
void testAnchorsAndRewriting();
void testAnchorsAndRewritingCenter();
// //
// regression tests // regression tests

View File

@@ -1652,6 +1652,17 @@ void testStuff()
++*p; ++*p;
} }
void testPassByReferenceHelper(Foo &f)
{
++f.a;
}
void testPassByReference()
{
Foo f(12);
testPassByReferenceHelper(f);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
testColor(); testColor();
@@ -1701,6 +1712,7 @@ int main(int argc, char *argv[])
testStdString(); testStdString();
testStdVector(); testStdVector();
testPassByReference();
testPlugin(); testPlugin();
testQList(); testQList();
testQLinkedList(); testQLinkedList();