Changeset 70500 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 10, 2018 9:36:36 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 9 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r70487 r70500 338 338 src/logviewer/UIVMLogViewerDialog.h \ 339 339 src/logviewer/UIVMLogViewerFilterPanel.h \ 340 src/logviewer/UIVMLogViewerPanel.h \ 340 341 src/logviewer/UIVMLogViewerSearchPanel.h \ 341 342 src/logviewer/UIVMLogViewerWidget.h \ … … 655 656 src/logviewer/UIVMLogViewerDialog.cpp \ 656 657 src/logviewer/UIVMLogViewerFilterPanel.cpp \ 658 src/logviewer/UIVMLogViewerPanel.cpp \ 657 659 src/logviewer/UIVMLogViewerSearchPanel.cpp \ 658 660 src/logviewer/UIVMLogViewerWidget.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.cpp
r70495 r70500 46 46 47 47 UIVMLogViewerBookmarksPanel::UIVMLogViewerBookmarksPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer) 48 : QIWithRetranslateUI<QWidget>(pParent)48 : UIVMLogViewerPanel(pParent, pViewer) 49 49 , m_iMaxBookmarkTextLength(60) 50 , m_pViewer(pViewer)51 , m_pMainLayout(0)52 , m_pCloseButton(0)53 50 , m_pBookmarksComboBox(0) 54 51 , m_clearAllButton(0) … … 58 55 } 59 56 60 void UIVMLogViewerBookmarksPanel::update ()57 void UIVMLogViewerBookmarksPanel::updateBookmarkList() 61 58 { 62 if (!m_pBookmarksComboBox)59 if (!m_pBookmarksComboBox || !viewer()) 63 60 return; 64 const QVector<QPair<int, QString> > *bookmarkVector = m_pViewer->currentBookmarkVector();65 if (!bookmarkVector)61 const QVector<QPair<int, QString> > *bookmarkVector = viewer()->currentBookmarkVector(); 62 if (!bookmarkVector) 66 63 return; 67 64 … … 73 70 arg(QString::number(bookmarkVector->at(i).first)).arg(bookmarkVector->at(i).second); 74 71 75 if (strItem.length() > m_iMaxBookmarkTextLength)72 if (strItem.length() > m_iMaxBookmarkTextLength) 76 73 { 77 74 strItem.resize(m_iMaxBookmarkTextLength); … … 92 89 } 93 90 94 void UIVMLogViewerBookmarksPanel::prepare()95 {96 prepareWidgets();97 prepareConnections();98 retranslateUi();99 }100 101 91 void UIVMLogViewerBookmarksPanel::prepareWidgets() 102 92 { 103 m_pMainLayout = new QHBoxLayout(this); 104 AssertPtrReturnVoid(m_pMainLayout); 105 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 106 m_pMainLayout->setSpacing(4); 107 108 m_pCloseButton = new UIMiniCancelButton(this); 109 AssertPtrReturnVoid(m_pCloseButton); 110 m_pMainLayout->addWidget(m_pCloseButton, 0, Qt::AlignLeft); 93 if (!mainLayout()) 94 return; 111 95 112 96 m_pBookmarksComboBox = new QComboBox(this); … … 115 99 m_pBookmarksComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); 116 100 m_pBookmarksComboBox->setMaximumWidth(fontMetrics.width('a') * (m_iMaxBookmarkTextLength + 2)); 117 m _pMainLayout->addWidget(m_pBookmarksComboBox, 2, Qt::AlignLeft);101 mainLayout()->addWidget(m_pBookmarksComboBox, 2, Qt::AlignLeft); 118 102 } 119 103 120 104 void UIVMLogViewerBookmarksPanel::prepareConnections() 121 105 { 122 connect(m_pCloseButton, &UIMiniCancelButton::clicked, this, &UIVMLogViewerBookmarksPanel::hide);123 124 106 } 125 107 … … 127 109 void UIVMLogViewerBookmarksPanel::retranslateUi() 128 110 { 129 m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel."));111 UIVMLogViewerPanel::retranslateUi(); 130 112 } 131 132 bool UIVMLogViewerBookmarksPanel::eventFilter(QObject *pObject, QEvent *pEvent)133 {134 /* Depending on event-type: */135 switch (pEvent->type())136 {137 /* Process key press only: */138 case QEvent::KeyPress:139 {140 break;141 }142 default:143 break;144 }145 /* Call to base-class: */146 return QWidget::eventFilter(pObject, pEvent);147 }148 149 /** Handles the Qt show @a pEvent. */150 void UIVMLogViewerBookmarksPanel::showEvent(QShowEvent *pEvent)151 {152 /* Call to base-class: */153 QWidget::showEvent(pEvent);154 }155 156 /** Handles the Qt hide @a pEvent. */157 void UIVMLogViewerBookmarksPanel::hideEvent(QHideEvent *pEvent)158 {159 /* Get focused widget: */160 QWidget *pFocus = QApplication::focusWidget();161 /* If focus-widget is valid and child-widget of search-panel,162 * focus next child-widget in line: */163 if (pFocus && pFocus->parent() == this)164 focusNextPrevChild(true);165 /* Call to base-class: */166 QWidget::hideEvent(pEvent);167 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.h
r70495 r70500 19 19 #define ___UIVMLogViewerBookmarksPanel_h___ 20 20 21 /* Qt includes: */22 #include <QWidget>23 24 21 /* GUI includes: */ 25 #include " QIWithRetranslateUI.h"22 #include "UIVMLogViewerPanel.h" 26 23 27 24 /* Forward declarations: */ 28 25 class QComboBox; 29 class QHBoxLayout;30 class QLabel;31 class QLineEdit;32 26 class QPushButton; 33 class UIVMFilterLineEdit;34 class UIMiniCancelButton;35 class UIVMLogViewerWidget;36 27 37 28 38 /** QWidget extension 39 * providing GUI for bookmark management. Show a list of bookmarks currently set 29 30 31 /** UIVMLogViewerPanel extension providing GUI for bookmark management. Show a list of bookmarks currently set 40 32 for displayed log page. It has controls to navigate and clear bookmarks. */ 41 class UIVMLogViewerBookmarksPanel : public QIWithRetranslateUI<QWidget>33 class UIVMLogViewerBookmarksPanel : public UIVMLogViewerPanel 42 34 { 43 35 Q_OBJECT; … … 55 47 user switches to another log page tab etc. */ 56 48 void setBookmarksList(const QVector<QPair<int, QString> > &bookmarkList); 57 void update ();49 void updateBookmarkList(); 58 50 /* @a index is the index of the curent bookmark. */ 59 51 void setBookmarkIndex(int index); … … 61 53 public slots: 62 54 55 protected: 63 56 64 private slots: 65 66 67 private: 68 69 void prepare(); 70 void prepareWidgets(); 71 void prepareConnections(); 57 virtual void prepareWidgets() /* override */; 58 virtual void prepareConnections() /* override */; 72 59 73 60 /** Handles the translation event. */ 74 61 void retranslateUi(); 75 62 76 /** Handles Qt @a pEvent, used for keyboard processing. */ 77 bool eventFilter(QObject *pObject, QEvent *pEvent); 78 /** Handles the Qt show @a pEvent. */ 79 void showEvent(QShowEvent *pEvent); 80 /** Handles the Qt hide @a pEvent. */ 81 void hideEvent(QHideEvent *pEvent); 63 private slots: 82 64 83 const int m_iMaxBookmarkTextLength; 84 /** Holds the reference to VM Log-Viewer this panel belongs to. */ 85 UIVMLogViewerWidget *m_pViewer; 86 /** Holds the instance of main-layout we create. */ 87 QHBoxLayout *m_pMainLayout; 88 /** Holds the instance of close-button we create. */ 89 UIMiniCancelButton *m_pCloseButton; 90 QComboBox *m_pBookmarksComboBox; 91 QPushButton *m_clearAllButton; 92 QPushButton *m_clearCurrentButton; 65 private: 66 67 const int m_iMaxBookmarkTextLength; 68 QComboBox *m_pBookmarksComboBox; 69 QPushButton *m_clearAllButton; 70 QPushButton *m_clearCurrentButton; 93 71 }; 94 72 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp
r70487 r70500 173 173 174 174 UIVMLogViewerFilterPanel::UIVMLogViewerFilterPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer) 175 : QIWithRetranslateUI<QWidget>(pParent) 176 , m_pViewer(pViewer) 177 , m_pMainLayout(0) 178 , m_pCloseButton(0) 175 : UIVMLogViewerPanel(pParent, pViewer) 179 176 , m_pFilterLabel(0) 180 177 , m_pFilterComboBox(0) … … 202 199 void UIVMLogViewerFilterPanel::filter() 203 200 { 204 QPlainTextEdit *pCurrentPage = m_pViewer->currentLogPage();201 QPlainTextEdit *pCurrentPage = viewer()->currentLogPage(); 205 202 AssertReturnVoid(pCurrentPage); 206 const QString* strInputText = m_pViewer->currentLog();203 const QString* strInputText = viewer()->currentLog(); 207 204 m_iUnfilteredLineCount = 0; 208 205 m_iFilteredLineCount = 0; … … 331 328 } 332 329 333 void UIVMLogViewerFilterPanel::prepare()334 {335 prepareWidgets();336 prepareConnections();337 retranslateUi();338 }339 340 330 void UIVMLogViewerFilterPanel::prepareWidgets() 341 331 { 342 m_pMainLayout = new QHBoxLayout(this); 343 AssertPtrReturnVoid(m_pMainLayout); 344 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 345 m_pMainLayout->setSpacing(4); 346 347 m_pCloseButton = new UIMiniCancelButton(this); 348 AssertPtrReturnVoid(m_pCloseButton); 349 m_pMainLayout->addWidget(m_pCloseButton); 332 if (!mainLayout()) 333 return; 350 334 351 335 prepareRadioButtonGroup(); … … 360 344 strFilterPresets.sort(); 361 345 m_pFilterComboBox->addItems(strFilterPresets); 362 m _pMainLayout->addWidget(m_pFilterComboBox,1);346 mainLayout()->addWidget(m_pFilterComboBox,1); 363 347 } 364 348 … … 367 351 { 368 352 m_pAddFilterTermButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this)); 369 m _pMainLayout->addWidget(m_pAddFilterTermButton,0);353 mainLayout()->addWidget(m_pAddFilterTermButton,0); 370 354 } 371 355 … … 373 357 AssertPtrReturnVoid(m_pFilterTermsLineEdit); 374 358 { 375 m _pMainLayout->addWidget(m_pFilterTermsLineEdit, 4);359 mainLayout()->addWidget(m_pFilterTermsLineEdit, 4); 376 360 m_pFilterTermsLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum /*vertical */); 377 361 } … … 380 364 AssertPtrReturnVoid(m_pResultLabel); 381 365 { 382 m _pMainLayout->addWidget(m_pResultLabel,0);366 mainLayout()->addWidget(m_pResultLabel,0); 383 367 } 384 368 /* Create filter-label: */ … … 394 378 // #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 395 379 // /* Add filter-label to main-layout: */ 396 // m _pMainLayout->addWidget(m_pFilterLabel);380 // mainLayout()->addWidget(m_pFilterLabel); 397 381 // } 398 382 } … … 426 410 containerLayout->addWidget(m_pOrRadioButton); 427 411 containerLayout->addWidget(m_pAndRadioButton); 428 m _pMainLayout->addWidget(m_pRadioButtonContainer);412 mainLayout()->addWidget(m_pRadioButtonContainer); 429 413 } 430 414 431 415 void UIVMLogViewerFilterPanel::prepareConnections() 432 416 { 433 connect(m_pCloseButton, &UIMiniCancelButton::clicked, this, &UIVMLogViewerFilterPanel::hide);434 417 connect(m_pAddFilterTermButton, &QPushButton::clicked, this, &UIVMLogViewerFilterPanel::sltAddFilterTerm); 435 418 connect(m_pButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), … … 446 429 void UIVMLogViewerFilterPanel::retranslateUi() 447 430 { 448 m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel."));431 UIVMLogViewerPanel::retranslateUi(); 449 432 m_pFilterComboBox->setToolTip(UIVMLogViewerWidget::tr("Enter filtering string here.")); 450 433 m_pAddFilterTermButton->setToolTip(UIVMLogViewerWidget::tr("Add filter term.")); … … 469 452 pKeyEvent->key() == Qt::Key_T) 470 453 { 471 if ( m_pViewer->currentLogPage())454 if (viewer()->currentLogPage()) 472 455 { 473 456 if (isHidden()) … … 486 469 } 487 470 /* Call to base-class: */ 488 return QWidget::eventFilter(pObject, pEvent);471 return UIVMLogViewerPanel::eventFilter(pObject, pEvent); 489 472 } 490 473 … … 492 475 void UIVMLogViewerFilterPanel::showEvent(QShowEvent *pEvent) 493 476 { 494 /* Call to base-class: */ 495 QWidget::showEvent(pEvent); 477 UIVMLogViewerPanel::showEvent(pEvent); 496 478 /* Set focus to combo-box: */ 497 479 m_pFilterComboBox->setFocus(); 498 480 } 499 481 500 /** Handles the Qt hide @a pEvent. */501 void UIVMLogViewerFilterPanel::hideEvent(QHideEvent *pEvent)502 {503 /* Get focused widget: */504 QWidget *pFocus = QApplication::focusWidget();505 /* If focus-widget is valid and child-widget of search-panel,506 * focus next child-widget in line: */507 if (pFocus && pFocus->parent() == this)508 focusNextPrevChild(true);509 /* Call to base-class: */510 QWidget::hideEvent(pEvent);511 }512 513 482 #include "UIVMLogViewerFilterPanel.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h
r70474 r70500 19 19 #define ___UIVMLogViewerFilterPanel_h___ 20 20 21 /* Qt includes: */22 #include <QWidget>23 21 24 22 /* GUI includes: */ 25 #include " QIWithRetranslateUI.h"23 #include "UIVMLogViewerPanel.h" 26 24 27 25 /* Forward declarations: */ … … 29 27 class QComboBox; 30 28 class QFrame; 31 class QHBoxLayout;32 29 class QLabel; 33 30 class QLineEdit; … … 35 32 class QRadioButton; 36 33 class UIVMFilterLineEdit; 37 class UIMiniCancelButton;38 class UIVMLogViewerWidget;39 34 40 35 41 36 /** QWidget extension 42 37 * providing GUI for filter panel in VM Log Viewer. */ 43 class UIVMLogViewerFilterPanel : public QIWithRetranslateUI<QWidget>38 class UIVMLogViewerFilterPanel : public UIVMLogViewerPanel 44 39 { 45 40 Q_OBJECT; … … 62 57 void applyFilter(const int iCurrentIndex = 0); 63 58 59 protected: 60 61 virtual void prepareWidgets() /* override */; 62 virtual void prepareConnections() /* override */; 63 64 /** Handles the translation event. */ 65 void retranslateUi() /* override */; 66 /** Handles Qt @a pEvent, used for keyboard processing. */ 67 bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 68 /** Handles the Qt show @a pEvent. */ 69 void showEvent(QShowEvent *pEvent) /* override */; 70 64 71 private slots: 65 72 … … 80 87 }; 81 88 82 /** Prepares filter-panel. */83 void prepare();84 void prepareWidgets();85 89 void prepareRadioButtonGroup(); 86 void prepareConnections();87 88 /** Handles the translation event. */89 void retranslateUi();90 91 /** Handles Qt @a pEvent, used for keyboard processing. */92 bool eventFilter(QObject *pObject, QEvent *pEvent);93 /** Handles the Qt show @a pEvent. */94 void showEvent(QShowEvent *pEvent);95 /** Handles the Qt hide @a pEvent. */96 void hideEvent(QHideEvent *pEvent);97 90 98 91 bool applyFilterTermsToString(const QString& string); 99 92 void filter(); 100 93 101 /** Holds the reference to VM Log-Viewer this filter-panel belongs to. */102 UIVMLogViewerWidget *m_pViewer;103 /** Holds the instance of main-layout we create. */104 QHBoxLayout *m_pMainLayout;105 /** Holds the instance of close-button we create. */106 UIMiniCancelButton *m_pCloseButton;107 /** Holds the instance of filter-label we create. */108 94 QLabel *m_pFilterLabel; 109 /** Holds instance of filter combo-box we create. */110 95 QComboBox *m_pFilterComboBox; 111 112 96 QButtonGroup *m_pButtonGroup; 113 97 QRadioButton *m_pAndRadioButton; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.cpp
r70495 r70500 37 37 # include "UIIconPool.h" 38 38 # include "UISpecialControls.h" 39 # include "UIVMLogViewer BookmarksPanel.h"39 # include "UIVMLogViewerPanel.h" 40 40 # include "UIVMLogViewerWidget.h" 41 41 # ifdef VBOX_WS_MAC … … 45 45 46 46 47 UIVMLogViewer BookmarksPanel::UIVMLogViewerBookmarksPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer)47 UIVMLogViewerPanel::UIVMLogViewerPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer) 48 48 : QIWithRetranslateUI<QWidget>(pParent) 49 , m_iMaxBookmarkTextLength(60)50 49 , m_pViewer(pViewer) 51 50 , m_pMainLayout(0) 52 51 , m_pCloseButton(0) 53 , m_pBookmarksComboBox(0)54 , m_clearAllButton(0)55 , m_clearCurrentButton(0)56 52 { 57 53 prepare(); 58 54 } 59 55 60 void UIVMLogViewerBookmarksPanel::update()56 UIVMLogViewerWidget* UIVMLogViewerPanel::viewer() 61 57 { 62 if(!m_pBookmarksComboBox) 63 return; 64 const QVector<QPair<int, QString> > *bookmarkVector = m_pViewer->currentBookmarkVector(); 65 if(!bookmarkVector) 66 return; 67 68 m_pBookmarksComboBox->clear(); 69 QStringList bList; 70 for(int i = 0; i < bookmarkVector->size(); ++i) 71 { 72 QString strItem = QString("BookMark %1 at Line %2: %3").arg(QString::number(i)). 73 arg(QString::number(bookmarkVector->at(i).first)).arg(bookmarkVector->at(i).second); 74 75 if(strItem.length() > m_iMaxBookmarkTextLength) 76 { 77 strItem.resize(m_iMaxBookmarkTextLength); 78 strItem.replace(m_iMaxBookmarkTextLength, 3, QString("...")); 79 } 80 bList << strItem; 81 } 82 m_pBookmarksComboBox->addItems(bList); 58 return m_pViewer; 83 59 } 84 60 85 void UIVMLogViewerBookmarksPanel::setBookmarkIndex(int index) 61 const UIVMLogViewerWidget* UIVMLogViewerPanel::viewer() const 86 62 { 87 if (!m_pBookmarksComboBox) 88 return; 89 if (index >= m_pBookmarksComboBox->count()) 90 return; 91 m_pBookmarksComboBox->setCurrentIndex(index); 63 return m_pViewer; 92 64 } 93 65 94 void UIVMLogViewerBookmarksPanel::prepare() 66 QHBoxLayout* UIVMLogViewerPanel::mainLayout() 67 { 68 return m_pMainLayout; 69 } 70 71 void UIVMLogViewerPanel::prepare() 95 72 { 96 73 prepareWidgets(); … … 99 76 } 100 77 101 void UIVMLogViewer BookmarksPanel::prepareWidgets()78 void UIVMLogViewerPanel::prepareWidgets() 102 79 { 103 80 m_pMainLayout = new QHBoxLayout(this); 104 81 AssertPtrReturnVoid(m_pMainLayout); 105 82 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 106 m_pMainLayout->setSpacing( 4);83 m_pMainLayout->setSpacing(2); 107 84 108 85 m_pCloseButton = new UIMiniCancelButton(this); 109 86 AssertPtrReturnVoid(m_pCloseButton); 110 87 m_pMainLayout->addWidget(m_pCloseButton, 0, Qt::AlignLeft); 111 112 m_pBookmarksComboBox = new QComboBox(this);113 QFontMetrics fontMetrics = m_pBookmarksComboBox->fontMetrics();114 AssertPtrReturnVoid(m_pBookmarksComboBox);115 m_pBookmarksComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);116 m_pBookmarksComboBox->setMaximumWidth(fontMetrics.width('a') * (m_iMaxBookmarkTextLength + 2));117 m_pMainLayout->addWidget(m_pBookmarksComboBox, 2, Qt::AlignLeft);118 88 } 119 89 120 void UIVMLogViewer BookmarksPanel::prepareConnections()90 void UIVMLogViewerPanel::prepareConnections() 121 91 { 122 connect(m_pCloseButton, &UIMiniCancelButton::clicked, this, &UIVMLogViewerBookmarksPanel::hide); 92 if (m_pCloseButton) 93 connect(m_pCloseButton, &UIMiniCancelButton::clicked, this, &UIVMLogViewerPanel::hide); 123 94 124 95 } 125 96 126 97 127 void UIVMLogViewer BookmarksPanel::retranslateUi()98 void UIVMLogViewerPanel::retranslateUi() 128 99 { 129 m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel.")); 100 if (m_pCloseButton) 101 m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel.")); 130 102 } 131 103 132 bool UIVMLogViewer BookmarksPanel::eventFilter(QObject *pObject, QEvent *pEvent)104 bool UIVMLogViewerPanel::eventFilter(QObject *pObject, QEvent *pEvent) 133 105 { 134 /* Depending on event-type: */135 switch (pEvent->type())136 {137 /* Process key press only: */138 case QEvent::KeyPress:139 {140 break;141 }142 default:143 break;144 }145 /* Call to base-class: */146 106 return QWidget::eventFilter(pObject, pEvent); 147 107 } 148 108 149 /** Handles the Qt show @a pEvent. */ 150 void UIVMLogViewerBookmarksPanel::showEvent(QShowEvent *pEvent) 109 void UIVMLogViewerPanel::showEvent(QShowEvent *pEvent) 151 110 { 152 /* Call to base-class: */153 111 QWidget::showEvent(pEvent); 154 112 } 155 113 156 /** Handles the Qt hide @a pEvent. */ 157 void UIVMLogViewerBookmarksPanel::hideEvent(QHideEvent *pEvent) 114 void UIVMLogViewerPanel::hideEvent(QHideEvent *pEvent) 158 115 { 159 116 /* Get focused widget: */ … … 163 120 if (pFocus && pFocus->parent() == this) 164 121 focusNextPrevChild(true); 165 /* Call to base-class: */ 122 166 123 QWidget::hideEvent(pEvent); 124 emit sigHide(); 167 125 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.h
r70495 r70500 16 16 */ 17 17 18 #ifndef ___UIVMLogViewer BookmarksPanel_h___19 #define ___UIVMLogViewer BookmarksPanel_h___18 #ifndef ___UIVMLogViewerPanel_h___ 19 #define ___UIVMLogViewerPanel_h___ 20 20 21 21 /* Qt includes: */ … … 36 36 37 37 38 /** QWidget extension 39 * providing GUI for bookmark management. Show a list of bookmarks currently set 40 for displayed log page. It has controls to navigate and clear bookmarks. */ 41 class UIVMLogViewerBookmarksPanel : public QIWithRetranslateUI<QWidget> 38 /** QWidget extension acting as the base class for UIVMLogViewerXXXPanel widgets. */ 39 class UIVMLogViewerPanel : public QIWithRetranslateUI<QWidget> 42 40 { 43 41 Q_OBJECT; … … 45 43 signals: 46 44 45 void sigHide(); 46 47 47 public: 48 48 49 UIVMLogViewer BookmarksPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer);49 UIVMLogViewerPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer); 50 50 51 /* Adds a single bookmark to an existing list of bookmarks. Possibly called52 by UIVMLogViewerWidget when user adds a bookmark thru context menu etc. */53 void addBookmark(const QPair<int, QString> &newBookmark);54 /* Clear the bookmark list and show this list instead. Probably done after55 user switches to another log page tab etc. */56 void setBookmarksList(const QVector<QPair<int, QString> > &bookmarkList);57 void update();58 /* @a index is the index of the curent bookmark. */59 void setBookmarkIndex(int index);60 51 61 52 public slots: 62 53 54 protected: 63 55 64 private slots: 56 virtual void prepare(); 57 virtual void prepareWidgets(); 58 virtual void prepareConnections(); 65 59 66 67 private: 68 69 void prepare(); 70 void prepareWidgets(); 71 void prepareConnections(); 60 /* Access functions for children classes. */ 61 UIVMLogViewerWidget* viewer(); 62 const UIVMLogViewerWidget* viewer() const; 63 QHBoxLayout* mainLayout(); 72 64 73 65 /** Handles the translation event. */ … … 81 73 void hideEvent(QHideEvent *pEvent); 82 74 83 const int m_iMaxBookmarkTextLength; 75 private slots: 76 77 78 private: 79 80 84 81 /** Holds the reference to VM Log-Viewer this panel belongs to. */ 85 82 UIVMLogViewerWidget *m_pViewer; … … 88 85 /** Holds the instance of close-button we create. */ 89 86 UIMiniCancelButton *m_pCloseButton; 90 QComboBox *m_pBookmarksComboBox;91 QPushButton *m_clearAllButton;92 QPushButton *m_clearCurrentButton;93 87 }; 94 88 95 #endif /* !___UIVMLogViewer BookmarksPanel_h___ */89 #endif /* !___UIVMLogViewerPanel!_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp
r70476 r70500 44 44 45 45 UIVMLogViewerSearchPanel::UIVMLogViewerSearchPanel(QWidget *pParent, UIVMLogViewerWidget *pViewer) 46 : QIWithRetranslateUI<QWidget>(pParent) 47 , m_pViewer(pViewer) 48 , m_pMainLayout(0) 49 , m_pCloseButton(0) 50 , m_pSearchLabel(0), m_pSearchEditor(0) 46 : UIVMLogViewerPanel(pParent, pViewer) 47 , m_pSearchLabel(0) 48 , m_pSearchEditor(0) 51 49 , m_pNextPrevButtons(0) 52 50 , m_pCaseSensitiveCheckBox(0) … … 96 94 focusNextPrevChild(true); 97 95 /* Call to base-class: */ 98 QWidget::hideEvent(pEvent);96 UIVMLogViewerPanel::hideEvent(pEvent); 99 97 reset(); 100 98 } … … 127 125 else 128 126 { 129 /* Get current log-page: */ 130 QPlainTextEdit *pBrowser = m_pViewer->currentLogPage(); 131 /* If current log-page is valid and cursor has selection: */ 132 if (pBrowser && pBrowser->textCursor().hasSelection()) 127 if (viewer()) 133 128 { 134 /* Get cursor and reset position: */ 135 QTextCursor cursor = pBrowser->textCursor(); 136 cursor.setPosition(cursor.anchor()); 137 pBrowser->setTextCursor(cursor); 129 /* Get current log-page: */ 130 QPlainTextEdit *pBrowser = viewer()->currentLogPage(); 131 /* If current log-page is valid and cursor has selection: */ 132 if (pBrowser && pBrowser->textCursor().hasSelection()) 133 { 134 /* Get cursor and reset position: */ 135 QTextCursor cursor = pBrowser->textCursor(); 136 cursor.setPosition(cursor.anchor()); 137 pBrowser->setTextCursor(cursor); 138 } 139 m_iSearchPosition = -1; 140 clearHighlighting(-1); 138 141 } 139 m_iSearchPosition = -1;140 clearHighlighting(-1);141 142 } 142 143 } … … 144 145 void UIVMLogViewerSearchPanel::sltHighlightAllCheckBox() 145 146 { 146 QPlainTextEdit *pTextEdit = m_pViewer->currentLogPage(); 147 if (!viewer()) 148 return; 149 QPlainTextEdit *pTextEdit = viewer()->currentLogPage(); 147 150 if (!pTextEdit) 148 151 return; … … 181 184 } 182 185 183 void UIVMLogViewerSearchPanel::prepare()184 {185 /* Prepare widgets: */186 prepareWidgets();187 188 /* Prepare connections: */189 prepareConnections();190 191 /* Retranslate finally: */192 retranslateUi();193 }194 195 186 void UIVMLogViewerSearchPanel::prepareWidgets() 196 187 { 197 /* Create main-layout: */ 198 m_pMainLayout = new QHBoxLayout(this); 199 AssertPtrReturnVoid(m_pMainLayout); 200 { 201 /* Configure main-layout: */ 202 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 203 m_pMainLayout->setSpacing(4); 204 205 /* Create close-button: */ 206 m_pCloseButton = new UIMiniCancelButton(this); 207 AssertPtrReturnVoid(m_pCloseButton); 208 { 209 /* Add close-button to main-layout: */ 210 m_pMainLayout->addWidget(m_pCloseButton); 211 } 212 213 /* Create search-editor: */ 214 m_pSearchEditor = new UISearchField(this); 215 AssertPtrReturnVoid(m_pSearchEditor); 216 { 217 /* Configure search-editor: */ 218 m_pSearchEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 219 /* Add search-editor to main-layout: */ 220 m_pMainLayout->addWidget(m_pSearchEditor); 221 } 222 223 /* Create search-label: */ 224 m_pSearchLabel = new QLabel(this); 225 AssertPtrReturnVoid(m_pSearchLabel); 226 { 227 /* Configure search-label: */ 228 m_pSearchLabel->setBuddy(m_pSearchEditor); 229 /* Prepare font: */ 188 if (!mainLayout()) 189 return; 190 191 /* Create search-editor: */ 192 m_pSearchEditor = new UISearchField(this); 193 AssertPtrReturnVoid(m_pSearchEditor); 194 { 195 /* Configure search-editor: */ 196 m_pSearchEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 197 /* Add search-editor to main-layout: */ 198 mainLayout()->addWidget(m_pSearchEditor); 199 } 200 201 /* Create search-label: */ 202 m_pSearchLabel = new QLabel(this); 203 AssertPtrReturnVoid(m_pSearchLabel); 204 { 205 /* Configure search-label: */ 206 m_pSearchLabel->setBuddy(m_pSearchEditor); 207 /* Prepare font: */ 230 208 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 231 232 233 209 QFont font = m_pSearchLabel->font(); 210 font.setPointSize(::darwinSmallFontSize()); 211 m_pSearchLabel->setFont(font); 234 212 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 235 236 m_pMainLayout->addWidget(m_pSearchLabel);237 238 239 240 241 242 243 244 245 213 /* Add search-label to main-layout: */ 214 mainLayout()->addWidget(m_pSearchLabel); 215 } 216 217 /* Create Next/Prev button-box: */ 218 m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2); 219 AssertPtrReturnVoid(m_pNextPrevButtons); 220 { 221 /* Configure Next/Prev button-box: */ 222 m_pNextPrevButtons->setEnabled(0, false); 223 m_pNextPrevButtons->setEnabled(1, false); 246 224 #ifndef VBOX_WS_MAC 247 248 249 225 /* No icons on the Mac: */ 226 m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this)); 227 m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this)); 250 228 #endif /* !VBOX_WS_MAC */ 251 252 m_pMainLayout->addWidget(m_pNextPrevButtons);253 254 255 256 257 258 259 229 /* Add Next/Prev button-box to main-layout: */ 230 mainLayout()->addWidget(m_pNextPrevButtons); 231 } 232 233 /* Create case-sensitive checkbox: */ 234 m_pCaseSensitiveCheckBox = new QCheckBox; 235 AssertPtrReturnVoid(m_pCaseSensitiveCheckBox); 236 { 237 /* Configure font: */ 260 238 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 261 262 263 239 QFont font = m_pCaseSensitiveCheckBox->font(); 240 font.setPointSize(::darwinSmallFontSize()); 241 m_pCaseSensitiveCheckBox->setFont(font); 264 242 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 265 266 m_pMainLayout->addWidget(m_pCaseSensitiveCheckBox);267 268 269 270 271 272 273 274 243 /* Add case-sensitive checkbox to main-layout: */ 244 mainLayout()->addWidget(m_pCaseSensitiveCheckBox); 245 } 246 247 m_pMatchWholeWordCheckBox = new QCheckBox(this); 248 AssertPtrReturnVoid(m_pMatchWholeWordCheckBox); 249 { 250 /* Configure focus for case-sensitive checkbox: */ 251 setFocusProxy(m_pMatchWholeWordCheckBox); 252 /* Configure font: */ 275 253 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 276 277 278 254 QFont font = m_pMatchWholeWordCheckBox->font(); 255 font.setPointSize(::darwinSmallFontSize()); 256 m_pMatchWholeWordCheckBox->setFont(font); 279 257 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 280 m_pMainLayout->addWidget(m_pMatchWholeWordCheckBox);281 282 283 284 285 286 258 mainLayout()->addWidget(m_pMatchWholeWordCheckBox); 259 } 260 261 m_pHighlightAllCheckBox = new QCheckBox(this); 262 AssertPtrReturnVoid(m_pHighlightAllCheckBox); 263 { 264 /* Configure font: */ 287 265 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 288 289 290 266 QFont font = m_pHighlightAllCheckBox->font(); 267 font.setPointSize(::darwinSmallFontSize()); 268 m_pHighlightAllCheckBox->setFont(font); 291 269 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 292 293 m_pMainLayout->addWidget(m_pHighlightAllCheckBox);294 295 296 297 298 299 300 301 m_pMainLayout->addItem(m_pWarningSpacer);302 303 304 305 306 307 308 309 310 311 312 313 314 m_pMainLayout->addWidget(m_pWarningIcon);315 316 317 318 319 320 321 322 323 270 /* Add case-sensitive checkbox to main-layout: */ 271 mainLayout()->addWidget(m_pHighlightAllCheckBox); 272 } 273 274 /* Create warning-spacer: */ 275 m_pWarningSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); 276 AssertPtrReturnVoid(m_pWarningSpacer); 277 { 278 /* Add warning-spacer to main-layout: */ 279 mainLayout()->addItem(m_pWarningSpacer); 280 } 281 282 /* Create warning-icon: */ 283 m_pWarningIcon = new QLabel(this); 284 AssertPtrReturnVoid(m_pWarningIcon); 285 { 286 /* Confifure warning-icon: */ 287 m_pWarningIcon->hide(); 288 QIcon icon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning, this); 289 if (!icon.isNull()) 290 m_pWarningIcon->setPixmap(icon.pixmap(16, 16)); 291 /* Add warning-icon to main-layout: */ 292 mainLayout()->addWidget(m_pWarningIcon); 293 } 294 295 /* Create warning-label: */ 296 m_pInfoLabel = new QLabel(this); 297 AssertPtrReturnVoid(m_pInfoLabel); 298 { 299 /* Configure warning-label: */ 300 m_pInfoLabel->hide(); 301 /* Prepare font: */ 324 302 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 325 326 327 303 QFont font = m_pInfoLabel->font(); 304 font.setPointSize(::darwinSmallFontSize()); 305 m_pInfoLabel->setFont(font); 328 306 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 329 /* Add warning-label to main-layout: */ 330 m_pMainLayout->addWidget(m_pInfoLabel); 331 } 332 333 /* Create spacer-item: */ 334 m_pSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 335 AssertPtrReturnVoid(m_pSpacerItem); 336 { 337 /* Add spacer-item to main-layout: */ 338 m_pMainLayout->addItem(m_pSpacerItem); 339 } 307 /* Add warning-label to main-layout: */ 308 mainLayout()->addWidget(m_pInfoLabel); 309 } 310 311 m_pSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 312 AssertPtrReturnVoid(m_pSpacerItem); 313 { 314 mainLayout()->addItem(m_pSpacerItem); 340 315 } 341 316 } … … 343 318 void UIVMLogViewerSearchPanel::prepareConnections() 344 319 { 345 /* Prepare connections: */346 connect(m_pCloseButton, &UIMiniCancelButton::clicked, this, &UIVMLogViewerSearchPanel::hide);347 320 connect(m_pSearchEditor, &UISearchField::textChanged, this, &UIVMLogViewerSearchPanel::sltSearchTextChanged); 348 321 connect(m_pNextPrevButtons, &UIRoundRectSegmentedButton::clicked, this, &UIVMLogViewerSearchPanel::find); … … 357 330 void UIVMLogViewerSearchPanel::retranslateUi() 358 331 { 359 m_pCloseButton->setToolTip(UIVMLogViewerWidget::tr("Close the search panel"));360 361 332 m_pSearchLabel->setText(QString("%1 ").arg(UIVMLogViewerWidget::tr("&Find"))); 362 333 m_pSearchEditor->setToolTip(UIVMLogViewerWidget::tr("Enter a search string here")); … … 402 373 } 403 374 /* Call to base-class: */ 404 QWidget::keyPressEvent(pEvent);375 UIVMLogViewerPanel::keyPressEvent(pEvent); 405 376 } 406 377 … … 439 410 pKeyEvent->key() == Qt::Key_F) 440 411 { 441 if ( m_pViewer->currentLogPage())412 if (viewer() && viewer()->currentLogPage()) 442 413 { 443 414 /* Make sure current log-page is visible: */ … … 454 425 { 455 426 /* Make sure current log-page is visible: */ 456 if ( m_pViewer->currentLogPage())427 if (viewer() && viewer()->currentLogPage()) 457 428 { 458 429 if (isHidden()) … … 471 442 } 472 443 /* Call to base-class: */ 473 return QWidget::eventFilter(pObject, pEvent);444 return UIVMLogViewerPanel::eventFilter(pObject, pEvent); 474 445 } 475 446 … … 477 448 { 478 449 /* Call to base-class: */ 479 QWidget::showEvent(pEvent);450 UIVMLogViewerPanel::showEvent(pEvent); 480 451 /* Set focus on search-editor: */ 481 452 m_pSearchEditor->setFocus(); … … 486 457 void UIVMLogViewerSearchPanel::search(SearchDirection direction, bool highlight) 487 458 { 488 QPlainTextEdit *pTextEdit = m_pViewer->currentLogPage(); 489 if (!pTextEdit) return; 490 QTextDocument *pDocument = pTextEdit->document(); 491 if (!pDocument) 492 return; 493 494 const QString &searchString = m_pSearchEditor->text(); 495 if (searchString.isEmpty()) 496 return; 497 498 QTextCursor endCursor(pDocument); 499 endCursor.movePosition(QTextCursor::End); 500 QTextCursor startCursor(pDocument); 501 502 if (m_pHighlightAllCheckBox->isChecked()) 503 { 504 if (highlight) 505 highlightAll(pDocument, searchString); 506 } 507 else 508 { 509 m_iMatchCount = -1; 510 m_matchLocationVector.clear(); 511 } 512 513 QTextCursor resultCursor(pDocument); 514 int startPosition = m_iSearchPosition; 515 if (direction == BackwardSearch) 516 startPosition -= searchString.length(); 517 resultCursor = pDocument->find(searchString, startPosition, constructFindFlags(direction)); 518 519 /* Decide whether to wrap around or to end the search */ 520 if (resultCursor.isNull()) 521 { 522 /* End the search if we search the whole document with no find: */ 523 if ((direction == ForwardSearch && startPosition == startCursor.position()) || 524 (direction == BackwardSearch && startPosition == endCursor.position())) 525 { 526 /* Set the match count 0 here since we did not call highLightAll function: */ 527 if (!m_pHighlightAllCheckBox->isChecked()) 528 m_iMatchCount = 0; 529 configureInfoLabels(); 530 return; 531 } 532 /* Wrap the search */ 533 if (direction == ForwardSearch) 534 { 535 m_iSearchPosition = startCursor.position(); 536 search(ForwardSearch, false); 537 return; 538 } 539 else 540 { 541 /* Set the search position away from the end position to be 542 able to find the string at the end of the document: */ 543 m_iSearchPosition = endCursor.position() + searchString.length(); 544 search(BackwardSearch, false); 545 return; 546 } 547 } 548 pTextEdit->setTextCursor(resultCursor); 549 m_iSearchPosition = resultCursor.position(); 550 configureInfoLabels(); 459 if (!viewer()) 460 return; 461 QPlainTextEdit *pTextEdit = viewer()->currentLogPage(); 462 if (!pTextEdit) return; 463 QTextDocument *pDocument = pTextEdit->document(); 464 if (!pDocument) 465 return; 466 467 const QString &searchString = m_pSearchEditor->text(); 468 if (searchString.isEmpty()) 469 return; 470 471 QTextCursor endCursor(pDocument); 472 endCursor.movePosition(QTextCursor::End); 473 QTextCursor startCursor(pDocument); 474 475 if (m_pHighlightAllCheckBox->isChecked()) 476 { 477 if (highlight) 478 highlightAll(pDocument, searchString); 479 } 480 else 481 { 482 m_iMatchCount = -1; 483 m_matchLocationVector.clear(); 484 } 485 486 QTextCursor resultCursor(pDocument); 487 int startPosition = m_iSearchPosition; 488 if (direction == BackwardSearch) 489 startPosition -= searchString.length(); 490 resultCursor = pDocument->find(searchString, startPosition, constructFindFlags(direction)); 491 492 /* Decide whether to wrap around or to end the search */ 493 if (resultCursor.isNull()) 494 { 495 /* End the search if we search the whole document with no find: */ 496 if ((direction == ForwardSearch && startPosition == startCursor.position()) || 497 (direction == BackwardSearch && startPosition == endCursor.position())) 498 { 499 /* Set the match count 0 here since we did not call highLightAll function: */ 500 if (!m_pHighlightAllCheckBox->isChecked()) 501 m_iMatchCount = 0; 502 configureInfoLabels(); 503 return; 504 } 505 /* Wrap the search */ 506 if (direction == ForwardSearch) 507 { 508 m_iSearchPosition = startCursor.position(); 509 search(ForwardSearch, false); 510 return; 511 } 512 else 513 { 514 /* Set the search position away from the end position to be 515 able to find the string at the end of the document: */ 516 m_iSearchPosition = endCursor.position() + searchString.length(); 517 search(BackwardSearch, false); 518 return; 519 } 520 } 521 pTextEdit->setTextCursor(resultCursor); 522 m_iSearchPosition = resultCursor.position(); 523 configureInfoLabels(); 551 524 } 552 525 … … 563 536 void UIVMLogViewerSearchPanel::clearHighlighting(int count) 564 537 { 538 if (!viewer()) 539 return; 565 540 m_iMatchCount = count; 566 541 m_matchLocationVector.clear(); 567 542 568 QPlainTextEdit *pBrowser = m_pViewer->currentLogPage();569 if (pBrowser)543 QPlainTextEdit *pBrowser = viewer()->currentLogPage(); 544 if (pBrowser) 570 545 { 571 546 QTextDocument* pDocument = pBrowser->document(); 572 if (pDocument)547 if (pDocument) 573 548 pDocument->undo(); 574 549 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h
r70476 r70500 21 21 /* Qt includes: */ 22 22 #include <QTextDocument> 23 #include <QWidget>24 23 25 24 /* GUI includes: */ 26 #include " QIWithRetranslateUI.h"25 #include "UIVMLogViewerPanel.h" 27 26 28 27 /* Forward declarations: */ … … 38 37 /** QWidget extension 39 38 * providing GUI for search-panel in VM Log-Viewer. */ 40 class UIVMLogViewerSearchPanel : public QIWithRetranslateUI<QWidget>39 class UIVMLogViewerSearchPanel : public UIVMLogViewerPanel 41 40 { 42 41 Q_OBJECT; … … 58 57 protected: 59 58 59 60 /** Prepares widgets. */ 61 virtual void prepareWidgets() /* override */; 62 virtual void prepareConnections() /* override */; 63 /** Handles translation event. */ 64 virtual void retranslateUi() /* override */; 65 /** Handles Qt key-press @a pEevent. */ 66 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 67 /** Handles Qt @a pEvent, used for keyboard processing. */ 68 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 69 /** Handles Qt show @a pEvent. */ 70 virtual void showEvent(QShowEvent *pEvent) /* override */; 60 71 virtual void hideEvent(QHideEvent* pEvent) /* override */; 61 72 … … 75 86 76 87 enum SearchDirection { ForwardSearch, BackwardSearch }; 77 /** Prepares search-panel. */78 void prepare();79 /** Prepares widgets. */80 void prepareWidgets();81 void prepareConnections();82 88 83 /** Handles translation event. */84 void retranslateUi();85 86 /** Handles Qt key-press @a pEevent. */87 void keyPressEvent(QKeyEvent *pEvent);88 /** Handles Qt @a pEvent, used for keyboard processing. */89 bool eventFilter(QObject *pObject, QEvent *pEvent);90 /** Handles Qt show @a pEvent. */91 void showEvent(QShowEvent *pEvent);92 89 /** Clear the result of highlight */ 93 90 void clearHighlight(); … … 110 107 QTextDocument::FindFlags constructFindFlags(SearchDirection eDirection); 111 108 112 /** Holds the reference to the VM Log-Viewer this search-panel belongs to. */113 UIVMLogViewerWidget *m_pViewer;114 /** Holds the instance of main-layout we create. */115 QHBoxLayout *m_pMainLayout;116 /** Holds the instance of close-button we create. */117 UIMiniCancelButton *m_pCloseButton;118 109 /** Holds the instance of search-label we create. */ 119 110 QLabel *m_pSearchLabel; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70487 r70500 151 151 m_iContextMenuBookmark.second = block.text(); 152 152 153 if (pAction)153 if (pAction) 154 154 connect(pAction, &QAction::triggered, this, &UIVMLogViewerTextEdit::sltBookmark); 155 155 156 156 menu->exec(pEvent->globalPos()); 157 157 158 if (pAction)158 if (pAction) 159 159 disconnect(pAction, &QAction::triggered, this, &UIVMLogViewerTextEdit::sltBookmark); 160 160 … … 236 236 } 237 237 238 void UIVMLogViewerWidget::sltPanelActionTriggered(bool checked) 239 { 240 QAction *pSenderAction = qobject_cast<QAction*>(sender()); 241 if(!pSenderAction) 242 return; 243 /* Look for the sender() within the m_panelActionMap's values: */ 244 for(QMap<UIVMLogViewerPanel**, QAction**>::const_iterator iterator = m_panelActionMap.begin(); 245 iterator != m_panelActionMap.end(); ++iterator) 246 { 247 if(iterator.value() == &pSenderAction) 248 continue; 249 } 250 } 251 238 252 void UIVMLogViewerWidget::sltShowHideSearchPanel() 239 253 { 240 if (!m_pSearchPanel)254 if (!m_pSearchPanel) 241 255 return; 242 256 /* Show/hide search-panel: */ … … 296 310 297 311 /* Apply the filter settings: */ 298 if (m_pFilterPanel)312 if (m_pFilterPanel) 299 313 m_pFilterPanel->applyFilter(); 300 314 … … 321 335 return; 322 336 UIVMLogViewerTextEdit *logPage = qobject_cast<UIVMLogViewerTextEdit*>(currentLogPage()); 323 if (!logPage)337 if (!logPage) 324 338 return; 325 339 /* Prepare "save as" dialog: */ … … 351 365 void UIVMLogViewerWidget::sltShowHideFilterPanel() 352 366 { 353 if (!m_pFilterPanel)367 if (!m_pFilterPanel) 354 368 return; 355 369 /* Show/hide filter-panel: */ … … 391 405 void UIVMLogViewerWidget::sltShowHideBookmarkPanel() 392 406 { 393 if (!m_pBookmarksPanel)407 if (!m_pBookmarksPanel) 394 408 return; 395 409 m_pBookmarksPanel->isHidden() ? m_pBookmarksPanel->show() : m_pBookmarksPanel->hide(); … … 398 412 void UIVMLogViewerWidget::sltCreateBookmarkAtCurrent() 399 413 { 400 if (!currentLogPage())414 if (!currentLogPage()) 401 415 return; 402 416 QWidget* viewport = currentLogPage()->viewport(); … … 414 428 { 415 429 QVector<LogBookmark> *pBookmarkVector = currentBookmarkVector(); 416 if (!pBookmarkVector)430 if (!pBookmarkVector) 417 431 return; 418 432 pBookmarkVector->push_back(bookmark); 419 if (m_pBookmarksPanel)420 { 421 m_pBookmarksPanel->update ();433 if (m_pBookmarksPanel) 434 { 435 m_pBookmarksPanel->updateBookmarkList(); 422 436 m_pBookmarksPanel->setBookmarkIndex(pBookmarkVector->size() - 1); 423 437 } … … 499 513 AssertPtrReturnVoid(m_pBookmarksPanel); 500 514 { 515 //QMap<UIVMLogViewerPanel*&, QAction*&> m_panelActionMap; 516 m_panelActionMap.insert(reinterpret_cast<UIVMLogViewerPanel**>(&m_pBookmarksPanel), &m_pActionBookmark); 517 //connect(m_pBookmarksPanel, &UIVMLogViewerBookmarksPanel::sigHide, this, &UIVMLogViewerWidget::sltHidePanel); 501 518 installEventFilter(m_pBookmarksPanel); 502 519 m_pBookmarksPanel->hide(); … … 764 781 const QString* UIVMLogViewerWidget::currentLog() 765 782 { 766 if (!currentLogPage())783 if (!currentLogPage()) 767 784 return 0; 768 785 return &(m_logMap[currentLogPage()]); … … 787 804 { 788 805 UIVMLogViewerTextEdit *logPage = qobject_cast<UIVMLogViewerTextEdit*>(currentLogPage()); 789 if (!logPage)806 if (!logPage) 790 807 return 0; 791 808 QString logFileName = logPage->logFileName(); 792 if (logFileName.isEmpty())809 if (logFileName.isEmpty()) 793 810 return 0; 794 811 … … 799 816 { 800 817 UIVMLogViewerTextEdit *logPage = qobject_cast<UIVMLogViewerTextEdit*>(currentLogPage()); 801 if (!logPage)818 if (!logPage) 802 819 return 0; 803 820 QString logFileName = logPage->logFileName(); 804 if (logFileName.isEmpty())821 if (logFileName.isEmpty()) 805 822 return 0; 806 823 … … 808 825 } 809 826 827 void UIVMLogViewerWidget::hidePanel(UIVMLogViewerPanel* panel) 828 { 829 if (!panel || panel->isHidden()) 830 return; 831 panel->setVisible(false); 832 } 833 834 void UIVMLogViewerWidget::showPanel(UIVMLogViewerPanel* panel) 835 { 836 if (!panel || panel->isVisible()) 837 return; 838 panel->setVisible(true); 839 } 810 840 811 841 QPlainTextEdit* UIVMLogViewerWidget::logPage(int pIndex) const -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70487 r70500 39 39 class UIVMLogViewerBookmarksPanel; 40 40 class UIVMLogViewerFilterPanel; 41 class UIVMLogViewerPanel; 41 42 class UIVMLogViewerSearchPanel; 42 43 … … 88 89 void sltSave(); 89 90 91 void sltPanelActionTriggered(bool checked); 90 92 void sltShowHideFilterPanel(); 91 93 void sltShowHideSearchPanel(); 92 94 void sltShowHideBookmarkPanel(); 95 /* Handles QAction sync. when a panel is closed (hidden) by panel's own close button */ 96 //void sltPanelCloseButton(); 93 97 94 98 /** Handles the search result highlight changes. */ … … 150 154 const QVector<LogBookmark>* currentBookmarkVector() const; 151 155 156 void hidePanel(UIVMLogViewerPanel* panel); 157 void showPanel(UIVMLogViewerPanel* panel); 158 152 159 /** Holds whether the dialog is polished. */ 153 160 bool m_fIsPolished; … … 163 170 164 171 /** Holds the instance of search-panel. */ 165 UIVMLogViewerSearchPanel *m_pSearchPanel;172 UIVMLogViewerSearchPanel *m_pSearchPanel; 166 173 /** Holds the instance of filter panel. */ 167 UIVMLogViewerFilterPanel *m_pFilterPanel;174 UIVMLogViewerFilterPanel *m_pFilterPanel; 168 175 UIVMLogViewerBookmarksPanel *m_pBookmarksPanel; 176 QMap<UIVMLogViewerPanel**, QAction**> m_panelActionMap; 169 177 170 178 /** Holds the list of log file content. */
Note:
See TracChangeset
for help on using the changeset viewer.