mirror of
https://github.com/Indy970/QtHPConnect
synced 2024-11-15 19:48:02 +01:00
Update
This commit is contained in:
parent
ffa75742b6
commit
880a2f2b89
9 changed files with 117 additions and 117 deletions
|
@ -243,14 +243,16 @@ inline bool AbstractData::operator ==(AbstractData& lhs) {
|
|||
//Equivalence on name and type NOT on data
|
||||
bool AbstractData::equivalent(QString name_in, hp_DataType type_in) {
|
||||
|
||||
if((name==name_in)&&(type==type_in))
|
||||
if((getName()==name_in)&&(getType()==type_in))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void AbstractData::setName(QString name_in) {
|
||||
qDebug()<<"Abstract set name"<<name_in;
|
||||
name = name_in;
|
||||
return;
|
||||
}
|
||||
|
||||
QString AbstractData::getName() {
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
<?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>
|
|
@ -10,9 +10,14 @@ hp_mdiTextEdit::hp_mdiTextEdit(QWidget * parent,hpTreeItem * treeItem, AbstractD
|
|||
setMaximumSize(1000,1000);
|
||||
setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
|
||||
|
||||
qDebug()<<"hp_mdiTextEdit::hp_mdiTextEdit";
|
||||
hptreeitem=treeItem;
|
||||
data = calcData;
|
||||
qDebug()<<data->getName();
|
||||
qDebug()<<data->getType();
|
||||
filename=treeItem->getFileName();
|
||||
qDebug()<<filename;
|
||||
|
||||
type=treeItem->getType();
|
||||
|
||||
setup();
|
||||
|
|
|
@ -93,6 +93,7 @@ void hpCalcData::addData(AbstractData * data) {
|
|||
|
||||
void hpCalcData::deleteData(AbstractData *) {
|
||||
// lData.erase();
|
||||
qDebug()<<"hpCalcData::deleteData - functionality requierd";
|
||||
}
|
||||
|
||||
//returns position of entry in list or returns 0;
|
||||
|
|
|
@ -60,7 +60,7 @@ hpTreeItem::hpTreeItem(const QString & name,hpCalcData * hpDataStore,int flag)
|
|||
setDragEnabled(true);
|
||||
setDropEnabled(true);
|
||||
|
||||
filename=name;
|
||||
// filename=name;
|
||||
|
||||
if (flag==0)
|
||||
setGraphicTree();
|
||||
|
@ -173,6 +173,10 @@ void hpTreeItem::clickAction(QMdiArea * mdiwin) {
|
|||
data=dataStore->getData(getFileName(),getType());
|
||||
}
|
||||
|
||||
//To fix by having hp_mdi reset
|
||||
hptextedit=nullptr;
|
||||
|
||||
|
||||
if (hptextedit==nullptr)
|
||||
hptextedit = new hp_mdiTextEdit(mdiwin,this, data);
|
||||
if (hptextedit!=nullptr)
|
||||
|
@ -180,13 +184,18 @@ void hpTreeItem::clickAction(QMdiArea * mdiwin) {
|
|||
}
|
||||
break;
|
||||
case HP_PROG: {
|
||||
hpCalcData * dataStore;
|
||||
hpCalcData * dataStore =nullptr;
|
||||
AbstractData * data =nullptr;
|
||||
dataStore = getDataStore();
|
||||
qDebug()<<"HP_Prog ... click"<<getFileName();
|
||||
if (dataStore) {
|
||||
data=dataStore->getData(getFileName(),getType());
|
||||
qDebug()<<data->getName();
|
||||
}
|
||||
|
||||
//To fix by having hp_mdi reset
|
||||
hptextedit=nullptr;
|
||||
|
||||
if (hptextedit==nullptr) {
|
||||
hptextedit = new hp_mdiTextEdit(mdiwin,this, data);
|
||||
}
|
||||
|
@ -289,7 +298,7 @@ QString hpTreeItem::getGroupName() {
|
|||
|
||||
QString hpTreeItem::getFileName() {
|
||||
|
||||
return filename;
|
||||
return text();
|
||||
}
|
||||
|
||||
QString hpTreeItem::getCalculatorName() {
|
||||
|
@ -306,7 +315,14 @@ QString hpTreeItem::getCalculatorName() {
|
|||
|
||||
void hpTreeItem::setFileName(QString file) {
|
||||
|
||||
filename=file;
|
||||
|
||||
qDebug()<<"rename "<<text()<<" to "<<file;
|
||||
|
||||
// filename=file;
|
||||
setText(file);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//Slot to respond to data changes
|
||||
|
@ -599,6 +615,6 @@ hpTreeItem::~hpTreeItem() {
|
|||
}
|
||||
*/
|
||||
removeColumn(0);
|
||||
qDebug()<<"hpTreeItem:: delete"<<filename;
|
||||
qDebug()<<"hpTreeItem:: delete"<<text();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public slots:
|
|||
private:
|
||||
const static QString func_list[][2];
|
||||
const static hp_DataType func_type[];
|
||||
QString filename;
|
||||
// QString filename;
|
||||
hp_DataType type;
|
||||
hpCalcData * hp_data=nullptr;
|
||||
QMdiArea * mdiarea=nullptr;
|
||||
|
|
|
@ -682,15 +682,9 @@ void MainWindow::treeRenameAction(bool clicked) {
|
|||
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();
|
||||
|
||||
QString newName= hpTreeModel->getName(index);
|
||||
bool ok;
|
||||
newName = QInputDialog::getText(this, tr("QInputDialog::getText()"),
|
||||
tr("File name:"), QLineEdit::Normal,
|
||||
|
@ -716,7 +710,9 @@ void MainWindow::treeDeleteAction(bool clicked) {
|
|||
|
||||
if (index.isValid()) {
|
||||
|
||||
QString fileName= hpTreeModel->getName(index);
|
||||
QString msg("Are you sure you want to delete file ");
|
||||
msg=msg+fileName;
|
||||
|
||||
reply = QMessageBox::question(this, "Delete File", msg,
|
||||
QMessageBox::Yes|QMessageBox::No);
|
||||
|
|
|
@ -117,36 +117,89 @@ void treeModel::openFile(QMdiArea * mdiwin, QModelIndex &index) {
|
|||
void treeModel::renameFile(QModelIndex &index,QString newName) {
|
||||
|
||||
qDebug()<<"treeModel::renameFile";
|
||||
hp_mdiTextEdit * hptextedit = nullptr;
|
||||
AbstractData * data=nullptr;
|
||||
|
||||
AbstractData * adata=nullptr;
|
||||
hpTreeItem * item=nullptr;
|
||||
QString calc;
|
||||
QString name;
|
||||
hp_DataType type;
|
||||
hpCalcData * hpdata=nullptr;
|
||||
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
if (index.isValid()) {
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
|
||||
if (item!=nullptr) {
|
||||
//
|
||||
}
|
||||
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";
|
||||
hp_mdiTextEdit * hptextedit = nullptr;
|
||||
AbstractData * data=nullptr;
|
||||
AbstractData * adata=nullptr;
|
||||
hpTreeItem * item=nullptr;
|
||||
QString calc;
|
||||
QString name;
|
||||
hp_DataType type;
|
||||
hpCalcData * hpdata=nullptr;
|
||||
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
if (index.isValid()) {
|
||||
item = static_cast<hpTreeItem *>(itemFromIndex(index));
|
||||
|
||||
if (item!=nullptr) {
|
||||
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
|
||||
|
||||
//delete Data
|
||||
hpdata->deleteData(adata);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
qDebug()<<"Null data";
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug()<<"treeMoel::deleteFile invalid index";
|
||||
}
|
||||
}
|
||||
|
||||
//return the calculator data within the model
|
||||
|
@ -211,6 +264,23 @@ 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 {
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
hpCalcData * getHpCalcData(QString name) const;
|
||||
AbstractData * createData(hp_Data data_in);
|
||||
AbstractData * getData(QModelIndex) const;
|
||||
QString getName(QModelIndex) const;
|
||||
int addItem(QString calc, AbstractData * obj);
|
||||
int deleteItem(hpCalcData* hpcalc, AbstractData * obj);
|
||||
void setHpCalcData(QString name, hpCalcData * , hpTreeItem *);
|
||||
|
|
Loading…
Reference in a new issue