Changeset 70645 in vbox
- Timestamp:
- Jan 19, 2018 12:27:22 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120375
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
r70617 r70645 45 45 , m_iSelectedBookmarkIndex(-1) 46 46 , m_bFiltered(false) 47 , m_iFilteredLineCount(-1) 48 , m_iUnfilteredLineCount(-1) 47 49 , m_bShowLineNumbers(true) 48 50 , m_bWrapLines(false) … … 142 144 } 143 145 144 void UIVMLogPage::setTextEdit (const QString &strText)146 void UIVMLogPage::setTextEditText(const QString &strText) 145 147 { 146 148 if (!m_pTextEdit) … … 155 157 } 156 158 157 void UIVMLogPage::setTextEdit AsHtml(const QString &strText)159 void UIVMLogPage::setTextEditTextAsHtml(const QString &strText) 158 160 { 159 161 if (!m_pTextEdit) … … 245 247 if (m_pTextEdit) 246 248 m_pTextEdit->setFocus(); 249 247 250 QWidget::showEvent(pEvent); 248 251 } … … 311 314 update(); 312 315 } 316 317 void UIVMLogPage::setFilterParameters(const QSet<QString> &filterTermSet, int filterOperationType, 318 int iFilteredLineCount, int iUnfilteredLineCount) 319 { 320 m_filterTermSet = filterTermSet; 321 m_filterOperationType = filterOperationType; 322 m_iFilteredLineCount = iFilteredLineCount; 323 m_iUnfilteredLineCount = iUnfilteredLineCount; 324 } 325 326 int UIVMLogPage::filteredLineCount() const 327 { 328 return m_iFilteredLineCount; 329 } 330 331 int UIVMLogPage::unfilteredLineCount() const 332 { 333 return m_iUnfilteredLineCount; 334 } 335 336 bool UIVMLogPage::shouldFilterBeApplied(const QSet<QString> &filterTermSet, int filterOperationType) const 337 { 338 /* If filter terms set is different reapply the filter. */ 339 if(filterTermSet != m_filterTermSet) 340 return true; 341 342 /* If filter operation type set is different reapply the filter. */ 343 if(filterOperationType != m_filterOperationType) 344 return true; 345 return false; 346 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r70618 r70645 38 38 typedef QPair<int, QString> LogBookmark; 39 39 40 /** UIVMLogPage defines data and functionalities of the each tab page of a UIVMLogViewerWidget. 41 It stores the original log file content , a list of bookmarks, etc */ 40 42 class UIVMLogPage : public QIWithRetranslateUI<QWidget> 41 43 { … … 71 73 show currently might be different than 72 74 m_strLog. For example during filtering. */ 73 void setTextEdit (const QString &strText);74 void setTextEdit AsHtml(const QString &strText);75 void setTextEditText(const QString &strText); 76 void setTextEditTextAsHtml(const QString &strText); 75 77 76 78 /** Marks the plain text edit When we dont have a log content. */ … … 95 97 void setShowLineNumbers(bool bShowLineNumbers); 96 98 void setWrapLines(bool bWrapLines); 99 100 /** setFilterParameters is called at the end of filtering operation to store the parameter etc. 101 these parameters are used to decide whether we have to reapply the filter, and if not to 102 update filter panel with correct line counts etc.*/ 103 void setFilterParameters(const QSet<QString> &filterTermSet, int filterOperationType, 104 int iFilteredLineCount, int iUnfilteredLineCount); 105 int filteredLineCount() const; 106 int unfilteredLineCount() const; 107 /** Compares filter parameters with previous filter operation's parameters to decide if the 108 filter should be applied again. */ 109 bool shouldFilterBeApplied(const QSet<QString> &filterTermSet, int filterOperationType) const; 97 110 98 111 protected: … … 127 140 /** Keeps the index of the selected bookmark. Used especially when moving from one tab to another. */ 128 141 int m_iSelectedBookmarkIndex; 129 /** Keeps the scrolled line number. Used when switching between tabs. */ 130 int m_iScrolledLineNumber; 142 143 /** @name Filtering related state variables 144 * @{ */ 131 145 /** Designates whether currently displayed text is log text or a filtered version of it. That is 132 146 if m_bFiltered is false than (m_strLog == m_pTextEdit->text()). */ 133 bool m_bFiltered; 147 bool m_bFiltered; 148 /** The set of filter terms used in the last filtering. 149 Used when deciding whether we have to reapply the filter or not. see shouldFilterBeApplied function. */ 150 QSet<QString> m_filterTermSet; 151 /** The type of the boolean last filtering operation. Used in deciding whether we have to reapply the 152 filter. see shouldFilterBeApplied function. This is int cast of enum FilterOperatorButton 153 of UIVMLogViewerFilterPanel. */ 154 int m_filterOperationType; 155 /** These counts are saveds and restored during filtering operation. If filter is not reapplied these counts 156 are shown in the filter panel. */ 157 int m_iFilteredLineCount; 158 int m_iUnfilteredLineCount; 159 /** @} */ 160 134 161 bool m_bShowLineNumbers; 135 162 bool m_bWrapLines; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp
r70610 r70645 40 40 # include "UIIconPool.h" 41 41 # include "UISpecialControls.h" 42 # include "UIVMLogPage.h" 42 43 # include "UIVMLogViewerFilterPanel.h" 43 44 # include "UIVMLogViewerWidget.h" … … 204 205 if (!pCurrentTextEdit) 205 206 return; 207 208 UIVMLogPage *logPage = viewer()->currentLogPage(); 209 if(!logPage) 210 return; 211 /* Check if we have to reapply the filter. If not 212 restore line counts etc. and return */ 213 if(!logPage->shouldFilterBeApplied(m_filterTermSet, (int)m_eFilterOperatorButton)) 214 { 215 m_iFilteredLineCount = logPage->filteredLineCount(); 216 m_iUnfilteredLineCount = logPage->unfilteredLineCount(); 217 emit sigFilterApplied(!logPage->isFiltered() /* isOriginalLog */); 218 return; 219 } 220 221 206 222 const QString* originalLogString = logString(); 207 223 m_iUnfilteredLineCount = 0; … … 214 230 QStringList stringLines = originalLogString->split("\n"); 215 231 m_iUnfilteredLineCount = stringLines.size(); 216 if (m_filterTermList.empty()) 232 233 if (m_filterTermSet.empty()) 217 234 { 218 235 document->setPlainText(*originalLogString); 219 236 emit sigFilterApplied(true /* isOriginalLog */); 220 237 m_iFilteredLineCount = document->lineCount(); 238 logPage->setFilterParameters(m_filterTermSet, (int)m_eFilterOperatorButton, 239 m_iFilteredLineCount, m_iUnfilteredLineCount); 221 240 return; 222 241 } … … 246 265 247 266 emit sigFilterApplied(false /* isOriginalLog */); 267 logPage->setFilterParameters(m_filterTermSet, (int)m_eFilterOperatorButton, 268 m_iFilteredLineCount, m_iUnfilteredLineCount); 248 269 } 249 270 … … 253 274 /* Number of the filter terms contained with the @p string: */ 254 275 int hitCount = 0; 255 for (int i = 0; i < m_filterTermList.size(); ++i) 256 { 257 const QRegExp rxFilterExp(m_filterTermList.at(i), Qt::CaseInsensitive); 276 277 for(QSet<QString>::const_iterator iterator = m_filterTermSet.begin(); 278 iterator != m_filterTermSet.end(); ++iterator) 279 { 280 const QString& filterTerm = *iterator; 281 const QRegExp rxFilterExp(filterTerm, Qt::CaseInsensitive); 258 282 /* Disregard empty and invalid filter terms: */ 259 283 if (rxFilterExp.isEmpty() || !rxFilterExp.isValid()) … … 273 297 } 274 298 /* All the terms are found within the @p string. To catch AND case: */ 275 if (hitCount == m_filterTerm List.size())299 if (hitCount == m_filterTermSet.size()) 276 300 return true; 277 301 return false; … … 287 311 288 312 /* Continue only if the term is new. */ 289 if (m_filterTerm List.contains(m_pFilterComboBox->currentText()))290 return; 291 m_filterTerm List.push_back(m_pFilterComboBox->currentText());313 if (m_filterTermSet.contains(m_pFilterComboBox->currentText())) 314 return; 315 m_filterTermSet.insert(m_pFilterComboBox->currentText()); 292 316 293 317 /* Add the new filter term to line edit: */ … … 302 326 void UIVMLogViewerFilterPanel::sltClearFilterTerms() 303 327 { 304 if (m_filterTerm List.empty())305 return; 306 m_filterTerm List.clear();328 if (m_filterTermSet.empty()) 329 return; 330 m_filterTermSet.clear(); 307 331 applyFilter(); 308 332 if (m_pFilterTermsLineEdit) … … 320 344 void UIVMLogViewerFilterPanel::sltRemoveFilterTerm(const QString &termString) 321 345 { 322 QStringList newList; 323 for (QStringList::iterator iterator = m_filterTermList.begin(); 324 iterator != m_filterTermList.end(); ++iterator) 325 { 326 if ((*iterator) != termString) 327 newList.push_back(*iterator); 328 } 329 m_filterTermList = newList; 346 m_filterTermSet.remove(termString); 330 347 applyFilter(); 331 348 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h
r70610 r70645 19 19 #define ___UIVMLogViewerFilterPanel_h___ 20 20 21 /* Qt includes: */ 22 # include <QSet> 21 23 22 24 /* GUI includes: */ … … 84 86 85 87 enum FilterOperatorButton{ 86 AndButton = 0, 88 AndButton = 0,/* Don't change this value */ 87 89 OrButton, 88 90 ButtonEnd … … 101 103 QFrame *m_pRadioButtonContainer; 102 104 QIToolButton *m_pAddFilterTermButton; 103 QS tringList m_filterTermList;105 QSet<QString> m_filterTermSet; 104 106 FilterOperatorButton m_eFilterOperatorButton; 105 107 UIVMFilterLineEdit *m_pFilterTermsLineEdit; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.h
r70539 r70645 42 42 UIVMLogViewerPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer); 43 43 44 45 public slots:46 47 44 protected: 48 45 … … 70 67 /* Return the unmodified log. */ 71 68 const QString* logString() const; 72 private slots:73 74 69 75 70 private: 76 77 71 78 72 /** Holds the reference to VM Log-Viewer this panel belongs to. */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp
r70591 r70645 74 74 m_matchLocationVector.clear(); 75 75 m_iMatchCount = -1; 76 if (m_pHighlightAllCheckBox)77 {78 if (m_pHighlightAllCheckBox->checkState() == Qt::Checked)79 m_pHighlightAllCheckBox->setCheckState(Qt::Unchecked);80 }81 76 configureInfoLabels(); 82 77 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r70617 r70645 162 162 //setStyleSheet("background-color: rgba(240, 240, 240, 75%) "); 163 163 prepare(); 164 165 164 166 } 165 167 … … 186 188 setWordWrapMode(QTextOption::NoWrap); 187 189 setWordWrapMode(QTextOption::NoWrap); 190 188 191 setReadOnly(true); 192 189 193 /* Set colors to have a selection with bluebackground and white foreground: */ 190 194 QPalette mPalette = palette(); 191 195 mPalette.setColor(QPalette::Highlight, QColor(48, 140, 198, 255)); 192 196 mPalette.setColor(QPalette::HighlightedText, QColor(255, 255, 255, 255)); 197 mPalette.setColor(QPalette::Text, QColor(0, 0, 0, 255)); 193 198 setPalette(mPalette); 194 199 … … 311 316 { 312 317 QPlainTextEdit::resizeEvent(pEvent); 313 314 QRect cr = contentsRect(); 315 m_pLineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); 318 if(m_pLineNumberArea) 319 { 320 QRect cr = contentsRect(); 321 m_pLineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); 322 } 316 323 } 317 324 … … 319 326 { 320 327 setMouseCursorLine(lineNumberForPos(pEvent->pos())); 321 m_pLineNumberArea->repaint(); 328 if(m_pLineNumberArea) 329 m_pLineNumberArea->repaint(); 330 QPlainTextEdit::mouseMoveEvent(pEvent); 322 331 } 323 332 … … 326 335 QPlainTextEdit::leaveEvent(pEvent); 327 336 /* Force a redraw as mouse leaves this to remove the mouse 328 cursor track rectangle (the red rectangle we draw on the line number area . */337 cursor track rectangle (the red rectangle we draw on the line number area). */ 329 338 update(); 330 339 } … … 371 380 return; 372 381 382 moveCursor(QTextCursor::End); 373 383 int halfPageLineCount = 0.5 * visibleLineCount() ; 374 384 QTextCursor cursor(pDocument->findBlockByLineNumber(qMax(lineNumber - halfPageLineCount, 0))); 375 moveCursor(QTextCursor::End);376 385 setTextCursor(cursor); 377 386 } … … 403 412 } 404 413 414 405 415 QPair<int, QString> UIVMLogViewerTextEdit::bookmarkForPos(const QPoint &position) 406 416 { … … 461 471 } 462 472 473 int UIVMLogViewerTextEdit::currentVerticalScrollBarValue() const 474 { 475 if(!verticalScrollBar()) 476 return -1; 477 return verticalScrollBar()->value(); 478 } 479 void UIVMLogViewerTextEdit::setCurrentVerticalScrollBarValue(int value) 480 { 481 if(!verticalScrollBar()) 482 return; 483 484 setCenterOnScroll(true); 485 486 verticalScrollBar()->setValue(value); 487 verticalScrollBar()->setSliderPosition(value); 488 printf("value %d\n", value); 489 viewport()->update(); 490 update(); 491 } 492 463 493 464 494 #include "UIVMLogViewerTextEdit.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h
r70598 r70645 53 53 void setWrapLines(bool bWrapLines); 54 54 55 /** currentVerticalScrollBarValue is used by UIVMLogPage to store and restore scrolled 56 plain text position as we switch from a tab to another */ 57 int currentVerticalScrollBarValue() const; 58 void setCurrentVerticalScrollBarValue(int value); 59 55 60 protected: 56 61 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70617 r70645 263 263 Q_UNUSED(tabIndex); 264 264 265 // if (m_iCurrentTabIndex == tabIndex)266 // return;267 268 265 resetHighlighthing(); 269 266 if (m_pSearchPanel) 270 267 m_pSearchPanel->reset(); 271 // m_iCurrentTabIndex = tabIndex;272 268 273 269 /* We keep a separate QVector<LogBookmark> for each log page: */ … … 850 846 /* Set text edit since we want to display this text: */ 851 847 if (!noLogsToShow) 852 pLogPage->setTextEdit (strLogContent);848 pLogPage->setTextEditText(strLogContent); 853 849 /* In case there are some errors append the error text as html: */ 854 850 else 855 851 { 856 pLogPage->setTextEdit AsHtml(strLogContent);852 pLogPage->setTextEditTextAsHtml(strLogContent); 857 853 pLogPage->markForError(); 858 854 }
Note:
See TracChangeset
for help on using the changeset viewer.