mirror of
https://github.com/Indy970/QtHPConnect
synced 2024-12-25 21:59:15 +01:00
MAtrix Progress
This commit is contained in:
parent
0ede818ad6
commit
0a69a38559
50 changed files with 503 additions and 11084 deletions
122
Notes
122
Notes
|
@ -1,122 +0,0 @@
|
|||
Command d-249 Settings
|
||||
|
||||
Send 0x00 0xFF
|
||||
|
||||
Edit a 0xFF 0x59
|
||||
|
||||
|
||||
Read info
|
||||
get 00 fa 01 00 00 00 6C string
|
||||
|
||||
Read is_ready
|
||||
get 00 fa 01 00 00 00 6c string
|
||||
|
||||
Get Image return header
|
||||
00 CMD 01 [ SIZE ][CRC ][ ]
|
||||
00 fc 01 00 00 1d 73 5a 2d 08 ff ff ff ff || 89 [ 50 4E 47 ] (PNG)
|
||||
P N G
|
||||
|
||||
PNG Magic number 89 50 4e 47 0d 0a 1a 0a
|
||||
|
||||
Subsequent chucnks, byte 1 = chunk number
|
||||
|
||||
|
||||
Chunk header
|
||||
xx chunk no
|
||||
|
||||
data
|
||||
|
||||
|
||||
|
||||
Header format
|
||||
|
||||
00
|
||||
|
||||
Type
|
||||
|
||||
01
|
||||
|
||||
Num Packets 00 00 00 00
|
||||
|
||||
CRC??
|
||||
|
||||
00 00 00 6c String Marker
|
||||
|
||||
|
||||
Read procedure
|
||||
|
||||
1. Get message
|
||||
2. Get header
|
||||
3, Exract data from header
|
||||
3. If chuncks get chunks
|
||||
4. Combine chunks to data
|
||||
5. issue complete message to parser
|
||||
6. look for next message
|
||||
7. stop when return length 0;
|
||||
|
||||
|
||||
Set GetInfo, IsReady
|
||||
|
||||
|
||||
NOTE Program data comes across in ASCII :)
|
||||
|
||||
First header with serial number is repeated
|
||||
|
||||
tokens calc.hpvars
|
||||
calc.hpsettings
|
||||
list off all apps comes through in Ascii with & as Start
|
||||
|
||||
|
||||
Near full dump, reading over 213 chuncks and still not enough
|
||||
|
||||
00 f7 01 00 00 18 46 00 1e d6 4a 63 00 61 00 6c
|
||||
|
||||
File header
|
||||
[ int } TYPE {Data ...
|
||||
00 F7 01 00 00 00 00 00 00 ?? ?? ?? Name Start ...
|
||||
Name len
|
||||
|
||||
|
||||
|
||||
Do a get settings
|
||||
|
||||
|
||||
CAS SETTINGS - 6 chunks follow
|
||||
0040 00 f7 01 00 00 18 33 00 1c 8a c6 63 00 61 00 73 .÷....3...Æc.a.s
|
||||
|
||||
CAL VARS - 0 chunks follow
|
||||
0040 00 f7 01 00 00 01 02 00 16 93 1d 63 00 61 00 6c .÷.........c.a.l
|
||||
|
||||
|
||||
L lists - A list item per packet - 0 chunks follow
|
||||
0040 00 f7 01 00 00 00 60 03 04 58 8f 4c 00 31 00 fe .÷....`..X.L.1.þ
|
||||
|
||||
M Lists - A list item per packet
|
||||
0040 00 f7 01 00 00 00 38 04 04 bf 4e 4d 00 30 00 01 .÷....8..¿NM.0..
|
||||
|
||||
|
||||
Prog
|
||||
0040 00 f7 01 00 00 02 3c 06 06 51 72 41 00 57 00 47 .÷....<..QrA.W.G
|
||||
|
||||
|
||||
Next Prog - spread over 0xF chunks
|
||||
0040 00 f7 01 00 00 3e 18 06 0e 80 79 65 00 65 00 78 .÷...>....ye.e.x
|
||||
|
||||
Next Prog - sperad over ?? chunks
|
||||
0040 00 f7 01 00 0d 01 dc 06 08 13 cf 43 00 6e 00 48 .÷....Ü...ÏC.n.H
|
||||
|
||||
CAN READ ALL!!!
|
||||
|
||||
|
||||
|
||||
0040 00 f7 01 00 00 00 b8 00 10 24 0b 73 00 65 00 74 .÷....¸..$.s.e.t
|
||||
0050 00 74 00 69 00 6e 00 67 00 73 00 dc 2d 6b c9 03 .t.i.n.g.s.Ü-kÉ.
|
||||
|
||||
|
||||
0040 00 f7 01 00 00 00 20 04 04 c8 9c 4d 00 37 00 01 .÷.... ..È.M.7..
|
||||
|
||||
0040 00 f7 01 00 00 00 20 04 04 68 a9 4d 00 38 00 01 .÷.... ..h©M.8..
|
||||
|
||||
0040 00 f7 01 00 00 00 38 04 04 a5 92 4d 00 39 00 01 .÷....8..¥.M.9..
|
||||
|
||||
0040 00 f7 01 00 00 3e 18 06 0e 80 79 65 00 65 00 78 .÷...>....ye.e.x
|
294
QtHPConnect.pro
294
QtHPConnect.pro
|
@ -1,31 +1,303 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2019-01-21T20:42:03
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
TARGET = QtHPConnect
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
VERSION_MAJOR = HP_MAJOR_VERSION
|
||||
VERSION_MINOR = HP_MINOR_VERSION
|
||||
VERSION_PATCH = HP_MINOR_PATCH
|
||||
VERSION_BUILD = HP_MINOR_BUILD
|
||||
|
||||
DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\
|
||||
"VERSION_MINOR=$$VERSION_MINOR"\
|
||||
"VERSION_PATCH=$$VERSION_PATCH"\
|
||||
"VERSION_BUILD=$$VERSION_BUILD"
|
||||
|
||||
#Target version
|
||||
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_PATCH}$${VERSION_BUILD}
|
||||
|
||||
#QMAKE_CFLAGS += -Wno-unused-parameter -Werror=shadow -Werror=write-strings -Werror=redundant-decls -Werror=format -Werror=format-nonliteral -Werror=date-time -Werror=missing-prototypes -Werror=pointer-arith -Wunreachable-code -Werror=format-security -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=return-type -D_FORTIFY_SOURCE=2 -D__LINUX__ -fvisibility=hidden
|
||||
#QMAKE_CXXFLAGS += -include cctype -include cstdlib
|
||||
#QMAKE_CXXFLAGS += -Wno-unused-parameter -Werror=shadow -Werror=write-strings -Werror=redundant-decls -Werror=format -Werror=format-nonliteral -Werror=date-time -Werror=missing-prototypes -Werror=pointer-arith -Wunreachable-code -Werror=format-security -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=return-type -D_FORTIFY_SOURCE=2 -D__LINUX__ -fvisibility=hidden
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
source/main.cpp \
|
||||
source/abstractdata.cpp \
|
||||
source/cntfilesystemmodel.cpp \
|
||||
source/datamodel.cpp \
|
||||
source/errorhandler.cpp \
|
||||
source/eventthread.cpp \
|
||||
source/eventtimer.cpp \
|
||||
source/getnumber.cpp \
|
||||
source/hp_infodialog.cpp \
|
||||
source/hp_mdilogwindow.cpp \
|
||||
source/hp_mditexteditor.cpp \
|
||||
source/hp_mdivariableedit.cpp \
|
||||
source/hp_mdiwindow.cpp \
|
||||
source/hp_settingsdlg.cpp \
|
||||
source/hpdata.cpp \
|
||||
# source/hptoolbox.cpp \
|
||||
source/hptreeitem.cpp \
|
||||
source/hpusb.cpp \
|
||||
source/mainwindow.cpp \
|
||||
source/matrixdata.cpp \
|
||||
source/options.cpp \
|
||||
source/texteditor.cpp \
|
||||
source/treemodel.cpp \
|
||||
source/variableview.cpp \
|
||||
source/vartablemodel.cpp \
|
||||
libhpcalcs/src/calc_none.c \
|
||||
libhpcalcs/src/calc_prime.c \
|
||||
libhpcalcs/src/error.c \
|
||||
libhpcalcs/src/filetypes.c \
|
||||
libhpcalcs/src/hpcables.c \
|
||||
libhpcalcs/src/hpcalcs.c \
|
||||
libhpcalcs/src/hpfiles.c \
|
||||
libhpcalcs/src/hpopers.c \
|
||||
libhpcalcs/src/link_nul.c \
|
||||
libhpcalcs/src/link_prime_hid.c \
|
||||
libhpcalcs/src/logging.c \
|
||||
libhpcalcs/src/prime_cmd.c \
|
||||
libhpcalcs/src/prime_rpkt.c \
|
||||
libhpcalcs/src/prime_vpkt.c \
|
||||
libhpcalcs/src/type2str.c \
|
||||
libhpcalcs/src/typesprime.c \
|
||||
libhpcalcs/src/utils.c
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
include/abstractdata.h \
|
||||
include/cntfilesystemmodel.h \
|
||||
include/datamodel.h \
|
||||
include/errorhandler.h \
|
||||
include/eventthread.h \
|
||||
include/eventtimer.h \
|
||||
include/getnumber.h \
|
||||
include/global.h \
|
||||
include/hp_infodialog.h \
|
||||
include/hp_mdilogwindow.h \
|
||||
include/hp_mditexteditor.h \
|
||||
include/hp_mdivariableedit.h \
|
||||
include/hp_mdiwindow.h \
|
||||
include/hp_settingsdlg.h \
|
||||
include/hp_typedef.h \
|
||||
include/hpdata.h \
|
||||
include/hpinterface.h \
|
||||
include/hptreeitem.h \
|
||||
include/hpusb.h \
|
||||
include/main.h \
|
||||
include/mainwindow.h \
|
||||
include/matrixdata.h \
|
||||
include/options.h \
|
||||
include/texteditor.h \
|
||||
include/treemodel.h \
|
||||
include/variableview.h \
|
||||
include/vartablemodel.h \
|
||||
include/version.h \
|
||||
libhpcalcs/include/error.h \
|
||||
libhpcalcs/include/export.h \
|
||||
libhpcalcs/include/filetypes.h \
|
||||
libhpcalcs/include/gettext.h \
|
||||
libhpcalcs/include/hpcables.h \
|
||||
libhpcalcs/include/hpcalcs.h \
|
||||
libhpcalcs/include/hpfiles.h \
|
||||
libhpcalcs/include/hplibs.h \
|
||||
libhpcalcs/include/hpopers.h \
|
||||
libhpcalcs/include/internal.h \
|
||||
libhpcalcs/include/logging.h \
|
||||
libhpcalcs/include/prime_cmd.h \
|
||||
libhpcalcs/include/typesprime.h \
|
||||
libhpcalcs/include/utils.h
|
||||
hidapi/hidapi.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
source/getnumber.ui \
|
||||
source/hp_infodialog.ui \
|
||||
source/hp_mdiwindow.ui \
|
||||
source/hp_settingsdlg.ui \
|
||||
source/mainwindow.ui \
|
||||
source/options.ui \
|
||||
source/variableview.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../usr/local/lib/release/ -lhpcalcs
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../usr/local/lib/debug/ -lhpcalcs
|
||||
else:unix: LIBS +=
|
||||
|
||||
#-L$$PWD/../../../../usr/local/lib/ -lhpcalcs
|
||||
|
||||
INCLUDEPATH += inc
|
||||
INCLUDEPATH += $$PWD/include
|
||||
INCLUDEPATH += $$PWD/libhpcalcs/include/
|
||||
INCLUDEPATH += $$PWD/hidapi/
|
||||
|
||||
INCLUDEPATH += /usr/include/libusb-1.0
|
||||
INCLUDEPATH += /usr/local/include
|
||||
#INCLUDEPATH += /usr/include/linux
|
||||
|
||||
DEPENDPATH += /usr/local/include
|
||||
|
||||
RESOURCES += \
|
||||
qthpconnect.qrc
|
||||
|
||||
DISTFILES += \
|
||||
icons/about_16x16.png \
|
||||
icons/about_32x32.png \
|
||||
icons/add_background_16x16.png \
|
||||
icons/add_background_22x22.png \
|
||||
icons/add_background_32x32.png \
|
||||
icons/add_icon_16x16.png \
|
||||
icons/add_icon_22x22.png \
|
||||
icons/add_icon_32x32.png \
|
||||
icons/add_new_16x16.png \
|
||||
icons/add_new_22x22.png \
|
||||
icons/add_new_32x32.png \
|
||||
icons/apps_16x16.png \
|
||||
icons/apps_32x32.png \
|
||||
icons/backup_16x16.png \
|
||||
icons/backup_32x32.png \
|
||||
icons/calc_tree_16x16.png \
|
||||
icons/calc_tree_22x22.png \
|
||||
icons/calc_tree_32x32.png \
|
||||
icons/casFolder_16x16.png \
|
||||
icons/casFolder_32x32.png \
|
||||
icons/casVars_16x16.png \
|
||||
icons/casVars_32x32.png \
|
||||
icons/chars_16x16.png \
|
||||
icons/chars_32x32.png \
|
||||
icons/chat_16x16.png \
|
||||
icons/chat_22x22.png \
|
||||
icons/chat_32x32.png \
|
||||
icons/check_update_16x16.png \
|
||||
icons/check_update_32x32.png \
|
||||
icons/clear_16x16.png \
|
||||
icons/clear_32x32.png \
|
||||
icons/clone_from_16x16.png \
|
||||
icons/clone_from_32x32.png \
|
||||
icons/clone_to_16x16.png \
|
||||
icons/clone_to_32x32.png \
|
||||
icons/complex_16x16.png \
|
||||
icons/complex_32x32.png \
|
||||
icons/content_16x16.png \
|
||||
icons/content_22x22.png \
|
||||
icons/content_32x32.png \
|
||||
icons/copy_16x16.png \
|
||||
icons/copy_32x32.png \
|
||||
icons/cut_16x16.png \
|
||||
icons/cut_32x32.png \
|
||||
icons/delete_16x16.png \
|
||||
icons/delete_32x32.png \
|
||||
icons/delete_col_16x16.png \
|
||||
icons/delete_col_32x32.png \
|
||||
icons/delete_row_16x16.png \
|
||||
icons/delete_row_32x32.png \
|
||||
icons/exam_mode_16x16.png \
|
||||
icons/exam_mode_32x32.png \
|
||||
icons/fileFolder_16x16.png \
|
||||
icons/fileFolder_32x32.png \
|
||||
icons/file_16x16.png \
|
||||
icons/file_32x32.png \
|
||||
icons/firmware_16x16.png \
|
||||
icons/firmware_32x32.png \
|
||||
icons/help_16x16.png \
|
||||
icons/help_32x32.png \
|
||||
icons/insert_col_16x16.png \
|
||||
icons/insert_col_32x32.png \
|
||||
icons/insert_row_16x16.png \
|
||||
icons/insert_row_32x32.png \
|
||||
icons/internet_16x16.png \
|
||||
icons/internet_32x32.png \
|
||||
icons/language_16x16.png \
|
||||
icons/language_32x32.png \
|
||||
icons/list_16x16.png \
|
||||
icons/list_32x32.png \
|
||||
icons/monitor_16x16.png \
|
||||
icons/monitor_22x22.png \
|
||||
icons/monitor_32x32.png \
|
||||
icons/new_folder_16x16.png \
|
||||
icons/new_folder_22x22.png \
|
||||
icons/new_folder_32x32.png \
|
||||
icons/note_16x16.png \
|
||||
icons/note_32x32.png \
|
||||
icons/open_16x16.png \
|
||||
icons/open_32x32.png \
|
||||
icons/paste_16x16.png \
|
||||
icons/paste_32x32.png \
|
||||
icons/poll_16x16.png \
|
||||
icons/poll_32x32.png \
|
||||
icons/preferences_16x16.png \
|
||||
icons/preferences_32x32.png \
|
||||
icons/proctor_16x16.png \
|
||||
icons/proctor_22x22.png \
|
||||
icons/proctor_32x32.png \
|
||||
icons/program_16x16.png \
|
||||
icons/program_32x32.png \
|
||||
icons/project_16x16.png \
|
||||
icons/project_32x32.png \
|
||||
icons/properties_16x16.png \
|
||||
icons/properties_32x32.png \
|
||||
icons/real_16x16.png \
|
||||
icons/real_32x32.png \
|
||||
icons/refresh_16x16.png \
|
||||
icons/refresh_32x32.png \
|
||||
icons/rename_16x16.png \
|
||||
icons/rename_32x32.png \
|
||||
icons/reset_16x16.png \
|
||||
icons/reset_32x32.png \
|
||||
icons/restore_16x16.png \
|
||||
icons/restore_32x32.png \
|
||||
icons/results_16x16.png \
|
||||
icons/results_32x32.png \
|
||||
icons/save_16x16.png \
|
||||
icons/save_22x22.png \
|
||||
icons/save_32x32.png \
|
||||
icons/save_all_16x16.png \
|
||||
icons/save_all_22x22.png \
|
||||
icons/save_all_32x32.png \
|
||||
icons/save_as_16x16.png \
|
||||
icons/save_as_32x32.png \
|
||||
icons/screenshot_16x16.png \
|
||||
icons/screenshot_32x32.png \
|
||||
icons/send_16x16.png \
|
||||
icons/send_32x32.png \
|
||||
icons/start_16x16.png \
|
||||
icons/start_32x32.png \
|
||||
icons/stop_16x16.png \
|
||||
icons/stop_32x32.png \
|
||||
icons/table_16x16.png \
|
||||
icons/table_32x32.png \
|
||||
icons/varFolder_16x16.png \
|
||||
icons/varFolder_32x32.png \
|
||||
icons/vars_16x16.png \
|
||||
icons/vars_32x32.png \
|
||||
model.qmodel \
|
||||
README.md \
|
||||
LICENSE \
|
||||
CHANGELOG.md \
|
||||
NEWS \
|
||||
AUTHORS \
|
||||
Notes \
|
||||
TODO.md
|
||||
../hplp-master/libhpcalcs/tests/test_hpcalcs.c
|
||||
|
||||
unix|win32: LIBS += -lhidapi-libusb
|
||||
|
||||
unix|win32: LIBS += -lusb-1.0
|
||||
|
|
15
TODO.md
15
TODO.md
|
@ -1,14 +1,11 @@
|
|||
|
||||
1 GUI
|
||||
About
|
||||
Content - fix icons
|
||||
Content - fix columns
|
||||
Content - fix resizing
|
||||
Create storage path if it does not exist
|
||||
Load and read program files
|
||||
Add options - set default paths
|
||||
|
||||
Drag and drop from content window to calc
|
||||
matrix data output to correct format
|
||||
list data output
|
||||
|
||||
|
||||
confirm output formats are correct
|
||||
|
||||
2 Comms
|
||||
|
||||
|
@ -23,4 +20,6 @@
|
|||
|
||||
Extract vars file
|
||||
|
||||
write to calculator
|
||||
|
||||
3 Backup to disk
|
||||
|
|
1106
abstractdata.cpp
1106
abstractdata.cpp
File diff suppressed because it is too large
Load diff
|
@ -1,577 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <global.h>
|
||||
#include <cntfilesystemmodel.h>
|
||||
#include <QMimeData>
|
||||
#include <QList>
|
||||
#include <QStringListModel>
|
||||
|
||||
#include <hp_mditexteditor.h>
|
||||
#include <hp_infodialog.h>
|
||||
#include <hp_mdivariableedit.h>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include <utility>
|
||||
#define FILE_NUM 9
|
||||
|
||||
|
||||
//list of file types and associated icons
|
||||
//Todo fix for all file types
|
||||
const QString contentFileSystemModel::filetype_list[FILE_NUM][2]={{"hpprgm",":/icons/apps_16x16.png"},
|
||||
{"CAS Vars",":/icons/casFolder_16x16.png"},
|
||||
{"Complex",":/icons/complex_16x16.png"},
|
||||
{"hplist",":/icons/list_16x16.png"},
|
||||
{"Matrices",":/icons/table_16x16.png"},
|
||||
{"Notes",":/icons/note_16x16.png"},
|
||||
{"hpprgm",":/icons/program_16x16.png"},
|
||||
{"Real",":/icons/real_16x16.png"},
|
||||
{"Variables",":/icons/varFolder_16x16.png"}
|
||||
};
|
||||
|
||||
|
||||
//list of data object types used by contentFileSystemModel
|
||||
const hp_DataType contentFileSystemModel::func_type[FILE_TYPE]={
|
||||
HP_PROG,
|
||||
HP_LIST,
|
||||
HP_MATRIX,
|
||||
HP_NOTE,
|
||||
HP_MAIN};
|
||||
|
||||
/*
|
||||
const std::array<std::pair<hp_DataType,QString>,FILE_TYPE> contentFileSystemModel::file_type{ {0,"hpprgm"},
|
||||
{1,"hplist"},
|
||||
{2,"hpmat"},
|
||||
{3,"hpnote"},
|
||||
{4,""}};
|
||||
*/
|
||||
|
||||
//list of file type suffixes
|
||||
const QString contentFileSystemModel::file_type[FILE_TYPE]{ "hpprgm",
|
||||
"hplist",
|
||||
"hpmat",
|
||||
"hpnote",
|
||||
""};
|
||||
|
||||
|
||||
//condstrutor
|
||||
contentFileSystemModel::contentFileSystemModel(QObject * parent)
|
||||
:QFileSystemModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Get and pass on the data to be dragged
|
||||
QMimeData* contentFileSystemModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
|
||||
QMimeData *mimeDataPtr = new QMimeData();
|
||||
QByteArray mydata;
|
||||
QModelIndex index;
|
||||
hp_DataStruct filedata;
|
||||
|
||||
qDebug()<<"contentFileSystemModel::mimeData";
|
||||
|
||||
foreach(index,indexes) {
|
||||
|
||||
index=indexes.first();
|
||||
// qDebug()<<index.data(Qt::DisplayRole);
|
||||
// QString data;
|
||||
|
||||
QFileInfo info = contentFileSystemModel::fileInfo(index);
|
||||
QFile file(info.absoluteFilePath());
|
||||
|
||||
qDebug()<<info.absoluteFilePath();
|
||||
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QDataStream in(&file);
|
||||
|
||||
filedata=getFileType(info);
|
||||
|
||||
in.setByteOrder(QDataStream::LittleEndian);
|
||||
qint8 c;
|
||||
|
||||
//read in file
|
||||
in.startTransaction();
|
||||
while(!in.atEnd()) {
|
||||
in>>c;
|
||||
mydata.append(c);
|
||||
}
|
||||
mimeDataPtr->setText(info.baseName());
|
||||
|
||||
|
||||
switch (filedata.type) {
|
||||
|
||||
case HP_PROG:
|
||||
case HP_APP:
|
||||
case HP_MATRIX:
|
||||
case HP_NOTE:
|
||||
case HP_LIST:
|
||||
case HP_VAR: {
|
||||
mimeDataPtr->setData(mimetypes[filedata.type][1],mydata);
|
||||
break;
|
||||
}
|
||||
case HP_CAS:
|
||||
case HP_MAIN:
|
||||
case HP_COMPLEX:
|
||||
case HP_SCREEN:
|
||||
case HP_REAL: {
|
||||
// no action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
//Allow copy to external file managers
|
||||
QList<QUrl> urls;
|
||||
QFileInfo info;
|
||||
QUrl url;
|
||||
foreach(index,indexes) {
|
||||
info = contentFileSystemModel::fileInfo(index);
|
||||
|
||||
url = QUrl::fromLocalFile(info.absoluteFilePath());
|
||||
|
||||
urls.append(url);
|
||||
}
|
||||
mimeDataPtr->setUrls(urls);
|
||||
|
||||
return mimeDataPtr;
|
||||
}
|
||||
|
||||
//Set drop actions supported
|
||||
Qt::DropActions contentFileSystemModel::supportedDropActions() const
|
||||
{
|
||||
return Qt::CopyAction | Qt::MoveAction| Qt::TargetMoveAction;
|
||||
}
|
||||
|
||||
//Not sure that this is neccesary. Item should control this
|
||||
Qt::ItemFlags contentFileSystemModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QFileSystemModel::flags(index);
|
||||
|
||||
if (index.isValid())
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
|
||||
else
|
||||
return Qt::ItemIsDropEnabled | defaultFlags;
|
||||
}
|
||||
|
||||
//Allow drop in location
|
||||
bool contentFileSystemModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
qDebug()<<data->formats();
|
||||
|
||||
if (data->hasUrls()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (data->hasText()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Process the drop action
|
||||
bool contentFileSystemModel::dropMimeData(const QMimeData* md_data, Qt::DropAction action, int row,
|
||||
int column, const QModelIndex &parent)
|
||||
{
|
||||
|
||||
qDebug()<<"contentFileSystemModel::DropMineData";
|
||||
|
||||
QSettings appSettings("IRGP","QtHPconnect");
|
||||
QString path=appSettings.value("contentPath").toString();
|
||||
|
||||
QDir dir;
|
||||
dir= rootDirectory();
|
||||
|
||||
if (!dir.exists()) {
|
||||
qWarning()<<tr("Content Path Does not exist: ")<<path;
|
||||
if(!dir.mkpath("."))
|
||||
{
|
||||
qWarning()<<tr("Path could not be created: ")<<path;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == Qt::IgnoreAction) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check for external file drop
|
||||
if (md_data->hasUrls()) {
|
||||
|
||||
QString name = md_data->text();
|
||||
QList<QUrl> urls = md_data->urls();
|
||||
QUrl url;
|
||||
QString filefrom;
|
||||
QString fileto;
|
||||
|
||||
foreach(url,urls) {
|
||||
filefrom=url.toLocalFile();
|
||||
QFileInfo fileinfo(filefrom);
|
||||
fileto=path+"/"+url.fileName();
|
||||
if(isFileType(fileinfo)) {
|
||||
//consider check to limit unusual file types
|
||||
QFile::copy(filefrom,fileto);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//rework
|
||||
QByteArray data_in;
|
||||
QByteArray typeary;
|
||||
QString name = md_data->text();
|
||||
typeary=md_data->data("application/x-type");
|
||||
int type_i=typeary[0];
|
||||
hp_DataType type=static_cast<hp_DataType>(type_i);
|
||||
QString type_str=getFileType(type);
|
||||
name=name+"_2"+"."+type_str;
|
||||
data_in=md_data->data("application/x-qabstractmodeldatalist");
|
||||
QFileInfo fileinfo(path,name);
|
||||
|
||||
qDebug()<<data_in;
|
||||
qDebug()<<fileinfo;
|
||||
|
||||
// QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
if (writeFile(fileinfo,data_in)>-1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
//override to return a file object
|
||||
QVariant contentFileSystemModel::data( const QModelIndex &index, int role ) const {
|
||||
|
||||
if( role == Qt::DecorationRole )
|
||||
{
|
||||
QString name = index.data().toString();
|
||||
QFileInfo info = contentFileSystemModel::fileInfo(index);
|
||||
//QFileInfo info(name);
|
||||
|
||||
if((info.isFile()&&(name==info.fileName())))
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<FILE_NUM;i++) {
|
||||
if(info.suffix() == filetype_list[i][0])
|
||||
return QPixmap(filetype_list[i][1]);//I pick the icon depending on the extension
|
||||
}
|
||||
return QPixmap(":/icons/file_16x16.png");
|
||||
}
|
||||
}
|
||||
return QFileSystemModel::data(index, role);
|
||||
}
|
||||
|
||||
//action if file is left clicked
|
||||
void contentFileSystemModel::clickAction(QMdiArea * mdiwin, QModelIndex &index) {
|
||||
openFile(mdiwin,index);
|
||||
return;
|
||||
}
|
||||
|
||||
//open a file in the mdi window
|
||||
bool contentFileSystemModel::openFile(QMdiArea * mdiwin, QModelIndex &index) {
|
||||
|
||||
QFileInfo info = contentFileSystemModel::fileInfo(index);
|
||||
return openFile(mdiwin,info);
|
||||
}
|
||||
|
||||
//open a file in the mdi window
|
||||
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) {
|
||||
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";
|
||||
}
|
||||
return false;
|
||||
qDebug()<<"ClickAction "<<info.absoluteFilePath();
|
||||
|
||||
}
|
||||
|
||||
//delete a file
|
||||
void contentFileSystemModel::deleteFile(QModelIndex &index) {
|
||||
QFileInfo fileinfo = contentFileSystemModel::fileInfo(index);
|
||||
qDebug()<<"deleteFile "<<fileinfo.absoluteFilePath();
|
||||
QFile file(fileinfo.absoluteFilePath());
|
||||
file.remove();
|
||||
}
|
||||
|
||||
//rename a file
|
||||
void contentFileSystemModel::renameFile(QModelIndex &index, QString newName) {
|
||||
QFileInfo fileinfo = contentFileSystemModel::fileInfo(index);
|
||||
|
||||
QFile file(fileinfo.absoluteFilePath());
|
||||
QDir dir=fileinfo.absoluteDir();
|
||||
QString newPath;
|
||||
|
||||
newPath=dir.absolutePath()+"/"+newName;
|
||||
|
||||
if (file.rename(newPath)) {
|
||||
qDebug()<<"File rename succesfull";
|
||||
}
|
||||
else {
|
||||
qDebug()<<"File rename failed";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//read a file and return the resulting data object
|
||||
AbstractData * contentFileSystemModel::readFile(QFileInfo fileinfo) const {
|
||||
|
||||
AbstractData * data=nullptr;
|
||||
hp_DataStruct filedata;
|
||||
QFile file(fileinfo.absoluteFilePath());
|
||||
|
||||
if (file.open(QIODevice::ReadOnly),QFileDevice::AutoCloseHandle) {
|
||||
QDataStream in(&file);
|
||||
// QTextCodec *codec = QTextCodec::codecForName("UTF-16");
|
||||
// in.setCodec(codec);
|
||||
in.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
filedata=getFileType(fileinfo);
|
||||
|
||||
switch (filedata.type) {
|
||||
|
||||
case HP_PROG: {
|
||||
qDebug()<<"HP_PROG";
|
||||
data = new Program(filedata.filename, HP_PROG, QStringLiteral(""));
|
||||
data->parseData(in);
|
||||
}
|
||||
break;
|
||||
case HP_NOTE: {
|
||||
qDebug()<<"HP_NOTE";
|
||||
data = new Notes(filedata.filename, HP_NOTE, QStringLiteral(""));
|
||||
data->parseData(in);
|
||||
}
|
||||
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: ;
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
//write a file to the directory store
|
||||
int contentFileSystemModel::writeFile(QFileInfo fileinfo, QByteArray data_in) const {
|
||||
|
||||
QFile file(fileinfo.absoluteFilePath());
|
||||
|
||||
if (file.open(QIODevice::ReadWrite)) {
|
||||
QDataStream out(&file);
|
||||
// QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
// out.setCodec(codec);
|
||||
out.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// quint8 c;
|
||||
// for (int i =0 ;i< data_in.length();i++)
|
||||
// {
|
||||
// c= data_in[i];
|
||||
// out<<(quint8)c;
|
||||
// }
|
||||
// out.writeRawData(data_in,data_in.length());
|
||||
qDebug()<<"Wriiting";
|
||||
qDebug()<<data_in;
|
||||
|
||||
out<<data_in;
|
||||
|
||||
file.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//create a new folder in the contents location
|
||||
bool contentFileSystemModel::createNewFolder(QString foldername) {
|
||||
|
||||
QSettings appSettings("IRGP","QtHPconnect");
|
||||
QString path=appSettings.value("contentPath").toString();
|
||||
|
||||
path=path+foldername;
|
||||
|
||||
QDir dir(path);
|
||||
|
||||
if (!dir.exists()) {
|
||||
if(!dir.mkpath("."))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
qDebug()<<"Create new folder pressed"<<path;
|
||||
return true;
|
||||
}
|
||||
|
||||
//create a new program file
|
||||
bool contentFileSystemModel::createNewProgram(QMdiArea * mdiwin, QString filename) {
|
||||
|
||||
QSettings appSettings("IRGP","QtHPconnect");
|
||||
QString path=appSettings.value("contentPath").toString();
|
||||
QDir dir(path);
|
||||
QFileInfo fileinfo(dir,filename+"."+getFileType(HP_PROG));
|
||||
|
||||
qDebug()<<"Create new program pressed";
|
||||
return openFile(mdiwin,fileinfo);
|
||||
}
|
||||
|
||||
//create a new note file
|
||||
bool contentFileSystemModel::createNewNote(QMdiArea * mdiwin,QString filename) {
|
||||
|
||||
QSettings appSettings("IRGP","QtHPconnect");
|
||||
QString path=appSettings.value("contentPath").toString();
|
||||
QDir dir(path);
|
||||
QFileInfo fileinfo(dir,filename+"."+getFileType(HP_NOTE));
|
||||
|
||||
qDebug()<<"Create new program pressed";
|
||||
return openFile(mdiwin,fileinfo);
|
||||
}
|
||||
|
||||
//return the file type
|
||||
hp_DataStruct contentFileSystemModel::getFileType(QFileInfo info) const {
|
||||
hp_DataStruct filedata;
|
||||
|
||||
int i;
|
||||
QString suffix;
|
||||
hp_DataType type=HP_MAIN;
|
||||
suffix=info.completeSuffix();
|
||||
for (i=0;i<FILE_TYPE;i++) {
|
||||
if (suffix==file_type[i])
|
||||
break;
|
||||
}
|
||||
type=func_type[i];
|
||||
if (type!=HP_MAIN) {
|
||||
filedata.filename=info.completeBaseName();
|
||||
filedata.type=type;
|
||||
}
|
||||
|
||||
return filedata;
|
||||
}
|
||||
|
||||
//return the file type
|
||||
bool contentFileSystemModel::isFileType(QFileInfo info) const {
|
||||
hp_DataStruct filedata;
|
||||
|
||||
int i;
|
||||
QString suffix;
|
||||
suffix=info.completeSuffix();
|
||||
for (i=0;i<FILE_TYPE;i++) {
|
||||
if (suffix==file_type[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//return the file type suffix
|
||||
QString contentFileSystemModel::getFileType(hp_DataType type) const {
|
||||
int i;
|
||||
QString suffix=QStringLiteral("");
|
||||
|
||||
switch (type) {
|
||||
case HP_PROG: {
|
||||
i=0;
|
||||
break;
|
||||
}
|
||||
case HP_LIST: {
|
||||
i=1;
|
||||
break;
|
||||
}
|
||||
case HP_MATRIX: {
|
||||
i=2;
|
||||
break;
|
||||
}
|
||||
case HP_NOTE: {
|
||||
i=3;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
i=-1;
|
||||
}
|
||||
}
|
||||
if (i>-1) {
|
||||
suffix=file_type[i];
|
||||
}
|
||||
|
||||
return suffix;
|
||||
}
|
||||
|
||||
//destructor
|
||||
contentFileSystemModel::~contentFileSystemModel() {
|
||||
qDebug()<<"contentFileSystemModel::delete";
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "datamodel.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
|
||||
dataModel::dataModel(QObject *parent)
|
||||
:QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int dataModel::rowCount(const QModelIndex & /*parent*/) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int dataModel::columnCount(const QModelIndex & /*parent*/) const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
QVariant dataModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
int row = index.row();
|
||||
int col = index.column();
|
||||
// // generate a log message when this method gets called
|
||||
// qDebug() << QString("row %1, col%2, role %3")
|
||||
// .arg(row).arg(col).arg(role);
|
||||
|
||||
switch(role){
|
||||
case Qt::DisplayRole:
|
||||
if (row == 0 && col == 1) return QString("<--left");
|
||||
if (row == 1 && col == 1) return QString("right-->");
|
||||
|
||||
return QString("Row%1, Column%2")
|
||||
.arg(row + 1)
|
||||
.arg(col +1);
|
||||
break;
|
||||
case Qt::FontRole:
|
||||
if (row == 0 && col == 0) //change font only for cell(0,0)
|
||||
{
|
||||
QFont boldFont;
|
||||
boldFont.setBold(true);
|
||||
return boldFont;
|
||||
}
|
||||
break;
|
||||
case Qt::BackgroundRole:
|
||||
|
||||
if (row == 1 && col == 2) //change background only for cell(1,2)
|
||||
{
|
||||
QBrush redBackground(Qt::red);
|
||||
return redBackground;
|
||||
}
|
||||
break;
|
||||
case Qt::TextAlignmentRole:
|
||||
|
||||
if (row == 1 && col == 1) //change text alignment only for cell(1,1)
|
||||
{
|
||||
return Qt::AlignRight + Qt::AlignVCenter;
|
||||
}
|
||||
break;
|
||||
case Qt::CheckStateRole:
|
||||
|
||||
if (row == 1 && col == 0) //add a checkbox to cell(1,0)
|
||||
{
|
||||
return Qt::Checked;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
dataModel::~dataModel() {
|
||||
|
||||
qDebug()<<"dataModel::close";
|
||||
}
|
139
errorhandler.cpp
139
errorhandler.cpp
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "errorhandler.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
errorHandler::errorHandler()
|
||||
{
|
||||
}
|
||||
|
||||
errorHandler::errorHandler(QObject * parent)
|
||||
{
|
||||
pParent = parent;
|
||||
}
|
||||
|
||||
QString errorHandler::getLogFileName()
|
||||
{
|
||||
return QString("hpinterface.log");
|
||||
}
|
||||
|
||||
int errorHandler::writeLog(QString lineToBeLogged)
|
||||
{
|
||||
|
||||
QMutexLocker locker(&m_lineLoggerMutex);
|
||||
QFile fileLog(getLogFileName());
|
||||
|
||||
//doRollLogsIfNeeded(static_cast<qint64>(fileLog.size() + lineToBeLogged.length()));
|
||||
|
||||
// Do not open in append mode but seek() to avoid warning for unseekable
|
||||
// devices, note that if open is made with WriteOnly without Append, the
|
||||
// file gets truncated
|
||||
if (!fileLog.open(QIODevice::ReadWrite | QIODevice::Text))
|
||||
{
|
||||
QTextStream out(stdout);
|
||||
out << "CANNOT OPEN LOG FILE: " << getLogFileName();
|
||||
return -1;
|
||||
}
|
||||
// seek() does nothing on sequential devices, this is in essence what QFile
|
||||
// does when Append flag is set in open()
|
||||
if (!fileLog.isSequential())
|
||||
{
|
||||
fileLog.seek(fileLog.size());
|
||||
}
|
||||
QDateTime time(QDateTime::currentDateTime());
|
||||
|
||||
QTextStream out(&fileLog);
|
||||
out << time.toString("yyyy/MM/dd hh:mm:ss") << " "<< lineToBeLogged << endl;
|
||||
|
||||
fileLog.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int errorHandler::writeStatus(QString msg)
|
||||
{
|
||||
if (MainWindow *pb = qobject_cast<MainWindow*> (pParent))
|
||||
{
|
||||
pb->writeStatus( msg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int errorHandler::writeChatter(QString msg)
|
||||
{
|
||||
if (MainWindow *pb = qobject_cast<MainWindow*> (pParent))
|
||||
{
|
||||
pb->writeChatter( msg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int errorHandler::error(ErrLevel el, int num, QString msg, QString Data=QString())
|
||||
{
|
||||
switch (el) {
|
||||
case L0:
|
||||
writeLog("Abort: "+msg);
|
||||
writeStatus("Abort: "+msg);
|
||||
exit(num);
|
||||
break;
|
||||
default:
|
||||
writeLog(" "+msg+Data);
|
||||
writeStatus(" "+msg);
|
||||
if (Data=="")
|
||||
writeChatter(" "+msg);
|
||||
else
|
||||
writeChatter(" "+msg+Data);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int errorHandler::dump(uint8_t * data, int size)
|
||||
{
|
||||
int i,j;
|
||||
QString text = QString("Dump:\n");
|
||||
QString texta = QString("ASCII:\n");
|
||||
j=0;
|
||||
text = text + QString().sprintf("%04d | ",0);
|
||||
for (i=0; i< size; i++)
|
||||
{
|
||||
text = text + QString(" %1 ").arg(QChar(data[i]).unicode(),2,16,QChar('0'));
|
||||
j++;
|
||||
if (j>15) {
|
||||
j=0;
|
||||
text=text+"\n";
|
||||
text = text + QString().sprintf("%04d | ",i+1);
|
||||
}
|
||||
texta = texta +" "+QChar(data[i]).unicode();
|
||||
|
||||
}
|
||||
text = text + "\n";
|
||||
texta = texta + "\n";
|
||||
|
||||
writeLog(text);
|
||||
writeChatter(text);
|
||||
writeLog(texta);
|
||||
writeChatter(texta);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
errorHandler::~errorHandler() {
|
||||
qDebug()<<"errorHandler:: close";
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "eventthread.h"
|
||||
#include <mainwindow.h>
|
||||
#include <QDebug>
|
||||
|
||||
EventThread::EventThread(MainWindow * parent):QThread (parent)
|
||||
{
|
||||
|
||||
main=parent;
|
||||
if (main)
|
||||
hpapi=main->getAPI();
|
||||
|
||||
if (hpapi==nullptr)
|
||||
qDebug()<<"hpusb not started";
|
||||
}
|
||||
|
||||
void EventThread::run() {
|
||||
|
||||
qDebug()<<"Event run";
|
||||
// emit startTimer();
|
||||
hpapi->eventHandler();
|
||||
qDebug()<<"Event end";
|
||||
//exec();
|
||||
}
|
||||
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "eventtimer.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
EventTimer::EventTimer(MainWindow * main):QObject()
|
||||
{
|
||||
|
||||
if (main)
|
||||
hpapi=main->getAPI();
|
||||
|
||||
if (hpapi==nullptr)
|
||||
qDebug()<<"hpusb not started";
|
||||
|
||||
}
|
||||
|
||||
void EventTimer::timerAction()
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
// qDebug()<<"In Eventhandler";
|
||||
// QThread::msleep(1);
|
||||
|
||||
if(hpapi!=nullptr) {
|
||||
hpapi->eventHandler();
|
||||
}
|
||||
emit tick();
|
||||
}
|
||||
|
||||
void EventTimer::start() {
|
||||
timer = new QTimer(this);
|
||||
timer->setInterval(100);
|
||||
// timer->callOnTimeout(SLOT(timerEvent()),Qt::AutoConnection);
|
||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(timerAction()));
|
||||
// timer->connect(timer, SIGNAL(timeout()), hpapi, SLOT(eventHandler()),Qt::DirectConnection);
|
||||
|
||||
// timer->connect(this, SIGNAL(tick()), this, SLOT(tickEvent()),Qt::AutoConnection);
|
||||
|
||||
timer->connect(this, SIGNAL(stop()), this, SLOT(stopTimer()));
|
||||
timer->start();
|
||||
qDebug()<<"EventTimer::started Timer";
|
||||
}
|
||||
|
||||
void EventTimer::exit() {
|
||||
emit stop();
|
||||
stop();
|
||||
}
|
||||
|
||||
void EventTimer::stopTimer() {
|
||||
qDebug()<<"EventTimer::stop Timer";
|
||||
timer->stop();
|
||||
emit stopped();
|
||||
}
|
||||
|
||||
void EventTimer::tickEvent() {
|
||||
qDebug()<<"EventTimer::tickEvent";
|
||||
}
|
||||
|
||||
EventTimer::~EventTimer()
|
||||
{
|
||||
stopTimer();
|
||||
if (timer!=nullptr) {
|
||||
delete timer;
|
||||
timer=nullptr;
|
||||
}
|
||||
qDebug()<<"delete EventTimer";
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "getnumber.h"
|
||||
#include "ui_getnumber.h"
|
||||
#include <QDebug>
|
||||
|
||||
getNumber::getNumber(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::getNumber)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
getNumber::~getNumber()
|
||||
{
|
||||
// qDebug()<<"Entering ~getNumber()";
|
||||
delete ui;
|
||||
}
|
91
getnumber.ui
91
getnumber.ui
|
@ -1,91 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>getNumber</class>
|
||||
<widget class="QDialog" name="getNumber">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>427</width>
|
||||
<height>118</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>70</y>
|
||||
<width>411</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>381</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>88</width>
|
||||
<height>34</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>getNumber</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>getNumber</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hp_infodialog.h"
|
||||
#include "ui_hp_infodialog.h"
|
||||
#include <QDebug>
|
||||
|
||||
hp_infoDialog::hp_infoDialog(QWidget *parent, hp_Information info) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::hp_infoDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->serialnum->setText(info.serialnum);
|
||||
ui->appver->setText(info.appver);
|
||||
ui->oppver->setText(info.osver);
|
||||
}
|
||||
|
||||
hp_infoDialog::~hp_infoDialog()
|
||||
{
|
||||
// qDebug()<<"Entering ~hp_infoDialog()";
|
||||
delete ui;
|
||||
}
|
125
hp_infodialog.ui
125
hp_infodialog.ui
|
@ -1,125 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>hp_infoDialog</class>
|
||||
<widget class="QDialog" name="hp_infoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>143</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>HP Information</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="formAlignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelapp">
|
||||
<property name="text">
|
||||
<string>Application version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="appver">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelopp">
|
||||
<property name="text">
|
||||
<string>Operational system version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="oppver">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelser">
|
||||
<property name="text">
|
||||
<string>Serial number:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="serialnum">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>hp_infoDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>hp_infoDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hp_mdilogwindow.h"
|
||||
#include <QDebug>
|
||||
|
||||
hp_MdiLogWindow::hp_MdiLogWindow(QWidget * parent)
|
||||
:hp_MdiWindow(parent)
|
||||
{
|
||||
setMinimumSize(200,200);
|
||||
setMaximumSize(1000,1000);
|
||||
setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
|
||||
setup();
|
||||
resize(500,400);
|
||||
}
|
||||
|
||||
void hp_MdiLogWindow::setup() {
|
||||
|
||||
textEdit = new QTextEdit(this);
|
||||
setWidget(textEdit);
|
||||
}
|
||||
|
||||
QTextEdit * hp_MdiLogWindow::getEditor() {
|
||||
return textEdit;
|
||||
}
|
||||
|
||||
void hp_MdiLogWindow::show() {
|
||||
textEdit->show();
|
||||
hp_MdiWindow::show();
|
||||
}
|
||||
|
||||
hp_MdiLogWindow::~hp_MdiLogWindow() {
|
||||
|
||||
qDebug()<<"Entering ~hpmdiLogWindow()";
|
||||
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <hp_mditexteditor.h>
|
||||
#include <hp_mdiwindow.h>
|
||||
#include <hptreeitem.h>
|
||||
#include <hpdata.h>
|
||||
#include <abstractdata.h>
|
||||
#include <QBoxLayout>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
|
||||
//Called by the calculator Window
|
||||
hp_mdiTextEdit::hp_mdiTextEdit(QWidget * parent,hpTreeItem * treeItem, AbstractData * calcData)
|
||||
:hp_MdiWindow(parent)
|
||||
{
|
||||
setMinimumSize(200,200);
|
||||
setMaximumSize(1000,1000);
|
||||
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
||||
|
||||
qDebug()<<"hp_mdiTextEdit::hp_mdiTextEdit 1";
|
||||
hptreeitem=treeItem;
|
||||
content=false;
|
||||
data = calcData;
|
||||
|
||||
filename=treeItem->getFileName();
|
||||
calculator=treeItem->getCalculatorName();
|
||||
type=treeItem->getType();
|
||||
|
||||
setup();
|
||||
setWindowTitle(calculator+": "+filename);
|
||||
}
|
||||
|
||||
//Called by the content window
|
||||
hp_mdiTextEdit::hp_mdiTextEdit(QWidget * parent, QFileInfo filedata, AbstractData * calcData)
|
||||
:hp_MdiWindow (parent)
|
||||
{
|
||||
|
||||
qDebug()<<"hp_mdiTextEdit::hp_mdiTextEdit 2";
|
||||
setMinimumSize(200,200);
|
||||
setMaximumSize(1000,1000);
|
||||
// setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
||||
calculator=QStringLiteral("Content: ");
|
||||
content=true;
|
||||
hptreeitem=nullptr;
|
||||
data = calcData;
|
||||
filename=filedata.fileName();
|
||||
file=filedata;
|
||||
type=calcData->getType();
|
||||
setup();
|
||||
setWindowTitle(calculator+filename);
|
||||
resize(450,350);
|
||||
}
|
||||
|
||||
void hp_mdiTextEdit::setup() {
|
||||
|
||||
QString text;
|
||||
textEdit = new textEditor(this);
|
||||
|
||||
if (data) {
|
||||
|
||||
qDebug()<<data->getName();
|
||||
qDebug()<<data->getType();
|
||||
|
||||
if (data->getType()==HP_NOTE) {
|
||||
Notes *note;
|
||||
note=static_cast<Notes *>(data);
|
||||
text=note->getNote();
|
||||
}
|
||||
|
||||
if (data->getType()==HP_PROG) {
|
||||
Program *prog;
|
||||
prog=static_cast<Program *>(data);
|
||||
text=prog->getProg();
|
||||
textEdit->setDocumentTitle(prog->getName());
|
||||
}
|
||||
qDebug()<<text;
|
||||
textEdit->setPlainText(text);
|
||||
|
||||
}
|
||||
else {
|
||||
qDebug()<<"hp_mdiTextEdit::setup - Data Null";
|
||||
}
|
||||
|
||||
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(toolbar);
|
||||
// QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// sizePolicy1.setHorizontalStretch(0);
|
||||
// sizePolicy1.setVerticalStretch(0);
|
||||
// sizePolicy1.setHeightForWidth(textEdit->sizePolicy().hasHeightForWidth());
|
||||
// textEdit->setSizePolicy(sizePolicy1);
|
||||
// layout->setSizeConstraint(QLayout::SetNoConstraint);
|
||||
|
||||
layout->addWidget(textEdit);
|
||||
setWidget(top);
|
||||
|
||||
connect(actionSave,SIGNAL(triggered()),this,SLOT(eventSave()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void hp_mdiTextEdit::eventSave(){
|
||||
save();
|
||||
}
|
||||
|
||||
bool hp_mdiTextEdit::save(){
|
||||
|
||||
if(content)
|
||||
return textEdit->save(file);
|
||||
else {
|
||||
return textEdit->save(calculator);
|
||||
}
|
||||
}
|
||||
|
||||
bool hp_mdiTextEdit::saveAs(){
|
||||
|
||||
if(content)
|
||||
return textEdit->saveAs(file);
|
||||
else {
|
||||
return textEdit->saveAs(calculator);
|
||||
}
|
||||
}
|
||||
|
||||
void hp_mdiTextEdit::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
||||
if (maybeSave()) {
|
||||
event->accept();
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool hp_mdiTextEdit::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_mdiTextEdit::show() {
|
||||
|
||||
if (textEdit)
|
||||
textEdit->show();
|
||||
QMdiSubWindow::show();
|
||||
}
|
||||
|
||||
hp_mdiTextEdit::~hp_mdiTextEdit() {
|
||||
|
||||
qDebug()<<"Entering ~hpmdiTextEdit()";
|
||||
if (textEdit!=nullptr)
|
||||
delete textEdit;
|
||||
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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 "hptreeitem.h"
|
||||
|
||||
hp_mdiVariableEdit::hp_mdiVariableEdit(QWidget *parent,
|
||||
hpTreeItem * treeItem,
|
||||
hpCalcData * dataStore)
|
||||
: hp_MdiWindow(parent)
|
||||
{
|
||||
setMinimumSize(200,200);
|
||||
setMaximumSize(1000,1000);
|
||||
setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
|
||||
|
||||
hptreeitem=treeItem;
|
||||
hpcalc = dataStore;
|
||||
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(calculator+filename);
|
||||
}
|
||||
|
||||
void hp_mdiVariableEdit::setup() {
|
||||
|
||||
if (data!=nullptr) {
|
||||
varmodel = new varTableModel(this,data,filename,type);
|
||||
tableView = new QTableView(this);
|
||||
tableView->setModel(varmodel);
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
void hp_mdiVariableEdit::show() {
|
||||
if(tableView!=nullptr)
|
||||
tableView->show();
|
||||
else {
|
||||
qWarning()<<"hp_mdiVariableEdit::show tableView null";
|
||||
}
|
||||
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() {
|
||||
|
||||
qDebug()<<"Entering ~hpmdiVariableEdit()";
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hp_mdiwindow.h"
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QBoxLayout>
|
||||
|
||||
hp_MdiWindow::hp_MdiWindow(QWidget * parent)
|
||||
:QMdiSubWindow(parent)
|
||||
{
|
||||
// setMinimumSize(500,400);
|
||||
// setMaximumSize(1000,1000);
|
||||
setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
|
||||
setup();
|
||||
}
|
||||
|
||||
void hp_MdiWindow::setup() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
void hp_MdiWindow::eventSave() {
|
||||
qDebug()<<"Save pressed";
|
||||
}
|
||||
|
||||
bool hp_MdiWindow::save() {
|
||||
|
||||
qDebug()<<"hp_MdiWindow::save";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hp_MdiWindow::saveAs() {
|
||||
|
||||
qDebug()<<"hp_MdiWindow::saveas";
|
||||
return false;
|
||||
}
|
||||
|
||||
void hp_MdiWindow::show() {
|
||||
|
||||
QMdiSubWindow::show();
|
||||
}
|
||||
|
||||
hp_MdiWindow::~hp_MdiWindow() {
|
||||
|
||||
qDebug()<<"Entering ~hpmdiWindow()";
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>hp_MdiWindow</class>
|
||||
<widget class="QMainWindow" name="hp_MdiWindow">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>575</width>
|
||||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>LogWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionSave"/>
|
||||
</widget>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/save_22x22.png</normaloff>:/icons/save_22x22.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="qthpconnect.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hp_settingsdlg.h"
|
||||
#include "ui_hp_settingsdlg.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
hp_SettingsDlg::hp_SettingsDlg(QWidget *parent, hp_Settings * hpset) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::hp_SettingsDlg)
|
||||
{
|
||||
if (hpset) {
|
||||
dlgset=*hpset;
|
||||
retsettings=hpset;
|
||||
}
|
||||
ui->setupUi(this);
|
||||
setupSettings();
|
||||
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(on_clicked(QAbstractButton*)));
|
||||
}
|
||||
|
||||
void hp_SettingsDlg::setupSettings() {
|
||||
ui->cb_angle->setCurrentIndex(dlgset.angle_measure);
|
||||
ui->cb_format->setCurrentIndex(dlgset.number_format);
|
||||
ui->cb_precision->setCurrentIndex(dlgset.precision);
|
||||
ui->cb_grouping->setCurrentIndex(dlgset.digit_grouping);
|
||||
ui->cb_entry->setCurrentIndex(dlgset.entry);
|
||||
ui->cb_integers->setCurrentIndex(dlgset.integers);
|
||||
ui->cb_complex->setCurrentIndex(dlgset.complex);
|
||||
ui->cb_language->setCurrentIndex(dlgset.language);
|
||||
ui->cb_font->setCurrentIndex(dlgset.font_size);
|
||||
ui->cb_theme->setCurrentIndex(dlgset.theme);
|
||||
|
||||
ui->le_integer->setText(QString().sprintf("%d",dlgset.bits));
|
||||
|
||||
if (dlgset.textbook)
|
||||
ui->ch_textbook->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->ch_textbook->setCheckState(Qt::Unchecked);
|
||||
|
||||
if (dlgset.menu)
|
||||
ui->ch_menu->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->ch_menu->setCheckState(Qt::Unchecked);
|
||||
|
||||
if (dlgset.signed_int)
|
||||
ui->ch_signed->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->ch_signed->setCheckState(Qt::Unchecked);
|
||||
|
||||
}
|
||||
|
||||
void hp_SettingsDlg::putSettings() {
|
||||
dlgset.angle_measure=ui->cb_angle->currentIndex();
|
||||
dlgset.number_format=ui->cb_format->currentIndex();
|
||||
dlgset.precision=ui->cb_precision->currentIndex();
|
||||
dlgset.digit_grouping= ui->cb_grouping->currentIndex();
|
||||
dlgset.entry=ui->cb_entry->currentIndex();
|
||||
dlgset.integers=ui->cb_integers->currentIndex();
|
||||
dlgset.complex=ui->cb_complex->currentIndex();
|
||||
dlgset.language=ui->cb_language->currentIndex();
|
||||
dlgset.font_size=ui->cb_font->currentIndex();
|
||||
dlgset.theme=ui->cb_theme->currentIndex();
|
||||
|
||||
dlgset.bits=ui->le_integer->text().toInt();
|
||||
|
||||
if (ui->ch_menu->checkState()==Qt::Checked)
|
||||
dlgset.menu=true;
|
||||
else
|
||||
dlgset.menu=false;
|
||||
|
||||
if (ui->ch_textbook->checkState()==Qt::Checked)
|
||||
dlgset.textbook=true;
|
||||
else
|
||||
dlgset.textbook=false;
|
||||
|
||||
if (ui->ch_signed->checkState()==Qt::Checked)
|
||||
dlgset.signed_int=true;
|
||||
else
|
||||
dlgset.signed_int=false;
|
||||
}
|
||||
|
||||
void hp_SettingsDlg::resetSettings() {
|
||||
hp_Settings newset;
|
||||
dlgset = newset;
|
||||
setupSettings();
|
||||
}
|
||||
|
||||
void hp_SettingsDlg::on_clicked(QAbstractButton * button) {
|
||||
|
||||
if(button==(QAbstractButton*) ui->buttonBox->button(QDialogButtonBox::Reset) ){
|
||||
resetSettings();
|
||||
}
|
||||
if(button==(QAbstractButton*) ui->buttonBox->button(QDialogButtonBox::Ok) ){
|
||||
putSettings();
|
||||
if (retsettings) {
|
||||
*retsettings=dlgset;
|
||||
}
|
||||
close();
|
||||
}
|
||||
if(button==(QAbstractButton*) ui->buttonBox->button(QDialogButtonBox::Cancel) ){
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
hp_SettingsDlg::~hp_SettingsDlg()
|
||||
{
|
||||
qDebug()<<"delete hp_SettingsDlf";
|
||||
delete ui;
|
||||
}
|
|
@ -1,720 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>hp_SettingsDlg</class>
|
||||
<widget class="QDialog" name="hp_SettingsDlg">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>415</width>
|
||||
<height>455</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="hpSettings">
|
||||
<attribute name="title">
|
||||
<string>Home Settings</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>17</x>
|
||||
<y>20</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Angle Measure:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_angle">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>20</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Radians</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Radians</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Degrees</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Gradians</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="ch_signed">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>150</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>±:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_format">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>50</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Standard</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Standard</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Fixed</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Scientific</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Engineering</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Floating</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rounded</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_grouping">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>81</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>123,456.789</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123,456.789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123'456.789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123 456.789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123456.789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123.456,789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123'456,789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123 456,789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123"456.789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>123456,789</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1234,5678.901</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1,23,456.789</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>50</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number Format:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>80</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Digit Grouping:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_entry">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>112</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Textbook</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Textbook</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Algebraic</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RPN</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>111</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Entry:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_integers">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>144</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Binary</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Binary</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Octal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Decimal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Hex</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>143</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Integers:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>175</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Complex:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_complex">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>176</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>a+b*i</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>a+b*i</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>(a,b)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_language">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>208</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Deutsch</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Deutsch</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>English</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Espanol</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Francais</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Nederlands</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Portugues</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>New Item</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>New Item</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>207</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>239</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font Size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_font">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>240</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Small Font</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Small Font</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Medium Font</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Large Font</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="ch_textbook">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>277</y>
|
||||
<width>141</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Textbook Display:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="ch_menu">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>151</x>
|
||||
<y>277</y>
|
||||
<width>141</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Menu Display:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_theme">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>311</y>
|
||||
<width>131</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Light</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Light</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dark</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>310</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color Theme:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="cb_precision">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>50</y>
|
||||
<width>51</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>9</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>11</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="le_integer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>266</x>
|
||||
<y>144</y>
|
||||
<width>41</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhDigitsOnly</set>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>32</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>hp_SettingsDlg</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>hp_SettingsDlg</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
438
hpdata.cpp
438
hpdata.cpp
|
@ -1,438 +0,0 @@
|
|||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// This class acts as a data store for the interface and calls for data as required
|
||||
//
|
||||
#include "hpdata.h"
|
||||
#include "global.h"
|
||||
#include "errorhandler.h"
|
||||
#include "abstractdata.h"
|
||||
#include "hp_typedef.h"
|
||||
|
||||
const QString hpCalcData::func_list[FUNC_NUM][2]={{"Application Library",":/icons/apps_32x32.png"},
|
||||
{"CAS Vars",":/icons/casFolder_32x32.png"},
|
||||
{"Real",":/icons/real_32x32.png"},
|
||||
{"Complex",":/icons/complex_32x32.png"},
|
||||
{"Lists",":/icons/list_32x32.png"},
|
||||
{"Matrices",":/icons/table_32x32.png"},
|
||||
{"Notes",":/icons/note_32x32.png"},
|
||||
{"Programs",":/icons/program_32x32.png"},
|
||||
{"Variables",":/icons/varFolder_32x32.png"}
|
||||
};
|
||||
|
||||
|
||||
const hp_DataType hpCalcData::func_type[FUNC_NUM]={HP_APP,
|
||||
HP_CAS,
|
||||
HP_REAL,
|
||||
HP_COMPLEX,
|
||||
HP_LIST,
|
||||
HP_MATRIX,
|
||||
HP_NOTE,
|
||||
HP_PROG,
|
||||
HP_VAR
|
||||
};
|
||||
|
||||
|
||||
|
||||
//constructor
|
||||
hpCalcData::hpCalcData(QString name, hpusb * handle)
|
||||
:QObject()
|
||||
{
|
||||
hp_api = handle;
|
||||
lData.clear();
|
||||
calculatorName=name;
|
||||
|
||||
//open usb port and store the handle
|
||||
if (hp_api) {
|
||||
hp_handle.calc=this;
|
||||
hp_api->hp_open(getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
//return the interface class
|
||||
hp_Handle * hpCalcData::getHandle() {
|
||||
hp_handle.calc=this;
|
||||
return &hp_handle;
|
||||
}
|
||||
|
||||
//return the interface class
|
||||
hpusb * hpCalcData::getAPI() {
|
||||
return hp_api;
|
||||
}
|
||||
|
||||
//data managment
|
||||
hp_Information hpCalcData::getInfo() {
|
||||
|
||||
return hp_info;
|
||||
}
|
||||
|
||||
//get Name
|
||||
QString hpCalcData::getName() {
|
||||
|
||||
return hp_info.name;
|
||||
}
|
||||
|
||||
//get Calculator Name
|
||||
QString hpCalcData::getCalculatorName() {
|
||||
|
||||
return calculatorName;
|
||||
}
|
||||
|
||||
|
||||
//get Settings
|
||||
hp_Settings hpCalcData::getSettings() {
|
||||
|
||||
return hp_homesettings;
|
||||
}
|
||||
|
||||
//Add a new object to the list
|
||||
void hpCalcData::addData(AbstractData * data) {
|
||||
lData.append(data);
|
||||
}
|
||||
|
||||
void hpCalcData::deleteData(AbstractData * data) {
|
||||
// lData.erase();
|
||||
if (data!=nullptr) {
|
||||
QString name=data->getName();
|
||||
hp_DataType type=data->getType();
|
||||
QList<AbstractData *>::iterator i;
|
||||
i=findData(name,type);
|
||||
|
||||
lData.erase(i);
|
||||
delete data;
|
||||
qDebug()<<"hpCalcData::deleteData - Object Deleted";
|
||||
}
|
||||
else {
|
||||
qDebug()<<"hpCalcData::deleteData - Object not deleted";
|
||||
}
|
||||
}
|
||||
|
||||
//returns position of entry in list or returns 0;
|
||||
QList<AbstractData *>::iterator hpCalcData::findData(QString name, hp_DataType dataType) {
|
||||
|
||||
QList<AbstractData *>::iterator i;
|
||||
AbstractData * ldata;
|
||||
|
||||
i = lData.begin();
|
||||
while (i!= lData.end()) {
|
||||
ldata=*i;
|
||||
if (ldata->equivalent(name,dataType)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//returns position of entry in list or returns 0;
|
||||
AbstractData * hpCalcData::getData(QString name, hp_DataType dataType) {
|
||||
|
||||
|
||||
for (int i = 0; i < lData.size(); ++i) {
|
||||
if (lData.at(i)->equivalent(name,dataType)) {
|
||||
|
||||
qDebug()<<"hpCalcData::Data found"<<name<<" "<<dataType;
|
||||
return lData.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug()<<"hpCalcData::No data found"<<name<<" "<<dataType;;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AbstractData * hpCalcData::dataAt(int i) {
|
||||
return lData.at(i);
|
||||
}
|
||||
|
||||
int hpCalcData::dataCount() {
|
||||
return lData.size();
|
||||
}
|
||||
|
||||
void hpCalcData::refresh() {
|
||||
readInfo();
|
||||
readSettings();
|
||||
}
|
||||
|
||||
//read Settings via usb
|
||||
void hpCalcData::readSettings() {
|
||||
|
||||
hpusb * api;
|
||||
hp_Handle * handle;
|
||||
hp_Settings hpset;
|
||||
|
||||
errlog("hpCalcData::readSettings: -Reading Settings");
|
||||
qDebug()<<"Reading Settings";
|
||||
api=getAPI();
|
||||
handle=getHandle();
|
||||
|
||||
if (api) {
|
||||
if(handle) {
|
||||
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle);
|
||||
if (api) {
|
||||
api->get_settings(handle);
|
||||
}
|
||||
}
|
||||
else {
|
||||
errlog("hpCalcData::readSettings Handle null");
|
||||
}
|
||||
}
|
||||
else {
|
||||
errlog("hpCalcData::readSettings API null");
|
||||
}
|
||||
// hp_homesettings=hpset;
|
||||
|
||||
// hp_Change change;
|
||||
// change.dataChange=HP_MAIN;
|
||||
// emit dataChanged(change);
|
||||
}
|
||||
|
||||
//read Settings via usb
|
||||
void hpCalcData::readScreen() {
|
||||
|
||||
hpusb * api;
|
||||
hp_Handle * handle;
|
||||
hp_Settings hpset;
|
||||
|
||||
errlog("Reading Screen");
|
||||
|
||||
api=getAPI();
|
||||
handle=getHandle();
|
||||
|
||||
QByteArray imageData;
|
||||
|
||||
if (api) {
|
||||
if(handle) {
|
||||
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle);
|
||||
if (api) {
|
||||
api->get_screen_shot(handle);
|
||||
// if (screenShot!=nullptr) {
|
||||
// delete screenShot;
|
||||
// }
|
||||
//
|
||||
// screenShot = new QPixmap();
|
||||
// screenShot->loadFromData(imageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
// emit emitChange(HP_SCREEN);
|
||||
}
|
||||
|
||||
//recieve Screenshot
|
||||
void hpCalcData::recvScreen(hp_ScreenShot shot) {
|
||||
|
||||
errlog("Recieving Screen");
|
||||
|
||||
QByteArray imageData;
|
||||
if (screenShot!=nullptr) {
|
||||
delete screenShot;
|
||||
}
|
||||
screenShot = shot.image;
|
||||
|
||||
emit emitChange(HP_SCREEN);
|
||||
}
|
||||
|
||||
//recieve Setting
|
||||
void hpCalcData::recvSettings(hp_Data data) {
|
||||
|
||||
QString filename;
|
||||
errlog("hpCalcData::recvSettings: Recieving Setting");
|
||||
filename = data.name;
|
||||
qDebug()<<filename;
|
||||
|
||||
if (filename==QStringLiteral("calc.hpsettings")) {
|
||||
qDebug()<<"hpCalcData::recvSetting - Setting";
|
||||
|
||||
qDebug()<<"hpCalcData::recvSetting - Real";
|
||||
errlog("hpCalcData::recvSetting - Real");
|
||||
Real * obj1 = new Real(data.name,HP_REAL);
|
||||
obj1->setData(data.data);
|
||||
addData(obj1);
|
||||
emit emitChange(HP_REAL);
|
||||
|
||||
qDebug()<<"hpCalcData::recvSetting - Complex";
|
||||
errlog("hpCalcData::recvSetting - Complex");
|
||||
Complex * obj2 = new Complex(data.name,HP_COMPLEX);
|
||||
obj2->setData(data.data);
|
||||
addData(obj2);
|
||||
emit emitChange(HP_COMPLEX);
|
||||
|
||||
}
|
||||
|
||||
if (filename== QStringLiteral("cas.hpsettings")) {
|
||||
qDebug()<<"cas.chps";
|
||||
|
||||
qDebug()<<"hpCalcData::recvSetting - CAS";
|
||||
CASVariables * obj2 = new CASVariables(data.name,HP_CAS);
|
||||
obj2->setData(data.data);
|
||||
addData(obj2);
|
||||
emit emitChange(HP_CAS);
|
||||
}
|
||||
|
||||
if (filename==QStringLiteral("calc.hpvars")) {
|
||||
|
||||
qDebug()<<"hpCalcData::recvSetting - Variables";
|
||||
Variables * var = new Variables(data.name,HP_VAR);
|
||||
var->setData(data.data);
|
||||
addData(var);
|
||||
}
|
||||
|
||||
if (filename==QStringLiteral("settings")) {
|
||||
qDebug()<<"set-";
|
||||
|
||||
qDebug()<<"hpCalcData::recvSetting - Variables";
|
||||
Settings * var = new Settings(data.name,HP_SETTINGS);
|
||||
var->setData(data.data);
|
||||
addData(var);
|
||||
}
|
||||
|
||||
emit emitChange(HP_MAIN);
|
||||
}
|
||||
|
||||
|
||||
//recieve Program
|
||||
void hpCalcData::recvProg(hp_Prog program) {
|
||||
|
||||
errlog("Recieving Program");
|
||||
qDebug()<<"hpCalcData::recvProg";
|
||||
|
||||
qDebug()<<program.filename;
|
||||
//qDebug()<<program.prog;
|
||||
|
||||
Program * obj = new Program(program.filename,HP_PROG, program.prog);
|
||||
obj->setData(program.data);
|
||||
addData(obj);
|
||||
|
||||
emit emitChange(HP_PROG);
|
||||
}
|
||||
|
||||
//recieve Program
|
||||
void hpCalcData::recvNote(hp_Note note) {
|
||||
|
||||
errlog("Recieving Note");
|
||||
qDebug()<<"hpCalcData::recvNote";
|
||||
|
||||
qDebug()<<note.filename;
|
||||
|
||||
Notes * obj = new Notes(note.filename,HP_NOTE, note.text);
|
||||
obj->setData(note.data);
|
||||
addData(obj);
|
||||
|
||||
emit emitChange(HP_NOTE);
|
||||
}
|
||||
|
||||
//recieve Program
|
||||
void hpCalcData::recvData(hp_Data data) {
|
||||
|
||||
errlog("Recieving Data");
|
||||
|
||||
switch (data.type) {
|
||||
case HP_APP: {
|
||||
qDebug()<<"hpCalcData::recvData - Application";
|
||||
Application * obj = new Application(data.name,data.type);
|
||||
obj->setData(data.data);
|
||||
addData(obj);
|
||||
emit emitChange(HP_APP);
|
||||
}
|
||||
break;
|
||||
case HP_LIST: {
|
||||
List * obj = new List(data.name,data.type);
|
||||
obj->setData(data.data);
|
||||
addData(obj);
|
||||
emit emitChange(HP_LIST);
|
||||
}
|
||||
break;
|
||||
case HP_MATRIX: {
|
||||
qDebug()<<"hpCalcData::recvData - Matrix";
|
||||
Matrix * obj = new Matrix(data.name,data.type);
|
||||
obj->setData(data.data);
|
||||
addData(obj);
|
||||
emit emitChange(HP_MATRIX);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void hpCalcData::emitChange(hp_DataType type) {
|
||||
|
||||
hp_Change change;
|
||||
change.dataChange=type;
|
||||
change.calc = this;
|
||||
|
||||
emit dataChanged(change);
|
||||
|
||||
}
|
||||
|
||||
hp_ScreenShot hpCalcData::getScreenShot() {
|
||||
hp_ScreenShot scn;
|
||||
|
||||
scn.image = screenShot;
|
||||
scn.format = CALC_SCREENSHOT_FORMAT_PRIME_PNG_320x240x16;
|
||||
scn.calc = this;
|
||||
|
||||
return scn;
|
||||
}
|
||||
|
||||
//set Settings
|
||||
int hpCalcData::setSettings(hp_Settings set) {
|
||||
|
||||
hp_homesettings=set;
|
||||
}
|
||||
|
||||
void hpCalcData::setInfo(hp_Information dtype) {
|
||||
hp_info=dtype;
|
||||
return;
|
||||
}
|
||||
|
||||
//read information via hp interface
|
||||
void hpCalcData::readInfo() {
|
||||
|
||||
hpusb * api;
|
||||
hp_Handle * handle;
|
||||
hp_Information hpinfo;
|
||||
|
||||
api=getAPI();
|
||||
handle=getHandle();
|
||||
|
||||
if (api) {
|
||||
if(handle) {
|
||||
qDebug()<<QString().sprintf("%s %p",__FUNCTION__,handle->usbhandle);
|
||||
if (api)
|
||||
api->load_info(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hpCalcData::recvInfo(hp_Information hpinfo) {
|
||||
|
||||
hp_info=hpinfo;
|
||||
emit emitChange(HP_MAIN);
|
||||
}
|
||||
|
||||
|
||||
void hpCalcData::vpkt_send_experiments(int cmd) {
|
||||
|
||||
hpusb * api;
|
||||
hp_Handle * handle;
|
||||
|
||||
api=getAPI();
|
||||
handle=getHandle();
|
||||
|
||||
if (api) {
|
||||
if(handle) {
|
||||
if (api) {
|
||||
api->is_ready(handle);
|
||||
|
||||
// api->vpkt_send_experiments(handle,cmd);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hpCalcData::~hpCalcData() {
|
||||
qDebug()<<"Close ~hpCalcData";
|
||||
};
|
|
@ -1,14 +0,0 @@
|
|||
#include <hptoolbox.h>
|
||||
#include "ui_hptoolbox.h"
|
||||
|
||||
hpToolBox::hpToolBox(QWidget *parent) :
|
||||
QToolBox(parent),
|
||||
ui(new Ui::hpToolBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
hpToolBox::~hpToolBox()
|
||||
{
|
||||
delete ui;
|
||||
}
|
641
hptreeitem.cpp
641
hptreeitem.cpp
|
@ -1,641 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hptreeitem.h"
|
||||
#include "global.h"
|
||||
#include "hpdata.h"
|
||||
#include "hp_mditexteditor.h"
|
||||
#include "hp_infodialog.h"
|
||||
#include "hp_settingsdlg.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
|
||||
const QString hpTreeItem::func_list[FUNC_NUM][2]={
|
||||
{"Main",":/icons/apps_32x32.png"},
|
||||
{"Application Library",":/icons/apps_32x32.png"},
|
||||
{"CAS Vars",":/icons/casFolder_32x32.png"},
|
||||
{"Real",":/icons/real_32x32.png"},
|
||||
{"Complex",":/icons/complex_32x32.png"},
|
||||
{"Lists",":/icons/list_32x32.png"},
|
||||
{"Matrices",":/icons/table_32x32.png"},
|
||||
{"Notes",":/icons/note_32x32.png"},
|
||||
{"Programs",":/icons/program_32x32.png"},
|
||||
{"Variables",":/icons/varFolder_32x32.png"}
|
||||
};
|
||||
|
||||
const hp_DataType hpTreeItem::func_type[FUNC_NUM]={
|
||||
HP_MAIN,
|
||||
HP_APP,
|
||||
HP_CAS,
|
||||
HP_REAL,
|
||||
HP_COMPLEX,
|
||||
HP_LIST,
|
||||
HP_MATRIX,
|
||||
HP_NOTE,
|
||||
HP_PROG,
|
||||
HP_VAR
|
||||
};
|
||||
|
||||
|
||||
|
||||
//QString hpTreeItem::hp_name;
|
||||
|
||||
|
||||
hpTreeItem::hpTreeItem()
|
||||
:QStandardItem() {
|
||||
setDropEnabled(true);
|
||||
setEditable(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
hpTreeItem::hpTreeItem(const QString & name,hpCalcData * hpDataStore,int flag)
|
||||
:QStandardItem(name)
|
||||
{
|
||||
setEditable(0);
|
||||
setDataStore(hpDataStore);
|
||||
|
||||
setDragEnabled(true);
|
||||
setDropEnabled(true);
|
||||
|
||||
// filename=name;
|
||||
|
||||
if (flag==0)
|
||||
setGraphicTree();
|
||||
}
|
||||
|
||||
bool hpTreeItem::dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) {
|
||||
|
||||
qDebug()<<"hpTreeItem::dropMimeData";
|
||||
}
|
||||
|
||||
QStandardItem * hpTreeItem::clone() const {
|
||||
//return new hpTreeItem(QStringLiteral("test"),getDataStore(),0);
|
||||
}
|
||||
|
||||
void hpTreeItem::setGraphicTree() {
|
||||
|
||||
int func_num=FUNC_NUM;
|
||||
hpTreeItem * newChild;
|
||||
|
||||
int i;
|
||||
|
||||
for (i=1; i<func_num; i++)
|
||||
{
|
||||
newChild= new hpTreeItem(func_list[i][0],getDataStore(),1);
|
||||
newChild->setType(func_type[i]);
|
||||
newChild->setIcon(QIcon(func_list[i][1]));
|
||||
newChild->setEditable(0);
|
||||
newChild->setToolTip(QString("Manage Applications"));
|
||||
// newChild->getDataStore()->getInfo().serialnum="12-3456";
|
||||
appendRow(newChild);
|
||||
}
|
||||
}
|
||||
|
||||
void hpTreeItem::clickAction(QMdiArea * mdiwin) {
|
||||
|
||||
hp_infoDialog * hpinfodlg;
|
||||
hp_Information hpinfo;
|
||||
hpCalcData * calc;
|
||||
hp_DataStruct hpdata;
|
||||
calc=getDataStore();
|
||||
AbstractData * data=nullptr;
|
||||
|
||||
// QString test;
|
||||
// test=data(Qt::DisplayRole).toString();
|
||||
|
||||
qDebug()<<"hpTreeItem::clickAction ... click";
|
||||
|
||||
switch (getType()) {
|
||||
case HP_MAIN: {
|
||||
hpCalcData * dataStore;
|
||||
dataStore = getDataStore();
|
||||
hpinfo=dataStore->getInfo();
|
||||
hpinfodlg = new hp_infoDialog(mdiwin,hpinfo);
|
||||
hpinfodlg->show();
|
||||
}
|
||||
break;
|
||||
case HP_APP: {
|
||||
|
||||
}
|
||||
break;
|
||||
case HP_CAS:
|
||||
if (hpvaredit==nullptr) {
|
||||
if (calc) {
|
||||
data=calc->getData(getFileName(),HP_COMPLEX);
|
||||
}
|
||||
if (data!=nullptr) {
|
||||
hpvaredit = new hp_mdiVariableEdit(mdiwin,this,calc);
|
||||
}
|
||||
}
|
||||
if (hpvaredit!=nullptr)
|
||||
hpvaredit ->show();
|
||||
case HP_COMPLEX:
|
||||
if (hpvaredit==nullptr) {
|
||||
if (calc) {
|
||||
data=calc->getData(getFileName(),HP_COMPLEX);
|
||||
}
|
||||
if (data!=nullptr) {
|
||||
hpvaredit = new hp_mdiVariableEdit(mdiwin,this,calc);
|
||||
}
|
||||
}
|
||||
if (hpvaredit!=nullptr)
|
||||
hpvaredit ->show();
|
||||
break;
|
||||
case HP_LIST:
|
||||
if (hpvaredit==nullptr) {
|
||||
if (calc) {
|
||||
data=calc->getData(getFileName(),HP_LIST);
|
||||
}
|
||||
if (data) {
|
||||
hpvaredit = new hp_mdiVariableEdit(mdiwin,this,calc);
|
||||
}
|
||||
}
|
||||
if (hpvaredit!=nullptr)
|
||||
hpvaredit ->show();
|
||||
break;
|
||||
case HP_MATRIX:
|
||||
if (hpvaredit==nullptr) {
|
||||
if (calc) {
|
||||
data=calc->getData(getFileName(),HP_MATRIX);
|
||||
}
|
||||
if (data!=nullptr) {
|
||||
hpvaredit = new hp_mdiVariableEdit(mdiwin,this,calc);
|
||||
}
|
||||
}
|
||||
if (hpvaredit!=nullptr)
|
||||
hpvaredit ->show();
|
||||
break;
|
||||
case HP_NOTE: {
|
||||
hpCalcData * dataStore;
|
||||
dataStore = getDataStore();
|
||||
|
||||
AbstractData * data =nullptr;
|
||||
dataStore = getDataStore();
|
||||
if (dataStore) {
|
||||
data=dataStore->getData(getFileName(),getType());
|
||||
}
|
||||
|
||||
//To fix by having hp_mdi reset
|
||||
hptextedit=nullptr;
|
||||
|
||||
|
||||
if ((hptextedit==nullptr)&&(data!=nullptr))
|
||||
hptextedit = new hp_mdiTextEdit(mdiwin,this, data);
|
||||
if (hptextedit!=nullptr)
|
||||
hptextedit ->show();
|
||||
}
|
||||
break;
|
||||
case HP_PROG: {
|
||||
hpCalcData * dataStore =nullptr;
|
||||
AbstractData * data =nullptr;
|
||||
dataStore = getDataStore();
|
||||
qDebug()<<"HP_Prog ... click"<<getFileName();
|
||||
if (dataStore!=nullptr) {
|
||||
data=dataStore->getData(getFileName(),getType());
|
||||
if(data!=nullptr) {
|
||||
qDebug()<<data->getName();
|
||||
}
|
||||
}
|
||||
|
||||
//To fix by having hp_mdi reset
|
||||
hptextedit=nullptr;
|
||||
|
||||
if ((hptextedit==nullptr)&&(data!=nullptr)) {
|
||||
hptextedit = new hp_mdiTextEdit(mdiwin,this, data);
|
||||
}
|
||||
if (hptextedit!=nullptr)
|
||||
hptextedit ->show();
|
||||
}
|
||||
break;
|
||||
case HP_REAL:
|
||||
if (hpvaredit==nullptr) {
|
||||
if (calc) {
|
||||
data=calc->getData(getFileName(),HP_REAL);
|
||||
}
|
||||
if (data!=nullptr) {
|
||||
hpvaredit = new hp_mdiVariableEdit(mdiwin,this,calc);
|
||||
}
|
||||
}
|
||||
if (hpvaredit!=nullptr)
|
||||
hpvaredit ->show();
|
||||
break;
|
||||
case HP_VAR:
|
||||
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
void hpTreeItem::contextAction(QMdiArea * mdiwin, contextActionType cta) {
|
||||
|
||||
hp_SettingsDlg * hpsettingsdlg;
|
||||
hp_Information hpinfo;
|
||||
hp_Settings hpset;
|
||||
int ret=0;
|
||||
switch (getType()) {
|
||||
case HP_MAIN: {
|
||||
switch (cta) {
|
||||
case CT_PREFERENCE: {
|
||||
hpCalcData * dataStore;
|
||||
dataStore = getDataStore();
|
||||
dataStore->readSettings();
|
||||
hpset=dataStore->getSettings();
|
||||
hpsettingsdlg = new hp_SettingsDlg(mdiwin, &hpset);
|
||||
ret=hpsettingsdlg->exec();
|
||||
if (ret)
|
||||
dataStore->setSettings(hpset);
|
||||
}
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
hp_DataType hpTreeItem::getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
void hpTreeItem::setType(hp_DataType dtype) {
|
||||
type=dtype;
|
||||
return;
|
||||
}
|
||||
|
||||
//manage access to datastore
|
||||
hpCalcData * hpTreeItem::getDataStore() {
|
||||
if (hp_data) {
|
||||
qDebug()<<"Data store found";
|
||||
return hp_data;
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Null data store";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void hpTreeItem::setDataStore(hpCalcData * dtype) {
|
||||
hp_data=dtype;
|
||||
return;
|
||||
}
|
||||
|
||||
int hpTreeItem::dt2int() {
|
||||
switch (getType()) {
|
||||
case HP_APP: return 0;
|
||||
case HP_CAS: return 1;
|
||||
case HP_COMPLEX: return 2;
|
||||
case HP_LIST: return 3;
|
||||
case HP_MATRIX: return 4;
|
||||
case HP_NOTE: return 5;
|
||||
case HP_PROG: return 6;
|
||||
case HP_REAL: return 7;
|
||||
case HP_VAR: return 8;
|
||||
default:;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString hpTreeItem::getGroupName() {
|
||||
return func_list[dt2int()][0];
|
||||
}
|
||||
|
||||
QString hpTreeItem::getFileName() {
|
||||
|
||||
return text();
|
||||
}
|
||||
|
||||
QString hpTreeItem::getCalculatorName() {
|
||||
hpCalcData * hpcalc;
|
||||
QString calcName;
|
||||
hpcalc=getDataStore();
|
||||
|
||||
if (hpcalc!=nullptr)
|
||||
calcName=hpcalc->getCalculatorName();
|
||||
|
||||
qDebug()<<calcName;
|
||||
return calcName;
|
||||
}
|
||||
|
||||
void hpTreeItem::setFileName(QString file) {
|
||||
|
||||
|
||||
qDebug()<<"rename "<<text()<<" to "<<file;
|
||||
|
||||
// filename=file;
|
||||
setText(file);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//Slot to respond to data changes
|
||||
void hpTreeItem::dataChange(hp_Change hpchange) {
|
||||
|
||||
hpCalcData * ptr=nullptr;
|
||||
QString name;
|
||||
switch (hpchange.dataChange) {
|
||||
case HP_MAIN:
|
||||
ptr=getDataStore();
|
||||
if (ptr) {
|
||||
name=ptr->getName();
|
||||
setData(name,Qt::DisplayRole);
|
||||
}
|
||||
break;
|
||||
case HP_SCREEN: {
|
||||
emit dataChanged(hpchange);
|
||||
}
|
||||
break;
|
||||
case HP_REAL: {
|
||||
refresh();
|
||||
}
|
||||
break;
|
||||
case HP_APP: {
|
||||
refresh();
|
||||
}
|
||||
case HP_MATRIX: {
|
||||
refresh();
|
||||
}
|
||||
break;
|
||||
case HP_LIST: {
|
||||
refresh();
|
||||
}
|
||||
break;
|
||||
case HP_NOTE: {
|
||||
refresh();
|
||||
}
|
||||
break;
|
||||
case HP_PROG: {
|
||||
refresh();
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
void hpTreeItem::addChild(AbstractData *obj) {
|
||||
hpTreeItem * subItem=nullptr;
|
||||
hp_DataType type;
|
||||
|
||||
qDebug()<<"hpTreeItem:Adding Child";
|
||||
|
||||
if (obj!=nullptr) {
|
||||
QString name;
|
||||
//create fixed variable list
|
||||
|
||||
type= obj->getType();
|
||||
name=obj->getName();
|
||||
|
||||
qDebug()<<"hpTreeItem:this is "<<getFileName()<<" of type:"<<getType()
|
||||
<<"Column:"<<columnCount();
|
||||
|
||||
//check if this is the same type
|
||||
if ((getType()==type)&&(columnCount()<3))
|
||||
{
|
||||
|
||||
qDebug()<<"hpTreeItem: Creating hpTreeItem:"<<type;
|
||||
qDebug()<<"Column Count:"<<columnCount();
|
||||
|
||||
switch (type) {
|
||||
case HP_APP: {
|
||||
subItem= new hpTreeItem(name,getDataStore(),1);
|
||||
subItem->setType(type);
|
||||
subItem->setIcon(QIcon(func_list[HP_APP][1]));
|
||||
}
|
||||
break;
|
||||
case HP_MATRIX: {
|
||||
subItem= new hpTreeItem(name,getDataStore(),1);
|
||||
subItem->setType(type);
|
||||
subItem->setIcon(QIcon(func_list[HP_MATRIX][1]));
|
||||
}
|
||||
break;
|
||||
case HP_LIST: {
|
||||
subItem= new hpTreeItem(name,getDataStore(),1);
|
||||
subItem->setType(type);
|
||||
subItem->setIcon(QIcon(func_list[HP_LIST][1]));
|
||||
|
||||
}
|
||||
break;
|
||||
case HP_NOTE: {
|
||||
subItem= new hpTreeItem(name,getDataStore(),1);
|
||||
subItem->setType(type);
|
||||
subItem->setIcon(QIcon(func_list[HP_NOTE][1]));
|
||||
qDebug()<<"hpTreeItem: Creating Note type:"<<type;
|
||||
}
|
||||
break;
|
||||
case HP_PROG: {
|
||||
subItem= new hpTreeItem(name,getDataStore(),1);
|
||||
subItem->setType(type);
|
||||
subItem->setIcon(QIcon(func_list[HP_PROG][1]));
|
||||
}
|
||||
break;
|
||||
case HP_REAL: {
|
||||
setType(type);
|
||||
setFileName(name);
|
||||
}
|
||||
break;
|
||||
case HP_COMPLEX: {
|
||||
setType(type);
|
||||
setFileName(name);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
subItem= new hpTreeItem(name,getDataStore(),1);
|
||||
subItem->setType(type);
|
||||
}
|
||||
}
|
||||
if (subItem)
|
||||
appendRow(subItem);
|
||||
}
|
||||
else {
|
||||
qDebug()<<"hpTreeItem:No Object added";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Up date the data
|
||||
void hpTreeItem::refresh() {
|
||||
int rows,i,j;
|
||||
int datalen;
|
||||
hpTreeItem * ti_child;
|
||||
|
||||
QString name;
|
||||
hp_DataType type;
|
||||
|
||||
rows=rowCount();
|
||||
hpCalcData * calc;
|
||||
|
||||
calc=getDataStore();
|
||||
|
||||
if (calc) {
|
||||
if (columnCount()==1) {
|
||||
AbstractData * obj;
|
||||
datalen=calc->dataCount();
|
||||
//get object at from calc
|
||||
//get number of list items
|
||||
|
||||
//for all data items in list
|
||||
for (j=0; j<datalen; j++ ) {
|
||||
//compare with data
|
||||
obj= calc->dataAt(j);
|
||||
|
||||
if (obj) {
|
||||
for (i=0; i<rows; i++) {
|
||||
ti_child=(hpTreeItem *)child(i);
|
||||
name=ti_child->getFileName();
|
||||
type=ti_child->getType();
|
||||
|
||||
if(obj->getType()==type) {
|
||||
ti_child->addFile(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"hpTreeItem:obj is null!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//delete excess
|
||||
qDebug()<<"hpTreeItem: Checking for deletes";
|
||||
if (columnCount()==1) {
|
||||
AbstractData * obj;
|
||||
int ret;
|
||||
rows=rowCount();
|
||||
flag =0;
|
||||
//for all rows check data exists
|
||||
for (i=0; i<rows; i++) {
|
||||
ti_child=(hpTreeItem *)child(i);
|
||||
if (ti_child) {
|
||||
name=ti_child->getFileName();
|
||||
type=ti_child->getType();
|
||||
for (j=0; j<datalen; j++ ) {
|
||||
//compare with all data
|
||||
obj= calc->dataAt(j);
|
||||
if (obj) {
|
||||
qDebug()<<"hpTreeItem::refresh - calling object";
|
||||
if(obj->getType()==type) {
|
||||
ret=ti_child->findFile(obj->getName());
|
||||
}
|
||||
if(ret!=0) {
|
||||
flag =1; //obj found
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//If data and no row add row
|
||||
if (flag==0) {
|
||||
qDebug()<<"hpTreeItem::refresh - deleting ";
|
||||
removeRow(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//check if file is in the list and add it if not
|
||||
void hpTreeItem::addFile(AbstractData * obj) {
|
||||
|
||||
int i;
|
||||
int rows;
|
||||
int flag;
|
||||
|
||||
hpTreeItem * ti_child;
|
||||
QString name;
|
||||
hp_DataType type;
|
||||
|
||||
// qDebug()<<"hpTreeItem::addFile";
|
||||
|
||||
rows=rowCount();
|
||||
flag=0;
|
||||
|
||||
if (obj) {
|
||||
// qDebug()<<"hpTreeItem::addFile - File Not null";
|
||||
for (i=0; i<rows; i++) {
|
||||
ti_child=(hpTreeItem *)child(i);
|
||||
name=ti_child->getFileName();
|
||||
type=ti_child->getType();
|
||||
if(obj->equivalent(name,type)) {
|
||||
flag =1; //obj found
|
||||
}
|
||||
}
|
||||
//If data and no row add row
|
||||
if (flag==0) {
|
||||
qDebug()<<"hpTreeItem::addFile - Adding a child";
|
||||
addChild(obj);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"hpTreeItem:obj is null!";
|
||||
}
|
||||
}
|
||||
|
||||
//check if file is in the list of children and add it if not return 0 else return row;
|
||||
int hpTreeItem::findFile(QString dataname) {
|
||||
|
||||
int i;
|
||||
int rows;
|
||||
int flag;
|
||||
|
||||
rows=rowCount();
|
||||
hpTreeItem * ti_child;
|
||||
QString name;
|
||||
|
||||
for (i=0; i<rows; i++) {
|
||||
ti_child=static_cast<hpTreeItem *>(child(i));
|
||||
dataname=ti_child->getFileName();
|
||||
if(name==dataname) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
hpTreeItem::~hpTreeItem() {
|
||||
|
||||
/*
|
||||
if (hpvaredit!=nullptr) {
|
||||
hpvaredit->close();
|
||||
delete hpvaredit;
|
||||
hpvaredit=nullptr;
|
||||
}
|
||||
|
||||
if (hptextedit!=nullptr) {
|
||||
hptextedit->close();
|
||||
delete hptextedit;
|
||||
hptextedit=nullptr;
|
||||
}
|
||||
|
||||
if (mdiarea!=nullptr) {
|
||||
mdiarea->close();
|
||||
mdiarea=nullptr;
|
||||
}
|
||||
*/
|
||||
removeColumn(0);
|
||||
qDebug()<<"hpTreeItem:: delete"<<text();
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@ public:
|
|||
hp_pkt_type getFileCode();
|
||||
virtual void setData(QByteArray);
|
||||
virtual QByteArray getData(); //data extract
|
||||
virtual bool getData(QDataStream &ds);
|
||||
virtual void parseData();
|
||||
virtual void parseData(QDataStream& in);
|
||||
virtual QByteArray fileOut(); //full data out in file transmittable format
|
||||
|
@ -103,10 +104,10 @@ class List: public AbstractData
|
|||
{
|
||||
private:
|
||||
QList <itemData>values;
|
||||
void parseData();
|
||||
void parseData() override;
|
||||
public:
|
||||
List(QString, hp_DataType);
|
||||
QByteArray getData();
|
||||
QByteArray getData() override;
|
||||
itemData getListItem(int);
|
||||
void setListItem(int, itemData);
|
||||
QString getItem(int);
|
||||
|
@ -123,11 +124,13 @@ public:
|
|||
Matrix(QString, hp_DataType);
|
||||
itemData getListItem(int row, int column);
|
||||
void setListItem(int, int, itemData);
|
||||
void parseData();
|
||||
virtual void parseData(QDataStream& in);
|
||||
void parseData() override;
|
||||
virtual void parseData(QDataStream& in) override;
|
||||
QString getItem(int row, int column);
|
||||
void setItem(int, int, QString);
|
||||
void setItem(int, int, QString, double);
|
||||
// QByteArray getData() override;
|
||||
bool getData(QDataStream &ds);
|
||||
m_Size getMatrixSize();
|
||||
int getMatrixRows();
|
||||
int getMatrixColumns();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QMutexLocker>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
|
||||
#ifndef ERRORHANDLER_H
|
||||
#define ERRORHANDLER_H
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
void show();
|
||||
bool save() override;
|
||||
bool saveAs() override;
|
||||
bool saveFile(const QFileInfo fileinfo);
|
||||
bool maybeSave();
|
||||
~hp_mdiVariableEdit() override;
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ private slots:
|
|||
void closeEvent(QCloseEvent *) override;
|
||||
void createLogWindow();
|
||||
void testFunction();
|
||||
void testFunction2();
|
||||
void writeSettings();
|
||||
void readSettings();
|
||||
void setTimerStopped();
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#define MATRIXDATA_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
|
||||
struct itemData {
|
||||
double dReal=0.0;
|
||||
|
@ -40,6 +42,7 @@ public:
|
|||
int rows();
|
||||
void addRow(int);
|
||||
int columns();
|
||||
bool dataOut(QDataStream &out);
|
||||
void resize(int,int);
|
||||
void upsize(int,int);
|
||||
void matchsize();
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
AbstractData * dataobj =nullptr;
|
||||
QList<QList<double>> dataarray;
|
||||
void setup();
|
||||
|
||||
bool ismodified=false;
|
||||
bool isUntitled;
|
||||
QDir defaultPath;
|
||||
|
||||
|
@ -59,12 +59,9 @@ public:
|
|||
int columnCount(const QModelIndex &parent = QModelIndex()) 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);
|
||||
bool getData( QDataStream &ds);
|
||||
bool isModified();
|
||||
void resetModified();
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
~varTableModel() override;
|
||||
|
|
49
main.cpp
49
main.cpp
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Q_INIT_RESOURCE(qthpconnect);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QCoreApplication::setOrganizationName("");
|
||||
QCoreApplication::setApplicationName("Linux QtHP Connect");
|
||||
QCoreApplication::setApplicationVersion(HP_VERSION_STRING);
|
||||
QCommandLineParser parser;
|
||||
MainWindow w;
|
||||
|
||||
parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||
//REWORK
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
// parser.addPositionalArgument("file", "The file to open.");
|
||||
parser.process(a);
|
||||
|
||||
// a.setQuitLockEnabled(true);
|
||||
// if (!parser.positionalArguments().isEmpty())
|
||||
// w.loadFile(parser.positionalArguments().first());
|
||||
w.show();
|
||||
a.exec();
|
||||
qDebug()<<"Main.cpp:: closing main";
|
||||
return 1;
|
||||
}
|
1083
mainwindow.cpp
1083
mainwindow.cpp
File diff suppressed because it is too large
Load diff
21
mainwindow.h
21
mainwindow.h
|
@ -1,21 +0,0 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
698
mainwindow.ui
698
mainwindow.ui
|
@ -1,698 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>Ian Gebbie</author>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>919</width>
|
||||
<height>584</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Linux HP Connect</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QMdiArea" name="mdiArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>919</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>Fi&le</string>
|
||||
</property>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit">
|
||||
<property name="title">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPreferences"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuWindow">
|
||||
<property name="title">
|
||||
<string>Wi&ndow</string>
|
||||
</property>
|
||||
<addaction name="actionClose"/>
|
||||
<addaction name="actionClose_all"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionTile"/>
|
||||
<addaction name="actionCascade"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionNext"/>
|
||||
<addaction name="actionPrevious"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMessages"/>
|
||||
<addaction name="actionMonitor"/>
|
||||
<addaction name="actionCalculators"/>
|
||||
<addaction name="actionContent"/>
|
||||
<addaction name="actionLog"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionAbout_HP_Connect"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuWindow"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dwCalculator">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>184</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>524287</width>
|
||||
<height>524287</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="wCalculator">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTreeView" name="tvCalculators">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::ActionsContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Calculator View</p></body></html></string>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionCalculators"/>
|
||||
<addaction name="actionContent"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_All"/>
|
||||
<addaction name="actionCreateNew"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMonitor"/>
|
||||
<addaction name="actionMessages"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionTest"/>
|
||||
<addaction name="actionTestSettings"/>
|
||||
<addaction name="actionTestScreen"/>
|
||||
<addaction name="actionRefresh"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dwContent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>130</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>524287</width>
|
||||
<height>524287</height>
|
||||
</size>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="wContent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeView" name="tvContent">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>File View</p></body></html></string>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectItems</enum>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<attribute name="headerCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerMinimumSectionSize">
|
||||
<number>47</number>
|
||||
</attribute>
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>150</number>
|
||||
</attribute>
|
||||
<attribute name="headerHighlightSections">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dwMessenger">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>524287</height>
|
||||
</size>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="wMessage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="teMessage"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dwMonitor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="wMonitor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="wMonitorGrid" rowstretch="0" columnstretch="0" rowminimumheight="0"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>20</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string extracomment="Status"/>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<action name="actionCut">
|
||||
<property name="icon">
|
||||
<iconset theme="cut" resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/cut_32x32.png</normaloff>:/icons/cut_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Cut</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="icon">
|
||||
<iconset theme="action_copy" resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/copy_32x32.png</normaloff>:/icons/copy_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>C&opy</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPaste">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/paste_32x32.png</normaloff>:/icons/paste_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Paste</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose_all">
|
||||
<property name="text">
|
||||
<string>C&lose all</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTile">
|
||||
<property name="text">
|
||||
<string>&Tile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCascade">
|
||||
<property name="text">
|
||||
<string>Ca&scade</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNext">
|
||||
<property name="text">
|
||||
<string>&Next</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMessages">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/chat_32x32.png</normaloff>:/icons/chat_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Messages</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMonitor">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/monitor_32x32.png</normaloff>:/icons/monitor_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>M&onitor</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCalculators">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/calc_tree_32x32.png</normaloff>:/icons/calc_tree_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Calc&ulators</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout_HP_Connect">
|
||||
<property name="icon">
|
||||
<iconset theme="about" resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/about_32x32.png</normaloff>:/icons/about_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&About HP Connect</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPreferences">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>P&references</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font/>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPrevious">
|
||||
<property name="text">
|
||||
<string>&Previous</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionContent">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/content_32x32.png</normaloff>:/icons/content_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cont&ent</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/save_32x32.png</normaloff>:/icons/save_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_All">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/save_all_32x32.png</normaloff>:/icons/save_all_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateNew">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/add_new_32x32.png</normaloff>:/icons/add_new_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CreateNew</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create New </string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/delete_32x32.png</normaloff>:/icons/delete_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/add_icon_32x32.png</normaloff>:/icons/add_icon_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLog">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/note_32x32.png</normaloff>:/icons/note_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Lo&g</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTest">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/clone_to_32x32.png</normaloff>:/icons/clone_to_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Test Button</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTreePreference">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TreePreference</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTestSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TestSettings</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTestScreen">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/add_background_32x32.png</normaloff>:/icons/add_background_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TestScreen</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Test get Screen Function</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/refresh_32x32.png</normaloff>:/icons/refresh_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFileOpen">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/open_16x16.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open a file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFileDelete">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/delete_16x16.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Delete</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete a file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFileRename">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/rename_16x16.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Rename</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rename a file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCalcOpen">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/open_16x16.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open a file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCalcDelete">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/delete_16x16.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Delete</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete a file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCalcRename">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/rename_16x16.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Rename</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rename a file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNewFolder">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<normaloff>:/icons/new_folder_16x16.png</normaloff>:/icons/new_folder_16x16.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Folder</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create a New Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew_Note">
|
||||
<property name="text">
|
||||
<string>New Note</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew_Program">
|
||||
<property name="text">
|
||||
<string>New Program</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="qthpconnect.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
258
matrixdata.cpp
258
matrixdata.cpp
|
@ -1,258 +0,0 @@
|
|||
/*
|
||||
* QtHP Connect: hand-helds support interface.
|
||||
* Copyright (C) 2019 Ian Gebbie
|
||||
* Code patterns and snippets borrowed from libhpcalcs :
|
||||
* Copyright (C) 1999-2009 Romain Li<EFBFBD>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 <QDebug>
|
||||
#include "matrixdata.h"
|
||||
|
||||
MatrixData::MatrixData()
|
||||
{
|
||||
// clear();
|
||||
qDebug()<<"MtarixData Construct";
|
||||
}
|
||||
|
||||
//Return the item or a zero item
|
||||
itemData MatrixData::at(int row, int column)
|
||||
{
|
||||
QList<itemData> * rowlist;
|
||||
itemData item;
|
||||
|
||||
if (row<matrix.size()) {
|
||||
rowlist=matrix.at(row);
|
||||
if (rowlist) {
|
||||
if (column<rowlist->size()) {
|
||||
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<itemData> * rowlist=nullptr;
|
||||
|
||||
upsize(row+1,column+1);
|
||||
|
||||
if(row<matrix.size())
|
||||
rowlist=matrix.at(row);
|
||||
|
||||
if(rowlist) {
|
||||
rowlist->replace(column,data);
|
||||
}
|
||||
}
|
||||
|
||||
//Add a new row
|
||||
void MatrixData::addRow(int row)
|
||||
{
|
||||
int rows;
|
||||
int i;
|
||||
QList<itemData> * rowlist;
|
||||
|
||||
|
||||
// qDebug()<<"MatrixData::addRow" << row;
|
||||
rows=matrix.size();
|
||||
if (rows<=row)
|
||||
{
|
||||
for (i=rows; i<=row;i++) {
|
||||
// qDebug()<<"MatrixData::addRow "<<i;
|
||||
|
||||
rowlist = new QList<itemData>;
|
||||
matrix.insert(i,rowlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get all columns to same size by padding it zero items
|
||||
void MatrixData::resize(int newrow,int newcol) {
|
||||
|
||||
QList<itemData> * 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 "<<maxcolumns;
|
||||
|
||||
//decrease rows if not requiered
|
||||
for(i=0;i<rows;i++) {
|
||||
if (i>newrow) {
|
||||
matrix.removeAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
//increase rows to match
|
||||
if(newrow>rows) {
|
||||
|
||||
for(i=rows;i<newrow;i++) {
|
||||
addRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
rows = matrix.size();
|
||||
qDebug()<<"MatrixData::resize - rows "<<rows;
|
||||
//match colums
|
||||
for(i=0;i<rows;i++) {
|
||||
columns=matrix.at(i)->size();
|
||||
if (columns<newcol) {
|
||||
row=matrix.at(i);
|
||||
for(j=columns;j<maxcolumns; j++) {
|
||||
row->insert(j,item);
|
||||
}
|
||||
}
|
||||
if (columns>newcol) {
|
||||
row=matrix.at(i);
|
||||
if (row) {
|
||||
for(j=columns;j<maxcolumns; j++) {
|
||||
row->removeAt(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get all columns to same size by padding it zero items
|
||||
void MatrixData::upsize(int newrow,int newcol) {
|
||||
|
||||
QList<itemData> * row;
|
||||
int rows=0;
|
||||
|
||||
int columns=0;
|
||||
|
||||
int i;
|
||||
int j;
|
||||
|
||||
qDebug()<<"MatrixData::upsize";
|
||||
|
||||
itemData item;
|
||||
item.sValue=QStringLiteral("0");
|
||||
|
||||
rows = matrix.size();
|
||||
// qDebug()<<"MatrixData::upsize - rows:"<<newrow<<" columns:"<<newcol;
|
||||
|
||||
//increase rows to match
|
||||
if(rows<newrow) {
|
||||
for(i=rows;i<newrow;i++) {
|
||||
addRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
rows = matrix.size();
|
||||
// qDebug()<<"MatrixData::upsize - rows "<<rows;
|
||||
//match colums
|
||||
for(i=0;i<rows;i++) {
|
||||
row=matrix.at(i);
|
||||
if (row) {
|
||||
columns=row->size();
|
||||
for(j=columns;j<newcol; j++) {
|
||||
if (j<newcol) {
|
||||
// qDebug()<<"MatrixData::upsize - column "<<newcol<<" at"<<j;
|
||||
row->insert(j,item);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug()<<"MatrixData::upsize - Null row!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get all columns to same size by padding it zero items
|
||||
void MatrixData::matchsize() {
|
||||
|
||||
QList<itemData> * 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;i<rows;i++) {
|
||||
columns=matrix.at(i)->size();
|
||||
if (maxcolumns<columns)
|
||||
maxcolumns=columns;
|
||||
}
|
||||
qDebug()<<"MatrixData::matchsize - maxcolumns "<<maxcolumns;
|
||||
for(i=0;i<rows;i++) {
|
||||
columns=matrix.at(i)->size();
|
||||
if (columns<maxcolumns) {
|
||||
row=matrix.at(i);
|
||||
for(j=columns;j<maxcolumns; j++) {
|
||||
row->insert(j,item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MatrixData::clear()
|
||||
{
|
||||
int i;
|
||||
int r;
|
||||
QList<itemData> * row;
|
||||
|
||||
r=rows();
|
||||
|
||||
for(i=0; i<r;i++) {
|
||||
row=matrix.at(i);
|
||||
if (row) {
|
||||
row->clear();
|
||||
delete row;
|
||||
}
|
||||
}
|
||||
matrix.clear();
|
||||
}
|
||||
|
||||
int MatrixData::columns()
|
||||
{
|
||||
QList<itemData> * row;
|
||||
|
||||
if (matrix.size()>0) {
|
||||
row=matrix.at(0);
|
||||
if (row) {
|
||||
qDebug()<<"MatrixData: column "<<row->size();
|
||||
return row->size();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MatrixData::rows()
|
||||
{
|
||||
qDebug()<<"MatrixData: row"<<matrix.size();
|
||||
matrix.size();
|
||||
}
|
||||
|
||||
MatrixData::~MatrixData()
|
||||
{
|
||||
qDebug()<<"Entering ~MatrixData()";
|
||||
clear();
|
||||
}
|
1127
model.qmodel
1127
model.qmodel
File diff suppressed because it is too large
Load diff
56
options.cpp
56
options.cpp
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* QtHP Connect: hand-helds support interface.
|
||||
* Copyright (C) 2019 Ian Gebbie
|
||||
* Code patterns and snippets borrowed from libhpcalcs :
|
||||
* Copyright (C) 1999-2009 Romain Li<EFBFBD>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 "options.h"
|
||||
#include "ui_options.h"
|
||||
#include "global.h"
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
Options::Options(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::Options)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QString path;
|
||||
|
||||
QSettings appSettings("IRGP","QtHPconnect");
|
||||
path=appSettings.value("contentPath").toString();
|
||||
ui->filePath->setText(path);
|
||||
}
|
||||
|
||||
void Options::accept() {
|
||||
|
||||
QString path;
|
||||
path=ui->filePath->text();
|
||||
QSettings appSettings("IRGP","QtHPconnect");
|
||||
appSettings.setValue("contentPath",path);
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void Options::reject() {
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
Options::~Options()
|
||||
{
|
||||
qDebug()<<"~Options()";
|
||||
delete ui;
|
||||
}
|
135
options.ui
135
options.ui
|
@ -1,135 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Options</class>
|
||||
<widget class="QDialog" name="Options">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>440</y>
|
||||
<width>621</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>621</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string extracomment="Set Global Settings"/>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string extracomment="Set Global Settings"/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string extracomment="Set Global Settings"/>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string extracomment="Settings"/>
|
||||
</property>
|
||||
<property name="accessibleDescription">
|
||||
<string extracomment="Global Settings"/>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="filePath">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>40</y>
|
||||
<width>521</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>58</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>141</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Environment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Options</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Options</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -1,6 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>input.txt</file>
|
||||
<file>icons/about_16x16.png</file>
|
||||
<file>icons/about_32x32.png</file>
|
||||
<file>icons/add_background_16x16.png</file>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include <QDebug>
|
||||
#include <QTextCodec>
|
||||
#include <QtMath>
|
||||
#include <QBuffer>
|
||||
#include <math.h>
|
||||
#include <QByteArrayMatcher>
|
||||
#include <QByteArray>
|
||||
|
||||
|
@ -48,6 +50,7 @@ quint8 I2BCD(int num) {
|
|||
|
||||
quint8 ret;
|
||||
int shift =0;
|
||||
ret=0;
|
||||
while (num > 0) {
|
||||
ret |= (num % 10) << (shift++ << 2);
|
||||
num /= 10;
|
||||
|
@ -59,6 +62,23 @@ quint8 I2BCD(int num) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
QString I2BCDS(int num) {
|
||||
|
||||
quint8 ret;
|
||||
QString out=QStringLiteral("OUT");
|
||||
int shift =0;
|
||||
ret=0;
|
||||
while (num > 0) {
|
||||
ret |= (num % 10) << (shift++ << 2);
|
||||
num /= 10;
|
||||
}
|
||||
|
||||
errlog(QString("Num= %1 Ret= %2").arg(num,1,16).arg(ret));
|
||||
|
||||
qDebug()<<QString("Num= %1 Ret= %2").arg(num,1,16).arg(ret);
|
||||
return out;
|
||||
}
|
||||
|
||||
qint32 TwosComplement2Int(quint32 rawValue)
|
||||
{
|
||||
|
||||
|
@ -252,50 +272,96 @@ itemData extract8(QByteArray item) {
|
|||
return listvalue;
|
||||
}
|
||||
|
||||
bool BCD(QDataStream &ds, double real) {
|
||||
|
||||
qint16 out;
|
||||
|
||||
double exp;
|
||||
double base;
|
||||
double mant;
|
||||
exp = real;
|
||||
int i;
|
||||
|
||||
qDebug()<<"BCD from "<<real;
|
||||
QString mants=QStringLiteral("");
|
||||
|
||||
int bcd;
|
||||
int num1;
|
||||
num1=(int)real;
|
||||
|
||||
bcd=I2BCD(num1);
|
||||
|
||||
|
||||
|
||||
double dig;
|
||||
int num;
|
||||
base=mant;
|
||||
for (i=0;i<12;i++) {
|
||||
dig=round(base);
|
||||
num=(int)dig;
|
||||
base=base-dig;
|
||||
base=base *10;
|
||||
ds<<(quint8)num;
|
||||
mants=mants+(quint8)num;
|
||||
double step(double edge, double x) {
|
||||
if ( x < edge ) {
|
||||
return 0.0;
|
||||
}
|
||||
qDebug()<<mants;
|
||||
|
||||
base=exp;
|
||||
for (i=0;i<3;i++) {
|
||||
base=base/10;
|
||||
dig=fmod(base,1)*10;
|
||||
num=(int)dig;
|
||||
base=base-dig;
|
||||
ds<<(quint8)num;
|
||||
else {
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
//I to BCD
|
||||
quint8 BCDi(quint8 in1, quint8 in2) {
|
||||
|
||||
quint8 out = ((in1<<4)&0b11110000) | (in2&0b00001111);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
///Real to BCD
|
||||
bool BCD(QDataStream &ds, double real) {
|
||||
|
||||
double base=0.0;
|
||||
int i;
|
||||
|
||||
qDebug()<<"BCD from "<<real;
|
||||
|
||||
double fractpart, intpart;
|
||||
quint8 num1;
|
||||
quint8 num2;
|
||||
quint8 num;
|
||||
double F = abs(real);
|
||||
double Sign = step(0.0,-real);
|
||||
double Exponent = floor(log10(F));
|
||||
double Mantissa = real/(pow(10,Exponent));
|
||||
|
||||
/*
|
||||
if(Mantissa < 1)
|
||||
Exponent -= 1;
|
||||
Exponent += 127;
|
||||
*/
|
||||
|
||||
qDebug()<<F;
|
||||
qDebug()<<Exponent;
|
||||
qDebug()<<Mantissa;
|
||||
qDebug()<<Sign;
|
||||
qDebug()<<"---";
|
||||
|
||||
base=Mantissa;
|
||||
|
||||
//**TODO --- Reverse Order - LittleEndine
|
||||
|
||||
|
||||
for (i=0;i<6;i++) {
|
||||
fractpart=modf(base,&intpart);
|
||||
num1=(quint8)intpart;
|
||||
base=fractpart*10.0;
|
||||
// num1=i*2;
|
||||
fractpart=modf(base,&intpart);
|
||||
num2=(quint8)intpart;
|
||||
base=fractpart*10.0;
|
||||
// num2=i*2+1;
|
||||
num=BCDi(num1,num2);
|
||||
qDebug()<<"base: "<<base;
|
||||
ds<<(quint8)num;
|
||||
|
||||
qDebug()<<"i= "<<i<<": "<<hex<<num;
|
||||
}
|
||||
|
||||
base=Exponent;
|
||||
for (i=0;i<2;i++) {
|
||||
fractpart=modf(base,&intpart);
|
||||
num1=(quint8)intpart;
|
||||
base=fractpart*10.0;
|
||||
// num1=i*2;
|
||||
fractpart=modf(base,&intpart);
|
||||
num2=(quint8)intpart;
|
||||
base=fractpart*10.0;
|
||||
// num2=i*2+1;
|
||||
num=BCDi(num1,num2);
|
||||
|
||||
qDebug()<<"base: "<<base;
|
||||
ds<<(quint8)num;
|
||||
|
||||
qDebug()<<"i= "<<i<<": "<<hex<<num;
|
||||
}
|
||||
|
||||
// ds<<(quint8)Sign;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////
|
||||
|
@ -930,10 +996,8 @@ void Matrix::setItem(int row, int column, QString string, double value) {
|
|||
|
||||
bool Matrix::getData(QDataStream &ds) {
|
||||
qDebug()<<"Matrix::getData(ds)";
|
||||
// QByteArray out;
|
||||
// out.clear();
|
||||
mdata.dataOut(ds);
|
||||
return true;
|
||||
|
||||
return mdata.dataOut(ds);
|
||||
}
|
||||
|
||||
//Passes the number of entries in the list
|
||||
|
|
|
@ -168,6 +168,8 @@ bool hp_mdiVariableEdit::saveFile(const QFileInfo fileinfo)
|
|||
QDataStream ds(&file);
|
||||
|
||||
ds.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
|
||||
varmodel->getData(ds);
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
#include "eventthread.h"
|
||||
#include "eventtimer.h"
|
||||
|
||||
|
||||
extern QString I2BCDS(int num);
|
||||
|
||||
errorHandler *main_err;
|
||||
#define errlog(a) main_err->error(L7,0,QString(a),QString());
|
||||
|
||||
|
@ -136,6 +139,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(ui->tvContent,SIGNAL(clicked(QModelIndex)),this,SLOT(clickedContent(QModelIndex)));
|
||||
connect(ui->actionLog,SIGNAL(triggered()),this,SLOT(createLogWindow()));
|
||||
connect(ui->actionTest,SIGNAL(triggered()),this,SLOT(testFunction()));
|
||||
connect(ui->actionTestFunction,SIGNAL(triggered()),this,SLOT(testFunction2()));
|
||||
connect(ui->actionTestSettings,SIGNAL(triggered()),this,SLOT(onTestSettings()));
|
||||
connect(ui->actionTestScreen,SIGNAL(triggered()),this,SLOT(onTestScreen()));
|
||||
connect(ui->actionRefresh,SIGNAL(triggered(bool)),this,SLOT(refresh(bool)));
|
||||
|
@ -195,6 +199,20 @@ void MainWindow::testFunction() {
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::testFunction2() {
|
||||
|
||||
hpCalcData * pH;
|
||||
|
||||
int cmd;
|
||||
qDebug()<<"In Test Function 2";
|
||||
|
||||
QString out;
|
||||
cmd = QInputDialog::getInt(this,"Get Command","CMD:",0,0,0xFFFF);
|
||||
out=I2BCDS(cmd);
|
||||
errlog("command is "+QString().sprintf("%x",cmd));
|
||||
qDebug()<<out;
|
||||
}
|
||||
|
||||
treeModel * MainWindow::getTreeModel() {
|
||||
return hpTreeModel;
|
||||
}
|
||||
|
|
|
@ -195,6 +195,7 @@
|
|||
<addaction name="actionTestSettings"/>
|
||||
<addaction name="actionTestScreen"/>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="actionTestFunction"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dwContent">
|
||||
<property name="sizePolicy">
|
||||
|
@ -333,7 +334,7 @@
|
|||
</widget>
|
||||
<action name="actionCut">
|
||||
<property name="icon">
|
||||
<iconset theme="cut" resource="qthpconnect.qrc">
|
||||
<iconset theme="cut" resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/cut_32x32.png</normaloff>:/icons/cut_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -345,7 +346,7 @@
|
|||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="icon">
|
||||
<iconset theme="action_copy" resource="qthpconnect.qrc">
|
||||
<iconset theme="action_copy" resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/copy_32x32.png</normaloff>:/icons/copy_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -357,7 +358,7 @@
|
|||
</action>
|
||||
<action name="actionPaste">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/paste_32x32.png</normaloff>:/icons/paste_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -391,7 +392,7 @@
|
|||
</action>
|
||||
<action name="actionMessages">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/chat_32x32.png</normaloff>:/icons/chat_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -400,7 +401,7 @@
|
|||
</action>
|
||||
<action name="actionMonitor">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/monitor_32x32.png</normaloff>:/icons/monitor_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -409,7 +410,7 @@
|
|||
</action>
|
||||
<action name="actionCalculators">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/calc_tree_32x32.png</normaloff>:/icons/calc_tree_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -418,7 +419,7 @@
|
|||
</action>
|
||||
<action name="actionAbout_HP_Connect">
|
||||
<property name="icon">
|
||||
<iconset theme="about" resource="qthpconnect.qrc">
|
||||
<iconset theme="about" resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/about_32x32.png</normaloff>:/icons/about_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -430,7 +431,7 @@
|
|||
</action>
|
||||
<action name="actionPreferences">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -447,7 +448,7 @@
|
|||
</action>
|
||||
<action name="actionContent">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/content_32x32.png</normaloff>:/icons/content_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -456,7 +457,7 @@
|
|||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/save_32x32.png</normaloff>:/icons/save_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -465,7 +466,7 @@
|
|||
</action>
|
||||
<action name="actionSave_All">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/save_all_32x32.png</normaloff>:/icons/save_all_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -474,7 +475,7 @@
|
|||
</action>
|
||||
<action name="actionCreateNew">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/add_new_32x32.png</normaloff>:/icons/add_new_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -486,7 +487,7 @@
|
|||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/delete_32x32.png</normaloff>:/icons/delete_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -495,7 +496,7 @@
|
|||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/add_icon_32x32.png</normaloff>:/icons/add_icon_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -504,7 +505,7 @@
|
|||
</action>
|
||||
<action name="actionLog">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/note_32x32.png</normaloff>:/icons/note_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -513,7 +514,7 @@
|
|||
</action>
|
||||
<action name="actionTest">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/clone_to_32x32.png</normaloff>:/icons/clone_to_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -525,7 +526,7 @@
|
|||
</action>
|
||||
<action name="actionTreePreference">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -534,7 +535,7 @@
|
|||
</action>
|
||||
<action name="actionTestSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -543,7 +544,7 @@
|
|||
</action>
|
||||
<action name="actionTestScreen">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/add_background_32x32.png</normaloff>:/icons/add_background_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -555,7 +556,7 @@
|
|||
</action>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/refresh_32x32.png</normaloff>:/icons/refresh_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -564,7 +565,7 @@
|
|||
</action>
|
||||
<action name="actionSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/preferences_32x32.png</normaloff>:/icons/preferences_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -669,7 +670,7 @@
|
|||
</action>
|
||||
<action name="actionNewFolder">
|
||||
<property name="icon">
|
||||
<iconset resource="qthpconnect.qrc">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/new_folder_16x16.png</normaloff>:/icons/new_folder_16x16.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
@ -689,10 +690,19 @@
|
|||
<string>New Program</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTestFunction">
|
||||
<property name="icon">
|
||||
<iconset resource="../qthpconnect.qrc">
|
||||
<normaloff>:/icons/vars_32x32.png</normaloff>:/icons/vars_32x32.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TestFunction</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="qthpconnect.qrc"/>
|
||||
<include location="../qthpconnect.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDataStream>
|
||||
#include <QBuffer>
|
||||
#include "matrixdata.h"
|
||||
|
||||
extern bool BCD(QDataStream &ds, double real) ;
|
||||
|
@ -97,29 +99,36 @@ bool MatrixData::dataOut(QDataStream & ds) {
|
|||
QString str;
|
||||
//header
|
||||
|
||||
static const quint8 mydata[] = {0x02, 0x01, 0x04,0x03,0x06,0x05,0x08,0x07};
|
||||
// static const quint8 mydata[] = {0x02, 0x01, 0x04,0x03,0x06,0x05,0x08,0x07};
|
||||
|
||||
QByteArray test= QByteArray::fromRawData((char *)mydata,sizeof (mydata));
|
||||
//QByteArray test= QByteArray::fromRawData((char *)mydata,sizeof (mydata));
|
||||
|
||||
ds<<static_cast<quint16>(0x0001);
|
||||
ds<<static_cast<quint16>(0x8014);
|
||||
ds<<static_cast<quint16>(0x0002);
|
||||
ds<<static_cast<quint16>(0x0000);
|
||||
//QDataStream ds(&test, QIODevice::ReadWrite);
|
||||
|
||||
//ds.writeRawData((char *)mydata,sizeof(mydata));
|
||||
|
||||
|
||||
ds<<(quint16)0x0001;
|
||||
ds<<(quint16)0x8014;
|
||||
ds<<(quint16)0x0002;
|
||||
ds<<(quint16)0x0000;
|
||||
|
||||
ds<<static_cast<quint32>(row);
|
||||
ds<<static_cast<quint32>(column);
|
||||
// ds<<static_cast<quint8>(0x30);
|
||||
// ds<<static_cast<quint8>(0x31);
|
||||
|
||||
// qDebug()<<test;
|
||||
//body
|
||||
double real;
|
||||
QStringList l1;
|
||||
quint8 g;
|
||||
for (i=0;i<row;i++) {
|
||||
for (j=0;j<column;j++) {
|
||||
item=at(i,j);
|
||||
|
||||
real=item.dReal;
|
||||
|
||||
BCD(ds,real);
|
||||
|
||||
|
||||
// if(j!=column)
|
||||
// out.append("");
|
||||
}
|
||||
|
@ -129,6 +138,12 @@ bool MatrixData::dataOut(QDataStream & ds) {
|
|||
|
||||
//footer
|
||||
|
||||
ds.device()->seek(0);
|
||||
ds>>g;
|
||||
qDebug()<<g;
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -282,13 +282,18 @@ QVariant varTableModel::headerData(int section, Qt::Orientation orientation, in
|
|||
|
||||
bool varTableModel::getData(QDataStream &ds) {
|
||||
|
||||
// QByteArray out;
|
||||
// out.clear();
|
||||
QByteArray buf;
|
||||
buf.clear();
|
||||
QDataStream ds_test(&buf, QIODevice::ReadWrite);
|
||||
//buf.open(QIODevice::ReadWrite);
|
||||
ds_test.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
if(dataobj!=nullptr) {
|
||||
dataobj->getData(ds);
|
||||
// out=dataobj->fileOut();
|
||||
// qDebug()<<out;
|
||||
// ds<<out;
|
||||
dataobj->getData(ds_test);
|
||||
|
||||
qDebug()<<"VarTableModel::getData";
|
||||
qDebug()<<"Out:"<<buf.toHex();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
165
texteditor.cpp
165
texteditor.cpp
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
|
||||
* Copyright (c) 2020 Ian Gebbie.
|
||||
*
|
||||
* 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, version 3 or later.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "texteditor.h"
|
||||
#include <QtWidgets>
|
||||
#include <QRect>
|
||||
#include <QSettings>
|
||||
|
||||
textEditor::textEditor(QWidget *parent) :
|
||||
QTextEdit(parent)
|
||||
{
|
||||
QSettings appSettings("IRGP","QtHPconnect");
|
||||
wParent = parent;
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
// setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
||||
isUntitled = true;
|
||||
|
||||
defaultPath=QDir(appSettings.value("contentPath").toString());
|
||||
qDebug()<<defaultPath;
|
||||
}
|
||||
|
||||
/*
|
||||
void textEditor::newFile()
|
||||
{
|
||||
static int sequenceNumber = 1;
|
||||
|
||||
isUntitled = true;
|
||||
curFile = tr("document%1.txt").arg(sequenceNumber++);
|
||||
setWindowTitle(curFile + "[*]");
|
||||
|
||||
connect(document(), &QTextDocument::contentsChanged,
|
||||
this, &textEditor::documentWasModified);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
bool textEditor::loadFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QMessageBox::warning(this, tr("MDI"),
|
||||
tr("Cannot read file %1:\n%2.")
|
||||
.arg(fileName)
|
||||
.arg(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream in(&file);
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
setPlainText(in.readAll());
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
setCurrentFile(fileName);
|
||||
|
||||
connect(document(), &QTextDocument::contentsChanged,
|
||||
this, &textEditor::documentWasModified);
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool textEditor::save(QString Calculator)
|
||||
{
|
||||
if (isUntitled) {
|
||||
return saveAs(Calculator);
|
||||
} else {
|
||||
return saveFile(curFile);
|
||||
}
|
||||
}
|
||||
|
||||
bool textEditor::save(QFileInfo file)
|
||||
{
|
||||
if (isUntitled) {
|
||||
return saveAs(file);
|
||||
} else {
|
||||
return saveFile(curFile);
|
||||
}
|
||||
}
|
||||
|
||||
bool textEditor::saveAs(QFileInfo fileinfo)
|
||||
{
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
|
||||
fileinfo.absoluteFilePath());
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
|
||||
return saveFile(fileName);
|
||||
}
|
||||
|
||||
|
||||
bool textEditor::saveAs(QString calculaor)
|
||||
{
|
||||
|
||||
// QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
|
||||
// fileinfo.absoluteFilePath());
|
||||
QString fileName=curFile;
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
|
||||
return saveFile(fileName);
|
||||
}
|
||||
|
||||
bool textEditor::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;
|
||||
}
|
||||
|
||||
QString textEditor::userFriendlyCurrentFile()
|
||||
{
|
||||
return strippedName(curFile);
|
||||
}
|
||||
|
||||
void textEditor::documentWasModified()
|
||||
{
|
||||
setWindowModified(document()->isModified());
|
||||
}
|
||||
|
||||
void textEditor::setCurrentFile(const QString &fileName)
|
||||
{
|
||||
curFile = QFileInfo(fileName).canonicalFilePath();
|
||||
isUntitled = false;
|
||||
document()->setModified(false);
|
||||
setWindowModified(false);
|
||||
setWindowTitle(userFriendlyCurrentFile() + "[*]");
|
||||
}
|
||||
|
||||
QString textEditor::strippedName(const QString &fullFileName)
|
||||
{
|
||||
return QFileInfo(fullFileName).fileName();
|
||||
}
|
||||
|
||||
textEditor::~textEditor() {
|
||||
qDebug()<<"textEditor:: delete";
|
||||
}
|
607
treemodel.cpp
607
treemodel.cpp
|
@ -1,607 +0,0 @@
|
|||
/*
|
||||
* QtHP Connect: hand-helds support interface.
|
||||
* Copyright (C) 2019 Ian Gebbie
|
||||
* Code patterns and snippets borrowed from libhpcalcs :
|
||||
* Copyright (C) 1999-2009 Romain Li<EFBFBD>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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Model to contain the calculator data structure
|
||||
//
|
||||
|
||||
#include "treemodel.h"
|
||||
#include "hptreeitem.h"
|
||||
#include <hp_infodialog.h>
|
||||
#include <hp_mdivariableedit.h>
|
||||
#include <hp_mditexteditor.h>
|
||||
#include <QStringListModel>
|
||||
#include <QMimeData>
|
||||
|
||||
|
||||
//Constructor
|
||||
treeModel::treeModel(QObject *parent)
|
||||
:QStandardItemModel(parent)
|
||||
{
|
||||
setItemPrototype(new hpTreeItem());
|
||||
createRoot();
|
||||
setParent(parent);
|
||||
}
|
||||
|
||||
//Create the start of the tree
|
||||
int treeModel::createRoot()
|
||||
{
|
||||
rootNode = invisibleRootItem();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Create Item
|
||||
AbstractData * treeModel::createData(hp_Data data_in) {
|
||||
|
||||
AbstractData * obj=nullptr;
|
||||
errlog("TreeModel::Creating Data Stucture");
|
||||
|
||||
switch (data_in.type) {
|
||||
case HP_APP: {
|
||||
qDebug()<<"hpCalcData::recvData - Application";
|
||||
Application * obj = new Application(data_in.name,data_in.type);
|
||||
return obj;
|
||||
}
|
||||
break;
|
||||
case HP_LIST: {
|
||||
List * obj = new List(data_in.name,data_in.type);
|
||||
return obj;
|
||||
}
|
||||
break;
|
||||
case HP_MATRIX: {
|
||||
qDebug()<<"hpCalcData::recvData - Matrix";
|
||||
Matrix * obj = new Matrix(data_in.name,data_in.type);
|
||||
return obj;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
//Rework - name should be calc name
|
||||
int treeModel::addCalculator(QString name, hpusb * handle){
|
||||
|
||||
hpCalcData * hpData = new hpCalcData(name, handle);
|
||||
hpTreeItem * hpCalc = new hpTreeItem(name,hpData,0);
|
||||
hpCalc->setType(HP_MAIN);
|
||||
hpCalc->setIcon(QIcon(":/icons/monitor_32x32.png"));
|
||||
hpCalc->setToolTip(QString("Calculator contents"));
|
||||
QObject::connect(hpData, SIGNAL(dataChanged(hp_Change)),hpCalc, SLOT(dataChange(hp_Change)));
|
||||
if (parent()!=nullptr)
|
||||
QObject::connect(hpData, SIGNAL(dataChanged(hp_Change)),parent(), SLOT(dataChange(hp_Change)));
|
||||
setHpCalcData(name,hpData,hpCalc);
|
||||
rootNode->appendRow(hpCalc);
|
||||
hpData->readInfo();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//return the calculator data within the model
|
||||
hpCalcData * treeModel::getCalculator(QString name){
|
||||
|
||||
hpDataLink hplink;
|
||||
hpCalcData * hpdata = nullptr;
|
||||
|
||||
if (!hpCalcList.isEmpty()) {
|
||||
QMap<QString, hpDataLink>::const_iterator i = hpCalcList.find(name);
|
||||
|
||||
if (i!=hpCalcList.end()) {
|
||||
hplink = i.value();
|
||||
hpdata= hplink.dataItem;
|
||||
}
|
||||
}
|
||||
return hpdata;
|
||||
}
|
||||
|
||||
void treeModel::clickAction(QMdiArea * mdiwin,QModelIndex &index) {
|
||||
|
||||
qDebug()<<"row "<<index.row()<<" column "<<index.column();
|
||||
return openFile(mdiwin,index);
|
||||
}
|
||||
|
||||
void treeModel::openFile(QMdiArea * mdiwin, QModelIndex &index) {
|
||||
|
||||
qDebug()<<"treeModel::openFile";
|
||||
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)) {
|
||||
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) {
|
||||
|
||||
qDebug()<<"treeModel::renameFile";
|
||||
|
||||
AbstractData * adata=nullptr;
|
||||
hpTreeItem * item=nullptr;
|
||||
QString calc;
|
||||
QString name;
|
||||
hp_DataType type;
|
||||
hpCalcData * hpdata=nullptr;
|
||||
|
||||
qDebug()<<"row "<<index.row()<<" column "<<index.column();
|
||||
if (index.isValid()) {
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
|
||||
if (item!=nullptr) {
|
||||
|
||||
calc=item->getCalculatorName();
|
||||
name=item->getFileName();
|
||||
qDebug()<<name;
|
||||
type=item->getType();
|
||||
hpdata=getHpCalcData(calc);
|
||||
if (hpdata!=nullptr) {
|
||||
adata=hpdata->getData(name,type);
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeModel::renameFile hpdata is null";
|
||||
}
|
||||
|
||||
//
|
||||
item->setFileName(newName);
|
||||
adata->setName(newName);
|
||||
|
||||
//
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Null data";
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeModel::renameFile invalid index";
|
||||
}
|
||||
}
|
||||
|
||||
void treeModel::deleteFile( QModelIndex &index) {
|
||||
|
||||
qDebug()<<"treeModel::deleteFile";
|
||||
AbstractData * adata=nullptr;
|
||||
hpTreeItem * item=nullptr;
|
||||
QString calc;
|
||||
QString name;
|
||||
hp_DataType type;
|
||||
hpCalcData * hpdata=nullptr;
|
||||
|
||||
if (index.isValid()) {
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
|
||||
if (item!=nullptr) {
|
||||
|
||||
calc=item->getCalculatorName();
|
||||
name=item->getFileName();
|
||||
qDebug()<<name;
|
||||
type=item->getType();
|
||||
hpdata=getHpCalcData(calc);
|
||||
if (hpdata!=nullptr) {
|
||||
adata=hpdata->getData(name,type);
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeMoel::deletFile hpdata is null";
|
||||
}
|
||||
|
||||
//
|
||||
//delete hpTreeItem
|
||||
// qDebug()<<"row "<<index.row()<<" column "<<index.column();
|
||||
if (removeRow(index.row(),index.parent()))
|
||||
{
|
||||
//qDebug()<<"Deleted";
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Removal failed";
|
||||
}
|
||||
|
||||
//delete Data
|
||||
hpdata->deleteData(adata);
|
||||
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Null data";
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeMoel::deleteFile invalid index";
|
||||
}
|
||||
}
|
||||
|
||||
//return the calculator data within the model
|
||||
hpTreeItem * treeModel::getCalculatorItem(QString name){
|
||||
|
||||
hpDataLink hplink;
|
||||
hpTreeItem * hpitem = nullptr;
|
||||
|
||||
if (!hpCalcList.isEmpty()) {
|
||||
QMap<QString, hpDataLink>::const_iterator i = hpCalcList.find(name);
|
||||
|
||||
if (i!=hpCalcList.end()) {
|
||||
hplink = i.value();
|
||||
hpitem= hplink.treeItem;
|
||||
}
|
||||
}
|
||||
return hpitem;
|
||||
}
|
||||
|
||||
//index system for data retrieval
|
||||
//review QStandardItemModel should already have one in place
|
||||
QString treeModel::getLastDataKey() {
|
||||
if (hpCalcList.isEmpty())
|
||||
return QStringLiteral("");
|
||||
else
|
||||
return hpCalcList.lastKey();
|
||||
}
|
||||
|
||||
//manage link between tree and data
|
||||
//A map stores the treeItem, dataItem and in future perhaps the handle in a list
|
||||
// retrievable by a string key
|
||||
hpCalcData * treeModel::getHpCalcData(QString name) const {
|
||||
|
||||
hpDataLink hplink;
|
||||
hpCalcData * hpdata=nullptr;
|
||||
|
||||
if (!hpCalcList.isEmpty()) {
|
||||
QMap<QString, hpDataLink>::const_iterator i = hpCalcList.find(name);
|
||||
|
||||
if (i!=hpCalcList.end()) {
|
||||
hplink = i.value();
|
||||
hpdata= hplink.dataItem;
|
||||
}
|
||||
}
|
||||
return hpdata;
|
||||
}
|
||||
|
||||
//manage link between tree and data
|
||||
void treeModel::setHpCalcData(QString name, hpCalcData * data, hpTreeItem * tree ){
|
||||
|
||||
hpDataLink hplink;
|
||||
hplink.dataItem=data;
|
||||
hplink.treeItem=tree;
|
||||
hpCalcList.insert(name,hplink);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Part the the drag and drop system
|
||||
Qt::DropActions treeModel::supportedDropActions() const
|
||||
{
|
||||
return Qt::CopyAction | Qt::MoveAction | Qt::TargetMoveAction;
|
||||
}
|
||||
|
||||
QString treeModel::getName(QModelIndex index) const {
|
||||
|
||||
QString calc;
|
||||
QString name=QStringLiteral("None");
|
||||
hpTreeItem * item=nullptr;
|
||||
if (index.isValid()) {
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
if (item!=nullptr) {
|
||||
calc=item->getCalculatorName();
|
||||
name=item->getFileName();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Return the data object belonging to an item
|
||||
AbstractData * treeModel::getData(QModelIndex index) const {
|
||||
|
||||
AbstractData * adata=nullptr;
|
||||
QString calc;
|
||||
QString name;
|
||||
hp_DataType type;
|
||||
hpTreeItem * item=nullptr;
|
||||
hpCalcData * hpdata=nullptr;
|
||||
if (index.isValid()) {
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
if (item!=nullptr) {
|
||||
calc=item->getCalculatorName();
|
||||
name=item->getFileName();
|
||||
qDebug()<<name;
|
||||
type=item->getType();
|
||||
hpdata=getHpCalcData(calc);
|
||||
if (hpdata!=nullptr) {
|
||||
adata=hpdata->getData(name,type);
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeMoel::getData hpdata is null";
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeMoel::getData item is null";
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeMoel::getData invalid index";
|
||||
}
|
||||
return adata;
|
||||
}
|
||||
|
||||
|
||||
//Get and pass on the data to be dragged
|
||||
QMimeData* treeModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
|
||||
QMimeData *mimeDataPtr = new QMimeData();
|
||||
AbstractData * adata = nullptr;
|
||||
QByteArray mydata;
|
||||
QByteArray datatype;
|
||||
QModelIndex index;
|
||||
|
||||
qDebug()<<"treeModel::mimeData";
|
||||
|
||||
for(int i =0; i<indexes.count(); i++)
|
||||
{
|
||||
index = indexes.at(i);
|
||||
adata = getData(index);
|
||||
if (adata!=nullptr) {
|
||||
qDebug()<<"Data "<<adata->getType();
|
||||
mydata = adata->getData();
|
||||
mimeDataPtr->setText(adata->getName());
|
||||
datatype[0] = adata->getType();
|
||||
mimeDataPtr->setData("application/x-type",datatype);
|
||||
mimeDataPtr->setData("application/x-qabstractmodeldatalist",mydata);
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeModel::mimeData No Data";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mimeDataPtr;
|
||||
}
|
||||
|
||||
//Allow drop in location
|
||||
bool treeModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//Process the drop action
|
||||
bool treeModel::dropMimeData(const QMimeData* md_data, Qt::DropAction action, int row,
|
||||
int column, const QModelIndex &index)
|
||||
{
|
||||
QByteArray data_in;
|
||||
AbstractData * absitem;
|
||||
|
||||
qDebug()<<"treemodel::DropMineData "<<row<<" "<<column;
|
||||
if (action == Qt::IgnoreAction) {
|
||||
qDebug()<<"treemodel::IgnoreAction";
|
||||
return true;
|
||||
}
|
||||
|
||||
hpTreeItem * item=nullptr;
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
if (item!=nullptr) {
|
||||
hp_DataType type=HP_MAIN;
|
||||
QStringList formatList;
|
||||
QString mimeType;
|
||||
formatList=md_data->formats();
|
||||
|
||||
foreach(const QString& format, formatList) {
|
||||
qDebug()<<format;
|
||||
for(int i = HP_MAIN; i < HP_SETTINGS; i++) {
|
||||
mimeType=mimetypes[i][1];
|
||||
qDebug()<<mimeType;
|
||||
if( mimeType==format) {
|
||||
type=static_cast<hp_DataType>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( type!=HP_MAIN) {
|
||||
QString name=md_data->text();
|
||||
data_in=md_data->data(mimetypes[type][1]);
|
||||
|
||||
QDataStream in(&data_in,QIODevice::ReadOnly);
|
||||
|
||||
qDebug()<<"Type="<<type;
|
||||
switch(type) {
|
||||
case HP_NOTE: {
|
||||
absitem = new Notes(name, HP_NOTE,QStringLiteral(""));
|
||||
absitem->parseData(in);
|
||||
break;
|
||||
}
|
||||
case HP_LIST: {
|
||||
absitem = new List(name, HP_LIST);
|
||||
absitem->parseData(in);
|
||||
break;
|
||||
}
|
||||
case HP_MATRIX: {
|
||||
absitem = new Matrix(name, HP_MATRIX);
|
||||
absitem->parseData(in);
|
||||
break;
|
||||
}
|
||||
case HP_PROG: {
|
||||
absitem = new Program(name, HP_PROG, QStringLiteral(""));
|
||||
absitem->parseData(in);
|
||||
break;
|
||||
}
|
||||
case HP_VAR: {
|
||||
absitem = new Variables(name, HP_VAR);
|
||||
absitem->parseData(in);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString calc = item->getCalculatorName();
|
||||
addItem(calc,absitem);
|
||||
|
||||
// qDebug()<<"treemodel::dropMimeData End";
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treemodel::sropMimeData type not found "<<type;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Find the hpTreeItem of a type in a calculator
|
||||
hpTreeItem * treeModel::findTypeRoot(QString calcName, hp_DataType type) {
|
||||
|
||||
qDebug()<<calcName;
|
||||
hpTreeItem * calc=getCalculatorItem(calcName);
|
||||
hpTreeItem *item;
|
||||
|
||||
// qDebug()<<calc->getGroupName();
|
||||
|
||||
QModelIndex in = calc->index();
|
||||
|
||||
for (int e = 0; e<calc->rowCount(); e++) {
|
||||
QModelIndex si=index(e,0,in);
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(si));
|
||||
if(item->getType()==type) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
//add an object to the correct place in the tree of a calaculator
|
||||
int treeModel::addItem(QString calc, AbstractData * obj) {
|
||||
|
||||
hp_DataType type;
|
||||
hpCalcData * hpdata;
|
||||
|
||||
if (obj!=nullptr) {
|
||||
type = obj->getType();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
hpTreeItem * rootitem = findTypeRoot(calc,type);
|
||||
|
||||
if(rootitem!=nullptr) {
|
||||
hpdata=rootitem->getDataStore();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
rootitem->addChild(obj);
|
||||
hpdata->addData(obj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int treeModel::deleteItem(hpCalcData* hpcalc, AbstractData * obj) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags treeModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QStandardItemModel::flags(index);
|
||||
|
||||
if (index.isValid())
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
|
||||
else
|
||||
return Qt::ItemIsDropEnabled | defaultFlags;
|
||||
}
|
||||
|
||||
int deletCalculator(QString name, hpusb * handle) {
|
||||
|
||||
}
|
||||
|
||||
int treeModel::deleteAllCalculators() {
|
||||
|
||||
hpDataLink hplink;
|
||||
hpCalcData * hpdata = nullptr;
|
||||
|
||||
foreach(QString key, hpCalcList.keys()) {
|
||||
|
||||
QMap<QString, hpDataLink>::const_iterator i = hpCalcList.find(key);
|
||||
hplink=i.value();
|
||||
delete(hplink.dataItem);
|
||||
hpCalcList.remove(key);
|
||||
}
|
||||
hpCalcList.clear();
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
treeModel::~treeModel() {
|
||||
|
||||
deleteAllCalculators();
|
||||
|
||||
qDebug()<<"treeModel:: delete";
|
||||
}
|
||||
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* QtHP Connect: hand-helds support interface.
|
||||
* Copyright (C) 2019 Ian Gebbie
|
||||
* Code patterns and snippets borrowed from libhpcalcs :
|
||||
* Copyright (C) 1999-2009 Romain Li<EFBFBD>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 "variableview.h"
|
||||
#include "ui_variableview.h"
|
||||
#include <QDebug>
|
||||
|
||||
variableView::variableView(QWidget *)
|
||||
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
variableView::~variableView()
|
||||
{
|
||||
qDebug()<<"delete variableView";
|
||||
delete ui;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>variableView</class>
|
||||
<widget class="QWidget" name="variableView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>347</width>
|
||||
<height>358</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="variableList">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,348 +0,0 @@
|
|||
/*
|
||||
* QtHP Connect: hand-helds support interface.
|
||||
* Copyright (C) 2019 Ian Gebbie
|
||||
* Code patterns and snippets borrowed from libhpcalcs :
|
||||
* Copyright (C) 1999-2009 Romain Li<EFBFBD>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 <QMessageBox>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
|
||||
#include "global.h"
|
||||
#include "vartablemodel.h"
|
||||
|
||||
const QStringList varTableModel::real_header={ "A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"I",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"M",
|
||||
"N",
|
||||
"o",
|
||||
"P",
|
||||
"Q",
|
||||
"R",
|
||||
"S",
|
||||
"T",
|
||||
"U",
|
||||
"V",
|
||||
"W",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"THETA"
|
||||
};
|
||||
|
||||
const QStringList varTableModel::complex_header={ "Z0",
|
||||
"Z1",
|
||||
"Z2",
|
||||
"Z3",
|
||||
"Z4",
|
||||
"Z5",
|
||||
"Z6",
|
||||
"Z7",
|
||||
"Z8",
|
||||
"Z9"
|
||||
};
|
||||
|
||||
varTableModel::varTableModel(QObject *parent,
|
||||
AbstractData * data,
|
||||
QString file,
|
||||
hp_DataType dtype)
|
||||
:QAbstractTableModel(parent)
|
||||
{
|
||||
q_parent=parent;
|
||||
dataobj = data;
|
||||
filename=file;
|
||||
type=dtype;
|
||||
setup();
|
||||
}
|
||||
|
||||
//REWORK!
|
||||
QModelIndex varTableModel::parent(const QModelIndex &index) const {
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
Qt::ItemFlags varTableModel::flags(const QModelIndex &index) const {
|
||||
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
//rework!
|
||||
QModelIndex varTableModel::index(int row, int column, const QModelIndex &parent) const {
|
||||
|
||||
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()
|
||||
{
|
||||
// if (hpcalc) {
|
||||
|
||||
// dataobj=hpcalc->getData(filename,type);
|
||||
|
||||
// qDebug()<<"varTableModel: type"<<dataobj->getType();
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int varTableModel::rowCount(const QModelIndex & parent) const
|
||||
{
|
||||
int size=16; //should be zero
|
||||
if (type==HP_LIST) {
|
||||
List * list;
|
||||
list = static_cast<List *>(dataobj);
|
||||
size= list->getListSize()+1;
|
||||
}
|
||||
if (type==HP_REAL) {
|
||||
Real * real;
|
||||
real = static_cast<Real *>(dataobj);
|
||||
size= real->getListSize();
|
||||
}
|
||||
if (type==HP_COMPLEX) {
|
||||
Complex * complex;
|
||||
complex = static_cast<Complex *>(dataobj);
|
||||
size= complex->getListSize();
|
||||
}
|
||||
if (type==HP_MATRIX) {
|
||||
Matrix * matrix;
|
||||
matrix = static_cast<Matrix *>(dataobj);
|
||||
size= matrix->getMatrixRows()+1;
|
||||
// qDebug()<<matrix->getName()<<" row"<<size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int varTableModel::columnCount(const QModelIndex & /*parent*/) const
|
||||
{
|
||||
int size=1;
|
||||
if (type==HP_MATRIX) {
|
||||
Matrix * matrix;
|
||||
matrix = static_cast<Matrix *>(dataobj);
|
||||
size= matrix->getMatrixColumns()+1;
|
||||
// qDebug()<<matrix->getName()<<" column"<<size;
|
||||
|
||||
}
|
||||
if (type==HP_COMPLEX) {
|
||||
Complex * complex;
|
||||
complex = static_cast<Complex *>(dataobj);
|
||||
// size= matrix->getMatrixColumns();
|
||||
// qDebug()<<matrix->getName()<<" column"<<size;
|
||||
return 1;
|
||||
}
|
||||
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
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
||||
QString item=QStringLiteral("-");
|
||||
|
||||
if (type==HP_LIST) {
|
||||
List * list;
|
||||
list = static_cast<List *>(dataobj);
|
||||
item = list->getItem(index.row());
|
||||
return item;
|
||||
}
|
||||
if (type==HP_MATRIX) {
|
||||
Matrix * matrix;
|
||||
matrix = static_cast<Matrix *>(dataobj);
|
||||
item = matrix->getItem(index.row(),index.column());
|
||||
return item;
|
||||
}
|
||||
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 QString("Row%1, Column%2")
|
||||
.arg(index.row() + 1)
|
||||
.arg(index.column() +1);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant varTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (orientation == Qt::Horizontal) {
|
||||
if (type==HP_REAL) {
|
||||
return QString("%1").arg(section+1);
|
||||
}
|
||||
return QString("%1").arg(section+1);
|
||||
|
||||
}
|
||||
if (orientation == Qt::Vertical) {
|
||||
if (type==HP_REAL) {
|
||||
if (section < real_header.size()) {
|
||||
return real_header.at(section);
|
||||
}
|
||||
else {
|
||||
return QString("%1").arg(section);
|
||||
}
|
||||
}
|
||||
|
||||
if (type==HP_COMPLEX) {
|
||||
if (section < complex_header.size()) {
|
||||
return complex_header.at(section);
|
||||
}
|
||||
else {
|
||||
return QString("%1").arg(section);
|
||||
}
|
||||
}
|
||||
|
||||
return QString("%1").arg(section);
|
||||
}
|
||||
|
||||
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() {
|
||||
qDebug()<<"Entering ~varTableModel()";
|
||||
}
|
Loading…
Reference in a new issue