[Companion] Unix format used everywhere
This commit is contained in:
+727
-727
File diff suppressed because it is too large
Load Diff
@@ -20,58 +20,58 @@
|
||||
|
||||
#ifndef _GENERALEDIT_H_
|
||||
#define _GENERALEDIT_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "eeprominterface.h"
|
||||
#include "genericpanel.h"
|
||||
|
||||
namespace Ui {
|
||||
class GeneralEdit;
|
||||
}
|
||||
|
||||
class GeneralPanel : public GenericPanel
|
||||
{
|
||||
public:
|
||||
GeneralPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GenericPanel(parent, NULL, generalSettings, firmware)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class GeneralEdit : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * firmware);
|
||||
~GeneralEdit();
|
||||
|
||||
private:
|
||||
Ui::GeneralEdit *ui;
|
||||
GeneralSettings & generalSettings;
|
||||
|
||||
bool switchDefPosEditLock;
|
||||
bool voiceLangEditLock;
|
||||
bool mavbaudEditLock;
|
||||
void getGeneralSwitchDefPos(int i, bool val);
|
||||
void setSwitchDefPos();
|
||||
void updateVarioPitchRange();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void onTabModified();
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
void on_calretrieve_PB_clicked();
|
||||
void on_calstore_PB_clicked();
|
||||
|
||||
private:
|
||||
Firmware * firmware;
|
||||
QVector<GenericPanel *> panels;
|
||||
void addTab(GenericPanel *panel, QString text);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "eeprominterface.h"
|
||||
#include "genericpanel.h"
|
||||
|
||||
namespace Ui {
|
||||
class GeneralEdit;
|
||||
}
|
||||
|
||||
class GeneralPanel : public GenericPanel
|
||||
{
|
||||
public:
|
||||
GeneralPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GenericPanel(parent, NULL, generalSettings, firmware)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class GeneralEdit : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * firmware);
|
||||
~GeneralEdit();
|
||||
|
||||
private:
|
||||
Ui::GeneralEdit *ui;
|
||||
GeneralSettings & generalSettings;
|
||||
|
||||
bool switchDefPosEditLock;
|
||||
bool voiceLangEditLock;
|
||||
bool mavbaudEditLock;
|
||||
void getGeneralSwitchDefPos(int i, bool val);
|
||||
void setSwitchDefPos();
|
||||
void updateVarioPitchRange();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void onTabModified();
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
void on_calretrieve_PB_clicked();
|
||||
void on_calstore_PB_clicked();
|
||||
|
||||
private:
|
||||
Firmware * firmware;
|
||||
QVector<GenericPanel *> panels;
|
||||
void addTab(GenericPanel *panel, QString text);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
};
|
||||
|
||||
#endif // _GENERALEDIT_H_
|
||||
|
||||
+240
-240
@@ -20,244 +20,244 @@
|
||||
|
||||
#ifndef _MAINWINDOW_H_
|
||||
#define _MAINWINDOW_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QDateTime>
|
||||
#include "downloaddialog.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#define SPLASH_TIME 5
|
||||
#define MAX_RECENT 15
|
||||
#define MAX_PROFILES 15
|
||||
|
||||
class MdiChild;
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QMenu;
|
||||
class QMdiArea;
|
||||
class QMdiSubWindow;
|
||||
class QSignalMapper;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#define CHECK_COMPANION 1
|
||||
#define CHECK_FIRMWARE 2
|
||||
#define SHOW_DIALOG_WAIT 4
|
||||
#define AUTOMATIC_DOWNLOAD 8
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
friend class FirmwarePreferencesDialog;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
protected:
|
||||
QString getCompanionUpdateBaseUrl();
|
||||
void dowloadLastFirmwareUpdate();
|
||||
void startFirmwareDownload();
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void setLanguage(const QString & langString);
|
||||
QString seekCodeString(const QByteArray & qba, const QString & label);
|
||||
|
||||
private slots:
|
||||
void openDocURL();
|
||||
|
||||
void setSysLanguage() { setLanguage(""); };
|
||||
void setCZLanguage() { setLanguage("cs_CZ"); };
|
||||
void setDELanguage() { setLanguage("de_DE"); };
|
||||
void setENLanguage() { setLanguage("en"); };
|
||||
void setFILanguage() { setLanguage("fi_FI"); };
|
||||
void setFRLanguage() { setLanguage("fr_FR"); };
|
||||
void setITLanguage() { setLanguage("it_IT"); };
|
||||
void setHELanguage() { setLanguage("he_IL"); };
|
||||
void setPLLanguage() { setLanguage("pl_PL"); };
|
||||
void setESLanguage() { setLanguage("es_ES"); };
|
||||
void setPTLanguage() { setLanguage("pt_PT"); };
|
||||
void setRULanguage() { setLanguage("ru_RU"); };
|
||||
void setSELanguage() { setLanguage("sv_SE"); };
|
||||
void setNLLanguage() { setLanguage("nl_NL"); };
|
||||
|
||||
void setTheme(int index);
|
||||
void setClassicTheme() {setTheme(0);};
|
||||
void setYericoTheme() {setTheme(1);};
|
||||
void setMonoWhiteTheme() {setTheme(2);};
|
||||
void setMonochromeTheme(){setTheme(3);};
|
||||
void setMonoBlueTheme() {setTheme(4);};
|
||||
|
||||
void setIconThemeSize(int index);
|
||||
void setSmallIconThemeSize() {setIconThemeSize(0);};
|
||||
void setNormalIconThemeSize() {setIconThemeSize(1);};
|
||||
void setBigIconThemeSize() {setIconThemeSize(2);};
|
||||
void setHugeIconThemeSize() {setIconThemeSize(3);};
|
||||
|
||||
void checkForUpdates();
|
||||
void checkForFirmwareUpdate();
|
||||
|
||||
void checkForCompanionUpdateFinished(QNetworkReply * reply);
|
||||
void checkForFirmwareUpdateFinished(QNetworkReply * reply);
|
||||
|
||||
void displayWarnings();
|
||||
void doAutoUpdates();
|
||||
void doUpdates();
|
||||
void updateDownloaded();
|
||||
void firmwareDownloadAccepted();
|
||||
void newFile();
|
||||
void openFile();
|
||||
void save();
|
||||
void saveAs();
|
||||
void cut();
|
||||
void openRecentFile();
|
||||
void loadProfile();
|
||||
void logFile();
|
||||
void copy();
|
||||
void paste();
|
||||
void writeEeprom();
|
||||
void readEeprom();
|
||||
void writeFlash(QString fileToFlash="");
|
||||
void readFlash();
|
||||
void writeBackup();
|
||||
void readBackup();
|
||||
void burnConfig();
|
||||
void burnList();
|
||||
void burnFuses();
|
||||
void simulate();
|
||||
void contributors();
|
||||
void sdsync();
|
||||
void changelog();
|
||||
void fwchangelog();
|
||||
void customizeSplash();
|
||||
void about();
|
||||
void compare();
|
||||
void print();
|
||||
void loadBackup();
|
||||
void appPrefs();
|
||||
void fwPrefs();
|
||||
void updateMenus();
|
||||
void createProfile();
|
||||
MdiChild *createMdiChild();
|
||||
void setActiveSubWindow(QWidget *window);
|
||||
QMenu * createRecentFileMenu();
|
||||
QMenu * createProfilesMenu();
|
||||
void autoClose();
|
||||
|
||||
private:
|
||||
void closeUpdatesWaitDialog();
|
||||
void onUpdatesError();
|
||||
|
||||
void createActions();
|
||||
QAction * addAct(const QString &, const QString &, const QString &, enum QKeySequence::StandardKey, const char *, QObject *slotObj=NULL);
|
||||
QAction * addAct(const QString &, const QString &, const QString &, const QKeySequence &, const char *, QObject *slotObj=NULL);
|
||||
QAction * addAct(QActionGroup *, const QString &, const QString &, const char *);
|
||||
QAction * addAct(const QString &, const QString &, const QString &, const char *);
|
||||
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
void createStatusBar();
|
||||
void updateRecentFileActions();
|
||||
void updateProfilesActions();
|
||||
void updateIconSizeActions();
|
||||
void updateLanguageActions();
|
||||
void updateIconThemeActions();
|
||||
|
||||
int getFileType(const QString & fullFileName);
|
||||
QString Theme;
|
||||
QString ISize;
|
||||
QString strippedName(const QString & fullFileName);
|
||||
|
||||
MdiChild *activeMdiChild();
|
||||
QMdiSubWindow *findMdiChild(const QString & fileName);
|
||||
int getEpromVersion(QString fileName);
|
||||
|
||||
bool readEepromFromRadio(const QString & filename);
|
||||
bool writeEepromToRadio(const QString & filename);
|
||||
bool readFirmwareFromRadio(const QString & filename);
|
||||
bool writeFirmwareToRadio(const QString & filename);
|
||||
|
||||
QMdiArea *mdiArea;
|
||||
QSignalMapper *windowMapper;
|
||||
|
||||
QString installer_fileName;
|
||||
downloadDialog * downloadDialog_forWait;
|
||||
unsigned int checkForUpdatesState;
|
||||
QString firmwareVersionString;
|
||||
|
||||
QNetworkAccessManager *networkManager;
|
||||
|
||||
QMenu *fileMenu;
|
||||
QMenu *editMenu;
|
||||
QMenu *settingsMenu;
|
||||
QMenu *burnMenu;
|
||||
QMenu *helpMenu;
|
||||
QToolBar *fileToolBar;
|
||||
QToolBar *editToolBar;
|
||||
QToolBar *burnToolBar;
|
||||
QToolBar *helpToolBar;
|
||||
QAction *newAct;
|
||||
QAction *openAct;
|
||||
QAction *recentAct;
|
||||
QAction *saveAct;
|
||||
QAction *saveAsAct;
|
||||
QAction *exitAct;
|
||||
QAction *appPrefsAct;
|
||||
QAction *fwPrefsAct;
|
||||
QAction *checkForUpdatesAct;
|
||||
QAction *contributorsAct;
|
||||
QAction *sdsyncAct;
|
||||
QAction *changelogAct;
|
||||
QAction *fwchangelogAct;
|
||||
QAction *compareAct;
|
||||
QAction *editSplashAct;
|
||||
QAction *cutAct;
|
||||
QAction *copyAct;
|
||||
QAction *pasteAct;
|
||||
QAction *writeEepromAct;
|
||||
QAction *readEepromAct;
|
||||
QAction *burnConfigAct;
|
||||
QAction *burnListAct;
|
||||
QAction *burnFusesAct;
|
||||
QAction *writeFlashAct;
|
||||
QAction *readFlashAct;
|
||||
QAction *writeBackupToRadioAct;
|
||||
QAction *readBackupToFileAct;
|
||||
QAction *simulateAct;
|
||||
QAction *separatorAct;
|
||||
QAction *aboutAct;
|
||||
QAction *printAct;
|
||||
QAction *loadbackupAct;
|
||||
QAction *logsAct;
|
||||
QAction *recentFileActs[MAX_RECENT];
|
||||
QAction *profileActs[MAX_PROFILES];
|
||||
QAction *createProfileAct;
|
||||
QAction *classicThemeAct;
|
||||
QAction *yericoThemeAct;
|
||||
QAction *monoThemeAct;
|
||||
QAction *monoBlueAct;
|
||||
QAction *monoWhiteAct;
|
||||
QAction *smallIconAct;
|
||||
QAction *normalIconAct;
|
||||
QAction *bigIconAct;
|
||||
QAction *hugeIconAct;
|
||||
|
||||
QAction *sysLangAct;
|
||||
QAction *czechLangAct;
|
||||
QAction *germanLangAct;
|
||||
QAction *englishLangAct;
|
||||
QAction *finnishLangAct;
|
||||
QAction *frenchLangAct;
|
||||
QAction *italianLangAct;
|
||||
// QAction *hebrewLangAct;
|
||||
QAction *polishLangAct;
|
||||
// QAction *portugueseLangAct;
|
||||
QAction *spanishLangAct;
|
||||
QAction *swedishLangAct;
|
||||
// QAction *russianLangAct;
|
||||
// QAction *dutchLangAct;
|
||||
|
||||
QAction *openDocURLAct;
|
||||
};
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QDateTime>
|
||||
#include "downloaddialog.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#define SPLASH_TIME 5
|
||||
#define MAX_RECENT 15
|
||||
#define MAX_PROFILES 15
|
||||
|
||||
class MdiChild;
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QMenu;
|
||||
class QMdiArea;
|
||||
class QMdiSubWindow;
|
||||
class QSignalMapper;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#define CHECK_COMPANION 1
|
||||
#define CHECK_FIRMWARE 2
|
||||
#define SHOW_DIALOG_WAIT 4
|
||||
#define AUTOMATIC_DOWNLOAD 8
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
friend class FirmwarePreferencesDialog;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
protected:
|
||||
QString getCompanionUpdateBaseUrl();
|
||||
void dowloadLastFirmwareUpdate();
|
||||
void startFirmwareDownload();
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void setLanguage(const QString & langString);
|
||||
QString seekCodeString(const QByteArray & qba, const QString & label);
|
||||
|
||||
private slots:
|
||||
void openDocURL();
|
||||
|
||||
void setSysLanguage() { setLanguage(""); };
|
||||
void setCZLanguage() { setLanguage("cs_CZ"); };
|
||||
void setDELanguage() { setLanguage("de_DE"); };
|
||||
void setENLanguage() { setLanguage("en"); };
|
||||
void setFILanguage() { setLanguage("fi_FI"); };
|
||||
void setFRLanguage() { setLanguage("fr_FR"); };
|
||||
void setITLanguage() { setLanguage("it_IT"); };
|
||||
void setHELanguage() { setLanguage("he_IL"); };
|
||||
void setPLLanguage() { setLanguage("pl_PL"); };
|
||||
void setESLanguage() { setLanguage("es_ES"); };
|
||||
void setPTLanguage() { setLanguage("pt_PT"); };
|
||||
void setRULanguage() { setLanguage("ru_RU"); };
|
||||
void setSELanguage() { setLanguage("sv_SE"); };
|
||||
void setNLLanguage() { setLanguage("nl_NL"); };
|
||||
|
||||
void setTheme(int index);
|
||||
void setClassicTheme() {setTheme(0);};
|
||||
void setYericoTheme() {setTheme(1);};
|
||||
void setMonoWhiteTheme() {setTheme(2);};
|
||||
void setMonochromeTheme(){setTheme(3);};
|
||||
void setMonoBlueTheme() {setTheme(4);};
|
||||
|
||||
void setIconThemeSize(int index);
|
||||
void setSmallIconThemeSize() {setIconThemeSize(0);};
|
||||
void setNormalIconThemeSize() {setIconThemeSize(1);};
|
||||
void setBigIconThemeSize() {setIconThemeSize(2);};
|
||||
void setHugeIconThemeSize() {setIconThemeSize(3);};
|
||||
|
||||
void checkForUpdates();
|
||||
void checkForFirmwareUpdate();
|
||||
|
||||
void checkForCompanionUpdateFinished(QNetworkReply * reply);
|
||||
void checkForFirmwareUpdateFinished(QNetworkReply * reply);
|
||||
|
||||
void displayWarnings();
|
||||
void doAutoUpdates();
|
||||
void doUpdates();
|
||||
void updateDownloaded();
|
||||
void firmwareDownloadAccepted();
|
||||
void newFile();
|
||||
void openFile();
|
||||
void save();
|
||||
void saveAs();
|
||||
void cut();
|
||||
void openRecentFile();
|
||||
void loadProfile();
|
||||
void logFile();
|
||||
void copy();
|
||||
void paste();
|
||||
void writeEeprom();
|
||||
void readEeprom();
|
||||
void writeFlash(QString fileToFlash="");
|
||||
void readFlash();
|
||||
void writeBackup();
|
||||
void readBackup();
|
||||
void burnConfig();
|
||||
void burnList();
|
||||
void burnFuses();
|
||||
void simulate();
|
||||
void contributors();
|
||||
void sdsync();
|
||||
void changelog();
|
||||
void fwchangelog();
|
||||
void customizeSplash();
|
||||
void about();
|
||||
void compare();
|
||||
void print();
|
||||
void loadBackup();
|
||||
void appPrefs();
|
||||
void fwPrefs();
|
||||
void updateMenus();
|
||||
void createProfile();
|
||||
MdiChild *createMdiChild();
|
||||
void setActiveSubWindow(QWidget *window);
|
||||
QMenu * createRecentFileMenu();
|
||||
QMenu * createProfilesMenu();
|
||||
void autoClose();
|
||||
|
||||
private:
|
||||
void closeUpdatesWaitDialog();
|
||||
void onUpdatesError();
|
||||
|
||||
void createActions();
|
||||
QAction * addAct(const QString &, const QString &, const QString &, enum QKeySequence::StandardKey, const char *, QObject *slotObj=NULL);
|
||||
QAction * addAct(const QString &, const QString &, const QString &, const QKeySequence &, const char *, QObject *slotObj=NULL);
|
||||
QAction * addAct(QActionGroup *, const QString &, const QString &, const char *);
|
||||
QAction * addAct(const QString &, const QString &, const QString &, const char *);
|
||||
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
void createStatusBar();
|
||||
void updateRecentFileActions();
|
||||
void updateProfilesActions();
|
||||
void updateIconSizeActions();
|
||||
void updateLanguageActions();
|
||||
void updateIconThemeActions();
|
||||
|
||||
int getFileType(const QString & fullFileName);
|
||||
QString Theme;
|
||||
QString ISize;
|
||||
QString strippedName(const QString & fullFileName);
|
||||
|
||||
MdiChild *activeMdiChild();
|
||||
QMdiSubWindow *findMdiChild(const QString & fileName);
|
||||
int getEpromVersion(QString fileName);
|
||||
|
||||
bool readEepromFromRadio(const QString & filename);
|
||||
bool writeEepromToRadio(const QString & filename);
|
||||
bool readFirmwareFromRadio(const QString & filename);
|
||||
bool writeFirmwareToRadio(const QString & filename);
|
||||
|
||||
QMdiArea *mdiArea;
|
||||
QSignalMapper *windowMapper;
|
||||
|
||||
QString installer_fileName;
|
||||
downloadDialog * downloadDialog_forWait;
|
||||
unsigned int checkForUpdatesState;
|
||||
QString firmwareVersionString;
|
||||
|
||||
QNetworkAccessManager *networkManager;
|
||||
|
||||
QMenu *fileMenu;
|
||||
QMenu *editMenu;
|
||||
QMenu *settingsMenu;
|
||||
QMenu *burnMenu;
|
||||
QMenu *helpMenu;
|
||||
QToolBar *fileToolBar;
|
||||
QToolBar *editToolBar;
|
||||
QToolBar *burnToolBar;
|
||||
QToolBar *helpToolBar;
|
||||
QAction *newAct;
|
||||
QAction *openAct;
|
||||
QAction *recentAct;
|
||||
QAction *saveAct;
|
||||
QAction *saveAsAct;
|
||||
QAction *exitAct;
|
||||
QAction *appPrefsAct;
|
||||
QAction *fwPrefsAct;
|
||||
QAction *checkForUpdatesAct;
|
||||
QAction *contributorsAct;
|
||||
QAction *sdsyncAct;
|
||||
QAction *changelogAct;
|
||||
QAction *fwchangelogAct;
|
||||
QAction *compareAct;
|
||||
QAction *editSplashAct;
|
||||
QAction *cutAct;
|
||||
QAction *copyAct;
|
||||
QAction *pasteAct;
|
||||
QAction *writeEepromAct;
|
||||
QAction *readEepromAct;
|
||||
QAction *burnConfigAct;
|
||||
QAction *burnListAct;
|
||||
QAction *burnFusesAct;
|
||||
QAction *writeFlashAct;
|
||||
QAction *readFlashAct;
|
||||
QAction *writeBackupToRadioAct;
|
||||
QAction *readBackupToFileAct;
|
||||
QAction *simulateAct;
|
||||
QAction *separatorAct;
|
||||
QAction *aboutAct;
|
||||
QAction *printAct;
|
||||
QAction *loadbackupAct;
|
||||
QAction *logsAct;
|
||||
QAction *recentFileActs[MAX_RECENT];
|
||||
QAction *profileActs[MAX_PROFILES];
|
||||
QAction *createProfileAct;
|
||||
QAction *classicThemeAct;
|
||||
QAction *yericoThemeAct;
|
||||
QAction *monoThemeAct;
|
||||
QAction *monoBlueAct;
|
||||
QAction *monoWhiteAct;
|
||||
QAction *smallIconAct;
|
||||
QAction *normalIconAct;
|
||||
QAction *bigIconAct;
|
||||
QAction *hugeIconAct;
|
||||
|
||||
QAction *sysLangAct;
|
||||
QAction *czechLangAct;
|
||||
QAction *germanLangAct;
|
||||
QAction *englishLangAct;
|
||||
QAction *finnishLangAct;
|
||||
QAction *frenchLangAct;
|
||||
QAction *italianLangAct;
|
||||
// QAction *hebrewLangAct;
|
||||
QAction *polishLangAct;
|
||||
// QAction *portugueseLangAct;
|
||||
QAction *spanishLangAct;
|
||||
QAction *swedishLangAct;
|
||||
// QAction *russianLangAct;
|
||||
// QAction *dutchLangAct;
|
||||
|
||||
QAction *openDocURLAct;
|
||||
};
|
||||
|
||||
#endif // _MAINWINDOW_H_
|
||||
|
||||
+85
-85
@@ -20,89 +20,89 @@
|
||||
|
||||
#ifndef _MDICHILD_H_
|
||||
#define _MDICHILD_H_
|
||||
|
||||
#include <QtGui>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class mdiChild;
|
||||
}
|
||||
#define ER9X_EEPROM_FILE_TYPE "ER9X_EEPROM_FILE"
|
||||
|
||||
#define EEPE_EEPROM_FILE_HEADER "EEPE EEPROM FILE"
|
||||
#define EEPE_MODEL_FILE_HEADER "EEPE MODEL FILE"
|
||||
|
||||
class MdiChild : public QWidget
|
||||
{
|
||||
friend class ModelsListWidget;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MdiChild();
|
||||
~MdiChild();
|
||||
|
||||
void newFile();
|
||||
bool loadFile(const QString &fileName, bool resetCurrentFile=true);
|
||||
bool loadBackup();
|
||||
bool save();
|
||||
bool saveAs(bool isNew=false);
|
||||
bool saveFile(const QString &fileName, bool setCurrent=true);
|
||||
bool hasSelection();
|
||||
QString userFriendlyCurrentFile();
|
||||
QString currentFile() { return curFile; }
|
||||
// void keyPressEvent(QKeyEvent *event);
|
||||
bool hasPasteData();
|
||||
void viableModelSelected(bool viable);
|
||||
void eepromInterfaceChanged();
|
||||
void setEEpromAvail(int eavail);
|
||||
int getCurrentRow() const;
|
||||
|
||||
signals:
|
||||
void copyAvailable(bool val);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
private slots:
|
||||
void documentWasModified();
|
||||
void on_SimulateTxButton_clicked();
|
||||
void qSleep(int ms);
|
||||
|
||||
public slots:
|
||||
void checkAndInitModel(int row);
|
||||
void generalEdit();
|
||||
void modelEdit();
|
||||
void wizardEdit();
|
||||
void openEditWindow();
|
||||
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void writeEeprom();
|
||||
void simulate();
|
||||
void print(int model=-1, QString filename="");
|
||||
void setModified();
|
||||
void updateTitle();
|
||||
|
||||
private:
|
||||
bool maybeSave();
|
||||
void setCurrentFile(const QString &fileName);
|
||||
QString strippedName(const QString &fullFileName);
|
||||
void saveSelection();
|
||||
void restoreSelection();
|
||||
bool loadOtxFile(const QString &fileName, bool resetCurrentFile);
|
||||
|
||||
Ui::mdiChild *ui;
|
||||
|
||||
QString curFile;
|
||||
|
||||
Firmware * firmware;
|
||||
RadioData radioData;
|
||||
|
||||
bool isUntitled;
|
||||
bool fileChanged;
|
||||
int EEPromAvail;
|
||||
};
|
||||
|
||||
|
||||
#include <QtGui>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class mdiChild;
|
||||
}
|
||||
#define ER9X_EEPROM_FILE_TYPE "ER9X_EEPROM_FILE"
|
||||
|
||||
#define EEPE_EEPROM_FILE_HEADER "EEPE EEPROM FILE"
|
||||
#define EEPE_MODEL_FILE_HEADER "EEPE MODEL FILE"
|
||||
|
||||
class MdiChild : public QWidget
|
||||
{
|
||||
friend class ModelsListWidget;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MdiChild();
|
||||
~MdiChild();
|
||||
|
||||
void newFile();
|
||||
bool loadFile(const QString &fileName, bool resetCurrentFile=true);
|
||||
bool loadBackup();
|
||||
bool save();
|
||||
bool saveAs(bool isNew=false);
|
||||
bool saveFile(const QString &fileName, bool setCurrent=true);
|
||||
bool hasSelection();
|
||||
QString userFriendlyCurrentFile();
|
||||
QString currentFile() { return curFile; }
|
||||
// void keyPressEvent(QKeyEvent *event);
|
||||
bool hasPasteData();
|
||||
void viableModelSelected(bool viable);
|
||||
void eepromInterfaceChanged();
|
||||
void setEEpromAvail(int eavail);
|
||||
int getCurrentRow() const;
|
||||
|
||||
signals:
|
||||
void copyAvailable(bool val);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
private slots:
|
||||
void documentWasModified();
|
||||
void on_SimulateTxButton_clicked();
|
||||
void qSleep(int ms);
|
||||
|
||||
public slots:
|
||||
void checkAndInitModel(int row);
|
||||
void generalEdit();
|
||||
void modelEdit();
|
||||
void wizardEdit();
|
||||
void openEditWindow();
|
||||
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void writeEeprom();
|
||||
void simulate();
|
||||
void print(int model=-1, QString filename="");
|
||||
void setModified();
|
||||
void updateTitle();
|
||||
|
||||
private:
|
||||
bool maybeSave();
|
||||
void setCurrentFile(const QString &fileName);
|
||||
QString strippedName(const QString &fullFileName);
|
||||
void saveSelection();
|
||||
void restoreSelection();
|
||||
bool loadOtxFile(const QString &fileName, bool resetCurrentFile);
|
||||
|
||||
Ui::mdiChild *ui;
|
||||
|
||||
QString curFile;
|
||||
|
||||
Firmware * firmware;
|
||||
RadioData radioData;
|
||||
|
||||
bool isUntitled;
|
||||
bool fileChanged;
|
||||
int EEPromAvail;
|
||||
};
|
||||
|
||||
#endif // _MDICHILD_H_
|
||||
|
||||
@@ -20,49 +20,49 @@
|
||||
|
||||
#ifndef _CHANNELS_H_
|
||||
#define _CHANNELS_H_
|
||||
|
||||
#include "helpers.h"
|
||||
#include "modeledit.h"
|
||||
|
||||
class GVarGroup;
|
||||
|
||||
class LimitsGroup
|
||||
{
|
||||
public:
|
||||
LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt);
|
||||
~LimitsGroup();
|
||||
|
||||
void updateMinMax(int max);
|
||||
|
||||
protected:
|
||||
Firmware * firmware;
|
||||
QDoubleSpinBox * spinbox;
|
||||
GVarGroup * gvarGroup;
|
||||
int & value;
|
||||
double displayStep;
|
||||
};
|
||||
|
||||
class Channels : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Channels(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~Channels();
|
||||
|
||||
private:
|
||||
QVector<LimitsGroup *> limitsGroups;
|
||||
|
||||
public slots:
|
||||
void refreshExtendedLimits();
|
||||
|
||||
private slots:
|
||||
void symlimitsEdited();
|
||||
void nameEdited();
|
||||
void invEdited();
|
||||
void curveEdited();
|
||||
void ppmcenterEdited();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include "helpers.h"
|
||||
#include "modeledit.h"
|
||||
|
||||
class GVarGroup;
|
||||
|
||||
class LimitsGroup
|
||||
{
|
||||
public:
|
||||
LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt);
|
||||
~LimitsGroup();
|
||||
|
||||
void updateMinMax(int max);
|
||||
|
||||
protected:
|
||||
Firmware * firmware;
|
||||
QDoubleSpinBox * spinbox;
|
||||
GVarGroup * gvarGroup;
|
||||
int & value;
|
||||
double displayStep;
|
||||
};
|
||||
|
||||
class Channels : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Channels(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~Channels();
|
||||
|
||||
private:
|
||||
QVector<LimitsGroup *> limitsGroups;
|
||||
|
||||
public slots:
|
||||
void refreshExtendedLimits();
|
||||
|
||||
private slots:
|
||||
void symlimitsEdited();
|
||||
void nameEdited();
|
||||
void invEdited();
|
||||
void curveEdited();
|
||||
void ppmcenterEdited();
|
||||
|
||||
};
|
||||
|
||||
#endif // _CHANNELS_H_
|
||||
|
||||
@@ -20,72 +20,72 @@
|
||||
|
||||
#ifndef _CURVES_H_
|
||||
#define _CURVES_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
enum CopyAction {
|
||||
CURVE_COPY,
|
||||
CURVE_PASTE,
|
||||
CURVE_RESET,
|
||||
CURVE_RESETALL
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class Curves;
|
||||
}
|
||||
|
||||
typedef float (*curveFunction) (float x, float coeff, float yMin, float yMid, float yMax);
|
||||
|
||||
struct CurveCreatorTemplate {
|
||||
QString name;
|
||||
unsigned int flags;
|
||||
curveFunction function;
|
||||
};
|
||||
|
||||
class Curves : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Curves(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~Curves();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void editCurve();
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
void plotCurve(bool checked);
|
||||
void on_curveName_editingFinished();
|
||||
void on_curvePoints_currentIndexChanged(int index);
|
||||
void on_curveCustom_currentIndexChanged(int index);
|
||||
void on_curveSmooth_currentIndexChanged(int index);
|
||||
void onPointEdited();
|
||||
void onNodeMoved(int x, int y);
|
||||
void onNodeFocus();
|
||||
void onNodeUnfocus();
|
||||
void on_curveType_currentIndexChanged(int index);
|
||||
void on_curveApply_clicked();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
void addTemplate(QString name, unsigned int flags, curveFunction function);
|
||||
|
||||
private:
|
||||
Ui::Curves *ui;
|
||||
int currentCurve;
|
||||
bool visibleCurves[CPN_MAX_CURVES];
|
||||
QSpinBox * spnx[CPN_MAX_POINTS];
|
||||
QSpinBox * spny[CPN_MAX_POINTS];
|
||||
QVector<CurveCreatorTemplate> templates;
|
||||
void setCurrentCurve(int index);
|
||||
void updateCurve();
|
||||
void updateCurveType();
|
||||
void updateCurvePoints();
|
||||
bool allowCurveType(int points, CurveData::CurveType type);
|
||||
void setPointY(int i, int x, int y);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
enum CopyAction {
|
||||
CURVE_COPY,
|
||||
CURVE_PASTE,
|
||||
CURVE_RESET,
|
||||
CURVE_RESETALL
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class Curves;
|
||||
}
|
||||
|
||||
typedef float (*curveFunction) (float x, float coeff, float yMin, float yMid, float yMax);
|
||||
|
||||
struct CurveCreatorTemplate {
|
||||
QString name;
|
||||
unsigned int flags;
|
||||
curveFunction function;
|
||||
};
|
||||
|
||||
class Curves : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Curves(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~Curves();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void editCurve();
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
void plotCurve(bool checked);
|
||||
void on_curveName_editingFinished();
|
||||
void on_curvePoints_currentIndexChanged(int index);
|
||||
void on_curveCustom_currentIndexChanged(int index);
|
||||
void on_curveSmooth_currentIndexChanged(int index);
|
||||
void onPointEdited();
|
||||
void onNodeMoved(int x, int y);
|
||||
void onNodeFocus();
|
||||
void onNodeUnfocus();
|
||||
void on_curveType_currentIndexChanged(int index);
|
||||
void on_curveApply_clicked();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
void addTemplate(QString name, unsigned int flags, curveFunction function);
|
||||
|
||||
private:
|
||||
Ui::Curves *ui;
|
||||
int currentCurve;
|
||||
bool visibleCurves[CPN_MAX_CURVES];
|
||||
QSpinBox * spnx[CPN_MAX_POINTS];
|
||||
QSpinBox * spny[CPN_MAX_POINTS];
|
||||
QVector<CurveCreatorTemplate> templates;
|
||||
void setCurrentCurve(int index);
|
||||
void updateCurve();
|
||||
void updateCurveType();
|
||||
void updateCurvePoints();
|
||||
bool allowCurveType(int points, CurveData::CurveType type);
|
||||
void setPointY(int i, int x, int y);
|
||||
|
||||
};
|
||||
|
||||
#endif // _CURVES_H_
|
||||
|
||||
@@ -20,80 +20,80 @@
|
||||
|
||||
#ifndef _CUSTOMFUNCTIONS_H_
|
||||
#define _CUSTOMFUNCTIONS_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
#include <QtMultimedia>
|
||||
|
||||
class RepeatComboBox: public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RepeatComboBox(QWidget * parent, int & repeatParam);
|
||||
void update();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void onIndexChanged(int);
|
||||
|
||||
protected:
|
||||
int & repeatParam;
|
||||
};
|
||||
|
||||
class CustomFunctionsPanel : public GenericPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomFunctionsPanel(QWidget *parent, ModelData * mode, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~CustomFunctionsPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
CustomFunctionData * functions;
|
||||
|
||||
private slots:
|
||||
void customFunctionEdited();
|
||||
void functionEdited();
|
||||
void fsw_customContextMenuRequested(QPoint pos);
|
||||
void refreshCustomFunction(int index, bool modified=false);
|
||||
void onChildModified();
|
||||
void playMusic();
|
||||
void onMediaPlayerStateChanged(QMediaPlayer::State state);
|
||||
void onMediaPlayerError(QMediaPlayer::Error error);
|
||||
void fswDelete();
|
||||
void fswCopy();
|
||||
void fswPaste();
|
||||
void fswCut();
|
||||
|
||||
private:
|
||||
void populateFuncCB(QComboBox *b, unsigned int value);
|
||||
void populateGVmodeCB(QComboBox *b, unsigned int value);
|
||||
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
|
||||
|
||||
QSet<QString> tracksSet;
|
||||
QSet<QString> scriptsSet;
|
||||
int mediaPlayerCurrent;
|
||||
QComboBox * fswtchSwtch[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchFunc[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QCheckBox * fswtchParamGV[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QDoubleSpinBox * fswtchParam[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QTimeEdit * fswtchParamTime[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QPushButton * playBT[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchParamT[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchParamArmT[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QCheckBox * fswtchEnable[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
RepeatComboBox * fswtchRepeat[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchGVmode[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QSlider * fswtchBLcolor[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QMediaPlayer * mediaPlayer;
|
||||
|
||||
int selectedFunction;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
#include <QtMultimedia>
|
||||
|
||||
class RepeatComboBox: public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RepeatComboBox(QWidget * parent, int & repeatParam);
|
||||
void update();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void onIndexChanged(int);
|
||||
|
||||
protected:
|
||||
int & repeatParam;
|
||||
};
|
||||
|
||||
class CustomFunctionsPanel : public GenericPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomFunctionsPanel(QWidget *parent, ModelData * mode, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~CustomFunctionsPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
CustomFunctionData * functions;
|
||||
|
||||
private slots:
|
||||
void customFunctionEdited();
|
||||
void functionEdited();
|
||||
void fsw_customContextMenuRequested(QPoint pos);
|
||||
void refreshCustomFunction(int index, bool modified=false);
|
||||
void onChildModified();
|
||||
void playMusic();
|
||||
void onMediaPlayerStateChanged(QMediaPlayer::State state);
|
||||
void onMediaPlayerError(QMediaPlayer::Error error);
|
||||
void fswDelete();
|
||||
void fswCopy();
|
||||
void fswPaste();
|
||||
void fswCut();
|
||||
|
||||
private:
|
||||
void populateFuncCB(QComboBox *b, unsigned int value);
|
||||
void populateGVmodeCB(QComboBox *b, unsigned int value);
|
||||
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
|
||||
|
||||
QSet<QString> tracksSet;
|
||||
QSet<QString> scriptsSet;
|
||||
int mediaPlayerCurrent;
|
||||
QComboBox * fswtchSwtch[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchFunc[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QCheckBox * fswtchParamGV[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QDoubleSpinBox * fswtchParam[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QTimeEdit * fswtchParamTime[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QPushButton * playBT[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchParamT[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchParamArmT[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QCheckBox * fswtchEnable[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
RepeatComboBox * fswtchRepeat[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QComboBox * fswtchGVmode[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QSlider * fswtchBLcolor[CPN_MAX_CUSTOM_FUNCTIONS];
|
||||
QMediaPlayer * mediaPlayer;
|
||||
|
||||
int selectedFunction;
|
||||
|
||||
};
|
||||
|
||||
#endif // _CUSTOMFUNCTIONS_H_
|
||||
|
||||
@@ -18,92 +18,92 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
Edge::Edge(Node *sourceNode, Node *destNode)
|
||||
: arrowSize(10)
|
||||
{
|
||||
setAcceptedMouseButtons(0);
|
||||
source = sourceNode;
|
||||
dest = destNode;
|
||||
source->addEdge(this);
|
||||
dest->addEdge(this);
|
||||
adjust();
|
||||
}
|
||||
|
||||
Edge::~Edge()
|
||||
{
|
||||
}
|
||||
|
||||
Node *Edge::sourceNode() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
void Edge::setSourceNode(Node *node)
|
||||
{
|
||||
source = node;
|
||||
adjust();
|
||||
}
|
||||
|
||||
Node *Edge::destNode() const
|
||||
{
|
||||
return dest;
|
||||
}
|
||||
|
||||
void Edge::setDestNode(Node *node)
|
||||
{
|
||||
dest = node;
|
||||
adjust();
|
||||
}
|
||||
|
||||
void Edge::adjust()
|
||||
{
|
||||
if (!source || !dest)
|
||||
return;
|
||||
|
||||
QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
|
||||
qreal length = line.length();
|
||||
prepareGeometryChange();
|
||||
int ballSize = source->getBallSize();
|
||||
if (length > qreal(ballSize)) {
|
||||
QPointF edgeOffset((line.dx() * ballSize / 2) / length, (line.dy() * ballSize / 2) / length);
|
||||
sourcePoint = line.p1() + edgeOffset;
|
||||
destPoint = line.p2() - edgeOffset;
|
||||
} else {
|
||||
sourcePoint = destPoint = line.p1();
|
||||
}
|
||||
}
|
||||
|
||||
QRectF Edge::boundingRect() const
|
||||
{
|
||||
if (!source || !dest)
|
||||
return QRectF();
|
||||
|
||||
qreal penWidth = 1;
|
||||
qreal extra = (penWidth + arrowSize) / 2.0;
|
||||
|
||||
return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(),
|
||||
destPoint.y() - sourcePoint.y()))
|
||||
.normalized()
|
||||
.adjusted(-extra, -extra, extra, extra);
|
||||
}
|
||||
|
||||
void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
{
|
||||
if (!source || !dest)
|
||||
return;
|
||||
|
||||
QLineF line(sourcePoint, destPoint);
|
||||
if (qFuzzyCompare(line.length(), qreal(0.)))
|
||||
return;
|
||||
|
||||
// Draw the line itself
|
||||
painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
painter->drawLine(line);
|
||||
}
|
||||
#include <QPainter>
|
||||
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
Edge::Edge(Node *sourceNode, Node *destNode)
|
||||
: arrowSize(10)
|
||||
{
|
||||
setAcceptedMouseButtons(0);
|
||||
source = sourceNode;
|
||||
dest = destNode;
|
||||
source->addEdge(this);
|
||||
dest->addEdge(this);
|
||||
adjust();
|
||||
}
|
||||
|
||||
Edge::~Edge()
|
||||
{
|
||||
}
|
||||
|
||||
Node *Edge::sourceNode() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
void Edge::setSourceNode(Node *node)
|
||||
{
|
||||
source = node;
|
||||
adjust();
|
||||
}
|
||||
|
||||
Node *Edge::destNode() const
|
||||
{
|
||||
return dest;
|
||||
}
|
||||
|
||||
void Edge::setDestNode(Node *node)
|
||||
{
|
||||
dest = node;
|
||||
adjust();
|
||||
}
|
||||
|
||||
void Edge::adjust()
|
||||
{
|
||||
if (!source || !dest)
|
||||
return;
|
||||
|
||||
QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
|
||||
qreal length = line.length();
|
||||
prepareGeometryChange();
|
||||
int ballSize = source->getBallSize();
|
||||
if (length > qreal(ballSize)) {
|
||||
QPointF edgeOffset((line.dx() * ballSize / 2) / length, (line.dy() * ballSize / 2) / length);
|
||||
sourcePoint = line.p1() + edgeOffset;
|
||||
destPoint = line.p2() - edgeOffset;
|
||||
} else {
|
||||
sourcePoint = destPoint = line.p1();
|
||||
}
|
||||
}
|
||||
|
||||
QRectF Edge::boundingRect() const
|
||||
{
|
||||
if (!source || !dest)
|
||||
return QRectF();
|
||||
|
||||
qreal penWidth = 1;
|
||||
qreal extra = (penWidth + arrowSize) / 2.0;
|
||||
|
||||
return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(),
|
||||
destPoint.y() - sourcePoint.y()))
|
||||
.normalized()
|
||||
.adjusted(-extra, -extra, extra, extra);
|
||||
}
|
||||
|
||||
void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
{
|
||||
if (!source || !dest)
|
||||
return;
|
||||
|
||||
QLineF line(sourcePoint, destPoint);
|
||||
if (qFuzzyCompare(line.length(), qreal(0.)))
|
||||
return;
|
||||
|
||||
// Draw the line itself
|
||||
painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
painter->drawLine(line);
|
||||
}
|
||||
|
||||
@@ -20,38 +20,38 @@
|
||||
|
||||
#ifndef _EDGE_H_
|
||||
#define _EDGE_H_
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
class Node;
|
||||
|
||||
class Edge : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
Edge(Node *sourceNode, Node *destNode);
|
||||
~Edge();
|
||||
|
||||
Node *sourceNode() const;
|
||||
void setSourceNode(Node *node);
|
||||
|
||||
Node *destNode() const;
|
||||
void setDestNode(Node *node);
|
||||
|
||||
void adjust();
|
||||
|
||||
enum { Type = UserType + 2 };
|
||||
int type() const { return Type; }
|
||||
|
||||
protected:
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
private:
|
||||
Node *source, *dest;
|
||||
|
||||
QPointF sourcePoint;
|
||||
QPointF destPoint;
|
||||
qreal arrowSize;
|
||||
};
|
||||
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
class Node;
|
||||
|
||||
class Edge : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
Edge(Node *sourceNode, Node *destNode);
|
||||
~Edge();
|
||||
|
||||
Node *sourceNode() const;
|
||||
void setSourceNode(Node *node);
|
||||
|
||||
Node *destNode() const;
|
||||
void setDestNode(Node *node);
|
||||
|
||||
void adjust();
|
||||
|
||||
enum { Type = UserType + 2 };
|
||||
int type() const { return Type; }
|
||||
|
||||
protected:
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
private:
|
||||
Node *source, *dest;
|
||||
|
||||
QPointF sourcePoint;
|
||||
QPointF destPoint;
|
||||
qreal arrowSize;
|
||||
};
|
||||
|
||||
#endif // _EDGE_H_
|
||||
|
||||
@@ -20,87 +20,87 @@
|
||||
|
||||
#ifndef _FLIGHTMODES_H_
|
||||
#define _FLIGHTMODES_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class FlightMode;
|
||||
}
|
||||
|
||||
class FlightModePanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~FlightModePanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void nameModified();
|
||||
|
||||
private slots:
|
||||
void phaseName_editingFinished();
|
||||
void phaseSwitch_currentIndexChanged(int index);
|
||||
void phaseFadeIn_editingFinished();
|
||||
void phaseFadeOut_editingFinished();
|
||||
void phaseTrimUse_currentIndexChanged(int index);
|
||||
void phaseTrim_valueChanged();
|
||||
void phaseTrimSlider_valueChanged();
|
||||
void GVName_editingFinished();
|
||||
void phaseGVValue_editingFinished();
|
||||
void phaseGVUse_currentIndexChanged(int index);
|
||||
void phaseGVPopupToggled(bool checked);
|
||||
void phaseREValue_editingFinished();
|
||||
void phaseREUse_currentIndexChanged(int index);
|
||||
void name_customContextMenuRequested(const QPoint & pos);
|
||||
void fmClear();
|
||||
|
||||
private:
|
||||
Ui::FlightMode *ui;
|
||||
int phaseIdx;
|
||||
FlightModeData & phase;
|
||||
int reCount;
|
||||
int gvCount;
|
||||
QVector<QLabel *> trimsLabel;
|
||||
QLineEdit * gvNames[CPN_MAX_GVARS];
|
||||
QSpinBox * gvValues[CPN_MAX_GVARS];
|
||||
QCheckBox * gvPopups[CPN_MAX_GVARS];
|
||||
QComboBox * gvUse[CPN_MAX_GVARS];
|
||||
QSpinBox * reValues[CPN_MAX_ENCODERS];
|
||||
QComboBox * reUse[CPN_MAX_ENCODERS];
|
||||
QVector<QComboBox *> trimsUse;
|
||||
QVector<QSpinBox *> trimsValue;
|
||||
QVector<QSlider *> trimsSlider;
|
||||
|
||||
void trimUpdate(unsigned int trim);
|
||||
|
||||
};
|
||||
|
||||
class FlightModesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~FlightModesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void onPhaseModified();
|
||||
void onPhaseNameChanged();
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
private:
|
||||
int modesCount;
|
||||
QTabWidget *tabWidget;
|
||||
QString getTabName(int index);
|
||||
QVector<FlightModePanel *> panels;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class FlightMode;
|
||||
}
|
||||
|
||||
class FlightModePanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~FlightModePanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void nameModified();
|
||||
|
||||
private slots:
|
||||
void phaseName_editingFinished();
|
||||
void phaseSwitch_currentIndexChanged(int index);
|
||||
void phaseFadeIn_editingFinished();
|
||||
void phaseFadeOut_editingFinished();
|
||||
void phaseTrimUse_currentIndexChanged(int index);
|
||||
void phaseTrim_valueChanged();
|
||||
void phaseTrimSlider_valueChanged();
|
||||
void GVName_editingFinished();
|
||||
void phaseGVValue_editingFinished();
|
||||
void phaseGVUse_currentIndexChanged(int index);
|
||||
void phaseGVPopupToggled(bool checked);
|
||||
void phaseREValue_editingFinished();
|
||||
void phaseREUse_currentIndexChanged(int index);
|
||||
void name_customContextMenuRequested(const QPoint & pos);
|
||||
void fmClear();
|
||||
|
||||
private:
|
||||
Ui::FlightMode *ui;
|
||||
int phaseIdx;
|
||||
FlightModeData & phase;
|
||||
int reCount;
|
||||
int gvCount;
|
||||
QVector<QLabel *> trimsLabel;
|
||||
QLineEdit * gvNames[CPN_MAX_GVARS];
|
||||
QSpinBox * gvValues[CPN_MAX_GVARS];
|
||||
QCheckBox * gvPopups[CPN_MAX_GVARS];
|
||||
QComboBox * gvUse[CPN_MAX_GVARS];
|
||||
QSpinBox * reValues[CPN_MAX_ENCODERS];
|
||||
QComboBox * reUse[CPN_MAX_ENCODERS];
|
||||
QVector<QComboBox *> trimsUse;
|
||||
QVector<QSpinBox *> trimsValue;
|
||||
QVector<QSlider *> trimsSlider;
|
||||
|
||||
void trimUpdate(unsigned int trim);
|
||||
|
||||
};
|
||||
|
||||
class FlightModesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~FlightModesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void onPhaseModified();
|
||||
void onPhaseNameChanged();
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
private:
|
||||
int modesCount;
|
||||
QTabWidget *tabWidget;
|
||||
QString getTabName(int index);
|
||||
QVector<FlightModePanel *> panels;
|
||||
|
||||
};
|
||||
|
||||
#endif // _FLIGHTMODES_H_
|
||||
|
||||
|
||||
|
||||
@@ -20,27 +20,27 @@
|
||||
|
||||
#ifndef _HELI_H_
|
||||
#define _HELI_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
|
||||
namespace Ui {
|
||||
class Heli;
|
||||
}
|
||||
|
||||
class HeliPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~HeliPanel();
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
void edited();
|
||||
|
||||
private:
|
||||
Ui::Heli *ui;
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
|
||||
namespace Ui {
|
||||
class Heli;
|
||||
}
|
||||
|
||||
class HeliPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~HeliPanel();
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
void edited();
|
||||
|
||||
private:
|
||||
Ui::Heli *ui;
|
||||
};
|
||||
|
||||
#endif // _HELI_H_
|
||||
|
||||
@@ -20,56 +20,56 @@
|
||||
|
||||
#ifndef _INPUTS_H_
|
||||
#define _INPUTS_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "mixerslist.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class InputsPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~InputsPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void clearExpos();
|
||||
void moveExpoUp();
|
||||
void moveExpoDown();
|
||||
void mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction action);
|
||||
void expolistWidget_customContextMenuRequested(QPoint pos);
|
||||
void expolistWidget_doubleClicked(QModelIndex index);
|
||||
void expolistWidget_KeyPress(QKeyEvent *event);
|
||||
void exposDelete(bool ask=true);
|
||||
void exposCut();
|
||||
void exposCopy();
|
||||
void exposPaste();
|
||||
void exposDuplicate();
|
||||
void expoOpen(QListWidgetItem *item = NULL);
|
||||
void expoAdd();
|
||||
|
||||
private:
|
||||
bool expoInserted;
|
||||
MixersList *ExposlistWidget;
|
||||
bool firstLine;
|
||||
int inputsCount;
|
||||
ModelPrinter modelPrinter;
|
||||
|
||||
int getExpoIndex(unsigned int dch);
|
||||
bool gm_insertExpo(int idx);
|
||||
void gm_deleteExpo(int index);
|
||||
void gm_openExpo(int index);
|
||||
int gm_moveExpo(int idx, bool dir);
|
||||
void exposDeleteList(QList<int> list);
|
||||
QList<int> createExpoListFromSelected();
|
||||
void setSelectedByExpoList(QList<int> list);
|
||||
void pasteExpoMimeData(const QMimeData * mimeData, int destIdx);
|
||||
bool AddInputLine(int dest);
|
||||
QString getInputText(int dest, bool * new_ch);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "mixerslist.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class InputsPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~InputsPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void clearExpos();
|
||||
void moveExpoUp();
|
||||
void moveExpoDown();
|
||||
void mimeExpoDropped(int index, const QMimeData *data, Qt::DropAction action);
|
||||
void expolistWidget_customContextMenuRequested(QPoint pos);
|
||||
void expolistWidget_doubleClicked(QModelIndex index);
|
||||
void expolistWidget_KeyPress(QKeyEvent *event);
|
||||
void exposDelete(bool ask=true);
|
||||
void exposCut();
|
||||
void exposCopy();
|
||||
void exposPaste();
|
||||
void exposDuplicate();
|
||||
void expoOpen(QListWidgetItem *item = NULL);
|
||||
void expoAdd();
|
||||
|
||||
private:
|
||||
bool expoInserted;
|
||||
MixersList *ExposlistWidget;
|
||||
bool firstLine;
|
||||
int inputsCount;
|
||||
ModelPrinter modelPrinter;
|
||||
|
||||
int getExpoIndex(unsigned int dch);
|
||||
bool gm_insertExpo(int idx);
|
||||
void gm_deleteExpo(int index);
|
||||
void gm_openExpo(int index);
|
||||
int gm_moveExpo(int idx, bool dir);
|
||||
void exposDeleteList(QList<int> list);
|
||||
QList<int> createExpoListFromSelected();
|
||||
void setSelectedByExpoList(QList<int> list);
|
||||
void pasteExpoMimeData(const QMimeData * mimeData, int destIdx);
|
||||
bool AddInputLine(int dest);
|
||||
QString getInputText(int dest, bool * new_ch);
|
||||
|
||||
};
|
||||
|
||||
#endif // _INPUTS_H_
|
||||
|
||||
@@ -20,52 +20,52 @@
|
||||
|
||||
#ifndef _LOGICALSWITCHES_H_
|
||||
#define _LOGICALSWITCHES_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
class LogicalSwitchesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~LogicalSwitchesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void edited();
|
||||
void v1Edited(int value);
|
||||
void v2Edited(int value);
|
||||
void andEdited(int value);
|
||||
void durationEdited(double duration);
|
||||
void delayEdited(double delay);
|
||||
void csw_customContextMenuRequested(QPoint pos);
|
||||
void cswDelete();
|
||||
void cswCopy();
|
||||
void cswPaste();
|
||||
void cswCut();
|
||||
|
||||
private:
|
||||
QComboBox * csw[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchValue[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchOffset[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchOffset2[CPN_MAX_CSW];
|
||||
QTimeEdit * cswitchTOffset[CPN_MAX_CSW];
|
||||
QComboBox * cswitchAnd[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchDuration[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchDelay[CPN_MAX_CSW];
|
||||
QComboBox * cswitchSource1[CPN_MAX_CSW];
|
||||
QComboBox * cswitchSource2[CPN_MAX_CSW];
|
||||
void setSwitchWidgetVisibility(int i);
|
||||
int selectedSwitch;
|
||||
|
||||
void populateCSWCB(QComboBox *b, int value);
|
||||
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value);
|
||||
void updateLine(int index);
|
||||
void updateTimerParam(QDoubleSpinBox *sb, int timer, double minimum=0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
class LogicalSwitchesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~LogicalSwitchesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void edited();
|
||||
void v1Edited(int value);
|
||||
void v2Edited(int value);
|
||||
void andEdited(int value);
|
||||
void durationEdited(double duration);
|
||||
void delayEdited(double delay);
|
||||
void csw_customContextMenuRequested(QPoint pos);
|
||||
void cswDelete();
|
||||
void cswCopy();
|
||||
void cswPaste();
|
||||
void cswCut();
|
||||
|
||||
private:
|
||||
QComboBox * csw[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchValue[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchOffset[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchOffset2[CPN_MAX_CSW];
|
||||
QTimeEdit * cswitchTOffset[CPN_MAX_CSW];
|
||||
QComboBox * cswitchAnd[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchDuration[CPN_MAX_CSW];
|
||||
QDoubleSpinBox * cswitchDelay[CPN_MAX_CSW];
|
||||
QComboBox * cswitchSource1[CPN_MAX_CSW];
|
||||
QComboBox * cswitchSource2[CPN_MAX_CSW];
|
||||
void setSwitchWidgetVisibility(int i);
|
||||
int selectedSwitch;
|
||||
|
||||
void populateCSWCB(QComboBox *b, int value);
|
||||
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value);
|
||||
void updateLine(int index);
|
||||
void updateTimerParam(QDoubleSpinBox *sb, int timer, double minimum=0);
|
||||
|
||||
};
|
||||
|
||||
#endif // _LOGICALSWITCHES_H_
|
||||
|
||||
@@ -18,142 +18,142 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "mixerslist.h"
|
||||
|
||||
MixersList::MixersList(QWidget *parent, bool expo) :
|
||||
QListWidget(parent),
|
||||
expo(expo)
|
||||
{
|
||||
setFont(QFont("Courier New",12));
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
setDragEnabled(true);
|
||||
setAcceptDrops(true);
|
||||
setDropIndicatorShown(true);
|
||||
setItemDelegate(new MixersDelegate(parent)); //set custom paint handler
|
||||
}
|
||||
|
||||
void MixersList::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
emit keyWasPressed(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief Override to give us different mime type for mixers and inputs
|
||||
*/
|
||||
QStringList MixersList::mimeTypes () const
|
||||
{
|
||||
QStringList types;
|
||||
if (expo) types << "application/x-companion-expo-item";
|
||||
else types << "application/x-companion-mix-item";
|
||||
return types;
|
||||
}
|
||||
|
||||
void MixersList::dropEvent(QDropEvent *event)
|
||||
{
|
||||
QList<int> list;
|
||||
foreach(QListWidgetItem *item, selectedItems()) {
|
||||
int idx= item->data(Qt::UserRole).toByteArray().at(0);
|
||||
if(idx >= 0) list << idx;
|
||||
}
|
||||
if (list.count()<1) return;
|
||||
event->acceptProposedAction();
|
||||
dropMimeData(indexAt(event->pos()).row(),event->mimeData(),event->dropAction());
|
||||
}
|
||||
|
||||
bool MixersList::dropMimeData( int index, const QMimeData * data, Qt::DropAction action )
|
||||
{
|
||||
// qDebug() << "MixersList::dropMimeData() index:" << index << "formats" << data->formats();
|
||||
QByteArray dropData = data->data(expo ? "application/x-companion-expo-item" : "application/x-companion-mix-item");
|
||||
if (dropData.isNull() ) return false;
|
||||
QDataStream stream(&dropData, QIODevice::ReadOnly);
|
||||
QByteArray qba;
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
int r,c;
|
||||
QMap<int, QVariant> v;
|
||||
stream >> r >> c >> v;
|
||||
QList<QVariant> lsVars;
|
||||
lsVars = v.values();
|
||||
qba.append(lsVars.at(1).toByteArray().mid(1));
|
||||
// qDebug() << "MixersList::dropMimeData() added" << lsVars.count() << "items, data:" << lsVars;
|
||||
}
|
||||
|
||||
if(qba.length()>0) {
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
mimeData->setData(expo ? "application/x-companion-expo" : "application/x-companion-mix", qba);
|
||||
emit mimeDropped(index, mimeData, action);
|
||||
delete mimeData; //is this correct? is mimeData freed elswere??
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Paints our HTML formated list item text
|
||||
*/
|
||||
void MixersDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItem options = option;
|
||||
initStyleOption(&options, index);
|
||||
|
||||
painter->save();
|
||||
|
||||
//setup html document
|
||||
QTextDocument doc;
|
||||
SetupDocument(doc, options);
|
||||
|
||||
options.text = "";
|
||||
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
|
||||
|
||||
if ( index.model()->data(index, GroupHeaderRole).toInt() > 0 ) {
|
||||
//paint with added space
|
||||
painter->translate(options.rect.left(), options.rect.top() + MIX_ROW_HEIGHT_INCREASE);
|
||||
QRect clip(0, 0, options.rect.width(), options.rect.height() - MIX_ROW_HEIGHT_INCREASE);
|
||||
doc.drawContents(painter, clip);
|
||||
}
|
||||
else {
|
||||
painter->translate(options.rect.left(), options.rect.top());
|
||||
QRect clip(0, 0, options.rect.width(), options.rect.height());
|
||||
doc.drawContents(painter, clip);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief Returns needed size for our HTML formated list item text
|
||||
*/
|
||||
QSize MixersDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
|
||||
{
|
||||
QStyleOptionViewItem options = option;
|
||||
initStyleOption(&options, index);
|
||||
|
||||
//setup html document
|
||||
QTextDocument doc;
|
||||
SetupDocument(doc, options);
|
||||
|
||||
//qDebug() << "MixersDelegate::sizeHint() UserRole-> " << index.model()->data(index, Qt::UserRole + 2);
|
||||
int height = doc.size().height();
|
||||
if ( index.model()->data(index, Qt::UserRole + 2).toInt() > 0 ) {
|
||||
//qDebug() << "MixersDelegate::sizeHint() detected channel head";
|
||||
height = doc.size().height() + MIX_ROW_HEIGHT_INCREASE;
|
||||
}
|
||||
//qDebug() << "MixersDelegate::sizeHint() options.rect " << options.rect;
|
||||
//qDebug() << "MixersDelegate::sizeHint() result " << QSize(doc.idealWidth(), height) << options.rect.width();
|
||||
return QSize(doc.idealWidth(), height);
|
||||
}
|
||||
|
||||
void MixersDelegate::SetupDocument(QTextDocument & doc, const QStyleOptionViewItem & options) const
|
||||
{
|
||||
//setup html document
|
||||
doc.setHtml(options.text);
|
||||
doc.setDefaultFont(options.font);
|
||||
|
||||
//minimize margins (default margins look ugly)
|
||||
QTextFrame *tf = doc.rootFrame();
|
||||
QTextFrameFormat tff = tf->frameFormat();
|
||||
tff.setMargin(0);
|
||||
tf->setFrameFormat(tff);
|
||||
}
|
||||
#include "mixerslist.h"
|
||||
|
||||
MixersList::MixersList(QWidget *parent, bool expo) :
|
||||
QListWidget(parent),
|
||||
expo(expo)
|
||||
{
|
||||
setFont(QFont("Courier New",12));
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
setDragEnabled(true);
|
||||
setAcceptDrops(true);
|
||||
setDropIndicatorShown(true);
|
||||
setItemDelegate(new MixersDelegate(parent)); //set custom paint handler
|
||||
}
|
||||
|
||||
void MixersList::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
emit keyWasPressed(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief Override to give us different mime type for mixers and inputs
|
||||
*/
|
||||
QStringList MixersList::mimeTypes () const
|
||||
{
|
||||
QStringList types;
|
||||
if (expo) types << "application/x-companion-expo-item";
|
||||
else types << "application/x-companion-mix-item";
|
||||
return types;
|
||||
}
|
||||
|
||||
void MixersList::dropEvent(QDropEvent *event)
|
||||
{
|
||||
QList<int> list;
|
||||
foreach(QListWidgetItem *item, selectedItems()) {
|
||||
int idx= item->data(Qt::UserRole).toByteArray().at(0);
|
||||
if(idx >= 0) list << idx;
|
||||
}
|
||||
if (list.count()<1) return;
|
||||
event->acceptProposedAction();
|
||||
dropMimeData(indexAt(event->pos()).row(),event->mimeData(),event->dropAction());
|
||||
}
|
||||
|
||||
bool MixersList::dropMimeData( int index, const QMimeData * data, Qt::DropAction action )
|
||||
{
|
||||
// qDebug() << "MixersList::dropMimeData() index:" << index << "formats" << data->formats();
|
||||
QByteArray dropData = data->data(expo ? "application/x-companion-expo-item" : "application/x-companion-mix-item");
|
||||
if (dropData.isNull() ) return false;
|
||||
QDataStream stream(&dropData, QIODevice::ReadOnly);
|
||||
QByteArray qba;
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
int r,c;
|
||||
QMap<int, QVariant> v;
|
||||
stream >> r >> c >> v;
|
||||
QList<QVariant> lsVars;
|
||||
lsVars = v.values();
|
||||
qba.append(lsVars.at(1).toByteArray().mid(1));
|
||||
// qDebug() << "MixersList::dropMimeData() added" << lsVars.count() << "items, data:" << lsVars;
|
||||
}
|
||||
|
||||
if(qba.length()>0) {
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
mimeData->setData(expo ? "application/x-companion-expo" : "application/x-companion-mix", qba);
|
||||
emit mimeDropped(index, mimeData, action);
|
||||
delete mimeData; //is this correct? is mimeData freed elswere??
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Paints our HTML formated list item text
|
||||
*/
|
||||
void MixersDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItem options = option;
|
||||
initStyleOption(&options, index);
|
||||
|
||||
painter->save();
|
||||
|
||||
//setup html document
|
||||
QTextDocument doc;
|
||||
SetupDocument(doc, options);
|
||||
|
||||
options.text = "";
|
||||
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
|
||||
|
||||
if ( index.model()->data(index, GroupHeaderRole).toInt() > 0 ) {
|
||||
//paint with added space
|
||||
painter->translate(options.rect.left(), options.rect.top() + MIX_ROW_HEIGHT_INCREASE);
|
||||
QRect clip(0, 0, options.rect.width(), options.rect.height() - MIX_ROW_HEIGHT_INCREASE);
|
||||
doc.drawContents(painter, clip);
|
||||
}
|
||||
else {
|
||||
painter->translate(options.rect.left(), options.rect.top());
|
||||
QRect clip(0, 0, options.rect.width(), options.rect.height());
|
||||
doc.drawContents(painter, clip);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief Returns needed size for our HTML formated list item text
|
||||
*/
|
||||
QSize MixersDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
|
||||
{
|
||||
QStyleOptionViewItem options = option;
|
||||
initStyleOption(&options, index);
|
||||
|
||||
//setup html document
|
||||
QTextDocument doc;
|
||||
SetupDocument(doc, options);
|
||||
|
||||
//qDebug() << "MixersDelegate::sizeHint() UserRole-> " << index.model()->data(index, Qt::UserRole + 2);
|
||||
int height = doc.size().height();
|
||||
if ( index.model()->data(index, Qt::UserRole + 2).toInt() > 0 ) {
|
||||
//qDebug() << "MixersDelegate::sizeHint() detected channel head";
|
||||
height = doc.size().height() + MIX_ROW_HEIGHT_INCREASE;
|
||||
}
|
||||
//qDebug() << "MixersDelegate::sizeHint() options.rect " << options.rect;
|
||||
//qDebug() << "MixersDelegate::sizeHint() result " << QSize(doc.idealWidth(), height) << options.rect.width();
|
||||
return QSize(doc.idealWidth(), height);
|
||||
}
|
||||
|
||||
void MixersDelegate::SetupDocument(QTextDocument & doc, const QStyleOptionViewItem & options) const
|
||||
{
|
||||
//setup html document
|
||||
doc.setHtml(options.text);
|
||||
doc.setDefaultFont(options.font);
|
||||
|
||||
//minimize margins (default margins look ugly)
|
||||
QTextFrame *tf = doc.rootFrame();
|
||||
QTextFrameFormat tff = tf->frameFormat();
|
||||
tff.setMargin(0);
|
||||
tf->setFrameFormat(tff);
|
||||
}
|
||||
|
||||
@@ -20,54 +20,54 @@
|
||||
|
||||
#ifndef _MIXERSLIST_H_
|
||||
#define _MIXERSLIST_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#define MIX_ROW_HEIGHT_INCREASE 8 //how much space is added above mixer row (for new channel), if 0 space adding is disabled
|
||||
const int GroupHeaderRole = (Qt::UserRole+2); //defines new user role for list items. If value is > 0, then space is added before that item
|
||||
|
||||
class MixersList : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MixersList(QWidget *parent, bool expo);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
|
||||
signals:
|
||||
void mimeDropped(int index, const QMimeData *data, Qt::DropAction action);
|
||||
void keyWasPressed(QKeyEvent *event);
|
||||
|
||||
public slots:
|
||||
bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);
|
||||
|
||||
protected:
|
||||
virtual QStringList mimeTypes() const;
|
||||
|
||||
private:
|
||||
QPoint dragStartPosition;
|
||||
bool expo;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Provides sizing and painting of items for our mixes and inputs lists
|
||||
|
||||
This class draws HTML formated strings into QListWidget class
|
||||
*/
|
||||
class MixersDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
inline MixersDelegate(QObject *parent) : QStyledItemDelegate(parent) {};
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
|
||||
|
||||
private:
|
||||
void SetupDocument(QTextDocument & doc, const QStyleOptionViewItem & options) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#define MIX_ROW_HEIGHT_INCREASE 8 //how much space is added above mixer row (for new channel), if 0 space adding is disabled
|
||||
const int GroupHeaderRole = (Qt::UserRole+2); //defines new user role for list items. If value is > 0, then space is added before that item
|
||||
|
||||
class MixersList : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MixersList(QWidget *parent, bool expo);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
|
||||
signals:
|
||||
void mimeDropped(int index, const QMimeData *data, Qt::DropAction action);
|
||||
void keyWasPressed(QKeyEvent *event);
|
||||
|
||||
public slots:
|
||||
bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);
|
||||
|
||||
protected:
|
||||
virtual QStringList mimeTypes() const;
|
||||
|
||||
private:
|
||||
QPoint dragStartPosition;
|
||||
bool expo;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Provides sizing and painting of items for our mixes and inputs lists
|
||||
|
||||
This class draws HTML formated strings into QListWidget class
|
||||
*/
|
||||
class MixersDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
inline MixersDelegate(QObject *parent) : QStyledItemDelegate(parent) {};
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
|
||||
|
||||
private:
|
||||
void SetupDocument(QTextDocument & doc, const QStyleOptionViewItem & options) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // _MIXERSLIST_H_
|
||||
|
||||
@@ -20,63 +20,63 @@
|
||||
|
||||
#ifndef _MIXES_H_
|
||||
#define _MIXES_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "mixerslist.h"
|
||||
#include "mixerdialog.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class MixesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~MixesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
// TODO all slots?
|
||||
void clearMixes();
|
||||
void mixersDelete(bool ask=true);
|
||||
void mixersCut();
|
||||
void mixersCopy();
|
||||
void mixersPaste();
|
||||
void mixersDuplicate();
|
||||
void mixerOpen();
|
||||
void mixerAdd();
|
||||
void moveMixUp();
|
||||
void moveMixDown();
|
||||
void mixerHighlight();
|
||||
|
||||
|
||||
void mixerlistWidget_customContextMenuRequested(QPoint pos);
|
||||
void mixerlistWidget_doubleClicked(QModelIndex index);
|
||||
void mixerlistWidget_KeyPress(QKeyEvent *event);
|
||||
|
||||
void mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction action);
|
||||
void pasteMixerMimeData(const QMimeData * mimeData, int destIdx);
|
||||
|
||||
void mixesEdited();
|
||||
|
||||
private:
|
||||
MixersList *MixerlistWidget;
|
||||
bool mixInserted;
|
||||
unsigned int highlightedSource;
|
||||
bool firstLine;
|
||||
ModelPrinter modelPrinter;
|
||||
|
||||
int getMixerIndex(unsigned int dch);
|
||||
bool gm_insertMix(int idx);
|
||||
void gm_deleteMix(int index);
|
||||
void gm_openMix(int index);
|
||||
int gm_moveMix(int idx, bool dir);
|
||||
void mixersDeleteList(QList<int> list);
|
||||
QList<int> createMixListFromSelected();
|
||||
void setSelectedByMixList(QList<int> list);
|
||||
bool AddMixerLine(int dest);
|
||||
QString getMixerText(int dest, bool * new_ch);
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "mixerslist.h"
|
||||
#include "mixerdialog.h"
|
||||
#include "modelprinter.h"
|
||||
|
||||
class MixesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~MixesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
// TODO all slots?
|
||||
void clearMixes();
|
||||
void mixersDelete(bool ask=true);
|
||||
void mixersCut();
|
||||
void mixersCopy();
|
||||
void mixersPaste();
|
||||
void mixersDuplicate();
|
||||
void mixerOpen();
|
||||
void mixerAdd();
|
||||
void moveMixUp();
|
||||
void moveMixDown();
|
||||
void mixerHighlight();
|
||||
|
||||
|
||||
void mixerlistWidget_customContextMenuRequested(QPoint pos);
|
||||
void mixerlistWidget_doubleClicked(QModelIndex index);
|
||||
void mixerlistWidget_KeyPress(QKeyEvent *event);
|
||||
|
||||
void mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction action);
|
||||
void pasteMixerMimeData(const QMimeData * mimeData, int destIdx);
|
||||
|
||||
void mixesEdited();
|
||||
|
||||
private:
|
||||
MixersList *MixerlistWidget;
|
||||
bool mixInserted;
|
||||
unsigned int highlightedSource;
|
||||
bool firstLine;
|
||||
ModelPrinter modelPrinter;
|
||||
|
||||
int getMixerIndex(unsigned int dch);
|
||||
bool gm_insertMix(int idx);
|
||||
void gm_deleteMix(int index);
|
||||
void gm_openMix(int index);
|
||||
int gm_moveMix(int idx, bool dir);
|
||||
void mixersDeleteList(QList<int> list);
|
||||
QList<int> createMixListFromSelected();
|
||||
void setSelectedByMixList(QList<int> list);
|
||||
bool AddMixerLine(int dest);
|
||||
QString getMixerText(int dest, bool * new_ch);
|
||||
};
|
||||
|
||||
#endif // _MIXES_H_
|
||||
|
||||
@@ -20,55 +20,55 @@
|
||||
|
||||
#ifndef _MODELEDIT_H_
|
||||
#define _MODELEDIT_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "genericpanel.h"
|
||||
|
||||
class RadioData;
|
||||
|
||||
namespace Ui {
|
||||
class ModelEdit;
|
||||
}
|
||||
|
||||
class ModelPanel : public GenericPanel
|
||||
{
|
||||
public:
|
||||
ModelPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GenericPanel(parent, &model, generalSettings, firmware)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class ModelEdit : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmware * firmware);
|
||||
~ModelEdit();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void onTabModified();
|
||||
void on_pushButton_clicked();
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::ModelEdit *ui;
|
||||
int modelId;
|
||||
ModelData & model;
|
||||
GeneralSettings & generalSettings;
|
||||
Firmware * firmware;
|
||||
QVector<GenericPanel *> panels;
|
||||
|
||||
void addTab(GenericPanel *panel, QString text);
|
||||
void launchSimulation();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "genericpanel.h"
|
||||
|
||||
class RadioData;
|
||||
|
||||
namespace Ui {
|
||||
class ModelEdit;
|
||||
}
|
||||
|
||||
class ModelPanel : public GenericPanel
|
||||
{
|
||||
public:
|
||||
ModelPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GenericPanel(parent, &model, generalSettings, firmware)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class ModelEdit : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmware * firmware);
|
||||
~ModelEdit();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void onTabModified();
|
||||
void on_pushButton_clicked();
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::ModelEdit *ui;
|
||||
int modelId;
|
||||
ModelData & model;
|
||||
GeneralSettings & generalSettings;
|
||||
Firmware * firmware;
|
||||
QVector<GenericPanel *> panels;
|
||||
|
||||
void addTab(GenericPanel *panel, QString text);
|
||||
void launchSimulation();
|
||||
|
||||
};
|
||||
|
||||
#endif // _MODELEDIT_H_
|
||||
|
||||
+208
-208
@@ -18,213 +18,213 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
|
||||
Node::Node():
|
||||
minX(-100),
|
||||
maxX(+100)
|
||||
{
|
||||
setFlag(ItemIsMovable);
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
setZValue(-1);
|
||||
nodecolor = QColor(Qt::yellow);
|
||||
bPressed = false;
|
||||
centerX = true;
|
||||
centerY = true;
|
||||
fixedX = false;
|
||||
fixedY = false;
|
||||
ballSize = DEFAULT_BALL_SIZE;
|
||||
}
|
||||
|
||||
void Node::addEdge(Edge *edge)
|
||||
{
|
||||
edgeList << edge;
|
||||
edge->adjust();
|
||||
}
|
||||
|
||||
void Node::stepToCenter(qreal step)
|
||||
{
|
||||
if(scene() && !bPressed)
|
||||
{
|
||||
QRectF qr = scene()->sceneRect();
|
||||
qreal xStep = qr.width()/step;
|
||||
qreal yStep = qr.height()/step;
|
||||
|
||||
QPointF p = pos();
|
||||
if(centerX)
|
||||
{
|
||||
qreal x = qr.right() - qr.width()/2;
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
|
||||
Node::Node():
|
||||
minX(-100),
|
||||
maxX(+100)
|
||||
{
|
||||
setFlag(ItemIsMovable);
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
setZValue(-1);
|
||||
nodecolor = QColor(Qt::yellow);
|
||||
bPressed = false;
|
||||
centerX = true;
|
||||
centerY = true;
|
||||
fixedX = false;
|
||||
fixedY = false;
|
||||
ballSize = DEFAULT_BALL_SIZE;
|
||||
}
|
||||
|
||||
void Node::addEdge(Edge *edge)
|
||||
{
|
||||
edgeList << edge;
|
||||
edge->adjust();
|
||||
}
|
||||
|
||||
void Node::stepToCenter(qreal step)
|
||||
{
|
||||
if(scene() && !bPressed)
|
||||
{
|
||||
QRectF qr = scene()->sceneRect();
|
||||
qreal xStep = qr.width()/step;
|
||||
qreal yStep = qr.height()/step;
|
||||
|
||||
QPointF p = pos();
|
||||
if(centerX)
|
||||
{
|
||||
qreal x = qr.right() - qr.width()/2;
|
||||
if(fabs(x-p.x())>xStep)
|
||||
p.rx() += p.x()>x ? -xStep : xStep;
|
||||
else
|
||||
p.rx() = x;
|
||||
}
|
||||
|
||||
if(centerY)
|
||||
{
|
||||
qreal y = qr.bottom() - qr.height()/2;
|
||||
p.rx() += p.x()>x ? -xStep : xStep;
|
||||
else
|
||||
p.rx() = x;
|
||||
}
|
||||
|
||||
if(centerY)
|
||||
{
|
||||
qreal y = qr.bottom() - qr.height()/2;
|
||||
if(fabs(y-p.y())>yStep)
|
||||
p.ry() += p.y()>y ? -yStep : yStep;
|
||||
else
|
||||
p.ry() = y;
|
||||
}
|
||||
setPos(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Node::setColor(const QColor & color)
|
||||
{
|
||||
nodecolor=color;
|
||||
}
|
||||
|
||||
|
||||
void Node::setBallSize(int size)
|
||||
{
|
||||
if(size>2) ballSize = size;
|
||||
}
|
||||
|
||||
qreal Node::getX()
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
return 1+((x()-rect.right())*2/rect.width());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Node::setX(qreal newX)
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
QGraphicsObject::setX(rect.left() + (newX+1) * rect.width()/2);
|
||||
}
|
||||
}
|
||||
|
||||
qreal Node::getY()
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
return 1+((y()-rect.bottom())*2/rect.height());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Node::setY(qreal newY)
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
QGraphicsObject::setY(rect.top() + (newY+1) * rect.height()/2);
|
||||
}
|
||||
}
|
||||
|
||||
QList<Edge *> Node::edges() const
|
||||
{
|
||||
return edgeList;
|
||||
}
|
||||
|
||||
QRectF Node::boundingRect() const
|
||||
{
|
||||
qreal adjust = 2;
|
||||
return QRectF(-ballSize/2 - adjust, -ballSize/2 - adjust,
|
||||
ballSize+BALL_HEIGHT + adjust, ballSize+BALL_HEIGHT + adjust);
|
||||
}
|
||||
|
||||
|
||||
QPainterPath Node::shape() const
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addEllipse(-ballSize/2, -ballSize/2, ballSize, ballSize);
|
||||
return path;
|
||||
}
|
||||
|
||||
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
|
||||
{
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(Qt::darkGray);
|
||||
painter->drawEllipse(-ballSize/2 + BALL_HEIGHT, -ballSize/2 + BALL_HEIGHT, ballSize, ballSize);
|
||||
|
||||
QRadialGradient gradient(-BALL_HEIGHT, -BALL_HEIGHT, ballSize/2);
|
||||
if (option->state & QStyle::State_Sunken) {
|
||||
gradient.setCenter(BALL_HEIGHT, BALL_HEIGHT);
|
||||
gradient.setFocalPoint(BALL_HEIGHT, BALL_HEIGHT);
|
||||
gradient.setColorAt(1, nodecolor.light(180));
|
||||
gradient.setColorAt(0, nodecolor.light(120));
|
||||
} else {
|
||||
gradient.setColorAt(0, nodecolor);
|
||||
gradient.setColorAt(1, nodecolor.dark(120));
|
||||
}
|
||||
painter->setBrush(gradient);
|
||||
painter->setPen(QPen(Qt::black, 0));
|
||||
painter->drawEllipse(-ballSize/2, -ballSize/2, ballSize, ballSize);
|
||||
}
|
||||
|
||||
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
switch (change) {
|
||||
case ItemPositionChange:
|
||||
if (scene())
|
||||
{
|
||||
// value is the new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
QRectF rect = scene()->sceneRect();
|
||||
if(fixedX) newPos.setX(x());//make sure x doesn't change
|
||||
if(fixedY) newPos.setY(y());//make sure x doesn't change
|
||||
newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));// bound X
|
||||
newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));// bound Y
|
||||
|
||||
int newX = -100 + ( (newPos.x()-rect.left()) * 200) / rect.width();
|
||||
int newY = 100+(rect.top()-y())*200/rect.height();
|
||||
if (newX < minX) newX = minX;
|
||||
if (newX > maxX) newX = maxX;
|
||||
|
||||
if (!getFixedX()) {
|
||||
newPos.setX(((newX+100)*rect.width()/200+rect.left()));
|
||||
}
|
||||
|
||||
emit moved(newX, newY);
|
||||
return newPos;
|
||||
}
|
||||
break;
|
||||
case ItemPositionHasChanged:
|
||||
foreach (Edge *edge, edgeList)
|
||||
edge->adjust();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
update();
|
||||
bPressed = true;
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
emit focus();
|
||||
}
|
||||
|
||||
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
update();
|
||||
bPressed = false;
|
||||
if (scene()) {
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
emit unfocus();
|
||||
}
|
||||
else {
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
}
|
||||
p.ry() += p.y()>y ? -yStep : yStep;
|
||||
else
|
||||
p.ry() = y;
|
||||
}
|
||||
setPos(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Node::setColor(const QColor & color)
|
||||
{
|
||||
nodecolor=color;
|
||||
}
|
||||
|
||||
|
||||
void Node::setBallSize(int size)
|
||||
{
|
||||
if(size>2) ballSize = size;
|
||||
}
|
||||
|
||||
qreal Node::getX()
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
return 1+((x()-rect.right())*2/rect.width());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Node::setX(qreal newX)
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
QGraphicsObject::setX(rect.left() + (newX+1) * rect.width()/2);
|
||||
}
|
||||
}
|
||||
|
||||
qreal Node::getY()
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
return 1+((y()-rect.bottom())*2/rect.height());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Node::setY(qreal newY)
|
||||
{
|
||||
if(scene())
|
||||
{
|
||||
QRectF rect = scene()->sceneRect();
|
||||
QGraphicsObject::setY(rect.top() + (newY+1) * rect.height()/2);
|
||||
}
|
||||
}
|
||||
|
||||
QList<Edge *> Node::edges() const
|
||||
{
|
||||
return edgeList;
|
||||
}
|
||||
|
||||
QRectF Node::boundingRect() const
|
||||
{
|
||||
qreal adjust = 2;
|
||||
return QRectF(-ballSize/2 - adjust, -ballSize/2 - adjust,
|
||||
ballSize+BALL_HEIGHT + adjust, ballSize+BALL_HEIGHT + adjust);
|
||||
}
|
||||
|
||||
|
||||
QPainterPath Node::shape() const
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addEllipse(-ballSize/2, -ballSize/2, ballSize, ballSize);
|
||||
return path;
|
||||
}
|
||||
|
||||
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
|
||||
{
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(Qt::darkGray);
|
||||
painter->drawEllipse(-ballSize/2 + BALL_HEIGHT, -ballSize/2 + BALL_HEIGHT, ballSize, ballSize);
|
||||
|
||||
QRadialGradient gradient(-BALL_HEIGHT, -BALL_HEIGHT, ballSize/2);
|
||||
if (option->state & QStyle::State_Sunken) {
|
||||
gradient.setCenter(BALL_HEIGHT, BALL_HEIGHT);
|
||||
gradient.setFocalPoint(BALL_HEIGHT, BALL_HEIGHT);
|
||||
gradient.setColorAt(1, nodecolor.light(180));
|
||||
gradient.setColorAt(0, nodecolor.light(120));
|
||||
} else {
|
||||
gradient.setColorAt(0, nodecolor);
|
||||
gradient.setColorAt(1, nodecolor.dark(120));
|
||||
}
|
||||
painter->setBrush(gradient);
|
||||
painter->setPen(QPen(Qt::black, 0));
|
||||
painter->drawEllipse(-ballSize/2, -ballSize/2, ballSize, ballSize);
|
||||
}
|
||||
|
||||
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
switch (change) {
|
||||
case ItemPositionChange:
|
||||
if (scene())
|
||||
{
|
||||
// value is the new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
QRectF rect = scene()->sceneRect();
|
||||
if(fixedX) newPos.setX(x());//make sure x doesn't change
|
||||
if(fixedY) newPos.setY(y());//make sure x doesn't change
|
||||
newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));// bound X
|
||||
newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));// bound Y
|
||||
|
||||
int newX = -100 + ( (newPos.x()-rect.left()) * 200) / rect.width();
|
||||
int newY = 100+(rect.top()-y())*200/rect.height();
|
||||
if (newX < minX) newX = minX;
|
||||
if (newX > maxX) newX = maxX;
|
||||
|
||||
if (!getFixedX()) {
|
||||
newPos.setX(((newX+100)*rect.width()/200+rect.left()));
|
||||
}
|
||||
|
||||
emit moved(newX, newY);
|
||||
return newPos;
|
||||
}
|
||||
break;
|
||||
case ItemPositionHasChanged:
|
||||
foreach (Edge *edge, edgeList)
|
||||
edge->adjust();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
update();
|
||||
bPressed = true;
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
emit focus();
|
||||
}
|
||||
|
||||
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
update();
|
||||
bPressed = false;
|
||||
if (scene()) {
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
emit unfocus();
|
||||
}
|
||||
else {
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,72 +20,72 @@
|
||||
|
||||
#ifndef _NODE_H_
|
||||
#define _NODE_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#define DEFAULT_BALL_SIZE 10
|
||||
#define BALL_HEIGHT 2
|
||||
|
||||
class Edge;
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsSceneMouseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Node : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Node();
|
||||
|
||||
void addEdge(Edge *edge);
|
||||
QList<Edge *> edges() const;
|
||||
|
||||
enum { Type = UserType + 1 };
|
||||
int type() const { return Type; }
|
||||
QRectF boundingRect() const;
|
||||
QPainterPath shape() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void setBallSize(int size);
|
||||
void stepToCenter(qreal step=10);
|
||||
int getBallSize() {return ballSize;}
|
||||
qreal getX();
|
||||
qreal getY();
|
||||
void setX(qreal newX);
|
||||
void setY(qreal newX);
|
||||
|
||||
void setCenteringX(bool val) {centerX = val;}
|
||||
void setCenteringY(bool val) {centerY = val;}
|
||||
void setFixedX(bool val) {fixedX = val;}
|
||||
void setFixedY(bool val) {fixedY = val;}
|
||||
bool getFixedX() {return fixedX;}
|
||||
bool getFixedY() {return fixedY;}
|
||||
void setMinX(int val) {minX = val;};
|
||||
void setMaxX(int val) {maxX = val;};
|
||||
void setColor(const QColor & color);
|
||||
|
||||
signals:
|
||||
void moved(int x, int y);
|
||||
void focus();
|
||||
void unfocus();
|
||||
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
bool bPressed;
|
||||
bool centerX;
|
||||
bool centerY;
|
||||
bool fixedX;
|
||||
bool fixedY;
|
||||
int ballSize;
|
||||
int minX;
|
||||
int maxX;
|
||||
QList<Edge *> edgeList;
|
||||
QPointF newPos;
|
||||
QColor nodecolor;
|
||||
};
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#define DEFAULT_BALL_SIZE 10
|
||||
#define BALL_HEIGHT 2
|
||||
|
||||
class Edge;
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsSceneMouseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Node : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Node();
|
||||
|
||||
void addEdge(Edge *edge);
|
||||
QList<Edge *> edges() const;
|
||||
|
||||
enum { Type = UserType + 1 };
|
||||
int type() const { return Type; }
|
||||
QRectF boundingRect() const;
|
||||
QPainterPath shape() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void setBallSize(int size);
|
||||
void stepToCenter(qreal step=10);
|
||||
int getBallSize() {return ballSize;}
|
||||
qreal getX();
|
||||
qreal getY();
|
||||
void setX(qreal newX);
|
||||
void setY(qreal newX);
|
||||
|
||||
void setCenteringX(bool val) {centerX = val;}
|
||||
void setCenteringY(bool val) {centerY = val;}
|
||||
void setFixedX(bool val) {fixedX = val;}
|
||||
void setFixedY(bool val) {fixedY = val;}
|
||||
bool getFixedX() {return fixedX;}
|
||||
bool getFixedY() {return fixedY;}
|
||||
void setMinX(int val) {minX = val;};
|
||||
void setMaxX(int val) {maxX = val;};
|
||||
void setColor(const QColor & color);
|
||||
|
||||
signals:
|
||||
void moved(int x, int y);
|
||||
void focus();
|
||||
void unfocus();
|
||||
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
bool bPressed;
|
||||
bool centerX;
|
||||
bool centerY;
|
||||
bool fixedX;
|
||||
bool fixedY;
|
||||
int ballSize;
|
||||
int minX;
|
||||
int maxX;
|
||||
QList<Edge *> edgeList;
|
||||
QPointF newPos;
|
||||
QColor nodecolor;
|
||||
};
|
||||
|
||||
#endif // _NODE_H_
|
||||
|
||||
+123
-123
@@ -20,127 +20,127 @@
|
||||
|
||||
#ifndef _SETUP_H_
|
||||
#define _SETUP_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class Setup;
|
||||
class Timer;
|
||||
class Module;
|
||||
}
|
||||
|
||||
class TimerPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget *prevFocus);
|
||||
virtual ~TimerPanel();
|
||||
|
||||
virtual void update();
|
||||
QWidget * getLastFocus();
|
||||
|
||||
private slots:
|
||||
void on_mode_currentIndexChanged(int index);
|
||||
void on_value_editingFinished();
|
||||
void on_minuteBeep_toggled(bool checked);
|
||||
void on_name_editingFinished();
|
||||
|
||||
private:
|
||||
TimerData & timer;
|
||||
Ui::Timer *ui;
|
||||
};
|
||||
|
||||
class ModulePanel : public ModelPanel
|
||||
{
|
||||
static const int maxChannels = 16;
|
||||
|
||||
struct ChannelFailsafeWidgetsGroup {
|
||||
QComboBox * combo;
|
||||
QDoubleSpinBox * spinbox;
|
||||
QLabel * label;
|
||||
};
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModulePanel(QWidget *parent, ModelData & model, ModuleData & module, GeneralSettings & generalSettings, Firmware * firmware, int moduleIdx);
|
||||
virtual ~ModulePanel();
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
void updateFailsafe(int channel);
|
||||
|
||||
private slots:
|
||||
void on_trainerMode_currentIndexChanged(int index);
|
||||
void on_protocol_currentIndexChanged(int index);
|
||||
void on_ppmDelay_editingFinished();
|
||||
void on_channelsCount_editingFinished();
|
||||
void on_channelsStart_editingFinished();
|
||||
void on_ppmPolarity_currentIndexChanged(int index);
|
||||
void on_ppmOutputType_currentIndexChanged(int index);
|
||||
void on_ppmFrameLength_editingFinished();
|
||||
void on_rxNumber_editingFinished();
|
||||
void on_failsafeMode_currentIndexChanged(int value);
|
||||
void onFailsafeComboIndexChanged(int index);
|
||||
void onFailsafeSpinChanged(double value);
|
||||
void on_multiProtocol_currentIndexChanged(int index);
|
||||
void on_multiSubType_currentIndexChanged(int index);
|
||||
void on_autoBind_stateChanged(int state);
|
||||
void on_lowPower_stateChanged(int state);
|
||||
|
||||
private:
|
||||
ModuleData & module;
|
||||
int moduleIdx;
|
||||
Ui::Module *ui;
|
||||
ChannelFailsafeWidgetsGroup failsafeGroups[maxChannels];
|
||||
};
|
||||
|
||||
class SetupPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~SetupPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void extendedLimitsToggled();
|
||||
|
||||
private slots:
|
||||
void on_name_editingFinished();
|
||||
void on_throttleSource_currentIndexChanged(int index);
|
||||
void on_throttleTrim_toggled(bool checked);
|
||||
void on_extendedLimits_toggled(bool checked);
|
||||
void on_extendedTrims_toggled(bool checked);
|
||||
void on_throttleWarning_toggled(bool checked);
|
||||
void on_throttleReverse_toggled(bool checked);
|
||||
void on_displayText_toggled(bool checked);
|
||||
void on_gfEnabled_toggled(bool checked);
|
||||
void on_image_currentIndexChanged(int index);
|
||||
void on_trimIncrement_currentIndexChanged(int index);
|
||||
void onBeepCenterToggled(bool checked);
|
||||
void startupSwitchEdited(int value);
|
||||
void startupSwitchToggled(bool checked);
|
||||
void potWarningToggled(bool checked);
|
||||
void on_potWarningMode_currentIndexChanged(int index);
|
||||
void onChildModified();
|
||||
|
||||
private:
|
||||
Ui::Setup *ui;
|
||||
QVector<QSlider *> startupSwitchesSliders;
|
||||
QVector<QCheckBox *> startupSwitchesCheckboxes;
|
||||
QVector<QCheckBox *> potWarningCheckboxes;
|
||||
QVector<QCheckBox *> centerBeepCheckboxes;
|
||||
ModulePanel * modules[CPN_MAX_MODULES+1];
|
||||
TimerPanel * timers[CPN_MAX_TIMERS];
|
||||
void updateStartupSwitches();
|
||||
void updatePotWarnings();
|
||||
void updateBeepCenter();
|
||||
void populateThrottleSourceCB();
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
namespace Ui {
|
||||
class Setup;
|
||||
class Timer;
|
||||
class Module;
|
||||
}
|
||||
|
||||
class TimerPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget *prevFocus);
|
||||
virtual ~TimerPanel();
|
||||
|
||||
virtual void update();
|
||||
QWidget * getLastFocus();
|
||||
|
||||
private slots:
|
||||
void on_mode_currentIndexChanged(int index);
|
||||
void on_value_editingFinished();
|
||||
void on_minuteBeep_toggled(bool checked);
|
||||
void on_name_editingFinished();
|
||||
|
||||
private:
|
||||
TimerData & timer;
|
||||
Ui::Timer *ui;
|
||||
};
|
||||
|
||||
class ModulePanel : public ModelPanel
|
||||
{
|
||||
static const int maxChannels = 16;
|
||||
|
||||
struct ChannelFailsafeWidgetsGroup {
|
||||
QComboBox * combo;
|
||||
QDoubleSpinBox * spinbox;
|
||||
QLabel * label;
|
||||
};
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModulePanel(QWidget *parent, ModelData & model, ModuleData & module, GeneralSettings & generalSettings, Firmware * firmware, int moduleIdx);
|
||||
virtual ~ModulePanel();
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
void updateFailsafe(int channel);
|
||||
|
||||
private slots:
|
||||
void on_trainerMode_currentIndexChanged(int index);
|
||||
void on_protocol_currentIndexChanged(int index);
|
||||
void on_ppmDelay_editingFinished();
|
||||
void on_channelsCount_editingFinished();
|
||||
void on_channelsStart_editingFinished();
|
||||
void on_ppmPolarity_currentIndexChanged(int index);
|
||||
void on_ppmOutputType_currentIndexChanged(int index);
|
||||
void on_ppmFrameLength_editingFinished();
|
||||
void on_rxNumber_editingFinished();
|
||||
void on_failsafeMode_currentIndexChanged(int value);
|
||||
void onFailsafeComboIndexChanged(int index);
|
||||
void onFailsafeSpinChanged(double value);
|
||||
void on_multiProtocol_currentIndexChanged(int index);
|
||||
void on_multiSubType_currentIndexChanged(int index);
|
||||
void on_autoBind_stateChanged(int state);
|
||||
void on_lowPower_stateChanged(int state);
|
||||
|
||||
private:
|
||||
ModuleData & module;
|
||||
int moduleIdx;
|
||||
Ui::Module *ui;
|
||||
ChannelFailsafeWidgetsGroup failsafeGroups[maxChannels];
|
||||
};
|
||||
|
||||
class SetupPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~SetupPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void extendedLimitsToggled();
|
||||
|
||||
private slots:
|
||||
void on_name_editingFinished();
|
||||
void on_throttleSource_currentIndexChanged(int index);
|
||||
void on_throttleTrim_toggled(bool checked);
|
||||
void on_extendedLimits_toggled(bool checked);
|
||||
void on_extendedTrims_toggled(bool checked);
|
||||
void on_throttleWarning_toggled(bool checked);
|
||||
void on_throttleReverse_toggled(bool checked);
|
||||
void on_displayText_toggled(bool checked);
|
||||
void on_gfEnabled_toggled(bool checked);
|
||||
void on_image_currentIndexChanged(int index);
|
||||
void on_trimIncrement_currentIndexChanged(int index);
|
||||
void onBeepCenterToggled(bool checked);
|
||||
void startupSwitchEdited(int value);
|
||||
void startupSwitchToggled(bool checked);
|
||||
void potWarningToggled(bool checked);
|
||||
void on_potWarningMode_currentIndexChanged(int index);
|
||||
void onChildModified();
|
||||
|
||||
private:
|
||||
Ui::Setup *ui;
|
||||
QVector<QSlider *> startupSwitchesSliders;
|
||||
QVector<QCheckBox *> startupSwitchesCheckboxes;
|
||||
QVector<QCheckBox *> potWarningCheckboxes;
|
||||
QVector<QCheckBox *> centerBeepCheckboxes;
|
||||
ModulePanel * modules[CPN_MAX_MODULES+1];
|
||||
TimerPanel * timers[CPN_MAX_TIMERS];
|
||||
void updateStartupSwitches();
|
||||
void updatePotWarnings();
|
||||
void updateBeepCenter();
|
||||
void populateThrottleSourceCB();
|
||||
};
|
||||
|
||||
#endif // _SETUP_H_
|
||||
|
||||
+143
-143
@@ -20,147 +20,147 @@
|
||||
|
||||
#ifndef _TELEMETRY_H_
|
||||
#define _TELEMETRY_H_
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
class AutoComboBox;
|
||||
|
||||
namespace Ui {
|
||||
class TelemetryAnalog;
|
||||
class TelemetryCustomScreen;
|
||||
class TelemetrySensor;
|
||||
class Telemetry;
|
||||
}
|
||||
|
||||
class TelemetryAnalog: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class TelemetryPanel;
|
||||
|
||||
public:
|
||||
TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~TelemetryAnalog();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void on_UnitCB_currentIndexChanged(int index);
|
||||
void on_RatioSB_editingFinished();
|
||||
void on_RatioSB_valueChanged();
|
||||
void on_CalibSB_editingFinished();
|
||||
void on_alarm1LevelCB_currentIndexChanged(int index);
|
||||
void on_alarm1GreaterCB_currentIndexChanged(int index);
|
||||
void on_alarm1ValueSB_editingFinished();
|
||||
void on_alarm2LevelCB_currentIndexChanged(int index);
|
||||
void on_alarm2GreaterCB_currentIndexChanged(int index);
|
||||
void on_alarm2ValueSB_editingFinished();
|
||||
|
||||
private:
|
||||
Ui::TelemetryAnalog *ui;
|
||||
FrSkyChannelData & analog;
|
||||
bool lock;
|
||||
|
||||
void update();
|
||||
};
|
||||
|
||||
class TelemetryCustomScreen: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~TelemetryCustomScreen();
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
void on_screenType_currentIndexChanged(int index);
|
||||
void scriptNameEdited();
|
||||
void customFieldChanged(int index);
|
||||
void barSourceChanged(int index);
|
||||
void barMinChanged(double value);
|
||||
void barMaxChanged(double value);
|
||||
|
||||
protected:
|
||||
void populateTelemetrySourceCB(QComboBox * b, RawSource & source, bool last=false);
|
||||
|
||||
private:
|
||||
void updateBar(int line);
|
||||
Ui::TelemetryCustomScreen * ui;
|
||||
FrSkyScreenData & screen;
|
||||
QComboBox * fieldsCB[4][3];
|
||||
QComboBox * barsCB[4];
|
||||
QDoubleSpinBox * minSB[4];
|
||||
QDoubleSpinBox * maxSB[4];
|
||||
};
|
||||
|
||||
class TelemetrySensorPanel: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetrySensorPanel(QWidget *parent, SensorData & sensor, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~TelemetrySensorPanel();
|
||||
void update();
|
||||
|
||||
signals:
|
||||
void dataModified();
|
||||
|
||||
protected slots:
|
||||
void on_name_editingFinished();
|
||||
void on_type_currentIndexChanged(int index);
|
||||
void on_formula_currentIndexChanged(int index);
|
||||
void on_unit_currentIndexChanged(int index);
|
||||
void on_prec_valueChanged(double value);
|
||||
|
||||
protected:
|
||||
void updateSourcesComboBox(AutoComboBox * cb, bool negative);
|
||||
|
||||
private:
|
||||
Ui::TelemetrySensor * ui;
|
||||
SensorData & sensor;
|
||||
bool lock;
|
||||
};
|
||||
|
||||
class TelemetryPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~TelemetryPanel();
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void on_telemetryProtocol_currentIndexChanged(int index);
|
||||
void onModified();
|
||||
void on_frskyProtoCB_currentIndexChanged(int index);
|
||||
void on_bladesCount_editingFinished();
|
||||
void on_rssiAlarm1CB_currentIndexChanged(int index);
|
||||
void on_rssiAlarm2CB_currentIndexChanged(int index);
|
||||
void on_rssiAlarm1SB_editingFinished();
|
||||
void on_rssiAlarm2SB_editingFinished();
|
||||
void on_varioLimitMin_DSB_editingFinished();
|
||||
void on_varioLimitMax_DSB_editingFinished();
|
||||
void on_varioLimitCenterMin_DSB_editingFinished();
|
||||
void on_varioLimitCenterMax_DSB_editingFinished();
|
||||
void on_fasOffset_DSB_editingFinished();
|
||||
void on_mahCount_SB_editingFinished();
|
||||
void on_mahCount_ChkB_toggled(bool checked);
|
||||
|
||||
private:
|
||||
Ui::Telemetry *ui;
|
||||
TelemetryAnalog * analogs[4];
|
||||
TelemetryCustomScreen * telemetryCustomScreens[4];
|
||||
TelemetrySensorPanel * sensorPanels[CPN_MAX_SENSORS];
|
||||
|
||||
void setup();
|
||||
void telBarUpdate();
|
||||
void populateVoltsSource();
|
||||
void populateCurrentSource();
|
||||
void populateVarioSource();
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
class AutoComboBox;
|
||||
|
||||
namespace Ui {
|
||||
class TelemetryAnalog;
|
||||
class TelemetryCustomScreen;
|
||||
class TelemetrySensor;
|
||||
class Telemetry;
|
||||
}
|
||||
|
||||
class TelemetryAnalog: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class TelemetryPanel;
|
||||
|
||||
public:
|
||||
TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~TelemetryAnalog();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void on_UnitCB_currentIndexChanged(int index);
|
||||
void on_RatioSB_editingFinished();
|
||||
void on_RatioSB_valueChanged();
|
||||
void on_CalibSB_editingFinished();
|
||||
void on_alarm1LevelCB_currentIndexChanged(int index);
|
||||
void on_alarm1GreaterCB_currentIndexChanged(int index);
|
||||
void on_alarm1ValueSB_editingFinished();
|
||||
void on_alarm2LevelCB_currentIndexChanged(int index);
|
||||
void on_alarm2GreaterCB_currentIndexChanged(int index);
|
||||
void on_alarm2ValueSB_editingFinished();
|
||||
|
||||
private:
|
||||
Ui::TelemetryAnalog *ui;
|
||||
FrSkyChannelData & analog;
|
||||
bool lock;
|
||||
|
||||
void update();
|
||||
};
|
||||
|
||||
class TelemetryCustomScreen: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~TelemetryCustomScreen();
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
void on_screenType_currentIndexChanged(int index);
|
||||
void scriptNameEdited();
|
||||
void customFieldChanged(int index);
|
||||
void barSourceChanged(int index);
|
||||
void barMinChanged(double value);
|
||||
void barMaxChanged(double value);
|
||||
|
||||
protected:
|
||||
void populateTelemetrySourceCB(QComboBox * b, RawSource & source, bool last=false);
|
||||
|
||||
private:
|
||||
void updateBar(int line);
|
||||
Ui::TelemetryCustomScreen * ui;
|
||||
FrSkyScreenData & screen;
|
||||
QComboBox * fieldsCB[4][3];
|
||||
QComboBox * barsCB[4];
|
||||
QDoubleSpinBox * minSB[4];
|
||||
QDoubleSpinBox * maxSB[4];
|
||||
};
|
||||
|
||||
class TelemetrySensorPanel: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetrySensorPanel(QWidget *parent, SensorData & sensor, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
~TelemetrySensorPanel();
|
||||
void update();
|
||||
|
||||
signals:
|
||||
void dataModified();
|
||||
|
||||
protected slots:
|
||||
void on_name_editingFinished();
|
||||
void on_type_currentIndexChanged(int index);
|
||||
void on_formula_currentIndexChanged(int index);
|
||||
void on_unit_currentIndexChanged(int index);
|
||||
void on_prec_valueChanged(double value);
|
||||
|
||||
protected:
|
||||
void updateSourcesComboBox(AutoComboBox * cb, bool negative);
|
||||
|
||||
private:
|
||||
Ui::TelemetrySensor * ui;
|
||||
SensorData & sensor;
|
||||
bool lock;
|
||||
};
|
||||
|
||||
class TelemetryPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~TelemetryPanel();
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void on_telemetryProtocol_currentIndexChanged(int index);
|
||||
void onModified();
|
||||
void on_frskyProtoCB_currentIndexChanged(int index);
|
||||
void on_bladesCount_editingFinished();
|
||||
void on_rssiAlarm1CB_currentIndexChanged(int index);
|
||||
void on_rssiAlarm2CB_currentIndexChanged(int index);
|
||||
void on_rssiAlarm1SB_editingFinished();
|
||||
void on_rssiAlarm2SB_editingFinished();
|
||||
void on_varioLimitMin_DSB_editingFinished();
|
||||
void on_varioLimitMax_DSB_editingFinished();
|
||||
void on_varioLimitCenterMin_DSB_editingFinished();
|
||||
void on_varioLimitCenterMax_DSB_editingFinished();
|
||||
void on_fasOffset_DSB_editingFinished();
|
||||
void on_mahCount_SB_editingFinished();
|
||||
void on_mahCount_ChkB_toggled(bool checked);
|
||||
|
||||
private:
|
||||
Ui::Telemetry *ui;
|
||||
TelemetryAnalog * analogs[4];
|
||||
TelemetryCustomScreen * telemetryCustomScreens[4];
|
||||
TelemetrySensorPanel * sensorPanels[CPN_MAX_SENSORS];
|
||||
|
||||
void setup();
|
||||
void telBarUpdate();
|
||||
void populateVoltsSource();
|
||||
void populateCurrentSource();
|
||||
void populateVarioSource();
|
||||
};
|
||||
|
||||
#endif // _TELEMETRY_H_
|
||||
|
||||
@@ -20,24 +20,24 @@
|
||||
|
||||
#ifndef _TEMPLATES_H_
|
||||
#define _TEMPLATES_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
class Templates : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Templates(QWidget *parent, ModelData & model);
|
||||
~Templates();
|
||||
|
||||
private slots:
|
||||
void onDoubleClicked(QModelIndex index);
|
||||
|
||||
private:
|
||||
void applyNumericTemplate(uint64_t tpl);
|
||||
ModelData & model;
|
||||
};
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
class Templates : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Templates(QWidget *parent, ModelData & model);
|
||||
~Templates();
|
||||
|
||||
private slots:
|
||||
void onDoubleClicked(QModelIndex index);
|
||||
|
||||
private:
|
||||
void applyNumericTemplate(uint64_t tpl);
|
||||
ModelData & model;
|
||||
};
|
||||
|
||||
#endif // _TEMPLATES_H_
|
||||
|
||||
+530
-530
File diff suppressed because it is too large
Load Diff
+66
-66
@@ -20,70 +20,70 @@
|
||||
|
||||
#ifndef _MODELSLIST_H_
|
||||
#define _MODELSLIST_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
struct CurrentSelection
|
||||
{
|
||||
QListWidgetItem *current_item;
|
||||
bool selected[CPN_MAX_MODELS+1];
|
||||
};
|
||||
|
||||
class ModelsListWidget : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModelsListWidget(QWidget *parent = 0);
|
||||
|
||||
bool hasSelection();
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
bool hasPasteData();
|
||||
|
||||
protected:
|
||||
void dropEvent(QDropEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dragLeaveEvent(QDragLeaveEvent *event);
|
||||
void dragMoveEvent(QDragMoveEvent *event);
|
||||
#ifndef WIN32
|
||||
void focusInEvent ( QFocusEvent * event );
|
||||
void focusOutEvent ( QFocusEvent * event );
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void refreshList();
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void print();
|
||||
void EditModel();
|
||||
void OpenEditWindow();
|
||||
void LoadBackup();
|
||||
void OpenWizard();
|
||||
void simulate();
|
||||
void duplicate();
|
||||
void setdefault();
|
||||
void deleteSelected(bool ask);
|
||||
void confirmDelete();
|
||||
void viableModelSelected(int idx);
|
||||
|
||||
private:
|
||||
void doCut(QByteArray *gmData);
|
||||
void doPaste(QByteArray *gmData, int index);
|
||||
void doCopy(QByteArray *gmData);
|
||||
void saveSelection();
|
||||
void restoreSelection();
|
||||
|
||||
RadioData *radioData;
|
||||
QPoint dragStartPosition;
|
||||
|
||||
CurrentSelection currentSelection;
|
||||
QColor active_highlight_color;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <QtWidgets>
|
||||
#include "eeprominterface.h"
|
||||
|
||||
struct CurrentSelection
|
||||
{
|
||||
QListWidgetItem *current_item;
|
||||
bool selected[CPN_MAX_MODELS+1];
|
||||
};
|
||||
|
||||
class ModelsListWidget : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModelsListWidget(QWidget *parent = 0);
|
||||
|
||||
bool hasSelection();
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
bool hasPasteData();
|
||||
|
||||
protected:
|
||||
void dropEvent(QDropEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dragLeaveEvent(QDragLeaveEvent *event);
|
||||
void dragMoveEvent(QDragMoveEvent *event);
|
||||
#ifndef WIN32
|
||||
void focusInEvent ( QFocusEvent * event );
|
||||
void focusOutEvent ( QFocusEvent * event );
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void refreshList();
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void print();
|
||||
void EditModel();
|
||||
void OpenEditWindow();
|
||||
void LoadBackup();
|
||||
void OpenWizard();
|
||||
void simulate();
|
||||
void duplicate();
|
||||
void setdefault();
|
||||
void deleteSelected(bool ask);
|
||||
void confirmDelete();
|
||||
void viableModelSelected(int idx);
|
||||
|
||||
private:
|
||||
void doCut(QByteArray *gmData);
|
||||
void doPaste(QByteArray *gmData, int index);
|
||||
void doCopy(QByteArray *gmData);
|
||||
void saveSelection();
|
||||
void restoreSelection();
|
||||
|
||||
RadioData *radioData;
|
||||
QPoint dragStartPosition;
|
||||
|
||||
CurrentSelection currentSelection;
|
||||
QColor active_highlight_color;
|
||||
|
||||
};
|
||||
|
||||
#endif // _MODELSLIST_H_
|
||||
|
||||
@@ -18,107 +18,107 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "genericpanel.h"
|
||||
#include <QComboBox>
|
||||
#include <QEvent>
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
#include <QSpacerItem>
|
||||
|
||||
GenericPanel::GenericPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
QWidget(parent),
|
||||
model(model),
|
||||
generalSettings(generalSettings),
|
||||
firmware(firmware),
|
||||
lock(false)
|
||||
{
|
||||
}
|
||||
|
||||
GenericPanel::~GenericPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericPanel::update()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericPanel::addLabel(QGridLayout *gridLayout, const QString &text, int col, bool minimize)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Raised);
|
||||
label->setMidLineWidth(0);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setMargin(5);
|
||||
label->setText(text);
|
||||
if (!minimize)
|
||||
label->setMinimumWidth(100);
|
||||
gridLayout->addWidget(label, 0, col, 1, 1);
|
||||
}
|
||||
|
||||
void GenericPanel::addEmptyLabel(QGridLayout * gridLayout, int col)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText("");
|
||||
gridLayout->addWidget(label, 0, col, 1, 1);
|
||||
}
|
||||
|
||||
void GenericPanel::addHSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
void GenericPanel::addVSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
void GenericPanel::addDoubleSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
bool GenericPanel::eventFilter(QObject *object, QEvent * event)
|
||||
{
|
||||
QWidget * widget = qobject_cast<QWidget*>(object);
|
||||
if (widget) {
|
||||
if (event->type() == QEvent::Wheel) {
|
||||
if (widget->focusPolicy() == Qt::WheelFocus) {
|
||||
event->accept();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (event->type() == QEvent::FocusIn) {
|
||||
widget->setFocusPolicy(Qt::WheelFocus);
|
||||
}
|
||||
else if (event->type() == QEvent::FocusOut) {
|
||||
widget->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void GenericPanel::disableMouseScrolling()
|
||||
{
|
||||
Q_FOREACH(QComboBox * cb, findChildren<QComboBox*>()) {
|
||||
cb->installEventFilter(this);
|
||||
cb->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
Q_FOREACH(QAbstractSpinBox * sb, findChildren<QAbstractSpinBox*>()) {
|
||||
sb->installEventFilter(this);
|
||||
sb->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
Q_FOREACH(QSlider * slider, findChildren<QSlider*>()) {
|
||||
slider->installEventFilter(this);
|
||||
slider->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
}
|
||||
#include "genericpanel.h"
|
||||
#include <QComboBox>
|
||||
#include <QEvent>
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
#include <QSpacerItem>
|
||||
|
||||
GenericPanel::GenericPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
QWidget(parent),
|
||||
model(model),
|
||||
generalSettings(generalSettings),
|
||||
firmware(firmware),
|
||||
lock(false)
|
||||
{
|
||||
}
|
||||
|
||||
GenericPanel::~GenericPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericPanel::update()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericPanel::addLabel(QGridLayout *gridLayout, const QString &text, int col, bool minimize)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Raised);
|
||||
label->setMidLineWidth(0);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setMargin(5);
|
||||
label->setText(text);
|
||||
if (!minimize)
|
||||
label->setMinimumWidth(100);
|
||||
gridLayout->addWidget(label, 0, col, 1, 1);
|
||||
}
|
||||
|
||||
void GenericPanel::addEmptyLabel(QGridLayout * gridLayout, int col)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText("");
|
||||
gridLayout->addWidget(label, 0, col, 1, 1);
|
||||
}
|
||||
|
||||
void GenericPanel::addHSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
void GenericPanel::addVSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
void GenericPanel::addDoubleSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
bool GenericPanel::eventFilter(QObject *object, QEvent * event)
|
||||
{
|
||||
QWidget * widget = qobject_cast<QWidget*>(object);
|
||||
if (widget) {
|
||||
if (event->type() == QEvent::Wheel) {
|
||||
if (widget->focusPolicy() == Qt::WheelFocus) {
|
||||
event->accept();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (event->type() == QEvent::FocusIn) {
|
||||
widget->setFocusPolicy(Qt::WheelFocus);
|
||||
}
|
||||
else if (event->type() == QEvent::FocusOut) {
|
||||
widget->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void GenericPanel::disableMouseScrolling()
|
||||
{
|
||||
Q_FOREACH(QComboBox * cb, findChildren<QComboBox*>()) {
|
||||
cb->installEventFilter(this);
|
||||
cb->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
Q_FOREACH(QAbstractSpinBox * sb, findChildren<QAbstractSpinBox*>()) {
|
||||
sb->installEventFilter(this);
|
||||
sb->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
Q_FOREACH(QSlider * slider, findChildren<QSlider*>()) {
|
||||
slider->installEventFilter(this);
|
||||
slider->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,47 +20,47 @@
|
||||
|
||||
#ifndef _GENERICPANEL_H_
|
||||
#define _GENERICPANEL_H_
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ModelData;
|
||||
class GeneralSettings;
|
||||
class Firmware;
|
||||
class QGridLayout;
|
||||
class QString;
|
||||
|
||||
class GenericPanel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class AutoComboBox;
|
||||
friend class AutoDoubleSpinBox;
|
||||
friend class AutoCheckBox;
|
||||
friend class AutoHexSpinBox;
|
||||
friend class AutoLineEdit;
|
||||
|
||||
public:
|
||||
GenericPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~GenericPanel();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
public slots:
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
ModelData * model;
|
||||
GeneralSettings & generalSettings;
|
||||
Firmware * firmware;
|
||||
bool lock;
|
||||
void addLabel(QGridLayout * gridLayout, const QString &text, int col, bool mimimize=false);
|
||||
void addEmptyLabel(QGridLayout * gridLayout, int col);
|
||||
void addHSpring(QGridLayout *, int col, int row);
|
||||
void addVSpring(QGridLayout *, int col, int row);
|
||||
void addDoubleSpring(QGridLayout *, int col, int row);
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||
void disableMouseScrolling();
|
||||
};
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ModelData;
|
||||
class GeneralSettings;
|
||||
class Firmware;
|
||||
class QGridLayout;
|
||||
class QString;
|
||||
|
||||
class GenericPanel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class AutoComboBox;
|
||||
friend class AutoDoubleSpinBox;
|
||||
friend class AutoCheckBox;
|
||||
friend class AutoHexSpinBox;
|
||||
friend class AutoLineEdit;
|
||||
|
||||
public:
|
||||
GenericPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~GenericPanel();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
public slots:
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
ModelData * model;
|
||||
GeneralSettings & generalSettings;
|
||||
Firmware * firmware;
|
||||
bool lock;
|
||||
void addLabel(QGridLayout * gridLayout, const QString &text, int col, bool mimimize=false);
|
||||
void addEmptyLabel(QGridLayout * gridLayout, int col);
|
||||
void addHSpring(QGridLayout *, int col, int row);
|
||||
void addVSpring(QGridLayout *, int col, int row);
|
||||
void addDoubleSpring(QGridLayout *, int col, int row);
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||
void disableMouseScrolling();
|
||||
};
|
||||
|
||||
#endif // _GENERICPANEL_H_
|
||||
|
||||
@@ -18,30 +18,30 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "hexspinbox.h"
|
||||
|
||||
HexSpinBox::HexSpinBox(QWidget *parent):
|
||||
QSpinBox(parent)
|
||||
{
|
||||
validator = new QRegExpValidator(QRegExp("[0-9A-Fa-f]{1,8}"), this);
|
||||
}
|
||||
|
||||
QValidator::State HexSpinBox::validate(QString &text, int &pos) const
|
||||
{
|
||||
return validator->validate(text, pos);
|
||||
}
|
||||
|
||||
int HexSpinBox::valueFromText(const QString &text) const
|
||||
{
|
||||
return text.toInt(0, 16);
|
||||
}
|
||||
|
||||
QString HexSpinBox::textFromValue(int value) const
|
||||
{
|
||||
QString text;
|
||||
text.sprintf("%04X", value);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "hexspinbox.h"
|
||||
|
||||
HexSpinBox::HexSpinBox(QWidget *parent):
|
||||
QSpinBox(parent)
|
||||
{
|
||||
validator = new QRegExpValidator(QRegExp("[0-9A-Fa-f]{1,8}"), this);
|
||||
}
|
||||
|
||||
QValidator::State HexSpinBox::validate(QString &text, int &pos) const
|
||||
{
|
||||
return validator->validate(text, pos);
|
||||
}
|
||||
|
||||
int HexSpinBox::valueFromText(const QString &text) const
|
||||
{
|
||||
return text.toInt(0, 16);
|
||||
}
|
||||
|
||||
QString HexSpinBox::textFromValue(int value) const
|
||||
{
|
||||
QString text;
|
||||
text.sprintf("%04X", value);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,25 +20,25 @@
|
||||
|
||||
#ifndef _HEXSPINBOX_H_
|
||||
#define _HEXSPINBOX_H_
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
class QRegExpValidator;
|
||||
|
||||
class HexSpinBox : public QSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HexSpinBox(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
QValidator::State validate(QString &text, int &pos) const;
|
||||
int valueFromText(const QString &text) const;
|
||||
QString textFromValue(int value) const;
|
||||
|
||||
private:
|
||||
QRegExpValidator *validator;
|
||||
};
|
||||
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
class QRegExpValidator;
|
||||
|
||||
class HexSpinBox : public QSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HexSpinBox(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
QValidator::State validate(QString &text, int &pos) const;
|
||||
int valueFromText(const QString &text) const;
|
||||
QString textFromValue(int value) const;
|
||||
|
||||
private:
|
||||
QRegExpValidator *validator;
|
||||
};
|
||||
|
||||
#endif // _HEXSPINBOX_H_
|
||||
|
||||
@@ -18,25 +18,25 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "verticalscrollarea.h"
|
||||
#include "genericpanel.h"
|
||||
#include <QEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
VerticalScrollArea::VerticalScrollArea(QWidget * parent, GenericPanel * panel):
|
||||
QScrollArea(parent),
|
||||
panel(panel)
|
||||
{
|
||||
setWidgetResizable(true);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setWidget(panel);
|
||||
panel->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool VerticalScrollArea::eventFilter(QObject * o, QEvent * e)
|
||||
{
|
||||
if (o == panel && e->type() == QEvent::Resize) {
|
||||
setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#include "verticalscrollarea.h"
|
||||
#include "genericpanel.h"
|
||||
#include <QEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
VerticalScrollArea::VerticalScrollArea(QWidget * parent, GenericPanel * panel):
|
||||
QScrollArea(parent),
|
||||
panel(panel)
|
||||
{
|
||||
setWidgetResizable(true);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setWidget(panel);
|
||||
panel->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool VerticalScrollArea::eventFilter(QObject * o, QEvent * e)
|
||||
{
|
||||
if (o == panel && e->type() == QEvent::Resize) {
|
||||
setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,22 +20,22 @@
|
||||
|
||||
#ifndef _VERTICALSCROLLAREA_H_
|
||||
#define _VERTICALSCROLLAREA_H_
|
||||
|
||||
#include <QScrollArea>
|
||||
|
||||
class GenericPanel;
|
||||
|
||||
class VerticalScrollArea : public QScrollArea
|
||||
{
|
||||
public:
|
||||
VerticalScrollArea(QWidget * parent, GenericPanel * panel);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject * o, QEvent * e);
|
||||
|
||||
private:
|
||||
GenericPanel * panel;
|
||||
};
|
||||
|
||||
|
||||
#include <QScrollArea>
|
||||
|
||||
class GenericPanel;
|
||||
|
||||
class VerticalScrollArea : public QScrollArea
|
||||
{
|
||||
public:
|
||||
VerticalScrollArea(QWidget * parent, GenericPanel * panel);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject * o, QEvent * e);
|
||||
|
||||
private:
|
||||
GenericPanel * panel;
|
||||
};
|
||||
|
||||
#endif // _VERTICALSCROLLAREA_H_
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,257 +20,257 @@
|
||||
|
||||
#ifndef _SIMULATORDIALOG_H_
|
||||
#define _SIMULATORDIALOG_H_
|
||||
|
||||
#include "modeledit/node.h"
|
||||
#include "telemetrysimu.h"
|
||||
#include "trainersimu.h"
|
||||
#include "debugoutput.h"
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
#include "joystick.h"
|
||||
#endif
|
||||
|
||||
#define TMR_OFF 0
|
||||
#define TMR_RUNNING 1
|
||||
#define TMR_BEEPING 2
|
||||
#define TMR_STOPPED 3
|
||||
|
||||
#define FLASH_DURATION 10
|
||||
|
||||
namespace Ui {
|
||||
class SimulatorDialog9X;
|
||||
class SimulatorDialogTaranis;
|
||||
class SimulatorDialogFlamenco;
|
||||
class SimulatorDialogHorus;
|
||||
}
|
||||
|
||||
// TODO rename + move?
|
||||
class LcdWidget;
|
||||
class SliderWidget;
|
||||
|
||||
#define SIMULATOR_FLAGS_NOTX 1
|
||||
#define SIMULATOR_FLAGS_STICK_MODE_LEFT 2
|
||||
#define SIMULATOR_FLAGS_S1 4
|
||||
#define SIMULATOR_FLAGS_S2 8
|
||||
#define SIMULATOR_FLAGS_S3 16
|
||||
#define SIMULATOR_FLAGS_S4 32 // reserved for the future
|
||||
#define SIMULATOR_FLAGS_S1_MULTI 64
|
||||
#define SIMULATOR_FLAGS_S2_MULTI 128
|
||||
#define SIMULATOR_FLAGS_S3_MULTI 256
|
||||
#define SIMULATOR_FLAGS_S4_MULTI 512 // reserved for the future
|
||||
|
||||
void traceCb(const char * text);
|
||||
|
||||
class SimulatorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog();
|
||||
|
||||
void start(const char * filename);
|
||||
void start(QByteArray & eeprom);
|
||||
virtual void traceCallback(const char * text);
|
||||
|
||||
protected:
|
||||
template <class T> void initUi(T * ui);
|
||||
virtual void setLightOn(bool enable) { }
|
||||
virtual void updateBeepButton() { }
|
||||
|
||||
unsigned int flags;
|
||||
LcdWidget * lcd;
|
||||
QGraphicsView * leftStick, * rightStick;
|
||||
QVector<QDial *> pots;
|
||||
QVector<QLabel *> potLabels;
|
||||
QVector<QLabel *> potValues;
|
||||
QVector<QSlider *> sliders;
|
||||
|
||||
SliderWidget * trimHLeft, * trimVLeft, * trimHRight, * trimVRight;
|
||||
QLabel * leftXPerc, * rightXPerc, * leftYPerc, * rightYPerc;
|
||||
QTabWidget * tabWidget;
|
||||
QVector<QLabel *> logicalSwitchLabels;
|
||||
QVector<QLabel *> logicalSwitchLabels2;
|
||||
QVector<QSlider *> channelSliders;
|
||||
QVector<QLabel *> channelValues;
|
||||
QVector<QLabel *> gvarValues;
|
||||
|
||||
void init();
|
||||
Node *nodeLeft;
|
||||
Node *nodeRight;
|
||||
QTimer *timer;
|
||||
QString windowName;
|
||||
unsigned int backLight;
|
||||
bool lightOn;
|
||||
int switches;
|
||||
unsigned int numGvars;
|
||||
unsigned int numFlightModes;
|
||||
#ifdef JOYSTICKS
|
||||
Joystick *joystick;
|
||||
int jscal[8][4];
|
||||
int jsmap[8];
|
||||
#endif
|
||||
|
||||
SimulatorInterface *simulator;
|
||||
unsigned int lastPhase;
|
||||
|
||||
void setupSticks();
|
||||
void setupTimer();
|
||||
void resizeEvent(QResizeEvent *event = 0);
|
||||
|
||||
virtual void getValues() = 0;
|
||||
void setValues();
|
||||
void centerSticks();
|
||||
|
||||
int getValue(qint8 i);
|
||||
bool getSwitch(int swtch, bool nc, qint8 level=0);
|
||||
void setTrims();
|
||||
QFrame * createLogicalSwitch(QWidget * parent, int switchNo, QVector<QLabel *> & labels);
|
||||
|
||||
int beepVal;
|
||||
|
||||
int lcdWidth;
|
||||
int lcdHeight;
|
||||
int lcdDepth;
|
||||
TelemetrySimulator * TelemetrySimu;
|
||||
TrainerSimulator * TrainerSimu;
|
||||
DebugOutput * DebugOut;
|
||||
|
||||
QString traceBuffer;
|
||||
QMutex traceMutex;
|
||||
QList<QString> traceList;
|
||||
void updateDebugOutput();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *);
|
||||
virtual void wheelEvent(QWheelEvent *);
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual void keyReleaseEvent(QKeyEvent *);
|
||||
static int screenshotIdx;
|
||||
int buttonPressed;
|
||||
int trimPressed;
|
||||
bool middleButtonPressed;
|
||||
|
||||
private slots:
|
||||
void onButtonPressed(int value);
|
||||
void on_FixRightY_clicked(bool checked);
|
||||
void on_FixRightX_clicked(bool checked);
|
||||
void on_FixLeftY_clicked(bool checked);
|
||||
void on_FixLeftX_clicked(bool checked);
|
||||
void on_holdRightY_clicked(bool checked);
|
||||
void on_holdRightX_clicked(bool checked);
|
||||
void on_holdLeftY_clicked(bool checked);
|
||||
void on_holdLeftX_clicked(bool checked);
|
||||
void on_trimHLeft_valueChanged(int);
|
||||
void on_trimVLeft_valueChanged(int);
|
||||
void on_trimHRight_valueChanged(int);
|
||||
void on_trimVRight_valueChanged(int);
|
||||
void onTimerEvent();
|
||||
void onTrimPressed();
|
||||
void onTrimReleased();
|
||||
void openTelemetrySimulator();
|
||||
void openTrainerSimulator();
|
||||
void openDebugOutput();
|
||||
void onDebugOutputClose();
|
||||
void luaReload();
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
void onjoystickAxisValueChanged(int axis, int value);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
class SimulatorDialog9X: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog9X(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog9X();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
virtual void setLightOn(bool enable);
|
||||
virtual void updateBeepButton();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
protected slots:
|
||||
void dialChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialog9X * ui;
|
||||
static uint32_t switchstatus;
|
||||
int beepShow;
|
||||
|
||||
};
|
||||
|
||||
class SimulatorDialogTaranis: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogTaranis(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogTaranis();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialogTaranis * ui;
|
||||
static uint32_t switchstatus;
|
||||
|
||||
private slots:
|
||||
void resetSH();
|
||||
void on_switchH_sliderReleased();
|
||||
};
|
||||
|
||||
class SimulatorDialogFlamenco: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogFlamenco(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogFlamenco();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialogFlamenco * ui;
|
||||
static uint32_t switchstatus;
|
||||
|
||||
private slots:
|
||||
void resetSH();
|
||||
void on_switchH_sliderReleased();
|
||||
};
|
||||
|
||||
class SimulatorDialogHorus: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogHorus(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogHorus();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialogHorus * ui;
|
||||
static uint32_t switchstatus;
|
||||
|
||||
private slots:
|
||||
void resetSH();
|
||||
void on_switchH_sliderReleased();
|
||||
};
|
||||
|
||||
|
||||
#include "modeledit/node.h"
|
||||
#include "telemetrysimu.h"
|
||||
#include "trainersimu.h"
|
||||
#include "debugoutput.h"
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
#include "joystick.h"
|
||||
#endif
|
||||
|
||||
#define TMR_OFF 0
|
||||
#define TMR_RUNNING 1
|
||||
#define TMR_BEEPING 2
|
||||
#define TMR_STOPPED 3
|
||||
|
||||
#define FLASH_DURATION 10
|
||||
|
||||
namespace Ui {
|
||||
class SimulatorDialog9X;
|
||||
class SimulatorDialogTaranis;
|
||||
class SimulatorDialogFlamenco;
|
||||
class SimulatorDialogHorus;
|
||||
}
|
||||
|
||||
// TODO rename + move?
|
||||
class LcdWidget;
|
||||
class SliderWidget;
|
||||
|
||||
#define SIMULATOR_FLAGS_NOTX 1
|
||||
#define SIMULATOR_FLAGS_STICK_MODE_LEFT 2
|
||||
#define SIMULATOR_FLAGS_S1 4
|
||||
#define SIMULATOR_FLAGS_S2 8
|
||||
#define SIMULATOR_FLAGS_S3 16
|
||||
#define SIMULATOR_FLAGS_S4 32 // reserved for the future
|
||||
#define SIMULATOR_FLAGS_S1_MULTI 64
|
||||
#define SIMULATOR_FLAGS_S2_MULTI 128
|
||||
#define SIMULATOR_FLAGS_S3_MULTI 256
|
||||
#define SIMULATOR_FLAGS_S4_MULTI 512 // reserved for the future
|
||||
|
||||
void traceCb(const char * text);
|
||||
|
||||
class SimulatorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog();
|
||||
|
||||
void start(const char * filename);
|
||||
void start(QByteArray & eeprom);
|
||||
virtual void traceCallback(const char * text);
|
||||
|
||||
protected:
|
||||
template <class T> void initUi(T * ui);
|
||||
virtual void setLightOn(bool enable) { }
|
||||
virtual void updateBeepButton() { }
|
||||
|
||||
unsigned int flags;
|
||||
LcdWidget * lcd;
|
||||
QGraphicsView * leftStick, * rightStick;
|
||||
QVector<QDial *> pots;
|
||||
QVector<QLabel *> potLabels;
|
||||
QVector<QLabel *> potValues;
|
||||
QVector<QSlider *> sliders;
|
||||
|
||||
SliderWidget * trimHLeft, * trimVLeft, * trimHRight, * trimVRight;
|
||||
QLabel * leftXPerc, * rightXPerc, * leftYPerc, * rightYPerc;
|
||||
QTabWidget * tabWidget;
|
||||
QVector<QLabel *> logicalSwitchLabels;
|
||||
QVector<QLabel *> logicalSwitchLabels2;
|
||||
QVector<QSlider *> channelSliders;
|
||||
QVector<QLabel *> channelValues;
|
||||
QVector<QLabel *> gvarValues;
|
||||
|
||||
void init();
|
||||
Node *nodeLeft;
|
||||
Node *nodeRight;
|
||||
QTimer *timer;
|
||||
QString windowName;
|
||||
unsigned int backLight;
|
||||
bool lightOn;
|
||||
int switches;
|
||||
unsigned int numGvars;
|
||||
unsigned int numFlightModes;
|
||||
#ifdef JOYSTICKS
|
||||
Joystick *joystick;
|
||||
int jscal[8][4];
|
||||
int jsmap[8];
|
||||
#endif
|
||||
|
||||
SimulatorInterface *simulator;
|
||||
unsigned int lastPhase;
|
||||
|
||||
void setupSticks();
|
||||
void setupTimer();
|
||||
void resizeEvent(QResizeEvent *event = 0);
|
||||
|
||||
virtual void getValues() = 0;
|
||||
void setValues();
|
||||
void centerSticks();
|
||||
|
||||
int getValue(qint8 i);
|
||||
bool getSwitch(int swtch, bool nc, qint8 level=0);
|
||||
void setTrims();
|
||||
QFrame * createLogicalSwitch(QWidget * parent, int switchNo, QVector<QLabel *> & labels);
|
||||
|
||||
int beepVal;
|
||||
|
||||
int lcdWidth;
|
||||
int lcdHeight;
|
||||
int lcdDepth;
|
||||
TelemetrySimulator * TelemetrySimu;
|
||||
TrainerSimulator * TrainerSimu;
|
||||
DebugOutput * DebugOut;
|
||||
|
||||
QString traceBuffer;
|
||||
QMutex traceMutex;
|
||||
QList<QString> traceList;
|
||||
void updateDebugOutput();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *);
|
||||
virtual void wheelEvent(QWheelEvent *);
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual void keyReleaseEvent(QKeyEvent *);
|
||||
static int screenshotIdx;
|
||||
int buttonPressed;
|
||||
int trimPressed;
|
||||
bool middleButtonPressed;
|
||||
|
||||
private slots:
|
||||
void onButtonPressed(int value);
|
||||
void on_FixRightY_clicked(bool checked);
|
||||
void on_FixRightX_clicked(bool checked);
|
||||
void on_FixLeftY_clicked(bool checked);
|
||||
void on_FixLeftX_clicked(bool checked);
|
||||
void on_holdRightY_clicked(bool checked);
|
||||
void on_holdRightX_clicked(bool checked);
|
||||
void on_holdLeftY_clicked(bool checked);
|
||||
void on_holdLeftX_clicked(bool checked);
|
||||
void on_trimHLeft_valueChanged(int);
|
||||
void on_trimVLeft_valueChanged(int);
|
||||
void on_trimHRight_valueChanged(int);
|
||||
void on_trimVRight_valueChanged(int);
|
||||
void onTimerEvent();
|
||||
void onTrimPressed();
|
||||
void onTrimReleased();
|
||||
void openTelemetrySimulator();
|
||||
void openTrainerSimulator();
|
||||
void openDebugOutput();
|
||||
void onDebugOutputClose();
|
||||
void luaReload();
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
void onjoystickAxisValueChanged(int axis, int value);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
class SimulatorDialog9X: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog9X(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog9X();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
virtual void setLightOn(bool enable);
|
||||
virtual void updateBeepButton();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
protected slots:
|
||||
void dialChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialog9X * ui;
|
||||
static uint32_t switchstatus;
|
||||
int beepShow;
|
||||
|
||||
};
|
||||
|
||||
class SimulatorDialogTaranis: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogTaranis(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogTaranis();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialogTaranis * ui;
|
||||
static uint32_t switchstatus;
|
||||
|
||||
private slots:
|
||||
void resetSH();
|
||||
void on_switchH_sliderReleased();
|
||||
};
|
||||
|
||||
class SimulatorDialogFlamenco: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogFlamenco(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogFlamenco();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialogFlamenco * ui;
|
||||
static uint32_t switchstatus;
|
||||
|
||||
private slots:
|
||||
void resetSH();
|
||||
void on_switchH_sliderReleased();
|
||||
};
|
||||
|
||||
class SimulatorDialogHorus: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogHorus(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogHorus();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
void saveSwitches(void);
|
||||
void restoreSwitches(void);
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialogHorus * ui;
|
||||
static uint32_t switchstatus;
|
||||
|
||||
private slots:
|
||||
void resetSH();
|
||||
void on_switchH_sliderReleased();
|
||||
};
|
||||
|
||||
#endif // _SIMULATORDIALOG_H_
|
||||
|
||||
Reference in New Issue
Block a user