HeaderSection used by ImportFileView to allow basic manipulations on data to be imported. More...
#include <importfilemodel.h>


Signals | |
| void | signal_userInteraction (int logicalIndex, TagContainer::ColumnTag tag, QVariant change) |
Public Member Functions | |
| ImportFileHeaderSection (int column, QWidget *parent=0) | |
| void | adjustContent (const TagContainer::ColumnTag &role, const QVariant &data) |
HeaderSection used by ImportFileView to allow basic manipulations on data to be imported.
| ImportFileHeaderSection::ImportFileHeaderSection | ( | int | column, | |
| QWidget * | parent = 0 | |||
| ) |
: QFrame(parent) { setFrameStyle(QFrame::Panel | QFrame::Raised); defaultSectionName = QString("No sensor channel assigned"); this->logicalIndex = column; sectionName = new QLabel(defaultSectionName, this); dataTypeLayout = new QVBoxLayout; dataTypeComboBox = new QComboBox(this); dataTypeComboBox->insertItem(0, "None", QVariant::fromValue((int) TagContainer::ColumnTypeNone)); dataTypeComboBox->insertItem(1, "Timestamp", QVariant::fromValue((int) TagContainer::ColumnTypeTimestamp)); dataTypeComboBox->insertItem(2, "Data", QVariant::fromValue((int) TagContainer::ColumnTypeData)); dataTypeComboBox->setCurrentIndex(0); timestampFormatEditor = new QLineEdit(this); timestampFormatEditor->setToolTip("Two possible formats can be used here:\n" "1) Write the format of the timestamp string.\n" "\tFor more help about the syntax, see here: " "http://doc.qt.nokia.com/" QT_VERSION_STR "/qdatetime.html#toString\n" "2) Write a simple arithmetic expression where 'X' refers to the timestamp.\n" "\tSupported operators are '+', '-', '*' and '/'. Brackets '(' and ')' are also supported. " "Function 'int()' is also supported. \n\tNote that currently no bracket can be used inside a function." "The result should be the positive number of miliseconds that have passed since 1970-01-01T00:00:00 UTC."); timestampFormatEditor->hide(); unitComboBox = new UnitComboBox(new ConvertableUnitModel(this), this); unitComboBox->setCurrentIndex(-1); unitComboBox->hide(); unitConversionLabel = new QLabel("[??]", this); unitConversionLabel->hide(); unitConversionLabel->setAlignment(Qt::AlignCenter); dataTypeLayout->addWidget(dataTypeComboBox); dataTypeLayout->addWidget(timestampFormatEditor); dataTypeLayout->addWidget(unitComboBox); dataTypeLayout->addWidget(unitConversionLabel); mainLayout = new QVBoxLayout; mainLayout->addWidget(sectionName); mainLayout->addLayout(dataTypeLayout); mainLayout->setAlignment(Qt::AlignTop); setLayout(mainLayout); setupConnections(); }
| void ImportFileHeaderSection::adjustContent | ( | const TagContainer::ColumnTag & | role, | |
| const QVariant & | data | |||
| ) |
{
switch (role) {
case TagContainer::ColumnTagName:{
if (data.type() == QVariant::String && data.isValid()) {
sectionName->setText(data.toString());
} else {
sectionName->setText(defaultSectionName);
}
} break;
case TagContainer::ColumnTagTimestampFormat:{
if (!data.isValid()) {
timestampFormatEditor->clear();
break;
}
if (timestampFormatEditor->text() != data.toString())
timestampFormatEditor->setText(data.toString());
} break;
case TagContainer::ColumnTagTreeId:{
if (!data.isValid()) {
dataTypeComboBox->setCurrentIndex(0);
break;
}
// UnitComboBox
// The ColumnTagDataUnitId might be allready set for this tree_id so
// the function will try to retain the selection, set default,
// or revert to -1 which means there was an error
unitComboBox->setTreeIdConstraint(data.toInt());
// Layout
unitComboBox->show();
setupUnitConversionLabel();
} break;
case TagContainer::ColumnTagType:{
TagContainer::ColumnType type = static_cast<TagContainer::ColumnType>(data.toInt());
if (type == TagContainer::ColumnTypeNone) dataTypeComboBox->setCurrentIndex(0);
if (type == TagContainer::ColumnTypeTimestamp) dataTypeComboBox->setCurrentIndex(1);
if (type == TagContainer::ColumnTypeData) dataTypeComboBox->setCurrentIndex(2);
} break;
case TagContainer::ColumnTagDataUnitId:{
if (!data.isValid()){
unitComboBox->setCurrentIndex(-1);
break;
}
bool ok;
unitComboBox->setCurrentUnitFromId(data.toInt(&ok));
Q_ASSERT(ok);
// Probleem hier kan bij het loaden voorkomen: als reeds een tree_id is set,
// en een unit_id wordt toegewezen dat niet mogelijk is. Deze unit moet
// "geset" kunnen worden, anders kan em niet gelezen worden later. Vandaar de ASSERT:
if (unitComboBox->currentIndex() == -1){
qWarning() << "unitComboBox wasn't able to set unit_id to: " << data << unitComboBox->model()->query().lastQuery();
// This is a workaround just to make it work... and it works quite well...
unitComboBox->reset();
unitComboBox->setCurrentUnitFromId(data.toInt());
Q_ASSERT(unitComboBox->currentIndex() != -1);
}
} break;
case TagContainer::ColumnTagToolTip:{
if (!data.isValid()){
setToolTip(QString());
break;
}
setToolTip(data.toString());
} break;
}
}
| void ImportFileHeaderSection::signal_userInteraction | ( | int | logicalIndex, | |
| TagContainer::ColumnTag | tag, | |||
| QVariant | change | |||
| ) | [signal] |
1.7.1