Imported existing sources
This commit is contained in:
37
DbGuiLib.pro
Normal file
37
DbGuiLib.pro
Normal file
@@ -0,0 +1,37 @@
|
||||
QT += core gui widgets
|
||||
|
||||
PROJECT_ROOT = ../..
|
||||
|
||||
TARGET = dbgui
|
||||
|
||||
DEFINES += DBGUILIB_LIBRARY
|
||||
|
||||
SOURCES += ledindicator.cpp \
|
||||
matrix4x4widget.cpp \
|
||||
quaternionwidget.cpp \
|
||||
urlwidget.cpp \
|
||||
vector2dwidget.cpp \
|
||||
vector3dwidget.cpp \
|
||||
vector4dwidget.cpp \
|
||||
stringlistwidget.cpp \
|
||||
editorfactory.cpp
|
||||
|
||||
HEADERS += dbguilib_global.h \
|
||||
ledindicator.h \
|
||||
limitedspinbox.h \
|
||||
matrix4x4widget.h \
|
||||
quaternionwidget.h \
|
||||
urlwidget.h \
|
||||
vector2dwidget.h \
|
||||
vector3dwidget.h \
|
||||
vector4dwidget.h \
|
||||
stringlistwidget.h \
|
||||
editorfactory.h
|
||||
|
||||
FORMS += qstringlistwidget.ui
|
||||
|
||||
RESOURCES +=
|
||||
|
||||
TRANSLATIONS +=
|
||||
|
||||
include($${PROJECT_ROOT}/lib.pri)
|
9
dbguilib_global.h
Normal file
9
dbguilib_global.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if defined(DBGUILIB_LIBRARY)
|
||||
# define DBGUILIB_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define DBGUILIB_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
87
editorfactory.cpp
Normal file
87
editorfactory.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "editorfactory.h"
|
||||
|
||||
#include <QStandardItemEditorCreator>
|
||||
#include <QCheckBox>
|
||||
#include <QSpinBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QDateEdit>
|
||||
#include <QTimeEdit>
|
||||
#include <QDateTimeEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QKeySequenceEdit>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "limitedspinbox.h"
|
||||
#include "stringlistwidget.h"
|
||||
#include "urlwidget.h"
|
||||
#include "matrix4x4widget.h"
|
||||
#include "vector2dwidget.h"
|
||||
#include "vector3dwidget.h"
|
||||
#include "vector4dwidget.h"
|
||||
#include "quaternionwidget.h"
|
||||
|
||||
BetterItemFactory::BetterItemFactory() :
|
||||
QItemEditorFactory()
|
||||
{
|
||||
registerEditor(QVariant::Bool, new QStandardItemEditorCreator<QCheckBox>());
|
||||
registerEditor(QVariant::Int, new QStandardItemEditorCreator<LimitedSpinBox<std::numeric_limits<qint32>::min(), std::numeric_limits<qint32>::max()> >());
|
||||
//registerEditor(QVariant::UInt, new QStandardItemEditorCreator<LimitedSpinBox<std::numeric_limits<quint32>::min(), std::numeric_limits<quint32>::max()> >());
|
||||
//registerEditor(QVariant::LongLong, new QStandardItemEditorCreator<LimitedSpinBox<std::numeric_limits<qint64>::min(), std::numeric_limits<qint64>::max()> >()); //TODO: implement 64 bit
|
||||
//registerEditor(QVariant::ULongLong, new QStandardItemEditorCreator<LimitedSpinBox<std::numeric_limits<quint64>::min(), std::numeric_limits<quint64>::max()> >()); //TODO: implement 64 bit
|
||||
registerEditor(QVariant::Double, new QStandardItemEditorCreator<QDoubleSpinBox>());
|
||||
registerEditor(QMetaType::Float, new QStandardItemEditorCreator<QDoubleSpinBox>()); //TODO: Make this a real QFloatSpinBox
|
||||
registerEditor(QVariant::ULongLong, new QStandardItemEditorCreator<LimitedSpinBox<std::numeric_limits<char>::min(), std::numeric_limits<char>::max()> >());
|
||||
//registerEditor(QVariant::Map, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::List, Q_NULLPTR); //TODO
|
||||
registerEditor(QVariant::String, new QStandardItemEditorCreator<QLineEdit>());
|
||||
registerEditor(QVariant::StringList, new QStandardItemEditorCreator<StringListWidget>());
|
||||
//registerEditor(QVariant::ByteArray, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::BitArray, Q_NULLPTR); //TODO
|
||||
registerEditor(QVariant::Date, new QStandardItemEditorCreator<QDateEdit>());
|
||||
registerEditor(QVariant::Time, new QStandardItemEditorCreator<QTimeEdit>());
|
||||
registerEditor(QVariant::DateTime, new QStandardItemEditorCreator<QDateTimeEdit>());
|
||||
registerEditor(QVariant::Url, new QStandardItemEditorCreator<UrlWidget>()); //TODO
|
||||
//registerEditor(QVariant::Locale, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Rect, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::RectF, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Size, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::SizeF, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Line, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::LineF, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Point, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::PointF, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::RegExp, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::RegularExpression, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Hash, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::EasingCurve, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Uuid, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::ModelIndex, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::PersistentModelIndex, Q_NULLPTR); //TODO
|
||||
|
||||
//registerEditor(QVariant::Font, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Pixmap, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Brush, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Color, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Palette, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Image, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Polygon, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Region, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Bitmap, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Cursor, Q_NULLPTR); //TODO
|
||||
registerEditor(QVariant::KeySequence, new QStandardItemEditorCreator<QKeySequenceEdit>()); //TODO
|
||||
//registerEditor(QVariant::Pen, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::TextLength, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::TextFormat, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Matrix, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Transform, Q_NULLPTR); //TODO
|
||||
registerEditor(QVariant::Matrix4x4, new QStandardItemEditorCreator<Matrix4x4Widget>());
|
||||
registerEditor(QVariant::Vector2D, new QStandardItemEditorCreator<Vector2DWidget>());
|
||||
registerEditor(QVariant::Vector3D, new QStandardItemEditorCreator<Vector3DWidget>());
|
||||
registerEditor(QVariant::Vector4D, new QStandardItemEditorCreator<Vector4DWidget>());
|
||||
registerEditor(QVariant::Quaternion, new QStandardItemEditorCreator<QuaternionWidget>());
|
||||
//registerEditor(QVariant::PolygonF, Q_NULLPTR); //TODO
|
||||
//registerEditor(QVariant::Icon, Q_NULLPTR); //TODO
|
||||
|
||||
//registerEditor(QVariant::SizePolicy, Q_NULLPTR); //TODO
|
||||
}
|
10
editorfactory.h
Normal file
10
editorfactory.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <QItemEditorFactory>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
class DBGUILIB_EXPORT BetterItemFactory : public QItemEditorFactory
|
||||
{
|
||||
public:
|
||||
BetterItemFactory();
|
||||
};
|
37
ledindicator.cpp
Normal file
37
ledindicator.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "ledindicator.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
LedIndicator::LedIndicator(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setMinimumSize(16, 16);
|
||||
}
|
||||
|
||||
void LedIndicator::setColor(const QColor &color)
|
||||
{
|
||||
m_color = color;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void LedIndicator::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QRect ellipseRect;
|
||||
|
||||
if(width() < height())
|
||||
ellipseRect = QRect(0, height() / 2 - width() / 2, width(), width());
|
||||
else if(width() > height())
|
||||
ellipseRect = QRect(width() / 2 - height() / 2, 0, height(), height());
|
||||
else
|
||||
ellipseRect = rect();
|
||||
|
||||
ellipseRect.setWidth(ellipseRect.width() - 1);
|
||||
ellipseRect.setHeight(ellipseRect.height() - 1);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(m_color);
|
||||
painter.drawEllipse(ellipseRect);
|
||||
}
|
23
ledindicator.h
Normal file
23
ledindicator.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
class DBGUILIB_EXPORT LedIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LedIndicator(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
void setColor(const QColor &color);
|
||||
|
||||
protected:
|
||||
// QWidget interface
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
18
limitedspinbox.h
Normal file
18
limitedspinbox.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
template<int Tmin, int Tmax>
|
||||
class LimitedSpinBox : public QSpinBox
|
||||
{
|
||||
//No Q_OBJECT because template (not needed anyways)
|
||||
|
||||
public:
|
||||
LimitedSpinBox(QWidget *parent = Q_NULLPTR);
|
||||
};
|
||||
|
||||
template<int Tmin, int Tmax>
|
||||
LimitedSpinBox<Tmin, Tmax>::LimitedSpinBox(QWidget *parent) : QSpinBox(parent)
|
||||
{
|
||||
setRange(Tmin, Tmax);
|
||||
}
|
69
matrix4x4widget.cpp
Normal file
69
matrix4x4widget.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "matrix4x4widget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QVector4D>
|
||||
|
||||
Matrix4x4Widget::Matrix4x4Widget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
auto layout = new QGridLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(m_doubleSpinBox11 = new QDoubleSpinBox(this), 0, 0);
|
||||
layout->addWidget(m_doubleSpinBox12 = new QDoubleSpinBox(this), 0, 1);
|
||||
layout->addWidget(m_doubleSpinBox13 = new QDoubleSpinBox(this), 0, 2);
|
||||
layout->addWidget(m_doubleSpinBox14 = new QDoubleSpinBox(this), 0, 3);
|
||||
layout->addWidget(m_doubleSpinBox21 = new QDoubleSpinBox(this), 1, 0);
|
||||
layout->addWidget(m_doubleSpinBox22 = new QDoubleSpinBox(this), 1, 1);
|
||||
layout->addWidget(m_doubleSpinBox23 = new QDoubleSpinBox(this), 1, 2);
|
||||
layout->addWidget(m_doubleSpinBox24 = new QDoubleSpinBox(this), 1, 3);
|
||||
layout->addWidget(m_doubleSpinBox31 = new QDoubleSpinBox(this), 2, 0);
|
||||
layout->addWidget(m_doubleSpinBox32 = new QDoubleSpinBox(this), 2, 1);
|
||||
layout->addWidget(m_doubleSpinBox33 = new QDoubleSpinBox(this), 2, 2);
|
||||
layout->addWidget(m_doubleSpinBox34 = new QDoubleSpinBox(this), 2, 3);
|
||||
layout->addWidget(m_doubleSpinBox41 = new QDoubleSpinBox(this), 3, 0);
|
||||
layout->addWidget(m_doubleSpinBox42 = new QDoubleSpinBox(this), 3, 1);
|
||||
layout->addWidget(m_doubleSpinBox43 = new QDoubleSpinBox(this), 3, 2);
|
||||
layout->addWidget(m_doubleSpinBox44 = new QDoubleSpinBox(this), 3, 3);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QMatrix4x4 Matrix4x4Widget::value() const
|
||||
{
|
||||
return QMatrix4x4(m_doubleSpinBox11->value(), m_doubleSpinBox12->value(), m_doubleSpinBox13->value(), m_doubleSpinBox14->value(),
|
||||
m_doubleSpinBox21->value(), m_doubleSpinBox22->value(), m_doubleSpinBox23->value(), m_doubleSpinBox24->value(),
|
||||
m_doubleSpinBox31->value(), m_doubleSpinBox32->value(), m_doubleSpinBox33->value(), m_doubleSpinBox34->value(),
|
||||
m_doubleSpinBox41->value(), m_doubleSpinBox42->value(), m_doubleSpinBox43->value(), m_doubleSpinBox44->value());
|
||||
}
|
||||
|
||||
void Matrix4x4Widget::setValue(const QMatrix4x4 &value)
|
||||
{
|
||||
{
|
||||
auto row = value.row(0);
|
||||
m_doubleSpinBox11->setValue(row.x());
|
||||
m_doubleSpinBox12->setValue(row.y());
|
||||
m_doubleSpinBox13->setValue(row.z());
|
||||
m_doubleSpinBox14->setValue(row.w());
|
||||
}
|
||||
{
|
||||
auto row = value.row(1);
|
||||
m_doubleSpinBox21->setValue(row.x());
|
||||
m_doubleSpinBox22->setValue(row.y());
|
||||
m_doubleSpinBox23->setValue(row.z());
|
||||
m_doubleSpinBox24->setValue(row.w());
|
||||
}
|
||||
{
|
||||
auto row = value.row(2);
|
||||
m_doubleSpinBox31->setValue(row.x());
|
||||
m_doubleSpinBox32->setValue(row.y());
|
||||
m_doubleSpinBox33->setValue(row.z());
|
||||
m_doubleSpinBox34->setValue(row.w());
|
||||
}
|
||||
{
|
||||
auto row = value.row(3);
|
||||
m_doubleSpinBox41->setValue(row.x());
|
||||
m_doubleSpinBox42->setValue(row.y());
|
||||
m_doubleSpinBox43->setValue(row.z());
|
||||
m_doubleSpinBox44->setValue(row.w());
|
||||
}
|
||||
}
|
29
matrix4x4widget.h
Normal file
29
matrix4x4widget.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
#include <QMatrix4x4>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class DBGUILIB_EXPORT Matrix4x4Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QMatrix4x4 value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
Matrix4x4Widget(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
QMatrix4x4 value() const;
|
||||
void setValue(const QMatrix4x4 &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QMatrix4x4 &value);
|
||||
|
||||
private:
|
||||
QDoubleSpinBox *m_doubleSpinBox11, *m_doubleSpinBox12, *m_doubleSpinBox13, *m_doubleSpinBox14;
|
||||
QDoubleSpinBox *m_doubleSpinBox21, *m_doubleSpinBox22, *m_doubleSpinBox23, *m_doubleSpinBox24;
|
||||
QDoubleSpinBox *m_doubleSpinBox31, *m_doubleSpinBox32, *m_doubleSpinBox33, *m_doubleSpinBox34;
|
||||
QDoubleSpinBox *m_doubleSpinBox41, *m_doubleSpinBox42, *m_doubleSpinBox43, *m_doubleSpinBox44;
|
||||
};
|
49
qstringlistwidget.ui
Normal file
49
qstringlistwidget.ui
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QStringListWidget</class>
|
||||
<widget class="QWidget" name="QStringListWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>452</width>
|
||||
<height>369</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonAdd">
|
||||
<property name="text">
|
||||
<string>Add entry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonDelete">
|
||||
<property name="text">
|
||||
<string>Delete entry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="listView">
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
29
quaternionwidget.cpp
Normal file
29
quaternionwidget.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "quaternionwidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
QuaternionWidget::QuaternionWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxZ = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxScalar = new QDoubleSpinBox(this));
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QQuaternion QuaternionWidget::value() const
|
||||
{
|
||||
return QQuaternion(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value(), m_doubleSpinBoxZ->value(), m_doubleSpinBoxScalar->value());
|
||||
}
|
||||
|
||||
void QuaternionWidget::setValue(const QQuaternion &value)
|
||||
{
|
||||
m_doubleSpinBoxX->setValue(value.x());
|
||||
m_doubleSpinBoxY->setValue(value.y());
|
||||
m_doubleSpinBoxZ->setValue(value.z());
|
||||
m_doubleSpinBoxScalar->setValue(value.scalar());
|
||||
}
|
29
quaternionwidget.h
Normal file
29
quaternionwidget.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
#include <QQuaternion>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class DBGUILIB_EXPORT QuaternionWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QQuaternion value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
QuaternionWidget(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
QQuaternion value() const;
|
||||
void setValue(const QQuaternion &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QQuaternion &value);
|
||||
|
||||
private:
|
||||
QDoubleSpinBox *m_doubleSpinBoxX;
|
||||
QDoubleSpinBox *m_doubleSpinBoxY;
|
||||
QDoubleSpinBox *m_doubleSpinBoxZ;
|
||||
QDoubleSpinBox *m_doubleSpinBoxScalar;
|
||||
};
|
70
stringlistwidget.cpp
Normal file
70
stringlistwidget.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "stringlistwidget.h"
|
||||
#include "ui_qstringlistwidget.h"
|
||||
|
||||
#include <QStringListModel>
|
||||
|
||||
StringListWidget::StringListWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::QStringListWidget),
|
||||
m_model(new QStringListModel(this))
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
StringListWidget::StringListWidget(const QStringList &stringList, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::QStringListWidget),
|
||||
m_model(new QStringListModel(stringList, this))
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
StringListWidget::~StringListWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QStringList StringListWidget::value() const
|
||||
{
|
||||
return m_model->stringList();
|
||||
}
|
||||
|
||||
void StringListWidget::setValue(const QStringList &stringList)
|
||||
{
|
||||
m_model->setStringList(stringList);
|
||||
}
|
||||
|
||||
void StringListWidget::addPressed()
|
||||
{
|
||||
auto index = ui->listView->currentIndex();
|
||||
|
||||
m_model->insertRow(index.isValid() ? index.row() + 1: m_model->rowCount());
|
||||
}
|
||||
|
||||
void StringListWidget::deletePressed()
|
||||
{
|
||||
auto index = ui->listView->currentIndex();
|
||||
|
||||
if(!index.isValid())
|
||||
return;
|
||||
|
||||
m_model->removeRow(index.row());
|
||||
}
|
||||
|
||||
void StringListWidget::selectionChanged()
|
||||
{
|
||||
ui->pushButtonDelete->setEnabled(ui->listView->currentIndex().isValid());
|
||||
}
|
||||
|
||||
void StringListWidget::setup()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->listView->setModel(m_model);
|
||||
|
||||
connect(ui->pushButtonAdd, &QAbstractButton::pressed, this, &StringListWidget::addPressed);
|
||||
connect(ui->pushButtonDelete, &QAbstractButton::pressed, this, &StringListWidget::deletePressed);
|
||||
connect(ui->listView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &StringListWidget::selectionChanged);
|
||||
|
||||
selectionChanged();
|
||||
}
|
36
stringlistwidget.h
Normal file
36
stringlistwidget.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
class QStringListModel;
|
||||
|
||||
namespace Ui { class QStringListWidget; }
|
||||
|
||||
class DBGUILIB_EXPORT StringListWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QStringList value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
explicit StringListWidget(QWidget *parent = Q_NULLPTR);
|
||||
explicit StringListWidget(const QStringList &value, QWidget *parent = Q_NULLPTR);
|
||||
~StringListWidget();
|
||||
|
||||
QStringList value() const;
|
||||
void setValue(const QStringList &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QStringList &value);
|
||||
|
||||
private Q_SLOTS:
|
||||
void addPressed();
|
||||
void deletePressed();
|
||||
void selectionChanged();
|
||||
|
||||
private:
|
||||
void setup();
|
||||
|
||||
Ui::QStringListWidget *ui;
|
||||
QStringListModel *m_model;
|
||||
};
|
37
urlwidget.cpp
Normal file
37
urlwidget.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "urlwidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
#include <QFileDialog>
|
||||
|
||||
UrlWidget::UrlWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(m_lineEdit = new QLineEdit(this));
|
||||
{
|
||||
auto toolButton = new QToolButton(this);
|
||||
connect(toolButton, &QAbstractButton::pressed, this, &UrlWidget::pressed);
|
||||
layout->addWidget(toolButton);
|
||||
}
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QUrl UrlWidget::value() const
|
||||
{
|
||||
return QUrl(m_lineEdit->text());
|
||||
}
|
||||
|
||||
void UrlWidget::setValue(const QUrl &value)
|
||||
{
|
||||
m_lineEdit->setText(value.toString());
|
||||
}
|
||||
|
||||
void UrlWidget::pressed()
|
||||
{
|
||||
auto path = QFileDialog::getOpenFileName(this);
|
||||
if(!path.isEmpty())
|
||||
m_lineEdit->setText(path);
|
||||
}
|
29
urlwidget.h
Normal file
29
urlwidget.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
class DBGUILIB_EXPORT UrlWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QUrl value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
UrlWidget(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
QUrl value() const;
|
||||
void setValue(const QUrl &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QUrl &value);
|
||||
|
||||
private Q_SLOTS:
|
||||
void pressed();
|
||||
|
||||
private:
|
||||
QLineEdit *m_lineEdit;
|
||||
};
|
25
vector2dwidget.cpp
Normal file
25
vector2dwidget.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "vector2dwidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
Vector2DWidget::Vector2DWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this));
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QVector2D Vector2DWidget::value() const
|
||||
{
|
||||
return QVector2D(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value());
|
||||
}
|
||||
|
||||
void Vector2DWidget::setValue(const QVector2D &value)
|
||||
{
|
||||
m_doubleSpinBoxX->setValue(value.x());
|
||||
m_doubleSpinBoxY->setValue(value.y());
|
||||
}
|
27
vector2dwidget.h
Normal file
27
vector2dwidget.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class DBGUILIB_EXPORT Vector2DWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVector2D value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
Vector2DWidget(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
QVector2D value() const;
|
||||
void setValue(const QVector2D &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QVector2D &value);
|
||||
|
||||
private:
|
||||
QDoubleSpinBox *m_doubleSpinBoxX;
|
||||
QDoubleSpinBox *m_doubleSpinBoxY;
|
||||
};
|
27
vector3dwidget.cpp
Normal file
27
vector3dwidget.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "vector3dwidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
Vector3DWidget::Vector3DWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxZ = new QDoubleSpinBox(this));
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QVector3D Vector3DWidget::value() const
|
||||
{
|
||||
return QVector3D(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value(), m_doubleSpinBoxZ->value());
|
||||
}
|
||||
|
||||
void Vector3DWidget::setValue(const QVector3D &value)
|
||||
{
|
||||
m_doubleSpinBoxX->setValue(value.x());
|
||||
m_doubleSpinBoxY->setValue(value.y());
|
||||
m_doubleSpinBoxZ->setValue(value.z());
|
||||
}
|
28
vector3dwidget.h
Normal file
28
vector3dwidget.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
#include <QVector3D>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class DBGUILIB_EXPORT Vector3DWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVector3D value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
Vector3DWidget(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
QVector3D value() const;
|
||||
void setValue(const QVector3D &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QVector3D &value);
|
||||
|
||||
private:
|
||||
QDoubleSpinBox *m_doubleSpinBoxX;
|
||||
QDoubleSpinBox *m_doubleSpinBoxY;
|
||||
QDoubleSpinBox *m_doubleSpinBoxZ;
|
||||
};
|
28
vector4dwidget.cpp
Normal file
28
vector4dwidget.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "vector4dwidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
Vector4DWidget::Vector4DWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->addWidget(m_doubleSpinBoxX = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxY = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxZ = new QDoubleSpinBox(this));
|
||||
layout->addWidget(m_doubleSpinBoxW = new QDoubleSpinBox(this));
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
QVector4D Vector4DWidget::value() const
|
||||
{
|
||||
return QVector4D(m_doubleSpinBoxX->value(), m_doubleSpinBoxY->value(), m_doubleSpinBoxZ->value(), m_doubleSpinBoxW->value());
|
||||
}
|
||||
|
||||
void Vector4DWidget::setValue(const QVector4D &value)
|
||||
{
|
||||
m_doubleSpinBoxX->setValue(value.x());
|
||||
m_doubleSpinBoxY->setValue(value.y());
|
||||
m_doubleSpinBoxZ->setValue(value.z());
|
||||
m_doubleSpinBoxW->setValue(value.w());
|
||||
}
|
32
vector4dwidget.h
Normal file
32
vector4dwidget.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef VECTOR4DWIDGET_H
|
||||
#define VECTOR4DWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "dbguilib_global.h"
|
||||
|
||||
#include <QVector4D>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
|
||||
class DBGUILIB_EXPORT Vector4DWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVector4D value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
Vector4DWidget(QWidget *parent = Q_NULLPTR);
|
||||
|
||||
QVector4D value() const;
|
||||
void setValue(const QVector4D &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(const QVector4D &value);
|
||||
|
||||
private:
|
||||
QDoubleSpinBox *m_doubleSpinBoxX;
|
||||
QDoubleSpinBox *m_doubleSpinBoxY;
|
||||
QDoubleSpinBox *m_doubleSpinBoxZ;
|
||||
QDoubleSpinBox *m_doubleSpinBoxW;
|
||||
};
|
||||
|
||||
#endif // VECTOR4DWIDGET_H
|
Reference in New Issue
Block a user