/* ToolbarSearch is a search widget that also contains a small history and uses open-search for searching. */ ToolbarSearch::ToolbarSearch(QWidget *parent) : SearchLineEdit(parent) , m_suggestionsEnabled(true) , m_autosaver(new AutoSaver(this)) , m_maxSavedSearches(10) , m_model(new QStandardItemModel(this)) , m_suggestionsItem(0) , m_recentSearchesItem(0) , m_suggestTimer(0) , m_completer(0) { connect(openSearchManager(), SIGNAL(currentEngineChanged()), this, SLOT(currentEngineChanged())); m_completer = new QCompleter(m_model, this); m_completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion); setCompleter(m_completer); searchButton()->setShowMenuTriangle(true); connect(searchButton(), SIGNAL(clicked()), this, SLOT(showEnginesMenu())); connect(this, SIGNAL(returnPressed()), this, SLOT(searchNow())); load(); currentEngineChanged(); }
void ToolbarSearch::triggeredMenuAction(QAction *action) { QVariant v = action->data(); if (v.canConvert<QString>()) { QString text = v.toString(); lineEdit()->setText(text); searchNow(); } }
/* ToolbarSearch is a very basic search widget that also contains a small history. Searches are turned into urls that use Google to perform search */ ToolbarSearch::ToolbarSearch(QWidget *parent) : SearchLineEdit(parent) , m_autosaver(new AutoSaver(this)) , m_maxSavedSearches(10) , m_stringListModel(new QStringListModel(this)) { QMenu *m = menu(); connect(m, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu())); connect(m, SIGNAL(triggered(QAction*)), this, SLOT(triggeredMenuAction(QAction*))); QCompleter *completer = new QCompleter(m_stringListModel, this); completer->setCompletionMode(QCompleter::InlineCompletion); lineEdit()->setCompleter(completer); connect(lineEdit(), SIGNAL(returnPressed()), SLOT(searchNow())); setInactiveText(tr("Google")); load(); }
/* ToolbarSearch is a very basic search widget that also contains a small history. Searches are turned into urls that use Google to perform search */ ToolbarSearch::ToolbarSearch(QWidget *parent) : SearchLineEdit(new QCompleter(parent), parent) , m_autosaver(new AutoSaver(this)) , m_maxSavedSearches(10) , m_model(new QStandardItemModel(this)) , m_suggestionsItem(0) , m_recentSearchesItem(0) { completer()->setModel(m_model); completer()->setCompletionMode(QCompleter::UnfilteredPopupCompletion); connect(completer(), SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); connect(completer(), SIGNAL(highlighted(const QModelIndex &)), this, SLOT(highlighted(const QModelIndex &))); connect(this, SIGNAL(returnPressed()), SLOT(searchNow())); setInactiveText(QLatin1String("Google")); load(); }
void ToolbarSearch::activated(const QModelIndex &index) { if (highlighted(index)) searchNow(); }