forked from qt-creator/qt-creator
UI fixes to qml inspector
This commit is contained in:
@@ -28,15 +28,13 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
#include "objectpropertiesview.h"
|
#include "objectpropertiesview.h"
|
||||||
|
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#include <QtGui/qtreewidget.h>
|
#include <QtGui/QTreeWidget>
|
||||||
#include <QtGui/qlayout.h>
|
#include <QtGui/QLayout>
|
||||||
#include <QtGui/qheaderview.h>
|
#include <QtGui/QHeaderView>
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
class PropertiesViewItem : public QObject, public QTreeWidgetItem
|
class PropertiesViewItem : public QObject, public QTreeWidgetItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -78,6 +76,7 @@ ObjectPropertiesView::ObjectPropertiesView(QDeclarativeEngineDebug *client, QWid
|
|||||||
m_tree->setFrameStyle(QFrame::NoFrame);
|
m_tree->setFrameStyle(QFrame::NoFrame);
|
||||||
m_tree->setAlternatingRowColors(true);
|
m_tree->setAlternatingRowColors(true);
|
||||||
m_tree->setExpandsOnDoubleClick(false);
|
m_tree->setExpandsOnDoubleClick(false);
|
||||||
|
m_tree->setRootIsDecorated(false);
|
||||||
m_tree->setHeaderLabels(QStringList()
|
m_tree->setHeaderLabels(QStringList()
|
||||||
<< tr("Name") << tr("Value") << tr("Type"));
|
<< tr("Name") << tr("Value") << tr("Type"));
|
||||||
QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
|
QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
|
||||||
@@ -255,6 +254,4 @@ void ObjectPropertiesView::itemActivated(QTreeWidgetItem *i)
|
|||||||
emit activated(m_object, item->property);
|
emit activated(m_object, item->property);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
#include "objectpropertiesview.moc"
|
#include "objectpropertiesview.moc"
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
class QDeclarativeDebugConnection;
|
class QDeclarativeDebugConnection;
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class PropertiesViewItem;
|
class PropertiesViewItem;
|
||||||
|
|
||||||
class ObjectPropertiesView : public QWidget
|
class ObjectPropertiesView : public QWidget
|
||||||
@@ -76,6 +79,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ QVariant WatchTableModel::data(const QModelIndex &idx, int role) const
|
|||||||
return QVariant(m_entities.at(idx.row()).title);
|
return QVariant(m_entities.at(idx.row()).title);
|
||||||
} else if (idx.column() == C_VALUE) {
|
} else if (idx.column() == C_VALUE) {
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||||
return QVariant(m_entities.at(idx.row()).value);
|
return QVariant(m_entities.at(idx.row()).value);
|
||||||
|
|
||||||
} else if(role == Qt::BackgroundRole) {
|
} else if(role == Qt::BackgroundRole) {
|
||||||
@@ -164,6 +164,22 @@ QVariant WatchTableModel::data(const QModelIndex &idx, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WatchTableModel::setData ( const QModelIndex & index, const QVariant & value, int role)
|
||||||
|
{
|
||||||
|
if (role == Qt::EditRole) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags WatchTableModel::flags ( const QModelIndex & index ) const
|
||||||
|
{
|
||||||
|
if (index.column() == C_VALUE)
|
||||||
|
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
|
||||||
|
|
||||||
|
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
void WatchTableModel::watchStateChanged()
|
void WatchTableModel::watchStateChanged()
|
||||||
{
|
{
|
||||||
QDeclarativeDebugWatch *watch = qobject_cast<QDeclarativeDebugWatch*>(sender());
|
QDeclarativeDebugWatch *watch = qobject_cast<QDeclarativeDebugWatch*>(sender());
|
||||||
@@ -200,9 +216,8 @@ void WatchTableModel::togglePropertyWatch(const QDeclarativeDebugObjectReference
|
|||||||
delete watch;
|
delete watch;
|
||||||
watch = 0;
|
watch = 0;
|
||||||
} else {
|
} else {
|
||||||
QString desc = (object.name().isEmpty() ? QLatin1String("<unnamed object>") : object.name())
|
QString desc = (object.name().isEmpty() ? QLatin1String("<") + object.className() + QLatin1String(">") : object.name())
|
||||||
+ QLatin1String(".") + property.name()
|
+ QLatin1String(".") + property.name();
|
||||||
+ object.className();
|
|
||||||
|
|
||||||
addWatch(watch, desc);
|
addWatch(watch, desc);
|
||||||
emit watchCreated(watch);
|
emit watchCreated(watch);
|
||||||
@@ -278,6 +293,13 @@ WatchTableView::WatchTableView(WatchTableModel *model, QWidget *parent)
|
|||||||
{
|
{
|
||||||
setFrameStyle(QFrame::NoFrame);
|
setFrameStyle(QFrame::NoFrame);
|
||||||
setAlternatingRowColors(true);
|
setAlternatingRowColors(true);
|
||||||
|
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||||
|
setShowGrid(false);
|
||||||
|
setVerticalHeader(0);
|
||||||
|
setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
|
||||||
|
setFrameStyle(QFrame::NoFrame);
|
||||||
|
|
||||||
|
|
||||||
connect(model, SIGNAL(watchCreated(QDeclarativeDebugWatch*)), SLOT(watchCreated(QDeclarativeDebugWatch*)));
|
connect(model, SIGNAL(watchCreated(QDeclarativeDebugWatch*)), SLOT(watchCreated(QDeclarativeDebugWatch*)));
|
||||||
connect(this, SIGNAL(activated(QModelIndex)), SLOT(indexActivated(QModelIndex)));
|
connect(this, SIGNAL(activated(QModelIndex)), SLOT(indexActivated(QModelIndex)));
|
||||||
@@ -292,8 +314,9 @@ void WatchTableView::indexActivated(const QModelIndex &index)
|
|||||||
|
|
||||||
void WatchTableView::watchCreated(QDeclarativeDebugWatch *watch)
|
void WatchTableView::watchCreated(QDeclarativeDebugWatch *watch)
|
||||||
{
|
{
|
||||||
int column = m_model->rowForWatch(watch);
|
int row = m_model->rowForWatch(watch);
|
||||||
resizeColumnToContents(column);
|
resizeRowToContents(row);
|
||||||
|
resizeColumnToContents(C_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchTableView::mousePressEvent(QMouseEvent *me)
|
void WatchTableView::mousePressEvent(QMouseEvent *me)
|
||||||
|
|||||||
@@ -60,10 +60,12 @@ public:
|
|||||||
void removeWatchAt(int row);
|
void removeWatchAt(int row);
|
||||||
void removeAllWatches();
|
void removeAllWatches();
|
||||||
|
|
||||||
|
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void watchCreated(QDeclarativeDebugWatch *watch);
|
void watchCreated(QDeclarativeDebugWatch *watch);
|
||||||
|
|||||||
@@ -409,7 +409,9 @@ void QmlInspector::setSimpleDockWidgetArrangement()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainWindow->tabifyDockWidget(m_frameRateDock, m_propertyWatcherDock);
|
mainWindow->tabifyDockWidget(m_frameRateDock, m_propertyWatcherDock);
|
||||||
mainWindow->tabifyDockWidget(m_frameRateDock, m_inspectorOutputDock);
|
mainWindow->tabifyDockWidget(m_propertyWatcherDock, m_inspectorOutputDock);
|
||||||
|
|
||||||
|
m_inspectorOutputDock->setVisible(false);
|
||||||
|
|
||||||
mainWindow->setTrackingEnabled(true);
|
mainWindow->setTrackingEnabled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
@@ -162,9 +163,16 @@ void QmlInspectorPlugin::activateDebuggerForProject(ProjectExplorer::Project *pr
|
|||||||
void QmlInspectorPlugin::pollInspector()
|
void QmlInspectorPlugin::pollInspector()
|
||||||
{
|
{
|
||||||
++m_connectionAttempts;
|
++m_connectionAttempts;
|
||||||
if (m_inspector->connectToViewer() || m_connectionAttempts == MaxConnectionAttempts) {
|
if (m_inspector->connectToViewer()) {
|
||||||
m_connectionTimer->stop();
|
m_connectionTimer->stop();
|
||||||
m_connectionAttempts = 0;
|
m_connectionAttempts = 0;
|
||||||
|
} else if (m_connectionAttempts == MaxConnectionAttempts) {
|
||||||
|
m_connectionTimer->stop();
|
||||||
|
m_connectionAttempts = 0;
|
||||||
|
|
||||||
|
QMessageBox::critical(0,
|
||||||
|
tr("Failed to connect to debugger"),
|
||||||
|
tr("Could not connect to debugger server. Please check your settings from Projects pane.") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user