2013-05-08 01:33:42 +00:00
|
|
|
#ifndef ABSTRACTWIDGET_HPP
|
|
|
|
#define ABSTRACTWIDGET_HPP
|
|
|
|
|
|
|
|
#include <QWidget>
|
2013-05-11 10:55:46 +00:00
|
|
|
#include "support.hpp"
|
2013-05-08 01:33:42 +00:00
|
|
|
|
|
|
|
class QLayout;
|
|
|
|
|
2013-05-11 10:55:46 +00:00
|
|
|
namespace CSVSettings
|
2013-05-08 01:33:42 +00:00
|
|
|
{
|
|
|
|
class AbstractWidget : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QLayout *mLayout;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit AbstractWidget (QLayout *layout = 0, QWidget* parent = 0)
|
|
|
|
: QObject (parent), mLayout (layout)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//retrieve layout for insertion into itemblock
|
|
|
|
QLayout *getLayout();
|
|
|
|
|
|
|
|
//create the derived widget instance
|
|
|
|
void build (QWidget* widget, WidgetDef &def, bool noLabel = false);
|
|
|
|
|
|
|
|
//reference to the derived widget instance
|
|
|
|
virtual QWidget *widget() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
//called by inbound signal for type-specific widget udpates
|
|
|
|
virtual void updateWidget (const QString &value) = 0;
|
|
|
|
|
|
|
|
//converts user-defined enum to Qt equivalents
|
2013-05-12 19:28:36 +00:00
|
|
|
QFlags<Qt::AlignmentFlag> getAlignment (Alignment flag);
|
2013-05-08 01:33:42 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//widget initialization utilities
|
2013-05-12 19:28:36 +00:00
|
|
|
void createLayout (Orientation direction, bool isZeroMargin);
|
2013-05-08 01:33:42 +00:00
|
|
|
void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel);
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
//outbound update
|
|
|
|
void signalUpdateItem (const QString &value);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
//inbound updates
|
|
|
|
void slotUpdateWidget (const QString &value);
|
|
|
|
|
|
|
|
//Outbound updates from derived widget signal
|
|
|
|
void slotUpdateItem (const QString &value);
|
|
|
|
void slotUpdateItem (bool value);
|
|
|
|
void slotUpdateItem (int value);
|
|
|
|
void slotUpdateItem (QListWidgetItem* current, QListWidgetItem* previous);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // ABSTRACTWIDGET_HPP
|