mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Only use HTML if the text has a <table>
The text we generate for the diveplan has a table inside, and we must use HTML only for the dive plan. so I treat all text as HTML, look for a table item, if it doesn't have, I treat it as Simple text and set it on the notes. Works and makes linus loves me again. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									607d450cd6
								
							
						
					
					
						commit
						99922722d2
					
				
					 1 changed files with 15 additions and 2 deletions
				
			
		|  | @ -331,7 +331,7 @@ void MainTab::clearStats() | |||
| 
 | ||||
| #define UPDATE_TEXT(d, field)          \ | ||||
| 	if (clear || !d.field)         \ | ||||
| 		ui.field->setText(""); \ | ||||
| 		ui.field->setText(QString()); \ | ||||
| 	else                           \ | ||||
| 		ui.field->setText(d.field) | ||||
| 
 | ||||
|  | @ -370,6 +370,16 @@ void MainTab::updateDiveInfo(bool clear) | |||
| 	process_all_dives(&displayed_dive, &prevd); | ||||
| 
 | ||||
| 	divePictureModel->updateDivePictures(); | ||||
| 
 | ||||
| 	ui.notes->setText(QString()); | ||||
| 	if (!clear) { | ||||
| 		QString tmp(displayed_dive.notes); | ||||
| 		if (tmp.indexOf("<table") != -1) | ||||
| 			ui.notes->setHtml(tmp); | ||||
| 		else | ||||
| 			ui.notes->setPlainText(tmp); | ||||
| 	} | ||||
| 
 | ||||
| 	UPDATE_TEXT(displayed_dive, notes); | ||||
| 	UPDATE_TEXT(displayed_dive, location); | ||||
| 	UPDATE_TEXT(displayed_dive, suit); | ||||
|  | @ -1004,7 +1014,10 @@ void MainTab::on_notes_textChanged() | |||
| 	if (editMode == IGNORE) | ||||
| 		return; | ||||
| 	free(displayed_dive.notes); | ||||
| 	displayed_dive.notes = strdup(ui.notes->toHtml().toUtf8().data()); | ||||
| 	if (ui.notes->toHtml().indexOf("<table") != -1) | ||||
| 		displayed_dive.notes = strdup(ui.notes->toHtml().toUtf8().data()); | ||||
| 	else | ||||
| 		displayed_dive.notes = strdup(ui.notes->toPlainText().toUtf8().data()); | ||||
| 	markChangedWidget(ui.notes); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue