mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Started the Model to handle the DivePoints
Started the model to handle the divepoints between the Qt Widget interface and the QGraphicsView one. good thing is that we share code. Bad is that a model is harder to work, but doable. :) With this finished ( in a couple of commits ) one can insert a point on the Qt widget or on the graphics view and it will be 'mirrored' to both interfaces. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
aceb002a33
commit
9856aaaa86
2 changed files with 55 additions and 0 deletions
|
@ -792,4 +792,45 @@ void Button::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
|||
DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f), ui(new Ui::DivePlanner())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tablePoints->setModel(DivePlannerPointsModel::instance());
|
||||
}
|
||||
|
||||
int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole){
|
||||
switch(section){
|
||||
case DEPTH: return tr("Final Depth");
|
||||
case DURATION: return tr("Duration");
|
||||
case GAS: return tr("Used Gas");
|
||||
case CCSETPOINT: return tr("CC Set Point");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int DivePlannerPointsModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DivePlannerPointsModel::DivePlannerPointsModel(QObject* parent): QAbstractTableModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DivePlannerPointsModel* DivePlannerPointsModel::instance()
|
||||
{
|
||||
static DivePlannerPointsModel* self = new DivePlannerPointsModel();
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QGraphicsView>
|
||||
#include <QGraphicsPathItem>
|
||||
#include <QDialog>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace Ui{
|
||||
class DivePlanner;
|
||||
|
@ -13,6 +14,19 @@ class QListView;
|
|||
class QStringListModel;
|
||||
class QModelIndex;
|
||||
|
||||
class DivePlannerPointsModel : public QAbstractTableModel{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static DivePlannerPointsModel* instance();
|
||||
enum Sections{DEPTH, DURATION, GAS, CCSETPOINT, COLUMNS};
|
||||
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
private:
|
||||
explicit DivePlannerPointsModel(QObject* parent = 0);
|
||||
};
|
||||
|
||||
class Button : public QObject, public QGraphicsRectItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
Loading…
Add table
Reference in a new issue