void ShaderComboBox::currentChanged(int index) { if (itemData(index).isValid() && itemData(index) == QVariant((int)QVariant::UserType)) { QString newShader = HordeFileDialog::getResourceFile( H3DResTypes::Shader, m_resourcePath, this, tr("Select shader to import")); if (!newShader.isEmpty()) { int index2 = findText(newShader); if (index2 == -1) { blockSignals(true); removeItem(index); addItem(newShader); addItem(tr("Import from Repository"), QVariant(QVariant::UserType)); blockSignals(false); QHordeSceneEditorSettings settings; setItemData( count() - 1, settings.value( "ImportEntryColor", QColor( 132, 255, 136 ) ), Qt::BackgroundColorRole ); index2 = findText(newShader); } setCurrentIndex(index2); return; } else setCurrentIndex(findText(m_init)); return; } if (m_init != currentText()) { emit shaderChanged(); emit editFinished(); } }
void MainWindow::on_actionFindText_triggered() { SearchDialog dlg(this); if ( dlg.exec() ) { if ( !dlg.text.isEmpty() ) { bool found = false; found = findText(dlg.text, 1, SearchDialog::reverse, !SearchDialog::caseSensitive); if ( !found ) found = findText(dlg.text, -1, SearchDialog::reverse, !SearchDialog::caseSensitive); if ( !found ) { QMessageBox * mb = new QMessageBox( QMessageBox::Information, tr("Not found"), tr("Search pattern is not found in document"), QMessageBox::Close, this ); mb->exec(); if ( !ui->view->getDocView()->getMarkedRanges()->empty() ) { ui->view->getDocView()->clearSelection(); ui->view->update(); } } else { ui->view->update(); } } else if ( !ui->view->getDocView()->getMarkedRanges()->empty() ) { ui->view->getDocView()->clearSelection(); ui->view->update(); } } }
void MainWindow::onSetExportPath() { QString startPath; // 从当前选中路径开始; auto comboBox_exportPaths = this->findChild<QComboBox *>(tr("comboBox_exportPaths")); if (comboBox_exportPaths) { startPath = comboBox_exportPaths->currentText(); qDebug() << tr("start path: ") << startPath; } if (startPath.isEmpty()) { startPath = QDir::currentPath(); } // 打开选择目录对话框; QString directory = QFileDialog::getExistingDirectory(this, tr("Find Files"), startPath); if (!directory.isEmpty()) { // 在combobox中设置选中的文件夹; if (comboBox_exportPaths) { if (comboBox_exportPaths->findText(directory) == -1) { comboBox_exportPaths->addItem(directory); } comboBox_exportPaths->setCurrentIndex(comboBox_exportPaths->findText(directory)); } saveOpenedFileList(); } }
void PipelineComboBox::currentChanged(int index) { if (itemData(index).isValid() && itemData(index) == QVariant((int)QVariant::UserType)) { QString newPipeline = HordeFileDialog::getResourceFile( H3DResTypes::Pipeline, m_resourcePath, this, tr("Select pipeline to import")); if (!newPipeline.isEmpty()) { if (findText(newPipeline) == -1) { removeItem(index); addItem(newPipeline); addItem(tr("Import from Repository"), QVariant(QVariant::UserType)); } setCurrentIndex(findText(newPipeline)); return; } else setCurrentIndex(findText(m_init)); return; } if (m_init != currentText()) { emit pipelineChanged(); emit editFinished(); } }
void ItemWeb::highlight(const QRegExp &re, const QFont &, const QPalette &) { // FIXME: Set hightlight color and font! // FIXME: Hightlight text matching regular expression! findText( QString(), QWebPage::HighlightAllOccurrences ); if ( !re.isEmpty() ) findText( re.pattern(), QWebPage::HighlightAllOccurrences ); }
void PartitionComboBox::addPartition() { const QString partition = QInputDialog::getText( this, QString::null, tr( "Enter a partition path" ) ); if ( !partition.isNull() && findText( partition ) == -1 ) { partitionModel()->addPartition( partition ); } if ( !partition.isNull() ) { setCurrentIndex( findText( partition ) ); } }
DStyleComboBox::DStyleComboBox(QWidget *parent) : QComboBox(parent) { addItems( QStyleFactory::keys() ); connect(this, SIGNAL(activated( const QString& )), this, SLOT(chooseStyle(const QString &))); #if QT_VERSION >= 0x040200 setCurrentIndex( findText(QApplication::style()->objectName(), Qt::MatchExactly|Qt::MatchFixedString) ); #else setCurrentIndex( findText(QApplication::style()->objectName(), Qt::MatchExactly) ); #endif }
bool t4p::FinderClass::FindNextRegularExpression(const UnicodeString& text, int32_t start) { if (U_SUCCESS(PatternErrorCode) && Pattern != NULL) { UnicodeString findText(text); if (start > 0 && start < text.length()) { findText.setTo(text, start); } else if (start > 0) { findText = UNICODE_STRING_SIMPLE(""); } int32_t foundPos = 0, length = 0, endPos = 0; UErrorCode error = U_ZERO_ERROR; RegexMatcher* matcher = Pattern->matcher(findText, error); if (U_SUCCESS(error) && matcher) { if (matcher->find()) { foundPos = matcher->start(error); endPos = matcher->end(error); if (U_SUCCESS(error) && U_SUCCESS(error)) { IsFound = true; length = endPos - foundPos; // end is the index after the match // if search was started from the middle of a string, // need to correct the found position LastPosition = start > 0 ? foundPos + start : foundPos; LastLength = length; } } delete matcher; } } return IsFound; }
void ShaderComboBox::setShader(Shader shader) { blockSignals(true); setCurrentIndex(findText(shader.FileName)); blockSignals(false); m_init = shader.FileName; }
void SelectTargetDelegate::setEditorData (QWidget *editor, const QModelIndex& index) const { auto box = static_cast<QComboBox*> (editor); QString targetText = index.data (TargetRole).toString (); box->setCurrentIndex (box->findText (targetText, Qt::MatchExactly)); }
void AreaWidget::on_formulaChanged() { cleanup(); auto formulas = m_selectionWidget->currentFormula(); AreaParser parser{formulas}; if(!parser.check()) { return; } auto& dev_expl = m_space.context().devices.explorer(); auto area = parser.result(); for(int i = 0; i < m_spaceMappingLayout->rowCount(); i++) { auto cb = qobject_cast<QComboBox*>(m_spaceMappingLayout->itemAt(i, QFormLayout::ItemRole::FieldRole)->widget()); cb->addItem(""); // What happens if left blank ? e.g. x=5 in 2D space ? Should just do the correct stuff. for(const auto& sym: area.syms) { cb->setEnabled(true); cb->addItem(QString::fromStdString(sym.get_name())); } } for(const auto& sym: area.syms) { auto pw = new ParameterWidget{&dev_expl, this}; m_paramMappingLayout->addRow(QString::fromStdString(sym.get_name()), pw); } if(m_selectionWidget->currentAreaKey() != GenericArea::uuid()) { auto& fl = m_space.context().doc.app.components.factory<AreaFactoryList>(); auto area_f_it = fl.get(m_selectionWidget->currentAreaKey()); if(!area_f_it) { return; } AreaFactory& area_factory = *area_f_it; auto dsm = area_factory.defaultSpaceMap(); auto dpm = area_factory.defaultParameterMap(); // TODO // we set the default values int i = 0; for(const DimensionModel& dim : m_space.space().dimensions()) { auto cb = qobject_cast<QComboBox*>(m_spaceMappingLayout->itemAt(i, QFormLayout::ItemRole::FieldRole)->widget()); int text_id = cb->findText(dsm[dim.id()]); if(text_id != -1) { cb->setCurrentIndex(text_id); cb->setEnabled(false); } i++; } } }
void CHistoryComboBox::addToHistory(const QString& text) { int index = findText(text); if ( index >= 0) removeItem(index); insertItem(1, text); setCurrentIndex(1); }
void PipelineComboBox::setPipeline(Pipeline pipeline) { blockSignals(true); setCurrentIndex(findText(pipeline.FileName)); blockSignals(false); m_init = pipeline.FileName; }
void ChatControl::commandFind(ChatCommandContext* context) { if (context->param.empty()) { context->param = findTextPopup(); } if (!context->param.empty()) { findText(context->param); } }
bool ChatView::find(const QString &text, bool forward) { QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (!forward) options |= QWebPage::FindBackward; bool found = findText(text, options); options = QWebPage::HighlightAllOccurrences; findText(QString(), options); findText(text, options); if (!found && text.isEmpty()) found = true; return found; }
/** * Sets the currently selected width item to the given width. */ void QG_PatternBox::setPattern(const QString& pName) { RS_DEBUG->print("QG_PatternBox::setPattern %s\n", pName.toLatin1().data()); setCurrentIndex(findText(pName)); slotPatternChanged(currentIndex()); }
void SqueezedComboBox::setCurrent(const QString& itemText) { QString squeezedText = squeezeText(itemText); qint32 itemIndex = findText(squeezedText); if (itemIndex >= 0) { setCurrentIndex(itemIndex); } }
QString MessageTopicComboBox::getCurrentTopicType() const { int index = findText(currentTopic_); if (index >= 0) return itemData(index).toString(); else return QString(); }
bool EditorWidget::findNext() { // Find the next occurrence of the text in our editor mEditor->getCursorPosition(&mCurrentLine, &mCurrentColumn); return findText(mFindReplace->findText(), true); }
/******************** getText ************************************** char * getText(TextList textList, char *pszId) Purpose: Finds a text entry based on the specified ID and returns its text. Parameters: I TextList textList A text list which contains many text entries. I char *pszId The text entry to be found in the text list. Returns: A pointer to the text string of the specified ID. If not found, it returns a pointer to szUnknown. Notes: - This uses an array implementation of TextList. - References the static global variable szUnknown which is returned when the specified ID is not found. This allows getText() to be used in a printf() knowing that a non-NULL value is returned even when the specified ID is not found in the text list. - Invokes findText to find it. **************************************************************************/ char * getText(TextList textList, char *pszId) { int iFound = findText(textList, pszId); if (iFound >= 0) return textList->arrayM[iFound].szText; else return szUnknown; }
void ColorSelect::on_customColorChanged(const QColor &color) { QPixmap pixmap(qIconSize); auto index = findText(CUSTOM); pixmap.fill(color); setItemIcon(index, QIcon(pixmap)); _customColor = color; }
bool SearchableEditor::find(bool newSearch) { if (!fd) fd = new FindDialog(this, ::wxGetTopLevelParent(this)); if (newSearch || findTextM.empty()) { if (newSearch) { // find selected text wxString findText(GetSelectedText()); // failing that initialize with the word at the caret if (findText.empty()) { int pos = GetCurrentPos(); int start = WordStartPosition(pos, true); int end = WordEndPosition(pos, true); if (end > start) findText = GetTextRange(start, end); } fd->SetFindText(findText); } // do not re-center dialog if it is already visible if (!fd->IsShown()) fd->Show(); fd->SetFocus(); return false; // <- caller shouldn't care about this } int start = GetSelectionEnd(); if (findFlagsM.has(se::FROM_TOP)) { start = 0; findFlagsM.remove(se::ALERT); // remove flag after first find } int end = GetTextLength(); int p = FindText(start, end, findTextM, findFlagsM.asStc()); if (p == -1) { if (findFlagsM.has(se::WRAP)) p = FindText(0, end, findTextM, findFlagsM.asStc()); if (p == -1) { if (findFlagsM.has(se::ALERT)) wxMessageBox(_("No more matches"), _("Search complete"), wxICON_INFORMATION|wxOK); return false; } } centerCaret(true); GotoPos(p); GotoPos(p + findTextM.Length()); SetSelectionStart(p); SetSelectionEnd(p + findTextM.Length()); centerCaret(false); return true; }
void toRefreshCombo::setRefreshInterval(QString const& interval) { #if QT_VERSION < 0x050000 int index = findText(interval); setCurrentIndex(index); #else setCurrentText(interval); #endif }
void MyFontComboBox::setCurrentText( const QString & text ) { int i = findText(text); if (i != -1) setCurrentIndex(i); else if (isEditable()) setEditText(text); else setItemText(currentIndex(), text); }
PgxEditor::PgxEditor(Database *database, QString editor_name) { ++editor_widow_id; this->database = database; this->editor_name = editor_name; createActions(); breakpointArea = new BreakPointArea(this); lineNumberArea = new LineNumberArea(this); setStyleSheet("QPlainTextEdit{background-color: white; font: bold 14px 'Courier New';}"); highlighter = new Highlighter(document()); toolbar = new QToolBar; toolbar->setIconSize(QSize(36,36)); toolbar->setObjectName("pgxeditor"); toolbar->setMovable(false); toolbar->addAction(newpgxeditor_action); toolbar->addAction(cut_action); toolbar->addAction(copy_action); toolbar->addAction(paste_action); if(!editor_name.isEmpty()) { toolbar->addSeparator(); toolbar->addAction(save_action); toolbar->addSeparator(); toolbar->addAction(execute_action); } toolbar->addSeparator(); toolbar->addAction(selected_execute_action); toolbar->addAction(wrap_action); toolbar->addAction(find_action); pgxeditor_mainwin = new PgxEditorMainWindow; pgxeditor_mainwin->addToolBar(toolbar); pgxeditor_mainwin->setCentralWidget(this); pgxeditor_mainwin->setAttribute(Qt::WA_DeleteOnClose); find_bar = new QLineEdit; find_bar->setPlaceholderText(tr("Find")); find_bar->setVisible(false); pgxeditor_mainwin->statusBar()->setSizeGripEnabled(false); pgxeditor_mainwin->statusBar()->addPermanentWidget(casesensitivity_button, 0); pgxeditor_mainwin->statusBar()->addPermanentWidget(wholeword_button, 0); pgxeditor_mainwin->statusBar()->addPermanentWidget(backwards_button, 0); pgxeditor_mainwin->statusBar()->addPermanentWidget(find_bar); replace_bar = new QLineEdit; replace_bar->setPlaceholderText(tr("Replace")); replace_bar->setVisible(false); pgxeditor_mainwin->statusBar()->addPermanentWidget(replace_bar); connect(find_bar, SIGNAL(returnPressed()), this, SLOT(findText())); connect(replace_bar, SIGNAL(returnPressed()), this, SLOT(replaceText())); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot())); connect(this, SIGNAL(textChanged()), this, SLOT(textChangedSlot())); connect(pgxeditor_mainwin, SIGNAL(pgxeditorClosing()), this, SLOT(pgxeditorClosing())); updateLineNumberAreaWidth(0); }
void WComboBox::setValueText(const WT_USTRING& value) { // FIXME make cnor understand this #ifndef WT_TARGET_JAVA int i = findText(value, MatchExactly); setCurrentIndex(i); #endif }
void XComboBox::setCode(QString pString) { if (DEBUG) qDebug("%s::setCode(%d %d %s) with _codes.count %d and _ids.count %d", objectName().toAscii().data(), pString.isNull(), pString.isEmpty(), pString.toAscii().data(), _codes.count(), _ids.count()); if (pString.isEmpty()) { setId(-1); setCurrentText(pString); } else if (count() == _codes.count()) { for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++) { if (_codes.at(counter) == pString) { if (DEBUG) qDebug("%s::setCode(%s) found at %d with _ids.count %d & _lastId %d", objectName().toAscii().data(), pString.toAscii().data(), counter, _ids.count(), _lastId); setCurrentIndex(counter); if (_ids.count() && _lastId!=_ids.at(counter)) setId(_ids.at(counter)); return; } else if (DEBUG) qDebug("%s::setCode(%s) not found (%s)", qPrintable(objectName()), qPrintable(pString), qPrintable(_codes.at(counter))); } } else // this is an ad-hoc combobox without a query behind it? { setCurrentItem(findText(pString)); if (DEBUG) qDebug("%s::setCode(%s) set current item to %d using findData()", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); if (_ids.count() > currentItem()) setId(_ids.at(currentItem())); if (DEBUG) qDebug("%s::setCode(%s) current item is %d after setId", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); } if (editable()) { setId(-1); setCurrentText(pString); } }
void ColorSelect::onLayerChanged(lc::Layer_CSPtr layer) { auto index = findText(BY_LAYER); if(index != -1) { QColor color(layer->color().redI(), layer->color().greenI(), layer->color().blueI(), layer->color().alphaI()); QPixmap pixmap(qIconSize); pixmap.fill(color); setItemIcon(index, QIcon(pixmap)); } }
void setText(const QString& strText) { int index = findText(strText); if (index != -1) { setCurrentIndex(index); } m_strText = strText; repaint(); }
void QxtCheckComboBox::setCheckedItems(const QStringList& items) { // not the most efficient solution but most likely nobody // will put too many items into a combo box anyway so... foreach(const QString& text, items) { const int index = findText(text); setItemCheckState(index, index != -1 ? Qt::Checked : Qt::Unchecked); } }