diff --git a/src/vedittab.cpp b/src/vedittab.cpp index 3627f6ac..7b0451e8 100644 --- a/src/vedittab.cpp +++ b/src/vedittab.cpp @@ -241,7 +241,6 @@ void VEditTab::handleFocusChanged(QWidget *old, QWidget *now) void VEditTab::updateTocFromHtml(const QString &tocHtml) { - qDebug() << tocHtml; tableOfContent.type = VHeaderType::Anchor; QVector &headers = tableOfContent.headers; headers.clear(); diff --git a/src/voutline.cpp b/src/voutline.cpp index 828489e2..e4437355 100644 --- a/src/voutline.cpp +++ b/src/voutline.cpp @@ -81,11 +81,17 @@ void VOutline::handleItemClicked(QTreeWidgetItem *item, int column) QString anchor = itemJson["anchor"].toString(); int lineNumber = itemJson["line_number"].toInt(); qDebug() << "click anchor" << anchor << lineNumber; - emit outlineItemActivated(VAnchor(outline.filePath, anchor, lineNumber)); + curHeader.filePath = outline.filePath; + curHeader.anchor = anchor; + curHeader.lineNumber = lineNumber; + emit outlineItemActivated(curHeader); } void VOutline::updateCurHeader(const VAnchor &anchor) { + if (anchor == curHeader) { + return; + } curHeader = anchor; if (outline.type == VHeaderType::Anchor) { selectAnchor(anchor.anchor); diff --git a/src/vtoc.h b/src/vtoc.h index 287c68cd..a902a512 100644 --- a/src/vtoc.h +++ b/src/vtoc.h @@ -26,11 +26,19 @@ struct VAnchor VAnchor() : lineNumber(-1) {} VAnchor(const QString filePath, const QString &anchor, int lineNumber) : filePath(filePath), anchor(anchor), lineNumber(lineNumber) {} + inline bool operator ==(const VAnchor &p_anchor) const; QString filePath; QString anchor; int lineNumber; }; +inline bool VAnchor::operator ==(const VAnchor &p_anchor) const +{ + return p_anchor.filePath == filePath && + p_anchor.anchor == anchor && + p_anchor.lineNumber == lineNumber; +} + class VToc { public: