mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Whitespace and coding style updates
Another futile attempt to cleanup the code and make coding style and whitespace consistent. I tried to add a file that describes the key points of our coding style. I have no illusions that this will help the least bit... This commit should ONLY change whitespace Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									3387ccc6f6
								
							
						
					
					
						commit
						a27f67c026
					
				
					 28 changed files with 387 additions and 323 deletions
				
			
		
							
								
								
									
										63
									
								
								CodingStyle
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								CodingStyle
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,63 @@
 | 
			
		|||
- all indentation is tabs (set to 8 char) with the exception of
 | 
			
		||||
  continuation lines that are alligned with tabs and then spaces
 | 
			
		||||
 | 
			
		||||
- all keywords followed by a '(' have a space in between
 | 
			
		||||
 | 
			
		||||
	if (condition)
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < 5; i++)
 | 
			
		||||
 | 
			
		||||
- function calls do NOT have a space between their name and argument
 | 
			
		||||
 | 
			
		||||
	i = some_function(argument);
 | 
			
		||||
 | 
			
		||||
- usually there is no space on the inside of parenthesis (see examples
 | 
			
		||||
  above)
 | 
			
		||||
 | 
			
		||||
- function / method implementations have their opening curly braces in
 | 
			
		||||
  column 1
 | 
			
		||||
 | 
			
		||||
- all other opening curly braces follow at the end of the line, with a
 | 
			
		||||
  space separating them:
 | 
			
		||||
 | 
			
		||||
	if (condition) {
 | 
			
		||||
		dosomething();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
- both sides of an if / else clause either use or do not use curly braces:
 | 
			
		||||
 | 
			
		||||
	if (condition)
 | 
			
		||||
		i = 4;
 | 
			
		||||
	else
 | 
			
		||||
		j = 6;
 | 
			
		||||
 | 
			
		||||
	if (condition) {
 | 
			
		||||
		i = 6;
 | 
			
		||||
	} else {
 | 
			
		||||
		i = 4;
 | 
			
		||||
		j = 6;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
- use space to make visual separation easier
 | 
			
		||||
 | 
			
		||||
	a = b + 3 + e / 4;
 | 
			
		||||
 | 
			
		||||
- continuation lines have the operator / comma at the end
 | 
			
		||||
 | 
			
		||||
	if (very_long_conditiont_1 ||
 | 
			
		||||
	    condition_2)
 | 
			
		||||
 | 
			
		||||
	b = a + (c + d +
 | 
			
		||||
		 f + z);
 | 
			
		||||
 | 
			
		||||
- unfortunate inconsistency:
 | 
			
		||||
  -- C code usually uses underscores to structure names
 | 
			
		||||
 | 
			
		||||
	variable_in_C
 | 
			
		||||
 | 
			
		||||
  -- C++ code usually uses camelCase
 | 
			
		||||
 | 
			
		||||
	variableInCPlusPlus
 | 
			
		||||
 | 
			
		||||
  where the two meet, use your best judgment and go for best consistency
 | 
			
		||||
  (i.e., where does the variable "originate")
 | 
			
		||||
							
								
								
									
										2
									
								
								device.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								device.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -132,7 +132,7 @@ struct divecomputer* fake_dc(struct divecomputer* dc)
 | 
			
		|||
		/* we try for a sane slope, but bow to the insanity of
 | 
			
		||||
		 * the user supplied data */
 | 
			
		||||
		fill_samples_no_avg(fake, max_d, max_t, MAX(2.0 * max_d / max_t, 5000.0 / 60));
 | 
			
		||||
		if(fake[3].time.seconds == 0) { // just a 4 point profile
 | 
			
		||||
		if (fake[3].time.seconds == 0) { // just a 4 point profile
 | 
			
		||||
			fakedc.samples = 4;
 | 
			
		||||
			fake[3].time.seconds = max_t;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1628,10 +1628,10 @@ void parse_xml_buffer(const char *url, const char *buffer, int size,
 | 
			
		|||
extern int dm4_events(void *handle, int columns, char **data, char **column)
 | 
			
		||||
{
 | 
			
		||||
	event_start();
 | 
			
		||||
	if(data[1])
 | 
			
		||||
	if (data[1])
 | 
			
		||||
		cur_event.time.seconds = atoi(data[1]);
 | 
			
		||||
 | 
			
		||||
	if(data[2]) {
 | 
			
		||||
	if (data[2]) {
 | 
			
		||||
		switch (atoi(data[2])) {
 | 
			
		||||
			case 1:
 | 
			
		||||
				/* 1 Mandatory Safety Stop */
 | 
			
		||||
| 
						 | 
				
			
			@ -1728,7 +1728,7 @@ extern int dm4_events(void *handle, int columns, char **data, char **column)
 | 
			
		|||
 | 
			
		||||
extern int dm4_tags(void *handle, int columns, char **data, char **column)
 | 
			
		||||
{
 | 
			
		||||
	if(data[0])
 | 
			
		||||
	if (data[0])
 | 
			
		||||
		taglist_add_tag(cur_dive->tag_list, data[0]);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -1874,7 +1874,7 @@ int parse_dm4_buffer(const char *url, const char *buffer, int size,
 | 
			
		|||
 | 
			
		||||
	retval = sqlite3_open(url, &handle);
 | 
			
		||||
 | 
			
		||||
	if(retval) {
 | 
			
		||||
	if (retval) {
 | 
			
		||||
		fprintf(stderr, translate("gettextFromC","Database connection failed '%s'.\n"), url);
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1097,7 +1097,7 @@ static void calculate_ndl_tts(double tissue_tolerance, struct plot_data *entry,
 | 
			
		|||
	/* If we don't have a ceiling yet, calculate ndl. Don't try to calculate
 | 
			
		||||
	 * a ndl for lower values than 3m it would take forever */
 | 
			
		||||
	if (next_stop == 0) {
 | 
			
		||||
		if(entry->depth < 3000) {
 | 
			
		||||
		if (entry->depth < 3000) {
 | 
			
		||||
			entry->ndl = max_ndl;
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1440,10 +1440,10 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
 | 
			
		|||
		depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit);
 | 
			
		||||
		memcpy(buf2, buf, bufsize);
 | 
			
		||||
		snprintf(buf, bufsize, translate("gettextFromC","%s\nCalculated ceiling %.0f %s"), buf2, depthvalue, depth_unit);
 | 
			
		||||
		if (prefs.calc_all_tissues){
 | 
			
		||||
		if (prefs.calc_all_tissues) {
 | 
			
		||||
			int k;
 | 
			
		||||
			for (k=0; k<16; k++){
 | 
			
		||||
				if (entry->ceilings[k]){
 | 
			
		||||
			for (k=0; k<16; k++) {
 | 
			
		||||
				if (entry->ceilings[k]) {
 | 
			
		||||
					depthvalue = get_depth_units(entry->ceilings[k], NULL, &depth_unit);
 | 
			
		||||
					memcpy(buf2, buf, bufsize);
 | 
			
		||||
					snprintf(buf, bufsize, translate("gettextFromC","%s\nTissue %.0fmin: %.0f %s"), buf2, buehlmann_N2_t_halflife[k], depthvalue, depth_unit);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,9 +23,9 @@ void Class::updateModel() \
 | 
			
		|||
	QStringList list; \
 | 
			
		||||
	struct dive* dive; \
 | 
			
		||||
	int i = 0; \
 | 
			
		||||
	for_each_dive(i, dive){ \
 | 
			
		||||
	for_each_dive(i, dive) { \
 | 
			
		||||
		QString buddy(dive->diveStructMember); \
 | 
			
		||||
		if (!list.contains(buddy)){ \
 | 
			
		||||
		if (!list.contains(buddy)) { \
 | 
			
		||||
			list.append(buddy); \
 | 
			
		||||
		} \
 | 
			
		||||
	} \
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ void BuddyCompletionModel::updateModel()
 | 
			
		|||
	QSet<QString> set;
 | 
			
		||||
	struct dive* dive;
 | 
			
		||||
	int i = 0;
 | 
			
		||||
	for_each_dive(i, dive){
 | 
			
		||||
	for_each_dive(i, dive) {
 | 
			
		||||
		QString buddy(dive->buddy);
 | 
			
		||||
		foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) {
 | 
			
		||||
			set.insert(value.trimmed());
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ CREATE_UPDATE_METHOD(SuitCompletionModel, suit);
 | 
			
		|||
 | 
			
		||||
void TagCompletionModel::updateModel()
 | 
			
		||||
{
 | 
			
		||||
	if(g_tag_list == NULL)
 | 
			
		||||
	if (g_tag_list == NULL)
 | 
			
		||||
		return;
 | 
			
		||||
	QStringList list;
 | 
			
		||||
	struct tag_entry *current_tag_entry = g_tag_list->next;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ DiveListView::~DiveListView()
 | 
			
		|||
{
 | 
			
		||||
	QSettings settings;
 | 
			
		||||
	settings.beginGroup("ListWidget");
 | 
			
		||||
	for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++){
 | 
			
		||||
	for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) {
 | 
			
		||||
		if (isColumnHidden(i))
 | 
			
		||||
			continue;
 | 
			
		||||
		settings.setValue(QString("colwidth%1").arg(i), columnWidth(i));
 | 
			
		||||
| 
						 | 
				
			
			@ -65,17 +65,18 @@ DiveListView::~DiveListView()
 | 
			
		|||
	settings.endGroup();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DiveListView::setupUi(){
 | 
			
		||||
void DiveListView::setupUi()
 | 
			
		||||
{
 | 
			
		||||
	QSettings settings;
 | 
			
		||||
	static bool firstRun = true;
 | 
			
		||||
	if(firstRun)
 | 
			
		||||
	if (firstRun)
 | 
			
		||||
		backupExpandedRows();
 | 
			
		||||
	settings.beginGroup("ListWidget");
 | 
			
		||||
	/* if no width are set, use the calculated width for each column;
 | 
			
		||||
	 * for that to work we need to temporarily expand all rows */
 | 
			
		||||
	expandAll();
 | 
			
		||||
	for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) {
 | 
			
		||||
		if(isColumnHidden(i))
 | 
			
		||||
		if (isColumnHidden(i))
 | 
			
		||||
			continue;
 | 
			
		||||
		QVariant width = settings.value(QString("colwidth%1").arg(i));
 | 
			
		||||
		if (width.isValid())
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +85,7 @@ void DiveListView::setupUi(){
 | 
			
		|||
			setColumnWidth(i, 100);
 | 
			
		||||
	}
 | 
			
		||||
	settings.endGroup();
 | 
			
		||||
	if(firstRun)
 | 
			
		||||
	if (firstRun)
 | 
			
		||||
		restoreExpandedRows();
 | 
			
		||||
	else
 | 
			
		||||
		collapseAll();
 | 
			
		||||
| 
						 | 
				
			
			@ -96,21 +97,23 @@ int DiveListView::lastVisibleColumn()
 | 
			
		|||
{
 | 
			
		||||
	int lastColumn = -1;
 | 
			
		||||
	for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) {
 | 
			
		||||
		if(isColumnHidden(i))
 | 
			
		||||
		if (isColumnHidden(i))
 | 
			
		||||
			continue;
 | 
			
		||||
		lastColumn = i;
 | 
			
		||||
	}
 | 
			
		||||
	return lastColumn;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DiveListView::backupExpandedRows(){
 | 
			
		||||
void DiveListView::backupExpandedRows()
 | 
			
		||||
{
 | 
			
		||||
	expandedRows.clear();
 | 
			
		||||
	for(int i = 0; i < model()->rowCount(); i++)
 | 
			
		||||
		if(isExpanded( model()->index(i, 0) ))
 | 
			
		||||
		if (isExpanded( model()->index(i, 0) ))
 | 
			
		||||
			expandedRows.push_back(i);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DiveListView::restoreExpandedRows(){
 | 
			
		||||
void DiveListView::restoreExpandedRows()
 | 
			
		||||
{
 | 
			
		||||
	setAnimated(false);
 | 
			
		||||
	Q_FOREACH(const int &i, expandedRows)
 | 
			
		||||
		setExpanded( model()->index(i, 0), true );
 | 
			
		||||
| 
						 | 
				
			
			@ -141,18 +144,18 @@ void DiveListView::rememberSelection()
 | 
			
		|||
void DiveListView::restoreSelection()
 | 
			
		||||
{
 | 
			
		||||
	unselectDives();
 | 
			
		||||
	Q_FOREACH(dive_trip_t *trip, selectedDives.keys()){
 | 
			
		||||
	Q_FOREACH(dive_trip_t *trip, selectedDives.keys()) {
 | 
			
		||||
		QList<int> divesOnTrip = getDivesInTrip(trip);
 | 
			
		||||
		QList<int> selectedDivesOnTrip = selectedDives.values(trip);
 | 
			
		||||
 | 
			
		||||
		// Trip was not selected, let's select single-dives.
 | 
			
		||||
		if (trip == NULL || divesOnTrip.count() != selectedDivesOnTrip.count()){
 | 
			
		||||
			Q_FOREACH(int i, selectedDivesOnTrip){
 | 
			
		||||
		if (trip == NULL || divesOnTrip.count() != selectedDivesOnTrip.count()) {
 | 
			
		||||
			Q_FOREACH(int i, selectedDivesOnTrip) {
 | 
			
		||||
				selectDive(i);
 | 
			
		||||
			}
 | 
			
		||||
		}else{
 | 
			
		||||
		} else {
 | 
			
		||||
			selectTrip(trip);
 | 
			
		||||
			Q_FOREACH(int i, selectedDivesOnTrip){
 | 
			
		||||
			Q_FOREACH(int i, selectedDivesOnTrip) {
 | 
			
		||||
				selectDive(i);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -185,9 +188,9 @@ QList< dive_trip_t* > DiveListView::selectedTrips()
 | 
			
		|||
{
 | 
			
		||||
	QModelIndexList indexes = selectionModel()->selectedRows();
 | 
			
		||||
	QList<dive_trip_t*> ret;
 | 
			
		||||
	Q_FOREACH(const QModelIndex& index, indexes){
 | 
			
		||||
	Q_FOREACH(const QModelIndex& index, indexes) {
 | 
			
		||||
		dive_trip_t *trip = static_cast<dive_trip_t*>(index.data(DiveTripModel::TRIP_ROLE).value<void*>());
 | 
			
		||||
		if(!trip)
 | 
			
		||||
		if (!trip)
 | 
			
		||||
			continue;
 | 
			
		||||
		ret.push_back(trip);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -196,7 +199,7 @@ QList< dive_trip_t* > DiveListView::selectedTrips()
 | 
			
		|||
 | 
			
		||||
void DiveListView::selectDive(int i, bool scrollto, bool toggle)
 | 
			
		||||
{
 | 
			
		||||
	if( i == -1)
 | 
			
		||||
	if ( i == -1)
 | 
			
		||||
		return;
 | 
			
		||||
	QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
 | 
			
		||||
	QModelIndexList match = m->match(m->index(0,0), DiveTripModel::DIVE_IDX, i, 2, Qt::MatchRecursive);
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +208,7 @@ void DiveListView::selectDive(int i, bool scrollto, bool toggle)
 | 
			
		|||
	flags = toggle ? QItemSelectionModel::Toggle : QItemSelectionModel::Select;
 | 
			
		||||
	flags |= QItemSelectionModel::Rows;
 | 
			
		||||
	selectionModel()->setCurrentIndex(idx, flags);
 | 
			
		||||
	if(idx.parent().isValid()){
 | 
			
		||||
	if (idx.parent().isValid()) {
 | 
			
		||||
		setAnimated(false);
 | 
			
		||||
		expand(idx.parent());
 | 
			
		||||
		setAnimated(true);
 | 
			
		||||
| 
						 | 
				
			
			@ -216,7 +219,7 @@ void DiveListView::selectDive(int i, bool scrollto, bool toggle)
 | 
			
		|||
 | 
			
		||||
void DiveListView::selectDives(const QList< int >& newDiveSelection)
 | 
			
		||||
{
 | 
			
		||||
	if(!newDiveSelection.count())
 | 
			
		||||
	if (!newDiveSelection.count())
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	disconnect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
 | 
			
		||||
| 
						 | 
				
			
			@ -233,24 +236,24 @@ void DiveListView::selectDives(const QList< int >& newDiveSelection)
 | 
			
		|||
	QModelIndexList diveList;
 | 
			
		||||
 | 
			
		||||
	int firstSelectedDive = -1;
 | 
			
		||||
	/* context for temp. variables. */{
 | 
			
		||||
	/* context for temp. variables. */ {
 | 
			
		||||
		int i = 0;
 | 
			
		||||
		struct dive *dive;
 | 
			
		||||
		for_each_dive(i, dive){
 | 
			
		||||
		for_each_dive(i, dive) {
 | 
			
		||||
			dive->selected = newDiveSelection.contains(i) == true;
 | 
			
		||||
			if(firstSelectedDive == -1 && dive->selected ){
 | 
			
		||||
			if (firstSelectedDive == -1 && dive->selected ) {
 | 
			
		||||
				firstSelectedDive = i;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	select_dive(firstSelectedDive);
 | 
			
		||||
	Q_FOREACH(int i, newDiveSelection){
 | 
			
		||||
	Q_FOREACH(int i, newDiveSelection) {
 | 
			
		||||
		diveList.append(m->match(m->index(0,0), DiveTripModel::DIVE_IDX,
 | 
			
		||||
			i, 2, Qt::MatchRecursive).first());
 | 
			
		||||
	}
 | 
			
		||||
	Q_FOREACH(const QModelIndex& idx, diveList){
 | 
			
		||||
	Q_FOREACH(const QModelIndex& idx, diveList) {
 | 
			
		||||
		selectionModel()->select(idx, flags);
 | 
			
		||||
		if(idx.parent().isValid() && !isExpanded(idx.parent())){
 | 
			
		||||
		if (idx.parent().isValid() && !isExpanded(idx.parent())) {
 | 
			
		||||
			expand(idx.parent());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -273,7 +276,7 @@ void DiveListView::showSearchEdit()
 | 
			
		|||
 | 
			
		||||
bool DiveListView::eventFilter(QObject* , QEvent* event)
 | 
			
		||||
{
 | 
			
		||||
	if(event->type() != QEvent::KeyPress)
 | 
			
		||||
	if (event->type() != QEvent::KeyPress)
 | 
			
		||||
		return false;
 | 
			
		||||
	QKeyEvent *keyEv = static_cast<QKeyEvent*>(event);
 | 
			
		||||
	if (keyEv->key() != Qt::Key_Escape)
 | 
			
		||||
| 
						 | 
				
			
			@ -301,13 +304,13 @@ void DiveListView::headerClicked(int i)
 | 
			
		|||
		sortByColumn(i, currentOrder);
 | 
			
		||||
	} else {
 | 
			
		||||
		// clear the model, repopulate with new indexes.
 | 
			
		||||
		if(currentLayout == DiveTripModel::TREE){
 | 
			
		||||
		if (currentLayout == DiveTripModel::TREE) {
 | 
			
		||||
			backupExpandedRows();
 | 
			
		||||
		}
 | 
			
		||||
		reload(newLayout, false);
 | 
			
		||||
		currentOrder = Qt::DescendingOrder;
 | 
			
		||||
		sortByColumn(i, currentOrder);
 | 
			
		||||
		if (newLayout == DiveTripModel::TREE){
 | 
			
		||||
		if (newLayout == DiveTripModel::TREE) {
 | 
			
		||||
			restoreExpandedRows();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -329,7 +332,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
 | 
			
		|||
 | 
			
		||||
	QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
 | 
			
		||||
	QAbstractItemModel *oldModel = m->sourceModel();
 | 
			
		||||
	if (oldModel){
 | 
			
		||||
	if (oldModel) {
 | 
			
		||||
		oldModel->deleteLater();
 | 
			
		||||
	}
 | 
			
		||||
	DiveTripModel *tripModel = new DiveTripModel(this);
 | 
			
		||||
| 
						 | 
				
			
			@ -337,7 +340,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
 | 
			
		|||
 | 
			
		||||
	m->setSourceModel(tripModel);
 | 
			
		||||
 | 
			
		||||
	if(!forceSort)
 | 
			
		||||
	if (!forceSort)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	sortByColumn(sortColumn, currentOrder);
 | 
			
		||||
| 
						 | 
				
			
			@ -353,16 +356,16 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
	setupUi();
 | 
			
		||||
	if(selectedIndexes().count()){
 | 
			
		||||
	if (selectedIndexes().count()) {
 | 
			
		||||
		QModelIndex curr = selectedIndexes().first();
 | 
			
		||||
		curr = curr.parent().isValid() ? curr.parent() : curr;
 | 
			
		||||
		if(!isExpanded(curr)){
 | 
			
		||||
		if (!isExpanded(curr)) {
 | 
			
		||||
			setAnimated(false);
 | 
			
		||||
			expand(curr);
 | 
			
		||||
			setAnimated(true);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if(currentLayout == DiveTripModel::TREE){
 | 
			
		||||
	if (currentLayout == DiveTripModel::TREE) {
 | 
			
		||||
		fixMessyQtModelBehaviour();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -644,7 +647,7 @@ void DiveListView::markDiveInvalid()
 | 
			
		|||
	}
 | 
			
		||||
	mark_divelist_changed(true);
 | 
			
		||||
	mainWindow()->refreshDisplay();
 | 
			
		||||
	if(prefs.display_invalid_dives == false) {
 | 
			
		||||
	if (prefs.display_invalid_dives == false) {
 | 
			
		||||
		clearSelection();
 | 
			
		||||
		// select top dive that isn't marked invalid
 | 
			
		||||
		rememberSelection();
 | 
			
		||||
| 
						 | 
				
			
			@ -675,7 +678,7 @@ void DiveListView::deleteDive()
 | 
			
		|||
	}
 | 
			
		||||
	mark_divelist_changed(true);
 | 
			
		||||
	mainWindow()->refreshDisplay();
 | 
			
		||||
	if(lastDiveNr != -1){
 | 
			
		||||
	if (lastDiveNr != -1) {
 | 
			
		||||
		clearSelection();
 | 
			
		||||
		selectDive(lastDiveNr);
 | 
			
		||||
		rememberSelection();
 | 
			
		||||
| 
						 | 
				
			
			@ -754,7 +757,7 @@ void DiveListView::saveSelectedDivesAs()
 | 
			
		|||
 | 
			
		||||
	settings.beginGroup("FileDialog");
 | 
			
		||||
	if (settings.contains("LastDir")) {
 | 
			
		||||
		if(QDir::setCurrent(settings.value("LastDir").toString())) {
 | 
			
		||||
		if (QDir::setCurrent(settings.value("LastDir").toString())) {
 | 
			
		||||
			lastDir = settings.value("LastDir").toString();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -259,7 +259,7 @@ void DivePlannerGraphics::keyLeftAction()
 | 
			
		|||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if(nextStep)
 | 
			
		||||
			if (nextStep)
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			dp.time -= 60;
 | 
			
		||||
| 
						 | 
				
			
			@ -287,7 +287,7 @@ void DivePlannerGraphics::keyRightAction()
 | 
			
		|||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if(nextStep)
 | 
			
		||||
			if (nextStep)
 | 
			
		||||
				continue;
 | 
			
		||||
 | 
			
		||||
			dp.time += 60;
 | 
			
		||||
| 
						 | 
				
			
			@ -299,7 +299,7 @@ void DivePlannerGraphics::keyRightAction()
 | 
			
		|||
void DivePlannerGraphics::keyDeleteAction()
 | 
			
		||||
{
 | 
			
		||||
	int selCount = scene()->selectedItems().count();
 | 
			
		||||
	if(selCount) {
 | 
			
		||||
	if (selCount) {
 | 
			
		||||
		QVector<int> selectedIndexes;
 | 
			
		||||
		Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) {
 | 
			
		||||
			if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -599,7 +599,7 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
 | 
			
		|||
	depthString->setPos(fromPercent(1, Qt::Horizontal), ypos);
 | 
			
		||||
	timeString->setPos(xpos+1, fromPercent(95, Qt::Vertical));
 | 
			
		||||
 | 
			
		||||
	if(isPointOutOfBoundaries(mappedPos))
 | 
			
		||||
	if (isPointOutOfBoundaries(mappedPos))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	depthString->setText(get_depth_string(depthLine->valueAt(mappedPos), true, false));
 | 
			
		||||
| 
						 | 
				
			
			@ -665,8 +665,7 @@ bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point)
 | 
			
		|||
	if (xpos > timeLine->maximum() ||
 | 
			
		||||
	    xpos < timeLine->minimum() ||
 | 
			
		||||
	    ypos > depthLine->maximum() ||
 | 
			
		||||
	    ypos < depthLine->minimum())
 | 
			
		||||
	{
 | 
			
		||||
	    ypos < depthLine->minimum()) {
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -680,7 +679,7 @@ void DivePlannerGraphics::mousePressEvent(QMouseEvent* event)
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	QPointF mappedPos = mapToScene(event->pos());
 | 
			
		||||
	if (event->button() == Qt::LeftButton){
 | 
			
		||||
	if (event->button() == Qt::LeftButton) {
 | 
			
		||||
		Q_FOREACH(QGraphicsItem *item, scene()->items(mappedPos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, transform())) {
 | 
			
		||||
			if (DiveHandler *h = qgraphicsitem_cast<DiveHandler*>(item)) {
 | 
			
		||||
				activeDraggedHandler = h;
 | 
			
		||||
| 
						 | 
				
			
			@ -724,7 +723,7 @@ void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
 | 
			
		|||
	GasSelectionModel *model = GasSelectionModel::instance();
 | 
			
		||||
	model->repopulate();
 | 
			
		||||
	int rowCount = model->rowCount();
 | 
			
		||||
	for(int i = 0; i < rowCount; i++){
 | 
			
		||||
	for(int i = 0; i < rowCount; i++) {
 | 
			
		||||
		QAction *action = new QAction(&m);
 | 
			
		||||
		action->setText( model->data(model->index(i, 0),Qt::DisplayRole).toString());
 | 
			
		||||
		connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
 | 
			
		||||
| 
						 | 
				
			
			@ -922,7 +921,7 @@ Button::Button(QObject* parent, QGraphicsItem *itemParent): QObject(parent), QGr
 | 
			
		|||
void Button::setPixmap(const QPixmap& pixmap)
 | 
			
		||||
{
 | 
			
		||||
	icon->setPixmap(pixmap);
 | 
			
		||||
	if(pixmap.isNull())
 | 
			
		||||
	if (pixmap.isNull())
 | 
			
		||||
		icon->hide();
 | 
			
		||||
	else
 | 
			
		||||
		icon->show();
 | 
			
		||||
| 
						 | 
				
			
			@ -933,7 +932,7 @@ void Button::setPixmap(const QPixmap& pixmap)
 | 
			
		|||
void Button::setText(const QString& t)
 | 
			
		||||
{
 | 
			
		||||
	text->setText(t);
 | 
			
		||||
	if(icon->pixmap().isNull()) {
 | 
			
		||||
	if (icon->pixmap().isNull()) {
 | 
			
		||||
		icon->hide();
 | 
			
		||||
		text->setPos(0,0);
 | 
			
		||||
	} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -1043,16 +1042,16 @@ int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const
 | 
			
		|||
 | 
			
		||||
QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const
 | 
			
		||||
{
 | 
			
		||||
	if(role == Qt::DisplayRole) {
 | 
			
		||||
	if (role == Qt::DisplayRole) {
 | 
			
		||||
		divedatapoint p = divepoints.at(index.row());
 | 
			
		||||
		switch(index.column()) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
		case CCSETPOINT: return (double) p.po2 / 1000;
 | 
			
		||||
		case DEPTH: return rint(get_depth_units(p.depth, NULL, NULL));
 | 
			
		||||
		case DURATION: return p.time / 60;
 | 
			
		||||
		case GAS: return dpGasToStr(p);
 | 
			
		||||
		}
 | 
			
		||||
	} else if (role == Qt::DecorationRole) {
 | 
			
		||||
		switch(index.column()) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
			case REMOVE : return QIcon(":trash");
 | 
			
		||||
		}
 | 
			
		||||
	} else if (role == Qt::FontRole) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1065,9 +1064,9 @@ bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& v
 | 
			
		|||
{
 | 
			
		||||
	int o2 = 0;
 | 
			
		||||
	int he = 0;
 | 
			
		||||
	if(role == Qt::EditRole) {
 | 
			
		||||
	if (role == Qt::EditRole) {
 | 
			
		||||
		divedatapoint& p = divepoints[index.row()];
 | 
			
		||||
		switch(index.column()) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
		case DEPTH: p.depth = units_to_depth(value.toInt()); break;
 | 
			
		||||
		case DURATION: p.time = value.toInt() * 60; break;
 | 
			
		||||
		case CCSETPOINT: {
 | 
			
		||||
| 
						 | 
				
			
			@ -1093,7 +1092,7 @@ bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& v
 | 
			
		|||
QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const
 | 
			
		||||
{
 | 
			
		||||
	if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
 | 
			
		||||
		switch(section) {
 | 
			
		||||
		switch (section) {
 | 
			
		||||
			case DEPTH: return tr("Final Depth");
 | 
			
		||||
			case DURATION: return tr("Duration");
 | 
			
		||||
			case GAS: return tr("Used Gas");
 | 
			
		||||
| 
						 | 
				
			
			@ -1197,7 +1196,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he)
 | 
			
		|||
int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he, int ccpoint)
 | 
			
		||||
{
 | 
			
		||||
	int row = divepoints.count();
 | 
			
		||||
	if (seconds == 0 && milimeters == 0 && row != 0){
 | 
			
		||||
	if (seconds == 0 && milimeters == 0 && row != 0) {
 | 
			
		||||
		/* this is only possible if the user clicked on the 'plus' sign on the DivePoints Table */
 | 
			
		||||
		struct divedatapoint& t = divepoints.last();
 | 
			
		||||
		milimeters = t.depth;
 | 
			
		||||
| 
						 | 
				
			
			@ -1542,7 +1541,7 @@ ExpanderGraphics::ExpanderGraphics(QGraphicsItem* parent): QGraphicsRectItem(par
 | 
			
		|||
	//I need to bottom align the items, I need to make the 0,0 ( orgin ) to be
 | 
			
		||||
	// the bottom of this item, so shift everything up.
 | 
			
		||||
	QRectF r = childrenBoundingRect();
 | 
			
		||||
	Q_FOREACH(QGraphicsItem *i, childItems()){
 | 
			
		||||
	Q_FOREACH(QGraphicsItem *i, childItems()) {
 | 
			
		||||
		i->setPos(i->pos().x(), i->pos().y() - r.height());
 | 
			
		||||
	}
 | 
			
		||||
	setScale(0.7);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ struct mydescriptor {
 | 
			
		|||
	unsigned int model;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
namespace DownloadFromDcGlobal{
 | 
			
		||||
namespace DownloadFromDcGlobal {
 | 
			
		||||
	const char *err_string;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,7 +51,7 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0), edit
 | 
			
		|||
	setProjection(Marble::Spherical);
 | 
			
		||||
 | 
			
		||||
	setAnimationsEnabled(true);
 | 
			
		||||
	Q_FOREACH(AbstractFloatItem *i, floatItems()){
 | 
			
		||||
	Q_FOREACH(AbstractFloatItem *i, floatItems()) {
 | 
			
		||||
		i->setVisible(false);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -82,13 +82,13 @@ bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev)
 | 
			
		|||
	// This disables the Marble's Context Menu
 | 
			
		||||
	// we need to move this to our 'contextMenuEvent'
 | 
			
		||||
	// if we plan to do a different one in the future.
 | 
			
		||||
	if (ev->type() == QEvent::ContextMenu){
 | 
			
		||||
	if (ev->type() == QEvent::ContextMenu) {
 | 
			
		||||
		contextMenuEvent(static_cast<QContextMenuEvent*>(ev));
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	if (ev->type() == QEvent::MouseButtonPress){
 | 
			
		||||
	if (ev->type() == QEvent::MouseButtonPress) {
 | 
			
		||||
		QMouseEvent *e = static_cast<QMouseEvent*>(ev);
 | 
			
		||||
		if(e->button() == Qt::RightButton)
 | 
			
		||||
		 if (e->button() == Qt::RightButton)
 | 
			
		||||
			return true;
 | 
			
		||||
	}
 | 
			
		||||
	return QObject::eventFilter(obj,ev );
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
 | 
			
		|||
 | 
			
		||||
		selectedDiveIds.push_back(idx);
 | 
			
		||||
	}
 | 
			
		||||
	if(selectedDiveIds.empty())
 | 
			
		||||
	if (selectedDiveIds.empty())
 | 
			
		||||
		return;
 | 
			
		||||
	if (clear) {
 | 
			
		||||
		mainWindow()->dive_list()->unselectDives();
 | 
			
		||||
| 
						 | 
				
			
			@ -258,8 +258,8 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
 | 
			
		|||
	/* change everything on the selection. */
 | 
			
		||||
	int i;
 | 
			
		||||
	struct dive* dive;
 | 
			
		||||
	for_each_dive(i, dive){
 | 
			
		||||
		if(!dive->selected)
 | 
			
		||||
	for_each_dive(i, dive) {
 | 
			
		||||
		if (!dive->selected)
 | 
			
		||||
			continue;
 | 
			
		||||
		dive->latitude.udeg = lrint(lat * 1000000.0);
 | 
			
		||||
		dive->longitude.udeg = lrint(lon * 1000000.0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -132,7 +132,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
 | 
			
		|||
			"    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
 | 
			
		||||
			"    stop: 0 #E0E0E0, stop: 1 #FFFFFF);"
 | 
			
		||||
			"}");
 | 
			
		||||
		Q_FOREACH(QGroupBox *box, findChildren<QGroupBox*>()){
 | 
			
		||||
		Q_FOREACH(QGroupBox *box, findChildren<QGroupBox*>()) {
 | 
			
		||||
			box->setStyleSheet(gnomeCss);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +141,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
 | 
			
		|||
 | 
			
		||||
	QSettings s;
 | 
			
		||||
	s.beginGroup("cylinders_dialog");
 | 
			
		||||
	for(int i = 0; i < CylindersModel::COLUMNS; i++){
 | 
			
		||||
	for(int i = 0; i < CylindersModel::COLUMNS; i++) {
 | 
			
		||||
		if ((i == CylindersModel::REMOVE) || (i == CylindersModel::TYPE))
 | 
			
		||||
			  continue;
 | 
			
		||||
		bool checked = s.value(QString("column%1_hidden").arg(i)).toBool();
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ MainTab::~MainTab()
 | 
			
		|||
{
 | 
			
		||||
	QSettings s;
 | 
			
		||||
	s.beginGroup("cylinders_dialog");
 | 
			
		||||
	for(int i = 0; i < CylindersModel::COLUMNS; i++){
 | 
			
		||||
	for(int i = 0; i < CylindersModel::COLUMNS; i++) {
 | 
			
		||||
		if ((i == CylindersModel::REMOVE) || (i == CylindersModel::TYPE))
 | 
			
		||||
			  continue;
 | 
			
		||||
		s.setValue(QString("column%1_hidden").arg(i), ui.cylinders->view()->isColumnHidden(i));
 | 
			
		||||
| 
						 | 
				
			
			@ -172,9 +172,9 @@ void MainTab::toggleTriggeredColumn()
 | 
			
		|||
	int col = action->data().toInt();
 | 
			
		||||
	QTableView *view = ui.cylinders->view();
 | 
			
		||||
 | 
			
		||||
	if(action->isChecked()){
 | 
			
		||||
	if (action->isChecked()) {
 | 
			
		||||
		view->showColumn(col);
 | 
			
		||||
		if(view->columnWidth(col) <= 15)
 | 
			
		||||
		if (view->columnWidth(col) <= 15)
 | 
			
		||||
			view->setColumnWidth(col, 80);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
| 
						 | 
				
			
			@ -548,14 +548,14 @@ void MainTab::updateDiveInfo(int dive)
 | 
			
		|||
 | 
			
		||||
void MainTab::addCylinder_clicked()
 | 
			
		||||
{
 | 
			
		||||
	if(editMode == NONE)
 | 
			
		||||
	if (editMode == NONE)
 | 
			
		||||
		enableEdition();
 | 
			
		||||
	cylindersModel->add();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainTab::addWeight_clicked()
 | 
			
		||||
{
 | 
			
		||||
	if(editMode == NONE)
 | 
			
		||||
	if (editMode == NONE)
 | 
			
		||||
		enableEdition();
 | 
			
		||||
	weightModel->add();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -655,7 +655,7 @@ void MainTab::acceptChanges()
 | 
			
		|||
	}
 | 
			
		||||
	int scrolledBy = mainWindow()->dive_list()->verticalScrollBar()->sliderPosition();
 | 
			
		||||
	resetPallete();
 | 
			
		||||
	if(editMode == ADD || editMode == MANUALLY_ADDED_DIVE){
 | 
			
		||||
	if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE) {
 | 
			
		||||
		mainWindow()->dive_list()->unselectDives();
 | 
			
		||||
		struct dive *d = get_dive(dive_table.nr -1 );
 | 
			
		||||
		// mark the dive as remembered (abusing the selected flag)
 | 
			
		||||
| 
						 | 
				
			
			@ -663,7 +663,7 @@ void MainTab::acceptChanges()
 | 
			
		|||
		d->selected = true;
 | 
			
		||||
		sort_table(&dive_table);
 | 
			
		||||
		int i = 0;
 | 
			
		||||
		for_each_dive(i,d){
 | 
			
		||||
		for_each_dive(i,d) {
 | 
			
		||||
			if (d->selected) {
 | 
			
		||||
				d->selected = false;
 | 
			
		||||
				break;
 | 
			
		||||
| 
						 | 
				
			
			@ -715,7 +715,7 @@ void MainTab::rejectChanges()
 | 
			
		|||
	tabBar()->setTabIcon(1, QIcon()); // Equipment
 | 
			
		||||
 | 
			
		||||
	mainWindow()->dive_list()->setEnabled(true);
 | 
			
		||||
	if (mainWindow() && mainWindow()->dive_list()->selectedTrips().count() == 1){
 | 
			
		||||
	if (mainWindow() && mainWindow()->dive_list()->selectedTrips().count() == 1) {
 | 
			
		||||
		ui.notes->setText(notesBackup[NULL].notes );
 | 
			
		||||
		ui.location->setText(notesBackup[NULL].location);
 | 
			
		||||
	} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -823,7 +823,7 @@ void MainTab::rejectChanges()
 | 
			
		|||
	} \
 | 
			
		||||
} while(0)
 | 
			
		||||
 | 
			
		||||
void markChangedWidget(QWidget *w){
 | 
			
		||||
void markChangedWidget(QWidget *w) {
 | 
			
		||||
	QPalette p;
 | 
			
		||||
	qreal h, s, l, a;
 | 
			
		||||
	qApp->palette().color(QPalette::Text).getHslF(&h, &s, &l, &a);
 | 
			
		||||
| 
						 | 
				
			
			@ -890,12 +890,12 @@ 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 || editMode == ADD){
 | 
			
		||||
	} else if (editMode == DIVE || editMode == ADD) {
 | 
			
		||||
		if (!ui.coordinates->isModified() ||
 | 
			
		||||
		    ui.coordinates->text().trimmed().isEmpty()) {
 | 
			
		||||
			struct dive* dive;
 | 
			
		||||
			int i = 0;
 | 
			
		||||
			for_each_dive(i, dive){
 | 
			
		||||
			for_each_dive(i, dive) {
 | 
			
		||||
				QString location(dive->location);
 | 
			
		||||
				if (location == text &&
 | 
			
		||||
				    (dive->latitude.udeg || dive->longitude.udeg)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,7 +112,7 @@ void MainWindow::on_actionNew_triggered()
 | 
			
		|||
 | 
			
		||||
void MainWindow::on_actionOpen_triggered()
 | 
			
		||||
{
 | 
			
		||||
	if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
 | 
			
		||||
	if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
 | 
			
		||||
	    ui.InfoWidget->isEditing()) {
 | 
			
		||||
		QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before opening a new file."));
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +125,8 @@ void MainWindow::on_actionOpen_triggered()
 | 
			
		|||
	loadFiles( QStringList() << filename );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QTabWidget *MainWindow::tabWidget(){
 | 
			
		||||
QTabWidget *MainWindow::tabWidget()
 | 
			
		||||
{
 | 
			
		||||
	return ui.tabWidget;
 | 
			
		||||
}
 | 
			
		||||
void MainWindow::on_actionSave_triggered()
 | 
			
		||||
| 
						 | 
				
			
			@ -153,7 +154,7 @@ void MainWindow::cleanUpEmpty()
 | 
			
		|||
 | 
			
		||||
void MainWindow::on_actionClose_triggered()
 | 
			
		||||
{
 | 
			
		||||
	if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
 | 
			
		||||
	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;
 | 
			
		||||
| 
						 | 
				
			
			@ -223,7 +224,7 @@ void MainWindow::enableDcShortcuts()
 | 
			
		|||
 | 
			
		||||
void MainWindow::on_actionDivePlanner_triggered()
 | 
			
		||||
{
 | 
			
		||||
	if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
 | 
			
		||||
	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 plan a dive."));
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -250,7 +251,7 @@ void MainWindow::on_actionPreferences_triggered()
 | 
			
		|||
 | 
			
		||||
void MainWindow::on_actionQuit_triggered()
 | 
			
		||||
{
 | 
			
		||||
	if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
 | 
			
		||||
	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;
 | 
			
		||||
| 
						 | 
				
			
			@ -286,7 +287,7 @@ void MainWindow::on_actionEditDeviceNames_triggered()
 | 
			
		|||
 | 
			
		||||
void MainWindow::on_actionAddDive_triggered()
 | 
			
		||||
{
 | 
			
		||||
	if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
 | 
			
		||||
	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;
 | 
			
		||||
| 
						 | 
				
			
			@ -378,15 +379,15 @@ void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx)
 | 
			
		|||
void MainWindow::on_actionViewList_triggered()
 | 
			
		||||
{
 | 
			
		||||
	beginChangeState(LIST_MAXIMIZED);
 | 
			
		||||
	ui.listGlobeSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
 | 
			
		||||
	ui.mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED);
 | 
			
		||||
	ui.listGlobeSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
 | 
			
		||||
	ui.mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::on_actionViewProfile_triggered()
 | 
			
		||||
{
 | 
			
		||||
	beginChangeState(PROFILE_MAXIMIZED);
 | 
			
		||||
	ui.infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
 | 
			
		||||
	ui.mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
 | 
			
		||||
	ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
 | 
			
		||||
	redrawProfile();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -394,7 +395,7 @@ void MainWindow::on_actionViewInfo_triggered()
 | 
			
		|||
{
 | 
			
		||||
	beginChangeState(INFO_MAXIMIZED);
 | 
			
		||||
	ui.infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
 | 
			
		||||
	ui.mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
 | 
			
		||||
	ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::on_actionViewGlobe_triggered()
 | 
			
		||||
| 
						 | 
				
			
			@ -411,51 +412,51 @@ void MainWindow::on_actionViewAll_triggered()
 | 
			
		|||
	static QList<int> mainSizes;
 | 
			
		||||
	const int appH = qApp->desktop()->size().height();
 | 
			
		||||
	const int appW = qApp->desktop()->size().width();
 | 
			
		||||
	if (mainSizes.empty()){
 | 
			
		||||
		mainSizes.append( appH * 0.7 );
 | 
			
		||||
		mainSizes.append( appH * 0.3 );
 | 
			
		||||
	if (mainSizes.empty()) {
 | 
			
		||||
		mainSizes.append(appH * 0.7);
 | 
			
		||||
		mainSizes.append(appH * 0.3);
 | 
			
		||||
	}
 | 
			
		||||
	static QList<int> infoProfileSizes;
 | 
			
		||||
	if (infoProfileSizes.empty()){
 | 
			
		||||
		infoProfileSizes.append( appW * 0.3 );
 | 
			
		||||
		infoProfileSizes.append( appW * 0.7 );
 | 
			
		||||
	if (infoProfileSizes.empty()) {
 | 
			
		||||
		infoProfileSizes.append(appW * 0.3);
 | 
			
		||||
		infoProfileSizes.append(appW * 0.7);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static QList<int> listGlobeSizes;
 | 
			
		||||
	if(listGlobeSizes.empty()){
 | 
			
		||||
		listGlobeSizes.append( appW * 0.7 );
 | 
			
		||||
		listGlobeSizes.append( appW * 0.3 );
 | 
			
		||||
	if (listGlobeSizes.empty()) {
 | 
			
		||||
		listGlobeSizes.append(appW * 0.7);
 | 
			
		||||
		listGlobeSizes.append(appW * 0.3);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	QSettings settings;
 | 
			
		||||
	settings.beginGroup("MainWindow");
 | 
			
		||||
	if (settings.value("mainSplitter").isValid()){
 | 
			
		||||
	if (settings.value("mainSplitter").isValid()) {
 | 
			
		||||
		ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
 | 
			
		||||
		ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray());
 | 
			
		||||
		ui.listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray());
 | 
			
		||||
		if(ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0)
 | 
			
		||||
		if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0)
 | 
			
		||||
			ui.mainSplitter->setSizes(mainSizes);
 | 
			
		||||
		if(ui.infoProfileSplitter->sizes().first() == 0 || ui.infoProfileSplitter->sizes().last() == 0)
 | 
			
		||||
		if (ui.infoProfileSplitter->sizes().first() == 0 || ui.infoProfileSplitter->sizes().last() == 0)
 | 
			
		||||
			ui.infoProfileSplitter->setSizes(infoProfileSizes);
 | 
			
		||||
		if(ui.listGlobeSplitter->sizes().first() == 0 || ui.listGlobeSplitter->sizes().last() == 0)
 | 
			
		||||
		if (ui.listGlobeSplitter->sizes().first() == 0 || ui.listGlobeSplitter->sizes().last() == 0)
 | 
			
		||||
			ui.listGlobeSplitter->setSizes(listGlobeSizes);
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
		ui.mainSplitter->setSizes( mainSizes );
 | 
			
		||||
		ui.mainSplitter->setSizes(mainSizes);
 | 
			
		||||
		ui.infoProfileSplitter->setSizes(infoProfileSizes);
 | 
			
		||||
		ui.listGlobeSplitter->setSizes(listGlobeSizes);
 | 
			
		||||
	}
 | 
			
		||||
	redrawProfile();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::beginChangeState(CurrentState s){
 | 
			
		||||
	if (state == VIEWALL && state != s){
 | 
			
		||||
void MainWindow::beginChangeState(CurrentState s) {
 | 
			
		||||
	if (state == VIEWALL && state != s) {
 | 
			
		||||
		saveSplitterSizes();
 | 
			
		||||
	}
 | 
			
		||||
	state = s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::saveSplitterSizes(){
 | 
			
		||||
void MainWindow::saveSplitterSizes() {
 | 
			
		||||
	QSettings settings;
 | 
			
		||||
	settings.beginGroup("MainWindow");
 | 
			
		||||
	settings.setValue("mainSplitter", ui.mainSplitter->saveState());
 | 
			
		||||
| 
						 | 
				
			
			@ -481,8 +482,7 @@ void MainWindow::on_actionFullScreen_triggered(bool checked)
 | 
			
		|||
{
 | 
			
		||||
	if (checked) {
 | 
			
		||||
		setWindowState(windowState() | Qt::WindowFullScreen);
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	} else {
 | 
			
		||||
		setWindowState(windowState() & ~Qt::WindowFullScreen);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -504,7 +504,7 @@ void MainWindow::on_actionAboutSubsurface_triggered()
 | 
			
		|||
 | 
			
		||||
void MainWindow::on_actionUserManual_triggered()
 | 
			
		||||
{
 | 
			
		||||
	if(!helpView){
 | 
			
		||||
	if (!helpView) {
 | 
			
		||||
		helpView = new UserManual();
 | 
			
		||||
	}
 | 
			
		||||
	helpView->show();
 | 
			
		||||
| 
						 | 
				
			
			@ -613,7 +613,7 @@ void MainWindow::initialUiSetup()
 | 
			
		|||
		resize(sz);
 | 
			
		||||
 | 
			
		||||
	state = (CurrentState) settings.value("lastState", 0).toInt();
 | 
			
		||||
	switch(state){
 | 
			
		||||
	switch (state) {
 | 
			
		||||
		case VIEWALL: on_actionViewAll_triggered(); break;
 | 
			
		||||
		case GLOBE_MAXIMIZED : on_actionViewGlobe_triggered(); break;
 | 
			
		||||
		case INFO_MAXIMIZED : on_actionViewInfo_triggered(); break;
 | 
			
		||||
| 
						 | 
				
			
			@ -693,22 +693,21 @@ void MainWindow::writeSettings()
 | 
			
		|||
	settings.setValue("maximized", isMaximized());
 | 
			
		||||
	if (!isMaximized())
 | 
			
		||||
		settings.setValue("size", size());
 | 
			
		||||
	if (state == VIEWALL){
 | 
			
		||||
	if (state == VIEWALL)
 | 
			
		||||
		saveSplitterSizes();
 | 
			
		||||
	}
 | 
			
		||||
	settings.endGroup();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::closeEvent(QCloseEvent *event)
 | 
			
		||||
{
 | 
			
		||||
	if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
 | 
			
		||||
	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."));
 | 
			
		||||
		event->ignore();
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (helpView && helpView->isVisible()){
 | 
			
		||||
	if (helpView && helpView->isVisible()) {
 | 
			
		||||
		helpView->close();
 | 
			
		||||
		helpView->deleteLater();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -754,7 +753,7 @@ void MainWindow::file_save_as(void)
 | 
			
		|||
						tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
 | 
			
		||||
	if (!filename.isNull() && !filename.isEmpty()) {
 | 
			
		||||
 | 
			
		||||
		if(ui.InfoWidget->isEditing())
 | 
			
		||||
		if (ui.InfoWidget->isEditing())
 | 
			
		||||
			ui.InfoWidget->acceptChanges();
 | 
			
		||||
 | 
			
		||||
		save_dives(filename.toUtf8().data());
 | 
			
		||||
| 
						 | 
				
			
			@ -771,7 +770,7 @@ void MainWindow::file_save(void)
 | 
			
		|||
	if (!existing_filename)
 | 
			
		||||
		return file_save_as();
 | 
			
		||||
 | 
			
		||||
	if(ui.InfoWidget->isEditing())
 | 
			
		||||
	if (ui.InfoWidget->isEditing())
 | 
			
		||||
		ui.InfoWidget->acceptChanges();
 | 
			
		||||
 | 
			
		||||
	current_default = prefs.default_filename;
 | 
			
		||||
| 
						 | 
				
			
			@ -885,7 +884,7 @@ void MainWindow::on_actionImportDiveLog_triggered()
 | 
			
		|||
 | 
			
		||||
void MainWindow::editCurrentDive()
 | 
			
		||||
{
 | 
			
		||||
	if(information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING){
 | 
			
		||||
	if (information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
 | 
			
		||||
		QMessageBox::warning(this, tr("Warning"), tr("First finish the current edition before trying to do another."));
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -893,15 +892,14 @@ void MainWindow::editCurrentDive()
 | 
			
		|||
	struct dive *d = current_dive;
 | 
			
		||||
	QString defaultDC(d->dc.model);
 | 
			
		||||
	DivePlannerPointsModel::instance()->clear();
 | 
			
		||||
	if (defaultDC == "manually added dive"){
 | 
			
		||||
	if (defaultDC == "manually added dive") {
 | 
			
		||||
		disableDcShortcuts();
 | 
			
		||||
		DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
 | 
			
		||||
		ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
 | 
			
		||||
		ui.infoPane->setCurrentIndex(MAINTAB);
 | 
			
		||||
		DivePlannerPointsModel::instance()->loadFromDive(d);
 | 
			
		||||
		ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
 | 
			
		||||
	}
 | 
			
		||||
	else if (defaultDC == "planned dive"){
 | 
			
		||||
	} else if (defaultDC == "planned dive") {
 | 
			
		||||
		disableDcShortcuts();
 | 
			
		||||
		DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
 | 
			
		||||
		ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,13 +26,14 @@ QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem& option, const QMode
 | 
			
		|||
 | 
			
		||||
// Gets the index of the model in the currentRow and column.
 | 
			
		||||
// currCombo is defined below.
 | 
			
		||||
#define IDX( XX ) mymodel->index(currCombo.currRow, XX)
 | 
			
		||||
#define IDX(_XX) mymodel->index(currCombo.currRow, (_XX))
 | 
			
		||||
static bool keyboardFinished = false;
 | 
			
		||||
 | 
			
		||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
 | 
			
		||||
	QStyledItemDelegate(parent),
 | 
			
		||||
	parentWidget(parent)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
 | 
			
		||||
| 
						 | 
				
			
			@ -46,12 +47,12 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
 | 
			
		|||
		return;
 | 
			
		||||
 | 
			
		||||
	int rating = value.toInt();
 | 
			
		||||
	int deltaY = option.rect.height()/2 - StarWidget::starActive().height() /2 ;
 | 
			
		||||
	int deltaY = option.rect.height() / 2 - StarWidget::starActive().height() / 2 ;
 | 
			
		||||
	painter->save();
 | 
			
		||||
	painter->setRenderHint(QPainter::Antialiasing, true);
 | 
			
		||||
	for(int i = 0; i < rating; i++)
 | 
			
		||||
	for (int i = 0; i < rating; i++)
 | 
			
		||||
		painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, StarWidget::starActive());
 | 
			
		||||
	for(int i = rating; i < TOTALSTARS; i++)
 | 
			
		||||
	for (int i = rating; i < TOTALSTARS; i++)
 | 
			
		||||
		painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, StarWidget::starInactive());
 | 
			
		||||
	painter->restore();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +79,7 @@ void ComboBoxDelegate::setEditorData(QWidget* editor, const QModelIndex& index)
 | 
			
		|||
		c->setEditText(data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct CurrSelected{
 | 
			
		||||
struct CurrSelected {
 | 
			
		||||
	QComboBox *comboEditor;
 | 
			
		||||
	int currRow;
 | 
			
		||||
	QString activeText;
 | 
			
		||||
| 
						 | 
				
			
			@ -129,7 +130,7 @@ void ComboBoxDelegate::testActivation(const QString& currText)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// HACK, send a fake event so Qt thinks we hit 'enter' on the line edit.
 | 
			
		||||
void ComboBoxDelegate::fakeActivation(){
 | 
			
		||||
void ComboBoxDelegate::fakeActivation() {
 | 
			
		||||
	/* this test is needed because as soon as I show the selector,
 | 
			
		||||
	 * the first item gots selected, this sending an activated signal,
 | 
			
		||||
	 * calling this fakeActivation code and setting as the current,
 | 
			
		||||
| 
						 | 
				
			
			@ -137,7 +138,7 @@ void ComboBoxDelegate::fakeActivation(){
 | 
			
		|||
	 * to false and be happy, because the next activation  ( by click
 | 
			
		||||
	 * or keypress) is real.
 | 
			
		||||
	 */
 | 
			
		||||
	if(currCombo.ignoreSelection){
 | 
			
		||||
	if (currCombo.ignoreSelection) {
 | 
			
		||||
		currCombo.ignoreSelection = false;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -150,7 +151,7 @@ void ComboBoxDelegate::fakeActivation(){
 | 
			
		|||
// we are on a QComboBox ( but not on a QLineEdit.
 | 
			
		||||
void ComboBoxDelegate::fixTabBehavior()
 | 
			
		||||
{
 | 
			
		||||
	if(keyboardFinished){
 | 
			
		||||
	if (keyboardFinished) {
 | 
			
		||||
		setModelData(0,0,QModelIndex());
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -158,23 +159,22 @@ void ComboBoxDelegate::fixTabBehavior()
 | 
			
		|||
bool ComboBoxDelegate::eventFilter(QObject* object, QEvent* event)
 | 
			
		||||
{
 | 
			
		||||
	// Reacts on Key_UP and Key_DOWN to show the QComboBox - list of choices.
 | 
			
		||||
	if (event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride){
 | 
			
		||||
		if (object == currCombo.comboEditor){ // the 'LineEdit' part
 | 
			
		||||
	if (event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride) {
 | 
			
		||||
		if (object == currCombo.comboEditor) { // the 'LineEdit' part
 | 
			
		||||
			QKeyEvent *ev = static_cast<QKeyEvent*>(event);
 | 
			
		||||
			if(ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down){
 | 
			
		||||
			if (ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) {
 | 
			
		||||
				currCombo.ignoreSelection = true;
 | 
			
		||||
				currCombo.comboEditor->showPopup();
 | 
			
		||||
			}
 | 
			
		||||
			if(ev->key() == Qt::Key_Tab || ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return){
 | 
			
		||||
			if (ev->key() == Qt::Key_Tab || ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) {
 | 
			
		||||
				currCombo.activeText  = currCombo.comboEditor->currentText();
 | 
			
		||||
				keyboardFinished = true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else{	// the 'Drop Down Menu' part.
 | 
			
		||||
		} else {	// the 'Drop Down Menu' part.
 | 
			
		||||
			QKeyEvent *ev = static_cast<QKeyEvent*>(event);
 | 
			
		||||
			if(    ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return
 | 
			
		||||
				|| ev->key() == Qt::Key_Tab   || ev->key() == Qt::Key_Backtab
 | 
			
		||||
				|| ev->key() == Qt::Key_Escape){
 | 
			
		||||
			if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return ||
 | 
			
		||||
			    ev->key() == Qt::Key_Tab   || ev->key() == Qt::Key_Backtab ||
 | 
			
		||||
			    ev->key() == Qt::Key_Escape) {
 | 
			
		||||
				// treat Qt as a silly little boy - pretending that the key_return nwas pressed on the combo,
 | 
			
		||||
				// instead of the list of choices. this can be extended later for
 | 
			
		||||
				// other imputs, like tab navigation and esc.
 | 
			
		||||
| 
						 | 
				
			
			@ -196,7 +196,7 @@ void ComboBoxDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionV
 | 
			
		|||
	editor->setGeometry(defaultRect);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct RevertCylinderData{
 | 
			
		||||
struct RevertCylinderData {
 | 
			
		||||
	QString type;
 | 
			
		||||
	int pressure;
 | 
			
		||||
	int size;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ void CleanerTableModel::setHeaderDataStrings(const QStringList& newHeaders)
 | 
			
		|||
 | 
			
		||||
CylindersModel::CylindersModel(QObject* parent): current(0), rows(0)
 | 
			
		||||
{
 | 
			
		||||
	//	enum{REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
 | 
			
		||||
	//	enum {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH};
 | 
			
		||||
	setHeaderDataStrings( QStringList() <<  "" << tr("Type") << tr("Size") << tr("WorkPress") << tr("StartPress") << tr("EndPress") <<  trUtf8("O" UTF8_SUBSCRIPT_2 "%") << tr("He%") << tr("Switch at"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -106,7 +106,7 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
	break;
 | 
			
		||||
	case Qt::DisplayRole:
 | 
			
		||||
	case Qt::EditRole:
 | 
			
		||||
		switch(index.column()) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
		case TYPE:
 | 
			
		||||
			ret = QString(cyl->type.description);
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			@ -166,7 +166,7 @@ cylinder_t* CylindersModel::cylinderAt(const QModelIndex& index)
 | 
			
		|||
void CylindersModel::passInData(const QModelIndex& index, const QVariant& value)
 | 
			
		||||
{
 | 
			
		||||
	cylinder_t *cyl = cylinderAt(index);
 | 
			
		||||
	switch(index.column()) {
 | 
			
		||||
	switch (index.column()) {
 | 
			
		||||
	case SIZE:
 | 
			
		||||
		if (cyl->type.size.mliter != value.toInt()) {
 | 
			
		||||
			cyl->type.size.mliter = value.toInt();
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +194,7 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in
 | 
			
		|||
		DivePlannerPointsModel::instance()->rememberTanks();
 | 
			
		||||
 | 
			
		||||
	cylinder_t *cyl = cylinderAt(index);
 | 
			
		||||
	switch(index.column()) {
 | 
			
		||||
	switch (index.column()) {
 | 
			
		||||
	case TYPE:
 | 
			
		||||
		if (!value.isNull()) {
 | 
			
		||||
			QByteArray ba = value.toByteArray();
 | 
			
		||||
| 
						 | 
				
			
			@ -391,7 +391,7 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
	break;
 | 
			
		||||
	case Qt::DisplayRole:
 | 
			
		||||
	case Qt::EditRole:
 | 
			
		||||
		switch(index.column()) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
		case TYPE:
 | 
			
		||||
			ret = gettextFromC::instance()->tr(ws->description);
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			@ -542,7 +542,7 @@ bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int r
 | 
			
		|||
{
 | 
			
		||||
	QString vString = value.toString();
 | 
			
		||||
	weightsystem_t *ws = ¤t->weightsystem[index.row()];
 | 
			
		||||
	switch(index.column()) {
 | 
			
		||||
	switch (index.column()) {
 | 
			
		||||
	case TYPE:
 | 
			
		||||
		if (!value.isNull()) {
 | 
			
		||||
			if (!ws->description || gettextFromC::instance()->tr(ws->description) != vString) {
 | 
			
		||||
| 
						 | 
				
			
			@ -640,7 +640,7 @@ bool WSInfoModel::insertRows(int row, int count, const QModelIndex& parent)
 | 
			
		|||
bool WSInfoModel::setData(const QModelIndex& index, const QVariant& value, int role)
 | 
			
		||||
{
 | 
			
		||||
	struct ws_info_t *info = &ws_info[index.row()];
 | 
			
		||||
	switch(index.column()) {
 | 
			
		||||
	switch (index.column()) {
 | 
			
		||||
	case DESCRIPTION:
 | 
			
		||||
		info->name = strdup(value.toByteArray().data());
 | 
			
		||||
		break;
 | 
			
		||||
| 
						 | 
				
			
			@ -665,13 +665,13 @@ QVariant WSInfoModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
	struct ws_info_t *info = &ws_info[index.row()];
 | 
			
		||||
 | 
			
		||||
	int gr = info->grams;
 | 
			
		||||
	switch(role){
 | 
			
		||||
	switch (role) {
 | 
			
		||||
		case Qt::FontRole :
 | 
			
		||||
			ret = defaultModelFont();
 | 
			
		||||
			break;
 | 
			
		||||
		case Qt::DisplayRole :
 | 
			
		||||
		case Qt::EditRole :
 | 
			
		||||
			switch(index.column()) {
 | 
			
		||||
			switch (index.column()) {
 | 
			
		||||
				case GR:
 | 
			
		||||
					ret = gr;
 | 
			
		||||
					break;
 | 
			
		||||
| 
						 | 
				
			
			@ -698,9 +698,9 @@ WSInfoModel::WSInfoModel() : rows(-1)
 | 
			
		|||
{
 | 
			
		||||
	setHeaderDataStrings( QStringList() << tr("Description") << tr("kg"));
 | 
			
		||||
	struct ws_info_t *info = ws_info;
 | 
			
		||||
	for (info = ws_info; info->name; info++, rows++){
 | 
			
		||||
	for (info = ws_info; info->name; info++, rows++) {
 | 
			
		||||
		QString wsInfoName = gettextFromC::instance()->tr(info->name);
 | 
			
		||||
		if( wsInfoName.count() > biggerEntry.count())
 | 
			
		||||
		if ( wsInfoName.count() > biggerEntry.count())
 | 
			
		||||
			biggerEntry = wsInfoName;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -716,9 +716,9 @@ void WSInfoModel::updateInfo()
 | 
			
		|||
	beginRemoveRows(QModelIndex(), 0, this->rows);
 | 
			
		||||
	endRemoveRows();
 | 
			
		||||
	rows = -1;
 | 
			
		||||
	for (info = ws_info; info->name; info++, rows++){
 | 
			
		||||
	for (info = ws_info; info->name; info++, rows++) {
 | 
			
		||||
		QString wsInfoName = gettextFromC::instance()->tr(info->name);
 | 
			
		||||
		if( wsInfoName.count() > biggerEntry.count())
 | 
			
		||||
		if ( wsInfoName.count() > biggerEntry.count())
 | 
			
		||||
			biggerEntry = wsInfoName;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -766,7 +766,7 @@ bool TankInfoModel::insertRows(int row, int count, const QModelIndex& parent)
 | 
			
		|||
bool TankInfoModel::setData(const QModelIndex& index, const QVariant& value, int role)
 | 
			
		||||
{
 | 
			
		||||
	struct tank_info_t *info = &tank_info[index.row()];
 | 
			
		||||
	switch(index.column()) {
 | 
			
		||||
	switch (index.column()) {
 | 
			
		||||
	case DESCRIPTION:
 | 
			
		||||
		info->name = strdup(value.toByteArray().data());
 | 
			
		||||
		break;
 | 
			
		||||
| 
						 | 
				
			
			@ -791,7 +791,7 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
	if (!index.isValid()) {
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	if (role == Qt::FontRole){
 | 
			
		||||
	if (role == Qt::FontRole) {
 | 
			
		||||
		return defaultModelFont();
 | 
			
		||||
	}
 | 
			
		||||
	if (role == Qt::DisplayRole || role == Qt::EditRole) {
 | 
			
		||||
| 
						 | 
				
			
			@ -802,7 +802,7 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
		if (info->cuft && info->psi)
 | 
			
		||||
			ml = cuft_to_l(info->cuft) * 1000 / bar_to_atm(bar);
 | 
			
		||||
 | 
			
		||||
		switch(index.column()) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
			case BAR:
 | 
			
		||||
				ret = bar * 1000;
 | 
			
		||||
				break;
 | 
			
		||||
| 
						 | 
				
			
			@ -826,7 +826,7 @@ TankInfoModel::TankInfoModel() :  rows(-1)
 | 
			
		|||
{
 | 
			
		||||
	setHeaderDataStrings( QStringList() << tr("Description") << tr("ml") << tr("bar"));
 | 
			
		||||
	struct tank_info_t *info = tank_info;
 | 
			
		||||
	for (info = tank_info; info->name; info++, rows++){
 | 
			
		||||
	for (info = tank_info; info->name; info++, rows++) {
 | 
			
		||||
		QString infoName = gettextFromC::instance()->tr(info->name);
 | 
			
		||||
		if (infoName.count() > biggerEntry.count())
 | 
			
		||||
			biggerEntry = infoName;
 | 
			
		||||
| 
						 | 
				
			
			@ -1074,7 +1074,7 @@ QVariant DiveItem::data(int column, int role) const
 | 
			
		|||
	if (role == DiveTripModel::DIVE_ROLE) {
 | 
			
		||||
		retVal = QVariant::fromValue<void*>(dive);
 | 
			
		||||
	}
 | 
			
		||||
	if(role == DiveTripModel::DIVE_IDX){
 | 
			
		||||
	if (role == DiveTripModel::DIVE_IDX) {
 | 
			
		||||
		Q_ASSERT(dive != NULL);
 | 
			
		||||
		retVal = get_divenr(dive);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1083,7 +1083,7 @@ QVariant DiveItem::data(int column, int role) const
 | 
			
		|||
 | 
			
		||||
Qt::ItemFlags DiveItem::flags(const QModelIndex& index) const
 | 
			
		||||
{
 | 
			
		||||
	if(index.column() == NR){
 | 
			
		||||
	if (index.column() == NR) {
 | 
			
		||||
		return TreeItem::flags(index) | Qt::ItemIsEditable;
 | 
			
		||||
	}
 | 
			
		||||
	return TreeItem::flags(index);
 | 
			
		||||
| 
						 | 
				
			
			@ -1102,7 +1102,7 @@ bool DiveItem::setData(const QModelIndex& index, const QVariant& value, int role
 | 
			
		|||
 | 
			
		||||
	int i;
 | 
			
		||||
	struct dive *d;
 | 
			
		||||
	for_each_dive(i, d){
 | 
			
		||||
	for_each_dive(i, d) {
 | 
			
		||||
		if (d->number == v)
 | 
			
		||||
			return false;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1215,7 +1215,7 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int
 | 
			
		|||
	if (orientation == Qt::Vertical)
 | 
			
		||||
		return ret;
 | 
			
		||||
 | 
			
		||||
	switch(role){
 | 
			
		||||
	switch (role) {
 | 
			
		||||
		case Qt::FontRole :
 | 
			
		||||
			ret = defaultModelFont(); break;
 | 
			
		||||
		case Qt::DisplayRole :
 | 
			
		||||
| 
						 | 
				
			
			@ -1244,7 +1244,7 @@ void DiveTripModel::setupModelData()
 | 
			
		|||
{
 | 
			
		||||
	int i = dive_table.nr;
 | 
			
		||||
 | 
			
		||||
	if (rowCount()){
 | 
			
		||||
	if (rowCount()) {
 | 
			
		||||
		beginRemoveRows(QModelIndex(), 0, rowCount()-1);
 | 
			
		||||
		endRemoveRows();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1281,7 +1281,7 @@ void DiveTripModel::setupModelData()
 | 
			
		|||
		tripItem->children.push_back(diveItem);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (rowCount()){
 | 
			
		||||
	if (rowCount()) {
 | 
			
		||||
		beginInsertRows(QModelIndex(), 0, rowCount() - 1);
 | 
			
		||||
		endInsertRows();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1302,7 +1302,7 @@ bool DiveTripModel::setData(const QModelIndex& index, const QVariant& value, int
 | 
			
		|||
{
 | 
			
		||||
	TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
 | 
			
		||||
	DiveItem *diveItem = dynamic_cast<DiveItem*>(item);
 | 
			
		||||
	if(!diveItem)
 | 
			
		||||
	if (!diveItem)
 | 
			
		||||
		return false;
 | 
			
		||||
	return diveItem->setData(index, value, role);}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1327,16 +1327,16 @@ QVariant DiveComputerModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
	DiveComputerNode node = values.at(index.row());
 | 
			
		||||
 | 
			
		||||
	QVariant ret;
 | 
			
		||||
	if (role == Qt::DisplayRole || role == Qt::EditRole){
 | 
			
		||||
		switch(index.column()){
 | 
			
		||||
	if (role == Qt::DisplayRole || role == Qt::EditRole) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
			case ID:	ret = QString("0x").append(QString::number(node.deviceId, 16)); break;
 | 
			
		||||
			case MODEL:	ret = node.model; break;
 | 
			
		||||
			case NICKNAME:	ret = node.nickName; break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (index.column() == REMOVE){
 | 
			
		||||
		switch(role){
 | 
			
		||||
	if (index.column() == REMOVE) {
 | 
			
		||||
		switch (role) {
 | 
			
		||||
			case Qt::DecorationRole : ret = QIcon(":trash"); break;
 | 
			
		||||
			case Qt::ToolTipRole : ret = tr("Clicking here will remove this divecomputer."); break;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1354,13 +1354,13 @@ void DiveComputerModel::update()
 | 
			
		|||
	QList<DiveComputerNode> values = dcWorkingMap.values();
 | 
			
		||||
	int count = values.count();
 | 
			
		||||
 | 
			
		||||
	if(numRows){
 | 
			
		||||
	if (numRows) {
 | 
			
		||||
		beginRemoveRows(QModelIndex(), 0, numRows-1);
 | 
			
		||||
		numRows = 0;
 | 
			
		||||
		endRemoveRows();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (count){
 | 
			
		||||
	if (count) {
 | 
			
		||||
		beginInsertRows(QModelIndex(), 0, count-1);
 | 
			
		||||
		numRows = count;
 | 
			
		||||
		endInsertRows();
 | 
			
		||||
| 
						 | 
				
			
			@ -1413,7 +1413,7 @@ void DiveComputerModel::keepWorkingList()
 | 
			
		|||
 * ################################################################
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
class YearStatisticsItem : public TreeItem{
 | 
			
		||||
class YearStatisticsItem : public TreeItem {
 | 
			
		||||
public:
 | 
			
		||||
	enum {YEAR, DIVES, TOTAL_TIME, AVERAGE_TIME, SHORTEST_TIME, LONGEST_TIME, AVG_DEPTH, MIN_DEPTH,
 | 
			
		||||
		MAX_DEPTH, AVG_SAC, MIN_SAC, MAX_SAC, AVG_TEMP, MIN_TEMP, MAX_TEMP, COLUMNS};
 | 
			
		||||
| 
						 | 
				
			
			@ -1440,7 +1440,7 @@ QVariant YearStatisticsItem::data(int column, int role) const
 | 
			
		|||
	} else if (role != Qt::DisplayRole) {
 | 
			
		||||
		return ret;
 | 
			
		||||
	}
 | 
			
		||||
	switch(column) {
 | 
			
		||||
	switch (column) {
 | 
			
		||||
	case YEAR:
 | 
			
		||||
		if (stats_interval.is_trip) {
 | 
			
		||||
			ret = stats_interval.location;
 | 
			
		||||
| 
						 | 
				
			
			@ -1491,7 +1491,7 @@ QVariant YearlyStatisticsModel::headerData(int section, Qt::Orientation orientat
 | 
			
		|||
		  val = defaultModelFont();
 | 
			
		||||
 | 
			
		||||
	if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
 | 
			
		||||
		switch(section) {
 | 
			
		||||
		switch (section) {
 | 
			
		||||
		case YEAR:		val = tr("Year \n > Month / Trip"); break;
 | 
			
		||||
		case DIVES:		val = tr("#"); break;
 | 
			
		||||
		case TOTAL_TIME:	val = tr("Duration \n Total"); break;
 | 
			
		||||
| 
						 | 
				
			
			@ -1824,7 +1824,7 @@ void GasSelectionModel::repopulate()
 | 
			
		|||
 | 
			
		||||
QVariant GasSelectionModel::data(const QModelIndex& index, int role) const
 | 
			
		||||
{
 | 
			
		||||
	if(role == Qt::FontRole){
 | 
			
		||||
	if (role == Qt::FontRole) {
 | 
			
		||||
		return defaultModelFont();
 | 
			
		||||
	}
 | 
			
		||||
	return QStringListModel::data(index, role);
 | 
			
		||||
| 
						 | 
				
			
			@ -1844,8 +1844,8 @@ LanguageModel::LanguageModel(QObject* parent): QAbstractListModel(parent)
 | 
			
		|||
	QSettings s;
 | 
			
		||||
	QDir d(getSubsurfaceDataPath("translations"));
 | 
			
		||||
	QStringList result = d.entryList();
 | 
			
		||||
	Q_FOREACH(const QString& s, result){
 | 
			
		||||
		if ( s.startsWith("subsurface_") && s.endsWith(".qm") ){
 | 
			
		||||
	Q_FOREACH(const QString& s, result) {
 | 
			
		||||
		if ( s.startsWith("subsurface_") && s.endsWith(".qm") ) {
 | 
			
		||||
			languages.push_back( (s == "subsurface_source.qm") ? "English" : s);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1855,14 +1855,14 @@ QVariant LanguageModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
{
 | 
			
		||||
	QLocale loc;
 | 
			
		||||
	QString currentString = languages.at(index.row());
 | 
			
		||||
	if(!index.isValid())
 | 
			
		||||
	if (!index.isValid())
 | 
			
		||||
		return QVariant();
 | 
			
		||||
	switch(role){
 | 
			
		||||
		case Qt::DisplayRole:{
 | 
			
		||||
	switch (role) {
 | 
			
		||||
		case Qt::DisplayRole: {
 | 
			
		||||
			QLocale l( currentString.remove("subsurface_"));
 | 
			
		||||
			return currentString == "English" ? currentString : QString("%1 (%2)").arg(l.languageToString(l.language())).arg(l.countryToString(l.country()));
 | 
			
		||||
		}break;
 | 
			
		||||
	case Qt::UserRole:{
 | 
			
		||||
	case Qt::UserRole: {
 | 
			
		||||
			QString currentString = languages.at(index.row());
 | 
			
		||||
			return currentString == "English" ? "en_US" : currentString.remove("subsurface_");
 | 
			
		||||
		}break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -206,7 +206,7 @@ void PreferencesDialog::syncSettings()
 | 
			
		|||
 | 
			
		||||
void PreferencesDialog::buttonClicked(QAbstractButton* button)
 | 
			
		||||
{
 | 
			
		||||
	switch(ui.buttonBox->standardButton(button)){
 | 
			
		||||
	switch (ui.buttonBox->standardButton(button)) {
 | 
			
		||||
	case QDialogButtonBox::Discard:
 | 
			
		||||
		restorePrefs();
 | 
			
		||||
		close();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
#include <QPropertyAnimation>
 | 
			
		||||
#include <QPointF>
 | 
			
		||||
 | 
			
		||||
namespace Animations{
 | 
			
		||||
namespace Animations {
 | 
			
		||||
 | 
			
		||||
void hide(QObject* obj)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,6 +27,7 @@ void DiveCartesianAxis::setTextColor(const QColor& color)
 | 
			
		|||
 | 
			
		||||
DiveCartesianAxis::DiveCartesianAxis() : orientation(Qt::Horizontal)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DiveCartesianAxis::~DiveCartesianAxis()
 | 
			
		||||
| 
						 | 
				
			
			@ -50,8 +51,8 @@ void DiveCartesianAxis::updateTicks()
 | 
			
		|||
	double currValue = min;
 | 
			
		||||
 | 
			
		||||
	// Remove the uneeded Ticks / Texts.
 | 
			
		||||
	if (ticks.size() > steps){
 | 
			
		||||
		while (ticks.size() > steps){
 | 
			
		||||
	if (ticks.size() > steps) {
 | 
			
		||||
		while (ticks.size() > steps) {
 | 
			
		||||
			DiveLineItem *removedLine = ticks.takeLast();
 | 
			
		||||
			removedLine->animatedHide();
 | 
			
		||||
			DiveTextItem *removedText = labels.takeLast();
 | 
			
		||||
| 
						 | 
				
			
			@ -65,21 +66,20 @@ void DiveCartesianAxis::updateTicks()
 | 
			
		|||
	qreal end = orientation == Qt::Horizontal ? m.x2() : m.y2();
 | 
			
		||||
	double stepSize =  orientation == Qt::Horizontal ? (m.x2() - m.x1()) : (m.y2() - m.y1());
 | 
			
		||||
	stepSize = stepSize / steps;
 | 
			
		||||
	for(int i = 0, count = ticks.size(); i < count; i++, currValue += interval){
 | 
			
		||||
	for (int i = 0, count = ticks.size(); i < count; i++, currValue += interval) {
 | 
			
		||||
		qreal childPos = begin + i * stepSize;
 | 
			
		||||
		labels[i]->setText(textForValue(currValue));
 | 
			
		||||
		if ( orientation == Qt::Horizontal ){
 | 
			
		||||
		if ( orientation == Qt::Horizontal ) {
 | 
			
		||||
			ticks[i]->animateMoveTo(childPos, m.y1() + tickSize);
 | 
			
		||||
			labels[i]->animateMoveTo(childPos, m.y1() + tickSize);
 | 
			
		||||
		}
 | 
			
		||||
		else{
 | 
			
		||||
		} else {
 | 
			
		||||
			ticks[i]->animateMoveTo(m.x1() - tickSize, childPos);
 | 
			
		||||
			labels[i]->animateMoveTo(m.x1() - tickSize, childPos);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Add's the rest of the needed Ticks / Text.
 | 
			
		||||
	for(int i = ticks.size(); i < steps; i++,  currValue += interval){
 | 
			
		||||
	for (int i = ticks.size(); i < steps; i++,  currValue += interval) {
 | 
			
		||||
		qreal childPos = begin + i * stepSize;
 | 
			
		||||
		DiveLineItem *item = new DiveLineItem(this);
 | 
			
		||||
		item->setPen(pen());
 | 
			
		||||
| 
						 | 
				
			
			@ -90,15 +90,14 @@ void DiveCartesianAxis::updateTicks()
 | 
			
		|||
		label->setBrush(QBrush(textColor));
 | 
			
		||||
 | 
			
		||||
		labels.push_back(label);
 | 
			
		||||
		if(orientation == Qt::Horizontal){
 | 
			
		||||
		if (orientation == Qt::Horizontal) {
 | 
			
		||||
			item->setLine(0, 0, 0, tickSize);
 | 
			
		||||
			item->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene
 | 
			
		||||
			item->animateMoveTo(childPos, m.y1() + tickSize); // anim it to scene.
 | 
			
		||||
			label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
 | 
			
		||||
			label->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene);
 | 
			
		||||
			label->animateMoveTo(childPos, m.y1() + tickSize);
 | 
			
		||||
		}
 | 
			
		||||
		else{
 | 
			
		||||
		} else {
 | 
			
		||||
			item->setLine(0, 0, tickSize, 0);
 | 
			
		||||
			item->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
 | 
			
		||||
			item->animateMoveTo(m.x1() - tickSize, childPos);
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +145,7 @@ qreal DiveCartesianAxis::posAtValue(qreal value)
 | 
			
		|||
				m.y2() - m.y1();
 | 
			
		||||
	double retValue = realSize * percent;
 | 
			
		||||
	retValue =  (orientation == Qt::Horizontal) ?
 | 
			
		||||
				retValue + m.x1() + p.x():
 | 
			
		||||
				retValue + m.x1() + p.x() :
 | 
			
		||||
				retValue + m.y1() + p.y();
 | 
			
		||||
	return retValue;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,4 +2,5 @@
 | 
			
		|||
 | 
			
		||||
DivePixmapItem::DivePixmapItem(QObject* parent): QObject(parent), QGraphicsPixmapItem()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -23,8 +23,8 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
		return QVariant();
 | 
			
		||||
 | 
			
		||||
	plot_data item = plotData[index.row()];
 | 
			
		||||
	if (role == Qt::DisplayRole){
 | 
			
		||||
		switch(index.column()){
 | 
			
		||||
	if (role == Qt::DisplayRole) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
			case DEPTH:		return item.depth;
 | 
			
		||||
			case TIME:		return item.sec;
 | 
			
		||||
			case PRESSURE:		return item.pressure[0];
 | 
			
		||||
| 
						 | 
				
			
			@ -33,8 +33,8 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
 | 
			
		|||
			case USERENTERED:	return false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (role == Qt::BackgroundRole){
 | 
			
		||||
		switch(index.column()){
 | 
			
		||||
	if (role == Qt::BackgroundRole) {
 | 
			
		||||
		switch (index.column()) {
 | 
			
		||||
			case COLOR:	return getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + item.velocity));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
 | 
			
		|||
	if (role != Qt::DisplayRole)
 | 
			
		||||
		return QVariant();
 | 
			
		||||
 | 
			
		||||
	switch(section){
 | 
			
		||||
	switch (section) {
 | 
			
		||||
		case DEPTH:		return tr("Depth");
 | 
			
		||||
		case TIME:		return tr("Time");
 | 
			
		||||
		case PRESSURE:		return tr("Pressure");
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +67,7 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
 | 
			
		|||
 | 
			
		||||
void DivePlotDataModel::clear()
 | 
			
		||||
{
 | 
			
		||||
	if(rowCount() != 0){
 | 
			
		||||
	if (rowCount() != 0) {
 | 
			
		||||
		beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
 | 
			
		||||
		endRemoveRows();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,7 @@
 | 
			
		|||
DiveProfileItem::DiveProfileItem(): QObject(), QGraphicsPolygonItem(),
 | 
			
		||||
	hAxis(NULL), hDataColumn(-1), dataModel(NULL), vAxis(NULL), vDataColumn(-1)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DiveProfileItem::setHorizontalAxis(DiveCartesianAxis* horizontal)
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +55,7 @@ void DiveProfileItem::modelDataChanged()
 | 
			
		|||
	// is an array of QPointF's, so we basically get the point from the model, convert
 | 
			
		||||
	// to our coordinates, store. no painting is done here.
 | 
			
		||||
	QPolygonF poly;
 | 
			
		||||
	for(int i = 0, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++){
 | 
			
		||||
	for (int i = 0, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++) {
 | 
			
		||||
		qreal horizontalValue = dataModel->index(i, hDataColumn).data().toReal();
 | 
			
		||||
		qreal verticalValue = dataModel->index(i, vDataColumn).data().toReal();
 | 
			
		||||
		QPointF point( hAxis->posAtValue(horizontalValue), vAxis->posAtValue(verticalValue));
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +71,7 @@ void DiveProfileItem::modelDataChanged()
 | 
			
		|||
	setBrush(QBrush(pat));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget){
 | 
			
		||||
void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
 | 
			
		||||
	Q_UNUSED(widget);
 | 
			
		||||
 | 
			
		||||
	// This paints the Polygon + Background. I'm setting the pen to QPen() so we don't get a black line here,
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +85,7 @@ void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
 | 
			
		|||
	pen.setCosmetic(true);
 | 
			
		||||
	pen.setWidth(2);
 | 
			
		||||
	// This paints the colors of the velocities.
 | 
			
		||||
	for(int i = 1, count = dataModel->rowCount(); i < count; i++){
 | 
			
		||||
	for (int i = 1, count = dataModel->rowCount(); i < count; i++) {
 | 
			
		||||
		QModelIndex colorIndex = dataModel->index(i, DivePlotDataModel::COLOR);
 | 
			
		||||
		pen.setBrush(QBrush(colorIndex.data(Qt::BackgroundRole).value<QColor>()));
 | 
			
		||||
		painter->setPen(pen);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,4 +2,5 @@
 | 
			
		|||
 | 
			
		||||
DiveRectItem::DiveRectItem(QObject* parent, QGraphicsItem* parentItem): QObject(parent), QGraphicsRectItem(parentItem )
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,9 +29,9 @@ void DiveTextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* opti
 | 
			
		|||
//
 | 
			
		||||
// // 	if (internalAlignFlags & Qt::AlignLeft )
 | 
			
		||||
// // 		painter->translate(); // This is the default, uneeded.
 | 
			
		||||
// 	if(internalAlignFlags & Qt::AlignHCenter)
 | 
			
		||||
// 	if (internalAlignFlags & Qt::AlignHCenter)
 | 
			
		||||
// 		painter->translate(-rect.width()/2, 0);
 | 
			
		||||
// 	else if(internalAlignFlags & Qt::AlignRight)
 | 
			
		||||
// 	else if (internalAlignFlags & Qt::AlignRight)
 | 
			
		||||
// 		painter->translate(-rect.width(), 0);
 | 
			
		||||
 | 
			
		||||
	QGraphicsSimpleTextItem::paint(painter, option, widget);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,9 +65,9 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 | 
			
		|||
	timeController->setX(sceneRect().width() - timeController->boundingRect().width()); // Position it on the right spot.
 | 
			
		||||
 | 
			
		||||
	// insert in the same way it's declared on the Enum. This is needed so we don't use an map.
 | 
			
		||||
	QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis
 | 
			
		||||
		<< timeAxis << depthController << timeController;
 | 
			
		||||
	Q_FOREACH(QGraphicsItem *item, stateItems){
 | 
			
		||||
	QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis <<
 | 
			
		||||
							timeAxis << depthController << timeController;
 | 
			
		||||
	Q_FOREACH(QGraphicsItem *item, stateItems) {
 | 
			
		||||
		scene()->addItem(item);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -196,10 +196,10 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 | 
			
		|||
 | 
			
		||||
// Animations
 | 
			
		||||
	QList<QSignalTransition*> transitions;
 | 
			
		||||
	transitions << tAddToEmpty << tAddToPlan << tAddToProfile << tEditToAdd << tEditToEmpty << tEditToPlan
 | 
			
		||||
	<< tEditToProfile << tEmptyToAdd << tEmptyToPlan << tEmptyToProfile << tProfileToAdd << tProfileToEdit
 | 
			
		||||
	<< tProfileToEmpty << tProfileToPlan << tPlanToAdd << tPlanToEmpty << tPlanToProfile;
 | 
			
		||||
	Q_FOREACH(QSignalTransition *s, transitions){
 | 
			
		||||
	transitions << tAddToEmpty << tAddToPlan << tAddToProfile << tEditToAdd << tEditToEmpty << tEditToPlan <<
 | 
			
		||||
		       tEditToProfile << tEmptyToAdd << tEmptyToPlan << tEmptyToProfile << tProfileToAdd <<
 | 
			
		||||
		       tProfileToEdit << tProfileToEmpty << tProfileToPlan << tPlanToAdd << tPlanToEmpty << tPlanToProfile;
 | 
			
		||||
	Q_FOREACH(QSignalTransition *s, transitions) {
 | 
			
		||||
		s->addAnimation(backgroundYAnim);
 | 
			
		||||
		s->addAnimation(depthAxisAnim);
 | 
			
		||||
		s->addAnimation(gasAxisanim);
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +232,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 | 
			
		|||
	// I Know that it's a list, but currently we are
 | 
			
		||||
	// using just the first.
 | 
			
		||||
	struct dive *d = dives.first();
 | 
			
		||||
	if(!d)
 | 
			
		||||
	if (!d)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	// Here we need to probe for the limits of the dive.
 | 
			
		||||
| 
						 | 
				
			
			@ -257,7 +257,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 | 
			
		|||
	timeAxis->updateTicks();
 | 
			
		||||
	dataModel->setDive(current_dive, pInfo);
 | 
			
		||||
 | 
			
		||||
	if(diveProfileItem){
 | 
			
		||||
	if (diveProfileItem) {
 | 
			
		||||
		//diveProfileItem->animateDelete();
 | 
			
		||||
		scene()->removeItem(diveProfileItem);
 | 
			
		||||
		delete diveProfileItem;
 | 
			
		||||
| 
						 | 
				
			
			@ -294,10 +294,10 @@ void ProfileWidget2::resizeEvent(QResizeEvent* event)
 | 
			
		|||
	QGraphicsView::resizeEvent(event);
 | 
			
		||||
	fitInView(sceneRect(), Qt::IgnoreAspectRatio);
 | 
			
		||||
 | 
			
		||||
	if(!stateMachine->configuration().count())
 | 
			
		||||
	if (!stateMachine->configuration().count())
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	if ((*stateMachine->configuration().begin())->objectName() == "Empty State"){
 | 
			
		||||
	if ((*stateMachine->configuration().begin())->objectName() == "Empty State") {
 | 
			
		||||
		fixBackgroundPos();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -305,7 +305,7 @@ void ProfileWidget2::resizeEvent(QResizeEvent* event)
 | 
			
		|||
void ProfileWidget2::fixBackgroundPos()
 | 
			
		||||
{
 | 
			
		||||
	QPixmap p = QPixmap(":background").scaledToHeight(viewport()->height());
 | 
			
		||||
	int x = viewport()->width()/2 - p.width()/2;
 | 
			
		||||
	int x = viewport()->width() / 2 - p.width() / 2;
 | 
			
		||||
	DivePixmapItem *bg = background;
 | 
			
		||||
	bg->setPixmap(p);
 | 
			
		||||
	bg->setX(mapToScene(x, 0).x());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ static struct graphics_context last_gc;
 | 
			
		|||
static double plot_scale = SCALE_SCREEN;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct text_render_options{
 | 
			
		||||
struct text_render_options {
 | 
			
		||||
	double size;
 | 
			
		||||
	color_indice_t color;
 | 
			
		||||
	double hpos, vpos;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,9 +50,10 @@ extern int evn_used;
 | 
			
		|||
 | 
			
		||||
#define TOOLBAR_POS \
 | 
			
		||||
QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \
 | 
			
		||||
viewport()->geometry().height() - toolBarProxy->boundingRect().height() )
 | 
			
		||||
	viewport()->geometry().height() - toolBarProxy->boundingRect().height() )
 | 
			
		||||
 | 
			
		||||
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0)
 | 
			
		||||
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent),
 | 
			
		||||
	toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0)
 | 
			
		||||
{
 | 
			
		||||
	printMode = false;
 | 
			
		||||
	isGrayscale = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -119,23 +120,23 @@ void ProfileGraphicsView::wheelEvent(QWheelEvent* event)
 | 
			
		|||
	scrollViewTo(event->pos());
 | 
			
		||||
	toolTip->setPos(mapToScene(toolTipPos));
 | 
			
		||||
	toolBarProxy->setPos(mapToScene(TOOLBAR_POS));
 | 
			
		||||
	if(zoomLevel != 0){
 | 
			
		||||
	if (zoomLevel != 0) {
 | 
			
		||||
		toolBarProxy->hide();
 | 
			
		||||
	}else{
 | 
			
		||||
	} else {
 | 
			
		||||
		toolBarProxy->show();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ProfileGraphicsView::contextMenuEvent(QContextMenuEvent* event)
 | 
			
		||||
{
 | 
			
		||||
	if(selected_dive == -1)
 | 
			
		||||
	if (selected_dive == -1)
 | 
			
		||||
		return;
 | 
			
		||||
	QMenu m;
 | 
			
		||||
	QMenu *gasChange = m.addMenu(tr("Add Gas Change"));
 | 
			
		||||
	GasSelectionModel *model = GasSelectionModel::instance();
 | 
			
		||||
	model->repopulate();
 | 
			
		||||
	int rowCount = model->rowCount();
 | 
			
		||||
	for(int i = 0; i < rowCount; i++){
 | 
			
		||||
	for (int i = 0; i < rowCount; i++) {
 | 
			
		||||
		QAction *action = new QAction(&m);
 | 
			
		||||
		action->setText( model->data(model->index(i, 0),Qt::DisplayRole).toString());
 | 
			
		||||
		connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
 | 
			
		||||
| 
						 | 
				
			
			@ -145,9 +146,9 @@ void ProfileGraphicsView::contextMenuEvent(QContextMenuEvent* event)
 | 
			
		|||
	QAction *action = m.addAction(tr("Add Bookmark"), this, SLOT(addBookmark()));
 | 
			
		||||
	action->setData(event->globalPos());
 | 
			
		||||
	QList<QGraphicsItem*> itemsAtPos = scene()->items(mapToScene(mapFromGlobal(event->globalPos())));
 | 
			
		||||
	Q_FOREACH(QGraphicsItem *i, itemsAtPos){
 | 
			
		||||
	Q_FOREACH(QGraphicsItem *i, itemsAtPos) {
 | 
			
		||||
		EventItem *item = dynamic_cast<EventItem*>(i);
 | 
			
		||||
		if(!item)
 | 
			
		||||
		if (!item)
 | 
			
		||||
			continue;
 | 
			
		||||
		QAction *action = new QAction(&m);
 | 
			
		||||
		action->setText(tr("Remove Event"));
 | 
			
		||||
| 
						 | 
				
			
			@ -214,7 +215,7 @@ void ProfileGraphicsView::hideEvents()
 | 
			
		|||
	if (QMessageBox::question(mainWindow(), TITLE_OR_TEXT(
 | 
			
		||||
				  tr("Hide events"),
 | 
			
		||||
				  tr("Hide all %1 events?").arg(event->name)),
 | 
			
		||||
				  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok){
 | 
			
		||||
				  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
 | 
			
		||||
		if (event->name) {
 | 
			
		||||
			for (int i = 0; i < evn_used; i++) {
 | 
			
		||||
				if (! strcmp(event->name, ev_namelist[i].ev_name)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -246,7 +247,7 @@ void ProfileGraphicsView::removeEvent()
 | 
			
		|||
				  tr("%1 @ %2:%3").arg(event->name)
 | 
			
		||||
				  .arg(event->time.seconds / 60)
 | 
			
		||||
				  .arg(event->time.seconds % 60, 2, 10, QChar('0'))),
 | 
			
		||||
				  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok){
 | 
			
		||||
				  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
 | 
			
		||||
		struct event **ep = ¤t_dc->events;
 | 
			
		||||
		while (ep && *ep != event)
 | 
			
		||||
			ep = &(*ep)->next;
 | 
			
		||||
| 
						 | 
				
			
			@ -269,9 +270,9 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
 | 
			
		|||
	QPoint toolTipPos = mapFromScene(toolTip->pos());
 | 
			
		||||
	scrollViewTo(event->pos());
 | 
			
		||||
 | 
			
		||||
	if (zoomLevel == 0)
 | 
			
		||||
	if (zoomLevel == 0) {
 | 
			
		||||
		QGraphicsView::mouseMoveEvent(event);
 | 
			
		||||
	else{
 | 
			
		||||
	} else {
 | 
			
		||||
		toolTip->setPos(mapToScene(toolTipPos));
 | 
			
		||||
		toolBarProxy->setPos(mapToScene(TOOLBAR_POS));
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -287,7 +288,7 @@ bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
 | 
			
		|||
 | 
			
		||||
	// This will "Eat" the default tooltip behavior if it is not on the toolBar.
 | 
			
		||||
	if (event->type() == QEvent::GraphicsSceneHelp) {
 | 
			
		||||
		if(toolBarProxy && !toolBarProxy->geometry().contains(mapToScene(mapFromGlobal(QCursor::pos())))){
 | 
			
		||||
		if (toolBarProxy && !toolBarProxy->geometry().contains(mapToScene(mapFromGlobal(QCursor::pos())))) {
 | 
			
		||||
			event->ignore();
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -328,17 +329,17 @@ void ProfileGraphicsView::clear()
 | 
			
		|||
{
 | 
			
		||||
	resetTransform();
 | 
			
		||||
	zoomLevel = 0;
 | 
			
		||||
	if(toolTip) {
 | 
			
		||||
	if (toolTip) {
 | 
			
		||||
		scene()->removeItem(toolTip);
 | 
			
		||||
		toolTip->deleteLater();
 | 
			
		||||
		toolTip = 0;
 | 
			
		||||
	}
 | 
			
		||||
	if(toolBarProxy) {
 | 
			
		||||
	if (toolBarProxy) {
 | 
			
		||||
		scene()->removeItem(toolBarProxy);
 | 
			
		||||
		toolBarProxy->deleteLater();
 | 
			
		||||
		toolBarProxy = 0;
 | 
			
		||||
	}
 | 
			
		||||
	if(rulerItem) {
 | 
			
		||||
	if (rulerItem) {
 | 
			
		||||
		remove_ruler();
 | 
			
		||||
		rulerItem->destNode()->deleteLater();
 | 
			
		||||
		rulerItem->sourceNode()->deleteLater();
 | 
			
		||||
| 
						 | 
				
			
			@ -408,9 +409,9 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
 | 
			
		|||
	if (nick.isEmpty())
 | 
			
		||||
		nick = tr("unknown divecomputer");
 | 
			
		||||
 | 
			
		||||
	if ( tr("unknown divecomputer") == nick){
 | 
			
		||||
	if ( tr("unknown divecomputer") == nick) {
 | 
			
		||||
		mode = PLAN;
 | 
			
		||||
	}else{
 | 
			
		||||
	} else {
 | 
			
		||||
		mode = DIVE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -484,7 +485,7 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
 | 
			
		|||
	}
 | 
			
		||||
	toolTip->readPos();
 | 
			
		||||
 | 
			
		||||
	if(mode == PLAN){
 | 
			
		||||
	if (mode == PLAN) {
 | 
			
		||||
		timeEditor = new GraphicsTextEditor();
 | 
			
		||||
		timeEditor->setPlainText(d->duration.seconds ? QString::number(d->duration.seconds/60) : tr("Set Duration: 10 minutes"));
 | 
			
		||||
		timeEditor->setPos(profile_grid_area.width() - timeEditor->boundingRect().width(), timeMarkers->y());
 | 
			
		||||
| 
						 | 
				
			
			@ -572,7 +573,7 @@ void ProfileGraphicsView::plot_pp_text()
 | 
			
		|||
		QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(0, m), SCALEGC(hpos, m));
 | 
			
		||||
		QPen pen(defaultPen);
 | 
			
		||||
		pen.setColor(c);
 | 
			
		||||
		if ( QString::number(m).toDouble() != QString::number(m).toInt()){
 | 
			
		||||
		if ( QString::number(m).toDouble() != QString::number(m).toInt()) {
 | 
			
		||||
			pen.setStyle(Qt::DashLine);
 | 
			
		||||
			pen.setWidthF(1.2);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -696,7 +697,7 @@ void ProfileGraphicsView::createPPLegend(QString title, const QColor& c, QPointF
 | 
			
		|||
	scene()->addItem(rect);
 | 
			
		||||
	scene()->addItem(text);
 | 
			
		||||
	legendPos.setX(text->pos().x() + text->boundingRect().width() + 20);
 | 
			
		||||
	if(printMode){
 | 
			
		||||
	if (printMode) {
 | 
			
		||||
		QFont f = text->font();
 | 
			
		||||
		f.setPointSizeF( f.pointSizeF() * 0.7);
 | 
			
		||||
		text->setFont(f);
 | 
			
		||||
| 
						 | 
				
			
			@ -1029,7 +1030,7 @@ void ProfileGraphicsView::plot_one_event(struct event *ev)
 | 
			
		|||
			name += ": ";
 | 
			
		||||
			if (he)
 | 
			
		||||
				name += QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10);
 | 
			
		||||
			else if(is_air(o2, he))
 | 
			
		||||
			else if (is_air(o2, he))
 | 
			
		||||
				name += tr("air");
 | 
			
		||||
			else
 | 
			
		||||
				name += QString(tr("EAN%1")).arg((o2 + 5) / 10);
 | 
			
		||||
| 
						 | 
				
			
			@ -1292,9 +1293,9 @@ void ProfileGraphicsView::plot_depth_profile()
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	/* plot the calculated ceiling for all tissues */
 | 
			
		||||
	if (prefs.profile_calc_ceiling && prefs.calc_all_tissues){
 | 
			
		||||
	if (prefs.profile_calc_ceiling && prefs.calc_all_tissues) {
 | 
			
		||||
		int k;
 | 
			
		||||
		for (k=0; k<16; k++){
 | 
			
		||||
		for (k=0; k<16; k++) {
 | 
			
		||||
			pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
 | 
			
		||||
			pat.setColorAt(1, QColor(100, 100, 100, 50));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1641,7 +1642,7 @@ void ToolTipItem::readPos()
 | 
			
		|||
	QPointF value = scene()->views().at(0)->mapToScene(
 | 
			
		||||
		s.value("tooltip_position").toPoint()
 | 
			
		||||
	);
 | 
			
		||||
	if (!scene()->sceneRect().contains(value)){
 | 
			
		||||
	if (!scene()->sceneRect().contains(value)) {
 | 
			
		||||
		value = QPointF(0,0);
 | 
			
		||||
	}
 | 
			
		||||
	setPos(value);
 | 
			
		||||
| 
						 | 
				
			
			@ -1654,7 +1655,7 @@ QColor EventItem::getColor(const color_indice_t i)
 | 
			
		|||
 | 
			
		||||
EventItem::EventItem(struct event *ev, QGraphicsItem* parent, bool grayscale): QGraphicsPixmapItem(parent), ev(ev), isGrayscale(grayscale)
 | 
			
		||||
{
 | 
			
		||||
	if(ev->name && (strcmp(ev->name, "bookmark") == 0 || strcmp(ev->name, "heading") == 0)) {
 | 
			
		||||
	if (ev->name && (strcmp(ev->name, "bookmark") == 0 || strcmp(ev->name, "heading") == 0)) {
 | 
			
		||||
		setPixmap( QPixmap(QString(":flag")).scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation));
 | 
			
		||||
	} else {
 | 
			
		||||
		setPixmap( QPixmap(QString(":warning")).scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation));
 | 
			
		||||
| 
						 | 
				
			
			@ -1683,11 +1684,9 @@ void RulerNodeItem::recalculate()
 | 
			
		|||
	uint16_t count = 0;
 | 
			
		||||
	if (x() < 0) {
 | 
			
		||||
		setPos(0, y());
 | 
			
		||||
	}
 | 
			
		||||
	else if (x() > SCALEXGC(data->sec)) {
 | 
			
		||||
	} else if (x() > SCALEXGC(data->sec)) {
 | 
			
		||||
		setPos(SCALEXGC(data->sec), y());
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	} else {
 | 
			
		||||
		data = pi->entry;
 | 
			
		||||
		count=0;
 | 
			
		||||
		while (SCALEXGC(data->sec) < x() && count < pi->nr) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1701,9 +1700,9 @@ void RulerNodeItem::recalculate()
 | 
			
		|||
 | 
			
		||||
QVariant RulerNodeItem::itemChange(GraphicsItemChange change, const QVariant &value)
 | 
			
		||||
{
 | 
			
		||||
	if(change == ItemPositionHasChanged) {
 | 
			
		||||
	if (change == ItemPositionHasChanged) {
 | 
			
		||||
		recalculate();
 | 
			
		||||
		if(ruler != NULL)
 | 
			
		||||
		if (ruler != NULL)
 | 
			
		||||
			ruler->recalculate();
 | 
			
		||||
		if (scene()) {
 | 
			
		||||
			scene()->update();
 | 
			
		||||
| 
						 | 
				
			
			@ -1827,7 +1826,7 @@ void GraphicsTextEditor::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
 | 
			
		|||
 | 
			
		||||
void GraphicsTextEditor::keyReleaseEvent(QKeyEvent* event)
 | 
			
		||||
{
 | 
			
		||||
	if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return){
 | 
			
		||||
	if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
 | 
			
		||||
		setTextInteractionFlags(Qt::NoTextInteraction);
 | 
			
		||||
		emit editingFinished( toPlainText() );
 | 
			
		||||
		mainWindow()->graphics()->setFocusProxy(mainWindow()->dive_list());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,13 +15,13 @@
 | 
			
		|||
#include "../dive.h"
 | 
			
		||||
#include "mainwindow.h"
 | 
			
		||||
 | 
			
		||||
class MinMaxAvgWidgetPrivate{
 | 
			
		||||
class MinMaxAvgWidgetPrivate {
 | 
			
		||||
public:
 | 
			
		||||
	QLabel *avgIco, *avgValue;
 | 
			
		||||
	QLabel *minIco, *minValue;
 | 
			
		||||
	QLabel *maxIco, *maxValue;
 | 
			
		||||
 | 
			
		||||
	MinMaxAvgWidgetPrivate(MinMaxAvgWidget *owner){
 | 
			
		||||
	MinMaxAvgWidgetPrivate(MinMaxAvgWidget *owner) {
 | 
			
		||||
		avgIco = new QLabel(owner);
 | 
			
		||||
		avgIco->setPixmap(QIcon(":/average").pixmap(16,16));
 | 
			
		||||
		avgIco->setToolTip(QObject::tr("Average"));
 | 
			
		||||
| 
						 | 
				
			
			@ -60,8 +60,9 @@ double MinMaxAvgWidget::minimum() const
 | 
			
		|||
	return d->minValue->text().toDouble();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MinMaxAvgWidget::MinMaxAvgWidget(QWidget* parent)
 | 
			
		||||
	: d(new MinMaxAvgWidgetPrivate(this)){
 | 
			
		||||
MinMaxAvgWidget::MinMaxAvgWidget(QWidget* parent) : d(new MinMaxAvgWidgetPrivate(this))
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MinMaxAvgWidget::~MinMaxAvgWidget()
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +113,7 @@ RenumberDialog* RenumberDialog::instance()
 | 
			
		|||
 | 
			
		||||
void RenumberDialog::buttonClicked(QAbstractButton* button)
 | 
			
		||||
{
 | 
			
		||||
	if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole){
 | 
			
		||||
	if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
 | 
			
		||||
		qDebug() << "Renumbering.";
 | 
			
		||||
		renumber_dives(ui.spinBox->value());
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +135,7 @@ void ShiftTimesDialog::buttonClicked(QAbstractButton* button)
 | 
			
		|||
{
 | 
			
		||||
	int amount;
 | 
			
		||||
 | 
			
		||||
	if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole){
 | 
			
		||||
	if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
 | 
			
		||||
		amount = ui.timeEdit->time().hour() * 3600 + ui.timeEdit->time().minute() * 60;
 | 
			
		||||
		if (ui.backwards->isChecked())
 | 
			
		||||
			amount *= -1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ void StarWidget::paintEvent(QPaintEvent* event)
 | 
			
		|||
	for(int i = current; i < TOTALSTARS; i++)
 | 
			
		||||
		p.drawPixmap(i * IMG_SIZE + SPACING, 0, starInactive());
 | 
			
		||||
 | 
			
		||||
	if(hasFocus()){
 | 
			
		||||
	if (hasFocus()) {
 | 
			
		||||
		QStyleOptionFocusRect option;
 | 
			
		||||
		option.initFrom(this);
 | 
			
		||||
		option.backgroundColor = palette().color(QPalette::Background);
 | 
			
		||||
| 
						 | 
				
			
			@ -135,12 +135,12 @@ void StarWidget::focusOutEvent(QFocusEvent* event)
 | 
			
		|||
 | 
			
		||||
void StarWidget::keyPressEvent(QKeyEvent* event)
 | 
			
		||||
{
 | 
			
		||||
	if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Right){
 | 
			
		||||
		if (currentStars() < TOTALSTARS){
 | 
			
		||||
	if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Right) {
 | 
			
		||||
		if (currentStars() < TOTALSTARS) {
 | 
			
		||||
			setCurrentStars( currentStars()+1);
 | 
			
		||||
		}
 | 
			
		||||
	}else if(event->key() == Qt::Key_Down || event->key() == Qt::Key_Left){
 | 
			
		||||
		if(currentStars() > 0){
 | 
			
		||||
	} else if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Left) {
 | 
			
		||||
		if (currentStars() > 0) {
 | 
			
		||||
			setCurrentStars( currentStars()-1);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -331,8 +331,8 @@ SubsurfaceWebServices::SubsurfaceWebServices(QWidget* parent, Qt::WindowFlags f)
 | 
			
		|||
void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
 | 
			
		||||
{
 | 
			
		||||
	ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
 | 
			
		||||
	switch(ui.buttonBox->buttonRole(button)){
 | 
			
		||||
	case QDialogButtonBox::ApplyRole:{
 | 
			
		||||
	switch (ui.buttonBox->buttonRole(button)) {
 | 
			
		||||
	case QDialogButtonBox::ApplyRole: {
 | 
			
		||||
		clear_table(&gps_location_table);
 | 
			
		||||
		QByteArray url = tr("Webservice").toLocal8Bit();
 | 
			
		||||
		parse_xml_buffer(url.data(), downloadedData.data(), downloadedData.length(), &gps_location_table, NULL, NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -408,7 +408,7 @@ void SubsurfaceWebServices::downloadFinished()
 | 
			
		|||
 | 
			
		||||
	uint resultCode = download_dialog_parse_response(downloadedData);
 | 
			
		||||
	setStatusText(resultCode);
 | 
			
		||||
	if (resultCode == DD_STATUS_OK){
 | 
			
		||||
	if (resultCode == DD_STATUS_OK) {
 | 
			
		||||
		ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
 | 
			
		||||
	}
 | 
			
		||||
	reply->deleteLater();
 | 
			
		||||
| 
						 | 
				
			
			@ -850,8 +850,8 @@ void DivelogsDeWebServices::uploadError(QNetworkReply::NetworkError error)
 | 
			
		|||
void DivelogsDeWebServices::buttonClicked(QAbstractButton* button)
 | 
			
		||||
{
 | 
			
		||||
	ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
 | 
			
		||||
	switch(ui.buttonBox->buttonRole(button)){
 | 
			
		||||
	case QDialogButtonBox::ApplyRole:{
 | 
			
		||||
	switch (ui.buttonBox->buttonRole(button)) {
 | 
			
		||||
	case QDialogButtonBox::ApplyRole: {
 | 
			
		||||
		/* in 'uploadMode' button is called 'Done' and closes the dialog */
 | 
			
		||||
		if (uploadMode) {
 | 
			
		||||
			hide();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,8 @@ void TableView::setTitle(const QString& title)
 | 
			
		|||
	ui.groupBox->setTitle(title);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TableView::setModel(QAbstractItemModel *model){
 | 
			
		||||
void TableView::setModel(QAbstractItemModel *model)
 | 
			
		||||
{
 | 
			
		||||
	ui.tableView->setModel(model);
 | 
			
		||||
	connect(ui.tableView, SIGNAL(clicked(QModelIndex)), model, SLOT(remove(QModelIndex)));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -80,10 +81,12 @@ void TableView::showEvent(QShowEvent* event)
 | 
			
		|||
	fixPlusPosition();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TableView::edit(const QModelIndex& index){
 | 
			
		||||
void TableView::edit(const QModelIndex& index)
 | 
			
		||||
{
 | 
			
		||||
	ui.tableView->edit(index);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QTableView *TableView::view(){
 | 
			
		||||
QTableView *TableView::view()
 | 
			
		||||
{
 | 
			
		||||
	return ui.tableView;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,17 +14,15 @@ TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NUL
 | 
			
		|||
	qreal h, s, l, a;
 | 
			
		||||
	textColor.getHslF(&h, &s, &l, &a);
 | 
			
		||||
	// I use dark themes
 | 
			
		||||
	if (l <= 0.3 ){ // very dark text. get a brigth background
 | 
			
		||||
	if (l <= 0.3 ) { // very dark text. get a brigth background
 | 
			
		||||
		addColor( QColor(Qt::red).lighter(120) );
 | 
			
		||||
		addColor( QColor(Qt::green).lighter(120) );
 | 
			
		||||
		addColor( QColor(Qt::blue).lighter(120) );
 | 
			
		||||
	}
 | 
			
		||||
	else if ( l <= 0.6 ){ // moderated dark text. get a somewhat brigth background
 | 
			
		||||
	} else if ( l <= 0.6 ) { // moderated dark text. get a somewhat brigth background
 | 
			
		||||
		addColor( QColor(Qt::red).lighter(60) );
 | 
			
		||||
		addColor( QColor(Qt::green).lighter(60) );
 | 
			
		||||
		addColor( QColor(Qt::blue).lighter(60) );
 | 
			
		||||
	}
 | 
			
		||||
	else{
 | 
			
		||||
	} else {
 | 
			
		||||
		addColor( QColor(Qt::red).darker(120) );
 | 
			
		||||
		addColor( QColor(Qt::green).darker(120) );
 | 
			
		||||
		addColor( QColor(Qt::blue).darker(120) );
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +78,7 @@ void TagWidget::highlight() {
 | 
			
		|||
			} else if (state == FINDEND) {
 | 
			
		||||
				/* Found end of tag */
 | 
			
		||||
				if (i > 1) {
 | 
			
		||||
					if(text().at(i-1) != '\\') {
 | 
			
		||||
					if (text().at(i-1) != '\\') {
 | 
			
		||||
						addBlock(start, end);
 | 
			
		||||
						state = FINDSTART;
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -125,10 +123,9 @@ void TagWidget::reparse()
 | 
			
		|||
				QAbstractItemView *popup = m_completer->popup();
 | 
			
		||||
				if (popup)
 | 
			
		||||
					popup->hide();
 | 
			
		||||
				}
 | 
			
		||||
			else
 | 
			
		||||
			} else {
 | 
			
		||||
				m_completer->complete();
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			m_completer->complete();
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -141,8 +138,7 @@ void TagWidget::completionSelected(QString completion) {
 | 
			
		|||
	if (pos.first >= 0 && pos.second > 0) {
 | 
			
		||||
		setText(text().remove(pos.first, pos.second-pos.first).insert(pos.first, completion));
 | 
			
		||||
		setCursorPosition(pos.first+completion.length());
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	} else {
 | 
			
		||||
		setText(completion.append(", "));
 | 
			
		||||
		setCursorPosition(text().length());
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue