[Companion] Unix format used everywhere
This commit is contained in:
@@ -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_
|
||||
|
||||
Reference in New Issue
Block a user