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