stfl_query_widget_completer.hpp 804 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#ifndef CVVISUAL_STFL_QUERY_WIDGET_COMPLETER_HPP
#define CVVISUAL_STFL_QUERY_WIDGET_COMPLETER_HPP

#include <QStringList>
#include <QStringListModel>
#include <QString>
#include <QCompleter>

namespace cvv
{
namespace qtutil
{

/**
 * @brief A simple completer for the query widget.
 */
class STFLQueryWidgetCompleter : public QCompleter
{
	Q_OBJECT

      public:
	/**
	 * @brief Constructor of this class.
	 * @param parent widget
	 */
	STFLQueryWidgetCompleter(QObject *parent) : QCompleter(parent), model()
	{
		setModel(&model);
	}

	/**
	 * @brief Update the inherited model with the given suggestions.
	 * @param suggestions given suggestions
	 */
	void update(QStringList suggestions)
	{
		model.setStringList(suggestions);
		complete();
	}

      private:
	QStringListModel model;
};
}
}
#endif