Signals | Public Member Functions

Builder Class Reference

Main window for builing datasets. More...

#include <builder.h>

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

List of all members.

Signals

void queryExecPending (const bool &)

Public Member Functions

 Builder (BaseQueryModel *base, QWidget *parent=0)
QGridLayoutlayout ()
BuilderViewbuilderView () const
bool isCurrentlyUpToDate ()

Detailed Description

Main window for builing datasets.

builder_sample.png

This is the main window for building a custom table based on sensor channel data. It consists of two main columns: The left one shows timestamps, the right one data. The right one can consist of one or more data columns.

The base work-flow consists of dragging the items from the project tree to the right column, selecting data-specific options (if necessary) and pressing the "update" button. The program will accordingly fetch your request from the database.

Options

Data-specific options

Options can be set through the column headers. Currently there are two types of headers. TimestampHeaderSection and DataHeaderSection.

TimestampHeaderSection allows you to adjust the timestamp type: original or custom timestamps. In case of the latter you have to specify an interval.

DataHeaderSection allows you to convert the raw data to a specific unit and/or calibrate. By selecting the "graph" button you pass the data to the Grapher. By selecting the "delete" button you remove the column.

For more detailed information, check out the corresponding sections.

Advanced options

Advanced checkbox can be used for certain cases when you need to limit, group or order the data shown in a specific way not possible by the GUI. For this you can write a SQL statement consisting of an WHERE, GROUP BY, HAVING or ORDER BY clause referring to the columns used. For some statements a one-click-convenience-function could be made on request.

Analyze checkbox is used for analyzing the database performance for the requested data. So when your data request takes a considerable amount of time, this function can be used to check whether the bottleneck is at the database level. In short, it shows how much time it took the database to generate the issued dataset.

Query button on the left will copy the SQL string used to fetch the data to your clipboard, so you can use it as a basis for building more complex data request through other means, like pgAdmin, the webbased tool phpPgAdmin, or some other third party utility.

Note:
You can use the double-arrows from TimeConstraintToolBar to scroll backward or forward through the data.
For large datasets, slow connections and lots of calibration computation the execution might take a considerable amount of time. So make sure to request datasets in in small timeframes.
Todo:
Optimize calibration computation.

Constructor & Destructor Documentation

Builder::Builder ( BaseQueryModel base,
QWidget parent = 0 
)

                                                                :
        QWidget(parent), autoUpdateQuery(true), dirtyFlag(false), viewUpdatePending(false)
{
    setObjectName("Builder");
    this->base = base;

    view = new BuilderView(base, this);
    view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    // Setup data & timestamp models
    TimestampProxy *tProxy = new TimestampProxy(this);
    tProxy->setSourceModel(base);
    view->timestampView()->setModel(tProxy);

    DataProxy *dProxy = new DataProxy(this);
    dProxy->setSourceModel(base);
    view->dataView()->setModel(dProxy);

    advQEditCheckBox = new QCheckBox("Advanced", this);
    advWhereCondition = new AdvancedQueryEdit(this);
    advWhereCondition->setVisible(advQEditCheckBox->isChecked());
    advWhereCondition->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

    analyseCheckBox = new QCheckBox("Analyse", this);
    analyseCheckBox->setToolTip("<p>Check this, and then update, if you want to see "
                                "how fast the database generates your data, "
                                "neglecting the time it takes to transfer it to you. "
                                "It can be used to resolve performance issues. "
                                "If the execution time is far beyond your expectations, "
                                "export it and make a bug report.</p>");

    QHBoxLayout *checkBoxLayout = new QHBoxLayout;
    checkBoxLayout->addWidget(advQEditCheckBox);
    checkBoxLayout->addWidget(analyseCheckBox);
    checkBoxLayout->addStretch();
    QVBoxLayout *advQLayout = new QVBoxLayout;
    advQLayout->addLayout(checkBoxLayout);
    advQLayout->addWidget(advWhereCondition);

    updateButton = new QPushButton("Update", this);
    updateButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(updateButton, SIGNAL(clicked()),
            this, SLOT(onUpdateButtonPress()));

    // Setup toolbar
    QToolBar *toolBar = new QToolBar(this);
    QAction *query = toolBar->addAction("query", this, SLOT(pasteQueryToClipboard()));
    query->setToolTip("Copy query to clipboard.");
    toolBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);

#ifdef DEBUG_WITHOUTDB
    connect(updateButton, SIGNAL(clicked()),
            base, SIGNAL(modelReset()));
#endif //DEBUG_WITHOUTDB

    setLayout(new QGridLayout(this));
    layout()->addWidget(toolBar, 0, 0, 1, 1, Qt::AlignTop);
    layout()->addWidget(view, 0, 1, 1, 2);
    layout()->addLayout(advQLayout, 1, 0, 1, 2);
    layout()->addWidget(updateButton, 1, 2, 1, 1, Qt::AlignBottom);

    //AdvancedQueryEdit syncs
    connect(advQEditCheckBox, SIGNAL(toggled(bool)),
            advWhereCondition, SLOT(setVisible(bool)));

    //Scrollbar syncs:
    connect(view->dataView()->verticalScrollBar(), SIGNAL(valueChanged(int)),
            view->timestampView()->verticalScrollBar(), SLOT(setValue(int)));
    connect(view->timestampView()->verticalScrollBar(), SIGNAL(valueChanged(int)),
            view->dataView()->verticalScrollBar(), SLOT(setValue(int)));
    connect(view->dataView()->horizontalScrollBar(), SIGNAL(valueChanged(int)),
            view->dataHeader()->horizontalScrollBar(), SLOT(setValue(int)));
    connect(view->dataHeader()->horizontalScrollBar(), SIGNAL(valueChanged(int)),
            view->dataView()->horizontalScrollBar(), SLOT(setValue(int)));
    //HorizontalHeader syncs:
    connect(view->dataView()->horizontalHeader(), SIGNAL(sectionResized(int, int, int)),
            view->dataHeader()->viewPort(), SLOT(slot_resizeSection_request(int,int,int)));
    connect(view->dataHeader()->viewPort(), SIGNAL(signal_minimumSectionSize_reached(int, int)),
            this, SLOT(slot_setMinimumSectionSize_dView(int,int)));
    //TreeDrop Sync:
    connect(base, SIGNAL(signal_treeItemDropped(TreeItem*)),
            view->dataHeader()->viewPort(), SLOT(addSection(TreeItem*)));
    //BaseModel reset Sync:
    connect(view->timestampHeader(), SIGNAL(signal_userSetting_changed()),
            this, SLOT(onHeaderColumnChange()));
    connect(view->dataHeader()->viewPort(), SIGNAL(signal_userSetting_changed()),
            this, SLOT(onHeaderColumnChange()));
    connect(base, SIGNAL(signal_treeItemDropped(TreeItem*)),
            this, SLOT(onHeaderColumnChange()));
    connect(view->dataHeader()->viewPort(), SIGNAL(signal_dataHeaderSection_destroyed(QObject*)),
            this, SLOT(onHeaderColumnChange()));
    connect(advWhereCondition, SIGNAL(textChanged()),
            this, SLOT(onAdvEditChange()));
    connect(advQEditCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(onAdvEditChange()));
    connect(analyseCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(onAnalyseCheck()));
    connect(TimeConstraint::instance(), SIGNAL(signalOnTimeConstraintChange(TimeConstraint::ConstraintType,QDateTime)),
            this, SLOT(onTimeConstraintChange()));
}


Member Function Documentation

BuilderView * Builder::builderView (  )  const

Referenced by Factory::Factory().

{
    Q_ASSERT(view);
    return view;
}

bool Builder::isCurrentlyUpToDate (  ) 

{
    return !dirtyFlag && !viewUpdatePending;
}

QGridLayout * Builder::layout (  ) 

Reimplemented from QWidget.

Referenced by Builder().

{
    return dynamic_cast<QGridLayout*>(QWidget::layout());
}

void Builder::queryExecPending ( const bool &   )  [signal]

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