Public Slots | Signals | Public Member Functions

DataHeaderViewPort Class Reference

Specific viewport implementation for DataHeader. More...

#include <builderview.h>

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

List of all members.

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 ()
DataHeaderViewPortLayoutlayout () 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 ()
BaseQueryModelmodel ()
int logicalIndex (DataHeaderSection *section) const
DataHeaderSectionsection (int logicalIndex)
QVector< DataHeaderSection * > sections (int tree_id)
int sectionCount () const
void resetSectionSizes ()

Detailed Description

Specific viewport implementation for DataHeader.


Constructor & Destructor Documentation

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

                                                                                      : QWidget(parent)
{
    setLayout(new DataHeaderViewPortLayout(this));
    m_base = base;
}


Member Function Documentation

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]
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  ) 
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.
        }
    }
}


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