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); }
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 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 QQBoardsSettings::addBouchot() { QQBouchotSettingsDialog bouchotSettingsDialog(this); bouchotSettingsDialog.setGroups(m_listGroups); bouchotSettingsDialog.setNames(m_listNames); if(bouchotSettingsDialog.exec() == QDialog::Accepted) { QQBouchot::QQBouchotSettings bSettings = bouchotSettingsDialog.bouchotSettings(); QString bouchotName = bouchotSettingsDialog.bouchotName(); if(m_listNames.contains(bouchotName)) { qWarning() << "Trying to insert a bouchot with an already existing name, that's forbidden"; } else { m_listNames.append(bouchotName); if(! m_listGroups.contains(bSettings.group())) m_listGroups.append(bSettings.group()); QStringListModel *model = (QStringListModel *) ui->bouchotListView->model(); int numRow = model->rowCount(); model->insertRows(numRow,1); model->setData(model->index(numRow), QVariant(bouchotName)); m_newBouchots.insert(bouchotName, bSettings); m_oldBouchots.removeAll(bouchotName); } } }
void MainWindowMenuPlan::cleanListViewING() //Se borra el listview con los ingredientes mostrados en el apartado Ingredientes { QStringListModel *model = new QStringListModel(); model->removeRows(0, model->rowCount()); ui->listView_Ingredientes->setModel(model); delete model; }
void ConversationPage::folderSelected(const QModelIndex& index) { MPopupList *popupList = qobject_cast<MPopupList *>(sender()); if (!popupList) return; QStringListModel *model = (QStringListModel *) popupList->itemModel(); QStringList folders = model->stringList(); m_downloadFolder = QDir::homePath() + "/" + folders[index.row()]; QMailMessagePart::Location location = m_selectedAttachment.location(); location.setContainingMessageId(m_id); if (m_selectedAttachment.hasBody()) { // The content has already been downloaded to local device. No need to retrieve part from server. emit downloadCompleted(); return; } m_retrievalAction = new QMailRetrievalAction(this); connect(m_retrievalAction, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(activityChanged(QMailServiceAction::Activity))); m_retrievalAction->retrieveMessagePart(location); }
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); }
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); }
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 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 &))); }
//*********************************************************** //* 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 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); }
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 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 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 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 PluginGame5GenerateSituationDialog::onPluginAction() { QStringList funList = parseModelFUN(); QStringListModel* stringModel = (QStringListModel*)lineEditCustom->completer()->model(); stringModel->setStringList(funList); exec(); }
QStringList CodeEditor::completionWords() const{ QStringList words; QStringListModel *model = qobject_cast<QStringListModel*>(completer_->model()); if(model){ words=model->stringList(); } return words; }
void CFX2DCsvImportDialog::removeFile() { QModelIndex index = ui->listView->currentIndex (); if(!index.isValid ()) return; QStringListModel* model = getStringListModel (); model->removeRow (index.row ()); }
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 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 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 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); } }
Login::Login(QWidget *parent) : QWidget(parent), ui(new Ui::Login) { ui->setupUi(this); QIcon icon; icon.addFile(QString::fromUtf8(":image/icon.png"), QSize(), QIcon::Normal, QIcon::Off); this->setWindowIcon(icon); group = new QButtonGroup(this); QStringListModel * model = AdminDAO::getAdminDAOInstance()->getUsernames(); QString img = ":/users/0.jpg"; QRadioButton * tmpbutton = ui->userButton_0; for (int i = 0; i < model->rowCount(); i++) { img = QString(":/users/%1.jpg").arg(i); switch (i) { case 0: tmpbutton = ui->userButton_0; break; case 1: tmpbutton = ui->userButton_1; break; case 2: tmpbutton = ui->userButton_2; break; case 3: tmpbutton = ui->userButton_3; break; case 4: tmpbutton = ui->userButton_4; break; case 5: tmpbutton = ui->userButton_5; break; default: tmpbutton = ui->userButton_0; break; } tmpbutton->setIcon(QPixmap(img)); tmpbutton->setIconSize(QSize(40,40)); } group->addButton(ui->userButton_0); group->addButton(ui->userButton_1); group->addButton(ui->userButton_2); group->addButton(ui->userButton_3); group->addButton(ui->userButton_4); group->addButton(ui->userButton_5); group->setId(ui->userButton_0, 0); group->setId(ui->userButton_1, 1); group->setId(ui->userButton_2, 2); group->setId(ui->userButton_3, 3); group->setId(ui->userButton_4, 4); group->setId(ui->userButton_5, 5); connect(ui->userButton_0, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_1, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_2, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_3, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_4, SIGNAL(clicked()), this, SLOT(sellectOneUser())); connect(ui->userButton_5, SIGNAL(clicked()), this, SLOT(sellectOneUser())); }
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 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 ClickToFlashPlugin::configure() { QDialog dialog; Ui_ClickToFlashSettings ui; ui.setupUi(&dialog); QStringListModel *model = new QStringListModel(m_whitelist, ui.whitelist); ui.whitelist->setModel(model); if (dialog.exec() == QDialog::Accepted) { m_whitelist = model->stringList(); save(); } }
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; }
QHash<QString,QVariant> getReparse() { QHash<QString,QVariant> data; int g=0; for(int i=0;i<8;++i){ g=(g<<1)+Shield::shieldG[i]; } data["/Shield/Group"]=g; data["/Shield/Regexp"]=rm->stringList(); data["/Shield/Sender"]=sm->stringList(); data["/Shield/Limit"]=Config::getValue("/Shield/Limit",5); return data; }