Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+202
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* Widgets that change from QLabel to Q* if clicked (and not read only)
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QStackedWidget>
|
||||
#include <QMap>
|
||||
|
||||
class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
|
||||
namespace LtsWidgets {
|
||||
class LtsBitfieldWidget;
|
||||
}
|
||||
|
||||
enum class RwMode {
|
||||
ReadOnly,
|
||||
WriteOnly,
|
||||
ReadWrite
|
||||
};
|
||||
|
||||
class MyLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QLabel::QLabel;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
|
||||
};
|
||||
|
||||
class ResizableStackedWidget : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ResizableStackedWidget(QWidget *parent = nullptr);
|
||||
|
||||
int addWigdet(QWidget *widget);
|
||||
int insertWidget(int index, QWidget *widget);
|
||||
|
||||
private slots:
|
||||
void onCurrentChanged(int index);
|
||||
|
||||
};
|
||||
|
||||
class RWWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RWWidget(QWidget *parent = nullptr);
|
||||
|
||||
void setToolTip(const QString &string);
|
||||
|
||||
public slots:
|
||||
void onSetWritable();
|
||||
|
||||
private slots:
|
||||
void onSetWritablePrivate();
|
||||
|
||||
signals:
|
||||
void writableRequested();
|
||||
|
||||
protected:
|
||||
MyLabel *m_label;
|
||||
ResizableStackedWidget *m_stackedWidget;
|
||||
QWidget *m_editableWidget;
|
||||
|
||||
};
|
||||
|
||||
class RWSpinBox : public RWWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RWSpinBox(RwMode readOnly = RwMode::ReadWrite, QWidget *parent = nullptr);
|
||||
|
||||
void setMinimum(int min);
|
||||
void setMaximum(int max);
|
||||
|
||||
void setValue(int val);
|
||||
int value() const;
|
||||
|
||||
private:
|
||||
QSpinBox *m_spinBox;
|
||||
|
||||
};
|
||||
|
||||
class RWDoubleSpinBox : public RWWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RWDoubleSpinBox(RwMode readOnly = RwMode::ReadWrite, QWidget *parent = nullptr);
|
||||
|
||||
void setMinimum(double min);
|
||||
void setMaximum(double max);
|
||||
void setDecimals(int prec);
|
||||
|
||||
void setValue(double val);
|
||||
double value() const;
|
||||
|
||||
signals:
|
||||
void valueChanged();
|
||||
private:
|
||||
QDoubleSpinBox *m_doubleSpinBox;
|
||||
int m_precision;
|
||||
|
||||
};
|
||||
|
||||
class RWCheckBox : public RWWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RWCheckBox(RwMode readOnly = RwMode::ReadWrite, QWidget *parent = nullptr);
|
||||
|
||||
void setChecked(bool val);
|
||||
bool isChecked() const;
|
||||
|
||||
private:
|
||||
QCheckBox *m_checkBox;
|
||||
|
||||
};
|
||||
|
||||
class RWLineEdit : public RWWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RWLineEdit(RwMode readOnly = RwMode::ReadWrite, QWidget *parent = nullptr);
|
||||
|
||||
void setMaxLength(int length);
|
||||
|
||||
void setText(const QString &text);
|
||||
QString text() const;
|
||||
|
||||
private:
|
||||
QLineEdit *m_lineEdit;
|
||||
|
||||
};
|
||||
|
||||
class RWComboBox : public RWWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RWComboBox(RwMode readOnly = RwMode::ReadWrite, QWidget *parent = nullptr);
|
||||
|
||||
void addItem(const QString &text, int ordinal = -1);
|
||||
void insertItem(int index, const QString &text, int ordinal = -1);
|
||||
int count() const;
|
||||
// int currentIndex() const; //Shouldn't be used...
|
||||
int currentValue() const;
|
||||
QString currentText() const;
|
||||
// void setCurrentIndex(int index); //Shouldn't be used...
|
||||
void setCurrentValue(int ordinal);
|
||||
|
||||
|
||||
private:
|
||||
QComboBox *m_comboBox;
|
||||
QMap<int, QString> m_values; // For ReadOnly without ComboBox
|
||||
|
||||
};
|
||||
|
||||
class RWBitfieldWidget : public RWWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RWBitfieldWidget(RwMode readOnly = RwMode::ReadWrite, QWidget *parent = nullptr);
|
||||
|
||||
void setValue(quint8 val);
|
||||
quint8 value();
|
||||
|
||||
void setHasCaption(bool option);
|
||||
bool hasCaption();
|
||||
|
||||
signals:
|
||||
void valueChanged(quint8 newValue);
|
||||
void hasCaptionChanged(bool option);
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsBitfieldWidget *m_bitfield;
|
||||
};
|
||||
Reference in new issue
Block a user