diff --git a/cntfilesystemmodel.cpp b/cntfilesystemmodel.cpp index ec66811..e210a6e 100644 --- a/cntfilesystemmodel.cpp +++ b/cntfilesystemmodel.cpp @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include #include @@ -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: ; } diff --git a/hp_mdivariableedit.cpp b/hp_mdivariableedit.cpp index 49e17b3..6d0212a 100644 --- a/hp_mdivariableedit.cpp +++ b/hp_mdivariableedit.cpp @@ -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(); } diff --git a/include/hp_mdivariableedit.h b/include/hp_mdivariableedit.h index b1110de..8ed01b0 100644 --- a/include/hp_mdivariableedit.h +++ b/include/hp_mdivariableedit.h @@ -22,6 +22,7 @@ #include #include #include +#include #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(); diff --git a/include/mainwindow.h b/include/mainwindow.h index 64f381b..6b84bec 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -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); diff --git a/include/vartablemodel.h b/include/vartablemodel.h index eec48c8..72d511c 100644 --- a/include/vartablemodel.h +++ b/include/vartablemodel.h @@ -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; diff --git a/mainwindow.cpp b/mainwindow.cpp index 031cada..8d30266 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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(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() { diff --git a/mainwindow.ui b/mainwindow.ui index 7309c1b..d8272b7 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -64,9 +64,6 @@ Edit - - - diff --git a/treemodel.cpp b/treemodel.cpp index b9e790e..6298398 100644 --- a/treemodel.cpp +++ b/treemodel.cpp @@ -26,6 +26,8 @@ #include "treemodel.h" #include "hptreeitem.h" +#include +#include #include #include #include @@ -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(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) { diff --git a/vartablemodel.cpp b/vartablemodel.cpp index 503be4b..add63e2 100644 --- a/vartablemodel.cpp +++ b/vartablemodel.cpp @@ -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"<getType(); - } +// } return; }