Skip to content
Snippets Groups Projects
Commit 6485acc3 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Bug ifx in FitParameterAbsModel while calculating index of parent

parent 740374e9
No related branches found
No related tags found
No related merge requests found
......@@ -34,8 +34,8 @@ void FitModelHelper::createFitParameter(FitParameterContainerItem *container, Pa
SessionItem *link = fitPar->model()->insertNewItem(Constants::FitParameterLinkType, fitPar->index());
Q_ASSERT(link);
link->setItemValue(FitParameterLinkItem::P_LINK, "xxx");
SessionItem *link2 = fitPar->model()->insertNewItem(Constants::FitParameterLinkType, fitPar->index());
link2->setItemValue(FitParameterLinkItem::P_LINK, "yyy");
// SessionItem *link2 = fitPar->model()->insertNewItem(Constants::FitParameterLinkType, fitPar->index());
// link2->setItemValue(FitParameterLinkItem::P_LINK, "yyy");
if(parameterItem) {
......
......@@ -95,8 +95,8 @@ QModelIndex FitParameterAbsModel::parent(const QModelIndex &child) const
if (SessionItem *parent_item = child_item->parent()) {
if(parent_item->modelType()==Constants::FitParameterLinkType) {
// qDebug() << "FitParameterAbsModel::parent" << child_item->modelType() << parent_item->modelType();
return createIndex(0, 0, parent_item->parent());
SessionItem *fitPar = parent_item->parent();
return createIndex(fitPar->parentRow(), 0, fitPar);
}
}
......
......@@ -14,6 +14,7 @@ private slots:
void test_InitialState();
void test_addFitParameter();
void test_addFitParameterAndLink();
void test_addTwoFitParameterAndLinks();
};
inline void TestFitParameterModel::test_InitialState()
......@@ -189,6 +190,53 @@ inline void TestFitParameterModel::test_addFitParameterAndLink()
}
inline void TestFitParameterModel::test_addTwoFitParameterAndLinks()
{
JobModel source;
SessionItem *fitSuiteItem = source.insertNewItem(Constants::FitSuiteType);
SessionItem *container = source.insertNewItem(Constants::FitParameterContainerType, fitSuiteItem->index(), -1, FitSuiteItem::T_FIT_PARAMETERS);
FitParameterAbsModel proxy(dynamic_cast<FitParameterContainerItem *>(container));
// adding fit parameters
SessionItem *fitPar0 = source.insertNewItem(Constants::FitParameterType, container->index());
SessionItem *link0 = source.insertNewItem(Constants::FitParameterLinkType, fitPar0->index());
SessionItem *fitPar1 = source.insertNewItem(Constants::FitParameterType, container->index());
SessionItem *link1 = source.insertNewItem(Constants::FitParameterLinkType, fitPar1->index());
// checking index of root
QCOMPARE(2, proxy.rowCount(QModelIndex()));
QCOMPARE((int)FitParameterAbsModel::MAX_COLUMNS, proxy.columnCount(QModelIndex()));
// accessing fitPar1
QModelIndex index1 = proxy.index(1, 0, QModelIndex());
QCOMPARE(index1.row(), 1);
QCOMPARE(index1.column(), 0);
QCOMPARE(index1.parent(), QModelIndex());
QCOMPARE(proxy.rowCount(index1), 1);
QCOMPARE(proxy.columnCount(index1), 1);
QCOMPARE(fitPar1, proxy.itemForIndex(index1));
QCOMPARE(fitPar1->displayName(), proxy.data(index1).toString());
QCOMPARE(index1, proxy.indexOfItem(fitPar1));
// accessing link1
QModelIndex linkIndex1 = proxy.index(0, 0, index1);
QCOMPARE(linkIndex1.row(), 0);
QCOMPARE(linkIndex1.column(), 0);
qDebug() << "AAA" << index1 << linkIndex1;
QCOMPARE(linkIndex1.parent(), index1);
QCOMPARE(proxy.rowCount(linkIndex1), 0);
QCOMPARE(proxy.columnCount(linkIndex1), 0);
// QCOMPARE(proxy.parent(linkIndex), index);
// QCOMPARE(proxy.itemForIndex(linkIndex), link0->getItem(FitParameterLinkItem::P_LINK));
// QModelIndex linkIndex1 = proxy.index(0, 0, index1);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment