Specific viewport implementation for DataHeader. More...
#include <builderview.h>


Public Slots | |
| void | slot_curve_setEnabled (bool enable) |
| void | addSection (TreeItem *item) |
| void | removeSection (int position) |
| void | slot_resizeSection_request (int index, int, int width) |
| QString | getSql () |
| DataHeaderViewPortLayout * | layout () const |
Signals | |
| void | signal_minimumSectionSize_reached (int minimumSize, int section=-1) |
| void | signal_userSetting_changed () |
| void | signal_curve_requested (DataHeaderSection *section, bool enable) |
| void | signal_dataHeaderSection_destroyed (QObject *section) |
Public Member Functions | |
| DataHeaderViewPort (BaseQueryModel *base, QWidget *parent=0) | |
| QStringList | getHeaderNames () |
| BaseQueryModel * | model () |
| int | logicalIndex (DataHeaderSection *section) const |
| DataHeaderSection * | section (int logicalIndex) |
| QVector< DataHeaderSection * > | sections (int tree_id) |
| int | sectionCount () const |
| void | resetSectionSizes () |
Specific viewport implementation for DataHeader.
| DataHeaderViewPort::DataHeaderViewPort | ( | BaseQueryModel * | base, | |
| QWidget * | parent = 0 | |||
| ) |
: QWidget(parent) { setLayout(new DataHeaderViewPortLayout(this)); m_base = base; }
| void DataHeaderViewPort::addSection | ( | TreeItem * | item | ) | [slot] |
{
int logicalIndex = layout()->count();
layout()->addWidget(new DataHeaderSection(item, this));
Q_ASSERT(layout()->getSection(logicalIndex) != 0);
DataHeaderSection *section = layout()->getSection(logicalIndex);
connect(section, SIGNAL(signal_minimumSectionSize_reached(int)),
this, SIGNAL(signal_minimumSectionSize_reached(int)));
connect(section, SIGNAL(signal_userSetting_changed()),
this, SIGNAL(signal_userSetting_changed()));
connect(section, SIGNAL(signal_curve_setEnabled(bool)),
this, SLOT(slot_curve_setEnabled(bool)));
connect(section, SIGNAL(destroyed(QObject*)),
this, SIGNAL(signal_dataHeaderSection_destroyed(QObject*)));
connect(this, SIGNAL(signal_dataHeaderSection_destroyed(QObject*)),
section, SLOT(slot_updateTitle()), Qt::QueuedConnection);
}
| QStringList DataHeaderViewPort::getHeaderNames | ( | ) |
{
QStringList sectionNames;
for (int i = 0; i < layout()->count(); ++i){
DataHeaderSection *section = layout()->getSection(i);
if (section != 0){
sectionNames << section->getName();
}
}
return sectionNames;
}
| QString DataHeaderViewPort::getSql | ( | ) | [slot] |
{ //is a slot, but should be an oridinary function
QStringList selectList;
QSet<int> treeIdSet;
QString beginTime = TimeConstraint::instance()->getTimeConstraint(TimeConstraint::TypeBeginTime).toString(Qt::ISODate);
QString endTime = TimeConstraint::instance()->getTimeConstraint(TimeConstraint::TypeEndTime).toString(Qt::ISODate);
int sectionCount = layout()->count();
if (sectionCount == 0) return QString();
selectList << "timestamp";
for (int i = 0; i < sectionCount; ++i){
DataHeaderSection *section = layout()->getSection(i);
if (section != 0){
Q_ASSERT(!section->getName().isEmpty());
Q_ASSERT(!section->getSqlForColumn().isEmpty());
Q_ASSERT(section->getTreeId() > 0);
selectList << QString(section->getSqlForColumn() + " AS \"" + section->getName() + "\"");
treeIdSet << section->getTreeId();
}
}
QStringList fromList;
foreach(int treeId, treeIdSet){
fromList << GlobalConst::DB_BASE_DATA_QUERY.arg(TREE_ID_COLUMN.arg(QString::number(treeId)), QString::number(treeId), beginTime, endTime);
}
//making base outer join query
QString query;
query.append("SELECT ").append(selectList.join(",")).append(" \n FROM \n");
int fromListCount = fromList.count();
for (int i = 0; i < fromListCount; i++){
query.append(fromList[i]);
if (fromListCount == 1) break;
if (i == 0)
query.append(" FULL OUTER JOIN \n");
else if (i == fromListCount - 1)
query.append(" USING (timestamp)");
else
query.append(" USING (timestamp) FULL OUTER JOIN \n");
}
return query.append("\n ORDER BY timestamp");
}
| DataHeaderViewPortLayout * DataHeaderViewPort::layout | ( | ) | const [slot] |
Referenced by addSection(), getHeaderNames(), getSql(), logicalIndex(), removeSection(), resetSectionSizes(), section(), sectionCount(), sections(), and slot_resizeSection_request().
{
return dynamic_cast<DataHeaderViewPortLayout*>(QWidget::layout());
}
| int DataHeaderViewPort::logicalIndex | ( | DataHeaderSection * | section | ) | const |
Referenced by addSection(), and DataHeaderSection::logicalIndex().
{
int logicalIndex = layout()->indexOf(section);
Q_ASSERT(logicalIndex != -1);
return logicalIndex;
}
| BaseQueryModel * DataHeaderViewPort::model | ( | ) |
{
Q_ASSERT(m_base);
return m_base;
}
| void DataHeaderViewPort::removeSection | ( | int | position | ) | [slot] |
{
QLayoutItem *section;
if ((section = layout()->takeAt(position)) != 0)
section->widget()->deleteLater();;
}
| void DataHeaderViewPort::resetSectionSizes | ( | ) |
{
for(int i = 0; i < layout()->count(); i++)
slot_resizeSection_request(i, 0, 0);
}
| DataHeaderSection * DataHeaderViewPort::section | ( | int | logicalIndex | ) |
Referenced by addSection(), DataHeader::data(), getHeaderNames(), getSql(), slot_curve_setEnabled(), and slot_resizeSection_request().
{
if (logicalIndex >= layout()->count() || logicalIndex < 0) return 0;
return layout()->getSection(logicalIndex);
}
| int DataHeaderViewPort::sectionCount | ( | ) | const |
Referenced by getSql(), and DataHeader::sectionCount().
{
return layout()->count();
}
| QVector< DataHeaderSection * > DataHeaderViewPort::sections | ( | int | tree_id | ) |
Referenced by DataHeaderSection::getTitle().
{
QVector<DataHeaderSection*> sections;
if (layout()->count() == 0) return sections;
for(int i = 0; i < layout()->count(); i++){
int tree_id_temp = layout()->getSection(i)->getTreeId();
if (tree_id == tree_id_temp) sections << layout()->getSection(i);
}
return sections;
}
| void DataHeaderViewPort::signal_curve_requested | ( | DataHeaderSection * | section, | |
| bool | enable | |||
| ) | [signal] |
Referenced by slot_curve_setEnabled().
| void DataHeaderViewPort::signal_dataHeaderSection_destroyed | ( | QObject * | section | ) | [signal] |
Referenced by addSection().
| void DataHeaderViewPort::signal_minimumSectionSize_reached | ( | int | minimumSize, | |
| int | section = -1 | |||
| ) | [signal] |
Referenced by addSection().
| void DataHeaderViewPort::signal_userSetting_changed | ( | ) | [signal] |
Referenced by addSection().
| void DataHeaderViewPort::slot_curve_setEnabled | ( | bool | enable | ) | [slot] |
Referenced by addSection().
{
DataHeaderSection *section = dynamic_cast<DataHeaderSection*>(sender());
Q_ASSERT(section);
emit signal_curve_requested(section, enable);
}
| void DataHeaderViewPort::slot_resizeSection_request | ( | int | index, | |
| int | , | |||
| int | width | |||
| ) | [slot] |
Referenced by resetSectionSizes().
{
if (layout()->itemAt(index) != 0){
if (layout()->itemAt(index)->widget() != 0) {
DataHeaderSection *section = dynamic_cast<DataHeaderSection*>(layout()->itemAt(index)->widget());
if (section) section->slot_underLyingColumnWidth_changed(width); //kan zijn dat de sectie reeds deleted is.
}
}
}
1.7.1