SummaryTableController Class Reference

#include <summarytablecontroller.h>

Inheritance diagram for SummaryTableController:

Inheritance graph
[legend]
Collaboration diagram for SummaryTableController:

Collaboration graph
[legend]

List of all members.

Public Slots

void summaryTableContextMenu (const QPoint &pos)
void updateSummaryTableSizes (void)

Signals

void scanRangeRoleChanged (int scan0, int scan1)
void columnRangeRolesChanged (int scan0, int scan1, int col0, int col1)

Public Member Functions

 SummaryTableController (QseDataSet *ds, QseAveragerRole *r, QTableWidget *tw, QObject *parent=0)
 ~SummaryTableController ()
void updateSummaryTable (void)
void updateSummaryTableScanInfo (int scan0, int scan1)
void updateSummaryTableColumnInfo (int scan0, int scan1, int col0, int col1)
void updateSummaryTableScans (int scan0, int scan1)
void exportSelectedData (QList< QTableWidgetSelectionRange > selections)

Private Member Functions

void updateSummaryTableHeaders (void)
void updateSummaryTableColumnInfo (int scan0, int scan1)

Private Attributes

QseDataSetm_DataSet
QseAveragerRolem_Role
QTableWidget * m_Table
QTimer m_updateTimer

Static Private Attributes

static const int EXTRACOLUMNCOUNT = 4


Detailed Description

Definition at line 14 of file summarytablecontroller.h.


Constructor & Destructor Documentation

SummaryTableController::SummaryTableController ( QseDataSet ds,
QseAveragerRole r,
QTableWidget *  tw,
QObject parent = 0 
)

Definition at line 13 of file summarytablecontroller.cpp.

00015   : QObject(parent),
00016     m_DataSet(ds),
00017     m_Role(r),
00018     m_Table(tw)
00019 {
00020   // connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateSummaryTableSizes()));
00021 
00022   m_Table->setContextMenuPolicy(Qt::CustomContextMenu);
00023 
00024   connect(m_Table, SIGNAL(customContextMenuRequested(const QPoint &)),
00025     this, SLOT(summaryTableContextMenu(const QPoint &)));
00026 }

SummaryTableController::~SummaryTableController (  ) 

Definition at line 28 of file summarytablecontroller.cpp.

00029 {
00030 }


Member Function Documentation

void SummaryTableController::updateSummaryTable ( void   ) 

Definition at line 33 of file summarytablecontroller.cpp.

References m_DataSet, updateSummaryTableColumnInfo(), updateSummaryTableHeaders(), and updateSummaryTableScanInfo().

00034 {
00035   return;
00036 
00037   int nscans = m_DataSet -> scanCount();
00038 
00039   updateSummaryTableHeaders();
00040   updateSummaryTableScanInfo(0, nscans);
00041   updateSummaryTableColumnInfo(0, nscans);
00042 }

Here is the call graph for this function:

void SummaryTableController::updateSummaryTableScanInfo ( int  scan0,
int  scan1 
)

Definition at line 63 of file summarytablecontroller.cpp.

References QseScan::columnCount(), m_DataSet, m_Role, m_Table, QseScan::maxRowCount(), QseDataSet::scan(), and QseAveragerRole::styledScanItem().

Referenced by updateSummaryTable(), and updateSummaryTableColumnInfo().

00064 {
00065   for (int i = scan0; i <= scan1; i++) {
00066     QseScan *s = m_DataSet->scan(i);
00067     if (s) {
00068       m_Table -> setItem(i, 0, m_Role->styledScanItem(s));
00069       m_Table -> setItem(i, 1, new ColoredTableItem(Qt::black, false, 
00070                 QString("%1").arg(s->columnCount())));
00071       m_Table -> setItem(i, 2, new ColoredTableItem(Qt::black, false, 
00072                 QString("%1").arg(s->maxRowCount())));
00073       m_Table -> setItem(i, 3, new ColoredTableItem(Qt::black, false, ""));
00074     }
00075   }
00076 }

Here is the call graph for this function:

void SummaryTableController::updateSummaryTableColumnInfo ( int  scan0,
int  scan1,
int  col0,
int  col1 
)

Definition at line 84 of file summarytablecontroller.cpp.

References QseScan::column(), EXTRACOLUMNCOUNT, m_DataSet, m_Role, m_Table, QseDataSet::scan(), and QseAveragerRole::styledColumnItem().

Referenced by updateSummaryTable(), and updateSummaryTableColumnInfo().

00085 {
00086   m_Table -> setUpdatesEnabled(false);
00087 
00088   for (int i = scan0; i<=scan1; i++) {
00089     QseScan *s = m_DataSet->scan(i);
00090     if (s) {
00091       for (int c = col0; c <= col1; c++) {
00092   QseColumn *col = s->column(c);
00093 
00094   if (col) {
00095     m_Table -> setItem(i, c + EXTRACOLUMNCOUNT, m_Role->styledColumnItem(col));
00096   }
00097       }
00098     }
00099   }
00100 
00101   m_Table -> resizeColumnsToContents();
00102   m_Table -> resizeRowsToContents();
00103 
00104   m_Table -> setUpdatesEnabled(true);
00105   m_Table -> repaint();
00106 }

Here is the call graph for this function:

void SummaryTableController::updateSummaryTableScans ( int  scan0,
int  scan1 
)

Definition at line 119 of file summarytablecontroller.cpp.

References QseScan::column(), QseScan::columnCount(), EXTRACOLUMNCOUNT, m_DataSet, m_Role, m_Table, QseScan::maxRowCount(), QseDataSet::scan(), and QseDataSet::scanCount().

00120 {
00121   int tnr = m_Table ->rowCount();
00122   int nscans = m_DataSet->scanCount();
00123 
00124   if (scan0<0) {
00125     m_Table -> setColumnCount(EXTRACOLUMNCOUNT);
00126     m_Table -> setRowCount(0);
00127     m_Table -> setHorizontalHeaderItem(0, new ColoredTableItem(Qt::black, false, "Command"));
00128     m_Table -> setHorizontalHeaderItem(1, new ColoredTableItem(Qt::black, false, "#Cols"));
00129     m_Table -> setHorizontalHeaderItem(2, new ColoredTableItem(Qt::black, false, "#Points"));
00130     m_Table -> setHorizontalHeaderItem(3, new ColoredTableItem(Qt::black, false, "Status"));
00131   } else if (scan1 > tnr) {
00132     m_Table -> setRowCount(scan1);
00133     int tnc = m_Table -> columnCount() - EXTRACOLUMNCOUNT;
00134 
00135     for (int i = scan0; i<=scan1; i++) {
00136       QseScan *s = m_DataSet->scan(i);
00137       if (s) {
00138   int snc = s->columnCount();
00139 
00140   if (snc > tnc) {
00141     m_Table -> setColumnCount(snc + EXTRACOLUMNCOUNT);
00142 
00143     for (int c = tnc; c < snc; c++) {
00144       m_Table -> setHorizontalHeaderItem(c+EXTRACOLUMNCOUNT, 
00145            new ColoredTableItem(Qt::black, false, 
00146                     QString("col%1").arg(c + 1)));
00147     }
00148 
00149     tnc = snc;
00150   }
00151 
00152   m_Table -> setItem(i, 0, m_Role -> styledScanItem(s));
00153   m_Table -> setItem(i, 1, new ColoredTableItem(Qt::black, false, 
00154             QString("%1").arg(s->columnCount())));
00155   m_Table -> setItem(i, 2, new ColoredTableItem(Qt::black, false, 
00156             QString("%1").arg(s->maxRowCount())));
00157   m_Table -> setItem(i, 3, new ColoredTableItem(Qt::black, false, ""));
00158 
00159   for (int c = 0; c < snc; c++) {
00160     QseColumn *col = s->column(c);
00161 
00162     if (col) {
00163       m_Table -> setItem(i, c + EXTRACOLUMNCOUNT, m_Role -> styledColumnItem(col));
00164     }
00165   }
00166       }
00167     }
00168   }
00169 }

Here is the call graph for this function:

void SummaryTableController::exportSelectedData ( QList< QTableWidgetSelectionRange >  selections  ) 

Definition at line 171 of file summarytablecontroller.cpp.

References QseDataExport::exportSelectedData(), and m_DataSet.

Referenced by summaryTableContextMenu().

00172 {
00173   QList<int> selectedscans;
00174   QTableWidgetSelectionRange selection;
00175 
00176   foreach(selection, selections) {
00177     int minrow = selection.topRow();
00178     int maxrow = selection.bottomRow();
00179     for (int row = minrow; row <= maxrow; row++) {
00180       selectedscans.append(row);
00181     }
00182   }
00183 
00184   QseDataExport::exportSelectedData("export/data", m_DataSet, selectedscans);
00185 }

Here is the call graph for this function:

void SummaryTableController::summaryTableContextMenu ( const QPoint &  pos  )  [slot]

Definition at line 187 of file summarytablecontroller.cpp.

References QseScan::column(), columnRangeRolesChanged(), QseColumn::DetectorRole, QseColumn::EnergyRole, exportSelectedData(), EXTRACOLUMNCOUNT, m_DataSet, m_Table, QseColumn::NormalizationRole, QseColumn::NotUsedRole, QseScan::NotUsedRole, scanRangeRoleChanged(), QseColumn::SecondsRole, QseColumn::setColumnRole(), QseColumn::UnspecifiedRole, QseScan::UnspecifiedRole, and QseScan::UsedRole.

00188 {
00189   QList<QTableWidgetSelectionRange> selections = m_Table -> selectedRanges();
00190   QTableWidgetSelectionRange selection;
00191 
00192   int col = m_Table->columnAt(pos.x());
00193 
00194   if (col < EXTRACOLUMNCOUNT) {
00195     QMenu menu(NULL, NULL);
00196     QAction* revertItem = menu.addAction(QString("Revert scan(s) to Default Usage"));
00197     QAction* unusedItem = menu.addAction(QString("Do Not Use scan(s)"));
00198     QAction* usedItem = menu.addAction(QString("Use scan(s)"));
00199     menu.addSeparator();
00200     QAction* exportItem = menu.addAction(QString("Export scan(s)..."));
00201 
00202     QseScan::QseScanRole newrole = QseScan::UnspecifiedRole;
00203 
00204     menu.setMouseTracking(TRUE);
00205 
00206     QAction* init = revertItem;
00207     QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), init);
00208 
00209     if (id) {
00210       if (id == exportItem) {
00211   exportSelectedData(selections);
00212       } else {
00213   if (id == revertItem) {
00214     newrole = QseScan::UnspecifiedRole;
00215   } else if (id == unusedItem) {
00216     newrole = QseScan::NotUsedRole;
00217   } else if (id == usedItem) {
00218     newrole = QseScan::UsedRole;
00219   }
00220       
00221   foreach(selection, selections) {
00222     int nchanged = 0;
00223     int minrow = selection.topRow();
00224     int maxrow = selection.bottomRow();
00225     for (int row = minrow; row <= maxrow; row++) {
00226       QseScan *s = m_DataSet -> scan(row);
00227       
00228       if (s) {
00229         nchanged++;
00230         s -> setScanRole(newrole);
00231       }
00232     }
00233     
00234     if (nchanged) {
00235       emit scanRangeRoleChanged(minrow, maxrow);
00236     }
00237   }
00238       }
00239     }
00240   } else if (col >= EXTRACOLUMNCOUNT) {
00241     QMenu menu(NULL, NULL);
00242 
00243     QAction* revertItem = menu.addAction(QString("Revert column(s) to Default Usage"));
00244     QAction* unusedItem = menu.addAction(QString("Do Not Use column(s)"));
00245     QAction* detectorItem = menu.addAction(QString("Use column(s) as a signal channel"));
00246     QAction* normalizationItem = menu.addAction(QString("Use column(s) as a normalization channel"));
00247     QAction* energyItem = menu.addAction(QString("Use column(s) as Energy (X Value)"));
00248     QAction* secondsItem = menu.addAction(QString("Use column(s) as counting time"));
00249     menu.addSeparator();
00250     QAction* exportItem = menu.addAction(QString("Export scan(s)..."));
00251 
00252     QseColumn::QseColumnRole newrole = QseColumn::UnspecifiedRole;
00253 
00254     menu.setMouseTracking(TRUE);
00255 
00256     QAction* init = revertItem;
00257     QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), init);
00258 
00259     if (id) {
00260       if (id == exportItem) {
00261   exportSelectedData(selections);
00262       } else {
00263   if (id == revertItem) {
00264     newrole = QseColumn::UnspecifiedRole;
00265   } else if (id == unusedItem) {
00266     newrole = QseColumn::NotUsedRole;
00267   } else if (id == detectorItem) {
00268     newrole = QseColumn::DetectorRole;
00269   } else if (id == normalizationItem) {
00270     newrole = QseColumn::NormalizationRole;
00271   } else if (id == energyItem) {
00272     newrole = QseColumn::EnergyRole;
00273   } else if (id == secondsItem) {
00274     newrole = QseColumn::SecondsRole;
00275   }
00276   
00277   foreach(selection, selections) {
00278     int minrow = selection.topRow();
00279     int maxrow = selection.bottomRow();
00280     int mincol = selection.leftColumn()-EXTRACOLUMNCOUNT;
00281     int maxcol = selection.rightColumn()-EXTRACOLUMNCOUNT;
00282     
00283     int nchanged = 0;
00284 
00285     for (int row = minrow; row <= maxrow; row++) {
00286       QseScan *s = m_DataSet -> scan(row);
00287 
00288       if (s) {
00289         for (int col=mincol; col<=maxcol; col++) {
00290     if ((col >= 0) && (col <= s->columnCount())) {
00291       QseColumn *c = s->column(col);
00292       
00293       if (c) {
00294         c->setColumnRole(newrole);
00295       }
00296     }
00297         }
00298         
00299         nchanged++;
00300       }
00301     }
00302     
00303     if (nchanged) {
00304       emit columnRangeRolesChanged(minrow, maxrow, mincol, maxcol);
00305     }
00306   }
00307       }
00308     }
00309   }
00310 }

void SummaryTableController::scanRangeRoleChanged ( int  scan0,
int  scan1 
) [signal]

Referenced by summaryTableContextMenu().

void SummaryTableController::columnRangeRolesChanged ( int  scan0,
int  scan1,
int  col0,
int  col1 
) [signal]

Referenced by summaryTableContextMenu().

void SummaryTableController::updateSummaryTableHeaders ( void   )  [private]

Definition at line 44 of file summarytablecontroller.cpp.

References EXTRACOLUMNCOUNT, m_DataSet, m_Table, QseDataSet::maxColumnCount(), and QseDataSet::scanCount().

Referenced by updateSummaryTable().

00045 {
00046   int ns = m_DataSet->scanCount();
00047   int mxnc = m_DataSet->maxColumnCount();
00048 
00049   m_Table -> setRowCount(ns);
00050   m_Table -> setColumnCount(mxnc + EXTRACOLUMNCOUNT);
00051   
00052   m_Table -> setHorizontalHeaderItem(0, new ColoredTableItem(Qt::black, false, "Command"));
00053   m_Table -> setHorizontalHeaderItem(1, new ColoredTableItem(Qt::black, false, "#Cols"));
00054   m_Table -> setHorizontalHeaderItem(2, new ColoredTableItem(Qt::black, false, "#Points"));
00055   m_Table -> setHorizontalHeaderItem(3, new ColoredTableItem(Qt::black, false, "Status"));
00056       
00057   for (int i = 0; i < mxnc; i++) {
00058     m_Table -> setHorizontalHeaderItem(i+EXTRACOLUMNCOUNT, 
00059                new ColoredTableItem(Qt::black, false, QString("col%1").arg(i + 1)));
00060   }
00061 }

Here is the call graph for this function:

void SummaryTableController::updateSummaryTableColumnInfo ( int  scan0,
int  scan1 
) [private]

Definition at line 78 of file summarytablecontroller.cpp.

References m_DataSet, QseDataSet::maxColumnCount(), updateSummaryTableColumnInfo(), and updateSummaryTableScanInfo().

00079 {
00080   updateSummaryTableScanInfo(scan0, scan1);
00081   updateSummaryTableColumnInfo(scan0, scan1, 0, m_DataSet->maxColumnCount());
00082 }

Here is the call graph for this function:

void SummaryTableController::updateSummaryTableSizes ( void   )  [slot]

Definition at line 108 of file summarytablecontroller.cpp.

References m_Table.

00109 {
00110   m_Table -> setUpdatesEnabled(false);
00111 
00112   m_Table -> resizeColumnsToContents();
00113   m_Table -> resizeRowsToContents();  
00114 
00115   m_Table -> setUpdatesEnabled(true);
00116   m_Table -> repaint();
00117 }


Member Data Documentation

QTableWidget* SummaryTableController::m_Table [private]

Definition at line 51 of file summarytablecontroller.h.

const int SummaryTableController::EXTRACOLUMNCOUNT = 4 [static, private]


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