void tst_ModelTest::stringListModel() { QStringListModel model; QSortFilterProxyModel proxy; ModelTest t1(&model); ModelTest t2(&proxy); proxy.setSourceModel(&model); model.setStringList(QStringList() << "2" << "3" << "1"); model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c" ); proxy.setDynamicSortFilter(true); proxy.setFilterRegExp(QRegExp("[^b]")); }
void EffectsScrollArea::retranslateStrings() { retranslateUi(this); filterGradientWidget->retranslateStrings(); QStringListModel *model = 0; model = static_cast<QStringListModel*>(filterColorModel); model->setStringList(colorFilterStringList()); model = static_cast<QStringListModel*>(filterGradientModel); model->setStringList(gradientFilterStringList()); if (filterColorRadioButton->isChecked()) filterTypeComboBox->setCurrentIndex(filterColorModelIndex); else filterTypeComboBox->setCurrentIndex(filterGradientModelIndex); }
void PluginGame5GenerateSituationDialog::onPluginAction() { QStringList funList = parseModelFUN(); QStringListModel* stringModel = (QStringListModel*)lineEditCustom->completer()->model(); stringModel->setStringList(funList); exec(); }
void MRichTextEditDialogsManager::setTextStyleValues(const QString &fontfamily, int fontPointSize, const QColor &fontColor) { Q_ASSERT(fontFamilyCombo); int familyIndex = -1; QStringListModel *fontFamilyModel = dynamic_cast<QStringListModel *>(fontFamilyCombo->itemModel()); if (fontFamilyModel) { QStringList fontFamilies = fontFamilyModel->stringList(); familyIndex = fontFamilies.indexOf(fontfamily); } fontFamilyCombo->setCurrentIndex(familyIndex); Q_ASSERT(fontSizeCombo); QStringList fontSizeValues = generateFontSizeComboValues(); QStringListModel *fontSizeModel = dynamic_cast<QStringListModel *>(fontSizeCombo->itemModel()); if (fontSizeModel) { fontSizeModel->setStringList(fontSizeValues); } //% "%L1 points" QString fontSize(qtTrId("qtn_comm_font_size_value").arg(fontPointSize)); int sizeIndex = fontSizeValues.indexOf(fontSize); fontSizeCombo->setCurrentIndex(sizeIndex); Q_ASSERT(fontColorCombo); fontColorCombo->setPickedColor(fontColor); }
void AppearanceSettings::themeChanged(int index) { Theme *theme = m_themes.value(index, 0); if (!theme) return; QStringListModel *model; model = qobject_cast<QStringListModel *>(m_colorCombo->model()); model->setStringList(theme->colorSchemeNames()); m_colorCombo->setCurrentIndex(theme->currentColorIndex()); model = qobject_cast<QStringListModel *>(m_backgroundCombo->model()); model->setStringList(theme->backgrounds()); m_backgroundCombo->setCurrentIndex(theme->currentBackgroundIndex()); }
void QuickEdit::DirectionDelegateSetup() { GenericDelegate* delegate = new GenericDelegate(ui->tvEditor, false); delegate->widgetCreator = [](QWidget* parent) { QStringList visibilities; visibilities << "inout" << "in" << "out"; QComboBox* box = new QComboBox(parent); QStringListModel* model = new QStringListModel; model->setStringList(visibilities); box->setModel(model); box->setEditable(false); return box; }; delegate->dataAccessor = [](QWidget* editor, const QModelIndex& index) { QString value = index.model()->data(index, Qt::EditRole).toString(); QComboBox* box = static_cast<QComboBox*>(editor); box->setCurrentText(value); }; delegate->dataSetter = [](QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) { QComboBox* box = static_cast<QComboBox*>(editor); QString value = box->currentText(); model->setData(index, value, Qt::EditRole); }; ui->tvEditor->setItemDelegateForColumn(columns.indexOf("direction"), delegate); }
void GraphicalArrayTest::test_removeItems() { GraphicalArray * value = new GraphicalArray(); QPushButton * button = findRemoveButton(value); QStringListModel * model = findModel(value); QListView * view = findListView(value); QItemSelectionModel::SelectionFlags flag = QItemSelectionModel::Select; model->setStringList( QStringList() << "Hello" << "World" << "and" << "Happy" << "New" << "Year!" ); value->show(); view->selectionModel()->select( model->index(0), flag ); // select "Hello" view->selectionModel()->select( model->index(1), flag ); // select "World" view->selectionModel()->select( model->index(3), flag ); // select "Happy" view->selectionModel()->select( model->index(5), flag ); // select "Year" // simulate a click on the 'Remove' button QTest::mouseClick( button, Qt::LeftButton ); QStringList values = model->stringList(); QCOMPARE( values.count(), 2 ); QCOMPARE( values.at(0), QString("and") ); QCOMPARE( values.at(1), QString("New") ); delete value; }
void ConversationPage::openAttachmentOpenDialog() { MPopupList *popuplist = new MPopupList(); QStringListModel *model = new QStringListModel(this); QDir homeDir = QDir::home(); // Hack: hardcoded the list of applications for the 1.1 release QStringList apps = QStringList() //% "Music player" << qtTrId("xx_music_player") //% "Photo viewer" << qtTrId("xx_photo_viewer") //% "Video player" << qtTrId("xx_video player"); model->setStringList(apps); popuplist->setItemModel(model); //% "Select an application" popuplist->setTitle(qtTrId("xx_select_an_application")); popuplist->appear(); connect(popuplist, SIGNAL(clicked(const QModelIndex&)), SLOT(applicationSelected(const QModelIndex &))); }
void AnimationList::addNewFile() { //// For some unknown reason passing "this" locks up the OSX qavimator window. Possibly a QT4 bug, needs investigation #ifdef __APPLE__ QStringList files=QFileDialog::getOpenFileNames(NULL, "Choose an animation file", Settings::Instance()->lastPath(), ANIM_FILTER); #else QStringList files=QFileDialog::getOpenFileNames(this, "Choose an animation file", Settings::Instance()->lastPath(), ANIM_FILTER); #endif if(files.isEmpty()) return; else { QFileInfo fInfo(files.last()); Settings::Instance()->setLastPath(fInfo.absoluteDir().absolutePath()); } foreach(QString file, files) { if(file.isEmpty() || availableAnimations.contains(file)) continue; else { if(file.endsWith(".avm", Qt::CaseInsensitive) || file.endsWith(".bvh", Qt::CaseInsensitive)) availableAnimations.append(files); } } QStringListModel* model = dynamic_cast<QStringListModel*>(ui->availableAnimsListView->model()); model->setStringList(availableAnimations); //TODO: this is sooo lame. Find a dignified way onSelectionChanged(); }
void QuickEdit::PrefixDelegateSetup() { GenericDelegate* delegate = new GenericDelegate(ui->tvEditor, false); delegate->widgetCreator = [&](QWidget * parent) { QStringList list; list << " " << "const " << "volatile "; QCompleter *completer = new QCompleter(list, parent); completer->setCaseSensitivity(Qt::CaseSensitive); QComboBox* box = new QComboBox(parent); QStringListModel* model = new QStringListModel; model->setStringList(list); box->setModel(model); box->setEditable(true); box->setCompleter(completer); return box; }; delegate->dataAccessor = [](QWidget * editor, const QModelIndex & index) { QString value = index.model()->data(index, Qt::EditRole).toString(); QComboBox *box = static_cast<QComboBox*>(editor); box->setCurrentText(value); }; delegate->dataSetter = [](QWidget * editor,QAbstractItemModel* model, const QModelIndex &index) { QComboBox * box = static_cast<QComboBox*>(editor); QString value = box->currentText(); model->setData(index, value, Qt::EditRole); }; ui->tvEditor->setItemDelegateForColumn(columns.indexOf("prefix"), delegate); }
//*********************************************************** //* Load the completer with the list of valid tag names //*********************************************************** void TagEditorNewTag::loadCompleter() { QLOG_TRACE_IN() << typeid(*this).name(); QList<int> tagList; TagTable tagTable(global.db); QStringList tagNames; tagTable.getAll(tagList); for (qint32 i=0; i<tagList.size(); i++) { Tag t; QString guid; tagTable.getGuid(guid, tagList[i]); tagTable.get(t, guid); QString name = t.name; qint32 tagAccount = tagTable.owningAccount(tagList[i]); if (!currentTags.contains(name) && tagAccount == account) tagNames << name; } qSort(tagNames.begin(), tagNames.end(), caseInsensitiveLessThan); completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); completer->setCaseSensitivity(Qt::CaseInsensitive); setCompleter(completer); QStringListModel *model; model = (QStringListModel*)(completer->model()); if(model==NULL) model = new QStringListModel(); model->setStringList(tagNames); completer->setModel(model); QLOG_TRACE_OUT() << typeid(*this).name(); }
void QuickEdit::VisibilityDelegateSetup() { GenericDelegate* visibilityDelegate = new GenericDelegate(ui->tvEditor, false); visibilityDelegate->widgetCreator = [&](QWidget * parent) { QStringList visibilities = {"public" , "protected", "private", "package", "default"}; QComboBox* box = new QComboBox(parent); QStringListModel* model = new QStringListModel; model->setStringList(visibilities); box->setModel(model); box->setEditable(false); return box; }; visibilityDelegate->dataAccessor = [](QWidget * editor, const QModelIndex & index) { QString value = index.model()->data(index, Qt::EditRole).toString(); QComboBox *box = static_cast<QComboBox*>(editor); box->setCurrentText(value); }; visibilityDelegate->dataSetter = [](QWidget * editor,QAbstractItemModel* model, const QModelIndex &index) { QComboBox * box = static_cast<QComboBox*>(editor); QString value = box->currentText(); model->setData(index, value, Qt::EditRole); }; ui->tvEditor->setItemDelegateForColumn(columns.indexOf("visibility"), visibilityDelegate); }
SearchForm::SearchForm(QWidget *parent) : QWidget(parent), ui(new Ui::SearchForm) { ui->setupUi(this); table_name = "tabla"; c = new QCompleter(this); QStringList list; list<<"hola"<<"haber"<<"hay"<<"ha"<<"tambien"<<"tambor"<<"tata" <<"hola"<<"haber"<<"hay"<<"ha"<<"tambien"<<"tambor"<<"tata"; list.sort(); QStringListModel * model = new QStringListModel(); model->setStringList(list); c->setModelSorting(QCompleter::CaseInsensitivelySortedModel); c->setCaseSensitivity(Qt::CaseInsensitive); c->setWrapAround(false); c->setModel(model); ui->le_nombre->setCompleter(c); table_model = new QSqlRelationalTableModel(); table_model->setTable("e_marca"); table_model->select(); ui->tableView->setModel(table_model); }
QmitkLabelSetWidget::QmitkLabelSetWidget(QWidget *parent) : QWidget(parent), m_DataStorage(nullptr), m_Completer(nullptr), m_ToolManager(nullptr) { m_Controls.setupUi(this); m_ColorSequenceRainbow.GoToBegin(); m_ToolManager = mitk::ToolManagerProvider::GetInstance()->GetToolManager(); assert(m_ToolManager); m_Controls.m_LabelSearchBox->setAlwaysShowClearIcon(true); m_Controls.m_LabelSearchBox->setShowSearchIcon(true); QStringList completionList; completionList << ""; m_Completer = new QCompleter(completionList, this); m_Completer->setCaseSensitivity(Qt::CaseInsensitive); m_Controls.m_LabelSearchBox->setCompleter(m_Completer); connect(m_Controls.m_LabelSearchBox, SIGNAL(returnPressed()), this, SLOT(OnSearchLabel())); // connect( m_Controls.m_LabelSetTableWidget, SIGNAL(labelListModified(const QStringList&)), this, SLOT( // OnLabelListModified(const QStringList&)) ); // connect( m_Controls.m_LabelSetTableWidget, SIGNAL(mergeLabel(int)), this, SLOT( OnMergeLabel(int)) ); QStringListModel *completeModel = static_cast<QStringListModel *>(m_Completer->model()); completeModel->setStringList(GetLabelStringList()); m_Controls.m_LabelSearchBox->setEnabled(false); m_Controls.m_lblCaption->setText(""); InitializeTableWidget(); }
void ScriptWidget::showAutocompletion(const QStringList &list, const QString &prefix) { // do not show single autocompletion which is identical to existing prefix // or if it identical to prefix + '('. if (list.count() == 1) { if (list.at(0) == prefix || list.at(0) == (prefix + "(")) { return; } } // update list of completions QStringListModel * model = static_cast<QStringListModel *>(_completer->model()); model->setStringList(list); int currentLine = 0; int currentIndex = 0; _queryText->getCursorPosition(¤tLine, ¤tIndex); int physicalLine = currentLine - _queryText->firstVisibleLine(); // "physical" line number in text editor (not logical) int lineIndexLeft = _currentAutoCompletionInfo.lineIndexLeft(); QRect rect = _queryText->rect(); rect.setWidth(550); rect.setHeight(editorHeight(physicalLine + 1)); rect.moveLeft(charWidth() * lineIndexLeft + autocompletionBoxLeftPosition()); _completer->complete(rect); _completer->popup()->setCurrentIndex(_completer->completionModel()->index(0, 0)); _queryText->setIgnoreEnterKey(true); _queryText->setIgnoreTabKey(true); }
void OwncloudWizardResultPage::initializePage() { /* const QString localFolder = wizard()->property("localFolder").toString(); QString text; if( _remoteFolder == QLatin1String("/") || _remoteFolder.isEmpty() ) { text = tr("Your entire account is synced to the local folder <i>%1</i>") .arg(QDir::toNativeSeparators(localFolder)); } else { text = tr("%1 folder <i>%1</i> is synced to local folder <i>%2</i>") .arg(Theme::instance()->appNameGUI()) .arg(_remoteFolder).arg(QDir::toNativeSeparators(localFolder)); } _ui.localFolderLabel->setText( text ); */ QStringList folders = wizard()->property("localFolders").value<QStringList>(); foreach (const QString &str, folders) { qDebug()<<"folder selected : " << str; } QListView *list=_ui.listView; QStringListModel *model = new QStringListModel(this); model->setStringList(folders); //list->setViewMode(QListView::IconMode); list->setModel(model); }
void AppearanceSettings::loadThemes() { QStringList themeNames; QStringList installPaths = Qtopia::installPaths(); qDeleteAll(m_themes); m_themes.clear(); for (int i=0; i<installPaths.size(); i++) { QString path(installPaths[i] + "etc/themes/"); QDir dir; if (!dir.exists(path)) { qLog(UI) << "Theme style configuration path not found" << path.toLocal8Bit().data(); continue; } // read theme.conf files dir.setPath(path); dir.setNameFilters(QStringList("*.conf")); // No tr for (uint j=0; j<dir.count(); j++) { QString name = dir[j].mid(0, dir[j].length() - 5); // cut ".conf" Theme *theme = Theme::create(path + dir[j], name); if (theme) { m_themes << theme; themeNames << theme->name(); } } } themeNames << m_moreThemes; QStringListModel *model; model = qobject_cast<QStringListModel *>(m_themeCombo->model()); model->setStringList(themeNames); }
void MRichTextEditDialogsManager::initTextStylingDialog() { selectedFontSize = -1; selectedFontFamily = QString(); selectedFontColor = QColor(); if (dialogs.textStyles.first) { return; } //% "Text styles" dialogs.textStyles.first = new MDialog(qtTrId("qtn_comm_text_styles"),M::DoneButton); dialogs.textStyles.second = false; QGraphicsWidget *centralWidget = dialogs.textStyles.first->centralWidget(); MLayout *layout = new MLayout(centralWidget); MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(layout, Qt::Vertical); // Initialize Font Family combo box QFontDatabase fontDatabase; QStringList fontFamilyValues = fontDatabase.families(); // NOTE: black listing some ill-behaving fonts temporarily fontFamilyValues.removeAll("Webdings"); fontFamilyValues.removeAll("Wingdings"); fontFamilyCombo = new MComboBox(centralWidget); //% "Font" fontFamilyCombo->setTitle(qtTrId("qtn_comm_font")); QStringListModel *fontModel = new QStringListModel(centralWidget); fontModel->setStringList(fontFamilyValues); fontFamilyCombo->setItemModel(fontModel); policy->addItem(fontFamilyCombo); connect(fontFamilyCombo, SIGNAL(activated(QString)), this, SLOT(rememberFontFamily(QString))); // Initialize Font Size combo box fontSizeCombo = new MComboBox(centralWidget); //% "Font size" fontSizeCombo->setTitle(qtTrId("qtn_comm_font_size")); QStringListModel *sizeModel = new QStringListModel(centralWidget); fontSizeCombo->setItemModel(sizeModel); policy->addItem(fontSizeCombo); connect(fontSizeCombo, SIGNAL(activated(QString)), this, SLOT(rememberFontSize())); // Initialize Font Color item fontColorCombo = new MColorComboBox(centralWidget); //% "Font color" fontColorCombo->setTitle(qtTrId("qtn_comm_font_color_combobox")); policy->addItem(fontColorCombo); connect(fontColorCombo, SIGNAL(colorPicked(QColor)), this, SLOT(rememberFontColor(QColor))); // Selections are applied at pressing button "Done" connect(dialogs.textStyles.first, SIGNAL(accepted()), this, SLOT(applySelection())); }
void CodeEditor::setCompletionWords(const QStringList& words){ QStringList words2=words; words2=words2.toSet().toList(); qSort(words2.begin(),words2.end(),Global::stringLessThanCaseInSensitive); QStringListModel *model = qobject_cast<QStringListModel*>(completer_->model()); if(model){ model->setStringList(words2); } }
void OCamlSourceSearch::addToLRU() { QString v = text(); searched_pattern.removeAll( v ); searched_pattern.prepend( v ); QStringListModel *model = static_cast<QStringListModel*>( completer_p->model() ); model->setStringList( searched_pattern ); Options::set_opt( "SEARCHED_PATTERN", searched_pattern ) ; }
void QFontComboBoxPrivate::_q_updateModel() { Q_Q(QFontComboBox); const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts); const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts); QStringListModel *m = qobject_cast<QStringListModel *>(q->model()); if (!m) return; QFontFamilyDelegate *delegate = qobject_cast<QFontFamilyDelegate *>(q->view()->itemDelegate()); QFontDatabase::WritingSystem system = delegate ? delegate->writingSystem : QFontDatabase::Any; QFontDatabase fdb; QStringList list = fdb.families(system); QStringList result; int offset = 0; QFontInfo fi(currentFont); for (int i = 0; i < list.size(); ++i) { if (fdb.isPrivateFamily(list.at(i))) continue; if ((filters & scalableMask) && (filters & scalableMask) != scalableMask) { if (bool(filters & QFontComboBox::ScalableFonts) != fdb.isSmoothlyScalable(list.at(i))) continue; } if ((filters & spacingMask) && (filters & spacingMask) != spacingMask) { if (bool(filters & QFontComboBox::MonospacedFonts) != fdb.isFixedPitch(list.at(i))) continue; } result += list.at(i); if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + QLatin1String(" ["))) offset = result.count() - 1; } list = result; //we need to block the signals so that the model doesn't emit reset //this prevents the current index from changing //it will be updated just after this ///TODO: we should finda way to avoid blocking signals and have a real update of the model { const QSignalBlocker blocker(m); m->setStringList(list); } if (list.isEmpty()) { if (currentFont != QFont()) { currentFont = QFont(); emit q->currentFontChanged(currentFont); } } else { q->setCurrentIndex(offset); } }
void ConfigDialog::doClearCommandHistory() { logMessage("ConfigDialog::doClearCommandHistory()"); QSettings settings; settings.setValue("CommandDialog/RecentCommands", QStringList()); QStringListModel *model = dynamic_cast<QStringListModel *>(Util::completer()->model()); model->setStringList(QStringList()); QMessageBox::information(QApplication::activeWindow(), tr("Information"), tr("Command history was cleared successfully.")); }
AnimationList::AnimationList(QWidget *parent) : QWidget(parent), ui(new Ui::AnimationList) { ui->setupUi(this); QStringListModel* model = new QStringListModel(this); model->setStringList(availableAnimations); ui->availableAnimsListView->setModel(model); connect(ui->availableAnimsListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(onSelectionChanged())); }
void GraphicalArrayTest::test_signalEmmitting() { GraphicalArray * value = new GraphicalArray(); QLineEdit * lineEdit = findLineEdit(value); QStringListModel * model = findModel(value); QSignalSpy spy(value, SIGNAL(valueChanged())); // // 1. through setValue() // value->setValue( QString("Hello World") ); // when the value is a string value->setValue( QStringList() << "Hello" << "World" ); // when the value is a string list value->setValue( 42 ); // when the value is not valid (so signal emitted) // 2 signals should have been emitted QCOMPARE( spy.count(), 2 ); spy.clear(); // clear the model model->setStringList( QStringList() ); // // 2. by simulating keyboard events // // note: when validating, we wait 25 ms (last parameter) to let the event being processed // lineEdit->clear(); // value->show(); // make the value visible (it ignores keyboard events if not) // lineEdit->setFocus(Qt::PopupFocusReason); // QTest::keyClicks(lineEdit, "123" ); // QTest::keyClick(value, Qt::Key_Enter, Qt::NoModifier); // validate by pressing the 'ENTER' key on the keypad // QTest::keyClicks(lineEdit, "156" ); // QTest::keyClicks(lineEdit, "456" ); // QTest::keyClick(value, Qt::Key_Return, Qt::NoModifier); // validate by pressing the 'Return' key // 2 signals should have been emitted (one per validation) // QCOMPARE( spy.count(), 2 ); // QCOMPARE( model->stringList(), QStringList() << "123" << "156456"); // QCOMPARE( lineEdit->text(), QString() ); spy.clear(); // // 3. when committing // value->commit(); // 1 signal should have been emitted QCOMPARE( spy.count(), 1 ); delete value; }
int main(int argc, char* argv[]) { QApplication app(argc, argv); QStringListModel model; QStringList toBuy; toBuy << "butter" << "milk" << "cherries" << "bananas"; model.setStringList(toBuy); QListView view; view.setModel(&model); view.show(); return app.exec(); }
void AppearanceSettings::themeChanged(int index) { // Launch web browser for more themes if(index == (m_themeCombo->count() - 1)) { QProcess::execute("arora", QStringList() << "http://qtmoko.sourceforge.net/apps/category-themes.html"); QStringListModel *model = qobject_cast<QStringListModel *>(m_themeCombo->model()); QStringList oldThemes = model->stringList(); loadThemes(); // Find theme which was installed model = qobject_cast<QStringListModel *>(m_themeCombo->model()); QStringList newThemes = model->stringList(); for(int i = 0; i < newThemes.count(); i++) { if(oldThemes.count() <= i || oldThemes[i] != newThemes[i]) { m_prevIndex = i; break; } } m_themeCombo->setCurrentIndex(m_prevIndex); return; } Theme *theme = m_themes.value(index, 0); if (!theme) return; m_prevIndex = index; QStringListModel *model; model = qobject_cast<QStringListModel *>(m_colorCombo->model()); model->setStringList(theme->colorSchemeNames()); m_colorCombo->setCurrentIndex(theme->currentColorIndex()); model = qobject_cast<QStringListModel *>(m_backgroundCombo->model()); model->setStringList(theme->backgrounds()); m_backgroundCombo->setCurrentIndex(theme->currentBackgroundIndex()); }
void QScriptDebuggerLocalsWidgetPrivate::_q_onCompletionTaskFinished() { Q_Q(QScriptDebuggerLocalsWidget); QScriptCompletionTaskInterface *task = 0; task = qobject_cast<QScriptCompletionTaskInterface*>(q_func()->sender()); if (!completingEditor) { task->deleteLater(); return; } if (task->resultCount() == 1) { // do the completion right away QString completion = task->resultAt(0); completion.append(task->appendix()); QString tmp = completingEditor->text(); tmp.remove(task->position(), task->length()); tmp.insert(task->position(), completion); completingEditor->setText(tmp); completingEditor = 0; } else if (task->resultCount() > 1) { // popup completion if (!completer) { completer = new QCompleter(q); completer->setCompletionMode(QCompleter::PopupCompletion); completer->setCaseSensitivity(Qt::CaseSensitive); completer->setWrapAround(false); QObject::connect(completer, SIGNAL(activated(const QString &)), q, SLOT(_q_insertCompletion(const QString &))); } QStringListModel *model = qobject_cast<QStringListModel*>(completer->model()); if (!model) { model = new QStringListModel(q); completer->setModel(model); } QStringList strings; for (int i = 0; i < task->resultCount(); ++i) strings.append(task->resultAt(i)); model->setStringList(strings); QString prefix = completingEditor->text().mid(task->position(), task->length()); completer->setCompletionPrefix(prefix); completingEditor->setCompleter(completer); // we want to handle the insertion ourselves QObject::disconnect(completer, 0, completingEditor, 0); completer->complete(); } task->deleteLater(); }
void AnimationList::removeSelectedItems() { QStringListModel* model = dynamic_cast<QStringListModel*>(ui->availableAnimsListView->model()); QItemSelectionModel* selModel = ui->availableAnimsListView->selectionModel(); int count = selModel->selectedIndexes().count(); for(int i=0; i<count; i++) { int index = selModel->selectedIndexes().at(0).row(); availableAnimations.removeAt(index); } model->setStringList(availableAnimations); //TODO: bleh! onSelectionChanged(); //must be called explicitely }
void Settings::loadSettings() { QSettings settings; if (ui.patternListView->model() == NULL) { QStringListModel* model = new QStringListModel(); model->setStringList(settings.value(SETTINGS_PATTERNS).toStringList()); ui.patternListView->setModel(model); } else { ((QStringListModel*) ui.patternListView->model())->setStringList(settings.value(SETTINGS_PATTERNS).toStringList()); } if (ui.directoryListView->model() == NULL) { QStringListModel* model = new QStringListModel(); model->setStringList(settings.value(SETTINGS_DIRECTORIES).toStringList()); ui.directoryListView->setModel(model); } else { ((QStringListModel*) ui.directoryListView->model())->setStringList(settings.value(SETTINGS_DIRECTORIES).toStringList()); } ui.matchCaseCheckBox->setChecked(settings.value(SETTINGS_MATCH_CASE).toBool()); ui.dateMatchGroupBox->setChecked(settings.value(SETTINGS_DATE_MATCH).toBool()); if (settings.value(SETTINGS_DATE_OPTION).toInt() == 0) { ui.dateOption0RadioButton->setChecked(true); ui.dateOption1RadioButton->setChecked(false); } else { ui.dateOption0RadioButton->setChecked(false); ui.dateOption1RadioButton->setChecked(true); } ui.dateOption1dateTimeEdit->setDateTime(settings.value(SETTINGS_DATE).toDateTime()); ui.patternEdit->clear(); connect(ui.patternListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(changeDeletePatternButtonState())); connect(ui.directoryListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(changeDeleteDirectoryButtonState())); }
void CFX2DCsvImportDialog::addCsvFile() { QStringList selFiles = QFileDialog::getOpenFileNames (this,tr("open csv file")//打开csv文件 ,QString() ,tr("Ansys CFX csv file(*.csv)")//Ansys CFX csv file(*.csv) ); if(selFiles.size ()<=0) return; QStringListModel* model = getStringListModel (); if(!model) return; QStringList slist = model->stringList (); slist += selFiles; model->setStringList (slist); }