void KNMusicPlaylistModel::buildModel() { //Check if we have been build this model before. if(m_built) { return; } //Generate a detail info cache list. QList<KNMusicDetailInfo> detailInfos; //Parse all the data in the content array. for(auto i=m_contentData.constBegin(); i!=m_contentData.constEnd(); ++i) { //Parse and add the data to the model. detailInfos.append(KNMusicUtil::objectToDetailInfo((*i).toObject())); } //Clear the content data. m_contentData=QJsonArray(); //Add the detail infos to the model. appendRows(detailInfos); //Set the build flag. m_built=true; //Reset the changed flag, a model which just finished built cannot be //changed before. m_changed=false; }
returnValue Matrix::computeQRdecomposition(){ int run1, run2, run3; if( solver != 0 ){ delete solver; solver = 0; } ASSERT( getNumRows() == getNumCols() ); double r ; double h_s ; double kappa; double ll ; double ttt ; int nnn = getNumRows(); Matrix ddd(1,nnn); for(run2 = 0; run2 < nnn; run2++){ r = 0.0; for(run1 = run2; run1 < nnn; run1++){ r = r + operator()(run1,run2) * operator()(run1,run2); } if( r < EPS ) return ACADOERROR(RET_DIV_BY_ZERO); if( operator()(run2,run2) < 0.0 ){ h_s = sqrt(r); ddd(0,run2) = h_s ; } else{ h_s = -sqrt(r); ddd(0,run2) = h_s ; } ttt = h_s * operator()(run2,run2) - r; kappa = 1.0/ttt; operator()(run2,run2) -= h_s; for(run3 = run2+1; run3 < nnn; run3++){ ll = 0; for(run1 = run2; run1 < nnn; run1++) ll += operator()(run1,run2) * operator()(run1,run3); ll = kappa * ll; for(run1 = run2; run1 < nnn; run1++) operator()(run1,run3) = operator()(run1,run3) + operator()(run1,run2) * ll; } } appendRows(ddd); return SUCCESSFUL_RETURN; }
bool KNMusicPlaylistModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { //Check move or copy action enabled. if(action==Qt::MoveAction || action==Qt::CopyAction) { //Check if the drop operation is from a music model. if(data->hasFormat(ModelMimeType)) { //Check whether the data is from it self. if(data->data(ModelMimeType).toLongLong()==(qint64)this) { //Generate the remove index list. QList<QPersistentModelIndex> sourceRowIndexes; //Translate the row list to source row indexes list. //We have to move the source indexes to the target positions. QJsonArray rawRowData= QJsonDocument::fromBinaryData( data->data(ModelRowList)).array(); //Translate all the row into persistant list. for(auto i=rawRowData.begin(); i!=rawRowData.end(); ++i) { //Add the target index to source row indexes. sourceRowIndexes.append(index((*i).toInt(), Name)); } //Sort the indexes as the row. //We want to sort the list from a greater row to lesser row. std::sort(sourceRowIndexes.begin(), sourceRowIndexes.end(), [](const QModelIndex &left, const QModelIndex &right) {return left.row()>right.row();}); //Translate the target position to persistant index. int targetRow=(row==-1)?parent.row():row; QPersistentModelIndex targetIndex= index((targetRow==-1)?rowCount()-1:targetRow, Name); //Move all the rows to target position. while(!sourceRowIndexes.isEmpty()) { //Get the source row. int sourceRow=sourceRowIndexes.takeLast().row(); //Move the source row to target row. moveRow(QModelIndex(), sourceRow, QModelIndex(), targetIndex.row()); } return true; } //We can simply parse the row information. QJsonArray rawRowData= QJsonDocument::fromBinaryData( data->data(ModelRowData)).array(); //Generate a detail info list. QList<KNMusicDetailInfo> detailInfoList; //Parse all the data inside the array list. for(auto i=rawRowData.begin(); i!=rawRowData.end(); ++i) { //Add the detail info to the detail info list. detailInfoList.append( KNMusicUtil::objectToDetailInfo((*i).toObject())); } //Check the row. if(row==-1) { //We have to move all of these data to the end of the model. appendRows(detailInfoList); } else { //We have to insert those rows to a specific positions. insertMusicRows(row, detailInfoList); } //Accept. return true; } } //Or others, throw it to KNMusicModel. return KNMusicModel::dropMimeData(data, action, row, column, parent); }
MatrixExprReturnSP appendRows( LitMatrixExprReturn &litMatrixExprReturn ) { VarMatrixExprReturnSP varMatrixExprReturnSP = litMatrixExprReturn.convertToVarMatrixExprReturn(); return appendRows( varMatrixExprReturnSP ); }
void ListModel::appendRow(ListItem *item) { appendRows(QList<ListItem*>() << item); }
void RedisServerDbItem::keysLoadingFinished() { appendRows(keysLoadingResult.result()); server->statusMessage(QString("Keys rendering done")); server->unlockUI(); }
void AccountsListModel::appendRow(Settings::AccountProfile *account) { appendRows(QList<Dekko::Settings::AccountProfile *>() << account); }