mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Desktop: improve recognition of HTML-notes
To recognize HTML-notes the text was scanned for <div> tags. But apparently the planner notes do not feature such a thing. Therefore extend recognition of HTML to <table> tags. Note we can't use the <html> or <span> tags, because these are *always* produced by the QTextEdit::toHtml() function. Fixes #2265 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									98d171630c
								
							
						
					
					
						commit
						009f47c5dc
					
				
					 2 changed files with 9 additions and 4 deletions
				
			
		|  | @ -369,11 +369,15 @@ bool MainTab::isEditing() | |||
| 	return editMode != NONE; | ||||
| } | ||||
| 
 | ||||
| static bool isHtml(const QString &s) | ||||
| { | ||||
| 	return s.contains("<div", Qt::CaseInsensitive) || s.contains("<table", Qt::CaseInsensitive); | ||||
| } | ||||
| 
 | ||||
| void MainTab::updateNotes(const struct dive *d) | ||||
| { | ||||
| 	QString tmp(d->notes); | ||||
| 	if (tmp.indexOf("<div") != -1) { | ||||
| 		tmp.replace(QString("\n"), QString("<br>")); | ||||
| 	if (isHtml(tmp)) { | ||||
| 		ui.notes->setHtml(tmp); | ||||
| 	} else { | ||||
| 		ui.notes->setPlainText(tmp); | ||||
|  | @ -881,8 +885,8 @@ void MainTab::on_notes_editingFinished() | |||
| 	if (!currentTrip && !current_dive) | ||||
| 		return; | ||||
| 
 | ||||
| 	QString notes = ui.notes->toHtml().indexOf("<div") != -1 ? | ||||
| 		ui.notes->toHtml() : ui.notes->toPlainText(); | ||||
| 	QString html = ui.notes->toHtml(); | ||||
| 	QString notes = isHtml(html) ? html : ui.notes->toPlainText(); | ||||
| 
 | ||||
| 	if (currentTrip) | ||||
| 		Command::editTripNotes(currentTrip, notes); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue