LeechCraft  0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
tagscompleter.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #include "tagscompleter.h"
10 #include <QtDebug>
11 #include <QStringList>
12 #include "tagslineedit.h"
13 
14 namespace LC::Util
15 {
16  QAbstractItemModel *TagsCompleter::CompletionModel_ = nullptr;
17 
19  : QCompleter (toComplete)
20  , Edit_ (toComplete)
21  {
22  setCompletionRole (Qt::DisplayRole);
23  setModel (CompletionModel_);
24  toComplete->SetCompleter (this);
25  }
26 
27  void TagsCompleter::OverrideModel (QAbstractItemModel *model)
28  {
29  setModel (model);
30  }
31 
32  QStringList TagsCompleter::splitPath (const QString& string) const
33  {
34  const auto& sep = Edit_->GetSeparator ().trimmed ();
35  auto result = string.split (sep, Qt::SkipEmptyParts);
36  for (auto& s : result)
37  s = s.trimmed ();
38  return result;
39  }
40 }
QString GetSeparator() const
Returns the separator for the tags.
auto && sep
Definition: ctstringutils.h:40
UTIL_TAGS_API void OverrideModel(QAbstractItemModel *model)
Replaces the model this completer works with.
A line edit class suitable for use with TagsCompleter.
Definition: tagslineedit.h:28
UTIL_TAGS_API TagsCompleter(TagsLineEdit *line)
Constructs the completer.
void SetCompleter(TagsCompleter *)
UTIL_TAGS_API QStringList splitPath(const QString &path) const override
Path splitter override.