Ref T180, functions to access existing values in shared stringlist completer

This commit is contained in:
Klaus Basan
2017-11-05 04:53:43 +01:00
parent 62b859347b
commit 2d9bcc3e06
2 changed files with 26 additions and 3 deletions

View File

@@ -8,14 +8,13 @@
*/
#include "sharedstringlistcompleter.h"
#include <QStringListModel>
#include <QDateTime>
namespace BlackGui
{
bool CSharedStringListCompleter::updateData(const QStringList &data, int cacheTimeMs)
{
QStringListModel *model = qobject_cast<QStringListModel *>(m_completer->model());
QStringListModel *model = this->getCompleterModel();
Q_ASSERT_X(model, Q_FUNC_INFO, "Model missing");
bool updated = false;
const qint64 now = QDateTime::currentMSecsSinceEpoch();
@@ -40,6 +39,23 @@ namespace BlackGui
return (QDateTime::currentMSecsSinceEpoch() - m_lastUpdated) <= checkTimeMs;
}
bool CSharedStringListCompleter::contains(const QString &value, Qt::CaseSensitivity cs) const
{
return this->stringList().contains(value, cs);
}
QStringList CSharedStringListCompleter::stringList() const
{
const QStringListModel *model = this->getCompleterModel();
if (!model) { return QStringList(); }
return model->stringList();
}
QStringListModel *CSharedStringListCompleter::getCompleterModel() const
{
return qobject_cast<QStringListModel *>(m_completer->model());
}
void CompleterUtils::setCompleterParameters(QCompleter *completer)
{
Q_ASSERT_X(completer, Q_FUNC_INFO, "Need completer");