//*******************************************************
//* Get a copy of the current record, go create a new *
//* one, and copy this one's contents over to it... *
//*******************************************************
old_region_index = regionmapper->currentIndex ();
old_region_record = regionmodel->record (old_region_index);
riser_id = old_region_record.value("region_riser_id").toInt ();
old_region_seq_no = old_region_record.value ("region_seq_no").toInt ();
row = regionmodel->rowCount ();
regionmodel->insertRow (row);
//******************************************
//* Get hold of the new sequence number *
//* because we're gonna need it later... *
//******************************************
new_region_seq_no = sqldb.generate_seq_noDB ("REGION");
regionmodel->setData (regionmodel->index (row, 33), new_region_seq_no);
regionmodel->setData (regionmodel->index (row, 34), riser_id);
regionmodel->setData (regionmodel->index (row, 35), user);
regionmodel->setData (regionmodel->index (row, 36),
//***************************************************************
//* Now copy the flowline data associated with this region... *
//* We have to make sure we reset the flowline data to the *
//* first record associated with this region and loop thru *
//* all those records, copying them to the new set of data... *
//***************************************************************
flowlinemapper->toFirst ();
old_flowline_rowcount = flowlinemodel->rowCount ();
for (int i = 0; i < old_flowline_rowcount; i++)
{
flowline_filter
= QString("flowline_riser_id = %1").
arg (riser_id
);
flowline_filter.append (" and ");
flowline_filter.
append (QString("flowline_region_seq_no = %2").
arg (old_region_seq_no));
flowlinemodel->setFilter (flowline_filter);
//* This correctly returns the record to be copied...
old_flowline_record = flowlinemodel->record (i);
flowline_filter
= QString("flowline_riser_id = %1").
arg (riser_id
);
flowline_filter.append (" and ");
flowline_filter.
append (QString("flowline_region_seq_no = %2").
arg (new_region_seq_no));
flowlinemodel->setFilter (flowline_filter);
if (!flowlinemodel->insertRow (i))
qDebug() << flowlinemodel->lastError ();
else
{
flowlinemodel->setData (flowlinemodel->index (i, 7),
sqldb.generate_seq_noDB ("FLOWLINE"));
flowlinemodel->setData (flowlinemodel->index (i, 8), new_region_seq_no);
flowlinemodel->setData (flowlinemodel->index (i, 9), riser_id);
flowlinemodel->setData (flowlinemodel->index (i, 10), user);
flowlinemodel->setData (flowlinemodel->index (i, 11),
}
}
//*******************************************************
//* Get a copy of the current record, go create a new *
//* one, and copy this one's contents over to it... *
//*******************************************************
old_region_index = regionmapper->currentIndex ();
old_region_record = regionmodel->record (old_region_index);
riser_id = old_region_record.value("region_riser_id").toInt ();
old_region_seq_no = old_region_record.value ("region_seq_no").toInt ();
row = regionmodel->rowCount ();
regionmodel->insertRow (row);
//******************************************
//* Get hold of the new sequence number *
//* because we're gonna need it later... *
//******************************************
new_region_seq_no = sqldb.generate_seq_noDB ("REGION");
regionmodel->setData (regionmodel->index (row, 33), new_region_seq_no);
regionmodel->setData (regionmodel->index (row, 34), riser_id);
regionmodel->setData (regionmodel->index (row, 35), user);
regionmodel->setData (regionmodel->index (row, 36),
QDateTime::currentDateTime ());
//***************************************************************
//* Now copy the flowline data associated with this region... *
//* We have to make sure we reset the flowline data to the *
//* first record associated with this region and loop thru *
//* all those records, copying them to the new set of data... *
//***************************************************************
flowlinemapper->toFirst ();
old_flowline_rowcount = flowlinemodel->rowCount ();
for (int i = 0; i < old_flowline_rowcount; i++)
{
flowline_filter = QString("flowline_riser_id = %1").arg (riser_id);
flowline_filter.append (" and ");
flowline_filter.append (QString("flowline_region_seq_no = %2").
arg (old_region_seq_no));
flowlinemodel->setFilter (flowline_filter);
//* This correctly returns the record to be copied...
old_flowline_record = flowlinemodel->record (i);
flowline_filter = QString("flowline_riser_id = %1").arg (riser_id);
flowline_filter.append (" and ");
flowline_filter.append (QString("flowline_region_seq_no = %2").
arg (new_region_seq_no));
flowlinemodel->setFilter (flowline_filter);
if (!flowlinemodel->insertRow (i))
qDebug() << flowlinemodel->lastError ();
else
{
flowlinemodel->setData (flowlinemodel->index (i, 7),
sqldb.generate_seq_noDB ("FLOWLINE"));
flowlinemodel->setData (flowlinemodel->index (i, 8), new_region_seq_no);
flowlinemodel->setData (flowlinemodel->index (i, 9), riser_id);
flowlinemodel->setData (flowlinemodel->index (i, 10), user);
flowlinemodel->setData (flowlinemodel->index (i, 11),
QDateTime::currentDateTime ());
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks