void MainWindow::on_actionAddDive_triggered()
{
	if (!plannerStateClean())
		return;

	if (dive_list()->selectedTrips().count() >= 1) {
		dive_list()->rememberSelection();
		dive_list()->clearSelection();
	}

	DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);

	// setup things so we can later create our starting dive
	setupForAddAndPlan("manually added dive"); // don't translate, stored in the XML file

	// now show the mostly empty main tab
	ui.InfoWidget->updateDiveInfo();

	// show main tab
	ui.InfoWidget->setCurrentIndex(0);

	ui.InfoWidget->addDiveStarted();
	ui.infoPane->setCurrentIndex(MAINTAB);

	ui.newProfile->setAddState();
	DivePlannerPointsModel::instance()->createSimpleDive();
	ui.newProfile->plotDive();
}
Beispiel #2
0
void MainWindow::on_actionAddDive_triggered()
{
	if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
	    ui.InfoWidget->isEditing()) {
		QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive."));
		return;
	}
	dive_list()->rememberSelection();
	dive_list()->unselectDives();
	disableDcShortcuts();
	DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);

	// now cheat - create one dive that we use to store the info tab data in
	struct dive *dive = alloc_dive();
	dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
	dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file

	dive->latitude.udeg = 0;
	dive->longitude.udeg = 0;
	record_dive(dive);
	// this isn't in the UI yet, so let's call the C helper function - we'll fix this up when
	// accepting the dive
	select_dive(get_divenr(dive));
	ui.InfoWidget->setCurrentIndex(0);
	ui.InfoWidget->updateDiveInfo(selected_dive);
	ui.InfoWidget->addDiveStarted();
	ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
	ui.infoPane->setCurrentIndex(MAINTAB);
	DivePlannerPointsModel::instance()->clear();
	DivePlannerPointsModel::instance()->createSimpleDive();
	ui.ListWidget->reload(DiveTripModel::CURRENT);
}
Beispiel #3
0
void MainWindow::on_actionClose_triggered()
{
	if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
	    ui.InfoWidget->isEditing()) {
		QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before closing the file."));
		return;
	}
	if (unsaved_changes() && (askSaveChanges() == false))
		return;

	ui.newProfile->setEmptyState();
	/* free the dives and trips */
	clear_git_id();
	while (dive_table.nr)
		delete_single_dive(0);

	dive_list()->clearSelection();
	/* clear the selection and the statistics */
	selected_dive = -1;

	if (existing_filename) {
		free((void *)existing_filename);
		existing_filename = NULL;
	}
	cleanUpEmpty();
	mark_divelist_changed(false);

	clear_events();
}
Beispiel #4
0
// this gets called after we download dives from a divecomputer
void MainWindow::refreshDisplay(bool doRecreateDiveList)
{
	getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
	information()->reload();
	TankInfoModel::instance()->update();
	globe()->reload();
	if (doRecreateDiveList)
		recreateDiveList();

	setApplicationState("Default");
	dive_list()->setEnabled(true);
	dive_list()->setFocus();
	WSInfoModel::instance()->updateInfo();
	if (amount_selected == 0)
		cleanUpEmpty();
}
void MainWindow::planCreated()
{
	// get the new dive selected and assign a number if reasonable
	ui.newProfile->setProfileState();
	if (displayed_dive.id == 0) {
		// we might have added a new dive (so displayed_dive was cleared out by clone_dive()
		dive_list()->unselectDives();
		select_dive(dive_table.nr - 1);
		dive_list()->selectDive(selected_dive);
		set_dive_nr_for_current_dive();
	}
	// make sure our UI is in a consistent state
	ui.InfoWidget->updateDiveInfo();
	showProfile();
	refreshDisplay();
}
Beispiel #6
0
void MainWindow::recreateDiveList()
{
	dive_list()->reload(DiveTripModel::CURRENT);
	TagFilterModel::instance()->repopulate();
	BuddyFilterModel::instance()->repopulate();
	LocationFilterModel::instance()->repopulate();
	SuitsFilterModel::instance()->repopulate();
}
Beispiel #7
0
MainWindow::MainWindow() : QMainWindow(),
	actionNextDive(0),
	actionPreviousDive(0),
	helpView(0),
	state(VIEWALL),
	survey(0)
{
	Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!");
	m_Instance = this;
	ui.setupUi(this);
	read_hashes();
	// Define the States of the Application Here, Currently the states are situations where the different
	// widgets will change on the mainwindow.

	// for the "default" mode
	MainTab *mainTab = new MainTab();
	DiveListView *diveListView = new DiveListView();
	ProfileWidget2 *profileWidget = new ProfileWidget2();

#ifndef NO_MARBLE
	GlobeGPS *globeGps = new GlobeGPS();
#else
	QWidget *globeGps = NULL;
#endif

	PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget();
	DivePlannerWidget *plannerWidget = new DivePlannerWidget();
	PlannerDetails *plannerDetails = new PlannerDetails();
	LocationInformationWidget *locationInformation = new LocationInformationWidget();

	// what is a sane order for those icons? we should have the ones the user is
	// most likely to want towards the top so they are always visible
	// and the ones that someone likely sets and then never touches again towards the bottom
	profileToolbarActions << ui.profCalcCeiling << ui.profCalcAllTissues << // start with various ceilings
				 ui.profIncrement3m << ui.profDcCeiling <<
				 ui.profPhe << ui.profPn2 << ui.profPO2 << // partial pressure graphs
				 ui.profRuler << ui.profScaled << // measuring and scaling
				 ui.profTogglePicture << ui.profTankbar <<
				 ui.profMod << ui.profNdl_tts << // various values that a user is either interested in or not
				 ui.profEad << ui.profSAC <<
				 ui.profHR << // very few dive computers support this
				 ui.profTissues; // maybe less frequently used

	QToolBar *toolBar = new QToolBar();
	Q_FOREACH (QAction *a, profileToolbarActions)
		toolBar->addAction(a);
	toolBar->setOrientation(Qt::Vertical);
	toolBar->setIconSize(QSize(24,24));

	QWidget *profileContainer = new QWidget();
	QHBoxLayout *profLayout = new QHBoxLayout();
	profLayout->setSpacing(0);
	profLayout->setMargin(0);
	profLayout->setContentsMargins(0,0,0,0);
	profLayout->addWidget(toolBar);
	profLayout->addWidget(profileWidget);
	profileContainer->setLayout(profLayout);

	registerApplicationState("Default", mainTab, profileContainer, diveListView, globeGps );
	registerApplicationState("AddDive", mainTab, profileContainer, diveListView, globeGps );
	registerApplicationState("EditDive", mainTab, profileContainer, diveListView, globeGps );
	registerApplicationState("PlanDive", plannerWidget, profileContainer, plannerSettings, plannerDetails );
	registerApplicationState("EditPlannedDive", plannerWidget, profileContainer, diveListView, globeGps );
	registerApplicationState("EditDiveSite",locationInformation, profileContainer, diveListView, globeGps );

	setApplicationState("Default");

	ui.multiFilter->hide();

	setWindowIcon(QIcon(":subsurface-icon"));
	if (!QIcon::hasThemeIcon("window-close")) {
		QIcon::setThemeName("subsurface");
	}
	connect(dive_list(), SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int)));
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings()));
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(update()));
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(reloadHeaderActions()));
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), information(), SLOT(updateDiveInfo()));
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerWidget(), SLOT(settingsChanged()));
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerSettingsWidget(), SLOT(settingsChanged()));
	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
	connect(ui.actionRecent1, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
	connect(ui.actionRecent2, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
	connect(ui.actionRecent3, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
	connect(ui.actionRecent4, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
	connect(information(), SIGNAL(addDiveFinished()), graphics(), SLOT(setProfileState()));
	connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated()));
	connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
	connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
	connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t)));
	connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState()));
	connect(locationInformation, SIGNAL(informationManagementEnded()), information(), SLOT(showLocation()));
	connect(locationInformation, SIGNAL(coordinatesChanged()), globe(), SLOT(repopulateLabels()));

#ifdef NO_PRINTING
	plannerDetails->printPlan()->hide();
	ui.menuFile->removeAction(ui.actionPrint);
#endif
#ifndef USE_LIBGIT23_API
	ui.menuFile->removeAction(ui.actionCloudstorageopen);
	ui.menuFile->removeAction(ui.actionCloudstoragesave);
	qDebug() << "disabled / made invisible the cloud storage stuff";
#endif

	ui.mainErrorMessage->hide();
	graphics()->setEmptyState();
	initialUiSetup();
	readSettings();
	diveListView->reload(DiveTripModel::TREE);
	diveListView->reloadHeaderActions();
	diveListView->setFocus();
	globe()->reload();
	diveListView->expand(dive_list()->model()->index(0, 0));
	diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
	divePlannerWidget()->settingsChanged();
	divePlannerSettingsWidget()->settingsChanged();
#ifdef NO_MARBLE
	ui.menuView->removeAction(ui.actionViewGlobe);
#else
	connect(globe(), SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates()));
#endif
#ifdef NO_USERMANUAL
	ui.menuHelp->removeAction(ui.actionUserManual);
#endif
	memset(&copyPasteDive, 0, sizeof(copyPasteDive));
	memset(&what, 0, sizeof(what));

	updateManager = new UpdateManager(this);
	undoStack = new QUndoStack(this);
	QAction *undoAction = undoStack->createUndoAction(this, tr("&Undo"));
	QAction *redoAction = undoStack->createRedoAction(this, tr("&Redo"));
	undoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
	redoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z));
	QList<QAction*>undoRedoActions;
	undoRedoActions.append(undoAction);
	undoRedoActions.append(redoAction);
	ui.menu_Edit->addActions(undoRedoActions);

	ReverseGeoLookupThread *geoLookup = ReverseGeoLookupThread::instance();
	connect(geoLookup, SIGNAL(started()),information(), SLOT(disableGeoLookupEdition()));
	connect(geoLookup, SIGNAL(finished()), information(), SLOT(enableGeoLookupEdition()));
}