mirror of
https://github.com/Indy970/QtHPConnect
synced 2024-12-26 21:59:23 +01:00
update
This commit is contained in:
parent
848d8af1af
commit
5bfd57be11
14 changed files with 360 additions and 140 deletions
|
@ -22,9 +22,9 @@
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "abstractdata.h"
|
|
||||||
#include "hpusb.h"
|
#include "hpusb.h"
|
||||||
#include "matrixdata.h"
|
#include "matrixdata.h"
|
||||||
|
#include "abstractdata.h"
|
||||||
|
|
||||||
uint16_t crc16_block(const uint8_t * buffer, uint32_t len);
|
uint16_t crc16_block(const uint8_t * buffer, uint32_t len);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ int BCD2I(quint8 num) {
|
||||||
ret=0;
|
ret=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
log(QString("Num= %1 Ret= %2").arg(num,1,16).arg(ret));
|
errlog(QString("Num= %1 Ret= %2").arg(num,1,16).arg(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ qint32 TwosComplement2Int(quint32 rawValue)
|
||||||
|
|
||||||
qint32 ret;
|
qint32 ret;
|
||||||
|
|
||||||
log(QString("2C: %1").arg(rawValue& 0x80000000,1,16));
|
errlog(QString("2C: %1").arg(rawValue& 0x80000000,1,16));
|
||||||
|
|
||||||
// If a positive value, return it
|
// If a positive value, return it
|
||||||
if ((rawValue & 0x80000000) == 0)
|
if ((rawValue & 0x80000000) == 0)
|
||||||
|
@ -58,12 +58,12 @@ qint32 TwosComplement2Int(quint32 rawValue)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Otherwise perform the 2's complement math on the value
|
// Otherwise perform the 2's complement math on the value
|
||||||
log(QString("List 2C Negative Detected"));
|
errlog(QString("List 2C Negative Detected"));
|
||||||
|
|
||||||
ret = static_cast<qint32>(~(rawValue - 0x01)) * - 1;
|
ret = static_cast<qint32>(~(rawValue - 0x01)) * - 1;
|
||||||
// ret = ~rawValue;
|
// ret = ~rawValue;
|
||||||
}
|
}
|
||||||
log(QString("2C: %1 %2").arg(rawValue,1,16).arg(ret,1,16));
|
errlog(QString("2C: %1 %2").arg(rawValue,1,16).arg(ret,1,16));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ itemData extract16(QByteArray item) {
|
||||||
|
|
||||||
exp=((((((((static_cast<qint8>(item[7])&0xFF)<<8)+(static_cast<qint8>(item[6])&0xFF))<<8)+(static_cast<qint8>(item[5])&0xFF)))<<8)
|
exp=((((((((static_cast<qint8>(item[7])&0xFF)<<8)+(static_cast<qint8>(item[6])&0xFF))<<8)+(static_cast<qint8>(item[5])&0xFF)))<<8)
|
||||||
+(static_cast<qint8>(item[4])&0xFF));
|
+(static_cast<qint8>(item[4])&0xFF));
|
||||||
log(QString("extract16: exp %1").arg(exp));
|
errlog(QString("extract16: exp %1").arg(exp));
|
||||||
// exp=TwosComplement2Int(exp);
|
// exp=TwosComplement2Int(exp);
|
||||||
|
|
||||||
m=0;
|
m=0;
|
||||||
|
@ -166,8 +166,8 @@ itemData extract16(QByteArray item) {
|
||||||
msg=QString("multi:%1 base:%2 sign:%3 exp:%4 m:%5").arg(multi).arg(base).arg(sign).arg(exp).arg(m);
|
msg=QString("multi:%1 base:%2 sign:%3 exp:%4 m:%5").arg(multi).arg(base).arg(sign).arg(exp).arg(m);
|
||||||
// msg=QString("value: %1").arg(value);
|
// msg=QString("value: %1").arg(value);
|
||||||
|
|
||||||
log(msg);
|
errlog(msg);
|
||||||
log((QString("Ans: %1").arg(ret)));
|
errlog((QString("Ans: %1").arg(ret)));
|
||||||
|
|
||||||
listvalue.dReal=ret;
|
listvalue.dReal=ret;
|
||||||
listvalue.sValue=value;
|
listvalue.sValue=value;
|
||||||
|
@ -371,10 +371,10 @@ void Real::parseData() {
|
||||||
itemData listvalue;
|
itemData listvalue;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
log("Real: Parsing Vars");
|
errlog("Real: Parsing Vars");
|
||||||
|
|
||||||
name=getName();
|
name=getName();
|
||||||
log(name);
|
errlog(name);
|
||||||
a1.clear();
|
a1.clear();
|
||||||
a1=getData();
|
a1=getData();
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ void Real::parseData() {
|
||||||
else
|
else
|
||||||
len=0;
|
len=0;
|
||||||
|
|
||||||
log(QString("Real: %1 %2 %3").arg(ind,0,10)
|
errlog(QString("Real: %1 %2 %3").arg(ind,0,10)
|
||||||
.arg(searchstr.size())
|
.arg(searchstr.size())
|
||||||
.arg(len,2,10));
|
.arg(len,2,10));
|
||||||
// ind=a1.indexOf(searchstr,0);
|
// ind=a1.indexOf(searchstr,0);
|
||||||
|
@ -423,7 +423,7 @@ void Real::parseData() {
|
||||||
|
|
||||||
setListItem(getListSize(),listvalue);
|
setListItem(getListSize(),listvalue);
|
||||||
}
|
}
|
||||||
// log("Real Dump");
|
// errlog("Real Dump");
|
||||||
// main_err->dump((uint8_t *)a1.constData(),a1.size());
|
// main_err->dump((uint8_t *)a1.constData(),a1.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,10 +498,10 @@ void Complex::parseData() {
|
||||||
itemData value2;
|
itemData value2;
|
||||||
itemData listvalue;
|
itemData listvalue;
|
||||||
QString name;
|
QString name;
|
||||||
log("Complex: Parsing Vars");
|
errlog("Complex: Parsing Vars");
|
||||||
|
|
||||||
name=getName();
|
name=getName();
|
||||||
log(name);
|
errlog(name);
|
||||||
a1.clear();
|
a1.clear();
|
||||||
a1=getData();
|
a1=getData();
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ void Complex::parseData() {
|
||||||
else
|
else
|
||||||
len=0;
|
len=0;
|
||||||
|
|
||||||
log(QString("Real: %1 %2 %3").arg(ind,0,10)
|
errlog(QString("Real: %1 %2 %3").arg(ind,0,10)
|
||||||
.arg(searchstr.size())
|
.arg(searchstr.size())
|
||||||
.arg(len,2,10));
|
.arg(len,2,10));
|
||||||
// ind=a1.indexOf(searchstr,0);
|
// ind=a1.indexOf(searchstr,0);
|
||||||
|
@ -678,13 +678,18 @@ itemData List::getListItem(int row) {
|
||||||
void List::setListItem(int row, itemData item) {
|
void List::setListItem(int row, itemData item) {
|
||||||
|
|
||||||
//May need to pad for missing items
|
//May need to pad for missing items
|
||||||
|
|
||||||
values.insert(row,item);
|
values.insert(row,item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gets a string representation of the list item in the list at position row
|
//Gets a string representation of the list item in the list at position row
|
||||||
QString List::getItem(int row) {
|
QString List::getItem(int row) {
|
||||||
return QString("%1").arg(values.at(row).dReal);
|
|
||||||
|
if (row<values.size()) {
|
||||||
|
return QString("%1").arg(values.at(row).dReal);
|
||||||
|
}
|
||||||
|
return QString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Passes a string representation of the list item in the list at position row
|
//Passes a string representation of the list item in the list at position row
|
||||||
|
@ -762,31 +767,31 @@ void Matrix::parseData() {
|
||||||
qDebug()<<"Matrix: Parsing a Matrix";
|
qDebug()<<"Matrix: Parsing a Matrix";
|
||||||
|
|
||||||
name=getName();
|
name=getName();
|
||||||
log(name);
|
errlog(name);
|
||||||
a1=data;
|
a1=data;
|
||||||
// ind=a1.indexOf(searchstr,0);
|
// ind=a1.indexOf(searchstr,0);
|
||||||
ind=0;
|
ind=0;
|
||||||
vtype=a1[ind+2];
|
vtype=a1[ind+2];
|
||||||
|
|
||||||
log(QString("vtype=%1").arg(vtype,1,16));
|
errlog(QString("vtype=%1").arg(vtype,1,16));
|
||||||
if ((vtype&0x7F)==0x14) {
|
if ((vtype&0x7F)==0x14) {
|
||||||
log("matrix found");
|
errlog("matrix found");
|
||||||
flag =1;
|
flag =1;
|
||||||
}
|
}
|
||||||
log(QString("vtype=%1").arg(vtype&0x7F,1,16));
|
errlog(QString("vtype=%1").arg(vtype&0x7F,1,16));
|
||||||
if ((vtype&0x80)==0x80) {
|
if ((vtype&0x80)==0x80) {
|
||||||
log("complex found");
|
errlog("complex found");
|
||||||
flag =2;
|
flag =2;
|
||||||
}
|
}
|
||||||
log(QString("vtype=%1").arg(vtype&0x80,1,16));
|
errlog(QString("vtype=%1").arg(vtype&0x80,1,16));
|
||||||
|
|
||||||
//look for 00 14
|
//look for 00 14
|
||||||
log(QString("Found string at %1").arg(ind));
|
errlog(QString("Found string at %1").arg(ind));
|
||||||
|
|
||||||
mcolumns=a1[ind+12];
|
mcolumns=a1[ind+12];
|
||||||
mrows=a1[ind+8];
|
mrows=a1[ind+8];
|
||||||
qDebug()<<QString("Matrix: Row %1 Column %2").arg(mrows).arg(mcolumns);
|
qDebug()<<QString("Matrix: Row %1 Column %2").arg(mrows).arg(mcolumns);
|
||||||
log(QString("Matrix: Row %1 Column %2").arg(mrows).arg(mcolumns));
|
errlog(QString("Matrix: Row %1 Column %2").arg(mrows).arg(mcolumns));
|
||||||
|
|
||||||
start=ind+16;
|
start=ind+16;
|
||||||
for(j=0;j<mrows;j++) {
|
for(j=0;j<mrows;j++) {
|
||||||
|
@ -845,10 +850,7 @@ QString Matrix::getItem(int row, int column) {
|
||||||
//Passes a string representation of the item in the matrix at position position row,column
|
//Passes a string representation of the item in the matrix at position position row,column
|
||||||
void Matrix::setItem(int row, int column, QString string) {
|
void Matrix::setItem(int row, int column, QString string) {
|
||||||
|
|
||||||
itemData item;
|
setItem(row,column,string,string.toDouble());
|
||||||
item.dReal=string.toDouble();
|
|
||||||
item.sValue=string;
|
|
||||||
setListItem(row,column, item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Passes a string representation of the list item in the matrix at position row,column
|
//Passes a string representation of the list item in the matrix at position row,column
|
||||||
|
@ -951,14 +953,14 @@ void Program::parseData(QDataStream& in) {
|
||||||
phrase=a1.mid(ind,16*3);
|
phrase=a1.mid(ind,16*3);
|
||||||
//add array to catch variable list
|
//add array to catch variable list
|
||||||
str=codec->toUnicode(phrase);
|
str=codec->toUnicode(phrase);
|
||||||
log(QString("TD...%1 %2").arg(pos,0,16).arg(ind));
|
errlog(QString("TD...%1 %2").arg(pos,0,16).arg(ind));
|
||||||
main_err->dump((uint8_t *)phrase.data(),3*16);
|
main_err->dump((uint8_t *)phrase.data(),3*16);
|
||||||
log(str);
|
errlog(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("Data is not a program file");
|
errlog("Data is not a program file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1086,11 +1088,11 @@ void Settings::setData(QByteArray datain) {
|
||||||
|
|
||||||
int len1=data.size();
|
int len1=data.size();
|
||||||
int len2=datain.size();
|
int len2=datain.size();
|
||||||
log(QString("Settings Compare %1 %2").arg(len1).arg(len2));
|
errlog(QString("Settings Compare %1 %2").arg(len1).arg(len2));
|
||||||
int i=0;
|
int i=0;
|
||||||
while ((i<len1)&&(i<len2)) {
|
while ((i<len1)&&(i<len2)) {
|
||||||
if (data[i]!=datain[i]) {
|
if (data[i]!=datain[i]) {
|
||||||
log(QString("Settings diff at:%1").arg(i));
|
errlog(QString("Settings diff at:%1").arg(i));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -1098,7 +1100,7 @@ void Settings::setData(QByteArray datain) {
|
||||||
data = datain;
|
data = datain;
|
||||||
len1=data.size();
|
len1=data.size();
|
||||||
len2=datain.size();
|
len2=datain.size();
|
||||||
log(QString("Settings Compare 2 %1 %2").arg(len1).arg(len2));
|
errlog(QString("Settings Compare 2 %1 %2").arg(len1).arg(len2));
|
||||||
|
|
||||||
//parseData();
|
//parseData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QBoxLayout>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QMessageBox>
|
||||||
#include "hp_mdivariableedit.h"
|
#include "hp_mdivariableedit.h"
|
||||||
#include "hptreeitem.h"
|
#include "hptreeitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hp_mdiVariableEdit::hp_mdiVariableEdit(QWidget *parent,
|
hp_mdiVariableEdit::hp_mdiVariableEdit(QWidget *parent,
|
||||||
hpTreeItem * treeItem,
|
hpTreeItem * treeItem,
|
||||||
hpCalcData * dataStore)
|
hpCalcData * dataStore)
|
||||||
|
@ -85,7 +87,25 @@ void hp_mdiVariableEdit::setup() {
|
||||||
varmodel = new varTableModel(this,data,filename,type);
|
varmodel = new varTableModel(this,data,filename,type);
|
||||||
tableView = new QTableView(this);
|
tableView = new QTableView(this);
|
||||||
tableView->setModel(varmodel);
|
tableView->setModel(varmodel);
|
||||||
setWidget(tableView);
|
|
||||||
|
QIcon save(":/icons/save_22x22.png");
|
||||||
|
QAction * actionSave= new QAction(save,"Save",this);
|
||||||
|
QWidget * top = new QWidget();
|
||||||
|
QBoxLayout * layout = new QVBoxLayout();
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
top->setLayout(layout);
|
||||||
|
QToolBar * toolbar = new QToolBar("Save");
|
||||||
|
toolbar->addAction(actionSave);
|
||||||
|
|
||||||
|
QToolButton *saveButton=new QToolButton();
|
||||||
|
QMenu * menu = new QMenu(saveButton);
|
||||||
|
menu->addAction(actionSave);
|
||||||
|
layout->setMenuBar(menu);
|
||||||
|
layout->addWidget(tableView);
|
||||||
|
setWidget(top);
|
||||||
|
|
||||||
|
connect(actionSave,SIGNAL(triggered()),this,SLOT(eventSave()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +118,66 @@ void hp_mdiVariableEdit::show() {
|
||||||
hp_MdiWindow::show();
|
hp_MdiWindow::show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hp_mdiVariableEdit::eventSave(){
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hp_mdiVariableEdit::save(){
|
||||||
|
|
||||||
|
// if(content)
|
||||||
|
// return textEdit->save(file);
|
||||||
|
// else {
|
||||||
|
// return textEdit->save(calculator);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hp_mdiVariableEdit::saveAs(){
|
||||||
|
|
||||||
|
// if(content)
|
||||||
|
// return textEdit->saveAs(file);
|
||||||
|
// else {
|
||||||
|
// return textEdit->saveAs(calculator);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hp_mdiVariableEdit::maybeSave()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if (!textEdit->document()->isModified())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const QMessageBox::StandardButton ret
|
||||||
|
= QMessageBox::warning(this, tr("MDI"),
|
||||||
|
tr("'%1' has been modified.\n"
|
||||||
|
"Do you want to save your changes?")
|
||||||
|
.arg(file.fileName()),
|
||||||
|
QMessageBox::Save | QMessageBox::Discard
|
||||||
|
| QMessageBox::Cancel);
|
||||||
|
switch (ret) {
|
||||||
|
case QMessageBox::Save:
|
||||||
|
return textEdit->save(file);
|
||||||
|
case QMessageBox::Cancel:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void hp_mdiVariableEdit::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (maybeSave()) {
|
||||||
|
event->accept();
|
||||||
|
} else {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
hp_mdiVariableEdit::~hp_mdiVariableEdit() {
|
hp_mdiVariableEdit::~hp_mdiVariableEdit() {
|
||||||
|
|
||||||
qDebug()<<"Entering ~hpmdiVariableEdit()";
|
qDebug()<<"Entering ~hpmdiVariableEdit()";
|
||||||
|
|
22
hpdata.cpp
22
hpdata.cpp
|
@ -162,7 +162,7 @@ void hpCalcData::readSettings() {
|
||||||
hp_Handle * handle;
|
hp_Handle * handle;
|
||||||
hp_Settings hpset;
|
hp_Settings hpset;
|
||||||
|
|
||||||
log("hpCalcData::readSettings: -Reading Settings");
|
errlog("hpCalcData::readSettings: -Reading Settings");
|
||||||
qDebug()<<"Reading Settings";
|
qDebug()<<"Reading Settings";
|
||||||
api=getAPI();
|
api=getAPI();
|
||||||
handle=getHandle();
|
handle=getHandle();
|
||||||
|
@ -175,11 +175,11 @@ void hpCalcData::readSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("hpCalcData::readSettings Handle null");
|
errlog("hpCalcData::readSettings Handle null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("hpCalcData::readSettings API null");
|
errlog("hpCalcData::readSettings API null");
|
||||||
}
|
}
|
||||||
// hp_homesettings=hpset;
|
// hp_homesettings=hpset;
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ void hpCalcData::readScreen() {
|
||||||
hp_Handle * handle;
|
hp_Handle * handle;
|
||||||
hp_Settings hpset;
|
hp_Settings hpset;
|
||||||
|
|
||||||
log("Reading Screen");
|
errlog("Reading Screen");
|
||||||
|
|
||||||
api=getAPI();
|
api=getAPI();
|
||||||
handle=getHandle();
|
handle=getHandle();
|
||||||
|
@ -222,7 +222,7 @@ void hpCalcData::readScreen() {
|
||||||
//recieve Screenshot
|
//recieve Screenshot
|
||||||
void hpCalcData::recvScreen(hp_ScreenShot shot) {
|
void hpCalcData::recvScreen(hp_ScreenShot shot) {
|
||||||
|
|
||||||
log("Recieving Screen");
|
errlog("Recieving Screen");
|
||||||
|
|
||||||
QByteArray imageData;
|
QByteArray imageData;
|
||||||
if (screenShot!=nullptr) {
|
if (screenShot!=nullptr) {
|
||||||
|
@ -237,7 +237,7 @@ void hpCalcData::recvScreen(hp_ScreenShot shot) {
|
||||||
void hpCalcData::recvSettings(hp_Data data) {
|
void hpCalcData::recvSettings(hp_Data data) {
|
||||||
|
|
||||||
QString filename;
|
QString filename;
|
||||||
log("hpCalcData::recvSettings: Recieving Setting");
|
errlog("hpCalcData::recvSettings: Recieving Setting");
|
||||||
filename = data.name;
|
filename = data.name;
|
||||||
qDebug()<<filename;
|
qDebug()<<filename;
|
||||||
|
|
||||||
|
@ -245,14 +245,14 @@ void hpCalcData::recvSettings(hp_Data data) {
|
||||||
qDebug()<<"hpCalcData::recvSetting - Setting";
|
qDebug()<<"hpCalcData::recvSetting - Setting";
|
||||||
|
|
||||||
qDebug()<<"hpCalcData::recvSetting - Real";
|
qDebug()<<"hpCalcData::recvSetting - Real";
|
||||||
log("hpCalcData::recvSetting - Real");
|
errlog("hpCalcData::recvSetting - Real");
|
||||||
Real * obj1 = new Real(data.name,HP_REAL);
|
Real * obj1 = new Real(data.name,HP_REAL);
|
||||||
obj1->setData(data.data);
|
obj1->setData(data.data);
|
||||||
addData(obj1);
|
addData(obj1);
|
||||||
emit emitChange(HP_REAL);
|
emit emitChange(HP_REAL);
|
||||||
|
|
||||||
qDebug()<<"hpCalcData::recvSetting - Complex";
|
qDebug()<<"hpCalcData::recvSetting - Complex";
|
||||||
log("hpCalcData::recvSetting - Complex");
|
errlog("hpCalcData::recvSetting - Complex");
|
||||||
Complex * obj2 = new Complex(data.name,HP_COMPLEX);
|
Complex * obj2 = new Complex(data.name,HP_COMPLEX);
|
||||||
obj2->setData(data.data);
|
obj2->setData(data.data);
|
||||||
addData(obj2);
|
addData(obj2);
|
||||||
|
@ -294,7 +294,7 @@ void hpCalcData::recvSettings(hp_Data data) {
|
||||||
//recieve Program
|
//recieve Program
|
||||||
void hpCalcData::recvProg(hp_Prog program) {
|
void hpCalcData::recvProg(hp_Prog program) {
|
||||||
|
|
||||||
log("Recieving Program");
|
errlog("Recieving Program");
|
||||||
qDebug()<<"hpCalcData::recvProg";
|
qDebug()<<"hpCalcData::recvProg";
|
||||||
|
|
||||||
qDebug()<<program.filename;
|
qDebug()<<program.filename;
|
||||||
|
@ -310,7 +310,7 @@ void hpCalcData::recvProg(hp_Prog program) {
|
||||||
//recieve Program
|
//recieve Program
|
||||||
void hpCalcData::recvNote(hp_Note note) {
|
void hpCalcData::recvNote(hp_Note note) {
|
||||||
|
|
||||||
log("Recieving Note");
|
errlog("Recieving Note");
|
||||||
qDebug()<<"hpCalcData::recvNote";
|
qDebug()<<"hpCalcData::recvNote";
|
||||||
|
|
||||||
qDebug()<<note.filename;
|
qDebug()<<note.filename;
|
||||||
|
@ -325,7 +325,7 @@ void hpCalcData::recvNote(hp_Note note) {
|
||||||
//recieve Program
|
//recieve Program
|
||||||
void hpCalcData::recvData(hp_Data data) {
|
void hpCalcData::recvData(hp_Data data) {
|
||||||
|
|
||||||
log("Recieving Data");
|
errlog("Recieving Data");
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case HP_APP: {
|
case HP_APP: {
|
||||||
|
|
98
hpusb.cpp
98
hpusb.cpp
|
@ -89,10 +89,10 @@ int hpusb::hp_init()
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if(!lb_init) {
|
if(!lb_init) {
|
||||||
log("Initialising usb interface");
|
errlog("Initialising usb interface");
|
||||||
|
|
||||||
if(!(ret=libusb_init(&ctx))) {
|
if(!(ret=libusb_init(&ctx))) {
|
||||||
log("libusb init ok");
|
errlog("libusb init ok");
|
||||||
libusb_set_debug(ctx,LIBUSB_LOG_LEVEL_WARNING);
|
libusb_set_debug(ctx,LIBUSB_LOG_LEVEL_WARNING);
|
||||||
|
|
||||||
rc = libusb_hotplug_register_callback(ctx, (libusb_hotplug_event) (LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED |
|
rc = libusb_hotplug_register_callback(ctx, (libusb_hotplug_event) (LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED |
|
||||||
|
@ -101,11 +101,11 @@ int hpusb::hp_init()
|
||||||
&callback_handle);
|
&callback_handle);
|
||||||
|
|
||||||
if (LIBUSB_SUCCESS != rc) {
|
if (LIBUSB_SUCCESS != rc) {
|
||||||
log("Error creating a hotplug callback\n");
|
errlog("Error creating a hotplug callback\n");
|
||||||
libusb_exit(ctx);
|
libusb_exit(ctx);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
log("hpusb::hp_init - hotplug registered\n");
|
errlog("hpusb::hp_init - hotplug registered\n");
|
||||||
hp_callback_handle=callback_handle;
|
hp_callback_handle=callback_handle;
|
||||||
lb_init=1;
|
lb_init=1;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -139,7 +139,7 @@ int hpusb::hp_open(hp_Handle * handle) {
|
||||||
libusb_device *device = list[i];
|
libusb_device *device = list[i];
|
||||||
if (is_device(device)) {
|
if (is_device(device)) {
|
||||||
found = device;
|
found = device;
|
||||||
log("Device found");
|
errlog("Device found");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,22 +161,22 @@ int hpusb::hp_open(hp_Handle * handle) {
|
||||||
err(L3,0,"handle null");
|
err(L3,0,"handle null");
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Device opened");
|
errlog("Device opened");
|
||||||
|
|
||||||
//claim interface
|
//claim interface
|
||||||
ret = libusb_kernel_driver_active ( handle->usbhandle, 0x0) ;
|
ret = libusb_kernel_driver_active ( handle->usbhandle, 0x0) ;
|
||||||
if (ret==1) {
|
if (ret==1) {
|
||||||
log(QString().sprintf("Keneral active"));
|
errlog(QString().sprintf("Keneral active"));
|
||||||
ret = libusb_detach_kernel_driver( handle->usbhandle, 0x0) ;
|
ret = libusb_detach_kernel_driver( handle->usbhandle, 0x0) ;
|
||||||
log(QString().sprintf("Keneral detach: %s\n", libusb_error_name(ret)));
|
errlog(QString().sprintf("Keneral detach: %s\n", libusb_error_name(ret)));
|
||||||
if (ret!=0) {
|
if (ret!=0) {
|
||||||
log(QString().sprintf("Keneral detach error: %s\n", libusb_error_name(ret)));
|
errlog(QString().sprintf("Keneral detach error: %s\n", libusb_error_name(ret)));
|
||||||
goto endfunc;
|
goto endfunc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (ret!=0) {
|
if (ret!=0) {
|
||||||
log(QString().sprintf("Kernal error %s\n", libusb_error_name(ret)));
|
errlog(QString().sprintf("Kernal error %s\n", libusb_error_name(ret)));
|
||||||
goto endfunc;
|
goto endfunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,14 +185,14 @@ int hpusb::hp_open(hp_Handle * handle) {
|
||||||
//
|
//
|
||||||
// ret=libusb_set_configuration(handle->usbhandle,0x1);
|
// ret=libusb_set_configuration(handle->usbhandle,0x1);
|
||||||
// if (ret!=0) {
|
// if (ret!=0) {
|
||||||
// log(QString().sprintf("Set Configuration: %s\n", libusb_error_name(ret)));
|
// errlog(QString().sprintf("Set Configuration: %s\n", libusb_error_name(ret)));
|
||||||
// goto endfunc;
|
// goto endfunc;
|
||||||
// }
|
// }
|
||||||
handle->dev_open=1;
|
handle->dev_open=1;
|
||||||
|
|
||||||
ret = libusb_claim_interface(handle->usbhandle, 0x0);
|
ret = libusb_claim_interface(handle->usbhandle, 0x0);
|
||||||
if (ret!=0) {
|
if (ret!=0) {
|
||||||
log(QString().sprintf("Claim interface Error: %s\n", libusb_error_name(ret)));
|
errlog(QString().sprintf("Claim interface Error: %s\n", libusb_error_name(ret)));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ int hpusb::is_device(libusb_device * device) {
|
||||||
err(L3,rc,QString(__FUNCTION__) + QString(" Could not get device descriptor "));
|
err(L3,rc,QString(__FUNCTION__) + QString(" Could not get device descriptor "));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// log(QString().sprintf("Vendor:Device = %04x:%04x", desc.idVendor, desc.idProduct));
|
// errlog(QString().sprintf("Vendor:Device = %04x:%04x", desc.idVendor, desc.idProduct));
|
||||||
if ((desc.idVendor==USB_VID_HP)&&(desc.idProduct==USB_PID_PRIME3)) {
|
if ((desc.idVendor==USB_VID_HP)&&(desc.idProduct==USB_PID_PRIME3)) {
|
||||||
dumpDevice(device);
|
dumpDevice(device);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -251,7 +251,7 @@ void hpusb::dumpDevice(libusb_device * device) {
|
||||||
dump+=QString().sprintf("bNumConfigurations: %d\n",desc.bNumConfigurations);
|
dump+=QString().sprintf("bNumConfigurations: %d\n",desc.bNumConfigurations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(dump);
|
errlog(dump);
|
||||||
qDebug()<<dump;
|
qDebug()<<dump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,20 +291,20 @@ int hpusb::submit_sync_s_transfer(hp_Handle * handle, hp_pkt_out * pktout) {
|
||||||
offset += PRIME_RAW_DATA_SIZE - 1;
|
offset += PRIME_RAW_DATA_SIZE - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("In sync send transfer");
|
errlog("In sync send transfer");
|
||||||
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle);
|
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle);
|
||||||
|
|
||||||
//write
|
//write
|
||||||
log("Send..");
|
errlog("Send..");
|
||||||
ret = libusb_interrupt_transfer(devh, ENDPOINT_OUT, raw.data, raw.size,
|
ret = libusb_interrupt_transfer(devh, ENDPOINT_OUT, raw.data, raw.size,
|
||||||
&trans,10000);
|
&trans,10000);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
log(QString().sprintf("Write Error: %s\n", libusb_error_name(ret)));
|
errlog(QString().sprintf("Write Error: %s\n", libusb_error_name(ret)));
|
||||||
r = 0;
|
r = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log(QString().sprintf("Write bytes: %d\n", trans));
|
errlog(QString().sprintf("Write bytes: %d\n", trans));
|
||||||
}
|
}
|
||||||
// Increment packet ID, which seems to be necessary for computer -> calc packets
|
// Increment packet ID, which seems to be necessary for computer -> calc packets
|
||||||
pkt_id++;
|
pkt_id++;
|
||||||
|
@ -325,16 +325,16 @@ int hpusb::submit_sync_s_transfer(hp_Handle * handle, hp_pkt_out * pktout) {
|
||||||
raw.size = r;
|
raw.size = r;
|
||||||
memcpy(raw.data, pktout->data + offset, PRIME_RAW_DATA_SIZE-1);
|
memcpy(raw.data, pktout->data + offset, PRIME_RAW_DATA_SIZE-1);
|
||||||
}
|
}
|
||||||
log("Send small packet..");
|
errlog("Send small packet..");
|
||||||
|
|
||||||
ret = libusb_interrupt_transfer(devh, ENDPOINT_OUT, raw.data, raw.size,
|
ret = libusb_interrupt_transfer(devh, ENDPOINT_OUT, raw.data, raw.size,
|
||||||
&trans,10000);
|
&trans,10000);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
log(QString().sprintf("Write Error: %s\n", libusb_error_name(ret)));
|
errlog(QString().sprintf("Write Error: %s\n", libusb_error_name(ret)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log(QString().sprintf("Write bytes: %d\n", trans));
|
errlog(QString().sprintf("Write bytes: %d\n", trans));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,11 +475,11 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
|
||||||
QByteArray in_buffer(PRIME_RAW_DATA_SIZE,0);
|
QByteArray in_buffer(PRIME_RAW_DATA_SIZE,0);
|
||||||
libusb_device_handle * devh = handle->usbhandle;
|
libusb_device_handle * devh = handle->usbhandle;
|
||||||
|
|
||||||
log("hpusb::submit_sync_r_transfer: Receive...");
|
errlog("hpusb::submit_sync_r_transfer: Receive...");
|
||||||
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle);
|
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle);
|
||||||
|
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
log("Null handle");
|
errlog("Null handle");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ int hpusb::submit_sync_r_transfer(hp_Handle * handle, hp_pkt_in * pktin) {
|
||||||
memset(raw,0,PRIME_RAW_DATA_SIZE);
|
memset(raw,0,PRIME_RAW_DATA_SIZE);
|
||||||
if ((ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,PRIME_RAW_DATA_SIZE,&trans_c,TIME_OUT))!=0) {
|
if ((ret = libusb_interrupt_transfer(devh,ENDPOINT_IN,raw,PRIME_RAW_DATA_SIZE,&trans_c,TIME_OUT))!=0) {
|
||||||
qDebug()<<QString("hpusb::submit_sync_r_transfer: Read Error %1").arg(libusb_error_name(ret));
|
qDebug()<<QString("hpusb::submit_sync_r_transfer: Read Error %1").arg(libusb_error_name(ret));
|
||||||
log(QString("Read Error: %1\n").arg( libusb_error_name(ret)));
|
errlog(QString("Read Error: %1\n").arg( libusb_error_name(ret)));
|
||||||
exitflag=0;
|
exitflag=0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ int hpusb::send_info(hp_pkt_in * pkt) {
|
||||||
qDebug()<<"hpusb:In send info";
|
qDebug()<<"hpusb:In send info";
|
||||||
if( pkt->calc!=nullptr) {
|
if( pkt->calc!=nullptr) {
|
||||||
|
|
||||||
log("Unpacking Data");
|
errlog("Unpacking Data");
|
||||||
int ind=0;
|
int ind=0;
|
||||||
QTextCodec * codec = QTextCodec::codecForName("UTF-16LE");
|
QTextCodec * codec = QTextCodec::codecForName("UTF-16LE");
|
||||||
QTextCodec * codec8 = QTextCodec::codecForName("UTF-8");
|
QTextCodec * codec8 = QTextCodec::codecForName("UTF-8");
|
||||||
|
@ -668,7 +668,7 @@ int hpusb::send_info(hp_pkt_in * pkt) {
|
||||||
QString app;
|
QString app;
|
||||||
app = codec8->toUnicode(str1);
|
app = codec8->toUnicode(str1);
|
||||||
hpinfo.appver=QString("v%1").arg(listnum[4]);
|
hpinfo.appver=QString("v%1").arg(listnum[4]);
|
||||||
log(app);
|
errlog(app);
|
||||||
|
|
||||||
//find OS Version
|
//find OS Version
|
||||||
ind+=12;
|
ind+=12;
|
||||||
|
@ -678,7 +678,7 @@ int hpusb::send_info(hp_pkt_in * pkt) {
|
||||||
osv = codec8->toUnicode(str1);
|
osv = codec8->toUnicode(str1);
|
||||||
hpinfo.osver=osv;
|
hpinfo.osver=osv;
|
||||||
// qDebug()<<osv;
|
// qDebug()<<osv;
|
||||||
log(osv);
|
errlog(osv);
|
||||||
|
|
||||||
//find Serial Number
|
//find Serial Number
|
||||||
ind+=16;
|
ind+=16;
|
||||||
|
@ -686,13 +686,13 @@ int hpusb::send_info(hp_pkt_in * pkt) {
|
||||||
QString serial;
|
QString serial;
|
||||||
serial = codec8->toUnicode(str1);
|
serial = codec8->toUnicode(str1);
|
||||||
hpinfo.serialnum=serial;
|
hpinfo.serialnum=serial;
|
||||||
log(serial);
|
errlog(serial);
|
||||||
pkt->calc->recvInfo(hpinfo);
|
pkt->calc->recvInfo(hpinfo);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("Passed a null pointer");
|
errlog("Passed a null pointer");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//Error
|
//Error
|
||||||
|
@ -752,7 +752,7 @@ int hpusb::send_file(hp_pkt_in * pkt) {
|
||||||
//find file name
|
//find file name
|
||||||
QByteArray str1 =rd.mid(3,len);
|
QByteArray str1 =rd.mid(3,len);
|
||||||
filename = codec->toUnicode(str1);
|
filename = codec->toUnicode(str1);
|
||||||
log(QString("File: %1 Type: %2").arg(filename).arg(pkt->pkt_type));
|
errlog(QString("File: %1 Type: %2").arg(filename).arg(pkt->pkt_type));
|
||||||
|
|
||||||
qDebug()<<"hpusb:Checking file type";
|
qDebug()<<"hpusb:Checking file type";
|
||||||
qDebug()<<QString("File: %1 Type: %2").arg(filename).arg(pkt->pkt_type);
|
qDebug()<<QString("File: %1 Type: %2").arg(filename).arg(pkt->pkt_type);
|
||||||
|
@ -862,11 +862,11 @@ int hpusb::get_screen_shot(hp_Handle * handle) {
|
||||||
|
|
||||||
pktin.cmd= CMD_PRIME_RECV_SCREEN;
|
pktin.cmd= CMD_PRIME_RECV_SCREEN;
|
||||||
|
|
||||||
log(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
errlog(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
||||||
|
|
||||||
if (!submit_sync_r_transfer(handle,&pktin)){
|
if (!submit_sync_r_transfer(handle,&pktin)){
|
||||||
|
|
||||||
log(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
errlog(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
||||||
//Trying to understand reply
|
//Trying to understand reply
|
||||||
/* int endpos;
|
/* int endpos;
|
||||||
QByteArray rd = pktin.array;
|
QByteArray rd = pktin.array;
|
||||||
|
@ -874,7 +874,7 @@ int hpusb::get_screen_shot(hp_Handle * handle) {
|
||||||
qDebug()<<"End pos:"<<endpos;
|
qDebug()<<"End pos:"<<endpos;
|
||||||
*imageData = QByteArray(rd.mid(14,endpos+4-14));
|
*imageData = QByteArray(rd.mid(14,endpos+4-14));
|
||||||
// qDebug()<<*imageData;
|
// qDebug()<<*imageData;
|
||||||
log(QString().sprintf("%d bytes received",pktin.array.size()));*/
|
errlog(QString().sprintf("%d bytes received",pktin.array.size()));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,10 +913,10 @@ int hpusb::is_ready(hp_Handle * handle) {
|
||||||
pktin.cmd= CMD_PRIME_CHECK_READY;
|
pktin.cmd= CMD_PRIME_CHECK_READY;
|
||||||
// pktin.data=in_buffer;
|
// pktin.data=in_buffer;
|
||||||
// pktin.size=1024;
|
// pktin.size=1024;
|
||||||
log(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
errlog(QString("%1: Waiting for a reply").arg(__FUNCTION__));
|
||||||
|
|
||||||
if (!submit_sync_r_transfer(handle,&pktin)){
|
if (!submit_sync_r_transfer(handle,&pktin)){
|
||||||
log(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
errlog(QString("%1: Recieved a reply").arg(__FUNCTION__));
|
||||||
//Trying to understand reply
|
//Trying to understand reply
|
||||||
qDebug()<<pktin.array;
|
qDebug()<<pktin.array;
|
||||||
main_err-> dump((uint8_t *)pktin.array.constData(),pktin.array.size());
|
main_err-> dump((uint8_t *)pktin.array.constData(),pktin.array.size());
|
||||||
|
@ -925,7 +925,7 @@ int hpusb::is_ready(hp_Handle * handle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log(QString("%1: Could not send ready request ").arg(__FUNCTION__));
|
errlog(QString("%1: Could not send ready request ").arg(__FUNCTION__));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -971,7 +971,7 @@ int hpusb::load_info(hp_Handle * handle) {
|
||||||
{
|
{
|
||||||
//recieve response
|
//recieve response
|
||||||
if(submit_sync_r_transfer(handle,&pktin)) {
|
if(submit_sync_r_transfer(handle,&pktin)) {
|
||||||
log("failed to read info from device");
|
errlog("failed to read info from device");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,7 +986,7 @@ int hpusb::lookfordouble (QByteArray rd, int start) {
|
||||||
QByteArray str1;
|
QByteArray str1;
|
||||||
QTextCodec * codec = QTextCodec::codecForName("UTF-16");
|
QTextCodec * codec = QTextCodec::codecForName("UTF-16");
|
||||||
app = codec->toUnicode(str1);
|
app = codec->toUnicode(str1);
|
||||||
log(app);
|
errlog(app);
|
||||||
|
|
||||||
int i,ind;
|
int i,ind;
|
||||||
ind=start;
|
ind=start;
|
||||||
|
@ -1160,21 +1160,21 @@ int hpusb::hp_close(hp_Handle * handle)
|
||||||
void hpusb::print_libusb_transfer(struct libusb_transfer *p_t)
|
void hpusb::print_libusb_transfer(struct libusb_transfer *p_t)
|
||||||
{ int i;
|
{ int i;
|
||||||
if ( NULL == p_t){
|
if ( NULL == p_t){
|
||||||
log("No libusb_transfer...\n");
|
errlog("No libusb_transfer...\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("libusb_transfer structure:\n");
|
errlog("libusb_transfer structure:\n");
|
||||||
log(QString().sprintf("flags =%x \n", p_t->flags));
|
errlog(QString().sprintf("flags =%x \n", p_t->flags));
|
||||||
log(QString().sprintf("endpoint=%x \n", p_t->endpoint));
|
errlog(QString().sprintf("endpoint=%x \n", p_t->endpoint));
|
||||||
log(QString().sprintf("type =%x \n", p_t->type));
|
errlog(QString().sprintf("type =%x \n", p_t->type));
|
||||||
log(QString().sprintf("timeout =%d \n", p_t->timeout));
|
errlog(QString().sprintf("timeout =%d \n", p_t->timeout));
|
||||||
// length, and buffer are commands sent to the device
|
// length, and buffer are commands sent to the device
|
||||||
log(QString().sprintf("length =%d \n", p_t->length));
|
errlog(QString().sprintf("length =%d \n", p_t->length));
|
||||||
log(QString().sprintf("actual_length =%d \n", p_t->actual_length));
|
errlog(QString().sprintf("actual_length =%d \n", p_t->actual_length));
|
||||||
log(QString().sprintf("buffer =%p \n", p_t->buffer));
|
errlog(QString().sprintf("buffer =%p \n", p_t->buffer));
|
||||||
|
|
||||||
for (i=0; i < p_t->length; i++){
|
for (i=0; i < p_t->length; i++){
|
||||||
log(QString().sprintf("%d %x", i, p_t->buffer[i]));
|
errlog(QString().sprintf("%d %x", i, p_t->buffer[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1380,7 +1380,7 @@ int hpusb::hotplugcallback(struct libusb_context *ctx, struct libusb_device *dev
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug()<<QString("hpusb::hotplug_callback Unhandled event %1\n").arg(event);
|
qDebug()<<QString("hpusb::hotplug_callback Unhandled event %1\n").arg(event);
|
||||||
log(QString("hpusb::hotplug_callback Unhandled event %1\n").arg(event));
|
errlog(QString("hpusb::hotplug_callback Unhandled event %1\n").arg(event));
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include "hpusb.h"
|
#include "hpusb.h"
|
||||||
#include "matrixdata.h"
|
#include "matrixdata.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct m_Size {
|
struct m_Size {
|
||||||
int row;
|
int row;
|
||||||
int column;
|
int column;
|
||||||
|
|
|
@ -15,9 +15,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ERRORHANDLER_H
|
|
||||||
#define ERRORHANDLER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
@ -25,6 +22,9 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#ifndef ERRORHANDLER_H
|
||||||
|
#define ERRORHANDLER_H
|
||||||
|
|
||||||
enum ErrLevel {
|
enum ErrLevel {
|
||||||
L0, //abort
|
L0, //abort
|
||||||
L1, //fault
|
L1, //fault
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
class errorHandler;
|
class errorHandler;
|
||||||
extern errorHandler *main_err;
|
extern errorHandler *main_err;
|
||||||
#define log(a) main_err->error(L7,0,QString(a),QString());
|
#define errlog(a) main_err->error(L7,0,QString(a),QString());
|
||||||
#define err(a,b,c) main_err->error(a,b,QString(c),QString());
|
#define err(a,b,c) main_err->error(a,b,QString(c),QString());
|
||||||
|
|
||||||
#endif // GLOBAL_H
|
#endif // GLOBAL_H
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HP_MDIVARIABLEEDIT_H
|
|
||||||
#define HP_MDIVARIABLEEDIT_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMdiSubWindow>
|
#include <QMdiSubWindow>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#ifndef HP_MDIVARIABLEEDIT_H
|
||||||
|
#define HP_MDIVARIABLEEDIT_H
|
||||||
|
|
||||||
#include "vartablemodel.h"
|
#include "vartablemodel.h"
|
||||||
#include "hpdata.h"
|
#include "hpdata.h"
|
||||||
#include "hp_mdiwindow.h"
|
#include "hp_mdiwindow.h"
|
||||||
|
@ -45,6 +45,8 @@ protected:
|
||||||
QString calculator;
|
QString calculator;
|
||||||
bool content;
|
bool content;
|
||||||
void setup();
|
void setup();
|
||||||
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hp_mdiVariableEdit(QWidget *parent = nullptr,
|
hp_mdiVariableEdit(QWidget *parent = nullptr,
|
||||||
|
@ -56,12 +58,15 @@ public:
|
||||||
AbstractData * data
|
AbstractData * data
|
||||||
);
|
);
|
||||||
void show();
|
void show();
|
||||||
~hp_mdiVariableEdit();
|
bool save() override;
|
||||||
|
bool saveAs() override;
|
||||||
|
bool maybeSave();
|
||||||
|
~hp_mdiVariableEdit() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void eventSave();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HP_MDIVARIABLEEDIT_H
|
#endif // HP_MDIVARIABLEEDIT_H
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
struct itemData {
|
struct itemData {
|
||||||
double dReal=0.0;
|
double dReal=0.0;
|
||||||
double dImaginary=0.0;
|
double dImaginary=0.0;
|
||||||
QString sValue=QStringLiteral("NaH");
|
QString sValue=QStringLiteral("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef VARTABLEMODEL_H
|
#include <QtWidgets>
|
||||||
#define VARTABLEMODEL_H
|
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#ifndef VARTABLEMODEL_H
|
||||||
|
#define VARTABLEMODEL_H
|
||||||
|
|
||||||
#include "hpdata.h"
|
#include "hpdata.h"
|
||||||
#include "abstractdata.h"
|
#include "abstractdata.h"
|
||||||
|
@ -28,7 +31,6 @@ class varTableModel: public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QObject * q_parent;
|
QObject * q_parent;
|
||||||
const static QStringList real_header;
|
const static QStringList real_header;
|
||||||
|
@ -40,18 +42,32 @@ private:
|
||||||
QList<QList<double>> dataarray;
|
QList<QList<double>> dataarray;
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
|
bool isUntitled;
|
||||||
|
QDir defaultPath;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
varTableModel(QObject *parent = nullptr,
|
varTableModel(QObject *parent = nullptr,
|
||||||
AbstractData * data =nullptr,
|
AbstractData * data =nullptr,
|
||||||
QString file = QStringLiteral(""),
|
QString file = QStringLiteral(""),
|
||||||
hp_DataType dtype = HP_MAIN);
|
hp_DataType dtype = HP_MAIN);
|
||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const override;
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
|
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
|
|
||||||
|
bool save(QFileInfo file);
|
||||||
|
bool saveAs(QFileInfo file);
|
||||||
|
bool save(QString calculator);
|
||||||
|
bool saveAs(QString calculator);
|
||||||
|
bool saveFile(const QString &fileName);
|
||||||
|
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
~varTableModel();
|
~varTableModel() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VARTABLEMODEL_H
|
#endif // VARTABLEMODEL_H
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include <QFileIconProvider>
|
#include <QFileIconProvider>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include <global.h>
|
//#include <global.h>
|
||||||
#include "hpusb.h"
|
#include "hpusb.h"
|
||||||
#include "datamodel.h"
|
#include "datamodel.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
#include "eventtimer.h"
|
#include "eventtimer.h"
|
||||||
|
|
||||||
errorHandler *main_err;
|
errorHandler *main_err;
|
||||||
#define log(a) main_err->error(L7,0,QString(a),QString());
|
#define errlog(a) main_err->error(L7,0,QString(a),QString());
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
|
@ -154,7 +154,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(eventExit()));
|
connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(eventExit()));
|
||||||
|
|
||||||
//default data
|
//default data
|
||||||
log("Initialising....");
|
errlog("Initialising....");
|
||||||
|
|
||||||
if (hpapi->hp_init())
|
if (hpapi->hp_init())
|
||||||
err(L1,0,QString().sprintf("%s Failed to open libusb",__FUNCTION__));
|
err(L1,0,QString().sprintf("%s Failed to open libusb",__FUNCTION__));
|
||||||
|
@ -187,11 +187,11 @@ void MainWindow::testFunction() {
|
||||||
if (pH) {
|
if (pH) {
|
||||||
|
|
||||||
cmd = QInputDialog::getInt(this,"Get Command","CMD:",0,0,0xFFFF);
|
cmd = QInputDialog::getInt(this,"Get Command","CMD:",0,0,0xFFFF);
|
||||||
log("command is "+QString().sprintf("%x",cmd));
|
errlog("command is "+QString().sprintf("%x",cmd));
|
||||||
pH->vpkt_send_experiments(cmd);
|
pH->vpkt_send_experiments(cmd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log("Could not get calculator");
|
errlog("Could not get calculator");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +651,7 @@ void MainWindow::monitorAddImage(hp_ScreenShot scrnshot) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("Could not load image");
|
errlog("Could not load image");
|
||||||
}
|
}
|
||||||
ui->dwMonitor->show();
|
ui->dwMonitor->show();
|
||||||
}
|
}
|
||||||
|
@ -803,7 +803,7 @@ void MainWindow::treeMenuAction(bool clicked) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log(QStringLiteral("treeItem is null"));
|
errlog(QStringLiteral("treeItem is null"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ void MatrixData::addRow(int row)
|
||||||
int i;
|
int i;
|
||||||
QList<itemData> * rowlist;
|
QList<itemData> * rowlist;
|
||||||
|
|
||||||
|
|
||||||
// qDebug()<<"MatrixData::addRow" << row;
|
// qDebug()<<"MatrixData::addRow" << row;
|
||||||
rows=matrix.size();
|
rows=matrix.size();
|
||||||
if (rows<=row)
|
if (rows<=row)
|
||||||
|
@ -147,6 +148,8 @@ void MatrixData::upsize(int newrow,int newcol) {
|
||||||
qDebug()<<"MatrixData::upsize";
|
qDebug()<<"MatrixData::upsize";
|
||||||
|
|
||||||
itemData item;
|
itemData item;
|
||||||
|
item.sValue=QStringLiteral("0");
|
||||||
|
|
||||||
rows = matrix.size();
|
rows = matrix.size();
|
||||||
// qDebug()<<"MatrixData::upsize - rows:"<<newrow<<" columns:"<<newcol;
|
// qDebug()<<"MatrixData::upsize - rows:"<<newrow<<" columns:"<<newcol;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ int treeModel::createRoot()
|
||||||
AbstractData * treeModel::createData(hp_Data data_in) {
|
AbstractData * treeModel::createData(hp_Data data_in) {
|
||||||
|
|
||||||
AbstractData * obj=nullptr;
|
AbstractData * obj=nullptr;
|
||||||
log("TreeModel::Creating Data Stucture");
|
errlog("TreeModel::Creating Data Stucture");
|
||||||
|
|
||||||
switch (data_in.type) {
|
switch (data_in.type) {
|
||||||
case HP_APP: {
|
case HP_APP: {
|
||||||
|
|
|
@ -19,9 +19,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "vartablemodel.h"
|
#include "vartablemodel.h"
|
||||||
#include "abstractdata.h"
|
|
||||||
|
|
||||||
const QStringList varTableModel::real_header={ "A",
|
const QStringList varTableModel::real_header={ "A",
|
||||||
"B",
|
"B",
|
||||||
|
@ -80,16 +85,52 @@ varTableModel::varTableModel(QObject *parent,
|
||||||
//REWORK!
|
//REWORK!
|
||||||
QModelIndex varTableModel::parent(const QModelIndex &index) const {
|
QModelIndex varTableModel::parent(const QModelIndex &index) const {
|
||||||
|
|
||||||
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags varTableModel::flags(const QModelIndex &index) const {
|
||||||
|
|
||||||
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||||
|
}
|
||||||
|
|
||||||
//rework!
|
//rework!
|
||||||
QModelIndex varTableModel::index(int row, int column, const QModelIndex &parent) const {
|
QModelIndex varTableModel::index(int row, int column, const QModelIndex &parent) const {
|
||||||
|
|
||||||
return createIndex(row,column);
|
return createIndex(row,column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//alter the data table if data is edited
|
||||||
|
bool varTableModel::setData(const QModelIndex &index, const QVariant &value, int role) {
|
||||||
|
|
||||||
|
qDebug()<<"Data Changed";
|
||||||
|
|
||||||
|
if (type==HP_LIST) {
|
||||||
|
List * list;
|
||||||
|
list = static_cast<List *>(dataobj);
|
||||||
|
list->setItem(index.row(),value.toString(),value.toReal());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (type==HP_MATRIX) {
|
||||||
|
Matrix * matrix;
|
||||||
|
matrix = static_cast<Matrix *>(dataobj);
|
||||||
|
matrix->setItem(index.row(),index.column(),value.toString(),value.toReal());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (type==HP_REAL) {
|
||||||
|
Real * real;
|
||||||
|
real = static_cast<Real *>(dataobj);
|
||||||
|
// item = real->getItem(index.row());
|
||||||
|
// return item;
|
||||||
|
}
|
||||||
|
if (type==HP_COMPLEX) {
|
||||||
|
Complex * complex;
|
||||||
|
complex = static_cast<Complex *>(dataobj);
|
||||||
|
// item = complex->getItem(index.row());
|
||||||
|
// return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void varTableModel::setup()
|
void varTableModel::setup()
|
||||||
{
|
{
|
||||||
|
@ -108,23 +149,23 @@ int varTableModel::rowCount(const QModelIndex & parent) const
|
||||||
int size=16; //should be zero
|
int size=16; //should be zero
|
||||||
if (type==HP_LIST) {
|
if (type==HP_LIST) {
|
||||||
List * list;
|
List * list;
|
||||||
list = (List *)dataobj;
|
list = static_cast<List *>(dataobj);
|
||||||
size= list->getListSize();
|
size= list->getListSize()+1;
|
||||||
}
|
}
|
||||||
if (type==HP_REAL) {
|
if (type==HP_REAL) {
|
||||||
Real * real;
|
Real * real;
|
||||||
real = (Real *)dataobj;
|
real = static_cast<Real *>(dataobj);
|
||||||
size= real->getListSize();
|
size= real->getListSize();
|
||||||
}
|
}
|
||||||
if (type==HP_COMPLEX) {
|
if (type==HP_COMPLEX) {
|
||||||
Complex * complex;
|
Complex * complex;
|
||||||
complex = (Complex *)dataobj;
|
complex = static_cast<Complex *>(dataobj);
|
||||||
size= complex->getListSize();
|
size= complex->getListSize();
|
||||||
}
|
}
|
||||||
if (type==HP_MATRIX) {
|
if (type==HP_MATRIX) {
|
||||||
Matrix * matrix;
|
Matrix * matrix;
|
||||||
matrix = (Matrix *)dataobj;
|
matrix = static_cast<Matrix *>(dataobj);
|
||||||
size= matrix->getMatrixRows();
|
size= matrix->getMatrixRows()+1;
|
||||||
// qDebug()<<matrix->getName()<<" row"<<size;
|
// qDebug()<<matrix->getName()<<" row"<<size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,14 +177,14 @@ int varTableModel::columnCount(const QModelIndex & /*parent*/) const
|
||||||
int size=1;
|
int size=1;
|
||||||
if (type==HP_MATRIX) {
|
if (type==HP_MATRIX) {
|
||||||
Matrix * matrix;
|
Matrix * matrix;
|
||||||
matrix = (Matrix *)dataobj;
|
matrix = static_cast<Matrix *>(dataobj);
|
||||||
size= matrix->getMatrixColumns();
|
size= matrix->getMatrixColumns()+1;
|
||||||
// qDebug()<<matrix->getName()<<" column"<<size;
|
// qDebug()<<matrix->getName()<<" column"<<size;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (type==HP_COMPLEX) {
|
if (type==HP_COMPLEX) {
|
||||||
Complex * complex;
|
Complex * complex;
|
||||||
complex = (Complex *)dataobj;
|
complex = static_cast<Complex *>(dataobj);
|
||||||
// size= matrix->getMatrixColumns();
|
// size= matrix->getMatrixColumns();
|
||||||
// qDebug()<<matrix->getName()<<" column"<<size;
|
// qDebug()<<matrix->getName()<<" column"<<size;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -151,6 +192,15 @@ int varTableModel::columnCount(const QModelIndex & /*parent*/) const
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void varTableModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) {
|
||||||
|
|
||||||
|
|
||||||
|
qDebug()<<"Data Changed";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant varTableModel::data(const QModelIndex &index, int role) const
|
QVariant varTableModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
|
@ -159,25 +209,25 @@ QVariant varTableModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
if (type==HP_LIST) {
|
if (type==HP_LIST) {
|
||||||
List * list;
|
List * list;
|
||||||
list = (List *)dataobj;
|
list = static_cast<List *>(dataobj);
|
||||||
item = list->getItem(index.row());
|
item = list->getItem(index.row());
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
if (type==HP_MATRIX) {
|
if (type==HP_MATRIX) {
|
||||||
Matrix * matrix;
|
Matrix * matrix;
|
||||||
matrix = (Matrix *)dataobj;
|
matrix = static_cast<Matrix *>(dataobj);
|
||||||
item = matrix->getItem(index.row(),index.column());
|
item = matrix->getItem(index.row(),index.column());
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
if (type==HP_REAL) {
|
if (type==HP_REAL) {
|
||||||
Real * real;
|
Real * real;
|
||||||
real = (Real *)dataobj;
|
real = static_cast<Real *>(dataobj);
|
||||||
item = real->getItem(index.row());
|
item = real->getItem(index.row());
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
if (type==HP_COMPLEX) {
|
if (type==HP_COMPLEX) {
|
||||||
Complex * complex;
|
Complex * complex;
|
||||||
complex = (Complex *)dataobj;
|
complex = static_cast<Complex *>(dataobj);
|
||||||
item = complex->getItem(index.row());
|
item = complex->getItem(index.row());
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -227,6 +277,72 @@ QVariant varTableModel::headerData(int section, Qt::Orientation orientation, in
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool varTableModel::save(QString Calculator)
|
||||||
|
{
|
||||||
|
if (isUntitled) {
|
||||||
|
return saveAs(Calculator);
|
||||||
|
} else {
|
||||||
|
return saveFile("xx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool varTableModel::save(QFileInfo file)
|
||||||
|
{
|
||||||
|
if (isUntitled) {
|
||||||
|
return saveAs(file);
|
||||||
|
} else {
|
||||||
|
return saveFile("xx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool varTableModel::saveAs(QFileInfo fileinfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
// QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
|
||||||
|
// fileinfo.absoluteFilePath());
|
||||||
|
// if (fileName.isEmpty())
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
//return saveFile(fileName);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool varTableModel::saveAs(QString calculaor)
|
||||||
|
{
|
||||||
|
|
||||||
|
// QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
|
||||||
|
// fileinfo.absoluteFilePath());
|
||||||
|
QString fileName="";
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return saveFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool varTableModel::saveFile(const QString &fileName)
|
||||||
|
{
|
||||||
|
QFileInfo fileinfo(defaultPath,fileName);
|
||||||
|
QFile file(fileinfo.absoluteFilePath());
|
||||||
|
if (!file.open(QFile::WriteOnly | QFile::Text)) {
|
||||||
|
// QMessageBox::warning(this, tr("MDI"),
|
||||||
|
// tr("Cannot write file %1:\n%2.")
|
||||||
|
// .arg(QDir::toNativeSeparators(fileName), file.errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream out(&file);
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
// out << toPlainText();
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
|
// setCurrentFile(fileName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
varTableModel::~varTableModel() {
|
varTableModel::~varTableModel() {
|
||||||
qDebug()<<"Entering ~varTableModel()";
|
qDebug()<<"Entering ~varTableModel()";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue