diff --git a/SrcPony/businter.h b/SrcPony/businter.h index b3404aa..f9c253e 100644 --- a/SrcPony/businter.h +++ b/SrcPony/businter.h @@ -102,14 +102,12 @@ class BusInterface qDebug() << "BusInterface::TestRestore() OUT"; } - virtual int SetPower(int onoff) + virtual int SetPower(bool onoff) { - (void)onoff; return OK; } virtual void SetControlLine(int res = 1) { - (void)res; } virtual void SetDataOut(int sda = 1) = 0; diff --git a/SrcPony/dt006interf.cpp b/SrcPony/dt006interf.cpp index 8ab2fec..a3b8757 100644 --- a/SrcPony/dt006interf.cpp +++ b/SrcPony/dt006interf.cpp @@ -93,9 +93,8 @@ void Dt006Interface::SetControlLine(int res) } -int Dt006Interface::SetPower(int onoff) +int Dt006Interface::SetPower(bool onoff) { - (void)onoff; //OutDataPort(0); //No action SetControlLine(0); diff --git a/SrcPony/dt006interf.h b/SrcPony/dt006interf.h index b10e3de..c138393 100644 --- a/SrcPony/dt006interf.h +++ b/SrcPony/dt006interf.h @@ -49,7 +49,7 @@ class Dt006Interface : public LptExtInterface virtual int TestPort(int port); - int SetPower(int onoff); + int SetPower(bool onoff); void SetControlLine(int res = 1); protected: //------------------------------- protected diff --git a/SrcPony/e2app.cpp b/SrcPony/e2app.cpp index 47781d9..9c96a78 100644 --- a/SrcPony/e2app.cpp +++ b/SrcPony/e2app.cpp @@ -255,7 +255,7 @@ int e2App::OpenBus(BusIO *p) if (rv == OK) { - rv = busIntp->SetPower(1); + rv = busIntp->SetPower(true); qDebug() << "e2App::OpenBus() ** SetPower"; @@ -278,7 +278,7 @@ void e2App::SleepBus() qDebug() << "e2App::CloseBus() iniBus=" << (hex) << iniBus << (dec); iniBus->WaitMsec(5); // 08/04/98 -- hold time dell'alimentazione - busIntp->SetPower(0); + busIntp->SetPower(false); iniBus->Close(); // 28/09/98 -- richiude la porta dopo averla usata } diff --git a/SrcPony/e2cmdw.cpp b/SrcPony/e2cmdw.cpp index e023b12..444d7a7 100644 --- a/SrcPony/e2cmdw.cpp +++ b/SrcPony/e2cmdw.cpp @@ -1804,6 +1804,15 @@ void e2CmdWindow::createFontSizeMenu() connect(fsizeGroup, SIGNAL(triggered(QAction *)), this, SLOT(selectFontSize(QAction *))); } +void e2CmdWindow::onDtaChanged() +{ + if (awip) + { + awip->BufChanged(e2HexEdit->isModified()); + UpdateStatusBar(); + } +} + /** * @brief create all SIGNAL -> SLOT connections * EK 2017 @@ -1822,7 +1831,7 @@ void e2CmdWindow::createSignalSlotConnections() // not implemented are: cut/copy/paste buttons // font size - connect(fsizeGroup, SIGNAL(triggered()), this, SLOT(selectFontSize())); + //connect(fsizeGroup, SIGNAL(triggered()), this, SLOT(selectFontSize())); // new connect(actionNew, SIGNAL(triggered()), this, SLOT(onNew())); @@ -1983,7 +1992,7 @@ void e2CmdWindow::createSignalSlotConnections() connect(actiontEEPType, SIGNAL(triggered()), this, SLOT(onSelectEEPType(int val))); connect(actiontEEPSubtype, SIGNAL(triggered()), this, SLOT(onEEPSubType(int val))); #endif - connect(actionCalibration, SIGNAL(triggered()), this, SLOT(onReadCalibration(int idx))); + //connect(actionCalibration, SIGNAL(triggered()), this, SLOT(onReadCalibration(int idx))); // interface setup connect(actionInterfaceSetup, SIGNAL(triggered()), this, SLOT(onInterfSetup())); // connect(actiontWriteCalibration, SIGNAL(triggered()), this, SLOT( onWriteCalibration(int idx))); @@ -2007,6 +2016,26 @@ void e2CmdWindow::onInterfSetup() } } +#if 0 +void e2CmdWindow::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasUrls()) + event->accept(); +} + + +void e2CmdWindow::dropEvent(QDropEvent *event) +{ + if (event->mimeData()->hasUrls()) + { + QList urls = event->mimeData()->urls(); + QString filePath = urls.at(0).toLocalFile(); + loadFile(filePath); + event->accept(); + } +} +#endif + void e2CmdWindow::onGetInfo() { @@ -5999,27 +6028,23 @@ int e2CmdWindow::OpenScript(const QString &file) } -HIDDEN QStringList filter = QStringList({ "*.e2p", "*.hex", "*.mot", "*.bin", "*.csm", "*.rom", "*.eep", "*" }); -HIDDEN QStringList filterInfo = QStringList({ "E2P (*.e2p)", "Intel (*.hex)", "S-rec (*.mot)", "Raw (*.bin)", "CSM (*.csm)", "(*.rom)", "(*.eep)", "*" }); +HIDDEN QStringList filter = QStringList({ "*.e2p", "*.hex", "*.mot", "*.bin", "*.csm", "*.rom", "*.eep", "*" }); +// ^^^^^ ^^^^^ ^^^^^ ^^^^^ ^^^^^ +// form E2P form Intel form S-rec, form Binary (Raw), CSM, gli altri non aggiungono ulteriori formati +HIDDEN QStringList filterInfo = QStringList({ "E2P (*.e2p)", "Intel (*.hex)", "S-rec (*.mot)", "Raw (*.bin)", "CSM (*.csm)", "(*.rom)", "(*.eep)", "*" }); -// ^^^^^ ^^^^^ ^^^^^ ^^^^^ ^^^^^^^ -// form E2P form Intel form S-rec, form Binary (Raw), CSM, gli altri non aggiungono ulteriori formati HIDDEN int filterIndex = 0; HIDDEN void AddExtension(QString &name) { - int p = name.indexOf('.'); //look for extension + int p = name.lastIndexOf('.'); //look for extension - if (p < 0 || (name.mid(p) != filter.at(filterIndex))) + if (p < 0 || (name.mid(p) != filter.at(filterIndex).mid(1))) { - //not found - name += filter.at(filterIndex); - // if ( name.length() + strlen(filter[filterIndex] + 1) < maxlen ) - // { - // strcat(name, filter[filterIndex] + 1); //append extension - // } + //if not found append extension + name += filter.at(filterIndex).mid(1); } } @@ -6140,6 +6165,16 @@ int e2CmdWindow::OpenFile(const QString &file) return rval; } +int e2CmdWindow::filterNameToIndex(const QString &s, const QStringList &lst) +{ + for (int i = 0; i < lst.count(); i++) + { + if (lst.at(i) == s) + return i; + } + + return -1; +} QString e2CmdWindow::convertFilterListToString(const QStringList &lst) { @@ -6180,6 +6215,7 @@ int e2CmdWindow::SaveFile(int force_select) note.setIcon(QMessageBox::Critical); note.setWindowTitle("Save"); note.setText(str); + //note.setParent(this); note.exec(); } } @@ -6207,10 +6243,10 @@ int e2CmdWindow::SaveFile(int force_select) filterIndex = (int)awip->GetFileBuf(); // ??? - QString fltr = convertFilterListToString(filterInfo); + QString sFilter = filterInfo.at(filterIndex); //fn = awip->GetFileName(); //should be the filename proposed by the dialog by default - QString fn = QFileDialog::getSaveFileName(this, translate(STR_MSGFILESAVEAS), QDir::homePath(), fltr); + QString fn = QFileDialog::getSaveFileName(this, s, QDir::homePath(), fltr, &sFilter); if (fn.length()) { @@ -6218,8 +6254,12 @@ int e2CmdWindow::SaveFile(int force_select) //Save the old name in case some error occurs, so it can restore it QString oldname = awip->GetFileName(); - - awip->SetFileBuf((enum FileType)filterIndex); //????? Ci vorrebbe un controllo separato dall'estensione sul tipo di file (combobox) + int fidx = filterNameToIndex(sFilter, filterInfo); + if (fidx > -1) + { + filterIndex = fidx; + awip->SetFileBuf((enum FileType)filterIndex); //????? Ci vorrebbe un controllo separato dall'estensione sul tipo di file (combobox) + } E2Profile::SetDefaultFileType(awip->GetFileBuf()); awip->SetFileName(fn); diff --git a/SrcPony/e2cmdw.h b/SrcPony/e2cmdw.h index d3562a3..8cdd5f3 100644 --- a/SrcPony/e2cmdw.h +++ b/SrcPony/e2cmdw.h @@ -240,6 +240,7 @@ class e2CmdWindow : public QMainWindow, public e2App, public Ui::MainWindow void onSelectScript(QAction *a); void onSelectFile(QAction *a); + void onDtaChanged(); public: int CmdHelp(); @@ -308,6 +309,7 @@ class e2CmdWindow : public QMainWindow, public e2App, public Ui::MainWindow private: //--------------------------------------- private void createSignalSlotConnections(); QString convertFilterListToString(const QStringList &lst); + int filterNameToIndex(const QString &s, const QStringList &lst); void doProgress(const QString &text); diff --git a/SrcPony/ispinterf.cpp b/SrcPony/ispinterf.cpp index 997265a..1ca9c2d 100644 --- a/SrcPony/ispinterf.cpp +++ b/SrcPony/ispinterf.cpp @@ -142,7 +142,7 @@ void AvrISPInterface::SetControlLine(int res) } -int AvrISPInterface::SetPower(int onoff) +int AvrISPInterface::SetPower(bool onoff) { #ifdef AVRISP_MAPPED diff --git a/SrcPony/ispinterf.h b/SrcPony/ispinterf.h index 532e582..fb94997 100644 --- a/SrcPony/ispinterf.h +++ b/SrcPony/ispinterf.h @@ -49,7 +49,7 @@ class AvrISPInterface : public LptExtInterface virtual int TestPort(int port); - int SetPower(int onoff); + int SetPower(bool onoff); void SetControlLine(int res = 1); protected: //------------------------------- protected diff --git a/SrcPony/linuxsysfsint.cpp b/SrcPony/linuxsysfsint.cpp index 70a8504..2c8937c 100644 --- a/SrcPony/linuxsysfsint.cpp +++ b/SrcPony/linuxsysfsint.cpp @@ -193,7 +193,7 @@ static int gpio_close(unsigned int gpio, int fd) } #endif -int LinuxSysFsInterface::SetPower(int onoff) +int LinuxSysFsInterface::SetPower(bool onoff) { qDebug() << "LinuxSysFsInterface::SetPower(" << onoff << ")"; return OK; @@ -261,7 +261,7 @@ void LinuxSysFsInterface::Close() if (IsInstalled()) { - SetPower(0); + SetPower(false); DeInitPins(); DeInstall(); } diff --git a/SrcPony/linuxsysfsint.h b/SrcPony/linuxsysfsint.h index 7ce5912..f204c6f 100644 --- a/SrcPony/linuxsysfsint.h +++ b/SrcPony/linuxsysfsint.h @@ -51,7 +51,7 @@ class LinuxSysFsInterface : public BusInterface // virtual int TestPort(int port); - int SetPower(int onoff); + int SetPower(bool onoff); void SetControlLine(int res = 1); protected: //------------------------------- protected diff --git a/SrcPony/pgminter.cpp b/SrcPony/pgminter.cpp index e63c911..14be99a 100644 --- a/SrcPony/pgminter.cpp +++ b/SrcPony/pgminter.cpp @@ -64,7 +64,7 @@ void SIProgInterface::SetControlLine(int res) //La alimentazione e` data dalle tre linee: SCL, SDA, RESET. // Se una qualsiasi di queste tre linee e` a 1 vi e` alimentazione -int SIProgInterface::SetPower(int onoff) +int SIProgInterface::SetPower(bool onoff) { if (onoff) { @@ -91,7 +91,7 @@ int SIProgInterface::Open(int com_no) if ((ret_val = RS232Interface::OpenSerial(com_no)) == OK) { // SetSerialEventMask(0); - //SetPower(1); //08/02/1998 -- ora diamo alimentazione prima di ogni operazione e la togliamo subito dopo + //SetPower(true); //08/02/1998 -- ora diamo alimentazione prima di ogni operazione e la togliamo subito dopo Install(com_no); } @@ -108,7 +108,7 @@ void SIProgInterface::Close() if (IsInstalled()) { - SetPower(0); + SetPower(false); //SetCommMask(hCom, old_mask); DeInstall(); RS232Interface::CloseSerial(); diff --git a/SrcPony/pgminter.h b/SrcPony/pgminter.h index 1f33a23..58cce25 100644 --- a/SrcPony/pgminter.h +++ b/SrcPony/pgminter.h @@ -53,7 +53,7 @@ class SIProgInterface : public BusInterface, public RS232Interface // int TestSave(int port); // void TestRestore(); - int SetPower(int onoff); + int SetPower(bool onoff); void SetControlLine(int res = 1); protected: //------------------------------- protected diff --git a/SrcPony/ponyioint.cpp b/SrcPony/ponyioint.cpp index 8a2dc02..a0130e7 100644 --- a/SrcPony/ponyioint.cpp +++ b/SrcPony/ponyioint.cpp @@ -129,7 +129,7 @@ void PonyIOInterface::SetControlLine(int res) //Note that with PonyProg SI interface 3 lines provide the power: // SCL, SDA, RESET. If any of these lines are on (>5V) the power is ON -int PonyIOInterface::SetPower(int onoff) +int PonyIOInterface::SetPower(bool onoff) { qDebug() << "PonyIOInterface::SetPower(" << onoff << ")"; @@ -172,7 +172,7 @@ void PonyIOInterface::Close() if (IsInstalled()) { - SetPower(0); + SetPower(false); CloseSerial(); DeInstall(); } diff --git a/SrcPony/ponyioint.h b/SrcPony/ponyioint.h index 00344ca..7a9c929 100644 --- a/SrcPony/ponyioint.h +++ b/SrcPony/ponyioint.h @@ -51,7 +51,7 @@ class PonyIOInterface : public BusInterface, public PortInterface virtual int TestPort(int port); - int SetPower(int onoff); + int SetPower(bool onoff); void SetControlLine(int res = 1); protected: //------------------------------- protected