mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 19:53:24 +00:00
Create a view for the Statistics Model and Fix displaying the header
This simply creates a view to show the model, while doing that I noticed that the model header wasn't showing, so I fixed it too. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
240cfa74be
commit
a05ea5a6e8
2 changed files with 29 additions and 17 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
|
#include <QTableView>
|
||||||
#include "divelistview.h"
|
#include "divelistview.h"
|
||||||
#include "starwidget.h"
|
#include "starwidget.h"
|
||||||
|
|
||||||
|
@ -240,7 +241,10 @@ void MainWindow::on_actionToggleZoom_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionYearlyStatistics_triggered()
|
void MainWindow::on_actionYearlyStatistics_triggered()
|
||||||
{
|
{
|
||||||
qDebug("actionYearlyStatistics");
|
QTableView *view = new QTableView();
|
||||||
|
QAbstractItemModel *model = new YearlyStatisticsModel();
|
||||||
|
view->setModel(model);
|
||||||
|
view->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1284,26 +1284,34 @@ void DiveComputerModel::remove(const QModelIndex& i)
|
||||||
|
|
||||||
YearlyStatisticsModel::YearlyStatisticsModel(QObject* parent)
|
YearlyStatisticsModel::YearlyStatisticsModel(QObject* parent)
|
||||||
{
|
{
|
||||||
|
columns = COLUMNS;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant YearlyStatisticsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant YearlyStatisticsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
QVariant val;
|
QVariant val;
|
||||||
switch(section){
|
if (role == Qt::FontRole){
|
||||||
case YEAR: val = tr("Year \n > Month"); break;
|
val = defaultModelFont();
|
||||||
case DIVES: val = tr("#"); break;
|
|
||||||
case TOTAL_TIME: val = tr("Duration \n Total"); break;
|
|
||||||
case AVERAGE_TIME: val = tr("Average"); break;
|
|
||||||
case SHORTEST_TIME: val = tr("Shortest"); break;
|
|
||||||
case LONGEST_TIME: val = tr("Longest"); break;
|
|
||||||
case AVG_DEPTH: val = tr("Depth \n Average"); break;
|
|
||||||
case MIN_DEPTH: val = tr("Minimum"); break;
|
|
||||||
case MAX_DEPTH: val = tr("Maximum"); break;
|
|
||||||
case AVG_SAC: val = tr("SAC \n Average"); break;
|
|
||||||
case MIN_SAC: val = tr("Minimum"); break;
|
|
||||||
case MAX_SAC: val = tr("Maximum"); break;
|
|
||||||
case AVG_TEMP: val = tr("Temperature \n Average"); break;
|
|
||||||
case MIN_TEMP: val = tr("Minimum"); break;
|
|
||||||
case MAX_TEMP: val = tr("Maximum"); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role == Qt::DisplayRole && orientation == Qt::Horizontal){
|
||||||
|
switch(section){
|
||||||
|
case YEAR: val = tr("Year \n > Month"); break;
|
||||||
|
case DIVES: val = tr("#"); break;
|
||||||
|
case TOTAL_TIME: val = tr("Duration \n Total"); break;
|
||||||
|
case AVERAGE_TIME: val = tr("Average"); break;
|
||||||
|
case SHORTEST_TIME: val = tr("Shortest"); break;
|
||||||
|
case LONGEST_TIME: val = tr("Longest"); break;
|
||||||
|
case AVG_DEPTH: val = tr("Depth \n Average"); break;
|
||||||
|
case MIN_DEPTH: val = tr("Minimum"); break;
|
||||||
|
case MAX_DEPTH: val = tr("Maximum"); break;
|
||||||
|
case AVG_SAC: val = tr("SAC \n Average"); break;
|
||||||
|
case MIN_SAC: val = tr("Minimum"); break;
|
||||||
|
case MAX_SAC: val = tr("Maximum"); break;
|
||||||
|
case AVG_TEMP: val = tr("Temperature \n Average"); break;
|
||||||
|
case MIN_TEMP: val = tr("Minimum"); break;
|
||||||
|
case MAX_TEMP: val = tr("Maximum"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue