@@ -321,9 +321,9 @@ void AscentViewer::updateInfoArea()
321
321
{
322
322
resetInfoLabels ();
323
323
324
- BufferRowIndex ascentBufferRowIndex = compAscents.getBufferRowIndexForViewRow (currentViewRowIndex);
324
+ const BufferRowIndex ascentBufferRowIndex = compAscents.getBufferRowIndexForViewRow (currentViewRowIndex);
325
325
326
- ItemID tripID = db.ascentsTable .tripIDColumn .getValueAt (ascentBufferRowIndex);
326
+ const ItemID tripID = db.ascentsTable .tripIDColumn .getValueAt (ascentBufferRowIndex);
327
327
if (tripID.isValid ()) {
328
328
BufferRowIndex tripBufferRowIndex = db.tripsTable .getBufferIndexForPrimaryKey (FORCE_VALID (tripID));
329
329
tripNameLabel ->setText (compAscents.tripColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
@@ -337,7 +337,7 @@ void AscentViewer::updateInfoArea()
337
337
tripDatesLabel ->setText (dateRange);
338
338
}
339
339
340
- ItemID peakID = db.ascentsTable .peakIDColumn .getValueAt (ascentBufferRowIndex);
340
+ const ItemID peakID = db.ascentsTable .peakIDColumn .getValueAt (ascentBufferRowIndex);
341
341
if (peakID.isValid ()) {
342
342
BufferRowIndex peakBufferRowIndex = db.peaksTable .getBufferIndexForPrimaryKey (FORCE_VALID (peakID));
343
343
peakNameLabel ->setText (compAscents.peakColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
@@ -347,9 +347,9 @@ void AscentViewer::updateInfoArea()
347
347
peakRangeLabel ->setText (compAscents.rangeColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
348
348
peakCountryLabel ->setText (compAscents.countryColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
349
349
peakContinentLabel ->setText (compAscents.continentColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
350
- QString mapsLink = db.peaksTable .mapsLinkColumn .getValueAt (peakBufferRowIndex).toString ();
351
- QString earthLink = db.peaksTable .earthLinkColumn .getValueAt (peakBufferRowIndex).toString ();
352
- QString wikiLink = db.peaksTable .wikiLinkColumn .getValueAt (peakBufferRowIndex).toString ();
350
+ const QString mapsLink = db.peaksTable .mapsLinkColumn .getValueAt (peakBufferRowIndex).toString ();
351
+ const QString earthLink = db.peaksTable .earthLinkColumn .getValueAt (peakBufferRowIndex).toString ();
352
+ const QString wikiLink = db.peaksTable .wikiLinkColumn .getValueAt (peakBufferRowIndex).toString ();
353
353
if (!mapsLink.isEmpty () || !earthLink.isEmpty () || !wikiLink.isEmpty ()) peakLinksBox->setVisible (true );
354
354
if (!mapsLink.isEmpty ()) {
355
355
peakMapsLinkLabel ->setText (" [" + tr (" Google Maps" ) + " ](" + mapsLink + " )" );
@@ -365,7 +365,7 @@ void AscentViewer::updateInfoArea()
365
365
}
366
366
}
367
367
368
- QString ascentTitle = compAscents.titleColumn .getFormattedValueAt (ascentBufferRowIndex).toString ();
368
+ const QString ascentTitle = compAscents.titleColumn .getFormattedValueAt (ascentBufferRowIndex).toString ();
369
369
if (!ascentTitle.isEmpty ()) {
370
370
ascentTitleLabel ->setText (compAscents.titleColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
371
371
ascentTitleLabel ->setVisible (true );
@@ -380,13 +380,18 @@ void AscentViewer::updateInfoArea()
380
380
ascentDifficultyLabel ->setText (compAscents.difficultyColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
381
381
ascentPeakOrdinalLabel ->setText (compAscents.peakOrdinalColumn .getFormattedValueAt (ascentBufferRowIndex).toString ());
382
382
383
- QString hikersList = compAscents.hikersColumn .getFormattedValueAt (ascentBufferRowIndex).toString ();
383
+ const QString hikersList = compAscents.hikersColumn .getFormattedValueAt (ascentBufferRowIndex).toString ();
384
384
if (!hikersList.isEmpty ()) {
385
385
ascentParticipantsLabel ->setText (hikersList);
386
386
ascentParticipantsBox->setVisible (true );
387
387
}
388
388
389
- descriptionTextBrowser->setText (db.ascentsTable .descriptionColumn .getValueAt (ascentBufferRowIndex).toString ());
389
+ const QString ascentDescription = db.ascentsTable .descriptionColumn .getValueAt (ascentBufferRowIndex).toString ();
390
+ if (descriptionEditable) {
391
+ descriptionTextBrowser->setPlainText (ascentDescription);
392
+ } else {
393
+ descriptionTextBrowser->setMarkdown (ascentDescription);
394
+ }
390
395
}
391
396
392
397
/* *
@@ -849,8 +854,8 @@ void AscentViewer::saveDescription()
849
854
{
850
855
if (currentAscentID.isInvalid () || !descriptionEditable) return ;
851
856
852
- QString newDescription = descriptionTextBrowser->toPlainText ();
853
- bool descriptionChanged = db.ascentsTable .descriptionColumn .getValueFor (FORCE_VALID (currentAscentID)) != newDescription;
857
+ const QString newDescription = descriptionTextBrowser->toPlainText ();
858
+ const bool descriptionChanged = db.ascentsTable .descriptionColumn .getValueFor (FORCE_VALID (currentAscentID)) != newDescription;
854
859
if (descriptionChanged) {
855
860
db.beginChangingData ();
856
861
db.ascentsTable .updateCell (*this , FORCE_VALID (currentAscentID), db.ascentsTable .descriptionColumn , newDescription);
@@ -1141,6 +1146,12 @@ void AscentViewer::handle_descriptionEditableChanged()
1141
1146
1142
1147
descriptionEditable = editDescriptionButton->isChecked ();
1143
1148
1149
+ if (descriptionEditable) {
1150
+ const QString description = db.ascentsTable .descriptionColumn .getValueFor (FORCE_VALID (currentAscentID)).toString ();
1151
+ descriptionTextBrowser->setPlainText (description);
1152
+ } else {
1153
+ descriptionTextBrowser->setMarkdown (descriptionTextBrowser->toPlainText ());
1154
+ }
1144
1155
descriptionTextBrowser->setReadOnly (!descriptionEditable);
1145
1156
}
1146
1157
0 commit comments