#include <qxtscheduleviewheadermodel_p.h>
Public Slots | |
void | newZoomDepth (const int zoomDepth) |
void | viewModeChanged (const int viewMode) |
Public Member Functions | |
QxtScheduleViewHeaderModel (QObject *parent=0) | |
void | setDataSource (QxtScheduleView *dataSource) |
virtual QModelIndex | parent (const QModelIndex &index) const |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const |
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
virtual bool | insertRow (int row, const QModelIndex &parent=QModelIndex()) |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const |
virtual bool | hasChildren (const QModelIndex &parent=QModelIndex()) const |
Definition at line 52 of file qxtscheduleviewheadermodel_p.h.
QxtScheduleViewHeaderModel::QxtScheduleViewHeaderModel | ( | QObject * | parent = 0 ) |
Definition at line 32 of file qxtscheduleviewheadermodel_p.cpp.
: QAbstractTableModel(parent) , m_rowCountBuffer(0) , m_colCountBuffer(0) { }
int QxtScheduleViewHeaderModel::columnCount | ( | const QModelIndex & | parent = QModelIndex() ) |
const [virtual] |
Definition at line 134 of file qxtscheduleviewheadermodel_p.cpp.
{ if (!parent.isValid()) { if (this->m_dataSource) return m_dataSource->cols(); } return 0; }
QVariant QxtScheduleViewHeaderModel::data | ( | const QModelIndex & | index, |
int | role = Qt::DisplayRole |
||
) | const [virtual] |
Definition at line 144 of file qxtscheduleviewheadermodel_p.cpp.
{
Q_UNUSED(index);
Q_UNUSED(role);
return QVariant();
}
Qt::ItemFlags QxtScheduleViewHeaderModel::flags | ( | const QModelIndex & | index ) | const [virtual] |
Definition at line 199 of file qxtscheduleviewheadermodel_p.cpp.
{
Q_UNUSED(index);
return Qt::ItemIsEnabled;
}
bool QxtScheduleViewHeaderModel::hasChildren | ( | const QModelIndex & | parent = QModelIndex() ) |
const [virtual] |
Definition at line 205 of file qxtscheduleviewheadermodel_p.cpp.
{ Q_UNUSED(parent); return false; }
QVariant QxtScheduleViewHeaderModel::headerData | ( | int | section, |
Qt::Orientation | orientation, | ||
int | role = Qt::DisplayRole |
||
) | const [virtual] |
Definition at line 166 of file qxtscheduleviewheadermodel_p.cpp.
{ if (!m_dataSource) return QVariant(); #if 0 if (role == Qt::SizeHintRole) { if (this->viewModel) { return viewModel->headerData(section, orientation, role); } } #endif if (role == Qt::DisplayRole || role == Qt::EditRole) { if (Qt::Horizontal == orientation) { int iTableOffset = m_dataSource->qxt_d().visualIndexToOffset(0, section); QDateTime startTime = QDateTime::fromTime_t(m_dataSource->qxt_d().offsetToUnixTime(iTableOffset)); return QVariant(startTime.date().toString()); } else { int iTableOffset = m_dataSource->qxt_d().visualIndexToOffset(section, 0); QTime time = QDateTime::fromTime_t(m_dataSource->qxt_d().offsetToUnixTime(iTableOffset)).time(); return QVariant(time.toString()); } } return QVariant(); }
bool QxtScheduleViewHeaderModel::insertRow | ( | int | row, |
const QModelIndex & | parent = QModelIndex() |
||
) | [virtual] |
Definition at line 159 of file qxtscheduleviewheadermodel_p.cpp.
{ Q_UNUSED(row); Q_UNUSED(parent); return false; }
void QxtScheduleViewHeaderModel::newZoomDepth | ( | const int | zoomDepth ) | [slot] |
Definition at line 39 of file qxtscheduleviewheadermodel_p.cpp.
Referenced by setDataSource().
{ Q_UNUSED(zoomDepth); if (this->m_dataSource) { /* qDebug()<<"old rows "<<m_rowCountBuffer<<" new rows "<<m_dataSource->rows(); beginRemoveRows(QModelIndex(),0,m_rowCountBuffer); m_rowCountBuffer = 0; endRemoveRows(); beginInsertRows(QModelIndex(),0,m_dataSource->rows()); m_rowCountBuffer = m_dataSource->rows(); endInsertRows(); */ m_rowCountBuffer = m_dataSource->rows(); reset(); } }
QModelIndex QxtScheduleViewHeaderModel::parent | ( | const QModelIndex & | index ) | const [virtual] |
Definition at line 118 of file qxtscheduleviewheadermodel_p.cpp.
Referenced by QxtScheduleInternalItem::parentView(), and QxtScheduleInternalItem::setGeometry().
{
Q_UNUSED(index);
return QModelIndex();
}
int QxtScheduleViewHeaderModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() ) |
const [virtual] |
Definition at line 124 of file qxtscheduleviewheadermodel_p.cpp.
{ if (!parent.isValid()) { if (this->m_dataSource) return m_dataSource->rows(); } return 0; }
bool QxtScheduleViewHeaderModel::setData | ( | const QModelIndex & | index, |
const QVariant & | value, | ||
int | role = Qt::EditRole |
||
) | [virtual] |
Definition at line 151 of file qxtscheduleviewheadermodel_p.cpp.
{ Q_UNUSED(index); Q_UNUSED(value); Q_UNUSED(role); return false; }
void QxtScheduleViewHeaderModel::setDataSource | ( | QxtScheduleView * | dataSource ) |
Definition at line 85 of file qxtscheduleviewheadermodel_p.cpp.
References QxtScheduleView::cols(), newZoomDepth(), QxtScheduleView::rows(), and viewModeChanged().
Referenced by QxtScheduleHeaderWidget::QxtScheduleHeaderWidget().
{ if (this->m_dataSource) { disconnect(m_dataSource, SIGNAL(newZoomDepth(const int)), this, SLOT(newZoomDepth(const int))); disconnect(m_dataSource, SIGNAL(viewModeChanged(const int)), this, SLOT(viewModeChanged(const int))); emit beginRemoveRows(QModelIndex(), 0, m_rowCountBuffer); m_rowCountBuffer = 0; emit endRemoveRows(); emit beginRemoveColumns(QModelIndex(), 0, m_colCountBuffer); m_colCountBuffer = 0; emit endRemoveColumns(); } if (dataSource) { connect(dataSource, SIGNAL(newZoomDepth(const int)), this, SLOT(newZoomDepth(const int))); connect(dataSource, SIGNAL(viewModeChanged(const int)), this, SLOT(viewModeChanged(const int))); emit beginInsertRows(QModelIndex(), 0, dataSource->rows()); m_rowCountBuffer = dataSource->rows(); emit endInsertRows(); emit beginInsertColumns(QModelIndex(), 0, dataSource->cols()); m_colCountBuffer = dataSource->cols(); emit endInsertColumns(); } m_dataSource = dataSource; }
void QxtScheduleViewHeaderModel::viewModeChanged | ( | const int | viewMode ) | [slot] |
Definition at line 61 of file qxtscheduleviewheadermodel_p.cpp.
Referenced by setDataSource().
{
Q_UNUSED(viewMode);
if (this->m_dataSource)
{
beginRemoveRows(QModelIndex(), 0, m_rowCountBuffer);
m_rowCountBuffer = 0;
endRemoveRows();
beginInsertRows(QModelIndex(), 0, m_dataSource->rows());
m_rowCountBuffer = m_dataSource->rows();
endInsertRows();
beginRemoveColumns(QModelIndex(), 0, m_colCountBuffer);
m_colCountBuffer = 0;
endRemoveColumns();
beginInsertColumns(QModelIndex(), 0, m_dataSource->cols());
m_colCountBuffer = m_dataSource->cols();
endInsertColumns();
}
}