Public Slots | Public Member Functions

ProjectTree Class Reference

Main widget for editing project trees and previewing associated sensor channel data. More...

#include <scdviewer.h>

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

List of all members.

Public Slots

void pipe_queryResult (QSqlQuery *result)

Public Member Functions

 ProjectTree (QWidget *parent=0)
 ~ProjectTree ()
void expandAll ()

Detailed Description

Main widget for editing project trees and previewing associated sensor channel data.

scdviewer_sample.png

This ProjectTree is the main component of the Smartlet application. It consists of three columns and an optional preview window. The first column is the main column and called the project tree. Here you associate different elements (sensors, locations, etc.) with a project name. The second column shows the interval for which there is data available in the database. The third column shows the project-dependant descriptions. Furthermore, ProjectTree is used by the data factory and the data upload wizard.

Common use

All available projects are visible by default. When hovering over an item you can see its project-independant description. Only the sensor and its sensor channels can have a project-dependant description. You can see these in the third column after checking the "Descriptions" checkbox. You can edit a description by double-clicking it and pressing somewhere else when done.

You can add an existing element to the project tree by left-clicking on the parent element in the project tree. Deleting also works this way. New elements can be added through some editor. Note that you can only delete an element if no other elements are associated with it. For example, you can not delete a sensor if it already has some data associated with it. You first need to delete the data.

You can also preview the data associated with a project tree element. For this you check the "Data Preview" checkbox below and select an item. (Note that multi-selection doesn't work when in preview mode.) Note also that the data you see is constrained by the interval selected in the TimeConstraintToolBar.

The project tree layout is saved on each application exit.

Rights & privileges

After creating a new user account the window will be empty. This implies that either the database is empty, or that the user has no READ privilege on any project. So you must ask an administrator or the owner of the project to grant you a READ privilege on the project.

To be able to edit a project tree, like adding sensors to it or editing its project-dependant descriptions, you need a WRITE privilege. For deleting project tree elements you need the DELETE privilege.

You can not make a new project here. For this you have to use the Project Editor.

An administrator has all privileges for all projects auto-granted. Owners of projects have all privileges auto-granted for all projects they own.

Todo:
Extra "Calibrations preview" or "Experiment preview" checkboxes in addition to the "Data preview" checkbox?

Constructor & Destructor Documentation

ProjectTree::ProjectTree ( QWidget parent = 0  ) 

                                                  : QWidget(parent)
{
    setObjectName("ProjectTree");
    setWindowTitle("Project tree viewer");

    // Model/View setup
    treeView = new ProjectTreeView(this);
    previewModel = new SqlQueryModel(this);
    previewModel->setDependency("tbl_sensor_channel_data");
    dataView = new DataPreView(this);
    dataView->setModel(previewModel);

    // Button setup
    enableDataPreview = new QCheckBox("Data preview", this);
    enableDescriptions = new QCheckBox("Descriptions", this);

    // Layout setup
    QHBoxLayout *checkBoxLayout = new QHBoxLayout;
    checkBoxLayout->addWidget(enableDescriptions);
    checkBoxLayout->addWidget(enableDataPreview);
    checkBoxLayout->addStretch();
    QVBoxLayout *left = new QVBoxLayout;
    left->addWidget(treeView);
    left->addLayout(checkBoxLayout);
    left->setContentsMargins(0, 0, 0, 0);

    // Splitter setup
    QWidget *leftW = new QWidget(this);
    leftW->setLayout(left);
    splitter = new QSplitter(this);
    splitter->addWidget(leftW);
    splitter->addWidget(dataView);
    splitter->setStretchFactor(0, 0);
    splitter->setStretchFactor(1, 1);

    // Main layout setup
    QHBoxLayout *main = new QHBoxLayout;
    main->addWidget(splitter);
    setLayout(main);

    // Connections
    connect(enableDataPreview, SIGNAL(toggled(bool)), this, SLOT(onEnablePreviewToggle(const bool &)));
    connect(enableDescriptions, SIGNAL(toggled(bool)), this, SLOT(onEnableDescriptionsToggle(const bool &)));
    connect(TimeConstraint::instance(), SIGNAL(signalOnTimeConstraintChange(TimeConstraint::ConstraintType,QDateTime)),
            this, SLOT(onGlobalTimeConstraintChange()));

    // Setup
    enableDataPreview->setChecked(false);
    onEnablePreviewToggle(enableDataPreview->checkState()); //voor een of andere rede is de connectie nog niet geinitializeerd (??) en wordt dit niet uitgevoerd...
    enableDescriptions->setChecked(false);
    onEnableDescriptionsToggle(enableDescriptions->checkState());
}

ProjectTree::~ProjectTree (  )  [inline]

{};


Member Function Documentation

void ProjectTree::expandAll (  ) 

Referenced by main().

{
    Q_ASSERT(treeView);
    treeView->expandAll();
}

void ProjectTree::pipe_queryResult ( QSqlQuery result  )  [slot]

{
    Q_ASSERT(previewModel);
    Q_ASSERT(dataView);
    dataView->setEnabled(result->isActive());
    if (result->isActive() && enableDataPreview->isChecked()) previewModel->setQuery(*result);
    else {
        previewModel->clear();
    }
}


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