Changeset 70578 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 13, 2018 7:32:04 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
r70574 r70578 43 43 , m_pTextEdit(0) 44 44 , m_tabIndex(tabIndex) 45 , m_bFiltered(false) 45 46 { 46 47 prepare(); … … 193 194 for(int i = 0; i < m_bookmarkVector.size(); ++i) 194 195 { 195 if(m_bookmarkVector.at(i).first )196 if(m_bookmarkVector.at(i).first == bookmark.first) 196 197 { 197 198 index = i; … … 252 253 } 253 254 254 // void UIVMLogViewerWidget::sltCreateBookmarkAtCurrent() 255 // { 256 // if (!currentTextEdit()) 257 // return; 258 // QWidget* viewport = currentTextEdit()->viewport(); 259 // if (!viewport) 260 // return; 261 // QPoint point(0.5 * viewport->width(), 0.5 * viewport->height()); 262 // QTextBlock block = currentTextEdit()->cursorForPosition(point).block(); 263 // LogBookmark bookmark; 264 // bookmark.first = block.firstLineNumber(); 265 // bookmark.second = block.text(); 266 // sltCreateBookmarkAtLine(bookmark); 267 //} 255 bool UIVMLogPage::isFiltered() const 256 { 257 return m_bFiltered; 258 } 259 260 void UIVMLogPage::setFiltered(bool filtered) 261 { 262 if(m_bFiltered == filtered) 263 return; 264 m_bFiltered = filtered; 265 if(m_pTextEdit) 266 { 267 m_pTextEdit->setShownTextIsFiltered(m_bFiltered); 268 m_pTextEdit->update(); 269 } 270 emit sigLogPageFilteredChanged(m_bFiltered); 271 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r70574 r70578 45 45 46 46 void sigBookmarksUpdated(); 47 void sigLogPageFilteredChanged(bool isFiltered); 47 48 48 49 public: … … 82 83 83 84 void deleteBookmark(int index); 84 void deleteBookmark(LogBookmark bookmark);85 85 86 86 const QVector<LogBookmark>& bookmarkVector() const; … … 89 89 void scrollToBookmark(int bookmarkIndex); 90 90 91 protected: 91 bool isFiltered() const; 92 void setFiltered(bool filtered); 92 93 93 94 private slots: … … 97 98 98 99 private: 100 99 101 void prepare(); 100 102 void prepareWidgets(); … … 102 104 void retranslateUi(); 103 105 void updateTextEditBookmarkLineSet(); 106 void deleteBookmark(LogBookmark bookmark); 104 107 105 108 QHBoxLayout *m_pMainLayout; … … 111 114 /** This is the index of the tab containing this widget in UIVMLogViewerWidget. */ 112 115 int m_tabIndex; 113 116 /** Stores the bookmarks of the logpage. All other bookmark related containers are updated wrt. this one. */ 114 117 QVector<LogBookmark> m_bookmarkVector; 115 118 /** Designates whether currently displayed text is log text or a filtered version of it. That is 119 if m_bFiltered is false than (m_strLog == m_pTextEdit->text()). */ 120 bool m_bFiltered; 116 121 }; 117 122 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp
r70539 r70578 217 217 { 218 218 document->setPlainText(*originalLogString); 219 emit sigFilterApplied( );219 emit sigFilterApplied(true /* isOriginalLog */); 220 220 m_iFilteredLineCount = document->lineCount(); 221 221 return; … … 245 245 pCurrentTextEdit->setTextCursor(cursor); 246 246 247 emit sigFilterApplied( );247 emit sigFilterApplied(false /* isOriginalLog */); 248 248 } 249 249 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h
r70500 r70578 42 42 signals: 43 43 44 /* Notifies listeners that the filter has been applied. */ 45 void sigFilterApplied(); 44 /* Notifies listeners that the filter has been applied. @a isOriginalLog is true 45 if filter function returns early for some reason (no filter term etc.) and log page 46 content is set to original log file. @a isOriginalLog is false if content is reduced (filtered)*/ 47 void sigFilterApplied(bool isOriginalLog); 46 48 47 49 public: -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r70574 r70578 153 153 , m_pLineNumberArea(0) 154 154 , m_mouseCursorLine(-1) 155 , m_bShownTextIsFiltered(false) 155 156 { 156 157 setMouseTracking(true); … … 219 220 if (block.isVisible() && bottom >= event->rect().top()) { 220 221 QString number = QString::number(blockNumber + 1); 221 if (m_bookmarkLineSet.contains(blockNumber + 1)) 222 /* Mark this line if it is bookmarked, but only if the text is not filtered. */ 223 if (m_bookmarkLineSet.contains(blockNumber + 1) && !m_bShownTextIsFiltered) 222 224 { 223 225 QPainterPath path; … … 245 247 void UIVMLogViewerTextEdit::contextMenuEvent(QContextMenuEvent *pEvent) 246 248 { 249 /* If shown text is filtered, do not create Bookmark action since 250 we disable all bookmarking related functionalities in this case. */ 251 if(m_bShownTextIsFiltered) 252 { 253 QPlainTextEdit::contextMenuEvent(pEvent); 254 return; 255 } 256 247 257 QMenu *menu = createStandardContextMenu(); 248 258 QAction *pAction = menu->addAction(tr("Bookmark")); … … 257 267 258 268 delete menu; 269 } 270 271 void UIVMLogViewerTextEdit::paintEvent(QPaintEvent *pEvent) 272 { 273 QPlainTextEdit::paintEvent(pEvent); 274 if (m_bShownTextIsFiltered && viewport()) 275 { 276 int rectHeight = 24; 277 int rectWidth = 84; 278 int rectX = viewport()->width() - rectWidth; 279 int rectMargin = 4; 280 if(verticalScrollBar()) 281 rectX -= verticalScrollBar()->width(); 282 QPainter painter(viewport()); 283 painter.fillRect(rectX, 0, rectWidth, rectHeight, QColor(125, 125, 125, 100)); 284 QFont nFont(painter.font()); 285 nFont.setPixelSize(rectHeight- 2 * rectMargin) ; 286 painter.setFont(nFont); 287 painter.setPen(QPen(QColor(255, 0, 0, 175), 1.8f)); 288 painter.drawText(rectX + rectMargin, rectMargin, rectWidth, rectHeight, 289 Qt::AlignLeft, "Filtered"); 290 viewport()->update(); 291 } 259 292 } 260 293 … … 359 392 void UIVMLogViewerTextEdit::toggleBookmark(const QPair<int, QString>& bookmark) 360 393 { 394 if(m_bShownTextIsFiltered) 395 return; 396 361 397 int lineNumber = bookmark.first; 362 398 … … 367 403 } 368 404 405 void UIVMLogViewerTextEdit::setShownTextIsFiltered(bool warning) 406 { 407 if(m_bShownTextIsFiltered == warning) 408 return; 409 m_bShownTextIsFiltered = warning; 410 } 411 369 412 #include "UIVMLogViewerTextEdit.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h
r70574 r70578 25 25 26 26 /* QPlainTextEdit extension for some addtional context menu items, 27 a special scrollbar, line number area, and bookmark support: */27 a special scrollbar, line number area, and bookmarking support: */ 28 28 class UIVMLogViewerTextEdit : public QPlainTextEdit 29 29 { … … 46 46 47 47 void scrollToLine(int lineNumber); 48 49 48 void setBookmarkLineSet(const QSet<int>& lineSet); 49 void setShownTextIsFiltered(bool warning); 50 50 51 51 protected: 52 52 53 void contextMenuEvent(QContextMenuEvent *pEvent) /* override */; 54 void resizeEvent(QResizeEvent *pEvent) /* override */; 55 void mouseMoveEvent(QMouseEvent *pEvent) /* override */; 53 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 54 virtual void contextMenuEvent(QContextMenuEvent *pEvent) /* override */; 55 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 56 virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */; 56 57 57 58 private slots: … … 79 80 /** Number of the line under the mouse cursor. */ 80 81 int m_mouseCursorLine; 81 82 /** If true the we draw a text near the top right corner of the text edit to warn 83 the user the text edit's content is filtered (as oppesed to whole log file content. 84 And we dont display bookmarks and adding/deleting bookmarks are disabled. */ 85 bool m_bShownTextIsFiltered; 82 86 friend class UILineNumberArea; 83 87 }; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70559 r70578 128 128 } 129 129 130 void UIVMLogViewerWidget::slt BoomarksUpdated()130 void UIVMLogViewerWidget::sltUpdateBookmarkPanel() 131 131 { 132 132 if(!currentLogPage() || !m_pBookmarksPanel) … … 275 275 } 276 276 277 void UIVMLogViewerWidget::sltFilterApplied() 278 { 277 void UIVMLogViewerWidget::sltFilterApplied(bool isOriginal) 278 { 279 if(currentLogPage()) 280 currentLogPage()->setFiltered(!isOriginal); 279 281 /* Reapply the search to get highlighting etc. correctly */ 280 282 if (m_pSearchPanel && m_pSearchPanel->isVisible()) 281 283 m_pSearchPanel->refresh(); 284 } 285 286 void UIVMLogViewerWidget::sltLogPageFilteredChanged(bool isFiltered) 287 { 288 /* Disable bookmark panel since bookmarks are stored as line numbers within 289 the original log text and does not mean much in a reduced/filtered one. */ 290 if(m_pBookmarksPanel) 291 { 292 if(isFiltered) 293 { 294 m_pBookmarksPanel->setEnabled(false); 295 m_pBookmarksPanel->setVisible(false); 296 } 297 else 298 m_pBookmarksPanel->setEnabled(true); 299 } 282 300 } 283 301 … … 743 761 /* Create page-container: */ 744 762 UIVMLogPage* pLogPage = new UIVMLogPage(this); 745 connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltBoomarksUpdated); 763 connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltUpdateBookmarkPanel); 764 connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIVMLogViewerWidget::sltLogPageFilteredChanged); 746 765 AssertPtrReturnVoid(pLogPage); 747 766 /* Set the file name only if we really have log file to read. */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70549 r70578 98 98 void sltDeleteAllBookmarks(); 99 99 /** Manages bookmark panel update when bookmark vector is updated */ 100 void slt BoomarksUpdated();100 void sltUpdateBookmarkPanel(); 101 101 /* Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */ 102 102 void gotoBookmark(int bookmarkIndex); … … 108 108 /** Handles the tab change of the logviewer. */ 109 109 void sltTabIndexChange(int tabIndex); 110 void sltFilterApplied(); 110 /* if @a isOriginal true than the result of the filtering is equal to 111 the original log file for some reason. */ 112 void sltFilterApplied(bool isOriginal); 113 /* Handles the UIVMLogPage signal which is emitted when isFiltered property 114 of UIVMLogPage is changed. */ 115 void sltLogPageFilteredChanged(bool isFiltered); 111 116 112 117 private:
Note:
See TracChangeset
for help on using the changeset viewer.