Matrix Update

This commit is contained in:
Ian Gebbie 2020-02-08 21:29:59 +02:00
parent e773148a2b
commit 848d8af1af
9 changed files with 224 additions and 51 deletions

View file

@ -22,6 +22,8 @@
#include <QStringListModel>
#include <hp_mditexteditor.h>
#include <hp_infodialog.h>
#include <hp_mdivariableedit.h>
#include <QSettings>
#include <QTextCodec>
#include <utility>
@ -301,15 +303,43 @@ bool contentFileSystemModel::openFile(QMdiArea * mdiwin,QFileInfo info) {
hp_mdiTextEdit * hptextedit = nullptr;
AbstractData * data=nullptr;
QString calc;
QString name;
hp_DataType type;
hp_Information hpinfo;
// hp_infoDialog * hpinfodlg;
hp_mdiVariableEdit * hpvaredit=nullptr;
data = readFile(info);
if (data!=nullptr) {
if (hptextedit==nullptr)
hptextedit = new hp_mdiTextEdit(mdiwin,info, data);
if (hptextedit!=nullptr) {
hptextedit ->show();
return true;
}
type=data->getType();
switch (type) {
case HP_NOTE:
case HP_PROG: {
if (hptextedit==nullptr)
hptextedit = new hp_mdiTextEdit(mdiwin,info, data);
if (hptextedit!=nullptr)
hptextedit ->show();
}
break;
case HP_CAS:
case HP_REAL:
case HP_COMPLEX:
case HP_LIST:
case HP_MATRIX: {
if (hpvaredit==nullptr) {
if (data!=nullptr) {
qDebug()<<"Opening Varedit";
hpvaredit = new hp_mdiVariableEdit(mdiwin,info,data);
}
}
if (hpvaredit!=nullptr)
hpvaredit ->show();
}
break;
}
}
else {
qWarning()<<"Read file return null data";
@ -375,7 +405,19 @@ AbstractData * contentFileSystemModel::readFile(QFileInfo fileinfo) const {
data = new Notes(filedata.filename, HP_NOTE, QStringLiteral(""));
data->parseData(in);
}
break;
break;
case HP_LIST: {
qDebug()<<"HP_LIST";
data = new List(filedata.filename, HP_LIST);
data->parseData(in);
}
break;
case HP_MATRIX: {
qDebug()<<"HP_MATRIX";
data = new Matrix(filedata.filename, HP_MATRIX);
data->parseData(in);
}
break;
default: ;
}

View file

@ -31,18 +31,58 @@ hp_mdiVariableEdit::hp_mdiVariableEdit(QWidget *parent,
hptreeitem=treeItem;
hpcalc = dataStore;
filename=treeItem->getFileName();
type=treeItem->getType();
filename = QStringLiteral("NULL");
if (hpcalc!=nullptr) {
calculator=hpcalc->getCalculatorName();
if (treeItem!=nullptr) {
filename=treeItem->getFileName();
type=treeItem->getType();
}
else {
qWarning()<<"hpcalc is null";
}
data=hpcalc->getData(filename,type);
}
else {
qWarning()<<"hpcalc is null";
}
content=false;
setup();
setWindowTitle(calculator+": "+filename);
}
hp_mdiVariableEdit::hp_mdiVariableEdit(QWidget *parent,
QFileInfo file,
AbstractData * data_in)
: hp_MdiWindow(parent)
{
setMinimumSize(200,200);
setMaximumSize(1000,1000);
setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
calculator=QStringLiteral("Content: ");
content=true;
hptreeitem=nullptr;
hpcalc = nullptr;
filename=file.fileName();
data = data_in;
if (data!=nullptr)
type=data->getType();
setup();
setWindowTitle(filename);
setWindowTitle(calculator+filename);
}
void hp_mdiVariableEdit::setup() {
if (hpcalc) {
varmodel = new varTableModel(this,hpcalc,filename,type);
if (data!=nullptr) {
varmodel = new varTableModel(this,data,filename,type);
tableView = new QTableView(this);
tableView->setModel(varmodel);
setWidget(tableView);
@ -50,8 +90,11 @@ void hp_mdiVariableEdit::setup() {
}
void hp_mdiVariableEdit::show() {
if(tableView)
if(tableView!=nullptr)
tableView->show();
else {
qWarning()<<"hp_mdiVariableEdit::show tableView null";
}
hp_MdiWindow::show();
}

View file

@ -22,6 +22,7 @@
#include <QWidget>
#include <QMdiSubWindow>
#include <QTableView>
#include <QFileInfo>
#include "vartablemodel.h"
#include "hpdata.h"
#include "hp_mdiwindow.h"
@ -37,19 +38,23 @@ protected:
hpTreeItem * hptreeitem =nullptr;
varTableModel * varmodel =nullptr;
hpCalcData * hpcalc =nullptr;
AbstractData * data = nullptr;
QString filename;
hp_DataType type;
hp_DataType type=HP_MAIN;
QFileInfo file;
QString calculator;
bool content;
void setup();
public:
explicit hp_mdiVariableEdit(QWidget *parent = nullptr,
hp_mdiVariableEdit(QWidget *parent = nullptr,
hpTreeItem * treeItem = nullptr,
hpCalcData * dataStore =nullptr
);
// explicit hp_mdiVariableEdit(QWidget *parent,
// hp_DataStruct filedata,
// hpCalcData * dataStore
// );
hp_mdiVariableEdit(QWidget *parent,
QFileInfo file,
AbstractData * data
);
void show();
~hp_mdiVariableEdit();

View file

@ -57,7 +57,6 @@ public:
void writeStatus(QString);
void writeChatter(QString);
void addDummy();
void createActions();
hpusb * getAPI();
signals:
@ -84,12 +83,21 @@ private slots:
void readSettings();
void setTimerStopped();
void eventTileWindow();
void eventCascadeWindow();
void eventCloseWindow();
void eventCloseAllWindow();
void eventPrevious();
void eventNext();
void eventSave();
void eventSaveAs();
void eventCreateFolder();
void eventCreateNote();
void eventCreateProgram();
void eventExit();
treeModel * getTreeModel();
void treeMenuAction(bool);

View file

@ -42,7 +42,7 @@ private:
public:
varTableModel(QObject *parent = nullptr,
hpCalcData * dataStore =nullptr,
AbstractData * data =nullptr,
QString file = QStringLiteral(""),
hp_DataType dtype = HP_MAIN);
QModelIndex parent(const QModelIndex &index) const;

View file

@ -81,14 +81,11 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
setWindowIcon(QIcon::fromTheme("accessories-calculator",
QIcon(":/icons/monitor_32x32.png")));
createActions();
createLogWindow();
setTreeMenu();
setContentWindow();
//create some sub menus
QToolButton *createNewButton=
dynamic_cast<QToolButton*>(ui->toolBar->widgetForAction(ui->actionCreateNew));
createNewButton->setPopupMode(QToolButton::InstantPopup);
@ -109,7 +106,6 @@ MainWindow::MainWindow(QWidget *parent) :
createNewButton->setMenu(createMenu);
//Hack to fix QT resizing bug
resizeDocks({ui->dwCalculator,ui->dwContent},{0,0}, Qt::Horizontal);
@ -121,10 +117,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->tvCalculators->setDropIndicatorShown(true);
ui->tvCalculators->show();
//setup actions
connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(onOpen()));
connect(ui->actionAbout_HP_Connect,SIGNAL(triggered()),this,SLOT(about()));
// connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit()));
@ -151,6 +144,15 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->tvContent, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(on_tvContent_customContextMenuRequested(const QPoint &)));
connect(hpapi, SIGNAL(hotplug(int)), this, SLOT(hotplug_handler(int)));
connect(ui->actionTile,SIGNAL(triggered()),this,SLOT(eventTileWindow()));
connect(ui->actionCascade,SIGNAL(triggered()),this,SLOT(eventCascadeWindow()));
connect(ui->actionClose,SIGNAL(triggered()),this,SLOT(eventCloseWindow()));
connect(ui->actionClose_all,SIGNAL(triggered()),this,SLOT(eventCloseAllWindow()));
connect(ui->actionNext,SIGNAL(triggered()),this,SLOT(eventNext()));
connect(ui->actionPrevious,SIGNAL(triggered()),this,SLOT(eventPrevious()));
connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(eventExit()));
//default data
log("Initialising....");
@ -410,6 +412,48 @@ void MainWindow::eventSaveAs() {
qDebug()<<"Save As Pressed";
}
void MainWindow::eventTileWindow() {
QMdiArea * mdi=getMdi();
mdi->tileSubWindows();
}
void MainWindow::eventCascadeWindow() {
QMdiArea * mdi=getMdi();
mdi->cascadeSubWindows();
}
void MainWindow::eventCloseWindow() {
QMdiArea * mdi=getMdi();
mdi->closeActiveSubWindow();
}
void MainWindow::eventCloseAllWindow() {
QMdiArea * mdi=getMdi();
mdi->closeAllSubWindows();
}
void MainWindow::eventPrevious() {
QMdiArea * mdi=getMdi();
mdi->activatePreviousSubWindow();
}
void MainWindow::eventNext() {
QMdiArea * mdi=getMdi();
mdi->activateNextSubWindow();
}
void MainWindow::eventExit() {
QMdiArea * mdi=getMdi();
mdi->closeAllSubWindows();
close();
}
void MainWindow::eventCreateFolder() {
QString newName= QStringLiteral("New Folder");
@ -469,16 +513,6 @@ void MainWindow::onOptions(bool clicked)
optiondlg->show();
}
//Dummy from examples -- edit
void MainWindow::createActions()
{
// ui->toolBar->addWidget(QPushButton(QIcon(":/icons/about_32x32.png"),"test"));
// const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/icons/new.png"));
// QAction *newAct = new QAction(newIcon, tr("&New"), this);
};
//show or hide content window
void MainWindow::showContent() {

View file

@ -64,9 +64,6 @@
<property name="title">
<string>Edit</string>
</property>
<addaction name="actionCut"/>
<addaction name="actionCopy"/>
<addaction name="actionPaste"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
</widget>

View file

@ -26,6 +26,8 @@
#include "treemodel.h"
#include "hptreeitem.h"
#include <hp_infodialog.h>
#include <hp_mdivariableedit.h>
#include <hp_mditexteditor.h>
#include <QStringListModel>
#include <QMimeData>
@ -123,18 +125,59 @@ void treeModel::openFile(QMdiArea * mdiwin, QModelIndex &index) {
hp_mdiTextEdit * hptextedit = nullptr;
AbstractData * data=nullptr;
hpTreeItem * item=nullptr;
QString calc;
QString name;
hp_DataType type;
hp_Information hpinfo;
hp_infoDialog * hpinfodlg=nullptr;
hpCalcData * hpdata=nullptr;
hp_mdiVariableEdit * hpvaredit=nullptr;
item = static_cast<hpTreeItem *>(itemFromIndex(index));
data=getData(index);
if ((data!=nullptr)&&(item!=nullptr)) {
if (hptextedit==nullptr)
hptextedit = new hp_mdiTextEdit(mdiwin,item, data);
if (hptextedit!=nullptr)
hptextedit ->show();
calc=item->getCalculatorName();
name=item->getFileName();
type=data->getType();
hpdata=getHpCalcData(calc);
switch (type) {
case HP_MAIN: {
hpinfo=hpdata->getInfo();
hpinfodlg = new hp_infoDialog(mdiwin,hpinfo);
hpinfodlg->show();
}
break;
case HP_NOTE:
case HP_PROG: {
if (hptextedit==nullptr)
hptextedit = new hp_mdiTextEdit(mdiwin,item, data);
if (hptextedit!=nullptr)
hptextedit ->show();
}
break;
case HP_CAS:
case HP_REAL:
case HP_COMPLEX:
case HP_LIST:
case HP_MATRIX: {
if (hpvaredit==nullptr) {
if (data!=nullptr) {
hpvaredit = new hp_mdiVariableEdit(mdiwin,item,hpdata);
}
}
if (hpvaredit!=nullptr)
hpvaredit ->show();
}
break;
}
}
else {
qDebug()<<"Null data";
}
return;
}
void treeModel::renameFile(QModelIndex &index,QString newName) {

View file

@ -65,13 +65,13 @@ const QStringList varTableModel::complex_header={ "Z0",
};
varTableModel::varTableModel(QObject *parent,
hpCalcData * dataStore,
AbstractData * data,
QString file,
hp_DataType dtype)
:QAbstractTableModel(parent)
{
q_parent=parent;
hpcalc = dataStore;
dataobj = data;
filename=file;
type=dtype;
setup();
@ -90,14 +90,15 @@ QModelIndex varTableModel::index(int row, int column, const QModelIndex &parent)
return createIndex(row,column);
}
void varTableModel::setup()
{
if (hpcalc) {
// if (hpcalc) {
dataobj=hpcalc->getData(filename,type);
// dataobj=hpcalc->getData(filename,type);
// qDebug()<<"varTableModel: type"<<dataobj->getType();
}
// }
return;
}