mirror of
https://github.com/Indy970/QtHPConnect
synced 2025-02-05 08:46:22 +01:00
Menu Functionality
This commit is contained in:
parent
85ab7a3ace
commit
ffa75742b6
12 changed files with 843 additions and 104 deletions
|
@ -225,9 +225,10 @@ itemData extract8(QByteArray item) {
|
|||
AbstractData::AbstractData(QString name_in, hp_DataType type_in)
|
||||
{
|
||||
|
||||
// qDebug()<<"base class called "<<name_in;
|
||||
qDebug()<<"base class called "<<name_in;
|
||||
setName(name_in);
|
||||
setType(type_in);
|
||||
|
||||
}
|
||||
|
||||
//Equivalence on name and type NOT on data
|
||||
|
@ -293,8 +294,23 @@ void AbstractData::parseData() {
|
|||
qDebug()<<"AbstractData::parseData";
|
||||
}
|
||||
|
||||
void AbstractData::parseData(QDataStream& ) {
|
||||
qDebug()<<"AbstractData::parseData";
|
||||
void AbstractData::parseData(QDataStream& in) {
|
||||
qDebug()<<"AbstractData::parseData(DS)";
|
||||
|
||||
in.setByteOrder(QDataStream::LittleEndian);
|
||||
qint8 c;
|
||||
QByteArray a1;
|
||||
uint length;
|
||||
length=16;
|
||||
|
||||
qDebug()<<"Parsing Matrix";
|
||||
in.startTransaction();
|
||||
while(!in.atEnd()) {
|
||||
in>>c;
|
||||
a1.append(c);
|
||||
}
|
||||
data = a1;
|
||||
parseData();
|
||||
}
|
||||
|
||||
AbstractData::~AbstractData() {
|
||||
|
@ -681,10 +697,29 @@ int List::getListSize() {
|
|||
|
||||
Matrix::Matrix(QString name_in, hp_DataType type_in):
|
||||
AbstractData(name_in, type_in) {
|
||||
|
||||
qDebug()<<"Create Matrix";
|
||||
setFileCode(HP_TP_MATRIX);
|
||||
}
|
||||
|
||||
void Matrix::parseData(QDataStream & in) {
|
||||
|
||||
in.setByteOrder(QDataStream::LittleEndian);
|
||||
qint8 c;
|
||||
QByteArray a1;
|
||||
uint length;
|
||||
length=16;
|
||||
|
||||
qDebug()<<"Parsing Matrix";
|
||||
in.startTransaction();
|
||||
while(!in.atEnd()) {
|
||||
in>>c;
|
||||
a1.append(c);
|
||||
}
|
||||
data = a1;
|
||||
parseData();
|
||||
}
|
||||
|
||||
|
||||
void Matrix::parseData() {
|
||||
|
||||
QByteArray a1;
|
||||
|
|
|
@ -103,11 +103,12 @@ class Matrix: public AbstractData
|
|||
{
|
||||
private:
|
||||
MatrixData mdata;
|
||||
void parseData();
|
||||
public:
|
||||
Matrix(QString, hp_DataType);
|
||||
itemData getListItem(int row, int column);
|
||||
void setListItem(int, int, itemData);
|
||||
void parseData();
|
||||
virtual void parseData(QDataStream& in);
|
||||
QString getItem(int row, int column);
|
||||
void setItem(int, int, QString);
|
||||
void setItem(int, int, QString, double);
|
||||
|
@ -136,11 +137,12 @@ class Notes: public AbstractData
|
|||
private:
|
||||
QString text;
|
||||
QString format;
|
||||
void parseData();
|
||||
|
||||
public:
|
||||
Notes(QString, hp_DataType, QString);
|
||||
void setNote(QString);
|
||||
QString getNote();
|
||||
void parseData();
|
||||
};
|
||||
|
||||
class Variables: public AbstractData
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#include "global.h"
|
||||
#include "cntfilesystemmodel.h"
|
||||
#include <global.h>
|
||||
#include <cntfilesystemmodel.h>
|
||||
#include <QMimeData>
|
||||
#include <QStringListModel>
|
||||
#include "hp_mditexteditor.h"
|
||||
|
||||
#include <hp_mditexteditor.h>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include <utility>
|
||||
#define FILE_NUM 9
|
||||
#define FILE_TYPE 5
|
||||
|
||||
|
||||
//Todo fix for all file types
|
||||
const QString contentFileSystemModel::filetype_list[FILE_NUM][2]={{"hpprgm",":/icons/apps_16x16.png"},
|
||||
|
@ -26,12 +28,22 @@ const hp_DataType contentFileSystemModel::func_type[FILE_TYPE]={
|
|||
HP_NOTE,
|
||||
HP_MAIN};
|
||||
|
||||
const QString contentFileSystemModel::file_type[FILE_TYPE]={"hpprgm",
|
||||
/*
|
||||
const std::array<std::pair<hp_DataType,QString>,FILE_TYPE> contentFileSystemModel::file_type{ {0,"hpprgm"},
|
||||
{1,"hplist"},
|
||||
{2,"hpmat"},
|
||||
{3,"hpnote"},
|
||||
{4,""}};
|
||||
*/
|
||||
|
||||
const QString contentFileSystemModel::file_type[FILE_TYPE]{ "hpprgm",
|
||||
"hplist",
|
||||
"hpmat",
|
||||
"hpnote",
|
||||
""};
|
||||
//condtrutor
|
||||
""};
|
||||
|
||||
|
||||
//condstrutor
|
||||
contentFileSystemModel::contentFileSystemModel(QObject * parent)
|
||||
:QFileSystemModel(parent)
|
||||
{
|
||||
|
@ -58,7 +70,7 @@ QMimeData* contentFileSystemModel::mimeData(const QModelIndexList &indexes) cons
|
|||
|
||||
qDebug()<<info.absoluteFilePath();
|
||||
|
||||
if (file.open(QIODevice::ReadOnly), QFileDevice::AutoCloseHandle) {
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QDataStream in(&file);
|
||||
|
||||
filedata=getFileType(info);
|
||||
|
@ -72,25 +84,25 @@ QMimeData* contentFileSystemModel::mimeData(const QModelIndexList &indexes) cons
|
|||
in>>c;
|
||||
mydata.append(c);
|
||||
}
|
||||
mimeDataPtr->setText(info.baseName());
|
||||
|
||||
switch (filedata.type) {
|
||||
|
||||
case HP_PROG: {
|
||||
qDebug()<<"HP_PROG Found";
|
||||
mimeDataPtr->setText(info.baseName());
|
||||
mimeDataPtr->setData(mimetypes[HP_PROG][1],mydata);
|
||||
break;
|
||||
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_APP: {
|
||||
qDebug()<<"HP_APP Found";
|
||||
mimeDataPtr->setText(info.baseName());
|
||||
mimeDataPtr->setData(mimetypes[HP_APP][1],mydata);
|
||||
break;
|
||||
}
|
||||
case HP_MATRIX: {
|
||||
qDebug()<<"HP_MATRIX Found";
|
||||
mimeDataPtr->setData("application/x-matrix",mydata);
|
||||
break;
|
||||
case HP_CAS:
|
||||
case HP_MAIN:
|
||||
case HP_COMPLEX:
|
||||
case HP_SCREEN:
|
||||
case HP_REAL: {
|
||||
// no action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,49 +136,55 @@ bool contentFileSystemModel::canDropMimeData(const QMimeData *data, Qt::DropActi
|
|||
}
|
||||
|
||||
//Process the drop action
|
||||
bool contentFileSystemModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row,
|
||||
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()) {
|
||||
qDebug()<<"Content Path Does not Exist:"<<path;
|
||||
if(!dir.mkpath("."))
|
||||
{
|
||||
qDebug()<<"Path could not be created"<<path;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == Qt::IgnoreAction) {
|
||||
qDebug()<<"contentFileSystemModel::QT::ignoreAction";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (column > 1) {
|
||||
qDebug()<<"contentFileSystemModel::column>1";
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
|
||||
int position;
|
||||
qDebug()<<data_in;
|
||||
qDebug()<<fileinfo;
|
||||
|
||||
if (row != -1) {
|
||||
position = row;
|
||||
} else if (parent.isValid()) {
|
||||
position = parent.row();
|
||||
} else {
|
||||
position = rowCount(QModelIndex());
|
||||
}
|
||||
|
||||
// QByteArray encodedData = data->data("application/text.list");
|
||||
// QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
/* Retrieve row id */
|
||||
QList<int> rowIdList;
|
||||
// while (!stream.atEnd()) {
|
||||
// QString text;
|
||||
// stream >> text;
|
||||
// rowIdList << text.toInt();
|
||||
// }
|
||||
|
||||
/* Insert rows (one by one) */
|
||||
// foreach(int rowId, rowIdList) {
|
||||
// insertRow(position, parent, rowId);
|
||||
// }
|
||||
|
||||
|
||||
qDebug()<<"contentFileSystemModel::dropMineData end";
|
||||
return true;
|
||||
if (writeFile(fileinfo,data_in)>-1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant contentFileSystemModel::data( const QModelIndex &index, int role ) const {
|
||||
|
@ -191,31 +209,18 @@ QVariant contentFileSystemModel::data( const QModelIndex &index, int role ) cons
|
|||
}
|
||||
|
||||
void contentFileSystemModel::clickAction(QMdiArea * mdiwin, QModelIndex &index) {
|
||||
return openFile(mdiwin,index);
|
||||
}
|
||||
|
||||
void contentFileSystemModel::openFile(QMdiArea * mdiwin, QModelIndex &index) {
|
||||
|
||||
hp_mdiTextEdit * hptextedit = nullptr;
|
||||
hp_DataStruct filedata;
|
||||
AbstractData * data=nullptr;
|
||||
|
||||
QFileInfo info = contentFileSystemModel::fileInfo(index);
|
||||
/*
|
||||
if (file.open(QIODevice::ReadOnly),QFileDevice::AutoCloseHandle) {
|
||||
QDataStream in(&file);
|
||||
|
||||
filedata=getFileType(info);
|
||||
|
||||
switch (filedata.type) {
|
||||
|
||||
case HP_PROG: {
|
||||
|
||||
data = new Program(filedata.filename, HP_PROG, QStringLiteral(""));
|
||||
data->parseData(in);
|
||||
}
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
*/
|
||||
|
||||
data = readFile(info);
|
||||
data = readFile(info);
|
||||
|
||||
if (data!=nullptr) {
|
||||
if (hptextedit==nullptr)
|
||||
|
@ -227,6 +232,23 @@ void contentFileSystemModel::clickAction(QMdiArea * mdiwin, QModelIndex &index)
|
|||
qDebug()<<"Null data";
|
||||
}
|
||||
qDebug()<<"ClickAction "<<info.absoluteFilePath();
|
||||
|
||||
}
|
||||
|
||||
void contentFileSystemModel::deleteFile(QModelIndex &index) {
|
||||
QFileInfo fileinfo = contentFileSystemModel::fileInfo(index);
|
||||
qDebug()<<"deleteFile "<<fileinfo.absoluteFilePath();
|
||||
QFile file(fileinfo.absoluteFilePath());
|
||||
file.remove();
|
||||
}
|
||||
|
||||
void contentFileSystemModel::renameFile(QModelIndex &index, QString newName) {
|
||||
QFileInfo fileinfo = contentFileSystemModel::fileInfo(index);
|
||||
qDebug()<<"renameFile "<<fileinfo.absoluteFilePath();
|
||||
QFile file(fileinfo.absoluteFilePath());
|
||||
|
||||
// file.rename(newName);
|
||||
|
||||
}
|
||||
|
||||
AbstractData * contentFileSystemModel::readFile(QFileInfo fileinfo) const {
|
||||
|
@ -237,6 +259,7 @@ AbstractData * contentFileSystemModel::readFile(QFileInfo fileinfo) const {
|
|||
|
||||
if (file.open(QIODevice::ReadOnly),QFileDevice::AutoCloseHandle) {
|
||||
QDataStream in(&file);
|
||||
in.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
filedata=getFileType(fileinfo);
|
||||
|
||||
|
@ -257,6 +280,35 @@ AbstractData * contentFileSystemModel::readFile(QFileInfo fileinfo) const {
|
|||
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)) {
|
||||
QTextStream out(&file);
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-16");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
hp_DataStruct contentFileSystemModel::getFileType(QFileInfo info) const {
|
||||
|
@ -278,6 +330,39 @@ hp_DataStruct contentFileSystemModel::getFileType(QFileInfo info) const {
|
|||
return filedata;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
contentFileSystemModel::~contentFileSystemModel() {
|
||||
qDebug()<<"contentFileSystemModel::delete";
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <QMdiArea>
|
||||
#include "hpdata.h"
|
||||
|
||||
#define FILE_TYPE 5
|
||||
|
||||
class contentFileSystemModel : public QFileSystemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -20,15 +22,20 @@ public:
|
|||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
void clickAction(QMdiArea * mdiwin,QModelIndex &index);
|
||||
void openFile(QMdiArea * mdiwin,QModelIndex &index);
|
||||
void deleteFile(QModelIndex &index);
|
||||
void renameFile(QModelIndex &index, QString newName);
|
||||
hp_DataStruct getFileType(QFileInfo info) const;
|
||||
QString getFileType(hp_DataType) const;
|
||||
AbstractData * readFile(QFileInfo fileinfo) const;
|
||||
|
||||
int writeFile(QFileInfo fileinfo, QByteArray data_in) const;
|
||||
~contentFileSystemModel();
|
||||
|
||||
private:
|
||||
const static QString filetype_list[][2];
|
||||
const static hp_DataType func_type[];
|
||||
const static QString file_type[];
|
||||
// const static std::array<std::pair<hp_DataType,QString>,FILE_TYPE> file_type;
|
||||
};
|
||||
|
||||
#endif // CONTENTFILESYSTEMMODEL_H
|
||||
|
|
91
filerenamedialog.ui
Normal file
91
filerenamedialog.ui
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FileRenameDialog</class>
|
||||
<widget class="QDialog" name="FileRenameDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-60</x>
|
||||
<y>150</y>
|
||||
<width>341</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>100</y>
|
||||
<width>331</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>321</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Change File Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>FileRenameDialog</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>FileRenameDialog</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>
|
250
mainwindow.cpp
250
mainwindow.cpp
|
@ -96,6 +96,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
ui->tvCalculators->setDropIndicatorShown(true);
|
||||
ui->tvCalculators->show();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(onOpen()));
|
||||
connect(ui->actionAbout_HP_Connect,SIGNAL(triggered()),this,SLOT(about()));
|
||||
// connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit()));
|
||||
|
@ -112,6 +116,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(ui->actionRefresh,SIGNAL(triggered(bool)),this,SLOT(refresh(bool)));
|
||||
connect(ui->actionPreferences,SIGNAL(triggered(bool)),this,SLOT(onOptions(bool)));
|
||||
connect(ui->tvCalculators, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(on_tvCalculators_customContextMenuRequested(const QPoint &)));
|
||||
connect(ui->tvContent, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(on_tvContent_customContextMenuRequested(const QPoint &)));
|
||||
connect(hpapi, SIGNAL(hotplug(int)), this, SLOT(hotplug_handler(int)));
|
||||
|
||||
//default data
|
||||
|
@ -584,14 +589,52 @@ void MainWindow::setTreeMenu() {
|
|||
treeMenu->addAction(ui->actionSettings);
|
||||
treeMenu->addAction(ui->actionRefresh);
|
||||
ui->tvCalculators->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->tvContent->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->actionSettings, SIGNAL(triggered(bool)),
|
||||
this, SLOT(treeMenuAction(bool)));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)),
|
||||
this, SLOT(refresh(bool)));
|
||||
|
||||
|
||||
treeMenu1 = new QMenu(ui->tvCalculators);
|
||||
treeMenu1->addAction(ui->actionCalcOpen);
|
||||
treeMenu1->addAction(ui->actionCalcDelete);
|
||||
treeMenu1->addAction(ui->actionCalcRename);
|
||||
|
||||
treeMenu2 = new QMenu(ui->tvCalculators);
|
||||
treeMenu2->addAction(ui->actionCalcOpen);
|
||||
treeMenu2->addAction(ui->actionCalcDelete);
|
||||
|
||||
connect(ui->actionCalcOpen, SIGNAL(triggered(bool)),
|
||||
this, SLOT(treeOpenAction(bool)));
|
||||
connect(ui->actionCalcDelete, SIGNAL(triggered(bool)),
|
||||
this, SLOT(treeDeleteAction(bool)));
|
||||
connect(ui->actionCalcRename, SIGNAL(triggered(bool)),
|
||||
this, SLOT(treeRenameAction(bool)));
|
||||
|
||||
|
||||
fileMenu1 = new QMenu(ui->tvContent);
|
||||
fileMenu1->addAction(ui->actionFileOpen);
|
||||
fileMenu1->addAction(ui->actionFileDelete);
|
||||
fileMenu1->addAction(ui->actionFileRename);
|
||||
|
||||
fileMenu2 = new QMenu(ui->tvContent);
|
||||
fileMenu2->addAction(ui->actionFileOpen);
|
||||
fileMenu2->addAction(ui->actionFileDelete);
|
||||
|
||||
connect(ui->actionFileOpen, SIGNAL(triggered(bool)),
|
||||
this, SLOT(contentOpenAction(bool)));
|
||||
connect(ui->actionFileRename, SIGNAL(triggered(bool)),
|
||||
this, SLOT(contentRenameAction(bool)));
|
||||
connect(ui->actionFileDelete, SIGNAL(triggered(bool)),
|
||||
this, SLOT(contentDeleteAction(bool)));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::treeMenuAction(bool clicked) {
|
||||
|
||||
qDebug()<<"MainWindow::treeMenuAction";
|
||||
|
||||
QPoint pos;
|
||||
pos=ui->actionSettings->data().toPoint();
|
||||
|
||||
|
@ -615,10 +658,164 @@ void MainWindow::treeMenuAction(bool clicked) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::treeOpenAction(bool clicked) {
|
||||
qDebug()<<"MainWindow::treeOpenAction";
|
||||
|
||||
QPoint pos;
|
||||
pos=ui->actionCalcOpen->data().toPoint();
|
||||
QModelIndex index = ui->tvCalculators->indexAt(pos);
|
||||
|
||||
if (index.isValid()) {
|
||||
hpTreeModel->openFile(getMdi(),index);
|
||||
}
|
||||
else {
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::treeRenameAction(bool clicked) {
|
||||
qDebug()<<"MainWindow::treeRenameAction";
|
||||
|
||||
QPoint pos;
|
||||
pos=ui->actionCalcRename->data().toPoint();
|
||||
QModelIndex index = ui->tvCalculators->indexAt(pos);
|
||||
|
||||
QString newName=QStringLiteral("New");
|
||||
|
||||
|
||||
if (index.isValid()) {
|
||||
|
||||
// QFileInfo fileinfo = contentModel.fileInfo(index);
|
||||
|
||||
// newName=fileinfo.fileName();
|
||||
|
||||
bool ok;
|
||||
newName = QInputDialog::getText(this, tr("QInputDialog::getText()"),
|
||||
tr("File name:"), QLineEdit::Normal,
|
||||
newName, &ok);
|
||||
|
||||
if (ok && !newName.isEmpty()) {
|
||||
hpTreeModel->renameFile(index,newName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::treeDeleteAction(bool clicked) {
|
||||
qDebug()<<"MainWindow::treeDeleteAction";
|
||||
|
||||
QPoint pos;
|
||||
pos=ui->actionCalcDelete->data().toPoint();
|
||||
QModelIndex index = ui->tvCalculators->indexAt(pos);
|
||||
QMessageBox::StandardButton reply;
|
||||
|
||||
if (index.isValid()) {
|
||||
|
||||
QString msg("Are you sure you want to delete file ");
|
||||
|
||||
reply = QMessageBox::question(this, "Delete File", msg,
|
||||
QMessageBox::Yes|QMessageBox::No);
|
||||
if (reply == QMessageBox::Yes) {
|
||||
hpTreeModel->deleteFile(index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::contentMenuAction(bool clicked) {
|
||||
qDebug()<<"MainWindow::contentMenuAction";
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::contentOpenAction(bool clicked) {
|
||||
qDebug()<<"MainWindow::contentOpenAction";
|
||||
|
||||
QPoint pos;
|
||||
pos=ui->actionFileOpen->data().toPoint();
|
||||
QModelIndex index = ui->tvContent->indexAt(pos);
|
||||
|
||||
if (index.isValid()) {
|
||||
contentModel.clickAction(getMdi(),index);
|
||||
}
|
||||
else {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void MainWindow::contentRenameAction(bool clicked) {
|
||||
qDebug()<<"MainWindow::contentRenameAction";
|
||||
|
||||
QPoint pos;
|
||||
pos=ui->actionFileRename->data().toPoint();
|
||||
QModelIndex index = ui->tvContent->indexAt(pos);
|
||||
|
||||
QString newName;
|
||||
|
||||
if (index.isValid()) {
|
||||
QFileInfo fileinfo = contentModel.fileInfo(index);
|
||||
|
||||
newName=fileinfo.fileName();
|
||||
|
||||
bool ok;
|
||||
newName = QInputDialog::getText(this, tr("QInputDialog::getText()"),
|
||||
tr("File name:"), QLineEdit::Normal,
|
||||
newName, &ok);
|
||||
if (ok && !newName.isEmpty()) {
|
||||
contentModel.renameFile(index,newName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::contentDeleteAction(bool clicked) {
|
||||
qDebug()<<"MainWindow::contentDeleteAction";
|
||||
|
||||
QPoint pos;
|
||||
pos=ui->actionFileDelete->data().toPoint();
|
||||
QModelIndex index = ui->tvContent->indexAt(pos);
|
||||
|
||||
QMessageBox::StandardButton reply;
|
||||
|
||||
if (index.isValid()) {
|
||||
QFileInfo fileinfo = contentModel.fileInfo(index);
|
||||
QString msg("Are you sure you want to delete file ");
|
||||
|
||||
msg=msg+fileinfo.fileName()+".";
|
||||
|
||||
reply = QMessageBox::question(this, "Delete File", msg,
|
||||
QMessageBox::Yes|QMessageBox::No);
|
||||
|
||||
if (reply == QMessageBox::Yes) {
|
||||
contentModel.deleteFile(index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void MainWindow::on_tvCalculators_customContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
QModelIndex index = ui->tvCalculators->indexAt(pos);
|
||||
if (index.isValid()) {
|
||||
|
||||
ui->actionCalcOpen->setData(QVariant(pos));
|
||||
ui->actionCalcDelete->setData(QVariant(pos));
|
||||
ui->actionCalcRename->setData(QVariant(pos));
|
||||
|
||||
hpTreeItem * treeItem = dynamic_cast<hpTreeItem *>(hpTreeModel->itemFromIndex(index));
|
||||
if(treeItem) {
|
||||
hp_DataType treetype;
|
||||
|
@ -632,12 +829,65 @@ void MainWindow::on_tvCalculators_customContextMenuRequested(const QPoint &pos)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case HP_PROG:
|
||||
case HP_NOTE:{
|
||||
if(treeMenu1) {
|
||||
ui->actionPreferences->setData(QVariant(pos));
|
||||
treeMenu1->exec(ui->tvCalculators->viewport()->mapToGlobal(pos));
|
||||
treeMenu1->hide();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HP_MATRIX:
|
||||
case HP_LIST:{
|
||||
if(treeMenu2) {
|
||||
ui->actionPreferences->setData(QVariant(pos));
|
||||
treeMenu2->exec(ui->tvCalculators->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_tvContent_customContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
QModelIndex index = ui->tvContent->indexAt(pos);
|
||||
|
||||
hp_DataStruct filedata;
|
||||
if (index.isValid()) {
|
||||
|
||||
QFileInfo info = contentModel.fileInfo(index);
|
||||
ui->actionFileOpen->setData(QVariant(pos));
|
||||
ui->actionFileDelete->setData(QVariant(pos));
|
||||
ui->actionFileRename->setData(QVariant(pos));
|
||||
// qDebug()<<"MainWindow::on_tvContent_customContextMenuRequested";
|
||||
filedata=contentModel.getFileType(info);
|
||||
switch (filedata.type) {
|
||||
case HP_PROG:
|
||||
case HP_APP:
|
||||
case HP_NOTE:
|
||||
case HP_VAR: {
|
||||
fileMenu1->exec(ui->tvContent->viewport()->mapToGlobal(pos));
|
||||
fileMenu1->hide();
|
||||
break;
|
||||
}
|
||||
case HP_CAS:
|
||||
case HP_MAIN:
|
||||
case HP_MATRIX:
|
||||
case HP_LIST:
|
||||
case HP_COMPLEX:
|
||||
case HP_SCREEN:
|
||||
case HP_REAL: {
|
||||
fileMenu2->exec(ui->tvContent->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
||||
|
|
16
mainwindow.h
16
mainwindow.h
|
@ -20,6 +20,7 @@
|
|||
#include "cntfilesystemmodel.h"
|
||||
#include "eventtimer.h"
|
||||
|
||||
|
||||
class treeModel;
|
||||
class errorHandler;
|
||||
|
||||
|
@ -68,7 +69,17 @@ private slots:
|
|||
treeModel * getTreeModel();
|
||||
|
||||
void treeMenuAction(bool);
|
||||
void treeOpenAction(bool);
|
||||
void treeRenameAction(bool);
|
||||
void treeDeleteAction(bool);
|
||||
|
||||
void contentMenuAction(bool);
|
||||
void contentOpenAction(bool);
|
||||
void contentRenameAction(bool);
|
||||
void contentDeleteAction(bool);
|
||||
|
||||
void on_tvCalculators_customContextMenuRequested(const QPoint &pos);
|
||||
void on_tvContent_customContextMenuRequested(const QPoint &pos);
|
||||
void eventHandler();
|
||||
void refresh(bool clicked);
|
||||
void hotplug_handler(int );
|
||||
|
@ -84,6 +95,11 @@ private:
|
|||
|
||||
EventTimer * eventTimer;
|
||||
QMenu * treeMenu=nullptr;
|
||||
QMenu * treeMenu1=nullptr;
|
||||
QMenu * treeMenu2=nullptr;
|
||||
QMenu * fileMenu1=nullptr;
|
||||
QMenu * fileMenu2=nullptr;
|
||||
|
||||
hpusb * hpapi=nullptr;
|
||||
QMdiSubWindow * msgWindow=nullptr;
|
||||
hp_MdiWindow * logWindow=nullptr;
|
||||
|
|
130
mainwindow.ui
130
mainwindow.ui
|
@ -46,7 +46,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>919</width>
|
||||
<height>30</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
@ -159,7 +159,10 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
<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>
|
||||
|
@ -232,7 +235,32 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeView" name="tvContent"/>
|
||||
<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>
|
||||
|
@ -528,6 +556,102 @@
|
|||
<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>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include "matrixdata.h"
|
||||
|
||||
MatrixData::MatrixData()
|
||||
{
|
||||
clear();
|
||||
// clear();
|
||||
qDebug()<<"MtarixData Construct";
|
||||
}
|
||||
|
||||
//Return the item or a zero item
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
#include <QTextEdit>
|
||||
|
||||
|
||||
class textEditor : public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit textEditor(QWidget *parent = 0);
|
||||
~textEditor();
|
||||
explicit textEditor(QWidget *parent = nullptr);
|
||||
~textEditor() override;
|
||||
void newFile();
|
||||
bool loadFile(const QString &fileName);
|
||||
bool save();
|
||||
|
|
154
treemodel.cpp
154
treemodel.cpp
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "treemodel.h"
|
||||
#include "hptreeitem.h"
|
||||
#include <hp_mditexteditor.h>
|
||||
#include <QStringListModel>
|
||||
#include <QMimeData>
|
||||
|
||||
|
@ -88,6 +89,66 @@ hpCalcData * treeModel::getCalculator(QString name){
|
|||
return hpdata;
|
||||
}
|
||||
|
||||
void treeModel::clickAction(QMdiArea * mdiwin,QModelIndex &index) {
|
||||
|
||||
return openFile(mdiwin,index);
|
||||
}
|
||||
|
||||
void treeModel::openFile(QMdiArea * mdiwin, QModelIndex &index) {
|
||||
|
||||
qDebug()<<"treeModel::openFile";
|
||||
hp_mdiTextEdit * hptextedit = nullptr;
|
||||
AbstractData * data=nullptr;
|
||||
hpTreeItem * item=nullptr;
|
||||
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
data=getData(index);
|
||||
if ((data!=nullptr)&&(item!=nullptr)) {
|
||||
if (hptextedit==nullptr)
|
||||
hptextedit = new hp_mdiTextEdit(mdiwin,item, data);
|
||||
if (hptextedit!=nullptr)
|
||||
hptextedit ->show();
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Null data";
|
||||
}
|
||||
}
|
||||
|
||||
void treeModel::renameFile(QModelIndex &index,QString newName) {
|
||||
|
||||
qDebug()<<"treeModel::renameFile";
|
||||
hp_mdiTextEdit * hptextedit = nullptr;
|
||||
AbstractData * data=nullptr;
|
||||
hpTreeItem * item=nullptr;
|
||||
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
|
||||
if (item!=nullptr) {
|
||||
//
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Null data";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void treeModel::deleteFile( QModelIndex &index) {
|
||||
|
||||
qDebug()<<"treeModel::deleteFile";
|
||||
hp_mdiTextEdit * hptextedit = nullptr;
|
||||
AbstractData * data=nullptr;
|
||||
hpTreeItem * item=nullptr;
|
||||
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
|
||||
if (item!=nullptr) {
|
||||
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Null data";
|
||||
}
|
||||
}
|
||||
|
||||
//return the calculator data within the model
|
||||
hpTreeItem * treeModel::getCalculatorItem(QString name){
|
||||
|
||||
|
@ -117,7 +178,7 @@ QString treeModel::getLastDataKey() {
|
|||
//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) {
|
||||
hpCalcData * treeModel::getHpCalcData(QString name) const {
|
||||
|
||||
hpDataLink hplink;
|
||||
hpCalcData * hpdata=nullptr;
|
||||
|
@ -150,28 +211,69 @@ Qt::DropActions treeModel::supportedDropActions() const
|
|||
return Qt::CopyAction | Qt::MoveAction | Qt::TargetMoveAction;
|
||||
}
|
||||
|
||||
//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";
|
||||
|
||||
mimeDataPtr->setData("application/x-qabstractmodeldatalist",mydata);
|
||||
|
||||
/* Store row id list */
|
||||
QList<int> rowIdList;
|
||||
int rowId;
|
||||
foreach (QModelIndex index, indexes) {
|
||||
if (index.isValid()) {
|
||||
rowId = index.row();
|
||||
|
||||
if (!rowIdList.contains(rowId)) {
|
||||
rowIdList << rowId;
|
||||
}
|
||||
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;
|
||||
|
@ -205,10 +307,10 @@ bool treeModel::dropMimeData(const QMimeData* md_data, Qt::DropAction action, in
|
|||
formatList=md_data->formats();
|
||||
|
||||
foreach(const QString& format, formatList) {
|
||||
// qDebug()<<format;
|
||||
qDebug()<<format;
|
||||
for(int i = HP_MAIN; i < HP_SETTINGS; i++) {
|
||||
mimeType=mimetypes[i][1];
|
||||
// qDebug()<<mimeType;
|
||||
qDebug()<<mimeType;
|
||||
if( mimeType==format) {
|
||||
type=static_cast<hp_DataType>(i);
|
||||
break;
|
||||
|
@ -222,13 +324,33 @@ bool treeModel::dropMimeData(const QMimeData* md_data, Qt::DropAction action, in
|
|||
|
||||
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();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QStandardItemModel>
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QMdiArea>
|
||||
#include "hp_typedef.h"
|
||||
#include "hpdata.h"
|
||||
|
||||
|
@ -31,10 +32,15 @@ public:
|
|||
int addCalculator(QString name, hpusb * handle);
|
||||
int deletCalculator(QString name, hpusb * handle);
|
||||
int deleteAllCalculators();
|
||||
void clickAction(QMdiArea * mdiwin,QModelIndex &index);
|
||||
void openFile(QMdiArea * mdiwin,QModelIndex &index);
|
||||
void deleteFile(QModelIndex &index);
|
||||
void renameFile(QModelIndex &index,QString newName);
|
||||
hpCalcData * getCalculator(QString name);
|
||||
hpTreeItem * getCalculatorItem(QString name);
|
||||
hpCalcData * getHpCalcData(QString name);
|
||||
hpCalcData * getHpCalcData(QString name) const;
|
||||
AbstractData * createData(hp_Data data_in);
|
||||
AbstractData * getData(QModelIndex) const;
|
||||
int addItem(QString calc, AbstractData * obj);
|
||||
int deleteItem(hpCalcData* hpcalc, AbstractData * obj);
|
||||
void setHpCalcData(QString name, hpCalcData * , hpTreeItem *);
|
||||
|
|
Loading…
Add table
Reference in a new issue