QseDataSetModel Class Reference

#include <qsedatasetmodel.h>

Inheritance diagram for QseDataSetModel:

Inheritance graph
[legend]
Collaboration diagram for QseDataSetModel:

Collaboration graph
[legend]

List of all members.

Public Slots

void dataChanged ()
void dataCleared ()
void scanAdded (int n)

Public Member Functions

 QseDataSetModel (QseDataSet *dataSet, QObject *parent=0)
int rowCount (const QModelIndex &parent=QModelIndex()) const
int columnCount (const QModelIndex &parent=QModelIndex()) const
QVariant data (const QModelIndex &index, int role) const
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const

Private Types

typedef QAbstractTableModel inherited

Private Attributes

QseDataSetm_DataSet
int m_NScans


Detailed Description

Definition at line 9 of file qsedatasetmodel.h.


Member Typedef Documentation

Definition at line 11 of file qsedatasetmodel.h.


Constructor & Destructor Documentation

QseDataSetModel::QseDataSetModel ( QseDataSet dataSet,
QObject parent = 0 
)

Definition at line 5 of file qsedatasetmodel.cpp.

00006   : QAbstractTableModel(parent),
00007     m_DataSet(dataSet)
00008 {
00009 //   printf("Dataset Model Constructed %p, Model Thread %p\n", dataSet->thread(), this->thread());
00010 
00011   connect(dataSet, SIGNAL(dataChanged()),
00012     this,    SLOT(dataChanged()));
00013 
00014   connect(dataSet, SIGNAL(dataCleared()),
00015     this,    SLOT(dataCleared()));
00016 
00017 //   connect(dataSet, SIGNAL(scanAdded(int)),
00018 //    this,    SLOT(scanAdded(int)));
00019 }


Member Function Documentation

int QseDataSetModel::rowCount ( const QModelIndex &  parent = QModelIndex()  )  const

Definition at line 22 of file qsedatasetmodel.cpp.

References m_DataSet.

00023 {
00024   if (parent.column() > 0) {
00025     return 0;
00026   }
00027 
00028   int res = m_DataSet -> scanCount();
00029 
00030 //    printf("QseDataSetModel::rowCount = %d\n", res);
00031 
00032   return res;
00033 }

int QseDataSetModel::columnCount ( const QModelIndex &  parent = QModelIndex()  )  const

Definition at line 46 of file qsedatasetmodel.cpp.

References m_DataSet, and QseDataSet::maxColumnCount().

Referenced by data().

00047 {
00048   return 3 + m_DataSet->maxColumnCount();
00049 }

Here is the call graph for this function:

QVariant QseDataSetModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 52 of file qsedatasetmodel.cpp.

References QseScan::column(), columnCount(), m_DataSet, and QseDataSet::scan().

00053 {
00054   if (!index.isValid()) {
00055     return QVariant();
00056   }
00057 
00058   if (role != Qt::DisplayRole) {
00059     return QVariant();
00060   }
00061 
00062   int row = index.row();
00063   int col = index.column();
00064 
00065   QseScan *scan = m_DataSet->scan(row);
00066 
00067   switch (col) {
00068   case 0:
00069     return scan -> name();
00070     break;
00071   case 1:
00072     return scan -> maxRowCount();
00073     break;
00074   case 2:
00075     return scan -> columnCount();
00076     break;
00077   default:
00078     QseColumn *c = scan->column(col-3);
00079 
00080     if (c) {
00081       return c -> name();
00082     } else {
00083       return QVariant();
00084     }
00085   }
00086 }

Here is the call graph for this function:

QVariant QseDataSetModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Definition at line 90 of file qsedatasetmodel.cpp.

00091 {
00092   if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
00093     switch (section) {
00094     case 0:
00095       return "Scan Name";
00096       break;
00097     case 1:
00098       return "Rows";
00099       break;
00100     case 2:
00101       return "Columns";
00102       break;
00103     default:
00104       return tr("Col %1").arg(section-3);
00105     }
00106   }
00107 
00108   if (orientation == Qt::Vertical && role == Qt::DisplayRole) {
00109     return section;
00110   }
00111 
00112   return QVariant();
00113 }

void QseDataSetModel::dataChanged (  )  [slot]

Definition at line 133 of file qsedatasetmodel.cpp.

00134 {
00135    printf("QseDataSetModel::dataChanged\n");
00136   reset();
00137 }

void QseDataSetModel::dataCleared (  )  [slot]

Definition at line 140 of file qsedatasetmodel.cpp.

00141 {
00142 //   printf("QseDataSetModel::dataCleared\n");
00143 
00144   reset();
00145 }

void QseDataSetModel::scanAdded ( int  n  )  [slot]

Definition at line 148 of file qsedatasetmodel.cpp.

00149 {
00150 //   printf("%s: QseDataSetModel::scanAdded(%d)\n", qPrintable(m_DataSet->objectName()), n);
00151 
00152 //   insertRows(n, 1, QModelIndex());
00153 
00154 //   printf("Row Count = %d\n", rowCount());
00155 }


Member Data Documentation

Definition at line 47 of file qsedatasetmodel.h.

Referenced by columnCount(), data(), and rowCount().

Definition at line 48 of file qsedatasetmodel.h.


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

Generated on Fri May 2 16:26:42 2008 for QSE by  doxygen 1.5.5