forked from qt-creator/qt-creator
QmlJSInspector: Code cosmetics
This commit is contained in:
@@ -61,8 +61,9 @@ public:
|
|||||||
explicit CrumblePathButton(const QString &title, QWidget *parent = 0);
|
explicit CrumblePathButton(const QString &title, QWidget *parent = 0);
|
||||||
void setSegmentType(int type);
|
void setSegmentType(int type);
|
||||||
void select(bool s);
|
void select(bool s);
|
||||||
void setData(QVariant data);
|
void setData(const QVariant &data);
|
||||||
QVariant data() const;
|
QVariant data() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
void mouseMoveEvent(QMouseEvent *e);
|
void mouseMoveEvent(QMouseEvent *e);
|
||||||
@@ -148,7 +149,9 @@ void CrumblePathButton::paintEvent(QPaintEvent *)
|
|||||||
p.drawText(QRectF(m_textPos.x(), 4, geom.width(), geom.height()), textToDraw);
|
p.drawText(QRectF(m_textPos.x(), 4, geom.width(), geom.height()), textToDraw);
|
||||||
|
|
||||||
if (menu()) {
|
if (menu()) {
|
||||||
p.drawImage(geom.width() - m_triangleIcon.width() - 6, geom.center().y() - m_triangleIcon.height()/2, m_triangleIcon);
|
p.drawImage(geom.width() - m_triangleIcon.width() - 6,
|
||||||
|
geom.center().y() - m_triangleIcon.height() / 2,
|
||||||
|
m_triangleIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +206,7 @@ void CrumblePathButton::setSegmentType(int type)
|
|||||||
m_textPos.setX(useLeftPadding ? 18 : 4);
|
m_textPos.setX(useLeftPadding ? 18 : 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrumblePathButton::setData(QVariant data)
|
void CrumblePathButton::setData(const QVariant &data)
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
@@ -327,16 +330,16 @@ void CrumblePath::resizeButtons()
|
|||||||
int totalWidthLeft = width();
|
int totalWidthLeft = width();
|
||||||
|
|
||||||
if (d->m_buttons.length() >= 1) {
|
if (d->m_buttons.length() >= 1) {
|
||||||
QPoint nextElementPosition(0,0);
|
QPoint nextElementPosition(0, 0);
|
||||||
|
|
||||||
d->m_buttons[0]->raise();
|
d->m_buttons.first()->raise();
|
||||||
// rearrange all items so that the first item is on top (added last).
|
// rearrange all items so that the first item is on top (added last).
|
||||||
|
|
||||||
// compute relative sizes
|
// compute relative sizes
|
||||||
QList<int> sizes;
|
QList<int> sizes;
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
for (int i = 0; i < d->m_buttons.length() ; ++i) {
|
for (int i = 0; i < d->m_buttons.length() ; ++i) {
|
||||||
CrumblePathButton *button = d->m_buttons[i];
|
CrumblePathButton *button = d->m_buttons.at(i);
|
||||||
|
|
||||||
QFontMetrics fm(button->font());
|
QFontMetrics fm(button->font());
|
||||||
int originalSize = ArrowBorderSize + fm.width(button->text()) + ArrowBorderSize + 12;
|
int originalSize = ArrowBorderSize + fm.width(button->text()) + ArrowBorderSize + 12;
|
||||||
@@ -345,14 +348,13 @@ void CrumblePath::resizeButtons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < d->m_buttons.length() ; ++i) {
|
for (int i = 0; i < d->m_buttons.length() ; ++i) {
|
||||||
CrumblePathButton *button = d->m_buttons[i];
|
CrumblePathButton *button = d->m_buttons.at(i);
|
||||||
|
|
||||||
int candidateSize = (sizes[i] * totalWidthLeft) / totalSize;
|
int candidateSize = (sizes.at(i) * totalWidthLeft) / totalSize;
|
||||||
if (candidateSize < ArrowBorderSize)
|
if (candidateSize < ArrowBorderSize)
|
||||||
candidateSize = ArrowBorderSize;
|
candidateSize = ArrowBorderSize;
|
||||||
if (candidateSize > sizes[i] * 1.3)
|
if (candidateSize > sizes.at(i) * 1.3)
|
||||||
candidateSize = sizes[i] * 1.3;
|
candidateSize = sizes.at(i) * 1.3;
|
||||||
|
|
||||||
|
|
||||||
button->setMinimumWidth(candidateSize);
|
button->setMinimumWidth(candidateSize);
|
||||||
button->setMaximumWidth(candidateSize);
|
button->setMaximumWidth(candidateSize);
|
||||||
@@ -370,12 +372,10 @@ void CrumblePath::resizeButtons()
|
|||||||
void CrumblePath::mapClickToIndex()
|
void CrumblePath::mapClickToIndex()
|
||||||
{
|
{
|
||||||
QObject *element = sender();
|
QObject *element = sender();
|
||||||
if (QString("QAction") == element->metaObject()->className()) {
|
if (QString("QAction") == element->metaObject()->className())
|
||||||
emit elementClicked(static_cast<QAction *>(element)->data().toInt());
|
emit elementClicked(static_cast<QAction *>(element)->data().toInt());
|
||||||
} else
|
else if (QString("QPushButton") == element->metaObject()->className())
|
||||||
if (QString("QPushButton") == element->metaObject()->className()) {
|
emit elementClicked(static_cast<CrumblePathButton *>(element)->data().toInt());
|
||||||
emit elementClicked(static_cast<CrumblePathButton *>(element)->data().toInt());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void ContextCrumblePath::updateContextPath(const QStringList &path, const QList<
|
|||||||
if (m_isEmpty) {
|
if (m_isEmpty) {
|
||||||
pushElement(tr("[no context]"));
|
pushElement(tr("[no context]"));
|
||||||
} else {
|
} else {
|
||||||
for (int i=0; i<path.count(); i++)
|
for (int i = 0; i < path.count(); i++)
|
||||||
pushElement(path[i], QVariant(debugIds[i]));
|
pushElement(path[i], QVariant(debugIds[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,9 +63,8 @@ void ContextCrumblePath::updateContextPath(const QStringList &path, const QList<
|
|||||||
void ContextCrumblePath::addChildren(const QStringList &childrenNames, const QList<int> &childrenDebugIds)
|
void ContextCrumblePath::addChildren(const QStringList &childrenNames, const QList<int> &childrenDebugIds)
|
||||||
{
|
{
|
||||||
Q_ASSERT(childrenNames.count() == childrenDebugIds.count());
|
Q_ASSERT(childrenNames.count() == childrenDebugIds.count());
|
||||||
for (int i=0; i<childrenNames.count(); i++) {
|
for (int i = 0; i < childrenNames.count(); i++)
|
||||||
addChild(childrenNames[i],QVariant(childrenDebugIds[i]));
|
addChild(childrenNames[i], QVariant(childrenDebugIds[i]));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContextCrumblePath::isEmpty() const
|
bool ContextCrumblePath::isEmpty() const
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ inline QDeclarativeDebugObjectReference findParentRecursive( int goalDebugId,
|
|||||||
|
|
||||||
void InspectorUi::selectItems(const QList<QDeclarativeDebugObjectReference> &objectReferences)
|
void InspectorUi::selectItems(const QList<QDeclarativeDebugObjectReference> &objectReferences)
|
||||||
{
|
{
|
||||||
foreach (const QDeclarativeDebugObjectReference &objref, objectReferences)
|
foreach (const QDeclarativeDebugObjectReference &objref, objectReferences) {
|
||||||
if (objref.debugId() != -1) {
|
if (objref.debugId() != -1) {
|
||||||
// select only the first valid element of the list
|
// select only the first valid element of the list
|
||||||
|
|
||||||
@@ -548,6 +548,7 @@ void InspectorUi::selectItems(const QList<QDeclarativeDebugObjectReference> &obj
|
|||||||
gotoObjectReferenceDefinition(objref);
|
gotoObjectReferenceDefinition(objref);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QString displayName(const QDeclarativeDebugObjectReference &obj)
|
inline QString displayName(const QDeclarativeDebugObjectReference &obj)
|
||||||
|
|||||||
@@ -44,14 +44,8 @@ InspectorSettings::InspectorSettings(QObject *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectorSettings::~InspectorSettings()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InspectorSettings::restoreSettings(QSettings *settings)
|
void InspectorSettings::restoreSettings(QSettings *settings)
|
||||||
{
|
{
|
||||||
|
|
||||||
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
||||||
m_showLivePreviewWarning = settings->value(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), true).toBool();
|
m_showLivePreviewWarning = settings->value(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), true).toBool();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
@@ -64,7 +58,6 @@ void InspectorSettings::saveSettings(QSettings *settings) const
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InspectorSettings::showLivePreviewWarning() const
|
bool InspectorSettings::showLivePreviewWarning() const
|
||||||
{
|
{
|
||||||
return m_showLivePreviewWarning;
|
return m_showLivePreviewWarning;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class InspectorSettings : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
InspectorSettings(QObject *parent = 0);
|
InspectorSettings(QObject *parent = 0);
|
||||||
~InspectorSettings();
|
|
||||||
void restoreSettings(QSettings *settings);
|
void restoreSettings(QSettings *settings);
|
||||||
void saveSettings(QSettings *settings) const;
|
void saveSettings(QSettings *settings) const;
|
||||||
|
|
||||||
|
|||||||
@@ -118,12 +118,12 @@ class PropertyEditDelegate : public QItemDelegate
|
|||||||
QmlJSPropertyInspector::PropertyType propertyType = m_treeWidget->getTypeFor(index.row());
|
QmlJSPropertyInspector::PropertyType propertyType = m_treeWidget->getTypeFor(index.row());
|
||||||
const QChar quote(QLatin1Char('\"'));
|
const QChar quote(QLatin1Char('\"'));
|
||||||
|
|
||||||
if ( propertyType == QmlJSPropertyInspector::StringType ) {
|
if (propertyType == QmlJSPropertyInspector::StringType) {
|
||||||
const QChar backslash(QLatin1Char('\\'));
|
const QChar backslash(QLatin1Char('\\'));
|
||||||
propertyValue = propertyValue.replace(quote, QString(backslash) + quote);
|
propertyValue = propertyValue.replace(quote, QString(backslash) + quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( propertyType == QmlJSPropertyInspector::StringType || propertyType == QmlJSPropertyInspector::ColorType ) {
|
if (propertyType == QmlJSPropertyInspector::StringType || propertyType == QmlJSPropertyInspector::ColorType) {
|
||||||
propertyValue = quote + propertyValue + quote;
|
propertyValue = quote + propertyValue + quote;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,9 +149,10 @@ private:
|
|||||||
// expressionEdit
|
// expressionEdit
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
|
|
||||||
ExpressionEdit::ExpressionEdit(const QString & title, QDialog *parent):QDialog(parent),
|
ExpressionEdit::ExpressionEdit(const QString &title, QDialog *parent)
|
||||||
m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel)),
|
: QDialog(parent)
|
||||||
m_exprInput(new QLineEdit(this))
|
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel))
|
||||||
|
, m_exprInput(new QLineEdit(this))
|
||||||
{
|
{
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
|
||||||
@@ -166,7 +167,6 @@ ExpressionEdit::ExpressionEdit(const QString & title, QDialog *parent):QDialog(p
|
|||||||
connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExpressionEdit::expression() const
|
QString ExpressionEdit::expression() const
|
||||||
{
|
{
|
||||||
return m_exprInput->text();
|
return m_exprInput->text();
|
||||||
@@ -178,7 +178,8 @@ void ExpressionEdit::setItemData(int objectId, const QString &propertyName)
|
|||||||
m_paramName = propertyName;
|
m_paramName = propertyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpressionEdit::accept() {
|
void ExpressionEdit::accept()
|
||||||
|
{
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
emit dataChanged(m_debugId, m_paramName, expression());
|
emit dataChanged(m_debugId, m_paramName, expression());
|
||||||
}
|
}
|
||||||
@@ -187,7 +188,8 @@ void ExpressionEdit::accept() {
|
|||||||
// color chooser
|
// color chooser
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
|
|
||||||
ColorChooserDialog::ColorChooserDialog(const QString & title, QDialog *parent):QDialog(parent)
|
ColorChooserDialog::ColorChooserDialog(const QString &title, QDialog *parent)
|
||||||
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
|
||||||
@@ -285,7 +287,7 @@ void QmlJSPropertyInspector::setCurrentObjects(const QList<QDeclarativeDebugObje
|
|||||||
|
|
||||||
QVariant QmlJSPropertyInspector::getData(int row, int column, int role) const
|
QVariant QmlJSPropertyInspector::getData(int row, int column, int role) const
|
||||||
{
|
{
|
||||||
return m_filter->data(m_filter->index(row,column),role);
|
return m_filter->data(m_filter->index(row, column), role);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSPropertyInspector::PropertyType QmlJSPropertyInspector::getTypeFor(int row) const
|
QmlJSPropertyInspector::PropertyType QmlJSPropertyInspector::getTypeFor(int row) const
|
||||||
@@ -299,17 +301,17 @@ void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QString propertyNameS = QString(propertyName);
|
QString propertyNameS = QString(propertyName);
|
||||||
for (int ii=0; ii < m_model.rowCount(); ii++) {
|
for (int i = 0; i < m_model.rowCount(); i++) {
|
||||||
if (m_model.data(m_model.index(ii,0),Qt::DisplayRole).toString() == propertyNameS &&
|
if (m_model.data(m_model.index(i, 0), Qt::DisplayRole).toString() == propertyNameS &&
|
||||||
m_model.data(m_model.index(ii,0),Qt::UserRole).toInt() == debugId) {
|
m_model.data(m_model.index(i, 0), Qt::UserRole).toInt() == debugId) {
|
||||||
QVariant oldData = m_model.data(m_model.index(ii,1),Qt::DisplayRole);
|
QVariant oldData = m_model.data(m_model.index(i, 1), Qt::DisplayRole);
|
||||||
m_model.setData(m_model.index(ii,1),propertyValue.toString(), Qt::DisplayRole);
|
m_model.setData(m_model.index(i, 1), propertyValue.toString(), Qt::DisplayRole);
|
||||||
if (oldData != propertyValue) {
|
if (oldData != propertyValue) {
|
||||||
m_model.item(ii,0)->setForeground(QBrush(Qt::red));
|
m_model.item(i, 0)->setForeground(QBrush(Qt::red));
|
||||||
m_model.item(ii,1)->setForeground(QBrush(Qt::red));
|
m_model.item(i, 1)->setForeground(QBrush(Qt::red));
|
||||||
m_model.item(ii,2)->setForeground(QBrush(Qt::red));
|
m_model.item(i, 2)->setForeground(QBrush(Qt::red));
|
||||||
if ((QmlJSPropertyInspector::PropertyType)m_model.item(ii,2)->data(Qt::UserRole).toInt() == QmlJSPropertyInspector::ColorType)
|
if (getTypeFor(i) == QmlJSPropertyInspector::ColorType)
|
||||||
setColorIcon(ii);
|
setColorIcon(i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -377,39 +379,38 @@ void QmlJSPropertyInspector::addRow(const QString &name,const QString &value, co
|
|||||||
QStandardItem *typeColumn = new QStandardItem(type);
|
QStandardItem *typeColumn = new QStandardItem(type);
|
||||||
typeColumn->setToolTip(type);
|
typeColumn->setToolTip(type);
|
||||||
typeColumn->setEditable(false);
|
typeColumn->setEditable(false);
|
||||||
|
|
||||||
// encode type for easy lookup
|
// encode type for easy lookup
|
||||||
QVariant typeCode = QVariant(QmlJSPropertyInspector::OtherType);
|
QmlJSPropertyInspector::PropertyType typeCode = QmlJSPropertyInspector::OtherType;
|
||||||
if (type == "bool")
|
if (type == "bool")
|
||||||
typeCode = QVariant(QmlJSPropertyInspector::BooleanType);
|
typeCode = QmlJSPropertyInspector::BooleanType;
|
||||||
if (type == "qreal")
|
else if (type == "qreal")
|
||||||
typeCode = QVariant(QmlJSPropertyInspector::NumberType);
|
typeCode = QmlJSPropertyInspector::NumberType;
|
||||||
if (type == "QString")
|
else if (type == "QString")
|
||||||
typeCode = QVariant(QmlJSPropertyInspector::StringType);
|
typeCode = QmlJSPropertyInspector::StringType;
|
||||||
if (type == "QColor") {
|
else if (type == "QColor")
|
||||||
typeCode = QVariant(QmlJSPropertyInspector::ColorType);
|
typeCode = QmlJSPropertyInspector::ColorType;
|
||||||
}
|
|
||||||
|
|
||||||
typeColumn->setData(typeCode,Qt::UserRole);
|
typeColumn->setData(typeCode, Qt::UserRole);
|
||||||
|
|
||||||
QList <QStandardItem *> newRow;
|
QList<QStandardItem *> newRow;
|
||||||
newRow << nameColumn << valueColumn << typeColumn;
|
newRow << nameColumn << valueColumn << typeColumn;
|
||||||
m_model.appendRow(newRow);
|
m_model.appendRow(newRow);
|
||||||
|
|
||||||
if (type == "QColor") {
|
if (typeCode == QmlJSPropertyInspector::ColorType)
|
||||||
setColorIcon(m_model.indexFromItem(valueColumn).row());
|
setColorIcon(m_model.indexFromItem(valueColumn).row());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::setColorIcon(int row)
|
void QmlJSPropertyInspector::setColorIcon(int row)
|
||||||
{
|
{
|
||||||
QStandardItem *item = m_model.itemFromIndex(m_model.index(row,1));
|
QStandardItem *item = m_model.itemFromIndex(m_model.index(row, 1));
|
||||||
QColor color = QColor(item->data(Qt::DisplayRole).toString());
|
QColor color = QColor(item->data(Qt::DisplayRole).toString());
|
||||||
|
|
||||||
int recomendedLength = viewOptions().decorationSize.height() - 2;
|
int recomendedLength = viewOptions().decorationSize.height() - 2;
|
||||||
|
|
||||||
QPixmap colorpix(recomendedLength, recomendedLength);
|
QPixmap colorpix(recomendedLength, recomendedLength);
|
||||||
QPainter p(&colorpix);
|
QPainter p(&colorpix);
|
||||||
p.fillRect(1,1,recomendedLength-2,recomendedLength-2, color);
|
p.fillRect(1, 1, recomendedLength - 2, recomendedLength - 2, color);
|
||||||
p.setPen(Qt::black);
|
p.setPen(Qt::black);
|
||||||
p.drawRect(0, 0, recomendedLength - 1, recomendedLength - 1);
|
p.drawRect(0, 0, recomendedLength - 1, recomendedLength - 1);
|
||||||
item->setIcon(colorpix);
|
item->setIcon(colorpix);
|
||||||
@@ -422,7 +423,7 @@ void QmlJSPropertyInspector::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
bool isEditable = false;
|
bool isEditable = false;
|
||||||
bool isColor = false;
|
bool isColor = false;
|
||||||
if (itemIndex.isValid()) {
|
if (itemIndex.isValid()) {
|
||||||
isEditable = m_model.itemFromIndex(m_filter->mapToSource(m_filter->index(itemIndex.row(),1)))->isEditable();
|
isEditable = m_model.itemFromIndex(m_filter->mapToSource(m_filter->index(itemIndex.row(), 1)))->isEditable();
|
||||||
isColor = (getTypeFor(itemIndex.row()) == QmlJSPropertyInspector::ColorType);
|
isColor = (getTypeFor(itemIndex.row()) == QmlJSPropertyInspector::ColorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,36 +440,38 @@ void QmlJSPropertyInspector::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (action == &exprAction)
|
if (action == &exprAction)
|
||||||
openExpressionEditor( itemIndex );
|
openExpressionEditor(itemIndex);
|
||||||
if (action == &colorAction)
|
if (action == &colorAction)
|
||||||
openColorSelector( itemIndex );
|
openColorSelector(itemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::openExpressionEditor( QModelIndex &itemIndex )
|
void QmlJSPropertyInspector::openExpressionEditor(const QModelIndex &itemIndex)
|
||||||
{
|
{
|
||||||
QString propertyName = getData(itemIndex.row(),0,Qt::DisplayRole).toString();
|
QString propertyName = getData(itemIndex.row(), 0, Qt::DisplayRole).toString();
|
||||||
QString dialogText = tr("Javascript expression for ")+propertyName;
|
QString dialogText = tr("Javascript expression for ")+propertyName;
|
||||||
int objectId = getData(itemIndex.row(), 0, Qt::UserRole).toInt();
|
int objectId = getData(itemIndex.row(), 0, Qt::UserRole).toInt();
|
||||||
|
|
||||||
ExpressionEdit *expressionDialog = new ExpressionEdit(dialogText);
|
ExpressionEdit *expressionDialog = new ExpressionEdit(dialogText);
|
||||||
expressionDialog->setItemData(objectId, propertyName);
|
expressionDialog->setItemData(objectId, propertyName);
|
||||||
|
|
||||||
connect(expressionDialog,SIGNAL(dataChanged(int,QString,QString)), this, SLOT(propertyValueEdited(int,QString,QString)));
|
connect(expressionDialog, SIGNAL(dataChanged(int,QString,QString)),
|
||||||
|
this, SLOT(propertyValueEdited(int,QString,QString)));
|
||||||
|
|
||||||
expressionDialog->show();
|
expressionDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::openColorSelector( QModelIndex &itemIndex )
|
void QmlJSPropertyInspector::openColorSelector(const QModelIndex &itemIndex)
|
||||||
{
|
{
|
||||||
QString propertyName = getData(itemIndex.row(),0,Qt::DisplayRole).toString();
|
QString propertyName = getData(itemIndex.row(), 0, Qt::DisplayRole).toString();
|
||||||
QString dialogText = tr("Color selection for ")+propertyName;
|
QString dialogText = tr("Color selection for ") + propertyName;
|
||||||
int objectId = getData(itemIndex.row(), 0, Qt::UserRole).toInt();
|
int objectId = getData(itemIndex.row(), 0, Qt::UserRole).toInt();
|
||||||
QString propertyValue = getData(itemIndex.row(),1,Qt::DisplayRole).toString();
|
QString propertyValue = getData(itemIndex.row(), 1, Qt::DisplayRole).toString();
|
||||||
|
|
||||||
ColorChooserDialog *colorDialog = new ColorChooserDialog(dialogText);
|
ColorChooserDialog *colorDialog = new ColorChooserDialog(dialogText);
|
||||||
colorDialog->setItemData(objectId, propertyName, propertyValue);
|
colorDialog->setItemData(objectId, propertyName, propertyValue);
|
||||||
|
|
||||||
connect(colorDialog,SIGNAL(dataChanged(int,QString,QString)), this, SLOT(propertyValueEdited(int,QString,QString)));
|
connect(colorDialog, SIGNAL(dataChanged(int,QString,QString)),
|
||||||
|
this, SLOT(propertyValueEdited(int,QString,QString)));
|
||||||
|
|
||||||
colorDialog->show();
|
colorDialog->show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,8 +56,14 @@ class PropertiesFilter : public QSortFilterProxyModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PropertiesFilter(QObject *parent=0):QSortFilterProxyModel(parent) { setDynamicSortFilter(true); }
|
explicit PropertiesFilter(QObject *parent = 0)
|
||||||
|
: QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
|
setDynamicSortFilter(true);
|
||||||
|
}
|
||||||
|
|
||||||
~PropertiesFilter() { }
|
~PropertiesFilter() { }
|
||||||
|
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,10 +71,10 @@ class ExpressionEdit : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ExpressionEdit(const QString & title, QDialog *parent=0);
|
explicit ExpressionEdit(const QString &title, QDialog *parent = 0);
|
||||||
|
|
||||||
QString expression() const;
|
QString expression() const;
|
||||||
void setItemData(int objectId,const QString &propertyName);
|
void setItemData(int objectId, const QString &propertyName);
|
||||||
|
|
||||||
virtual void accept();
|
virtual void accept();
|
||||||
|
|
||||||
@@ -86,7 +92,7 @@ class ColorChooserDialog : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ColorChooserDialog(const QString & title, QDialog *parent=0);
|
explicit ColorChooserDialog(const QString &title, QDialog *parent = 0);
|
||||||
|
|
||||||
void setItemData(int objectId,const QString &propertyName, const QString &colorName);
|
void setItemData(int objectId,const QString &propertyName, const QString &colorName);
|
||||||
|
|
||||||
@@ -125,18 +131,18 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentObjects(const QList<QDeclarativeDebugObjectReference> &);
|
void setCurrentObjects(const QList<QDeclarativeDebugObjectReference> &);
|
||||||
void propertyValueEdited(const int objectId,const QString& propertyName, const QString& propertyValue);
|
void propertyValueEdited(const int objectId,const QString &propertyName, const QString &propertyValue);
|
||||||
void propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
void propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
||||||
void filterBy(const QString &expression);
|
void filterBy(const QString &expression);
|
||||||
|
|
||||||
void openExpressionEditor( QModelIndex &itemIndex );
|
void openExpressionEditor(const QModelIndex &itemIndex);
|
||||||
void openColorSelector( QModelIndex &itemIndex );
|
void openColorSelector(const QModelIndex &itemIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class PropertyEditDelegate;
|
friend class PropertyEditDelegate;
|
||||||
void buildPropertyTree(const QDeclarativeDebugObjectReference &);
|
void buildPropertyTree(const QDeclarativeDebugObjectReference &);
|
||||||
void addRow(const QString &name, const QString &value, const QString &type,
|
void addRow(const QString &name, const QString &value, const QString &type,
|
||||||
const int debugId=-1, bool editable=true);
|
const int debugId = -1, bool editable = true);
|
||||||
void setColorIcon(int row);
|
void setColorIcon(int row);
|
||||||
|
|
||||||
QVariant getData(int row, int column, int role) const;
|
QVariant getData(int row, int column, int role) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user