for (int i_count=0; i_count < (modelInventory->rowCount()); i_count++)
{
//The name of the current product being checked in the inventory model
QString tempProdName
= modelInventory
->record
(i_count
).
value(1).
toString();
QSqlRecord setterRecord
= modelSearchResult
->record
();
//A record to set the search //result model with
//If there is a substring match between the current product name and the search
//string (both ways), transfer all the information of that inventory record
//and put it into the temporary search result record "setRecord". Also,
//store the current "i_count" value into the eighth field of the search
//result record to remember the index of the record
if ( ( tempProdName.indexOf(searchString,0,Qt::CaseInsensitive) != -1 )
|| ( searchString.indexOf(tempProdName,0,Qt::CaseInsensitive) != -1) )
{
//Transfer over all the field information as well as the current index
//being searched
setterRecord.setValue(0, modelInventory->record(i_count).value(0));
setterRecord.setValue(1, modelInventory->record(i_count).value(1));
setterRecord.setValue(2, modelInventory->record(i_count).value(2));
setterRecord.setValue(3, modelInventory->record(i_count).value(3));
setterRecord.setValue(4, modelInventory->record(i_count).value(4));
setterRecord.setValue(5, modelInventory->record(i_count).value(5));
setterRecord.setValue(6, modelInventory->record(i_count).value(6));
setterRecord.setValue(7, modelInventory->record(i_count).value(7));
setterRecord.
setValue(8,
QVariant(i_count
));
//Store the index of the record in the //inventory model in the search result
//model
//Append the new search match into the search result model
modelSearchResult->insertRecord(-1, setterRecord);
} //END if ( ( tempProdName.indexOf(searchString,0,Qt::CaseInsensitive) != -1 )
// || ( searchString.indexOf(tempProdName,0,Qt::CaseInsensitive) != -1) )
} //END for (int i_count=0; i_count< (modelInventory->rowCount()); i_count++)
for (int i_count=0; i_count < (modelInventory->rowCount()); i_count++)
{
//The name of the current product being checked in the inventory model
QString tempProdName = modelInventory->record(i_count).value(1).toString();
QSqlRecord setterRecord = modelSearchResult->record(); //A record to set the search
//result model with
//If there is a substring match between the current product name and the search
//string (both ways), transfer all the information of that inventory record
//and put it into the temporary search result record "setRecord". Also,
//store the current "i_count" value into the eighth field of the search
//result record to remember the index of the record
if ( ( tempProdName.indexOf(searchString,0,Qt::CaseInsensitive) != -1 )
|| ( searchString.indexOf(tempProdName,0,Qt::CaseInsensitive) != -1) )
{
//Transfer over all the field information as well as the current index
//being searched
setterRecord.setValue(0, modelInventory->record(i_count).value(0));
setterRecord.setValue(1, modelInventory->record(i_count).value(1));
setterRecord.setValue(2, modelInventory->record(i_count).value(2));
setterRecord.setValue(3, modelInventory->record(i_count).value(3));
setterRecord.setValue(4, modelInventory->record(i_count).value(4));
setterRecord.setValue(5, modelInventory->record(i_count).value(5));
setterRecord.setValue(6, modelInventory->record(i_count).value(6));
setterRecord.setValue(7, modelInventory->record(i_count).value(7));
setterRecord.setValue(8, QVariant(i_count)); //Store the index of the record in the
//inventory model in the search result
//model
//Append the new search match into the search result model
modelSearchResult->insertRecord(-1, setterRecord);
} //END if ( ( tempProdName.indexOf(searchString,0,Qt::CaseInsensitive) != -1 )
// || ( searchString.indexOf(tempProdName,0,Qt::CaseInsensitive) != -1) )
} //END for (int i_count=0; i_count< (modelInventory->rowCount()); i_count++)
To copy to clipboard, switch view to plain text mode
Bookmarks