GmacsCompleter::GmacsCompleter(QPlainTextEdit *editor) : QCompleter() { //setModelSorting(QCompleter::CaseInsensitivelySortedModel); //setCaseSensitivity(Qt::CaseInsensitive); setWrapAround(false); setMaxVisibleItems(20); setCompletionMode(QCompleter::PopupCompletion); setWidget(editor); QObject::connect(this, SIGNAL(activated(QString)), editor, SLOT(insertCompletion(QString))); }
MyQComboBox::MyQComboBox(QWidget *parent) : QComboBox(parent) { setEditable(false); setMaxVisibleItems(1); setInsertPolicy(QComboBox::NoInsert); _menu = new QMenu(this); QWidget * basicEditor = new QFrame(this); QFormLayout * formLayout = new QFormLayout(basicEditor); basicEditor->setLayout(formLayout); QLineEdit * input = new QLineEdit(basicEditor); formLayout->addRow("Text", input); QWidgetAction * pickerAction = new QWidgetAction(this); pickerAction->setDefaultWidget(basicEditor); _menu->addAction(pickerAction); }
void KMyMoneyAccountCombo::makeCompletion(const QString& txt) { AccountNamesFilterProxyModel* filterModel = qobject_cast<AccountNamesFilterProxyModel*>(model()); if(filterModel) { if (txt.contains(MyMoneyFile::AccountSeperator) == 0) { // for some reason it helps to avoid internal errors if we // clear the filter before setting it to a new value filterModel->setFilterFixedString(""); filterModel->setFilterRegExp(QRegExp(QString("%1%2%3").arg(".*").arg(QRegExp::escape(txt)).arg(".*"), Qt::CaseInsensitive)); } else { QStringList parts = txt.split(MyMoneyFile::AccountSeperator /*, QString::SkipEmptyParts */); QString pattern; QStringList::iterator it; for (it = parts.begin(); it != parts.end(); ++it) { if (pattern.length() > 1) pattern += MyMoneyFile::AccountSeperator; pattern += QRegExp::escape(QString(*it).trimmed()) + ".*"; } filterModel->setFilterFixedString(""); filterModel->setFilterRegExp(QRegExp(pattern, Qt::CaseInsensitive)); // if we don't have a match, we try it again, but this time // we add a wildcard for the top level if (filterModel->visibleItems() == 0) { pattern = pattern.prepend(QString(".*") + MyMoneyFile::AccountSeperator); filterModel->setFilterFixedString(""); filterModel->setFilterRegExp(QRegExp(pattern, Qt::CaseInsensitive)); } } const int visibleAccounts = filterModel->visibleItems(); switch(visibleAccounts) { case 0: hidePopup(); break; default: setMaxVisibleItems(15); expandAll(); showPopup(); d->selectFirstMatchingItem(); break; } } }
LocationCompleter::LocationCompleter(QObject* parent) : QCompleter(parent) { setMaxVisibleItems(6); QStandardItemModel* completeModel = new QStandardItemModel(); setModel(completeModel); QTreeView* treeView = new QTreeView; setPopup(treeView); treeView->setRootIsDecorated(false); treeView->header()->hide(); treeView->header()->setStretchLastSection(false); treeView->header()->setResizeMode(0, QHeaderView::Stretch); treeView->header()->resizeSection(1, 0); setCompletionMode(QCompleter::PopupCompletion); setCaseSensitivity(Qt::CaseInsensitive); setWrapAround(true); setCompletionColumn(1); }
void RLineweightCombo::init() { clear(); setMaxVisibleItems(12); QVariant v; QListIterator<QPair<QString, RLineweight::Lineweight> > it( RLineweight::getList(onlyFixed)); while (it.hasNext()) { QPair<QString, RLineweight::Lineweight> p = it.next(); v.setValue<RLineweight::Lineweight> (p.second); addItem(RLineweight::getIcon(p.second), p.first, v); } if (!onlyFixed) { setLineweight(RLineweight::WeightByLayer); } else { // TODO: make configurable: //RLineweight::Lineweight lw = RSettings::getIntValue(""); setLineweight(RLineweight::Weight025); } }
int QComboBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 24) qt_static_metacall(this, _c, _id, _a); _id -= 24; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isEditable(); break; case 1: *reinterpret_cast< int*>(_v) = count(); break; case 2: *reinterpret_cast< QString*>(_v) = currentText(); break; case 3: *reinterpret_cast< int*>(_v) = currentIndex(); break; case 4: *reinterpret_cast< int*>(_v) = maxVisibleItems(); break; case 5: *reinterpret_cast< int*>(_v) = maxCount(); break; case 6: *reinterpret_cast< InsertPolicy*>(_v) = insertPolicy(); break; case 7: *reinterpret_cast< SizeAdjustPolicy*>(_v) = sizeAdjustPolicy(); break; case 8: *reinterpret_cast< int*>(_v) = minimumContentsLength(); break; case 9: *reinterpret_cast< QSize*>(_v) = iconSize(); break; case 10: *reinterpret_cast< bool*>(_v) = autoCompletion(); break; case 11: *reinterpret_cast< Qt::CaseSensitivity*>(_v) = autoCompletionCaseSensitivity(); break; case 12: *reinterpret_cast< bool*>(_v) = duplicatesEnabled(); break; case 13: *reinterpret_cast< bool*>(_v) = hasFrame(); break; case 14: *reinterpret_cast< int*>(_v) = modelColumn(); break; } _id -= 15; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setEditable(*reinterpret_cast< bool*>(_v)); break; case 3: setCurrentIndex(*reinterpret_cast< int*>(_v)); break; case 4: setMaxVisibleItems(*reinterpret_cast< int*>(_v)); break; case 5: setMaxCount(*reinterpret_cast< int*>(_v)); break; case 6: setInsertPolicy(*reinterpret_cast< InsertPolicy*>(_v)); break; case 7: setSizeAdjustPolicy(*reinterpret_cast< SizeAdjustPolicy*>(_v)); break; case 8: setMinimumContentsLength(*reinterpret_cast< int*>(_v)); break; case 9: setIconSize(*reinterpret_cast< QSize*>(_v)); break; case 10: setAutoCompletion(*reinterpret_cast< bool*>(_v)); break; case 11: setAutoCompletionCaseSensitivity(*reinterpret_cast< Qt::CaseSensitivity*>(_v)); break; case 12: setDuplicatesEnabled(*reinterpret_cast< bool*>(_v)); break; case 13: setFrame(*reinterpret_cast< bool*>(_v)); break; case 14: setModelColumn(*reinterpret_cast< int*>(_v)); break; } _id -= 15; } else if (_c == QMetaObject::ResetProperty) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 15; } #endif // QT_NO_PROPERTIES return _id; }