casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Slots | Signals | Public Member Functions | Public Attributes | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes
casa::TBDataTab Class Reference

Widget used to display table data. More...

#include <TBDataTab.qo.h>

List of all members.

Public Slots

void showWidgetInSplitter (QWidget *widget, bool isArray=false)
 Shows the given widget in the side panel.
void clearWidgetInSplitter ()
 Clears whatever widget (if any) is currently being displayed in the side panel.
void applyFormat (int index, TBFormat *format)
 Applies the given format to the field at the given index.
void clearFormat (int index)
 Clears the format on the field at the given index.
void clearAllFormats ()
 Clears all formats on all fields.

Signals

void dataChanged (int row, int col, String newVal)
 This signal is emitted when the user has edited a cell.
void rightWidgetClosed (QWidget *which)
 This signal is emitted when the side panel is closed.
void followReferenceRequested (String subtable, int index)
 This signal is emitted when the user right-clicks on an index and selects the "Follow subtable index reference" command.
void sortEntered ()
 This signal is emitted when a sort is applied to the table.
void sortCleared ()
 This signal is emitted when a sort is cleared from the table.
void columnHidden (int index, bool hidden)
 This signal is emitted when a column is shown or hidden.

Public Member Functions

 TBDataTab (TBTableTabs *tt)
 Constructor that takes the parent TBTableTabs.
 ~TBDataTab ()
QTableWidget * getTableWidget ()
 Returns the QTableWidget that displays the data.
QBrush & getSelectedCellBackground ()
 Returns the QBrush that is used to draw the background of any selected cells in the QTableWidget.
QBrush & getUnselectedCellBackground ()
 Retruns the QBrush that is used to draw the background of any unselected cells in the QTableWidget.
TBFilterRuleSequencegetFilter ()
 Returns the current row filter, or NULL if there is none.
void setFilter (TBFilterRuleSequence *rule)
 Sets the current filter to the given rules, but does NOT apply it.
TBFormatformatAt (int index)
 Returns the current format for the field at the given index, or NULL if there is none.
vector< pair< String, bool > > * getSortFields ()
 Returns the current sort on the displayed data.
void updateTable (ProgressHelper *pp=NULL)
 Updates the QTableWidget with new data that has been loaded into the table backend.
void setData (int row, int col, TBData *newVal, bool format=true)
 Sets the given cell in the QTableWidget to the new value, but does NOT update the backend.
bool loadPage (int p)
 Loads the given page into the table backend, which then updates the display.
void refresh (int row, int col, bool format=true)
 Refreshes the table backend using TBTable::refresh(), then updates the displayed data using setData().
void sortBy (vector< pair< String, bool > > &s)
 Sorts the displayed data with the given order.
void setSortIndicator (int index, bool asc)
 Sets the sort indicator on the QTableWidget for the given column with an ascending arrow if asc is true or a descending arrow otherwise.
void clearSortIndicator ()
 Clears the sort indicator on the QTableWidget.
void highlight (int row)
 Selects and highlights the given row in the table widget.
int visibleIndex (int logicalIndex)
 Returns the visible index for the row with the given logical index.
int logicalIndex (int visibleIndex)
 Returns the logical index for the row with the given visible index.
void hideColumn (int index, bool hidden)
 Hides (or shows) the column with the given index.
void formatField (int index)
 Opens a format dialog for the field with the given index.

Public Attributes

bool goForward
 Remembers whether you pressed the next or previous button.

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *event)
 Catches the right-click event; if the right click is on a table cell and the displayed data could be an index, show the subtable index reference menu.

Private Slots

void pageBack ()
 Slot for page back button.
void pageForward ()
 Slot for page forward button.
void pageFirst ()
 Slot to go to first page.
void pageLast ()
 Slot to go to last page.
void pageGo ()
 Slot for page go button.
void notifyDataChanged (int row, int col)
 Slot for QTableWidget::cellChanged().
void cellClicked (int row, int col)
 Slot for QTableWidget::currentCellChanged().
void referenceMenuClicked (QAction *which)
 Slot for the menu command chosen from the reference menu shown on a right click.
void doubleClicked (int row, int col)
 Slot for QTableWidget::cellDoubleClicked().
void displayFieldInfo ()
 Displays the tooltip for the last clicked header in a dialog.
void displayFieldStatistics ()
 Displays statistics (min, max, mean) for the last clicked header in a dialog.
void hideColumn ()
 Hides the column that was just right-clicked.
void formatField ()
 Formats the field that was just right-clicked.
void headerMoved ()
 Slot for when a column header is moved.
void restoreColumns ()
 Slot for the restore columns button.
void resizeHeaders ()
 Slot for the resize headers button.
void headerClicked (int index)
 Slot for QHeaderView::sectionClicked().
void clearSort ()
 Slot for the clear sort button.
void copyData ()
 Slot for copying the currently selected text into the system clipboard.

Private Member Functions

void updatePageTrackers ()
 Update widgets that keep track of what page the browser is on.
void sort (int col, bool asc)
 Sorts on the given row.
void applyFilter ()
 Applies the current filter to the displayed rows.

Private Attributes

TBTableTabsttabs
 Useful pointers to table backend.
TBTabletable
int page
 The currently loaded page.
int loadRows
 How many rows per page are loaded at once.
QCloseableWidgetrightWidget
 Side panel.
vector< QTableWidgetItem * > highlightedCells
 List of cells that are highlighted (the row and column of the currently selected cell).
QBrush unselectedBackground
 Brushes used to draw the backgrounds of unselected and selected cells in the QTableWidget, respectively.
QBrush selectedBackground
TBFilterRuleSequencefilter
 Current row filter, or NULL if there is none.
vector< TBFormat * > formats
 Current field formats.
QFontColordefaultFormat
 "Cleared" format for cell text.
bool arrayOpened
 Indicates whether the side panel is currently open with an array or not.
TBArrayPanelarrayPanel
 Points to the current array panel, or NULL if there is none.
vector< QTableWidgetItem * > rowItems
 Keeps track of the un-sorted order of the rows.
vector< int > rowIndices
 Keeps track of the un-sorted order of the rows.
vector< pair< String, bool > > currSort
 The current sort order.
int clickedHeader
 Used for handling right-clicks on headers.

Detailed Description

Widget used to display table data.

Synopsis

TBDataTab is the tab responsible for displaying table data in a QTableWidget. It also provides functionality for changing page and number of rows loaded, catching and passing on edit events, and handling double-click events.

Definition at line 110 of file TBDataTab.qo.h.


Constructor & Destructor Documentation

Constructor that takes the parent TBTableTabs.


Member Function Documentation

void casa::TBDataTab::applyFilter ( ) [private]

Applies the current filter to the displayed rows.

void casa::TBDataTab::applyFormat ( int  index,
TBFormat format 
) [slot]

Applies the given format to the field at the given index.

void casa::TBDataTab::cellClicked ( int  row,
int  col 
) [private, slot]

Slot for QTableWidget::currentCellChanged().

Updates the display to highlight the row and column of the selected cell.

Clears all formats on all fields.

void casa::TBDataTab::clearFormat ( int  index) [slot]

Clears the format on the field at the given index.

void casa::TBDataTab::clearSort ( ) [private, slot]

Slot for the clear sort button.

Clears the sort on the table by moving the rows back to their original order.

Clears the sort indicator on the QTableWidget.

Clears whatever widget (if any) is currently being displayed in the side panel.

void casa::TBDataTab::columnHidden ( int  index,
bool  hidden 
) [signal]

This signal is emitted when a column is shown or hidden.

void casa::TBDataTab::contextMenuEvent ( QContextMenuEvent *  event) [protected]

Catches the right-click event; if the right click is on a table cell and the displayed data could be an index, show the subtable index reference menu.

Also show action for copying to the clipboard.

void casa::TBDataTab::copyData ( ) [private, slot]

Slot for copying the currently selected text into the system clipboard.

void casa::TBDataTab::dataChanged ( int  row,
int  col,
String  newVal 
) [signal]

This signal is emitted when the user has edited a cell.

The parameter describe which cell was edited and its new value.

void casa::TBDataTab::displayFieldInfo ( ) [private, slot]

Displays the tooltip for the last clicked header in a dialog.

void casa::TBDataTab::displayFieldStatistics ( ) [private, slot]

Displays statistics (min, max, mean) for the last clicked header in a dialog.

void casa::TBDataTab::doubleClicked ( int  row,
int  col 
) [private, slot]

Slot for QTableWidget::cellDoubleClicked().

Catches a double-click event on a cell in the QTableWidget. If the value is a table type, opens the indicated table in a new tab. If the value is an array type, opens the array in the side panel. Otherwise, if the table is currently editable, enters into editing mode on that cell.

void casa::TBDataTab::followReferenceRequested ( String  subtable,
int  index 
) [signal]

This signal is emitted when the user right-clicks on an index and selects the "Follow subtable index reference" command.

The String indicates which subtable was chosen, and the index indicates the chosen index which is the value of the cell that was right-clicked on.

Returns the current format for the field at the given index, or NULL if there is none.

void casa::TBDataTab::formatField ( int  index)

Opens a format dialog for the field with the given index.

Applies the format that the user enters.

void casa::TBDataTab::formatField ( ) [private, slot]

Formats the field that was just right-clicked.

Returns the current row filter, or NULL if there is none.

Returns the QBrush that is used to draw the background of any selected cells in the QTableWidget.

vector<pair<String, bool> >* casa::TBDataTab::getSortFields ( )

Returns the current sort on the displayed data.

Each pair in the vector is the name of the field with a bool indicating whether the sort is ascending or not.

Returns the QTableWidget that displays the data.

Retruns the QBrush that is used to draw the background of any unselected cells in the QTableWidget.

void casa::TBDataTab::headerClicked ( int  index) [private, slot]

Slot for QHeaderView::sectionClicked().

Catches a sorting click event on a column header and sorts accordingly.

void casa::TBDataTab::headerMoved ( ) [private, slot]

Slot for when a column header is moved.

Enables the "restore columns" button.

void casa::TBDataTab::hideColumn ( int  index,
bool  hidden 
)

Hides (or shows) the column with the given index.

Whether the column is shown or hidden depends on the "hidden" parameter.

void casa::TBDataTab::hideColumn ( ) [private, slot]

Hides the column that was just right-clicked.

void casa::TBDataTab::highlight ( int  row)

Selects and highlights the given row in the table widget.

bool casa::TBDataTab::loadPage ( int  p)

Loads the given page into the table backend, which then updates the display.

If the page is valid, the result of TBTableTabs::loadRows() is returned; otherwise false is returned.

int casa::TBDataTab::logicalIndex ( int  visibleIndex)

Returns the logical index for the row with the given visible index.

Rows may have differing visible and logical indices when a sort has been entered.

void casa::TBDataTab::notifyDataChanged ( int  row,
int  col 
) [private, slot]

Slot for QTableWidget::cellChanged().

Catches changes from the QTableWidget and emits signals as needed.

void casa::TBDataTab::pageBack ( ) [private, slot]

Slot for page back button.

Goes back a page.

void casa::TBDataTab::pageFirst ( ) [private, slot]

Slot to go to first page.

void casa::TBDataTab::pageForward ( ) [private, slot]

Slot for page forward button.

Goes forward a page.

void casa::TBDataTab::pageGo ( ) [private, slot]

Slot for page go button.

Goes to the page specified in the page line edit.

void casa::TBDataTab::pageLast ( ) [private, slot]

Slot to go to last page.

void casa::TBDataTab::referenceMenuClicked ( QAction *  which) [private, slot]

Slot for the menu command chosen from the reference menu shown on a right click.

Catches which subtable the user followed a reference and emits signals as needed.

void casa::TBDataTab::refresh ( int  row,
int  col,
bool  format = true 
)

Refreshes the table backend using TBTable::refresh(), then updates the displayed data using setData().

void casa::TBDataTab::resizeHeaders ( ) [private, slot]

Slot for the resize headers button.

Resizes the row and column headers to fit displayed contents. See QTableWidget::resizeRowsToContents() and QTableWidget::resizeColumnsToContents().

void casa::TBDataTab::restoreColumns ( ) [private, slot]

Slot for the restore columns button.

Moves all columns back to their original locations.

void casa::TBDataTab::rightWidgetClosed ( QWidget *  which) [signal]

This signal is emitted when the side panel is closed.

The QWidget points to the widget that was just closed.

void casa::TBDataTab::setData ( int  row,
int  col,
TBData newVal,
bool  format = true 
)

Sets the given cell in the QTableWidget to the new value, but does NOT update the backend.

If format is true, then any existing format will be applied to the new value.

Sets the current filter to the given rules, but does NOT apply it.

void casa::TBDataTab::setSortIndicator ( int  index,
bool  asc 
)

Sets the sort indicator on the QTableWidget for the given column with an ascending arrow if asc is true or a descending arrow otherwise.

void casa::TBDataTab::showWidgetInSplitter ( QWidget *  widget,
bool  isArray = false 
) [slot]

Shows the given widget in the side panel.

isArray should be true if the widget is a TBViewArray, false otherwise.

void casa::TBDataTab::sort ( int  col,
bool  asc 
) [private]

Sorts on the given row.

If asc is true, sorts in ascending order, otherwise sorts in descending order.

void casa::TBDataTab::sortBy ( vector< pair< String, bool > > &  s)

Sorts the displayed data with the given order.

Each pair in the vector is the name of the field with a bool indicating whether the sort is ascending or not.

void casa::TBDataTab::sortCleared ( ) [signal]

This signal is emitted when a sort is cleared from the table.

void casa::TBDataTab::sortEntered ( ) [signal]

This signal is emitted when a sort is applied to the table.

Update widgets that keep track of what page the browser is on.

Updates the QTableWidget with new data that has been loaded into the table backend.

If a ProgressHelper is provided, it will be updated periodically with progress information.

int casa::TBDataTab::visibleIndex ( int  logicalIndex)

Returns the visible index for the row with the given logical index.

Rows may have differing visible and logical indices when a sort has been entered.


Member Data Documentation

Indicates whether the side panel is currently open with an array or not.

Definition at line 288 of file TBDataTab.qo.h.

Points to the current array panel, or NULL if there is none.

Definition at line 291 of file TBDataTab.qo.h.

Used for handling right-clicks on headers.

Keeps track of the last right-clicked header column number.

Definition at line 306 of file TBDataTab.qo.h.

vector<pair<String, bool> > casa::TBDataTab::currSort [private]

The current sort order.

Definition at line 302 of file TBDataTab.qo.h.

"Cleared" format for cell text.

Definition at line 285 of file TBDataTab.qo.h.

Current row filter, or NULL if there is none.

Definition at line 279 of file TBDataTab.qo.h.

vector<TBFormat*> casa::TBDataTab::formats [private]

Current field formats.

Definition at line 282 of file TBDataTab.qo.h.

Remembers whether you pressed the next or previous button.

Uses this when filter rules are applied to avoid displaying blank pages.

Definition at line 201 of file TBDataTab.qo.h.

vector<QTableWidgetItem*> casa::TBDataTab::highlightedCells [private]

List of cells that are highlighted (the row and column of the currently selected cell).

Definition at line 269 of file TBDataTab.qo.h.

How many rows per page are loaded at once.

Definition at line 262 of file TBDataTab.qo.h.

int casa::TBDataTab::page [private]

The currently loaded page.

Definition at line 259 of file TBDataTab.qo.h.

Side panel.

Definition at line 265 of file TBDataTab.qo.h.

vector<int> casa::TBDataTab::rowIndices [private]

Keeps track of the un-sorted order of the rows.

Doing rowIndices[visualRow] returns the logicalRow.

Definition at line 299 of file TBDataTab.qo.h.

vector<QTableWidgetItem*> casa::TBDataTab::rowItems [private]

Keeps track of the un-sorted order of the rows.

Doing rowItems[logicalRow]->row() returns the visualRow.

Definition at line 295 of file TBDataTab.qo.h.

Definition at line 275 of file TBDataTab.qo.h.

Definition at line 255 of file TBDataTab.qo.h.

Useful pointers to table backend.

Definition at line 254 of file TBDataTab.qo.h.

Brushes used to draw the backgrounds of unselected and selected cells in the QTableWidget, respectively.

Definition at line 274 of file TBDataTab.qo.h.


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