Public Member Functions | Protected Member Functions

SensorEditor Class Reference
[Editors]

Editor for sensors. More...

#include <projecteditor.h>

Inheritance diagram for SensorEditor:
Inheritance graph
[legend]
Collaboration diagram for SensorEditor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SensorEditor (QWidget *parent=0)

Protected Member Functions

virtual void onCurrentRecordChange (int row)
virtual void updateButtons ()
virtual void onQueryChange ()

Detailed Description

Editor for sensors.


Constructor & Destructor Documentation

SensorEditor::SensorEditor ( QWidget parent = 0  )  [inline]

                                      :
            MappedBaseEditor(parent), channelView(new SensorChannelView(this)) {
        setObjectName("SesnorEditor");
        setWindowTitle("Sensor editor");

        // set source
        setTable("tbl_sensors");

        // widget setup
        QLabel *type = new QLabel("&Type*:", this);
        QLabel *sn = new QLabel("&Serial number*:", this);
        QLabel *name = new QLabel("&Name:", this);
        QLabel *category = new QLabel("&Category*:", this);
        QLabel *unit = new QLabel("&Unit*:", this);
        QLabel *desc = new QLabel("Description:", this);
        QLineEdit *typeEdit = new QLineEdit(this);
        QLineEdit *snEdit = new QLineEdit(this);
        QLineEdit *nameEdit = new QLineEdit(this);
        QComboBox *categoryEdit = new QComboBox(this);
        QComboBox *unitEdit = new QComboBox(this);
        QTextEdit *descEdit = new QTextEdit(this);
        type->setBuddy(typeEdit);
        sn->setBuddy(snEdit);
        name->setBuddy(nameEdit);
        category->setBuddy(categoryEdit);
        unit->setBuddy(unitEdit);
        desc->setBuddy(descEdit);

        // add channels widget
        QLabel *channels = new QLabel("&Channels:\n(Doubleclick to edit/add/delete)", this);
        channels->setBuddy(channelView);
        channelView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); //descEdit is enige met QSizePolicy::ExpandFlag

        // add widgets
        addWidget(type, 0, 0, 1, 1);
        addWidget(typeEdit, 0, 1, 1, 1, "sens_type");
        addWidget(sn, 1, 0, 1, 1);
        addWidget(snEdit, 1, 1, 1, 1, "sens_serialnr");
        addWidget(name, 2, 0, 1, 1);
        addWidget(nameEdit, 2, 1, 1, 1, "sens_name");
        addWidget(category, 3, 0, 1, 1);
        addWidget(categoryEdit, 3, 1, 1, 1, QSqlRelation("tbl_sensor_categories", "sens_cate_id", "sens_cate_name"));
        addWidget(unit, 4, 0, 1, 1);
        addWidget(unitEdit, 4, 1, 1, 1, QSqlRelation("vew_sensor_units", "unit_id", "unit_symbol"));
        addWidget(channels, 0, 2, 1, 1);
        addWidget(channelView, 1, 2, 4, 1);
        addWidget(desc, 5, 0, 1, 3);
        addWidget(descEdit, 6, 0, 1, 3, "sens_desc", "plainText");

        // setup connections
        connect(typeEdit, SIGNAL(textChanged(QString)), this, SLOT(updateButtons()));
        connect(snEdit, SIGNAL(textChanged(QString)), this, SLOT(updateButtons()));
        connect(nameEdit, SIGNAL(textChanged(QString)), this, SLOT(updateButtons()));
        connect(categoryEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(updateButtons()));
        connect(unitEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(updateButtons()));
        connect(descEdit, SIGNAL(textChanged()), this, SLOT(updateButtons()));

        // update changes
        select();
    }


Member Function Documentation

virtual void SensorEditor::onCurrentRecordChange ( int  row  )  [inline, protected, virtual]

Reimplemented from MappedBaseEditor.

                                               {
        MappedBaseEditor::onCurrentRecordChange(row);
        updateSensorChannelView();
    }

virtual void SensorEditor::onQueryChange (  )  [inline, protected, virtual]

This function is primarily due to a bug in Qt where the mappers indexes become invalid after Model::select() is called, which also emits queryChanged(). cf. http://bugreports.qt.nokia.com/browse/QTBUG-1086 One consequence of this is that mapper->currentIndex() == -1 so it can not be used as currentIndex.

Todo:
Check whether MappedBaseEditor::onQueryChange() is still required. If not, delete.

Reimplemented from MappedBaseEditor.

                                {
        MappedBaseEditor::onQueryChange();
        updateSensorChannelView();
    }

virtual void SensorEditor::updateButtons (  )  [inline, protected, virtual]

Reimplemented from MappedBaseEditor.

Referenced by SensorEditor().

                                {
        MappedBaseEditor::updateButtons();
        channelView->setDisabled(isCurrentRecordNew() || model()->rowCount() == 0);
    }


The documentation for this class was generated from the following file: