forked from qt-creator/qt-creator
fancylineedit: enforce conscious choice between history or special completer
Change-Id: Ia667895b619d0bb37561dce348adb7269df2fb9c Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "fancylineedit.h"
|
||||
#include "historycompleter.h"
|
||||
#include "qtcassert.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QDebug>
|
||||
@@ -97,7 +99,8 @@ enum { margin = 6 };
|
||||
namespace Utils {
|
||||
|
||||
// --------- FancyLineEditPrivate
|
||||
class FancyLineEditPrivate : public QObject {
|
||||
class FancyLineEditPrivate : public QObject
|
||||
{
|
||||
public:
|
||||
explicit FancyLineEditPrivate(FancyLineEdit *parent);
|
||||
|
||||
@@ -109,12 +112,14 @@ public:
|
||||
bool m_menuTabFocusTrigger[2];
|
||||
IconButton *m_iconbutton[2];
|
||||
bool m_iconEnabled[2];
|
||||
|
||||
HistoryCompleter *m_completer;
|
||||
QString m_historyKey;
|
||||
};
|
||||
|
||||
|
||||
FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
|
||||
QObject(parent),
|
||||
m_lineEdit(parent)
|
||||
QObject(parent), m_lineEdit(parent), m_completer(0)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
m_menu[i] = 0;
|
||||
@@ -298,6 +303,19 @@ bool FancyLineEdit::hasAutoHideButton(Side side) const
|
||||
return d->m_iconbutton[side]->hasAutoHide();
|
||||
}
|
||||
|
||||
void FancyLineEdit::setHistoryKey(const QString &historyKey)
|
||||
{
|
||||
QTC_ASSERT(!d->m_completer, return);
|
||||
d->m_historyKey = historyKey;
|
||||
d->m_completer = new HistoryCompleter(this, historyKey);
|
||||
}
|
||||
|
||||
void FancyLineEdit::setSpecialCompleter(QCompleter *completer)
|
||||
{
|
||||
QTC_ASSERT(!d->m_completer, return);
|
||||
QLineEdit::setCompleter(completer);
|
||||
}
|
||||
|
||||
void FancyLineEdit::setAutoHideButton(Side side, bool h)
|
||||
{
|
||||
d->m_iconbutton[side]->setAutoHide(h);
|
||||
|
||||
Reference in New Issue
Block a user