Commit 7af52ee8 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Fix git push dialog

parent 4de29e12
Pipeline #217522 passed with stage
in 5 minutes and 25 seconds
......@@ -23,6 +23,8 @@ PushPullDialog::PushPullDialog(KTextEditor::MainWindow *mainWindow, const QStrin
, m_repo(repoPath)
{
m_lineEdit.setFont(Utils::editorFont());
m_treeView.setFont(Utils::editorFont());
setFilteringEnabled(false);
loadLastExecutedCommands();
}
......@@ -45,22 +47,13 @@ void PushPullDialog::openDialog(PushPullDialog::Mode m)
lastExecCmds.push_front(lastCmd);
}
auto *model = new QStandardItemModel(this);
m_treeView.setModel(model);
auto monoFont = m_lineEdit.font();
for (const QString &cmd : std::as_const(lastExecCmds)) {
auto *item = new QStandardItem(cmd);
item->setFont(monoFont);
model->appendRow(item);
}
setStringList(lastExecCmds);
connect(m_treeView.selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex &current, const QModelIndex &) {
m_lineEdit.setText(current.data().toString());
});
m_treeView.setCurrentIndex(model->index(0, 0));
reselectFirst();
exec();
}
......
......@@ -149,12 +149,7 @@ HUDDialog::HUDDialog(QWidget *parent, QWidget *mainWindow)
hide();
});
// user can add this as necessary
connect(&m_lineEdit, &QLineEdit::textChanged, this, [this](const QString &txt) {
static_cast<FuzzyFilterModel *>(m_proxy.data())->setFilterString(txt);
m_delegate->setFilterString(txt);
m_treeView.viewport()->update();
m_treeView.setCurrentIndex(m_treeView.model()->index(0, 0));
});
setFilteringEnabled(true);
connect(&m_treeView, &QTreeView::clicked, this, &HUDDialog::slotReturnPressed);
m_treeView.setSortingEnabled(true);
......@@ -277,3 +272,23 @@ void HUDDialog::setModel(QAbstractItemModel *model, FilterType type, int filterK
proxy->setFilterType(type);
proxy->setScoreRole(scoreRole);
}
void HUDDialog::setFilteringEnabled(bool enabled)
{
if (!enabled) {
disconnect(&m_lineEdit, &QLineEdit::textChanged, this, nullptr);
m_treeView.setModel(m_model);
} else {
Q_ASSERT(m_proxy);
if (m_treeView.model() != m_proxy) {
Q_ASSERT(m_proxy->sourceModel());
m_treeView.setModel(m_proxy);
}
connect(&m_lineEdit, &QLineEdit::textChanged, this, [this](const QString &txt) {
static_cast<FuzzyFilterModel *>(m_proxy.data())->setFilterString(txt);
m_delegate->setFilterString(txt);
m_treeView.viewport()->update();
m_treeView.setCurrentIndex(m_treeView.model()->index(0, 0));
});
}
}
......@@ -60,6 +60,8 @@ public:
void setModel(QAbstractItemModel *, FilterType, int filterKeyCol = 0, int filterRole = Qt::DisplayRole, int scoreRole = -1);
void setFilteringEnabled(bool enabled);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
void updateViewGeometry();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment