Changeset 70559 in vbox for trunk/src/VBox
- Timestamp:
- Jan 12, 2018 2:29:48 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
r70554 r70559 183 183 return; 184 184 m_bookmarkVector.remove(index, 1); 185 updateTextEditBookmarkLineSet(); 185 186 } 186 187 … … 188 189 { 189 190 m_bookmarkVector.clear(); 191 updateTextEditBookmarkLineSet(); 190 192 } 191 193 … … 198 200 199 201 int lineNumber = m_bookmarkVector.at(bookmarkIndex).first; 200 QTextDocument* document = m_pTextEdit->document(); 201 if(!document) 202 return; 203 204 QTextCursor cursor(document->findBlockByLineNumber(lineNumber)); 205 m_pTextEdit->moveCursor(QTextCursor::End); 206 m_pTextEdit->setTextCursor(cursor); 207 202 m_pTextEdit->scrollToLine(lineNumber); 208 203 } 209 204 … … 216 211 { 217 212 m_bookmarkVector.push_back(bookmark); 213 updateTextEditBookmarkLineSet(); 218 214 emit sigBookmarksUpdated(); 219 215 } 216 217 void UIVMLogPage::updateTextEditBookmarkLineSet() 218 { 219 if(!m_pTextEdit) 220 return; 221 QSet<int> bookmarkLinesSet; 222 for(int i = 0; i < m_bookmarkVector.size(); ++i) 223 { 224 bookmarkLinesSet.insert(m_bookmarkVector.at(i).first); 225 } 226 m_pTextEdit->setBookmarkLineSet(bookmarkLinesSet); 227 } 228 220 229 // void UIVMLogViewerWidget::sltCreateBookmarkAtCurrent() 221 230 // { -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r70554 r70559 99 99 void cleanup(); 100 100 void retranslateUi(); 101 void updateTextEditBookmarkLineSet(); 101 102 102 103 QHBoxLayout *m_pMainLayout; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r70556 r70559 201 201 if (block.isVisible() && bottom >= event->rect().top()) { 202 202 QString number = QString::number(blockNumber + 1); 203 if (m_bookmarkLineSet.contains(blockNumber + 1)) 204 { 205 painter.setBackgroundMode(Qt::OpaqueMode); 206 painter.setBackground(QBrush(Qt::red)); 207 } 208 else 209 { 210 painter.setBackgroundMode(Qt::TransparentMode); 211 } 203 212 painter.setPen(Qt::black); 204 213 painter.drawText(0, top, m_pLineNumberArea->width(), m_pLineNumberArea->fontMetrics().lineSpacing(), … … 275 284 } 276 285 286 void UIVMLogViewerTextEdit::scrollToLine(int lineNumber) 287 { 288 QTextDocument* pDocument = document(); 289 if(!pDocument) 290 return; 291 292 int halfPageLineCount = 0.5 * visibleLineCount() ; 293 QTextCursor cursor(pDocument->findBlockByLineNumber(qMax(lineNumber - halfPageLineCount, 0))); 294 moveCursor(QTextCursor::End); 295 setTextCursor(cursor); 296 } 297 298 int UIVMLogViewerTextEdit::visibleLineCount() 299 { 300 int height = 0; 301 if(viewport()) 302 height = viewport()->height(); 303 if(verticalScrollBar() && verticalScrollBar()->isVisible()) 304 height -= horizontalScrollBar()->height(); 305 int singleLineHeight = fontMetrics().lineSpacing(); 306 if(singleLineHeight == 0) 307 return 0; 308 return height / singleLineHeight; 309 } 310 311 void UIVMLogViewerTextEdit::setBookmarkLineSet(const QSet<int>& lineSet) 312 { 313 m_bookmarkLineSet = lineSet; 314 repaint(); 315 } 277 316 278 317 #include "UIVMLogViewerTextEdit.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h
r70554 r70559 44 44 void clearScrollBarMarkingsVector(); 45 45 46 void scrollToLine(int lineNumber); 47 48 void setBookmarkLineSet(const QSet<int>& lineSet); 49 46 50 protected: 47 51 … … 54 58 void sltUpdateLineNumberAreaWidth(int newBlockCount); 55 59 void sltUpdateLineNumberArea(const QRect &, int); 60 int visibleLineCount(); 56 61 57 62 private: … … 63 68 QPair<int, QString> m_iContextMenuBookmark; 64 69 QWidget *m_pLineNumberArea; 70 QSet<int> m_bookmarkLineSet; 65 71 }; 66 72 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70549 r70559 132 132 if(!currentLogPage() || !m_pBookmarksPanel) 133 133 return; 134 disconnect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected, 135 this, &UIVMLogViewerWidget::gotoBookmark); 134 136 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector()); 137 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected, 138 this, &UIVMLogViewerWidget::gotoBookmark); 135 139 } 136 140
Note:
See TracChangeset
for help on using the changeset viewer.