|
|
|
|
@ -123,7 +123,32 @@ void LocationCompleterView::setOriginalText(const QString &originalText) |
|
|
|
|
void LocationCompleterView::adjustSize() |
|
|
|
|
{ |
|
|
|
|
const int maxItemsCount = 12; |
|
|
|
|
m_view->setFixedHeight(m_view->sizeHintForRow(0) * qMin(maxItemsCount, model()->rowCount()) + 2 * m_view->frameWidth()); |
|
|
|
|
const int newHeight = m_view->sizeHintForRow(0) * qMin(maxItemsCount, model()->rowCount()) + 2 * m_view->frameWidth(); |
|
|
|
|
|
|
|
|
|
if (!m_resizeTimer) { |
|
|
|
|
m_resizeTimer = new QTimer(this); |
|
|
|
|
m_resizeTimer->setInterval(200); |
|
|
|
|
connect(m_resizeTimer, &QTimer::timeout, this, [this]() { |
|
|
|
|
if (m_resizeHeight > 0) { |
|
|
|
|
m_view->setFixedHeight(m_resizeHeight); |
|
|
|
|
setFixedHeight(sizeHint().height()); |
|
|
|
|
} |
|
|
|
|
m_resizeHeight = -1; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (newHeight == m_view->height() || newHeight == m_resizeHeight) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (newHeight < m_view->height()) { |
|
|
|
|
m_resizeHeight = newHeight; |
|
|
|
|
m_resizeTimer->start(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m_resizeHeight = -1; |
|
|
|
|
m_view->setFixedHeight(newHeight); |
|
|
|
|
setFixedHeight(sizeHint().height()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|