Beispiel #1
0
void ToolbarSearch::focusInEvent(QFocusEvent *event)
{
    SearchLineEdit::focusInEvent(event);
    // Every time we get a focus in event QLineEdit re-connects...
    disconnect(completer(), SIGNAL(activated(QString)),
               this, SLOT(setText(QString)));
    disconnect(completer(), SIGNAL(highlighted(QString)),
               this, SLOT(_q_completionHighlighted(QString)));
}
Beispiel #2
0
MultiValuesLineEdit::MultiValuesLineEdit(QWidget *parent):
    QLineEdit(parent),
    mMultiState(MultiValuesEmpty),
    mCompleterModel(new QStringListModel(this))
{
    setCompleter(new QCompleter(this));
    completer()->setModel(mCompleterModel);
    completer()->setCaseSensitivity(Qt::CaseInsensitive);
    completer()->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
}
Beispiel #3
0
DomModel* TextEdit::dommodel() {
    if (completer() == NULL) {
        SafetYAWL::streamlog
                << SafetLog::Debug
                << tr("Objeto completer es NULO (NULL");
        return NULL;
    }

        DomModel* mymodel = qobject_cast<DomModel*>(completer()->model());
        return mymodel;
}
bool FancyLineEdit::event(QEvent *e) {
    // workaround for QTCREATORBUG-9453
    if (e->type() == QEvent::ShortcutOverride && completer()
            && completer()->popup() && completer()->popup()->isVisible()) {
        QKeyEvent *ke = static_cast<QKeyEvent *>(e);
        if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
            ke->accept();
            return true;
        }
    }
    return QLineEdit::event(e);
}
void CompletingTextEdit::setCompleter(QCompleter *c)
{
    if (completer())
        disconnect(completer(), 0, this, 0);

    d->m_completer = c;

    if (!c)
        return;

    completer()->setWidget(this);
    completer()->setCompletionMode(QCompleter::PopupCompletion);
    connect(completer(), SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString)));
}
Beispiel #6
0
void MgCommandLine::keyPressEvent(QKeyEvent * e)
{
	if(e->key() == Qt::Key_Escape )
		clear();
	else if((e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) && m_scriptEngine && m_completer->popup()->isVisible())
	{
		insertText(m_completer->popup()->currentIndex().data().toString());
		m_completer->popup()->hide();
	}
	else if((e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) && m_scriptEngine)
	{
		m_scriptEngine->execCommand(text());
		clear();
	}
	else if(e->key() == Qt::Key_Space && e->modifiers().testFlag(Qt::ControlModifier))
	{
		if(!m_completer->popup()->isVisible())
		{
			MgCommandCompleter completer(m_scriptEngine);
			MgCommandCompleter::CompletionResult result = completer.completionOf(text(),cursorPosition());

			m_completer->setCompletionPrefix("");
			m_prefix = result.prefix;
			m_completionModel->setStringList(result.completion);
			m_completer->complete();
		}
		else
		{
			m_completer->popup()->hide();
		}

	}
	else
		QLineEdit::keyPressEvent(e);
}
Beispiel #7
0
    void CodeLineEdit::insertVariable(const QString &variable)
    {
        //If a validator is set this means that the insertion will fail
        //In this case, reset the content and set the code mode
        if(validator())
        {
            if(!text().isEmpty() && QMessageBox::question(this, tr("Insert variable/resource"), tr("Inserting a variable or a resource will replace the current parameter value.\nAre you sure?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes)
                return;

            setCode(true);
            setText(QString());
        }

        //Temporarily remove the completer so that we don't get a popup
        QCompleter *currentCompleter = completer();
        if(currentCompleter)
        {
            currentCompleter->setParent(0);
            setCompleter(0);
        }

        if(isCode())
            insert(variable);
        else
            insert("$" + variable);

        if(currentCompleter)
        {
            currentCompleter->setParent(this);
            setCompleter(currentCompleter);
        }
    }
Beispiel #8
0
void SearchTextBar::doSaveState()
{
    KConfigGroup group = getConfigGroup();

    if (completer()->completionMode() != QCompleter::PopupCompletion)
    {
        group.writeEntry(entryName(d->optionAutoCompletionModeEntry), (int)completer()->completionMode());
    }
    else
    {
        group.deleteEntry(entryName(d->optionAutoCompletionModeEntry));
    }

    group.writeEntry(entryName(d->optionCaseSensitiveEntry), (int)d->settings.caseSensitive);
    group.sync();
}
Beispiel #9
0
int main() {
    TestBuddy buddy;
    SKKCompleter completer(&buddy);
    SKKDictionaryKeyContainer dicts;

    SKKBackEnd& backend = SKKBackEnd::theInstance();

    backend.Initialize("skk-jisyo.utf8", dicts);

    buddy.SetQuery("ほかん");

    assert(completer.Execute() && buddy.Entry() == "ほかん1");

    completer.Next();
    completer.Next();

    assert(buddy.Entry() == "ほかん3");

    backend.Register(SKKEntry("とぐるほかん"), SKKCandidate());

    buddy.SetQuery("とぐる");
    assert(completer.Execute() && buddy.Entry() == "とぐるほかん");

    backend.Remove(SKKEntry("とぐるほかん"), SKKCandidate());
    assert(!completer.Execute());
}
Beispiel #10
0
void FormCompleterTest::completeWithData(const QString &html, const QByteArray &data)
{
    view->setHtml(html);

    PageFormCompleter completer(view->page());
    completer.completePage(data);
}
Beispiel #11
0
void SearchTextBar::doLoadState()
{
    KConfigGroup group        = getConfigGroup();
    completer()->setCompletionMode((QCompleter::CompletionMode)group.readEntry(entryName(d->optionAutoCompletionModeEntry), (int)QCompleter::PopupCompletion));
    d->settings.caseSensitive = (Qt::CaseSensitivity)group.readEntry(entryName(d->optionCaseSensitiveEntry), (int)Qt::CaseInsensitive);
    setIgnoreCase(d->settings.caseSensitive == Qt::CaseInsensitive);
}
AutocompletingComboBox::AutocompletingComboBox(QWidget* parent) : QComboBox(parent) {
	setEditable(true);
	setInsertPolicy(QComboBox::NoInsert);
	completer()->setCompletionMode(QCompleter::PopupCompletion);

	connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(resetColor()));
}
Beispiel #13
0
PageFormData FormCompleterTest::extractFormData(const QString &html, const QByteArray &data)
{
    view->setHtml(html);

    PageFormCompleter completer(view->page());
    return completer.extractFormData(data);
}
Beispiel #14
0
bool LineEdit::eventFilter(QObject *o, QEvent *e)
{
    if (e->type() == QEvent::Hide && o == completer()->popup()) {
        // next event cycle, the popup is deleted by the change and "return true" does not help
        // connect queued to not manipulate the history *during* selection from popup, but *after*
        CALL_LATER_NOARG(this, restoreInlineCompletion);
    }
    return false;
}
CaptureFilterCombo::CaptureFilterCombo(QWidget *parent) :
    QComboBox(parent),
    cf_edit_(NULL)
{
    cf_edit_ = new CaptureFilterEdit();

    setEditable(true);
    setLineEdit(cf_edit_);
    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    setInsertPolicy(QComboBox::NoInsert);
    setAccessibleName(tr("Capture filter selector"));
    setStyleSheet(
            "QComboBox {"
#ifdef Q_OS_MAC
            "  border: 1px solid gray;"
#else
            "  border: 1px solid palette(shadow);"
#endif
            "  border-radius: 3px;"
            "  padding: 0px 0px 0px 0px;"
            "  margin-left: 0px;"
            "  min-width: 20em;"
            " }"

            "QComboBox::drop-down {"
            "  subcontrol-origin: padding;"
            "  subcontrol-position: top right;"
            "  width: 16px;"
            "  border-left-width: 0px;"
            " }"

            "QComboBox::down-arrow {"
            "  image: url(:/dfilter/dfilter_dropdown.png);"
            " }"

            "QComboBox::down-arrow:on { /* shift the arrow when popup is open */"
            "  top: 1px;"
            "  left: 1px;"
            "}"
            );
    completer()->setCompletionMode(QCompleter::PopupCompletion);

    connect(this, SIGNAL(interfacesChanged()), cf_edit_, SLOT(checkFilter()));
    connect(cf_edit_, SIGNAL(pushFilterSyntaxStatus(QString&)),
            this, SIGNAL(pushFilterSyntaxStatus(QString&)));
    connect(cf_edit_, SIGNAL(popFilterSyntaxStatus()),
            this, SIGNAL(popFilterSyntaxStatus()));
    connect(cf_edit_, SIGNAL(captureFilterSyntaxChanged(bool)),
            this, SIGNAL(captureFilterSyntaxChanged(bool)));
    connect(cf_edit_, SIGNAL(startCapture()), this, SIGNAL(startCapture()));
    connect(cf_edit_, SIGNAL(startCapture()), this, SLOT(rebuildFilterList()));
    connect(wsApp, SIGNAL(appInitialized()), this, SLOT(rebuildFilterList()));
    connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(rebuildFilterList()));

    rebuildFilterList(false);
    clearEditText();
}
Beispiel #16
0
void LocationBar::showDomainCompletion(const QString &completion)
{
    m_domainCompleterModel->setStringList(QStringList() << completion);

    // We need to manually force the completion because model is updated asynchronously
    // But only force completion when the user actually added new text
    if (m_oldTextLength < m_currentTextLength)
        completer()->complete();
}
void ComboBox::setupLineEdit() {
  setInsertPolicy(QComboBox::NoInsert);

  setLineEdit(new QLineEdit(this));

  QCompleter *currentCompleter = completer();
  currentCompleter->setCompletionMode(QCompleter::PopupCompletion);
  currentCompleter->setCaseSensitivity(Qt::CaseSensitive);
}
void AutocompletingComboBox::resetColor(void) {
	QAbstractItemModel* m = completer()->model();
	if (QPalette::Base, (m->match(m->index(0, 0), Qt::DisplayRole, currentText(), 1, Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap) ).isEmpty())) {
		QPalette pal = palette();
		pal.setColor(QPalette::Base, QColor(233,150,122));
		setPalette(pal);
	}
	else
		setPalette(QApplication::palette(this));
}
Beispiel #19
0
/*
    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();
}
Beispiel #20
0
void ingresoBienes::limpiar(){    
    m_ui->nombreClase->clear();    
    m_ui->descripcion->clear();    
    m_ui->marca->clear();
    m_ui->modelo->clear();
    m_ui->cuentaAsignada->clear();
    m_ui->serie->clear();
    m_ui->nombreEspecifico->clear();
    m_ui->numeroCuenta->clear();    
    m_ui->valorBien->clear();
    completer();
}
void CompletingLineEdit::keyPressEvent(QKeyEvent *e)
{
    if (e->key() == Qt::Key_Down && !e->modifiers()) {
        if (QCompleter *comp = completer()) {
            if (text().isEmpty() && !comp->popup()->isVisible()) {
                comp->setCompletionPrefix(QString());
                comp->complete();
            }
        }
    }
    return QLineEdit::keyPressEvent(e);
}
Beispiel #22
0
void QDirEdit::acceptFiles(bool files, bool write) {
	_files = files;
	_writeFile = write;
	QDirModel* dirModel = qobject_cast<QDirModel*>(completer()->model());
	Q_ASSERT(dirModel);
	if (_files)
		dirModel->setFilter(
				QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
	else
		dirModel->setFilter(
				QDir::AllDirs               | QDir::NoDotAndDotDot);
}
// ui/gtk/filter_autocomplete.c:build_autocompletion_list
void FieldFilterEdit::buildCompletionList(const QString &field_word)
{
    // Push a hint about the current field.
    if (syntaxState() == Valid) {
        emit popFilterSyntaxStatus();

        header_field_info *hfinfo = proto_registrar_get_byname(field_word.toUtf8().constData());
        if (hfinfo) {
            QString cursor_field_msg = QString("%1: %2")
                    .arg(hfinfo->name)
                    .arg(ftype_pretty_name(hfinfo->type));
            emit pushFilterSyntaxStatus(cursor_field_msg);
        }
    }

    if (field_word.length() < 1) {
        completion_model_->setStringList(QStringList());
        return;
    }

    void *proto_cookie;
    QStringList field_list;
    int field_dots = field_word.count('.'); // Some protocol names (_ws.expert) contain periods.
    for (int proto_id = proto_get_first_protocol(&proto_cookie); proto_id != -1; proto_id = proto_get_next_protocol(&proto_cookie)) {
        protocol_t *protocol = find_protocol_by_id(proto_id);
        if (!proto_is_protocol_enabled(protocol)) continue;

        // Don't complete the current word.
        const QString pfname = proto_get_protocol_filter_name(proto_id);
        if (field_word.compare(pfname)) field_list << pfname;

        // Add fields only if we're past the protocol name and only for the
        // current protocol.
        if (field_dots > pfname.count('.')) {
            void *field_cookie;
            const QByteArray fw_ba = field_word.toUtf8(); // or toLatin1 or toStdString?
            const char *fw_utf8 = fw_ba.constData();
            gsize fw_len = (gsize) strlen(fw_utf8);
            for (header_field_info *hfinfo = proto_get_first_protocol_field(proto_id, &field_cookie); hfinfo; hfinfo = proto_get_next_protocol_field(proto_id, &field_cookie)) {
                if (hfinfo->same_name_prev_id != -1) continue; // Ignore duplicate names.

                if (!g_ascii_strncasecmp(fw_utf8, hfinfo->abbrev, fw_len)) {
                    if ((gsize) strlen(hfinfo->abbrev) != fw_len) field_list << hfinfo->abbrev;
                }
            }
        }
    }
    field_list.sort();

    completion_model_->setStringList(field_list);
    completer()->setCompletionPrefix(field_word);
}
Beispiel #24
0
void LocationBar::showCompletion(const QString &completion, bool completeDomain)
{
    LineEdit::setText(completion);

    // Move cursor to the end
    end(false);

    if (completeDomain) {
        completer()->complete();
    }

    updateSiteIcon();
}
ACListe preAC(char** mots, int nbrMots){
	ACListe acListe = createACListe();
	int i;
	for(i = 0; i < nbrMots; i++){
		if(mots[i] == NULL){
			break;
		}
		else{
			insertInTrie(acListe->trie, mots[i]);
		}
	}
	completer(acListe);
	
	return acListe;
}
Beispiel #26
0
void LineEdit::learnEntry()
{
    QAbstractItemModel *m = completer()->model();
    int rows = m->rowCount();
    for (int i = 0; i < rows; ++i) {
        if (m->index(i,0).data() == text()) {
            m->removeRow(i);
            --rows;
            break;
        }
    }
    m->insertRows(rows, 1);
    m->setData(m->index(rows, 0), text(), Qt::DisplayRole);
    m_historyPosition = rows + 1;
}
Beispiel #27
0
void MgCommandLine::updateCompletion()
{
	if(!m_scriptEngine)
		return;


	if(!m_completer->popup()->isVisible())
		return;

	MgCommandCompleter completer(m_scriptEngine);
	MgCommandCompleter::CompletionResult result = completer.completionOf(text(),cursorPosition());

	m_completer->setCompletionPrefix("");
	m_prefix = result.prefix;
	m_completionModel->setStringList(result.completion);
	m_completer->complete();
}
Beispiel #28
0
void ToolbarSearch::setupMenu()
{
    if (m_suggestions.isEmpty()
            || (m_model->rowCount() > 0
                && m_model->item(0) != m_suggestionsItem)) {
        m_model->clear();
        m_suggestionsItem = 0;
    } else {
        m_model->removeRows(1, m_model->rowCount() -1 );
    }

    QFont boldFont;
    boldFont.setBold(true);
    if (!m_suggestions.isEmpty()) {
        if (m_model->rowCount() == 0) {
            if (!m_suggestionsItem) {
                m_suggestionsItem = new QStandardItem();
                m_suggestionsItem->setFont(boldFont);
                retranslate();
            }
            m_model->appendRow(m_suggestionsItem);
        }
        for (int i = 0; i < m_suggestions.count(); ++i) {
            const QString &text = m_suggestions.at(i);
            m_model->appendRow(new QStandardItem(text));
        }
    }

    if (m_recentSearches.isEmpty()) {
        m_recentSearchesItem = new QStandardItem(tr("No Recent Searches"));
        m_recentSearchesItem->setFont(boldFont);
        m_model->appendRow(m_recentSearchesItem);
    } else {
        m_recentSearchesItem = new QStandardItem(tr("Recent Searches"));
        m_recentSearchesItem->setFont(boldFont);
        m_model->appendRow(m_recentSearchesItem);
        for (int i = 0; i < m_recentSearches.count(); ++i) {
            QString text = m_recentSearches.at(i);
            m_model->appendRow(new QStandardItem(text));
        }
    }

    QAbstractItemView *view = completer()->popup();
    view->setFixedHeight(view->sizeHintForRow(0) * m_model->rowCount() + view->frameWidth() * 2);
}
Beispiel #29
0
void LineEdit::setHistoryEnabled(bool enabled)
{
    if (enabled == m_historyEnabled)
        return;
    m_historyEnabled = enabled;
    if (m_historyEnabled) {
        // queued so we learn and update the history list *after* the user selected an item from popup
        connect(this, SIGNAL(returnPressed()), this, SLOT(learnEntry()), Qt::QueuedConnection);
        QCompleter *completer = new QCompleter(QStringList(), this);
        completer->setCaseSensitivity(Qt::CaseInsensitive);
        completer->setCompletionMode(QCompleter::InlineCompletion);
        setCompleter(completer);
    } else {
        disconnect(this, SIGNAL(returnPressed()), this, SLOT(learnEntry()));
        delete completer();
        setCompleter(NULL);
    }
}
Beispiel #30
0
AcTrie preAC (char ** x, int k) {
  // Création du trie
  AcTrie acTrie = initAcTrie();
  // Insertion de tous les mots de x au trie
  for (int i = 0; i < k; i++) {
    entrer (x[i], acTrie);
  }
  // Ajout de la boucle à la racine
  for (int i = 0; i < alphaSize; i++) {
    if (acTrie->trie->transition[0][(int) alpha[i]] == -1) {
      acTrie->trie->transition[0][(int) alpha[i]] = 0;
    }
  }
  // Complétion du acTrie
  completer (acTrie);
  // Renvoie du acTrie
  return acTrie;
}