From 5de6f4dc9484821aad1fcef0b16e5cd399919f8c Mon Sep 17 00:00:00 2001 From: bsongis Date: Fri, 18 Apr 2014 17:34:41 +0200 Subject: [PATCH] Now we are able to have Model windows with different transmitter types! --- companion/src/mainwindow.cpp | 18 +++++++++--------- companion/src/mdichild.cpp | 9 +++++---- companion/src/mdichild.h | 14 ++++++++------ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index a139505fc..c1a82fef6 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -1546,17 +1546,17 @@ void MainWindow::updateMenus() MdiChild *MainWindow::createMdiChild() { - MdiChild *child = new MdiChild; - mdiArea->addSubWindow(child); - if(!child->parentWidget()->isMaximized() && !child->parentWidget()->isMinimized()) - child->parentWidget()->resize(400, 400); + MdiChild *child = new MdiChild(); + mdiArea->addSubWindow(child); + if(!child->parentWidget()->isMaximized() && !child->parentWidget()->isMinimized()) + child->parentWidget()->resize(400, 400); - connect(child, SIGNAL(copyAvailable(bool)),cutAct, SLOT(setEnabled(bool))); - connect(child, SIGNAL(copyAvailable(bool)),copyAct, SLOT(setEnabled(bool))); - connect(child, SIGNAL(copyAvailable(bool)),simulateAct, SLOT(setEnabled(bool))); - connect(child, SIGNAL(copyAvailable(bool)),printAct, SLOT(setEnabled(bool))); + connect(child, SIGNAL(copyAvailable(bool)),cutAct, SLOT(setEnabled(bool))); + connect(child, SIGNAL(copyAvailable(bool)),copyAct, SLOT(setEnabled(bool))); + connect(child, SIGNAL(copyAvailable(bool)),simulateAct, SLOT(setEnabled(bool))); + connect(child, SIGNAL(copyAvailable(bool)),printAct, SLOT(setEnabled(bool))); - return child; + return child; } QAction * MainWindow::addAct(QString icon, QString sName, QString lName, QKeySequence::StandardKey shortcut, const char *slot, QObject *slotObj) diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 75dfc6af3..b910f6319 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -66,6 +66,7 @@ MdiChild::MdiChild(): QWidget(), ui(new Ui::mdiChild), + firmware(GetCurrentFirmware()), isUntitled(true), fileChanged(false) { @@ -103,7 +104,7 @@ void MdiChild::qSleep(int ms) void MdiChild::eepromInterfaceChanged() { ui->modelsList->refreshList(); - ui->SimulateTxButton->setEnabled(GetCurrentFirmware()->getCapability(Simulation)); + ui->SimulateTxButton->setEnabled(firmware->getCapability(Simulation)); updateTitle(); } @@ -181,7 +182,7 @@ void MdiChild::modelEdit() QApplication::setOverrideCursor(Qt::WaitCursor); checkAndInitModel( row ); ModelData &model = radioData.models[row - 1]; - ModelEdit *t = new ModelEdit(this, radioData, (row - 1), GetCurrentFirmware()); + ModelEdit *t = new ModelEdit(this, radioData, (row - 1), firmware); t->setWindowTitle(tr("Editing model %1: ").arg(row) + model.name); connect(t, SIGNAL(modified()), this, SLOT(setModified())); t->show(); @@ -666,10 +667,10 @@ void MdiChild::print(int model, QString filename) PrintDialog * pd = NULL; if (model>=0 && !filename.isEmpty()) { - pd = new PrintDialog(this, GetCurrentFirmware(), &radioData.generalSettings, &radioData.models[model], filename); + pd = new PrintDialog(this, firmware, &radioData.generalSettings, &radioData.models[model], filename); } else if (ui->modelsList->currentRow() > 0) { - pd = new PrintDialog(this, GetCurrentFirmware(), &radioData.generalSettings, &radioData.models[ui->modelsList->currentRow()-1]); + pd = new PrintDialog(this, firmware, &radioData.generalSettings, &radioData.models[ui->modelsList->currentRow()-1]); } if (pd) { diff --git a/companion/src/mdichild.h b/companion/src/mdichild.h index fab250127..4f6887108 100644 --- a/companion/src/mdichild.h +++ b/companion/src/mdichild.h @@ -59,7 +59,7 @@ class MdiChild : public QWidget Q_OBJECT -public: + public: MdiChild(); ~MdiChild(); @@ -78,18 +78,18 @@ public: void eepromInterfaceChanged(); void setEEpromAvail(int eavail); -signals: + signals: void copyAvailable(bool val); -protected: + protected: void closeEvent(QCloseEvent *event); -private slots: + private slots: void documentWasModified(); void on_SimulateTxButton_clicked(); void qSleep(int ms); -public slots: + public slots: void checkAndInitModel(int row); void generalEdit(); void modelEdit(); @@ -105,7 +105,7 @@ public slots: void setModified(); void updateTitle(); -private: + private: bool maybeSave(); void setCurrentFile(const QString &fileName); QString strippedName(const QString &fullFileName); @@ -115,6 +115,8 @@ private: Ui::mdiChild *ui; QString curFile; + + FirmwareInterface * firmware; RadioData radioData; bool isUntitled;