Changeset 70529 in vbox
- Timestamp:
- Jan 11, 2018 7:46:27 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120199
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.cpp
r70500 r70529 27 27 # endif 28 28 # include <QLabel> 29 # include <QLineEdit>30 # include <QPlainTextEdit>31 29 # include <QPushButton> 32 # include <QTextCursor> 33 # include <QToolButton> 34 # include <QScrollArea> 35 30 # include <QSpacerItem> 36 31 /* GUI includes: */ 37 # include "UIIconPool.h" 38 # include "UISpecialControls.h" 32 # include "QIToolButton.h" 39 33 # include "UIVMLogViewerBookmarksPanel.h" 40 34 # include "UIVMLogViewerWidget.h" 41 # ifdef VBOX_WS_MAC 42 # include "VBoxUtils-darwin.h" 43 # endif 35 44 36 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 45 37 … … 49 41 , m_iMaxBookmarkTextLength(60) 50 42 , m_pBookmarksComboBox(0) 51 , m_clearAllButton(0) 52 , m_clearCurrentButton(0) 43 , m_pDeleteAllButton(0) 44 , m_pDeleteCurrentButton(0) 45 , m_pSpacerItem(0) 53 46 { 54 47 prepare(); 55 48 } 56 49 57 void UIVMLogViewerBookmarksPanel::updateBookmarkList( )50 void UIVMLogViewerBookmarksPanel::updateBookmarkList(const QVector<QPair<int, QString> > *bookmarkVector) 58 51 { 59 52 if (!m_pBookmarksComboBox || !viewer()) 60 53 return; 61 const QVector<QPair<int, QString> > *bookmarkVector = viewer()->currentBookmarkVector();62 54 if (!bookmarkVector) 63 55 return; … … 65 57 m_pBookmarksComboBox->clear(); 66 58 QStringList bList; 59 bList << "Bookmarks List"; 67 60 for(int i = 0; i < bookmarkVector->size(); ++i) 68 61 { … … 78 71 } 79 72 m_pBookmarksComboBox->addItems(bList); 73 /* Goto last item of the combobox: */ 74 m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->count()-1); 80 75 } 81 76 … … 84 79 if (!m_pBookmarksComboBox) 85 80 return; 86 if (index >= m_pBookmarksComboBox->count()) 81 /* If there is only Title of the combo, then goto that item: */ 82 if (m_pBookmarksComboBox->count() == 1 || index >= m_pBookmarksComboBox->count()) 83 { 84 m_pBookmarksComboBox->setCurrentIndex(0); 87 85 return; 88 m_pBookmarksComboBox->setCurrentIndex(index); 86 } 87 /* index+1 since we always have a 0th item in our combo box. */ 88 m_pBookmarksComboBox->setCurrentIndex(index+1); 89 89 } 90 90 … … 99 99 m_pBookmarksComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); 100 100 m_pBookmarksComboBox->setMaximumWidth(fontMetrics.width('a') * (m_iMaxBookmarkTextLength + 2)); 101 mainLayout()->addWidget(m_pBookmarksComboBox, 2, Qt::AlignLeft); 101 /* Make sure we have 0th item in our combo box. */ 102 m_pBookmarksComboBox->insertItem(0, "Bookmarks List"); 103 104 105 mainLayout()->addWidget(m_pBookmarksComboBox, 2/*, Qt::AlignLeft*/); 106 107 m_pDeleteCurrentButton = new QIToolButton(this); 108 m_pDeleteCurrentButton->setIcon(m_pDeleteCurrentButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton)); 109 110 AssertPtrReturnVoid(m_pBookmarksComboBox); 111 mainLayout()->addWidget(m_pDeleteCurrentButton, 0); 112 113 m_pDeleteAllButton = new QPushButton(this); 114 AssertPtrReturnVoid(m_pDeleteAllButton); 115 mainLayout()->addWidget(m_pDeleteAllButton, 0); 116 117 118 m_pSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 119 AssertPtrReturnVoid(m_pSpacerItem); 120 mainLayout()->addItem(m_pSpacerItem); 102 121 } 103 122 104 123 void UIVMLogViewerBookmarksPanel::prepareConnections() 105 124 { 125 connect(m_pBookmarksComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 126 this, &UIVMLogViewerBookmarksPanel::sltBookmarkSelected); 127 128 connect(m_pDeleteAllButton, &QPushButton::clicked, this, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks); 129 connect(m_pDeleteCurrentButton, &QIToolButton::clicked, this, &UIVMLogViewerBookmarksPanel::sltDeleteCurrentBookmark); 106 130 } 107 131 … … 109 133 void UIVMLogViewerBookmarksPanel::retranslateUi() 110 134 { 135 if (m_pDeleteCurrentButton) 136 m_pDeleteCurrentButton->setToolTip(UIVMLogViewerWidget::tr("Delete the current bookmark.")); 137 if (m_pDeleteAllButton) 138 { 139 m_pDeleteAllButton->setToolTip(UIVMLogViewerWidget::tr("Delete all bookmarks.")); 140 m_pDeleteAllButton->setText(UIVMLogViewerWidget::tr("Delete all")); 141 } 111 142 UIVMLogViewerPanel::retranslateUi(); 112 143 } 144 145 void UIVMLogViewerBookmarksPanel::sltDeleteCurrentBookmark() 146 { 147 if (!m_pBookmarksComboBox) 148 return; 149 150 if (m_pBookmarksComboBox->currentIndex() == 0) 151 return; 152 emit sigDeleteBookmark(m_pBookmarksComboBox->currentIndex() - 1); 153 } 154 155 void UIVMLogViewerBookmarksPanel::sltBookmarkSelected(int index) 156 { 157 /* Do nothing if the index is 0, that is combo box title item: */ 158 if (index <= 0) 159 return; 160 emit sigBookmarkSelected(index - 1); 161 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.h
r70500 r70529 25 25 class QComboBox; 26 26 class QPushButton; 27 28 29 27 class QSpacerItem; 28 class QIToolButton; 30 29 31 30 /** UIVMLogViewerPanel extension providing GUI for bookmark management. Show a list of bookmarks currently set … … 36 35 37 36 signals: 37 38 void sigDeleteBookmark(int bookmarkIndex); 39 void sigDeleteAllBookmarks(); 40 void sigBookmarkSelected(int index); 38 41 39 42 public: … … 47 50 user switches to another log page tab etc. */ 48 51 void setBookmarksList(const QVector<QPair<int, QString> > &bookmarkList); 49 void updateBookmarkList(); 50 /* @a index is the index of the curent bookmark. */ 51 void setBookmarkIndex(int index); 52 void updateBookmarkList(const QVector<QPair<int, QString> > *bookmarkVector); 52 53 53 54 public slots: … … 63 64 private slots: 64 65 66 void sltDeleteCurrentBookmark(); 67 void sltBookmarkSelected(int index); 68 65 69 private: 70 71 /* @a index is the index of the curent bookmark. */ 72 void setBookmarkIndex(int index); 66 73 67 74 const int m_iMaxBookmarkTextLength; 68 75 QComboBox *m_pBookmarksComboBox; 69 QPushButton *m_clearAllButton; 70 QPushButton *m_clearCurrentButton; 76 QPushButton *m_pDeleteAllButton; 77 QIToolButton *m_pDeleteCurrentButton; 78 QSpacerItem *m_pSpacerItem; 71 79 }; 72 80 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.cpp
r70519 r70529 120 120 if (pFocus && pFocus->parent() == this) 121 121 focusNextPrevChild(true); 122 if (m_pViewer)122 if (m_pViewer) 123 123 m_pViewer->hidePanel(this); 124 124 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70523 r70529 54 54 /** We use a modified scrollbar style for our QPlainTextEdits to get the 55 55 markings on the scrollbars correctly. The default scrollbarstyle does not 56 reveal the height of the pushbuttons on the scrollbar to compute the marking57 locations correctlt. so we turn themoff: */56 reveal the height of the pushbuttons on the scrollbar (on either side of it, with arrow on them) 57 to compute the marking locations correctly. Thus we turn these push buttons off: */ 58 58 const QString verticalScrollBarStyle("QScrollBar:vertical {" 59 59 "border: 1px ridge grey; " … … 114 114 115 115 private: 116 116 117 /* Stores the relative (to scrollbar's height) positions of markings, 117 where we draw a horizontal line. */118 where we draw a horizontal line. Values are in [0.0, 1.0]*/ 118 119 QVector<float> m_markingsVector; 119 120 }; … … 201 202 , m_pActionBookmark(0) 202 203 , m_pMenu(0) 204 , m_bMarkBookmarkLines(0) 203 205 { 204 206 /* Prepare VM Log-Viewer: */ … … 237 239 } 238 240 241 void UIVMLogViewerWidget::sltDeleteBookmark(int index) 242 { 243 QVector<LogBookmark>* bookmarkVector = currentBookmarkVector(); 244 if(!bookmarkVector || bookmarkVector->size() <= index) 245 return; 246 bookmarkVector->remove(index, 1); 247 if (m_pBookmarksPanel) 248 m_pBookmarksPanel->updateBookmarkList(bookmarkVector); 249 } 250 251 void UIVMLogViewerWidget::sltDeleteAllBookmarks() 252 { 253 QVector<LogBookmark>* bookmarkVector = currentBookmarkVector(); 254 if(!bookmarkVector) 255 return; 256 bookmarkVector->clear(); 257 if (m_pBookmarksPanel) 258 m_pBookmarksPanel->updateBookmarkList(bookmarkVector); 259 } 260 261 void UIVMLogViewerWidget::sltBookmarkSelected(int index) 262 { 263 QVector<LogBookmark>* bookmarkVector = currentBookmarkVector(); 264 if(!bookmarkVector || index >= bookmarkVector->size()) 265 return; 266 if(!currentLogPage() || !currentLogPage()->document()) 267 return; 268 269 int lineNumber = bookmarkVector->at(index).first; 270 QTextCursor cursor(currentLogPage()->document()->findBlockByLineNumber(lineNumber)); 271 currentLogPage()->setTextCursor(cursor); 272 273 } 274 239 275 void UIVMLogViewerWidget::sltPanelActionTriggered(bool checked) 240 276 { 241 277 QAction *pSenderAction = qobject_cast<QAction*>(sender()); 242 if (!pSenderAction)278 if (!pSenderAction) 243 279 return; 244 280 UIVMLogViewerPanel* pPanel = 0; 245 281 /* Look for the sender() within the m_panelActionMap's values: */ 246 for (QMap<UIVMLogViewerPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin();282 for (QMap<UIVMLogViewerPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin(); 247 283 iterator != m_panelActionMap.end(); ++iterator) 248 284 { 249 if (iterator.value() == pSenderAction)285 if (iterator.value() == pSenderAction) 250 286 pPanel = iterator.key(); 251 287 } 252 if (!pPanel)253 return; 254 if (checked)288 if (!pPanel) 289 return; 290 if (checked) 255 291 showPanel(pPanel); 256 292 else 257 293 hidePanel(pPanel); 258 }259 260 void UIVMLogViewerWidget::sltShowHideSearchPanel()261 {262 if (!m_pSearchPanel)263 return;264 /* Show/hide search-panel: */265 m_pSearchPanel->isHidden() ? m_pSearchPanel->show() : m_pSearchPanel->hide();266 294 } 267 295 … … 371 399 } 372 400 373 void UIVMLogViewerWidget::sltShowHideFilterPanel()374 {375 if (!m_pFilterPanel)376 return;377 /* Show/hide filter-panel: */378 m_pFilterPanel->isHidden() ? m_pFilterPanel->show() : m_pFilterPanel->hide();379 }380 381 401 void UIVMLogViewerWidget::sltSearchResultHighLigting() 382 402 { … … 402 422 m_pSearchPanel->reset(); 403 423 m_iCurrentTabIndex = tabIndex; 424 /* We keep a separate QVector<LogBookmark> for each log page: */ 425 QVector<LogBookmark>* bookmarkVector = currentBookmarkVector(); 426 if(bookmarkVector && m_pBookmarksPanel) 427 m_pBookmarksPanel->updateBookmarkList(bookmarkVector); 404 428 } 405 429 … … 409 433 if (m_pSearchPanel && m_pSearchPanel->isVisible()) 410 434 m_pSearchPanel->refresh(); 411 }412 413 void UIVMLogViewerWidget::sltShowHideBookmarkPanel()414 {415 if (!m_pBookmarksPanel)416 return;417 m_pBookmarksPanel->isHidden() ? m_pBookmarksPanel->show() : m_pBookmarksPanel->hide();418 435 } 419 436 … … 440 457 pBookmarkVector->push_back(bookmark); 441 458 if (m_pBookmarksPanel) 442 { 443 m_pBookmarksPanel->updateBookmarkList(); 444 m_pBookmarksPanel->setBookmarkIndex(pBookmarkVector->size() - 1); 445 } 459 m_pBookmarksPanel->updateBookmarkList(pBookmarkVector); 446 460 } 447 461 … … 528 542 m_pBookmarksPanel->hide(); 529 543 m_pMainLayout->insertWidget(4, m_pBookmarksPanel); 530 } 531 544 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteBookmark, 545 this, &UIVMLogViewerWidget::sltDeleteBookmark); 546 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks, 547 this, &UIVMLogViewerWidget::sltDeleteAllBookmarks); 548 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected, 549 this, &UIVMLogViewerWidget::sltBookmarkSelected); 550 } 532 551 } 533 552 … … 714 733 if (m_pActionBookmark) 715 734 { 716 m_pActionBookmark->setText(tr("&Bookmark ..."));735 m_pActionBookmark->setText(tr("&Bookmarks")); 717 736 m_pActionBookmark->setToolTip(tr("Bookmark the line")); 718 737 m_pActionBookmark->setStatusTip(tr("Bookmark the line")); … … 839 858 panel->setVisible(false); 840 859 QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 841 if (iterator != m_panelActionMap.end())842 { 843 if (iterator.value()->isChecked())860 if (iterator != m_panelActionMap.end()) 861 { 862 if (iterator.value()->isChecked()) 844 863 iterator.value()->setChecked(false); 845 864 } … … 851 870 panel->setVisible(true); 852 871 QMap<UIVMLogViewerPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 853 if (iterator != m_panelActionMap.end())854 { 855 if (!iterator.value()->isChecked())872 if (iterator != m_panelActionMap.end()) 873 { 874 if (!iterator.value()->isChecked()) 856 875 iterator.value()->setChecked(true); 857 876 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70519 r70529 63 63 /** Destructs the VM Log-Viewer. */ 64 64 ~UIVMLogViewerWidget(); 65 /* Returns the width of the current log page. return 0 if there is no current log page: */65 /** Returns the width of the current log page. return 0 if there is no current log page: */ 66 66 int defaultLogPageWidth() const; 67 67 … … 89 89 void sltSave(); 90 90 91 /** @name Bookmark related slots 92 * @{ */ 93 /** Deletes the bookmark with @p index from the current logs bookmark list. */ 94 void sltDeleteBookmark(int index); 95 void sltDeleteAllBookmarks(); 96 /** Scroll the plain text edit to the selected bookmark. */ 97 void sltBookmarkSelected(int index); 98 /** Creates a bookmark out of line number and block text. */ 99 void sltCreateBookmarkAtLine(QPair<int, QString> bookmark); 100 /** Determines the (middle) line number of the visible text and calls sltCreateBookmarkAtLine. */ 101 void sltCreateBookmarkAtCurrent(); 102 /** @} */ 103 91 104 void sltPanelActionTriggered(bool checked); 92 void sltShowHideFilterPanel();93 void sltShowHideSearchPanel();94 void sltShowHideBookmarkPanel();95 /* Handles QAction sync. when a panel is closed (hidden) by panel's own close button */96 //void sltPanelCloseButton();97 98 105 /** Handles the search result highlight changes. */ 99 106 void sltSearchResultHighLigting(); … … 101 108 void sltTabIndexChange(int tabIndex); 102 109 void sltFilterApplied(); 103 /* create a bookmark out of line number and block text. */104 void sltCreateBookmarkAtLine(QPair<int, QString> bookmark);105 /* Determines the (middle) line number of the visible text and calls sltCreateBookmarkAtLine. */106 void sltCreateBookmarkAtCurrent();107 108 110 109 111 private: … … 179 181 VMLogMap m_logMap; 180 182 mutable BookmarkMap m_bookmarkMap; 181 182 QVBoxLayout *m_pMainLayout; 183 184 /** Holds the widget embedding type. */ 183 QVBoxLayout *m_pMainLayout; 184 185 /** Holds the widget's embedding type. */ 185 186 const EmbedTo m_enmEmbedding; 186 187 … … 199 200 /** Holds the Bookmark action instance. */ 200 201 QAction *m_pActionBookmark; 201 202 202 /** Holds the menu object instance. */ 203 203 QMenu *m_pMenu; 204 204 /** @} */ 205 205 const bool m_bMarkBookmarkLines; 206 206 friend class UIVMLogViewerBookmarksPanel; 207 207 friend class UIVMLogViewerFilterPanel;
Note:
See TracChangeset
for help on using the changeset viewer.