forked from qt-creator/qt-creator
QmlJSInspector: Use FindToolBar instead of Filter
QtCreator uses the Find Tool Bar uniformly to search for strings. Change-Id: I399661597120be3402432b0c99489174f7bf2d62 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
committed by
Kai Koehne
parent
f14dffe681
commit
05aa2eb204
@@ -86,6 +86,9 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <aggregation/aggregate.h>
|
||||||
|
#include <find/treeviewfind.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -149,7 +152,6 @@ InspectorUi::InspectorUi(QObject *parent)
|
|||||||
, m_listeningToEditorManager(false)
|
, m_listeningToEditorManager(false)
|
||||||
, m_toolBar(0)
|
, m_toolBar(0)
|
||||||
, m_crumblePath(0)
|
, m_crumblePath(0)
|
||||||
, m_filterExp(0)
|
|
||||||
, m_propertyInspector(0)
|
, m_propertyInspector(0)
|
||||||
, m_settings(new InspectorSettings(this))
|
, m_settings(new InspectorSettings(this))
|
||||||
, m_clientProxy(0)
|
, m_clientProxy(0)
|
||||||
@@ -655,7 +657,6 @@ void InspectorUi::enable()
|
|||||||
m_toolBar->enable();
|
m_toolBar->enable();
|
||||||
m_crumblePath->setEnabled(true);
|
m_crumblePath->setEnabled(true);
|
||||||
m_propertyInspector->setEnabled(true);
|
m_propertyInspector->setEnabled(true);
|
||||||
m_filterExp->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::disable()
|
void InspectorUi::disable()
|
||||||
@@ -663,7 +664,6 @@ void InspectorUi::disable()
|
|||||||
m_toolBar->disable();
|
m_toolBar->disable();
|
||||||
m_crumblePath->setEnabled(false);
|
m_crumblePath->setEnabled(false);
|
||||||
m_propertyInspector->setEnabled(false);
|
m_propertyInspector->setEnabled(false);
|
||||||
m_filterExp->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &fileName, int cursorPosition) const
|
QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &fileName, int cursorPosition) const
|
||||||
@@ -742,15 +742,10 @@ void InspectorUi::setupDockWidgets()
|
|||||||
QWidget *pathAndFilterWidget = new StyledBackground;
|
QWidget *pathAndFilterWidget = new StyledBackground;
|
||||||
pathAndFilterWidget->setMaximumHeight(m_crumblePath->height());
|
pathAndFilterWidget->setMaximumHeight(m_crumblePath->height());
|
||||||
|
|
||||||
m_filterExp = new Utils::FilterLineEdit;
|
|
||||||
m_filterExp->setPlaceholderText(tr("Filter properties"));
|
|
||||||
m_filterExp->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
|
||||||
|
|
||||||
QHBoxLayout *pathAndFilterLayout = new QHBoxLayout(pathAndFilterWidget);
|
QHBoxLayout *pathAndFilterLayout = new QHBoxLayout(pathAndFilterWidget);
|
||||||
pathAndFilterLayout->setMargin(0);
|
pathAndFilterLayout->setMargin(0);
|
||||||
pathAndFilterLayout->setSpacing(0);
|
pathAndFilterLayout->setSpacing(0);
|
||||||
pathAndFilterLayout->addWidget(m_crumblePath);
|
pathAndFilterLayout->addWidget(m_crumblePath);
|
||||||
pathAndFilterLayout->addWidget(m_filterExp);
|
|
||||||
|
|
||||||
QVBoxLayout *wlay = new QVBoxLayout(inspectorWidget);
|
QVBoxLayout *wlay = new QVBoxLayout(inspectorWidget);
|
||||||
wlay->setMargin(0);
|
wlay->setMargin(0);
|
||||||
@@ -758,10 +753,15 @@ void InspectorUi::setupDockWidgets()
|
|||||||
inspectorWidget->setLayout(wlay);
|
inspectorWidget->setLayout(wlay);
|
||||||
wlay->addWidget(pathAndFilterWidget);
|
wlay->addWidget(pathAndFilterWidget);
|
||||||
wlay->addWidget(m_propertyInspector);
|
wlay->addWidget(m_propertyInspector);
|
||||||
|
wlay->addWidget(new Core::FindToolBarPlaceHolder(inspectorWidget));
|
||||||
|
|
||||||
QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, inspectorWidget);
|
QDockWidget *dock = mw->createDockWidget(Debugger::QmlLanguage, inspectorWidget);
|
||||||
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
dock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
||||||
dock->setTitleBarWidget(new QWidget(dock));
|
dock->setTitleBarWidget(new QWidget(dock));
|
||||||
|
|
||||||
|
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
|
||||||
|
aggregate->add(m_propertyInspector);
|
||||||
|
aggregate->add(new Find::TreeViewFind(m_propertyInspector));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::crumblePathElementClicked(const QVariant &data)
|
void InspectorUi::crumblePathElementClicked(const QVariant &data)
|
||||||
@@ -893,9 +893,6 @@ void InspectorUi::connectSignals()
|
|||||||
m_clientProxy, SLOT(changeToSelectTool()));
|
m_clientProxy, SLOT(changeToSelectTool()));
|
||||||
connect(m_toolBar, SIGNAL(showAppOnTopSelected(bool)),
|
connect(m_toolBar, SIGNAL(showAppOnTopSelected(bool)),
|
||||||
m_clientProxy, SLOT(showAppOnTop(bool)));
|
m_clientProxy, SLOT(showAppOnTop(bool)));
|
||||||
|
|
||||||
connect(m_filterExp, SIGNAL(textChanged(QString)),
|
|
||||||
m_propertyInspector, SLOT(filterBy(QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectorUi::disconnectSignals()
|
void InspectorUi::disconnectSignals()
|
||||||
|
@@ -44,8 +44,6 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class Project;
|
class Project;
|
||||||
class Environment;
|
class Environment;
|
||||||
@@ -155,7 +153,6 @@ private:
|
|||||||
bool m_listeningToEditorManager;
|
bool m_listeningToEditorManager;
|
||||||
QmlJsInspectorToolBar *m_toolBar;
|
QmlJsInspectorToolBar *m_toolBar;
|
||||||
ContextCrumblePath *m_crumblePath;
|
ContextCrumblePath *m_crumblePath;
|
||||||
QLineEdit *m_filterExp;
|
|
||||||
QmlJSPropertyInspector *m_propertyInspector;
|
QmlJSPropertyInspector *m_propertyInspector;
|
||||||
|
|
||||||
InspectorSettings *m_settings;
|
InspectorSettings *m_settings;
|
||||||
|
@@ -239,20 +239,6 @@ void ColorChooserDialog::acceptColor(const QColor &color)
|
|||||||
emit dataChanged(m_debugId, m_paramName, QChar('\"')+color.name()+QChar('\"'));
|
emit dataChanged(m_debugId, m_paramName, QChar('\"')+color.name()+QChar('\"'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************************************
|
|
||||||
// FILTER
|
|
||||||
// *************************************************************************
|
|
||||||
bool PropertiesFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
|
||||||
{
|
|
||||||
QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
|
|
||||||
QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);
|
|
||||||
QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent);
|
|
||||||
|
|
||||||
return (sourceModel()->data(index0).toString().contains(filterRegExp())
|
|
||||||
|| sourceModel()->data(index1).toString().contains(filterRegExp())
|
|
||||||
|| sourceModel()->data(index2).toString().contains(filterRegExp()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
// QmlJSObjectTree
|
// QmlJSObjectTree
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
@@ -278,15 +264,7 @@ QmlJSPropertyInspector::QmlJSPropertyInspector(QWidget *parent)
|
|||||||
|
|
||||||
setItemDelegateForColumn(1, new PropertyEditDelegate(this));
|
setItemDelegateForColumn(1, new PropertyEditDelegate(this));
|
||||||
|
|
||||||
m_filter = new PropertiesFilter(this);
|
setModel(&m_model);
|
||||||
m_filter->setSourceModel(&m_model);
|
|
||||||
setModel(m_filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlJSPropertyInspector::filterBy(const QString &expression)
|
|
||||||
{
|
|
||||||
m_filter->setFilterWildcard(expression);
|
|
||||||
m_filter->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::clear()
|
void QmlJSPropertyInspector::clear()
|
||||||
@@ -310,12 +288,12 @@ void QmlJSPropertyInspector::setCurrentObjects(const QList<QmlDebugObjectReferen
|
|||||||
|
|
||||||
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_model.data(m_model.index(row, column), role);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSPropertyInspector::PropertyType QmlJSPropertyInspector::getTypeFor(int row) const
|
QmlJSPropertyInspector::PropertyType QmlJSPropertyInspector::getTypeFor(int row) const
|
||||||
{
|
{
|
||||||
return static_cast<QmlJSPropertyInspector::PropertyType>(m_filter->data(m_filter->index(row,2),Qt::UserRole).toInt());
|
return static_cast<QmlJSPropertyInspector::PropertyType>(m_model.data(m_model.index(row,2), Qt::UserRole).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue)
|
void QmlJSPropertyInspector::propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue)
|
||||||
@@ -435,7 +413,7 @@ void QmlJSPropertyInspector::addRow(const QString &name,const QString &value, co
|
|||||||
|
|
||||||
void QmlJSPropertyInspector::setColorIcon(int row)
|
void QmlJSPropertyInspector::setColorIcon(int row)
|
||||||
{
|
{
|
||||||
QStandardItem *item = m_model.itemFromIndex(m_model.index(row, 1));
|
QStandardItem *item = m_model.item(row, 1);
|
||||||
QColor color = colorFromExtendedName(item->data(Qt::DisplayRole).toString());
|
QColor color = colorFromExtendedName(item->data(Qt::DisplayRole).toString());
|
||||||
|
|
||||||
int recomendedLength = viewOptions().decorationSize.height() - 2;
|
int recomendedLength = viewOptions().decorationSize.height() - 2;
|
||||||
@@ -457,7 +435,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.item(itemIndex.row(), 1)->isEditable();
|
||||||
isColor = (getTypeFor(itemIndex.row()) == QmlJSPropertyInspector::ColorType);
|
isColor = (getTypeFor(itemIndex.row()) == QmlJSPropertyInspector::ColorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,6 @@
|
|||||||
#include <qmljsprivateapi.h>
|
#include <qmljsprivateapi.h>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
@@ -51,21 +50,6 @@ namespace Internal {
|
|||||||
|
|
||||||
class PropertyEditDelegate;
|
class PropertyEditDelegate;
|
||||||
|
|
||||||
class PropertiesFilter : public QSortFilterProxyModel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit PropertiesFilter(QObject *parent = 0)
|
|
||||||
: QSortFilterProxyModel(parent)
|
|
||||||
{
|
|
||||||
setDynamicSortFilter(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
~PropertiesFilter() { }
|
|
||||||
|
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ExpressionEdit : public QDialog
|
class ExpressionEdit : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -132,7 +116,6 @@ public slots:
|
|||||||
void setCurrentObjects(const QList<QmlDebugObjectReference> &);
|
void setCurrentObjects(const QList<QmlDebugObjectReference> &);
|
||||||
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 openExpressionEditor(const QModelIndex &itemIndex);
|
void openExpressionEditor(const QModelIndex &itemIndex);
|
||||||
void openColorSelector(const QModelIndex &itemIndex);
|
void openColorSelector(const QModelIndex &itemIndex);
|
||||||
@@ -150,7 +133,6 @@ private:
|
|||||||
void contextMenuEvent(QContextMenuEvent *ev);
|
void contextMenuEvent(QContextMenuEvent *ev);
|
||||||
|
|
||||||
QStandardItemModel m_model;
|
QStandardItemModel m_model;
|
||||||
PropertiesFilter *m_filter;
|
|
||||||
QList<int> m_currentObjects;
|
QList<int> m_currentObjects;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user