- fix filesave file name extension

- add missing ondtachanged()
- setpower() to bool type
This commit is contained in:
Claudio Lanconelli 2017-05-15 01:13:03 +02:00
parent 4e9520e612
commit 64904d73a7
14 changed files with 77 additions and 38 deletions

View File

@ -102,14 +102,12 @@ class BusInterface
qDebug() << "BusInterface::TestRestore() OUT"; qDebug() << "BusInterface::TestRestore() OUT";
} }
virtual int SetPower(int onoff) virtual int SetPower(bool onoff)
{ {
(void)onoff;
return OK; return OK;
} }
virtual void SetControlLine(int res = 1) virtual void SetControlLine(int res = 1)
{ {
(void)res;
} }
virtual void SetDataOut(int sda = 1) = 0; virtual void SetDataOut(int sda = 1) = 0;

View File

@ -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 //OutDataPort(0); //No action
SetControlLine(0); SetControlLine(0);

View File

@ -49,7 +49,7 @@ class Dt006Interface : public LptExtInterface
virtual int TestPort(int port); virtual int TestPort(int port);
int SetPower(int onoff); int SetPower(bool onoff);
void SetControlLine(int res = 1); void SetControlLine(int res = 1);
protected: //------------------------------- protected protected: //------------------------------- protected

View File

@ -255,7 +255,7 @@ int e2App::OpenBus(BusIO *p)
if (rv == OK) if (rv == OK)
{ {
rv = busIntp->SetPower(1); rv = busIntp->SetPower(true);
qDebug() << "e2App::OpenBus() ** SetPower"; qDebug() << "e2App::OpenBus() ** SetPower";
@ -278,7 +278,7 @@ void e2App::SleepBus()
qDebug() << "e2App::CloseBus() iniBus=" << (hex) << iniBus << (dec); qDebug() << "e2App::CloseBus() iniBus=" << (hex) << iniBus << (dec);
iniBus->WaitMsec(5); // 08/04/98 -- hold time dell'alimentazione 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 iniBus->Close(); // 28/09/98 -- richiude la porta dopo averla usata
} }

View File

@ -1804,6 +1804,15 @@ void e2CmdWindow::createFontSizeMenu()
connect(fsizeGroup, SIGNAL(triggered(QAction *)), this, SLOT(selectFontSize(QAction *))); 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 * @brief create all SIGNAL -> SLOT connections
* EK 2017 * EK 2017
@ -1822,7 +1831,7 @@ void e2CmdWindow::createSignalSlotConnections()
// not implemented are: cut/copy/paste buttons // not implemented are: cut/copy/paste buttons
// font size // font size
connect(fsizeGroup, SIGNAL(triggered()), this, SLOT(selectFontSize())); //connect(fsizeGroup, SIGNAL(triggered()), this, SLOT(selectFontSize()));
// new // new
connect(actionNew, SIGNAL(triggered()), this, SLOT(onNew())); connect(actionNew, SIGNAL(triggered()), this, SLOT(onNew()));
@ -1983,7 +1992,7 @@ void e2CmdWindow::createSignalSlotConnections()
connect(actiontEEPType, SIGNAL(triggered()), this, SLOT(onSelectEEPType(int val))); connect(actiontEEPType, SIGNAL(triggered()), this, SLOT(onSelectEEPType(int val)));
connect(actiontEEPSubtype, SIGNAL(triggered()), this, SLOT(onEEPSubType(int val))); connect(actiontEEPSubtype, SIGNAL(triggered()), this, SLOT(onEEPSubType(int val)));
#endif #endif
connect(actionCalibration, SIGNAL(triggered()), this, SLOT(onReadCalibration(int idx))); //connect(actionCalibration, SIGNAL(triggered()), this, SLOT(onReadCalibration(int idx)));
// interface setup // interface setup
connect(actionInterfaceSetup, SIGNAL(triggered()), this, SLOT(onInterfSetup())); connect(actionInterfaceSetup, SIGNAL(triggered()), this, SLOT(onInterfSetup()));
// connect(actiontWriteCalibration, SIGNAL(triggered()), this, SLOT( onWriteCalibration(int idx))); // 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<QUrl> urls = event->mimeData()->urls();
QString filePath = urls.at(0).toLocalFile();
loadFile(filePath);
event->accept();
}
}
#endif
void e2CmdWindow::onGetInfo() 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 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)", "*" }); // ^^^^^ ^^^^^ ^^^^^ ^^^^^ ^^^^^
// 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 int filterIndex = 0;
HIDDEN void AddExtension(QString &name) 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 //if not found append extension
name += filter.at(filterIndex); name += filter.at(filterIndex).mid(1);
// if ( name.length() + strlen(filter[filterIndex] + 1) < maxlen )
// {
// strcat(name, filter[filterIndex] + 1); //append extension
// }
} }
} }
@ -6140,6 +6165,16 @@ int e2CmdWindow::OpenFile(const QString &file)
return rval; 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) QString e2CmdWindow::convertFilterListToString(const QStringList &lst)
{ {
@ -6180,6 +6215,7 @@ int e2CmdWindow::SaveFile(int force_select)
note.setIcon(QMessageBox::Critical); note.setIcon(QMessageBox::Critical);
note.setWindowTitle("Save"); note.setWindowTitle("Save");
note.setText(str); note.setText(str);
//note.setParent(this);
note.exec(); note.exec();
} }
} }
@ -6207,10 +6243,10 @@ int e2CmdWindow::SaveFile(int force_select)
filterIndex = (int)awip->GetFileBuf(); // ??? filterIndex = (int)awip->GetFileBuf(); // ???
QString fltr = convertFilterListToString(filterInfo); QString fltr = convertFilterListToString(filterInfo);
QString sFilter = filterInfo.at(filterIndex);
//fn = awip->GetFileName(); //should be the filename proposed by the dialog by default //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()) 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 //Save the old name in case some error occurs, so it can restore it
QString oldname = awip->GetFileName(); QString oldname = awip->GetFileName();
int fidx = filterNameToIndex(sFilter, filterInfo);
awip->SetFileBuf((enum FileType)filterIndex); //????? Ci vorrebbe un controllo separato dall'estensione sul tipo di file (combobox) 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()); E2Profile::SetDefaultFileType(awip->GetFileBuf());
awip->SetFileName(fn); awip->SetFileName(fn);

View File

@ -240,6 +240,7 @@ class e2CmdWindow : public QMainWindow, public e2App, public Ui::MainWindow
void onSelectScript(QAction *a); void onSelectScript(QAction *a);
void onSelectFile(QAction *a); void onSelectFile(QAction *a);
void onDtaChanged();
public: public:
int CmdHelp(); int CmdHelp();
@ -308,6 +309,7 @@ class e2CmdWindow : public QMainWindow, public e2App, public Ui::MainWindow
private: //--------------------------------------- private private: //--------------------------------------- private
void createSignalSlotConnections(); void createSignalSlotConnections();
QString convertFilterListToString(const QStringList &lst); QString convertFilterListToString(const QStringList &lst);
int filterNameToIndex(const QString &s, const QStringList &lst);
void doProgress(const QString &text); void doProgress(const QString &text);

View File

@ -142,7 +142,7 @@ void AvrISPInterface::SetControlLine(int res)
} }
int AvrISPInterface::SetPower(int onoff) int AvrISPInterface::SetPower(bool onoff)
{ {
#ifdef AVRISP_MAPPED #ifdef AVRISP_MAPPED

View File

@ -49,7 +49,7 @@ class AvrISPInterface : public LptExtInterface
virtual int TestPort(int port); virtual int TestPort(int port);
int SetPower(int onoff); int SetPower(bool onoff);
void SetControlLine(int res = 1); void SetControlLine(int res = 1);
protected: //------------------------------- protected protected: //------------------------------- protected

View File

@ -193,7 +193,7 @@ static int gpio_close(unsigned int gpio, int fd)
} }
#endif #endif
int LinuxSysFsInterface::SetPower(int onoff) int LinuxSysFsInterface::SetPower(bool onoff)
{ {
qDebug() << "LinuxSysFsInterface::SetPower(" << onoff << ")"; qDebug() << "LinuxSysFsInterface::SetPower(" << onoff << ")";
return OK; return OK;
@ -261,7 +261,7 @@ void LinuxSysFsInterface::Close()
if (IsInstalled()) if (IsInstalled())
{ {
SetPower(0); SetPower(false);
DeInitPins(); DeInitPins();
DeInstall(); DeInstall();
} }

View File

@ -51,7 +51,7 @@ class LinuxSysFsInterface : public BusInterface
// virtual int TestPort(int port); // virtual int TestPort(int port);
int SetPower(int onoff); int SetPower(bool onoff);
void SetControlLine(int res = 1); void SetControlLine(int res = 1);
protected: //------------------------------- protected protected: //------------------------------- protected

View File

@ -64,7 +64,7 @@ void SIProgInterface::SetControlLine(int res)
//La alimentazione e` data dalle tre linee: SCL, SDA, RESET. //La alimentazione e` data dalle tre linee: SCL, SDA, RESET.
// Se una qualsiasi di queste tre linee e` a 1 vi e` alimentazione // 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) if (onoff)
{ {
@ -91,7 +91,7 @@ int SIProgInterface::Open(int com_no)
if ((ret_val = RS232Interface::OpenSerial(com_no)) == OK) if ((ret_val = RS232Interface::OpenSerial(com_no)) == OK)
{ {
// SetSerialEventMask(0); // 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); Install(com_no);
} }
@ -108,7 +108,7 @@ void SIProgInterface::Close()
if (IsInstalled()) if (IsInstalled())
{ {
SetPower(0); SetPower(false);
//SetCommMask(hCom, old_mask); //SetCommMask(hCom, old_mask);
DeInstall(); DeInstall();
RS232Interface::CloseSerial(); RS232Interface::CloseSerial();

View File

@ -53,7 +53,7 @@ class SIProgInterface : public BusInterface, public RS232Interface
// int TestSave(int port); // int TestSave(int port);
// void TestRestore(); // void TestRestore();
int SetPower(int onoff); int SetPower(bool onoff);
void SetControlLine(int res = 1); void SetControlLine(int res = 1);
protected: //------------------------------- protected protected: //------------------------------- protected

View File

@ -129,7 +129,7 @@ void PonyIOInterface::SetControlLine(int res)
//Note that with PonyProg SI interface 3 lines provide the power: //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 // 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 << ")"; qDebug() << "PonyIOInterface::SetPower(" << onoff << ")";
@ -172,7 +172,7 @@ void PonyIOInterface::Close()
if (IsInstalled()) if (IsInstalled())
{ {
SetPower(0); SetPower(false);
CloseSerial(); CloseSerial();
DeInstall(); DeInstall();
} }

View File

@ -51,7 +51,7 @@ class PonyIOInterface : public BusInterface, public PortInterface
virtual int TestPort(int port); virtual int TestPort(int port);
int SetPower(int onoff); int SetPower(bool onoff);
void SetControlLine(int res = 1); void SetControlLine(int res = 1);
protected: //------------------------------- protected protected: //------------------------------- protected