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
|
|
|
{
|
2013-06-20 23:06:25 +00:00
|
|
|
/// Abstract base class for widgets which are used in user preferences dialog
|
2013-05-08 01:33:42 +00:00
|
|
|
class AbstractWidget : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QLayout *mLayout;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// Passed layout is assigned the constructed widget.
|
|
|
|
/// if no layout is passed, one is created.
|
2013-05-08 01:33:42 +00:00
|
|
|
explicit AbstractWidget (QLayout *layout = 0, QWidget* parent = 0)
|
|
|
|
: QObject (parent), mLayout (layout)
|
|
|
|
{}
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// retrieve layout for insertion into itemblock
|
2013-05-08 01:33:42 +00:00
|
|
|
QLayout *getLayout();
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// create the derived widget instance
|
2013-05-08 01:33:42 +00:00
|
|
|
void build (QWidget* widget, WidgetDef &def, bool noLabel = false);
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// reference to the derived widget instance
|
2013-05-08 01:33:42 +00:00
|
|
|
virtual QWidget *widget() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// Callback called by receiving slot for widget udpates
|
2013-05-08 01:33:42 +00:00
|
|
|
virtual void updateWidget (const QString &value) = 0;
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// 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:
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// Creates layout and assigns label and widget as appropriate
|
2013-05-12 19:28:36 +00:00
|
|
|
void createLayout (Orientation direction, bool isZeroMargin);
|
2013-06-20 23:06:25 +00:00
|
|
|
|
|
|
|
/// Creates label and widget according to passed definition
|
2013-05-08 01:33:42 +00:00
|
|
|
void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel);
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// outbound update signal
|
2013-05-08 01:33:42 +00:00
|
|
|
void signalUpdateItem (const QString &value);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// receives inbound updates
|
2013-05-08 01:33:42 +00:00
|
|
|
void slotUpdateWidget (const QString &value);
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// Overloads for outbound updates from derived widget signal
|
2013-05-08 01:33:42 +00:00
|
|
|
void slotUpdateItem (const QString &value);
|
|
|
|
void slotUpdateItem (bool value);
|
|
|
|
void slotUpdateItem (int value);
|
|
|
|
void slotUpdateItem (QListWidgetItem* current, QListWidgetItem* previous);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // ABSTRACTWIDGET_HPP
|