Changeset 70617 in vbox
- Timestamp:
- Jan 18, 2018 7:50:33 AM (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
r70598 r70617 43 43 , m_pTextEdit(0) 44 44 , m_tabIndex(tabIndex) 45 , m_iSelectedBookmarkIndex(-1) 45 46 , m_bFiltered(false) 46 47 , m_bShowLineNumbers(true) … … 143 144 void UIVMLogPage::setTextEdit(const QString &strText) 144 145 { 145 if (!m_pTextEdit)146 if (!m_pTextEdit) 146 147 return; 147 148 … … 156 157 void UIVMLogPage::setTextEditAsHtml(const QString &strText) 157 158 { 158 if (!m_pTextEdit)159 if (!m_pTextEdit) 159 160 return; 160 161 m_pTextEdit->appendHtml(strText); … … 164 165 void UIVMLogPage::markForError() 165 166 { 166 if (!m_pTextEdit)167 if (!m_pTextEdit) 167 168 return; 168 169 m_pTextEdit->setWrapLines(true); … … 242 243 void UIVMLogPage::showEvent(QShowEvent *pEvent) 243 244 { 244 if (m_pTextEdit)245 if (m_pTextEdit) 245 246 m_pTextEdit->setFocus(); 246 247 QWidget::showEvent(pEvent); … … 293 294 void UIVMLogPage::setShowLineNumbers(bool bShowLineNumbers) 294 295 { 295 if (m_bShowLineNumbers == bShowLineNumbers)296 if (m_bShowLineNumbers == bShowLineNumbers) 296 297 return; 297 298 m_bShowLineNumbers = bShowLineNumbers; 298 if (m_pTextEdit)299 if (m_pTextEdit) 299 300 m_pTextEdit->setShowLineNumbers(m_bShowLineNumbers); 300 301 update(); … … 303 304 void UIVMLogPage::setWrapLines(bool bWrapLines) 304 305 { 305 if (m_bWrapLines == bWrapLines)306 if (m_bWrapLines == bWrapLines) 306 307 return; 307 308 m_bWrapLines = bWrapLines; 308 if (m_pTextEdit)309 if (m_pTextEdit) 309 310 m_pTextEdit->setWrapLines(m_bWrapLines); 310 311 update(); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r70598 r70617 124 124 /** Stores the bookmarks of the logpage. All other bookmark related containers are updated wrt. this one. */ 125 125 QVector<LogBookmark> m_bookmarkVector; 126 use following two variables 127 /** Keeps the index of the selected bookmark. Used especially when moving from one tab to another. */ 128 int m_iSelectedBookmarkIndex; 129 /** Keeps the scrolled line number. Used when switching between tabs. */ 130 int m_iScrolledLineNumber; 126 131 /** Designates whether currently displayed text is log text or a filtered version of it. That is 127 132 if m_bFiltered is false than (m_strLog == m_pTextEdit->text()). */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.cpp
r70610 r70617 30 30 /* GUI includes: */ 31 31 # include "QIToolButton.h" 32 # include "UIIconPool.h" 33 # include "UISpecialControls.h" 32 34 # include "UIVMLogViewerBookmarksPanel.h" 33 35 # include "UIVMLogViewerWidget.h" … … 37 39 38 40 UIVMLogViewerBookmarksPanel::UIVMLogViewerBookmarksPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer) 39 : UIVMLogViewerPanel(pParent, pViewer)41 : UIVMLogViewerPanel(pParent, pViewer) 40 42 , m_iMaxBookmarkTextLength(60) 41 43 , m_pBookmarksComboBox(0) 44 , m_pGotoSelectedBookmark(0) 42 45 , m_pDeleteAllButton(0) 43 46 , m_pDeleteCurrentButton(0) 47 , m_pNextPrevButtons(0) 44 48 { 45 49 prepare(); … … 53 57 m_pBookmarksComboBox->clear(); 54 58 QStringList bList; 55 bList << " Bookmarks List";59 bList << ""; 56 60 for (int i = 0; i < bookmarkVector.size(); ++i) 57 61 { … … 67 71 } 68 72 m_pBookmarksComboBox->addItems(bList); 69 /* Goto last item of the combobox: */ 73 /* Goto last item of the combobox. Avoid emitting sigBookmarkSelected since we dont want text edit to scroll to there: */ 74 disconnect(m_pBookmarksComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 75 this, &UIVMLogViewerBookmarksPanel::sltBookmarkSelected); 70 76 m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->count()-1); 77 connect(m_pBookmarksComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 78 this, &UIVMLogViewerBookmarksPanel::sltBookmarkSelected); 71 79 } 72 80 … … 96 104 m_pBookmarksComboBox->setMaximumWidth(fontMetrics.width('a') * (m_iMaxBookmarkTextLength + 2)); 97 105 /* Make sure we have 0th item in our combo box. */ 98 m_pBookmarksComboBox->insertItem(0, "Bookmarks List"); 99 100 101 mainLayout()->addWidget(m_pBookmarksComboBox, 2/*, Qt::AlignLeft*/); 106 m_pBookmarksComboBox->insertItem(0, ""); 107 mainLayout()->addWidget(m_pBookmarksComboBox, 2); 108 109 m_pGotoSelectedBookmark = new QIToolButton(this); 110 AssertPtrReturnVoid(m_pGotoSelectedBookmark); 111 mainLayout()->addWidget(m_pGotoSelectedBookmark, 0); 112 m_pGotoSelectedBookmark->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this)); 113 114 115 m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2); 116 AssertPtrReturnVoid(m_pNextPrevButtons); 117 m_pNextPrevButtons->setEnabled(0, false); 118 m_pNextPrevButtons->setEnabled(1, false); 119 #ifndef VBOX_WS_MAC 120 /* No icons on the Mac: */ 121 m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this)); 122 m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this)); 123 #endif /* !VBOX_WS_MAC */ 124 mainLayout()->addWidget(m_pNextPrevButtons); 125 m_pNextPrevButtons->setEnabled(0, true); 126 m_pNextPrevButtons->setEnabled(1, true); 102 127 103 128 m_pDeleteCurrentButton = new QIToolButton(this); 129 AssertPtrReturnVoid(m_pDeleteCurrentButton); 130 mainLayout()->addWidget(m_pDeleteCurrentButton, 0); 104 131 m_pDeleteCurrentButton->setIcon(m_pDeleteCurrentButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton)); 105 106 AssertPtrReturnVoid(m_pBookmarksComboBox);107 mainLayout()->addWidget(m_pDeleteCurrentButton, 0);108 132 109 133 m_pDeleteAllButton = new QIToolButton(this); … … 118 142 connect(m_pBookmarksComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 119 143 this, &UIVMLogViewerBookmarksPanel::sltBookmarkSelected); 144 145 connect(m_pGotoSelectedBookmark, &QIToolButton::clicked, this, &UIVMLogViewerBookmarksPanel::sltGotoSelectedBookmark); 146 connect(m_pNextPrevButtons, &UIRoundRectSegmentedButton::clicked, this, &UIVMLogViewerBookmarksPanel::sltGotoNextPreviousBookmark); 147 120 148 connect(m_pDeleteAllButton, &QIToolButton::clicked, this, &UIVMLogViewerBookmarksPanel::sigDeleteAllBookmarks); 121 149 connect(m_pDeleteCurrentButton, &QIToolButton::clicked, this, &UIVMLogViewerBookmarksPanel::sltDeleteCurrentBookmark); … … 127 155 if (m_pDeleteCurrentButton) 128 156 m_pDeleteCurrentButton->setToolTip(UIVMLogViewerWidget::tr("Delete the current bookmark.")); 157 129 158 if (m_pDeleteAllButton) 130 159 { … … 132 161 m_pDeleteAllButton->setText(UIVMLogViewerWidget::tr("Delete all")); 133 162 } 163 164 if (m_pNextPrevButtons) 165 { 166 m_pNextPrevButtons->setToolTip(0, UIVMLogViewerWidget::tr("Goto the previous bookmark")); 167 m_pNextPrevButtons->setToolTip(1, UIVMLogViewerWidget::tr("Goto the next bookmark")); 168 } 169 170 if (m_pGotoSelectedBookmark) 171 m_pGotoSelectedBookmark->setToolTip(UIVMLogViewerWidget::tr("Goto selected bookmark.")); 172 134 173 UIVMLogViewerPanel::retranslateUi(); 135 174 } … … 150 189 if (index <= 0) 151 190 return; 152 emit sigBookmarkSelected(index - 1); 153 } 191 emit sigBookmarkSelected(index - 1); 192 } 193 194 void UIVMLogViewerBookmarksPanel::sltGotoNextPreviousBookmark(int buttonIndex) 195 { 196 if (!m_pBookmarksComboBox || m_pBookmarksComboBox->count() <= 1) 197 return; 198 199 /* go to previous bookmark or wrap around to the end of the list: */ 200 if (buttonIndex == 0) 201 { 202 if (m_pBookmarksComboBox->currentIndex() <= 1) 203 m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->count() - 1); 204 else 205 m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->currentIndex() - 1); 206 } 207 /* go to next bookmark or wrap around to the beginning of the list: */ 208 else if (buttonIndex == 1) 209 { 210 if (m_pBookmarksComboBox->currentIndex() == m_pBookmarksComboBox->count()-1) 211 m_pBookmarksComboBox->setCurrentIndex(1); 212 else 213 m_pBookmarksComboBox->setCurrentIndex(m_pBookmarksComboBox->currentIndex() + 1); 214 } 215 } 216 217 void UIVMLogViewerBookmarksPanel::sltGotoSelectedBookmark() 218 { 219 if (!m_pBookmarksComboBox || m_pBookmarksComboBox->count() <= 1) 220 return; 221 emit sigBookmarkSelected(m_pBookmarksComboBox->currentIndex() - 1); 222 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.h
r70610 r70617 25 25 class QComboBox; 26 26 class QIToolButton; 27 class UIRoundRectSegmentedButton; 27 28 28 29 /** UIVMLogViewerPanel extension providing GUI for bookmark management. Show a list of bookmarks currently set … … 64 65 void sltDeleteCurrentBookmark(); 65 66 void sltBookmarkSelected(int index); 67 void sltGotoNextPreviousBookmark(int buttonIndex); 68 void sltGotoSelectedBookmark(); 66 69 67 70 private: … … 72 75 const int m_iMaxBookmarkTextLength; 73 76 QComboBox *m_pBookmarksComboBox; 77 QIToolButton *m_pGotoSelectedBookmark; 74 78 QIToolButton *m_pDeleteAllButton; 75 79 QIToolButton *m_pDeleteCurrentButton; 80 UIRoundRectSegmentedButton *m_pNextPrevButtons; 76 81 }; 77 82 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSettingsPanel.cpp
r70581 r70617 46 46 void UIVMLogViewerSettingsPanel::setShowLineNumbers(bool bShowLineNumbers) 47 47 { 48 if (!m_pLineNumberCheckBox)48 if (!m_pLineNumberCheckBox) 49 49 return; 50 if (m_pLineNumberCheckBox->isChecked() == bShowLineNumbers)50 if (m_pLineNumberCheckBox->isChecked() == bShowLineNumbers) 51 51 return; 52 52 m_pLineNumberCheckBox->setChecked(bShowLineNumbers); … … 55 55 void UIVMLogViewerSettingsPanel::setWrapLines(bool bWrapLines) 56 56 { 57 if (!m_pWrapLinesCheckBox)57 if (!m_pWrapLinesCheckBox) 58 58 return; 59 if (m_pWrapLinesCheckBox->isChecked() == bWrapLines)59 if (m_pWrapLinesCheckBox->isChecked() == bWrapLines) 60 60 return; 61 61 m_pWrapLinesCheckBox->setChecked(bWrapLines); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r70598 r70617 208 208 int UIVMLogViewerTextEdit::lineNumberAreaWidth() 209 209 { 210 if (!m_bShowLineNumbers)210 if (!m_bShowLineNumbers) 211 211 return 0; 212 212 … … 225 225 void UIVMLogViewerTextEdit::lineNumberAreaPaintEvent(QPaintEvent *event) 226 226 { 227 if (!m_bShowLineNumbers)227 if (!m_bShowLineNumbers) 228 228 return; 229 229 QPainter painter(m_pLineNumberArea); … … 436 436 void UIVMLogViewerTextEdit::setShowLineNumbers(bool bShowLineNumbers) 437 437 { 438 if (m_bShowLineNumbers == bShowLineNumbers)438 if (m_bShowLineNumbers == bShowLineNumbers) 439 439 return; 440 440 m_bShowLineNumbers = bShowLineNumbers; … … 444 444 void UIVMLogViewerTextEdit::setWrapLines(bool bWrapLines) 445 445 { 446 if (m_bWrapLines == bWrapLines)446 if (m_bWrapLines == bWrapLines) 447 447 return; 448 448 m_bWrapLines = bWrapLines; 449 if (m_bWrapLines)449 if (m_bWrapLines) 450 450 { 451 451 setLineWrapMode(QPlainTextEdit::WidgetWidth); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70598 r70617 136 136 if (!currentLogPage() || !m_pBookmarksPanel) 137 137 return; 138 disconnect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,139 this, &UIVMLogViewerWidget::gotoBookmark);140 138 m_pBookmarksPanel->updateBookmarkList(currentLogPage()->bookmarkVector()); 141 connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigBookmarkSelected,142 this, &UIVMLogViewerWidget::gotoBookmark);143 139 } 144 140 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70581 r70617 44 44 class UIVMLogViewerSettingsPanel; 45 45 46 /* Type definitions: */47 /** value is the content of the log file */48 //typedef QMap<QPlainTextEdit*, QString> VMLogMap;49 /** first is line number, second is block text */50 //typedef QPair<int, QString> LogBookmark;51 /** key is log file name, value is a vector of bookmarks. */52 //typedef QMap<QString, QVector<LogBookmark> > BookmarkMap;53 54 46 55 47 /** QWidget extension providing GUI for VirtualBox LogViewer. It
Note:
See TracChangeset
for help on using the changeset viewer.