return;
}
+ if (typeCombo->currentIndex() == 0)
+ queryEdit->setText(query);
+
SearchParams *searchParams = new SearchParams();
searchParams->setKeywords(query);
#include "autocomplete.h"
#include "suggester.h"
+#ifdef APP_MAC
+#include "searchlineedit_mac.h"
+#else
+#include "searchlineedit.h"
+#endif
-AutoComplete::AutoComplete(QWidget *parent, QLineEdit *editor):
- QObject(parent), buddy(parent), editor(editor), suggester(0) {
+AutoComplete::AutoComplete(SearchLineEdit *parent, QLineEdit *editor):
+ QObject(parent), editor(editor), suggester(0) {
+ buddy = parent;
enabled = true;
popup = new QListWidget;
if (ev->type() == QEvent::MouseButtonPress) {
popup->hide();
buddy->setFocus();
- editor->setText(originalText);
+ buddy->setText(originalText);
return true;
}
buddy->setFocus();
QListWidgetItem *item = popup->currentItem();
if (item) {
- editor->setText(item->text());
+ buddy->setText(item->text());
emit suggestionAccepted(item->text());
}
}
if (current) {
// qDebug() << "current" << current->text();
current->setSelected(true);
- editor->setText(current->text());
+ buddy->setText(current->text());
editor->setSelection(originalText.length(), editor->text().length());
}
}
#include <QtGui>
class Suggester;
+class SearchLineEdit;
class AutoComplete : public QObject {
Q_OBJECT
public:
- AutoComplete(QWidget *parent, QLineEdit *editor);
+ AutoComplete(SearchLineEdit *parent, QLineEdit *editor);
~AutoComplete();
bool eventFilter(QObject *obj, QEvent *ev);
void showCompletion(const QStringList &choices);
void suggestionAccepted(const QString &suggestion);
private:
- QWidget *buddy;
+ SearchLineEdit *buddy;
QLineEdit *editor;
QString originalText;
QListWidget *popup;
void preventSuggest();
void selectAll() { lineEdit()->selectAll(); }
void setSuggester(Suggester *suggester) { completion->setSuggester(suggester); }
+ void setText(const QString &text) { lineEdit()->setText(text); }
protected:
void resizeEvent(QResizeEvent *event);