mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Hook up adding a dive
This gets things mostly right. It creates a dive and uses the planner widget to create samples which are copied into the dive. It fills in some reasonable defaults (DC model, timestamp), but doesn't allow editing the timestamp (or the temperatures and air pressure). On accept the planner gets reset and the dive appears correctly in the dive list. Cancel still needs to be handled. And I bet there are many subtle bugs lurking here and there. But it's a start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									5a96389cd3
								
							
						
					
					
						commit
						46b125782e
					
				
					 6 changed files with 53 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -14,6 +14,7 @@
 | 
			
		|||
#include "modeldelegates.h"
 | 
			
		||||
#include "globe.h"
 | 
			
		||||
#include "completionmodels.h"
 | 
			
		||||
#include "diveplanner.h"
 | 
			
		||||
 | 
			
		||||
#include <QLabel>
 | 
			
		||||
#include <QCompleter>
 | 
			
		||||
| 
						 | 
				
			
			@ -90,9 +91,15 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
 | 
			
		|||
	ui->suit->setCompleter(completers.suit);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainTab::addDiveStarted()
 | 
			
		||||
{
 | 
			
		||||
	enableEdition();
 | 
			
		||||
	editMode = ADD;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainTab::enableEdition()
 | 
			
		||||
{
 | 
			
		||||
	if (!selected_dive)
 | 
			
		||||
	if (selected_dive < 0 || editMode != NONE)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	mainWindow()->dive_list()->setEnabled(false);
 | 
			
		||||
| 
						 | 
				
			
			@ -383,6 +390,13 @@ void MainTab::acceptChanges()
 | 
			
		|||
			mainWindow()->globe()->centerOn(current_dive);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (editMode == ADD) {
 | 
			
		||||
		// clean up the dive data (get duration, depth information from samples)
 | 
			
		||||
		fixup_dive(current_dive);
 | 
			
		||||
		DivePlannerPointsModel::instance()->cancelPlan();
 | 
			
		||||
		mainWindow()->showProfile();
 | 
			
		||||
		mainWindow()->refreshDisplay();
 | 
			
		||||
	}
 | 
			
		||||
	editMode = NONE;
 | 
			
		||||
 | 
			
		||||
	QPalette p;
 | 
			
		||||
| 
						 | 
				
			
			@ -500,7 +514,7 @@ void MainTab::on_location_textChanged(const QString& text)
 | 
			
		|||
		// we are editing a trip
 | 
			
		||||
		dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
 | 
			
		||||
		EDIT_TEXT(currentTrip->location, text);
 | 
			
		||||
	} else if (editMode == DIVE){
 | 
			
		||||
	} else if (editMode == DIVE || editMode == ADD){
 | 
			
		||||
		struct dive* dive;
 | 
			
		||||
		int i = 0;
 | 
			
		||||
		for_each_dive(i, dive){
 | 
			
		||||
| 
						 | 
				
			
			@ -535,7 +549,7 @@ void MainTab::on_notes_textChanged()
 | 
			
		|||
		// we are editing a trip
 | 
			
		||||
		dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
 | 
			
		||||
		EDIT_TEXT(currentTrip->notes, ui->notes->toPlainText());
 | 
			
		||||
	} else if (editMode == DIVE) {
 | 
			
		||||
	} else if (editMode == DIVE || editMode == ADD) {
 | 
			
		||||
		EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->notes, ui->notes->toPlainText()) );
 | 
			
		||||
	}
 | 
			
		||||
	markChangedWidget(ui->notes);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue