diff --git a/src/layui/layui/MarkerBrowserPage.ui b/src/layui/layui/MarkerBrowserPage.ui index 18afcbe7f..577e9cebc 100644 --- a/src/layui/layui/MarkerBrowserPage.ui +++ b/src/layui/layui/MarkerBrowserPage.ui @@ -480,51 +480,7 @@ 6 - - - - Waive - - - W - - - - :/waived_16px.png:/waived_16px.png - - - - - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Remove snapshot</p></body></html> - - - ... - - - - :/nophoto_16px.png:/nophoto_16px.png - - - - - - - Set or reset flag - - - Flag - - - QToolButton::MenuButtonPopup - - - - + Add snapshot @@ -538,28 +494,24 @@ p, li { white-space: pre-wrap; } - - + + - Important + Waive - Imp + W - :/important_16px.png:/important_16px.png + :/waived_16px.png:/waived_16px.png + + + Ctrl+W - - - - - - - - + @@ -605,7 +557,38 @@ p, li { white-space: pre-wrap; } - + + + + Important + + + Imp + + + + :/important_16px.png:/important_16px.png + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Remove snapshot</p></body></html> + + + ... + + + + :/nophoto_16px.png:/nophoto_16px.png + + + + @@ -662,6 +645,43 @@ p, li { white-space: pre-wrap; } + + + + + + + + + + + Set or reset flag + + + Flag + + + QToolButton::MenuButtonPopup + + + + + + + Edit Comment + + + ... + + + + :/edit_16px.png:/edit_16px.png + + + F2 + + + diff --git a/src/layui/layui/rdbMarkerBrowserPage.cc b/src/layui/layui/rdbMarkerBrowserPage.cc index 7b10974b1..657f52a14 100644 --- a/src/layui/layui/rdbMarkerBrowserPage.cc +++ b/src/layui/layui/rdbMarkerBrowserPage.cc @@ -39,6 +39,7 @@ #include #include #include +#include namespace rdb { @@ -1690,6 +1691,7 @@ MarkerBrowserPage::MarkerBrowserPage (QWidget * /*parent*/) connect (list_down_pb, SIGNAL (clicked ()), this, SLOT (list_down_clicked ())); connect (flags_pb, SIGNAL (clicked ()), this, SLOT (flag_button_clicked ())); connect (important_pb, SIGNAL (clicked ()), this, SLOT (important_button_clicked ())); + connect (edit_pb, SIGNAL (clicked ()), this, SLOT (edit_button_clicked ())); connect (waive_pb, SIGNAL (clicked ()), this, SLOT (waived_button_clicked ())); connect (photo_pb, SIGNAL (clicked ()), this, SLOT (snapshot_button_clicked ())); connect (nophoto_pb, SIGNAL (clicked ()), this, SLOT (remove_snapshot_button_clicked ())); @@ -2104,6 +2106,8 @@ MarkerBrowserPage::update_info_text () size_t n_category = 0; const rdb::Item *item = 0; size_t n_item = 0; + std::string comment; + size_t n_comment = 0; for (QModelIndexList::const_iterator selected_item = selected.begin (); selected_item != selected.end (); ++selected_item) { @@ -2115,6 +2119,11 @@ MarkerBrowserPage::update_info_text () item = i; ++n_item; + if (! item->comment ().empty () && item->comment () != comment) { + comment = item->comment (); + ++n_comment; + } + const rdb::Cell *c = mp_database->cell_by_id (item->cell_id ()); if (c && c != cell) { cell = c; @@ -2162,6 +2171,12 @@ MarkerBrowserPage::update_info_text () info += "

"; } + if (! comment.empty () && n_comment == 1) { + info += "

"; + tl::escape_to_html (info, comment); + info += "

"; + } + info += "

"; if (item && n_item == 1) { @@ -2901,7 +2916,61 @@ MarkerBrowserPage::flag_menu_selected () } } -void +void +MarkerBrowserPage::edit_button_clicked () +{ + if (! mp_database) { + return; + } + + MarkerBrowserListViewModel *list_model = dynamic_cast (markers_list->model ()); + if (! list_model) { + return; + } + + std::string str; + + QModelIndexList selected = markers_list->selectionModel ()->selectedIndexes (); + for (QModelIndexList::const_iterator selected_item = selected.begin (); selected_item != selected.end (); ++selected_item) { + if (selected_item->column () == 0) { + const rdb::Item *i = list_model->item (selected_item->row ()); + if (! i->comment ().empty ()) { + if (str.empty ()) { + str = i->comment (); + } else if (str != i->comment ()) { + str.clear (); + break; + } + } + } + } + + bool ok = false; + +#if QT_VERSION >= 0x50200 + QString new_text = QInputDialog::getMultiLineText (this, QObject::tr ("Edit Marker Comment"), QObject::tr ("Comment"), tl::to_qstring (str), &ok); + str = tl::to_string (new_text); +#else + QString new_text = QInputDialog::getText (this, QObject::tr ("Edit Marker Comment"), QObject::tr ("Comment"), QLineEdit::Normal, tl::to_qstring (tl::escape_string (str)), &ok); + str = tl::unescape_string (tl::to_string (new_text)); +#endif + + if (ok) { + + QModelIndexList selected = markers_list->selectionModel ()->selectedIndexes (); + for (QModelIndexList::const_iterator selected_item = selected.begin (); selected_item != selected.end (); ++selected_item) { + if (selected_item->column () == 0) { + const rdb::Item *i = list_model->item (selected_item->row ()); + mp_database->set_item_comment (i, str); + } + } + + update_info_text (); + + } +} + +void MarkerBrowserPage::waived_button_clicked () { if (! mp_database) { diff --git a/src/layui/layui/rdbMarkerBrowserPage.h b/src/layui/layui/rdbMarkerBrowserPage.h index 58cd27ecc..7a916b1f6 100644 --- a/src/layui/layui/rdbMarkerBrowserPage.h +++ b/src/layui/layui/rdbMarkerBrowserPage.h @@ -179,6 +179,7 @@ public slots: void flag_menu_selected (); void important_button_clicked (); void waived_button_clicked (); + void edit_button_clicked (); void snapshot_button_clicked (); void remove_snapshot_button_clicked (); void revisit_non_waived ();