10 #include <QVBoxLayout> 12 #include "AbstractTableModel.h" 14 #include "TableViewHeader.h" 15 #include "TableViewContent.h" 16 #include "TableColumn.h" 17 #include "TableColumnList.h" 29 QString pathForSettings,
34 setObjectName(objName);
39 connect(
m_model, SIGNAL(filterCountsChanged(
int,
int)),
40 this, SIGNAL(filterCountsChanged(
int,
int)));
41 connect(
m_model, SIGNAL(userWarning(AbstractTableModel::Warning)),
51 for (
int i = 0; i <
m_columns->size(); i++) {
53 QString colTitle = col->getTitle();
54 int defaultWidth = QFontMetrics(font()).width(colTitle) + 40;
55 if (colTitle.size()) {
56 key = objectName() +
" " + colTitle +
" width";
57 key.replace(
" ",
"_");
58 col->setWidth(settings.value(key, defaultWidth).toInt());
60 key = objectName() +
" " + colTitle +
" ascending";
61 key.replace(
" ",
"_");
62 col->setSortAscending(settings.value(key,
true).toBool());
65 col->setWidth(defaultWidth);
71 key = objectName() +
" sorting order";
72 key.replace(
" ",
"_");
81 connect(
m_header, SIGNAL(requestedGlobalSelection(
bool)),
83 connect(
m_header, SIGNAL(requestedGlobalSelection(
bool)),
84 this, SIGNAL(selectionChanged()));
87 connect(
m_content, SIGNAL(tableSelectionChanged()),
88 this, SIGNAL(selectionChanged()));
93 connect(
m_content, SIGNAL(horizontalScrollBarValueChanged(
int)),
94 m_header, SLOT(updateHeaderOffset(
int)));
95 connect(
m_content, SIGNAL(modelDataChanged()),
96 this, SIGNAL(modelDataChanged()));
100 this, SIGNAL(editControlPoint(
ControlPoint *, QString)));
102 connect(
m_header, SIGNAL(columnResized(
bool)),
103 m_content, SLOT(updateHorizontalScrollBar(
bool)));
105 QVBoxLayout *layout =
new QVBoxLayout;
109 layout->setContentsMargins(0, 0, 0, 0);
110 layout->setSpacing(0);
121 ASSERT(objectName().size());
125 for (
int i = 0; i <
m_columns->size(); i++) {
127 QString colTitle = col->getTitle();
128 if (colTitle.size()) {
129 key = objectName() +
" " + colTitle +
" width";
130 key.replace(
" ",
"_");
131 settings.setValue(key, col->getWidth());
133 key = objectName() +
" " + colTitle +
" ascending";
134 key.replace(
" ",
"_");
135 settings.setValue(key, col->sortAscending());
139 key = objectName() +
" sorting order";
140 key.replace(
" ",
"_");
141 settings.setValue(key,
m_columns->getSortingOrderAsStrings());
168 for (
int i = 0; i <
m_columns->size(); i++) {
170 if (col->getTitle() == column)
171 col->setVisible(visible);
251 case AbstractTableModel::SortingDisabled:
252 m_warningLabel->setText(tr(
"<font color='red'>Sorting disabled</font>"));
256 case AbstractTableModel::SortingTableSizeLimitReached:
258 tr(
"<font color='red'>Sorting disabled - table row count (%L1) > table size limit" 265 case AbstractTableModel::None:
void scrollTo(QList< AbstractTreeItem * >)
Scrolls to the selected items.
TableViewContent * m_content
The content of the header.
TableViewContent * content()
Returns the content of the table.
TableColumnList * m_columns
The columns of the table.
void refresh()
Refreshes the table and viewport.
AbstractTableModel * getModel()
Returns the model.
AbstractTableModel * m_model
The model of the table.
TableViewHeader * getHorizontalHeader()
Returns the horizontal header.
Translates the tree model into a table model.
void setColumnVisible(QString, bool)
Sets the specified column visible or invisible.
void nullify()
Sets all member variables to NULL.
AbstractTableModel * getModel()
Returns the model.
virtual ~TableView()
Destructor.
Namespace for ISIS/Bullet specific routines.
QString * m_settingsPath
Path of where to read/write the settings.
void handleModelSelectionChanged()
Handles refreshing the content when the model selection is changed.
TableView(AbstractTableModel *someModel, QString pathForSettigs, QString objName)
Constructor.
TableViewHeader * m_header
The table header.
void displayWarning(AbstractTableModel::Warning)
Displays warnings for a table.
QLabel * m_warningLabel
Label of any warnings.