/* * QtHP Connect: hand-helds support interface. * Copyright (C) 2019 Ian Gebbie * Code patterns and snippets borrowed from libhpcalcs : * Copyright (C) 1999-2009 Romain Li�vin * Copyright (C) 2009-2013 Lionel Debroux * Copyright (C) 1999-2013 libti* contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include #include "matrixdata.h" MatrixData::MatrixData() { // clear(); qDebug()<<"MtarixData Construct"; } //Return the item or a zero item itemData MatrixData::at(int row, int column) { QList * rowlist; itemData item; if (rowsize()) { item=rowlist->at(column); } } } return item; } //Insert a new item and resize the list if larger void MatrixData::insert(int row, int column, itemData data) { QList * rowlist=nullptr; upsize(row+1,column+1); if(rowreplace(column,data); } } //Add a new row void MatrixData::addRow(int row) { int rows; int i; QList * rowlist; // qDebug()<<"MatrixData::addRow" << row; rows=matrix.size(); if (rows<=row) { for (i=rows; i<=row;i++) { // qDebug()<<"MatrixData::addRow "<; matrix.insert(i,rowlist); } } } //get all columns to same size by padding it zero items void MatrixData::resize(int newrow,int newcol) { QList * row; int rows=0; int maxrows=0; int columns=0; int maxcolumns=0; int i; int j; qDebug()<<"MatrixData::resize"; itemData item; rows = matrix.size(); qDebug()<<"MatrixData::resize - maxcolumns "<newrow) { matrix.removeAt(i); } } //increase rows to match if(newrow>rows) { for(i=rows;isize(); if (columnsinsert(j,item); } } if (columns>newcol) { row=matrix.at(i); if (row) { for(j=columns;jremoveAt(j); } } } } } //get all columns to same size by padding it zero items void MatrixData::upsize(int newrow,int newcol) { QList * row; int rows=0; int columns=0; int i; int j; qDebug()<<"MatrixData::upsize"; itemData item; rows = matrix.size(); // qDebug()<<"MatrixData::upsize - rows:"<size(); for(j=columns;jinsert(j,item); } } } else { qDebug()<<"MatrixData::upsize - Null row!"; } } } //get all columns to same size by padding it zero items void MatrixData::matchsize() { QList * row; int rows=0; int maxrows=0; int columns=0; int maxcolumns=0; int i; int j; qDebug()<<"MatrixData::matchsize"; itemData item; rows = matrix.size(); for(i=0;isize(); if (maxcolumnssize(); if (columnsinsert(j,item); } } } } void MatrixData::clear() { int i; int r; QList * row; r=rows(); for(i=0; iclear(); delete row; } } matrix.clear(); } int MatrixData::columns() { QList * row; if (matrix.size()>0) { row=matrix.at(0); if (row) { qDebug()<<"MatrixData: column "<size(); return row->size(); } } return 0; } int MatrixData::rows() { qDebug()<<"MatrixData: row"<