void tst_QDataWidgetMapper::setData() { QDataWidgetMapper mapper; QAbstractItemModel *model = testModel(&mapper); mapper.setModel(model); QLineEdit edit1; QLineEdit edit2; QLineEdit edit3; mapper.addMapping(&edit1, 0); mapper.addMapping(&edit2, 1); mapper.addMapping(&edit3, 0, "text"); mapper.toFirst(); QCOMPARE(edit1.text(), QString("item 0 0")); QCOMPARE(edit2.text(), QString("item 0 1")); QCOMPARE(edit3.text(), QString("item 0 0")); edit1.setText("new text"); mapper.submit(); QCOMPARE(model->data(model->index(0, 0)).toString(), QString("new text")); edit3.setText("more text"); mapper.submit(); QCOMPARE(model->data(model->index(0, 0)).toString(), QString("more text")); }
void test_Iterate_UserBased_Predictor() { clock_t begin,end; string train_data = "E:/data/resys/corpus/1/train/base"; string test_data = "E:/data/resys/corpus/1/test/u1.test"; FileDataReader train_reader = FileDataReader(train_data); FileDataReader test_reader = FileDataReader(test_data); int n_user, n_item, n_rating; n_user = 943; n_item = 1682; n_rating = 80000; UserModel trainModel(n_user,n_item,n_rating); UserModel testModel(n_user,n_item,20000); UserModel resultModel(n_user,n_item,20000); if(train_reader.readData(trainModel) && test_reader.readData(testModel)) { int min_com = 0; double min_sim = 0.00001; int shrink_parameter = 25; Similarity_Shrinking shrinker(min_com,min_sim,shrink_parameter); Pearson_Similarity similarity(shrinker); UserBased_Predictor predictor = UserBased_Predictor(30,0); begin = clock(); predictor.train(trainModel); end = clock(); cout << "Train time: " << (end - begin) * 1.0 / CLOCKS_PER_SEC << endl; begin = end; predictor.predictAll(trainModel,testModel,resultModel); end = clock(); cout << "Predict time: " << (end - begin) * 1.0 / CLOCKS_PER_SEC << endl; double rmse = evl_rmse(testModel, resultModel); cout << "RMSE: " << rmse << endl; } }
void tst_QDataWidgetMapper::currentIndexChanged() { QDataWidgetMapper mapper; QAbstractItemModel *model = testModel(&mapper); mapper.setModel(model); QSignalSpy spy(&mapper, SIGNAL(currentIndexChanged(int))); mapper.toFirst(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst().at(0).toInt(), 0); mapper.toNext(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst().at(0).toInt(), 1); mapper.setCurrentIndex(7); QCOMPARE(spy.count(), 1); QCOMPARE(spy.takeFirst().at(0).toInt(), 7); mapper.setCurrentIndex(-1); QCOMPARE(spy.count(), 0); mapper.setCurrentIndex(42); QCOMPARE(spy.count(), 0); }
void tst_QDataWidgetMapper::addMapping() { QDataWidgetMapper mapper; QAbstractItemModel *model = testModel(&mapper); mapper.setModel(model); QLineEdit edit1; mapper.addMapping(&edit1, 0); mapper.toFirst(); QCOMPARE(edit1.text(), QString("item 0 0")); mapper.addMapping(&edit1, 1); mapper.toFirst(); QCOMPARE(edit1.text(), QString("item 0 1")); QCOMPARE(mapper.mappedSection(&edit1), 1); edit1.clear(); mapper.removeMapping(&edit1); mapper.toFirst(); QCOMPARE(edit1.text(), QString()); { QLineEdit edit2; mapper.addMapping(&edit2, 2); mapper.toFirst(); QCOMPARE(edit2.text(), QString("item 0 2")); } // let the edit go out of scope QCOMPARE(mapper.mappedWidgetAt(2), (QWidget *)0); mapper.toLast(); }
void test_Fill_Predictor() { string train_data = "E:/data/resys/corpus/1/train/base"; string test_data = "E:/data/resys/corpus/1/test/u1.test"; FileDataReader train_reader = FileDataReader(train_data); FileDataReader test_reader = FileDataReader(test_data); int n_user, n_item, n_rating; n_user = 943; n_item = 1682; n_rating = 80000; UserModel userModel(n_user,n_item,n_rating); UserModel testModel(n_user,n_item,20000); UserModel resultModel(n_user,n_item,20000); ItemModel itemModel(n_user,n_item,n_rating); if(train_reader.readData(userModel) && train_reader.readData(itemModel) && test_reader.readData(testModel)) { int min_com = 0; double min_sim = 0.00001; int shrink_parameter = 25; Similarity_Shrinking shrinker(min_com,min_sim,shrink_parameter); Pearson_Similarity similarity(shrinker); UserBased_Predictor predictor = UserBased_Predictor(similarity,30,0); min_com = 30; min_sim = 0.3; shrink_parameter = 40; NeighborCollection *item_nbs = new NeighborCollection[n_item+1]; vector<FillObj> *u_fobjs = new vector<FillObj>[n_user+1]; Similarity_Shrinking shrinker2(min_com,min_sim,shrink_parameter); Pearson_Similarity similarity2(shrinker2); similarity2.similarity(itemModel,item_nbs,1); //similarity2.similarity(itemModel,item_nbs,1); Fill_Predictor fill_predictor; //int fill_count = fill_predictor.cal_fill_objs(userModel,item_nbs,u_fobjs,min_com); int fill_count = fill_predictor.cal_fill_objs(userModel,item_nbs,u_fobjs,min_sim); cout << fill_count << endl; fill_predictor.fill(predictor,userModel,u_fobjs); predictor.train(userModel); predictor.predictAll(userModel,testModel,resultModel); double rmse = evl_rmse(testModel, resultModel); cout << "RMSE: " << rmse << endl; double mae = evl_mae(testModel, resultModel); cout << "MAE: " << mae << endl; } }
void tst_QDataWidgetMapper::comboBox() { QDataWidgetMapper mapper; QAbstractItemModel *model = testModel(&mapper); mapper.setModel(model); mapper.setSubmitPolicy(QDataWidgetMapper::ManualSubmit); QComboBox readOnlyBox; readOnlyBox.setEditable(false); readOnlyBox.addItem("read only item 0"); readOnlyBox.addItem("read only item 1"); readOnlyBox.addItem("read only item 2"); QComboBox readWriteBox; readWriteBox.setEditable(true); readWriteBox.addItem("read write item 0"); readWriteBox.addItem("read write item 1"); readWriteBox.addItem("read write item 2"); // populat the combo boxes with data mapper.addMapping(&readOnlyBox, 0, "currentIndex"); mapper.addMapping(&readWriteBox, 1, "currentText"); mapper.toFirst(); QCOMPARE(readOnlyBox.currentText(), QString("read only item 0")); QCOMPARE(readWriteBox.currentText(), QString("read write item 0")); // set some new values on the boxes readOnlyBox.setCurrentIndex(1); readWriteBox.setEditText("read write item y"); mapper.submit(); // make sure the new values are in the model QCOMPARE(model->data(model->index(0, 0)).toInt(), 1); QCOMPARE(model->data(model->index(0, 1)).toString(), QString("read write item y")); // now test updating of the widgets model->setData(model->index(0, 0), 2, Qt::EditRole); model->setData(model->index(0, 1), QString("read write item z"), Qt::EditRole); QCOMPARE(readOnlyBox.currentIndex(), 2); QEXPECT_FAIL("", "See task 125493 and QTBUG-428", Abort); QCOMPARE(readWriteBox.currentText(), QString("read write item z")); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); ::CoInitialize(NULL); ::CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_DELEGATE, NULL, 0, NULL); ldsmnTypeModel = new TypeLoodsmanModel(); ldsmnLinkModel = new LinkLoodsmanModel(); ldsmnAttrModel = new AttrLoodsmanModel(); ldsmnEditAttrModel = new AttrEditLoodsmanModel(); connect(pshBtnTestProject,SIGNAL(clicked()),this, SLOT(listProject())); connect(pshBtnModelTest,SIGNAL(clicked()),this, SLOT(testModel())); connect(pshBtnTypeTest,SIGNAL(clicked()),this, SLOT(testType())); connect(pshBtnLinkTest,SIGNAL(clicked()),this, SLOT(testLink())); connect(pshBtnStatTest,SIGNAL(clicked()),this, SLOT(testStat())); connect(pshBtnAttrTest,SIGNAL(clicked()),this, SLOT(testAttr())); }
void tst_QDataWidgetMapper::changingValues() { QDataWidgetMapper mapper; QAbstractItemModel *model = testModel(&mapper); mapper.setModel(model); QLineEdit edit1; mapper.addMapping(&edit1, 0); mapper.toFirst(); QCOMPARE(edit1.text(), QString("item 0 0")); QLineEdit edit2; mapper.addMapping(&edit2, 0, "text"); mapper.toFirst(); QCOMPARE(edit2.text(), QString("item 0 0")); model->setData(model->index(0, 0), QString("changed")); QCOMPARE(edit1.text(), QString("changed")); QCOMPARE(edit2.text(), QString("changed")); }
void test_ItemBased_Predictor() { clock_t begin,end; string train_data = "E:/data/resys/corpus/1/train/base"; string test_data = "E:/data/resys/corpus/1/test/u1.test"; FileDataReader train_reader = FileDataReader(train_data); FileDataReader test_reader = FileDataReader(test_data); int n_user, n_item, n_rating; n_user = 943; n_item = 1682; n_rating = 80000; ItemModel trainModel(n_user,n_item,n_rating); ItemModel testModel(n_user,n_item,20000); ItemModel resultModel(n_user,n_item,20000); double *userRanks = new double[n_user+1]; string filepath = "E:/data/resys/corpus/1/user_com_ranks.txt"; train_reader.readUserComRank(userRanks,filepath); if(train_reader.readData(trainModel) && test_reader.readData(testModel)) { int min_com = 0; double min_sim = 0.0; int shrink_parameter = 30; Similarity_Shrinking shrinker(min_com,min_sim,shrink_parameter); Pearson_Similarity similarity(shrinker); ItemBased_Predictor predictor = ItemBased_Predictor(similarity,30,0); begin = clock(); //predictor.train(trainModel); predictor.train(trainModel,userRanks); end = clock(); cout << "Train time: " << (end - begin) * 1.0 / CLOCKS_PER_SEC << endl; begin = end; predictor.predictAll(trainModel,testModel,resultModel); end = clock(); cout << "Predict time: " << (end - begin) * 1.0 / CLOCKS_PER_SEC << endl; double rmse = evl_rmse(testModel, resultModel); cout << "RMSE: " << rmse << endl; double mae = evl_mae(testModel, resultModel); cout << "MAE: " << mae << endl; } }
Clause* HCComponent::getClauseToPropagate( Learning& learning ) { assert( unfoundedSet.empty() ); if( hasToTestModel ) testModel(); hasToTestModel = false; if( !unfoundedSet.empty() ) { trace_msg( modelchecker, 1, "Learning unfounded set rule for component " << *this ); Clause* loopFormula = learning.learnClausesFromDisjunctiveUnfoundedSet( unfoundedSet ); trace_msg( modelchecker, 1, "Adding loop formula: " << *loopFormula ); unfoundedSet.clear(); if( !( wasp::Options::forwardPartialChecks ) ) solver.setAfterConflictPropagator( this ); solver.onLearningALoopFormulaFromModelChecker(); return loopFormula; } return NULL; }
void tst_QDataWidgetMapper::mappedWidgetAt() { QDataWidgetMapper mapper; QAbstractItemModel *model = testModel(&mapper); mapper.setModel(model); QLineEdit lineEdit1; QLineEdit lineEdit2; QCOMPARE(mapper.mappedWidgetAt(432312), (QWidget*)0); mapper.addMapping(&lineEdit1, 1); mapper.addMapping(&lineEdit2, 2); QCOMPARE(mapper.mappedWidgetAt(1), static_cast<QWidget *>(&lineEdit1)); QCOMPARE(mapper.mappedWidgetAt(2), static_cast<QWidget *>(&lineEdit2)); mapper.addMapping(&lineEdit2, 4242); QCOMPARE(mapper.mappedWidgetAt(2), (QWidget*)0); QCOMPARE(mapper.mappedWidgetAt(4242), static_cast<QWidget *>(&lineEdit2)); }
SamView::SamView(QWidget *parent, Qt::WFlags flags) : KXmlGuiWindow(parent, flags), m_startCompilationAfterAdaption(false), m_startTestAfterCompile(false), m_startTestAfterAdaption(false), m_exportAfterTest(false), m_dirty(false), m_creationCorpus(0), m_reportParameters(0), modelCompiler(0), modelCompilationAdapter(0), barGraph(0) { KGlobal::locale()->insertCatalog("simonlib"); ui.setupUi(this); ui.qpPlot->hide(); barGraphLegend = new QwtLegend(ui.qpPlot); ui.qpPlot->insertLegend(barGraphLegend); #if QWT_VERSION >= 0x060100 connect(ui.qpPlot, SIGNAL(legendDataChanged(const QVariant &, const QList<QwtLegendData>&)), barGraphLegend, SLOT(updateLegend(const QVariant&, const QList<QwtLegendData>&))); barGraphLegend->show(); ui.qpPlot->updateLegend(); #endif initGraph(); ui.saTestConfigurations->setWidget(ui.wgTestConfigurations); KAction* getPathsFromSimon = new KAction(this); getPathsFromSimon->setText(i18n("Modify Simon's model")); getPathsFromSimon->setStatusTip(i18n("Manage Simon's current model with SSC")); getPathsFromSimon->setIcon(KIcon("simon")); actionCollection()->addAction("getPathsFromSimon", getPathsFromSimon); connect(getPathsFromSimon, SIGNAL(triggered(bool)), this, SLOT(getBuildPathsFromSimon())); KAction* recompile = new KAction(this); recompile->setText(i18n("Build model")); recompile->setStatusTip(i18n("Build the currently open model.")); recompile->setIcon(KIcon("view-refresh")); recompile->setShortcut(Qt::CTRL + Qt::Key_F5); actionCollection()->addAction("compileModel", recompile); connect(recompile, SIGNAL(triggered(bool)), this, SLOT(compileModel())); KAction* test= new KAction(this); test->setText(i18n("Test model")); test->setStatusTip(i18n("Test the model.")); test->setIcon(KIcon("chronometer")); actionCollection()->addAction("testModel", test); connect(test, SIGNAL(triggered(bool)), this, SLOT(testModel())); KAction* testResults= new KAction(this); testResults->setText(i18n("Test results")); testResults->setStatusTip(i18n("Display the test results.")); testResults->setIcon(KIcon("view-pim-tasks")); actionCollection()->addAction("testResults", testResults); connect(testResults, SIGNAL(triggered(bool)), this, SLOT(switchToTestResults())); KAction* exportTestResults = new KAction(this); exportTestResults->setText(i18n("Export test result")); exportTestResults->setStatusTip(i18n("Export the test results to a file.")); exportTestResults->setIcon(KIcon("document-export")); actionCollection()->addAction("exportTestResults", exportTestResults); connect(exportTestResults, SIGNAL(triggered(bool)), this, SLOT(exportTestResults())); m_user = "******"; KStandardAction::openNew(this, SLOT(newProject()), actionCollection()); KStandardAction::save(this, SLOT(save()), actionCollection()); KStandardAction::saveAs(this, SLOT(saveAs()), actionCollection()); KStandardAction::open(this, SLOT(load()), actionCollection()); KStandardAction::preferences(this, SLOT(showConfig()), actionCollection()); KStandardAction::quit(this, SLOT(close()), actionCollection()); setupGUI(); connect(ui.cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(backendChanged())); connect(ui.pbCompileModel, SIGNAL(clicked()), this, SLOT(compileModel())); connect(ui.pbTestModel, SIGNAL(clicked()), this, SLOT(testModel())); connect(ui.pbImportRecognitionSamples, SIGNAL(clicked()), this, SLOT(importRecognitionSamples())); connect(ui.rbDynamicModel, SIGNAL(toggled(bool)), this, SLOT(setDirty())); connect(ui.rbStaticModel, SIGNAL(toggled(bool)), this, SLOT(setDirty())); connect(ui.urOutputModel, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.urPromptsBasePath, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.urLexicon, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.urGrammar, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.urVocabulary, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.urPrompts, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.urBaseModel, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.leScriptPrefix, SIGNAL(textChanged(QString)), this, SLOT(setDirty())); connect(ui.sbSampleRate, SIGNAL(valueChanged(int)), this, SLOT(setDirty())); connect(ui.pbExtractSimonModel, SIGNAL(clicked()), this, SLOT(extractSimonModel())); ui.urOutputModel->setMode(KFile::File|KFile::LocalOnly); ui.urPromptsBasePath->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly); ui.urLexicon->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly); ui.urGrammar->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly); ui.urVocabulary->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly); ui.urPrompts->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly); ui.urBaseModel->setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly); #ifdef BACKEND_TYPE_JHTK ui.cbType->removeItem(0); ui.swModelInputFiles->removeWidget(ui.pgSphinxInputFiles); if ((KCmdLineArgs::parsedArgs()->isSet("m")) && (KCmdLineArgs::parsedArgs()->getOption("m") == "sphinx")) { KMessageBox::sorry(this, i18n("SAM was built without SPHINX support.")); exit(0); } #endif if (KCmdLineArgs::parsedArgs()->isSet("m")) ui.cbType->setCurrentIndex(KCmdLineArgs::parsedArgs()->getOption("m") == "htk" ? 1 : 0); backendChanged(); connect(ui.pbAddTestConfiguration, SIGNAL(clicked()), this, SLOT(addTestConfiguration())); connect(ui.pbSerializeScenarios, SIGNAL(clicked()), this, SLOT(serializeScenarios())); connect(ui.pbSerializePrompts, SIGNAL(clicked()), this, SLOT(serializePrompts())); connect(ui.pbCancelBuildModel, SIGNAL(clicked()), this, SLOT(abortModelCompilation())); connect(ui.pbCancelTestModel, SIGNAL(clicked()), this, SLOT(abortModelTest())); connect(ui.pbSaveCompleteBuildlog, SIGNAL(clicked()), this, SLOT(storeBuildLog())); if (KCmdLineArgs::parsedArgs()->count() > 0) { QString loadPath = KCmdLineArgs::parsedArgs()->url(0).toLocalFile(); kDebug() << "Load path: " << loadPath; if (!loadPath.isEmpty()) load(loadPath); } bool autoTestModel = KCmdLineArgs::parsedArgs()->isSet("t"); if (KCmdLineArgs::parsedArgs()->isSet("s")) { getBuildPathsFromSimon(); //async if (KCmdLineArgs::parsedArgs()->isSet("c")) { m_startCompilationAfterAdaption = true; if (autoTestModel) { m_startTestAfterCompile = true; } } else if (autoTestModel) { m_startTestAfterAdaption = true; } } else { if (KCmdLineArgs::parsedArgs()->isSet("c")) { compileModel(); if (autoTestModel) m_startTestAfterCompile = true; } else if (autoTestModel) testModel(); } if (KCmdLineArgs::parsedArgs()->isSet("e")) m_exportAfterTest = true; }
void tst_QDataWidgetMapper::navigate() { QDataWidgetMapper mapper; QAbstractItemModel *model = testModel(&mapper); mapper.setModel(model); QLineEdit edit1; QLineEdit edit2; QLineEdit edit3; mapper.addMapping(&edit1, 0); mapper.toFirst(); mapper.addMapping(&edit2, 1); mapper.addMapping(&edit3, 2); QCOMPARE(edit1.text(), QString("item 0 0")); QVERIFY(edit2.text().isEmpty()); QVERIFY(edit3.text().isEmpty()); QVERIFY(mapper.submit()); edit2.setText(QString("item 0 1")); edit3.setText(QString("item 0 2")); QVERIFY(mapper.submit()); mapper.toFirst(); //this will repopulate QCOMPARE(edit1.text(), QString("item 0 0")); QCOMPARE(edit2.text(), QString("item 0 1")); QCOMPARE(edit3.text(), QString("item 0 2")); mapper.toFirst(); QCOMPARE(edit1.text(), QString("item 0 0")); QCOMPARE(edit2.text(), QString("item 0 1")); QCOMPARE(edit3.text(), QString("item 0 2")); mapper.toPrevious(); // should do nothing QCOMPARE(edit1.text(), QString("item 0 0")); QCOMPARE(edit2.text(), QString("item 0 1")); QCOMPARE(edit3.text(), QString("item 0 2")); mapper.toNext(); QCOMPARE(edit1.text(), QString("item 1 0")); QCOMPARE(edit2.text(), QString("item 1 1")); QCOMPARE(edit3.text(), QString("item 1 2")); mapper.toLast(); QCOMPARE(edit1.text(), QString("item 9 0")); QCOMPARE(edit2.text(), QString("item 9 1")); QCOMPARE(edit3.text(), QString("item 9 2")); mapper.toNext(); // should do nothing QCOMPARE(edit1.text(), QString("item 9 0")); QCOMPARE(edit2.text(), QString("item 9 1")); QCOMPARE(edit3.text(), QString("item 9 2")); mapper.setCurrentIndex(4); QCOMPARE(edit1.text(), QString("item 4 0")); QCOMPARE(edit2.text(), QString("item 4 1")); QCOMPARE(edit3.text(), QString("item 4 2")); mapper.setCurrentIndex(-1); // should do nothing QCOMPARE(edit1.text(), QString("item 4 0")); QCOMPARE(edit2.text(), QString("item 4 1")); QCOMPARE(edit3.text(), QString("item 4 2")); mapper.setCurrentIndex(10); // should do nothing QCOMPARE(edit1.text(), QString("item 4 0")); QCOMPARE(edit2.text(), QString("item 4 1")); QCOMPARE(edit3.text(), QString("item 4 2")); mapper.setCurrentModelIndex(QModelIndex()); // should do nothing QCOMPARE(edit1.text(), QString("item 4 0")); QCOMPARE(edit2.text(), QString("item 4 1")); QCOMPARE(edit3.text(), QString("item 4 2")); mapper.setCurrentModelIndex(model->index(6, 0)); QCOMPARE(edit1.text(), QString("item 6 0")); QCOMPARE(edit2.text(), QString("item 6 1")); QCOMPARE(edit3.text(), QString("item 6 2")); /* now try vertical navigation */ mapper.setOrientation(Qt::Vertical); mapper.addMapping(&edit1, 0); mapper.addMapping(&edit2, 1); mapper.addMapping(&edit3, 2); mapper.toFirst(); QCOMPARE(edit1.text(), QString("item 0 0")); QCOMPARE(edit2.text(), QString("item 1 0")); QCOMPARE(edit3.text(), QString("item 2 0")); mapper.toPrevious(); // should do nothing QCOMPARE(edit1.text(), QString("item 0 0")); QCOMPARE(edit2.text(), QString("item 1 0")); QCOMPARE(edit3.text(), QString("item 2 0")); mapper.toNext(); QCOMPARE(edit1.text(), QString("item 0 1")); QCOMPARE(edit2.text(), QString("item 1 1")); QCOMPARE(edit3.text(), QString("item 2 1")); mapper.toLast(); QCOMPARE(edit1.text(), QString("item 0 9")); QCOMPARE(edit2.text(), QString("item 1 9")); QCOMPARE(edit3.text(), QString("item 2 9")); mapper.toNext(); // should do nothing QCOMPARE(edit1.text(), QString("item 0 9")); QCOMPARE(edit2.text(), QString("item 1 9")); QCOMPARE(edit3.text(), QString("item 2 9")); mapper.setCurrentIndex(4); QCOMPARE(edit1.text(), QString("item 0 4")); QCOMPARE(edit2.text(), QString("item 1 4")); QCOMPARE(edit3.text(), QString("item 2 4")); mapper.setCurrentIndex(-1); // should do nothing QCOMPARE(edit1.text(), QString("item 0 4")); QCOMPARE(edit2.text(), QString("item 1 4")); QCOMPARE(edit3.text(), QString("item 2 4")); mapper.setCurrentIndex(10); // should do nothing QCOMPARE(edit1.text(), QString("item 0 4")); QCOMPARE(edit2.text(), QString("item 1 4")); QCOMPARE(edit3.text(), QString("item 2 4")); mapper.setCurrentModelIndex(QModelIndex()); // should do nothing QCOMPARE(edit1.text(), QString("item 0 4")); QCOMPARE(edit2.text(), QString("item 1 4")); QCOMPARE(edit3.text(), QString("item 2 4")); mapper.setCurrentModelIndex(model->index(0, 6)); QCOMPARE(edit1.text(), QString("item 0 6")); QCOMPARE(edit2.text(), QString("item 1 6")); QCOMPARE(edit3.text(), QString("item 2 6")); }