MCPcopy Create free account
hub / github.com/KDAB/GammaRay / SearchLineController

Method SearchLineController

ui/searchlinecontroller.cpp:45–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45SearchLineController::SearchLineController(QLineEdit *lineEdit, QAbstractItemModel *proxyModel, QTreeView *treeView)
46 : QObject(lineEdit)
47 , m_lineEdit(lineEdit)
48 , m_filterModel(findEffectiveFilterModel(proxyModel))
49 , m_targetTreeView(treeView)
50{
51 Q_ASSERT(lineEdit);
52 Q_ASSERT(m_filterModel);
53
54 if (!m_filterModel) {
55 QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
56 return;
57 }
58
59 m_filterModel->setProperty("filterKeyColumn", -1);
60 m_filterModel->setProperty("filterCaseSensitivity", Qt::CaseInsensitive);
61 activateSearch();
62
63 m_lineEdit->setClearButtonEnabled(true);
64 if (m_lineEdit->placeholderText().isEmpty())
65 m_lineEdit->setPlaceholderText(tr("Search"));
66
67 auto timer = new QTimer(this);
68 timer->setSingleShot(true);
69 timer->setInterval(300);
70 connect(lineEdit, &QLineEdit::textChanged, timer, [timer] { timer->start(); });
71 connect(timer, &QTimer::timeout, this, [this] {
72 activateSearch();
73 QTimer::singleShot(50, this, [this] {
74 onSearchFinished(m_lineEdit->text());
75 });
76 });
77}
78
79SearchLineController::~SearchLineController() = default;
80

Callers

nothing calls this directly

Calls 7

findEffectiveFilterModelFunction · 0.85
placeholderTextMethod · 0.80
setPlaceholderTextMethod · 0.80
textMethod · 0.80
setPropertyMethod · 0.45
isEmptyMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected