forked from qt-creator/qt-creator
ProjectExplorer: Use FancyLineEdit in AddRunConfigDialog
With place holder text, fancy delete button, more UI space and less code. Change-Id: I16a80c215ac18fdc088c13087d58481311b9b838 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -29,15 +29,13 @@
|
|||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include <utils/itemviews.h>
|
#include <utils/itemviews.h>
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@@ -141,7 +139,9 @@ AddRunConfigDialog::AddRunConfigDialog(Target *target, QWidget *parent)
|
|||||||
const auto model = new CandidatesModel(target, this);
|
const auto model = new CandidatesModel(target, this);
|
||||||
const auto proxyModel = new ProxyModel(this);
|
const auto proxyModel = new ProxyModel(this);
|
||||||
proxyModel->setSourceModel(model);
|
proxyModel->setSourceModel(model);
|
||||||
const auto filterEdit = new QLineEdit(this);
|
const auto filterEdit = new FancyLineEdit(this);
|
||||||
|
filterEdit->setFiltering(true);
|
||||||
|
filterEdit->setPlaceholderText(tr("Filter candidates by name"));
|
||||||
m_view->setSelectionMode(TreeView::SingleSelection);
|
m_view->setSelectionMode(TreeView::SingleSelection);
|
||||||
m_view->setSelectionBehavior(TreeView::SelectRows);
|
m_view->setSelectionBehavior(TreeView::SelectRows);
|
||||||
m_view->setSortingEnabled(true);
|
m_view->setSortingEnabled(true);
|
||||||
@@ -152,7 +152,7 @@ AddRunConfigDialog::AddRunConfigDialog(Target *target, QWidget *parent)
|
|||||||
const auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
const auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create"));
|
buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create"));
|
||||||
|
|
||||||
connect(filterEdit, &QLineEdit::textChanged, this, [proxyModel](const QString &text) {
|
connect(filterEdit, &FancyLineEdit::textChanged, this, [proxyModel](const QString &text) {
|
||||||
proxyModel->setFilterRegularExpression(QRegularExpression(text, QRegularExpression::CaseInsensitiveOption));
|
proxyModel->setFilterRegularExpression(QRegularExpression(text, QRegularExpression::CaseInsensitiveOption));
|
||||||
});
|
});
|
||||||
connect(m_view, &TreeView::doubleClicked, this, [this] { accept(); });
|
connect(m_view, &TreeView::doubleClicked, this, [this] { accept(); });
|
||||||
@@ -166,10 +166,7 @@ AddRunConfigDialog::AddRunConfigDialog(Target *target, QWidget *parent)
|
|||||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
const auto layout = new QVBoxLayout(this);
|
const auto layout = new QVBoxLayout(this);
|
||||||
const auto filterLayout = new QHBoxLayout;
|
layout->addWidget(filterEdit);
|
||||||
filterLayout->addWidget(new QLabel(tr("Filter candidates by name:"), this));
|
|
||||||
filterLayout->addWidget(filterEdit);
|
|
||||||
layout->addLayout(filterLayout);
|
|
||||||
layout->addWidget(m_view);
|
layout->addWidget(m_view);
|
||||||
layout->addWidget(buttonBox);
|
layout->addWidget(buttonBox);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user