mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Created a new dialog - Edit DiveComputer
Created a new dialog, Edit Divecomputer, it will currently only lists the divecomputers that are used on the xml file. I used the same method that the gtk version used, but only 2 divecomputers got visualized in the dirk dive data. I'll assume that it's correct and will fix it in the next couple of commits. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
3677f4e5ea
commit
ebed836ee5
7 changed files with 216 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -49,6 +49,7 @@ HEADERS = \
|
|||
qt-ui/preferences.h \
|
||||
qt-ui/simplewidgets.h \
|
||||
qt-ui/subsurfacewebservices.h \
|
||||
qt-ui/divecomputermanagementdialog.h \
|
||||
|
||||
|
||||
SOURCES = \
|
||||
|
@ -82,6 +83,7 @@ SOURCES = \
|
|||
qt-ui/preferences.cpp \
|
||||
qt-ui/simplewidgets.cpp \
|
||||
qt-ui/subsurfacewebservices.cpp \
|
||||
qt-ui/divecomputermanagementdialog.cpp \
|
||||
$(RESFILE)
|
||||
|
||||
|
||||
|
|
22
qt-ui/divecomputermanagementdialog.cpp
Normal file
22
qt-ui/divecomputermanagementdialog.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "divecomputermanagementdialog.h"
|
||||
#include "models.h"
|
||||
#include "ui_divecomputermanagementdialog.h"
|
||||
|
||||
DiveComputerManagementDialog::DiveComputerManagementDialog(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f)
|
||||
, ui( new Ui::DiveComputerManagementDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
model = new DiveComputerModel();
|
||||
ui->tableView->setModel(model);
|
||||
}
|
||||
|
||||
DiveComputerManagementDialog* DiveComputerManagementDialog::instance()
|
||||
{
|
||||
static DiveComputerManagementDialog *self = new DiveComputerManagementDialog();
|
||||
return self;
|
||||
}
|
||||
|
||||
void DiveComputerManagementDialog::update()
|
||||
{
|
||||
model->update();
|
||||
}
|
22
qt-ui/divecomputermanagementdialog.h
Normal file
22
qt-ui/divecomputermanagementdialog.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef DIVECOMPUTERMANAGEMENTDIALOG_H
|
||||
#define DIVECOMPUTERMANAGEMENTDIALOG_H
|
||||
#include <QDialog>
|
||||
|
||||
class DiveComputerModel;
|
||||
namespace Ui{
|
||||
class DiveComputerManagementDialog;
|
||||
};
|
||||
|
||||
class DiveComputerManagementDialog : public QDialog{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static DiveComputerManagementDialog *instance();
|
||||
void update();
|
||||
private:
|
||||
explicit DiveComputerManagementDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
||||
Ui::DiveComputerManagementDialog *ui;
|
||||
DiveComputerModel *model;
|
||||
};
|
||||
|
||||
#endif
|
67
qt-ui/divecomputermanagementdialog.ui
Normal file
67
qt-ui/divecomputermanagementdialog.ui
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DiveComputerManagementDialog</class>
|
||||
<widget class="QDialog" name="DiveComputerManagementDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DiveComputerManagementDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DiveComputerManagementDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -29,6 +29,7 @@
|
|||
#include "downloadfromdivecomputer.h"
|
||||
#include "preferences.h"
|
||||
#include "subsurfacewebservices.h"
|
||||
#include "divecomputermanagementdialog.h"
|
||||
|
||||
static MainWindow* instance = 0;
|
||||
|
||||
|
@ -187,7 +188,9 @@ void MainWindow::on_actionDownloadWeb_triggered()
|
|||
|
||||
void MainWindow::on_actionEditDeviceNames_triggered()
|
||||
{
|
||||
qDebug("actionEditDeviceNames");}
|
||||
DiveComputerManagementDialog::instance()->update();
|
||||
DiveComputerManagementDialog::instance()->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionAddDive_triggered()
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "models.h"
|
||||
#include "../helpers.h"
|
||||
#include "../dive.h"
|
||||
#include "../device.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QColor>
|
||||
|
@ -1105,3 +1106,85 @@ void DiveTripModel::setLayout(DiveTripModel::Layout layout)
|
|||
currentLayout = layout;
|
||||
setupModelData();
|
||||
}
|
||||
|
||||
/*####################################################################
|
||||
*
|
||||
* Dive Computer Model
|
||||
*
|
||||
*####################################################################
|
||||
*/
|
||||
|
||||
DiveComputerModel::DiveComputerModel(QObject* parent): QAbstractTableModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int DiveComputerModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
QVariant DiveComputerModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
QVariant ret;
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal){
|
||||
return ret;
|
||||
}
|
||||
switch(section){
|
||||
case ID : ret = tr("Device ID"); break;
|
||||
case MODEL : ret = tr("Model"); break;
|
||||
case NICKNAME : ret = tr("Nickname"); break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVariant DiveComputerModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
struct device_info *device = head_of_device_info_list();
|
||||
for(int i = 0; i < index.row(); i++){
|
||||
device = device->next;
|
||||
}
|
||||
|
||||
QVariant ret;
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole){
|
||||
switch(index.column()){
|
||||
case ID : ret = device->deviceid; break;
|
||||
case MODEL : ret = device->model; break;
|
||||
case NICKNAME : ret = device->nickname; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::DecorationRole && index.column() == REMOVE){
|
||||
ret = QIcon(":trash");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DiveComputerModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return numRows;
|
||||
}
|
||||
|
||||
void DiveComputerModel::update()
|
||||
{
|
||||
int count = 0;
|
||||
struct device_info *nnl = head_of_device_info_list();
|
||||
while (nnl) {
|
||||
nnl = nnl->next;
|
||||
count++;
|
||||
}
|
||||
qDebug() << "Numero de Devices" << count;
|
||||
|
||||
if(numRows){
|
||||
beginRemoveRows(QModelIndex(), 0, numRows-1);
|
||||
numRows = 0;
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
if (count){
|
||||
beginInsertRows(QModelIndex(), 0, count-1);
|
||||
numRows = count;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -167,4 +167,20 @@ private:
|
|||
Layout currentLayout;
|
||||
};
|
||||
|
||||
class DiveComputerModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {REMOVE, MODEL, ID, NICKNAME, COLUMNS};
|
||||
explicit DiveComputerModel(QObject* parent = 0);
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
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;
|
||||
void update();
|
||||
private:
|
||||
int numRows;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue