Changeset 70473 in vbox
- Timestamp:
- Jan 6, 2018 6:46:16 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp
r70469 r70473 23 23 # include <QButtonGroup> 24 24 # include <QComboBox> 25 # include <QFrame> 25 26 # include <QHBoxLayout> 26 27 # if defined(RT_OS_SOLARIS) … … 178 179 , m_pAndRadioButton(0) 179 180 , m_pOrRadioButton(0) 181 , m_pRadioButtonContainer(0) 180 182 , m_pAddFilterTermButton(0) 181 183 , m_eFilterOperatorButton(AndButton) 182 184 , m_pFilterTermsLineEdit(0) 185 , m_pResultLabel(0) 186 , m_iUnfilteredLineCount(0) 187 , m_iFilteredLineCount(0) 183 188 { 184 189 prepare(); … … 188 193 { 189 194 Q_UNUSED(iCurrentIndex); 195 filter(); 196 retranslateUi(); 197 } 198 199 void UIVMLogViewerFilterPanel::filter() 200 { 190 201 QPlainTextEdit *pCurrentPage = m_pViewer->currentLogPage(); 191 202 AssertReturnVoid(pCurrentPage); 192 203 const QString& strInputText = m_pViewer->currentLog(); 204 m_iUnfilteredLineCount = 0; 205 m_iFilteredLineCount = 0; 193 206 if (strInputText.isNull()) 194 207 return; 208 QTextDocument *document = pCurrentPage->document(); 209 if (!document) 210 return; 211 QStringList stringLines = strInputText.split("\n"); 212 m_iUnfilteredLineCount = stringLines.size(); 195 213 if (m_filterTermList.empty()) 196 214 { 197 QTextDocument *document = pCurrentPage->document(); 198 if (document) 199 document->setPlainText(strInputText); 215 document->setPlainText(strInputText); 200 216 emit sigFilterApplied(); 201 return; 202 } 203 QStringList stringLines = strInputText.split("\n"); 217 m_iFilteredLineCount = document->lineCount(); 218 return; 219 } 220 204 221 /* Prepare filter-data: */ 205 222 QString strFilteredText; … … 217 234 } 218 235 219 QTextDocument *document = pCurrentPage->document(); 220 if (document) 221 document->setPlainText(strFilteredText); 236 document->setPlainText(strFilteredText); 237 m_iFilteredLineCount = document->lineCount(); 222 238 223 239 /* Move the cursor position to end: */ … … 328 344 m_pCloseButton = new UIMiniCancelButton(this); 329 345 AssertPtrReturnVoid(m_pCloseButton); 330 { 331 m_pMainLayout->addWidget(m_pCloseButton); 332 } 333 334 m_pFilterTermsLineEdit = new UIVMFilterLineEdit(this); 335 AssertPtrReturnVoid(m_pFilterTermsLineEdit); 336 { 337 m_pMainLayout->addWidget(m_pFilterTermsLineEdit, 4); 338 m_pFilterTermsLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum /*vertical */); 339 } 340 341 m_pButtonGroup = new QButtonGroup(this); 342 AssertPtrReturnVoid(m_pButtonGroup); 343 { 344 m_pAndRadioButton = new QRadioButton(this); 345 m_pOrRadioButton = new QRadioButton(this); 346 AssertPtrReturnVoid(m_pAndRadioButton); 347 AssertPtrReturnVoid(m_pOrRadioButton); 348 m_pButtonGroup->addButton(m_pAndRadioButton, static_cast<int>(AndButton)); 349 m_pButtonGroup->addButton(m_pOrRadioButton, static_cast<int>(OrButton)); 350 351 m_pOrRadioButton->setText("Or"); 352 m_pAndRadioButton->setText("And"); 353 354 m_pOrRadioButton->setChecked(true); 355 m_eFilterOperatorButton = OrButton; 356 357 m_pMainLayout->addWidget(m_pOrRadioButton); 358 m_pMainLayout->addWidget(m_pAndRadioButton); 359 } 346 m_pMainLayout->addWidget(m_pCloseButton); 347 348 prepareRadioButtonGroup(); 360 349 361 350 m_pFilterComboBox = new QComboBox(this); … … 374 363 AssertPtrReturnVoid(m_pAddFilterTermButton); 375 364 { 365 m_pAddFilterTermButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this)); 376 366 m_pMainLayout->addWidget(m_pAddFilterTermButton,0); 377 367 } 378 368 369 m_pFilterTermsLineEdit = new UIVMFilterLineEdit(this); 370 AssertPtrReturnVoid(m_pFilterTermsLineEdit); 371 { 372 m_pMainLayout->addWidget(m_pFilterTermsLineEdit, 4); 373 m_pFilterTermsLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum /*vertical */); 374 } 375 376 m_pResultLabel = new QLabel(this); 377 AssertPtrReturnVoid(m_pResultLabel); 378 { 379 m_pMainLayout->addWidget(m_pResultLabel,0); 380 } 379 381 /* Create filter-label: */ 380 382 // m_pFilterLabel = new QLabel(this); … … 393 395 } 394 396 397 void UIVMLogViewerFilterPanel::prepareRadioButtonGroup() 398 { 399 m_pButtonGroup = new QButtonGroup(this); 400 AssertPtrReturnVoid(m_pButtonGroup); 401 402 m_pRadioButtonContainer = new QFrame(this); 403 m_pRadioButtonContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 404 AssertPtrReturnVoid(m_pRadioButtonContainer); 405 406 QHBoxLayout* containerLayout = (new QHBoxLayout(m_pRadioButtonContainer)); 407 AssertPtrReturnVoid(containerLayout); 408 containerLayout->setContentsMargins(0, 0, 0, 0); 409 containerLayout->setSpacing(0); 410 411 m_pAndRadioButton = new QRadioButton(this); 412 m_pOrRadioButton = new QRadioButton(this); 413 AssertPtrReturnVoid(m_pAndRadioButton); 414 AssertPtrReturnVoid(m_pOrRadioButton); 415 416 m_pButtonGroup->addButton(m_pAndRadioButton, static_cast<int>(AndButton)); 417 m_pButtonGroup->addButton(m_pOrRadioButton, static_cast<int>(OrButton)); 418 m_pOrRadioButton->setText("Or"); 419 m_pAndRadioButton->setText("And"); 420 m_pOrRadioButton->setChecked(true); 421 m_eFilterOperatorButton = OrButton; 422 423 containerLayout->addWidget(m_pOrRadioButton); 424 containerLayout->addWidget(m_pAndRadioButton); 425 m_pMainLayout->addWidget(m_pRadioButtonContainer); 426 } 427 395 428 void UIVMLogViewerFilterPanel::prepareConnections() 396 429 { … … 407 440 } 408 441 442 409 443 void UIVMLogViewerFilterPanel::retranslateUi() 410 444 { 411 m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel")); 412 //m_pFilterLabel->setText(UIVMLogViewerWidget::tr("Filter")); 413 m_pFilterComboBox->setToolTip(UIVMLogViewerWidget::tr("Enter filtering string here")); 414 m_pAddFilterTermButton->setText(UIVMLogViewerWidget::tr("Add")); 415 m_pAddFilterTermButton->setToolTip(UIVMLogViewerWidget::tr("Add filter term")); 445 m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel.")); 446 m_pFilterComboBox->setToolTip(UIVMLogViewerWidget::tr("Enter filtering string here.")); 447 m_pAddFilterTermButton->setToolTip(UIVMLogViewerWidget::tr("Add filter term.")); 448 m_pResultLabel->setText(UIVMLogViewerWidget::tr("Showing %1/%2").arg(m_iFilteredLineCount).arg(m_iUnfilteredLineCount)); 449 m_pFilterTermsLineEdit->setToolTip(UIVMLogViewerWidget::tr("The filter terms list. Select one to remove or click the button on the right side to remove them all.")); 450 m_pRadioButtonContainer->setToolTip(UIVMLogViewerWidget::tr("The type of boolean operator for filter operation.")); 416 451 } 417 452 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h
r70466 r70473 28 28 class QButtonGroup; 29 29 class QComboBox; 30 class QFrame; 30 31 class QHBoxLayout; 31 32 class QLabel; … … 79 80 /** Prepares filter-panel. */ 80 81 void prepare(); 81 /** Prepares widgets. */82 82 void prepareWidgets(); 83 /** Prepares connections. */83 void prepareRadioButtonGroup(); 84 84 void prepareConnections(); 85 85 … … 95 95 96 96 bool applyFilterTermsToString(const QString& string); 97 void filter(); 97 98 98 99 /** Holds the reference to VM Log-Viewer this filter-panel belongs to. */ … … 110 111 QRadioButton *m_pAndRadioButton; 111 112 QRadioButton *m_pOrRadioButton; 113 QFrame *m_pRadioButtonContainer; 112 114 QPushButton *m_pAddFilterTermButton; 113 115 QStringList m_filterTermList; 114 116 FilterOperatorButton m_eFilterOperatorButton; 115 117 UIVMFilterLineEdit *m_pFilterTermsLineEdit; 118 QLabel *m_pResultLabel; 119 int m_iUnfilteredLineCount; 120 int m_iFilteredLineCount; 116 121 }; 117 122 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70308 r70473 698 698 /* Create Log-Viewer: */ 699 699 QPlainTextEdit *pLogViewer = new QPlainTextEdit(pPageContainer); 700 700 701 AssertPtrReturn(pLogViewer, 0); 701 702 {
Note:
See TracChangeset
for help on using the changeset viewer.