mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Merge branch 'linusDiveList' of https://github.com/tcanabrava/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
commit
e34da61362
7 changed files with 60 additions and 37 deletions
|
@ -28,6 +28,8 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
||||||
model->setSortRole(TreeItemDT::SORT_ROLE);
|
model->setSortRole(TreeItemDT::SORT_ROLE);
|
||||||
model->setFilterKeyColumn(-1); // filter all columns
|
model->setFilterKeyColumn(-1); // filter all columns
|
||||||
setModel(model);
|
setModel(model);
|
||||||
|
connect(model, SIGNAL(layoutChanged()), this, SLOT(fixMessyQtModelBehaviour()));
|
||||||
|
|
||||||
setSortingEnabled(false);
|
setSortingEnabled(false);
|
||||||
setContextMenuPolicy(Qt::DefaultContextMenu);
|
setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||||
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
@ -42,6 +44,16 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
||||||
connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
|
connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiveListView::fixMessyQtModelBehaviour()
|
||||||
|
{
|
||||||
|
QAbstractItemModel *m = model();
|
||||||
|
for(int i = 0; i < model()->rowCount(); i++){
|
||||||
|
if (m->rowCount( m->index(i, 0) ) != 0){
|
||||||
|
setFirstColumnSpanned(i, QModelIndex(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DiveListView::unselectDives()
|
void DiveListView::unselectDives()
|
||||||
{
|
{
|
||||||
selectionModel()->clearSelection();
|
selectionModel()->clearSelection();
|
||||||
|
|
|
@ -38,6 +38,7 @@ public slots:
|
||||||
void removeFromTrip();
|
void removeFromTrip();
|
||||||
void deleteDive();
|
void deleteDive();
|
||||||
void testSlot();
|
void testSlot();
|
||||||
|
void fixMessyQtModelBehaviour();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void currentDiveChanged(int divenr);
|
void currentDiveChanged(int divenr);
|
||||||
|
|
|
@ -240,44 +240,54 @@ void MainWindow::on_actionYearlyStatistics_triggered()
|
||||||
qDebug("actionYearlyStatistics");
|
qDebug("actionYearlyStatistics");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* So, here's the deal.
|
||||||
|
* We have a few QSplitters that takes care of helping us with the
|
||||||
|
* size of a few widgets, they are ok, and we should continue using them
|
||||||
|
* to manage the visibility of them too. But the way that we did before was to
|
||||||
|
* widget->hide(); something, and if you hided something using the splitter,
|
||||||
|
* by holding it's handle and collapsing the widget, then you used the 'ctrl+number'
|
||||||
|
* shortcut to show it, it whould only show a gray panel.
|
||||||
|
*
|
||||||
|
* This patch makes everything behave using the splitters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BEHAVIOR QList<int>()
|
||||||
void MainWindow::on_actionViewList_triggered()
|
void MainWindow::on_actionViewList_triggered()
|
||||||
{
|
{
|
||||||
ui->InfoWidget->setVisible(false);
|
ui->listGlobeSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
|
||||||
ui->ListWidget->setVisible(true);
|
ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED);
|
||||||
ui->ProfileWidget->setVisible(false);
|
|
||||||
ui->globe->setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionViewProfile_triggered()
|
void MainWindow::on_actionViewProfile_triggered()
|
||||||
{
|
{
|
||||||
ui->InfoWidget->setVisible(false);
|
ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
|
||||||
ui->ListWidget->setVisible(false);
|
ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
|
||||||
ui->ProfileWidget->setVisible(true);
|
|
||||||
ui->globe->setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionViewInfo_triggered()
|
void MainWindow::on_actionViewInfo_triggered()
|
||||||
{
|
{
|
||||||
ui->InfoWidget->setVisible(true);
|
ui->infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
|
||||||
ui->ListWidget->setVisible(false);
|
ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
|
||||||
ui->ProfileWidget->setVisible(false);
|
|
||||||
ui->globe->setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionViewGlobe_triggered()
|
void MainWindow::on_actionViewGlobe_triggered()
|
||||||
{
|
{
|
||||||
ui->InfoWidget->setVisible(false);
|
ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
|
||||||
ui->ListWidget->setVisible(false);
|
ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED);
|
||||||
ui->ProfileWidget->setVisible(false);
|
|
||||||
ui->globe->setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
#undef BEHAVIOR
|
||||||
|
|
||||||
void MainWindow::on_actionViewAll_triggered()
|
void MainWindow::on_actionViewAll_triggered()
|
||||||
{
|
{
|
||||||
ui->InfoWidget->setVisible(true);
|
// big number squash the info profile to it's minimum.
|
||||||
ui->ListWidget->setVisible(true);
|
ui->infoProfileSplitter->setSizes(QList<int>() << 1 << 20000);
|
||||||
ui->ProfileWidget->setVisible(true);
|
|
||||||
ui->globe->setVisible(true);
|
// big number squash the globe view.
|
||||||
|
ui->listGlobeSplitter->setSizes(QList<int>() << 2000 << 1 );
|
||||||
|
|
||||||
|
// half and half?
|
||||||
|
ui->mainSplitter->setSizes( QList<int>() << 1 << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPreviousDC_triggered()
|
void MainWindow::on_actionPreviousDC_triggered()
|
||||||
|
@ -417,6 +427,7 @@ void MainWindow::initialUiSetup()
|
||||||
resize(sz);
|
resize(sz);
|
||||||
ui->mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
|
ui->mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
|
||||||
ui->infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray());
|
ui->infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray());
|
||||||
|
ui->listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup("ListWidget");
|
settings.beginGroup("ListWidget");
|
||||||
|
@ -508,6 +519,7 @@ void MainWindow::writeSettings()
|
||||||
settings.setValue("size",size());
|
settings.setValue("size",size());
|
||||||
settings.setValue("mainSplitter", ui->mainSplitter->saveState());
|
settings.setValue("mainSplitter", ui->mainSplitter->saveState());
|
||||||
settings.setValue("infoProfileSplitter", ui->infoProfileSplitter->saveState());
|
settings.setValue("infoProfileSplitter", ui->infoProfileSplitter->saveState());
|
||||||
|
settings.setValue("listGlobeSplitter", ui->listGlobeSplitter->saveState());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup("ListWidget");
|
settings.beginGroup("ListWidget");
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QModelIndex>
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
struct DiveList;
|
struct DiveList;
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class DiveTripModel;
|
class DiveTripModel;
|
||||||
|
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -35,6 +35,8 @@ class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
enum {COLLAPSED, EXPANDED};
|
||||||
|
|
||||||
MainWindow();
|
MainWindow();
|
||||||
ProfileGraphicsView *graphics();
|
ProfileGraphicsView *graphics();
|
||||||
MainTab *information();
|
MainTab *information();
|
||||||
|
@ -103,6 +105,7 @@ private:
|
||||||
void redrawProfile();
|
void redrawProfile();
|
||||||
void file_save();
|
void file_save();
|
||||||
void file_save_as();
|
void file_save_as();
|
||||||
|
void setupSplitters();
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindow *mainWindow();
|
MainWindow *mainWindow();
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="mainSplitter">
|
<widget class="QSplitter" name="mainSplitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
<widget class="KMessageWidget" name="mainErrorMessage" native="true"/>
|
<widget class="KMessageWidget" name="mainErrorMessage" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -147,8 +147,9 @@
|
||||||
<addaction name="actionViewList"/>
|
<addaction name="actionViewList"/>
|
||||||
<addaction name="actionViewProfile"/>
|
<addaction name="actionViewProfile"/>
|
||||||
<addaction name="actionViewInfo"/>
|
<addaction name="actionViewInfo"/>
|
||||||
<addaction name="actionViewAll"/>
|
|
||||||
<addaction name="actionViewGlobe"/>
|
<addaction name="actionViewGlobe"/>
|
||||||
|
<addaction name="actionViewAll"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionPreviousDC"/>
|
<addaction name="actionPreviousDC"/>
|
||||||
<addaction name="actionNextDC"/>
|
<addaction name="actionNextDC"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -317,7 +318,7 @@
|
||||||
<string>View All</string>
|
<string>View All</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+4</string>
|
<string>Ctrl+5</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPreviousDC">
|
<action name="actionPreviousDC">
|
||||||
|
@ -363,11 +364,8 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>View Globe</string>
|
<string>View Globe</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
|
||||||
<string>View Globe</string>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+5</string>
|
<string>Ctrl+4</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -785,11 +785,8 @@ QVariant TripItem::data(int column, int role) const
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case LOCATION:
|
case NR:
|
||||||
ret = QString(trip->location);
|
ret = QString(trip->location) + QString(get_trip_date_string(trip->when, trip->nrdives));
|
||||||
break;
|
|
||||||
case DATE:
|
|
||||||
ret = QString(get_trip_date_string(trip->when, trip->nrdives));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ void ProfileGraphicsView::showEvent(QShowEvent* event)
|
||||||
// but the dive was not ploted.
|
// but the dive was not ploted.
|
||||||
// force a replot by modifying the dive
|
// force a replot by modifying the dive
|
||||||
// hold by the view, and issuing a plot.
|
// hold by the view, and issuing a plot.
|
||||||
if (dive) {
|
if (dive && !scene()->items().count()) {
|
||||||
dive = 0;
|
dive = 0;
|
||||||
plot(get_dive(selected_dive));
|
plot(get_dive(selected_dive));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue