mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make Up/Down arrows work with tags
When using Up/Down arrows to scroll the tag list it always selected the first item in the list and doesn't scroll. Fixes #468 Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f2238300ef
commit
fdf6f3cd4e
2 changed files with 16 additions and 1 deletions
|
@ -35,7 +35,7 @@ void TagWidget::setCompleter(QCompleter *completer)
|
||||||
m_completer = completer;
|
m_completer = completer;
|
||||||
m_completer->setWidget(this);
|
m_completer->setWidget(this);
|
||||||
connect(m_completer, SIGNAL(activated(QString)), this, SLOT(completionSelected(QString)));
|
connect(m_completer, SIGNAL(activated(QString)), this, SLOT(completionSelected(QString)));
|
||||||
connect(m_completer, SIGNAL(highlighted(QString)), this, SLOT(completionSelected(QString)));
|
connect(m_completer, SIGNAL(highlighted(QString)), this, SLOT(completionHighlighted(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<int, int> TagWidget::getCursorTagPosition()
|
QPair<int, int> TagWidget::getCursorTagPosition()
|
||||||
|
@ -152,6 +152,20 @@ void TagWidget::completionSelected(QString completion)
|
||||||
emit(textChanged());
|
emit(textChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TagWidget::completionHighlighted(QString completion)
|
||||||
|
{
|
||||||
|
QPair<int, int> pos;
|
||||||
|
pos = getCursorTagPosition();
|
||||||
|
if (pos.first >= 0 && pos.second > 0) {
|
||||||
|
setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion));
|
||||||
|
setCursorPosition(pos.first + completion.length());
|
||||||
|
} else {
|
||||||
|
setText(completion.append(", "));
|
||||||
|
setCursorPosition(text().length());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TagWidget::setCursorPosition(int position)
|
void TagWidget::setCursorPosition(int position)
|
||||||
{
|
{
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
|
|
|
@ -20,6 +20,7 @@ public
|
||||||
slots:
|
slots:
|
||||||
void reparse();
|
void reparse();
|
||||||
void completionSelected(QString);
|
void completionSelected(QString);
|
||||||
|
void completionHighlighted(QString);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *e);
|
void keyPressEvent(QKeyEvent *e);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue