Пример #1
0
void BAbstractFileType::showAutocompletionMenu(BAbstractCodeEditorDocument *doc, QTextCursor cursor, const QPoint &)
{
    if (cursor.isNull())
        return;
    QCompleter *completer = doc->findChild<QCompleter *>("beqt/completer");
    cursor.select(QTextCursor::WordUnderCursor);
    if (!cursor.hasSelection()) {
        if (completer)
            completer->popup()->hide();
        return;
    }
    QList<AutocompletionItem> list = createAutocompletionItemList(doc, cursor);
    if (list.isEmpty()) {
        if (completer)
            completer->popup()->hide();
        return;
    }
    QStandardItemModel *model = doc->findChild<QStandardItemModel *>("beqt/completion_model");
    if (!model) {
        model = new QStandardItemModel(doc);
        model->setObjectName("beqt/completion_model");
        model->setColumnCount(1);
    }
    model->clear();
    foreach (const AutocompletionItem &item, list) {
        QStandardItem *si = new QStandardItem(item.actionIcon, item.actionText);
        si->setData(item.actionToolTip, Qt::ToolTipRole);
        si->setData(item.text, Qt::UserRole);
        model->appendRow(si);
    }
Пример #2
0
void MainWindow::updateArgumentCompleter(QStringList *list, bool google)
{
    editingCompleter++;
    QCompleter *completer = ui->txtArgument->completer();

    if (completer == NULL) {
        completer = new QCompleter(*list, ui->txtArgument);
        ui->txtArgument->setCompleter(completer);
    } else {
        QStringListModel *model = new QStringListModel(*list, completer);
        completer->setModel(model);
    }

    completer->setCaseSensitivity(Qt::CaseInsensitive);
    completer->setCompletionMode(QCompleter::PopupCompletion);
    completer->popup()->installEventFilter(this);
    completer->popup()->setItemDelegate(new GoogleResultDelegate());

    if (google) {
        completer->setMaxVisibleItems(21);
    } else {
        completer->setMaxVisibleItems(7);
    }

    completer->setCompletionPrefix(ui->txtArgument->text());

    if (!list->isEmpty()) {
        completer->complete();
    }

    editingCompleter--;
}
Пример #3
0
/** Define the QLineEdit to use as zip code editor */
void ZipCountryCompleters::setZipLineEdit(QLineEdit *zip)
{
    m_Zip = zip;
    // Completer
    QCompleter *completer = new QCompleter(this);
    completer->setModel(m_Model);
    completer->setCompletionColumn(ZipCountryModel::ZipCity);
    completer->setCaseSensitivity(Qt::CaseInsensitive);
    completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
    completer->popup()->setAlternatingRowColors(true);
    zip->setCompleter(completer);
    connect(m_Zip, SIGNAL(textChanged(QString)), this, SLOT(zipTextChanged()));
    connect(completer, SIGNAL(activated(QModelIndex)), this, SLOT(indexActivated(QModelIndex)));

    // button
    m_ZipButton = new QToolButton(m_Zip);
    m_ZipButton->setToolTip("Zip button");
    m_ZipButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_ZipButton->setIconSize(QSize(16,16));
    m_ZipButton->setIcon(QIcon(QDir::cleanPath(qApp->applicationDirPath() + "/../../../../../global_resources/pixmap/16x16/ok.png")));
    m_ZipButton->setMinimumSize(20,20);
    m_ZipButton->setMaximumSize(20,20);
    m_ZipButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
    m_ZipButton->show();

    int frameWidth = m_Zip->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
    QSize msz = m_Zip->minimumSizeHint();
    m_Zip->setMinimumSize(qMax(msz.width(), m_ZipButton->maximumHeight() + frameWidth * 2 + 2),
                          qMax(msz.height(), m_ZipButton->maximumHeight() + frameWidth * 2 + 2));
    m_Zip->setStyleSheet(QString("padding-left: %1px;").arg(m_ZipButton->sizeHint().width() + frameWidth));
    m_Zip->installEventFilter(this);
}
Пример #4
0
KBicEdit::KBicEdit(QWidget* parent)
  : KLineEdit(parent)
{
  QCompleter* completer = new QCompleter(this);

  bicModel* model = new bicModel(this);
  completer->setModel(model);
  m_popupDelegate = new bicItemDelegate(this);
  completer->popup()->setItemDelegate(m_popupDelegate);

  setCompleter(completer);

  bicValidator *const validator = new bicValidator(this);
  setValidator(validator);
}
Пример #5
0
void ProjectReader::readScripts(QString &path, QString &name, bool open) {
    Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("Script"));

    QString n;
    Highlighter *h;
    QCompleter *c;
    CodeEditor *editor = new CodeEditor(name, 0, h);
    
    if (open) {
        editor = 0;
        mMw->addCodeEditor(path + "/" + name);
    } else {
        
        editor->setUndoRedoEnabled(true);
        editor->setTabStopWidth(29);
#ifdef Q_WS_MAC
        int size = 12;
        QFont font("Monaco", size);
#endif
#ifdef Q_OS_WIN
        int size = 10;
        QFont font("Consolas", size);
#endif
#ifdef Q_OS_LINUX
        int size = 10;
        QFont font("Inconsolata-g", size);
#endif
        editor->setFont(font);
        h = new Highlighter(editor->document());
        c = new QCompleter();
        c->setModel(mDocumentManager->modelFromFile(":/wordlist.txt"));
        c->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
        c->setCaseSensitivity(Qt::CaseInsensitive);
        c->setWrapAround(false);
        c->popup()->setStyleSheet("color: #848484; background-color: #2E2E2E; selection-background-color: #424242;");
        editor->setCompleter(c);
        
        n = path + "/" + name;
        //qDebug() << "look a script" << n;
        
        editor->openFile(path + "/" + name);
        
        mMw->addCodeEditor(editor, open);
    }

    xml.skipCurrentElement();
}
/** Define the QLineEdit to use as zip code editor */
void ZipCountryCompleters::setZipLineEdit(Utils::QButtonLineEdit *zip)
{
    m_zipEdit = zip;
    // Completer
    QCompleter *completer = new QCompleter(this);
    completer->setModel(m_ZipModel);
    completer->setCompletionColumn(ZipCountryModel::ZipCity);
    completer->setCaseSensitivity(Qt::CaseInsensitive);
    completer->setCompletionMode(QCompleter::PopupCompletion);
    completer->popup()->setAlternatingRowColors(true);
    m_zipEdit->setCompleter(completer);
    connect(m_zipEdit, SIGNAL(textChanged(QString)), this, SLOT(zipTextChanged()));
    connect(completer, SIGNAL(activated(QModelIndex)), this, SLOT(onCompleterIndexActivated(QModelIndex)));

    // button
    m_ZipButton = new QToolButton(m_zipEdit);
    m_ZipButton->setIcon(theme()->icon(Core::Constants::ICONHELP));
    m_zipEdit->setRightButton(m_ZipButton);
}
Пример #7
0
bool BAbstractFileType::autocompletionMenuVisible(BAbstractCodeEditorDocument *doc) const
{
    QCompleter *completer = doc ? doc->findChild<QCompleter *>("beqt/completer") : 0;
    return completer && completer->popup()->isVisible();
}