Changeset 70549 in vbox
- Timestamp:
- Jan 12, 2018 7:46:15 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
r70539 r70549 168 168 169 169 private slots: 170 /// remove 170 171 171 void sltBookmark() 172 172 { … … 212 212 { 213 213 prepareWidgets(); 214 // prepareActions();215 216 // prepareToolBar();217 // prepareMenu();218 219 // /* Reading log files: */220 // sltRefresh();221 222 // /* Loading language constants: */223 214 retranslateUi(); 224 215 } … … 250 241 m_pPlainTextEdit->setWordWrapMode(QTextOption::NoWrap); 251 242 m_pPlainTextEdit->setReadOnly(true); 252 243 connect(qobject_cast<UIVMLogViewerTextEdit*>(m_pPlainTextEdit), &UIVMLogViewerTextEdit::sigContextMenuBookmarkAction, 244 this, &UIVMLogPage::sltAddBookmark); 253 245 } 254 246 … … 348 340 } 349 341 342 343 void UIVMLogPage::deleteBookmark(int index) 344 { 345 if (m_bookmarkVector.size() <= index) 346 return; 347 m_bookmarkVector.remove(index, 1); 348 } 349 350 void UIVMLogPage::deleteAllBookmarks() 351 { 352 m_bookmarkVector.clear(); 353 } 354 355 void UIVMLogPage::scrollToBookmark(int bookmarkIndex) 356 { 357 if(!m_pPlainTextEdit) 358 return; 359 if (bookmarkIndex >= m_bookmarkVector.size()) 360 return; 361 362 int lineNumber = m_bookmarkVector.at(bookmarkIndex).first; 363 QTextDocument* document = m_pPlainTextEdit->document(); 364 if(!document) 365 return; 366 367 QTextCursor cursor(document->findBlockByLineNumber(lineNumber)); 368 m_pPlainTextEdit->setTextCursor(cursor); 369 } 370 371 const QVector<LogBookmark>& UIVMLogPage::bookmarkVector() const 372 { 373 return m_bookmarkVector; 374 } 375 376 void UIVMLogPage::sltAddBookmark(LogBookmark bookmark) 377 { 378 m_bookmarkVector.push_back(bookmark); 379 emit sigBookmarksUpdated(); 380 } 381 // void UIVMLogViewerWidget::sltCreateBookmarkAtCurrent() 382 // { 383 // if (!currentTextEdit()) 384 // return; 385 // QWidget* viewport = currentTextEdit()->viewport(); 386 // if (!viewport) 387 // return; 388 // QPoint point(0.5 * viewport->width(), 0.5 * viewport->height()); 389 // QTextBlock block = currentTextEdit()->cursorForPosition(point).block(); 390 // LogBookmark bookmark; 391 // bookmark.first = block.firstLineNumber(); 392 // bookmark.second = block.text(); 393 // sltCreateBookmarkAtLine(bookmark); 394 //} 395 396 350 397 #include "UIVMLogPage.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r70539 r70549 50 50 Q_OBJECT; 51 51 52 signals: 53 54 void sigBookmarksUpdated(); 55 52 56 public: 53 57 … … 76 80 void setTextEdit(const QString &strText); 77 81 78 /* Marks the plain text edit When we dont have a log content. */82 /** Marks the plain text edit When we dont have a log content. */ 79 83 void markForError(); 80 84 … … 82 86 void clearScrollBarMarkingsVector(); 83 87 84 /* Undos the changes done to textDocument */88 /** Undos the changes done to textDocument */ 85 89 void documentUndo(); 90 91 void deleteBookmark(int index); 92 93 const QVector<LogBookmark>& bookmarkVector() const; 94 void deleteAllBookmarks(); 95 /** Scrolls the plain text edit to the bookmark with index @a bookmarkIndex. */ 96 void scrollToBookmark(int bookmarkIndex); 86 97 87 98 protected: … … 89 100 private slots: 90 101 102 void sltAddBookmark(LogBookmark bookmark); 91 103 92 104 private: … … 105 117 int m_tabIndex; 106 118 107 QVector<LogBookmark> m_bookmark Map;119 QVector<LogBookmark> m_bookmarkVector; 108 120 109 121 }; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.cpp
r70529 r70549 48 48 } 49 49 50 void UIVMLogViewerBookmarksPanel::updateBookmarkList(const QVector<QPair<int, QString> > *bookmarkVector)50 void UIVMLogViewerBookmarksPanel::updateBookmarkList(const QVector<QPair<int, QString> > &bookmarkVector) 51 51 { 52 52 if (!m_pBookmarksComboBox || !viewer()) 53 return;54 if (!bookmarkVector)55 53 return; 56 54 … … 58 56 QStringList bList; 59 57 bList << "Bookmarks List"; 60 for(int i = 0; i < bookmarkVector ->size(); ++i)58 for(int i = 0; i < bookmarkVector.size(); ++i) 61 59 { 62 60 QString strItem = QString("BookMark %1 at Line %2: %3").arg(QString::number(i)). 63 arg(QString::number(bookmarkVector ->at(i).first)).arg(bookmarkVector->at(i).second);61 arg(QString::number(bookmarkVector.at(i).first)).arg(bookmarkVector.at(i).second); 64 62 65 63 if (strItem.length() > m_iMaxBookmarkTextLength) -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.h
r70529 r70549 50 50 user switches to another log page tab etc. */ 51 51 void setBookmarksList(const QVector<QPair<int, QString> > &bookmarkList); 52 void updateBookmarkList(const QVector<QPair<int, QString> > *bookmarkVector);52 void updateBookmarkList(const QVector<QPair<int, QString> > &bookmarkVector); 53 53 54 54 public slots: -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70542 r70549 107 107 } 108 108 109 void UIVMLogViewerWidget::sltDeleteBookmark(int /*index*/)110 { 111 // QVector<LogBookmark>* bookmarkVector = currentBookmarkVector();112 // if (!bookmarkVector || bookmarkVector->size() <= index)113 //return;114 // bookmarkVector->remove(index, 1);115 //if (m_pBookmarksPanel)116 // m_pBookmarksPanel->updateBookmarkList(bookmarkVector);109 void UIVMLogViewerWidget::sltDeleteBookmark(int index) 110 { 111 UIVMLogPage* logPage = currentLogPage(); 112 if(!logPage) 113 return; 114 logPage->deleteBookmark(index); 115 if (m_pBookmarksPanel) 116 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector()); 117 117 } 118 118 119 119 void UIVMLogViewerWidget::sltDeleteAllBookmarks() 120 120 { 121 // QVector<LogBookmark>* bookmarkVector = currentBookmarkVector(); 122 // if (!bookmarkVector) 123 // return; 124 // bookmarkVector->clear(); 125 // if (m_pBookmarksPanel) 126 // m_pBookmarksPanel->updateBookmarkList(bookmarkVector); 127 } 128 129 void UIVMLogViewerWidget::sltBookmarkSelected(int /*index*/) 130 { 131 // QVector<LogBookmark>* bookmarkVector = currentBookmarkVector(); 132 // if (!bookmarkVector || index >= bookmarkVector->size()) 133 // return; 134 // if (!currentLogPage() || !currentLogPage()->document()) 135 // return; 136 137 // int lineNumber = bookmarkVector->at(index).first; 138 // QTextCursor cursor(currentLogPage()->document()->findBlockByLineNumber(lineNumber)); 139 // currentLogPage()->setTextCursor(cursor); 140 121 UIVMLogPage* logPage = currentLogPage(); 122 if(!logPage) 123 return; 124 logPage->deleteAllBookmarks(); 125 126 if (m_pBookmarksPanel) 127 m_pBookmarksPanel->updateBookmarkList(logPage->bookmarkVector()); 128 } 129 130 void UIVMLogViewerWidget::sltBoomarksUpdated() 131 { 132 if(!currentLogPage() || !m_pBookmarksPanel) 133 return; 134 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector()); 135 } 136 137 void UIVMLogViewerWidget::gotoBookmark(int bookmarkIndex) 138 { 139 if(!currentLogPage()) 140 return; 141 currentLogPage()->scrollToBookmark(bookmarkIndex); 141 142 } 142 143 … … 168 169 disconnect(m_pTabWidget, &QITabWidget::currentChanged, this, &UIVMLogViewerWidget::sltTabIndexChange); 169 170 170 // m_logMap.clear();171 171 m_logPageList.clear(); 172 172 m_pTabWidget->setEnabled(true); … … 262 262 263 263 resetHighlighthing(); 264 //if (m_pSearchPanel)265 //m_pSearchPanel->reset();264 if (m_pSearchPanel) 265 m_pSearchPanel->reset(); 266 266 // m_iCurrentTabIndex = tabIndex; 267 267 268 /* We keep a separate QVector<LogBookmark> for each log page: */ 268 // QVector<LogBookmark>* bookmarkVector = currentBookmarkVector(); 269 // if (bookmarkVector && m_pBookmarksPanel) 270 // m_pBookmarksPanel->updateBookmarkList(bookmarkVector); 269 if (m_pBookmarksPanel && currentLogPage()) 270 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector()); 271 271 } 272 272 … … 276 276 if (m_pSearchPanel && m_pSearchPanel->isVisible()) 277 277 m_pSearchPanel->refresh(); 278 }279 280 void UIVMLogViewerWidget::sltCreateBookmarkAtCurrent()281 {282 // if (!currentTextEdit())283 // return;284 // QWidget* viewport = currentTextEdit()->viewport();285 // if (!viewport)286 // return;287 // QPoint point(0.5 * viewport->width(), 0.5 * viewport->height());288 // QTextBlock block = currentTextEdit()->cursorForPosition(point).block();289 // LogBookmark bookmark;290 // bookmark.first = block.firstLineNumber();291 // bookmark.second = block.text();292 // sltCreateBookmarkAtLine(bookmark);293 }294 295 void UIVMLogViewerWidget::sltCreateBookmarkAtLine(LogBookmark bookmark)296 {297 Q_UNUSED(bookmark);298 // QVector<LogBookmark> *pBookmarkVector = currentBookmarkVector();299 // if (!pBookmarkVector)300 // return;301 // pBookmarkVector->push_back(bookmark);302 // if (m_pBookmarksPanel)303 // m_pBookmarksPanel->updateBookmarkList(pBookmarkVector);304 278 } 305 279 … … 391 365 this, &UIVMLogViewerWidget::sltDeleteAllBookmarks); 392 366 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected, 393 this, &UIVMLogViewerWidget:: sltBookmarkSelected);367 this, &UIVMLogViewerWidget::gotoBookmark); 394 368 } 395 369 } … … 610 584 611 585 /* Make sure the log view widget has the focus: */ 612 // QWidget *pCurrentLogPage = currentTextEdit(); 613 // if (pCurrentLogPage) 614 // pCurrentLogPage->setFocus(); 586 if(currentLogPage()) 587 currentLogPage()->setFocus(); 615 588 } 616 589 … … 666 639 } 667 640 668 // const QVector<LogBookmark>* UIVMLogViewerWidget::currentBookmarkVector() const669 // {670 // UIVMLogViewerTextEdit *logPage = qobject_cast<UIVMLogViewerTextEdit*>(currentLogPage());671 // if (!logPage)672 // return 0;673 // QString logFileName = logPage->logFileName();674 // if (logFileName.isEmpty())675 // return 0;676 677 // return &(m_bookmarkMap[logFileName]);678 // }679 680 // QVector<LogBookmark>* UIVMLogViewerWidget::currentBookmarkVector()681 // {682 // UIVMLogViewerTextEdit *logPage = qobject_cast<UIVMLogViewerTextEdit*>(currentLogPage());683 // if (!logPage)684 // return 0;685 // QString logFileName = logPage->logFileName();686 // if (logFileName.isEmpty())687 // return 0;688 689 // return &(m_bookmarkMap[logFileName]);690 // }691 692 641 void UIVMLogViewerWidget::hidePanel(UIVMLogViewerPanel* panel) 693 642 { … … 790 739 /* Create page-container: */ 791 740 UIVMLogPage* pLogPage = new UIVMLogPage(this); 741 connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltBoomarksUpdated); 792 742 AssertPtrReturnVoid(pLogPage); 793 743 /* Set the file name only if we really have log file to read. */ … … 818 768 logPage->documentUndo(); 819 769 logPage->clearScrollBarMarkingsVector(); 820 // QPlainTextEdit *pTextEdit = logPage(m_iCurrentTabIndex); 821 // if (pTextEdit) 822 // { 823 // QTextDocument *pDocument = pTextEdit->document(); 824 // if (pDocument) 825 // pDocument->undo(); 826 // } 827 // UIIndicatorScrollBar* scrollBar = qobject_cast<UIIndicatorScrollBar*>(pTextEdit->verticalScrollBar()); 828 // if (scrollBar) 829 // { 830 // scrollBar->setMarkingsVector(QVector<float>()); 831 // pTextEdit->repaint(); 832 // } 833 } 770 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70539 r70549 95 95 /** Deletes the bookmark with @p index from the current logs bookmark list. */ 96 96 void sltDeleteBookmark(int index); 97 /** Receives delete all signal from the bookmark panel and notifies UIVMLogPage. */ 97 98 void sltDeleteAllBookmarks(); 98 /** Scroll the plain text edit to the selected bookmark. */ 99 void sltBookmarkSelected(int index); 100 /** Creates a bookmark out of line number and block text. */ 101 void sltCreateBookmarkAtLine(QPair<int, QString> bookmark); 102 /** Determines the (middle) line number of the visible text and calls sltCreateBookmarkAtLine. */ 103 void sltCreateBookmarkAtCurrent(); 99 /** Manages bookmark panel update when bookmark vector is updated */ 100 void sltBoomarksUpdated(); 101 /* Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */ 102 void gotoBookmark(int bookmarkIndex); 104 103 /** @} */ 105 104
Note:
See TracChangeset
for help on using the changeset viewer.