VirtualBox

Changeset 70664 in vbox


Ignore:
Timestamp:
Jan 22, 2018 7:09:07 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt Some code style changes

Location:
trunk/src/VBox/Frontends/VirtualBox/src/logviewer
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerBookmarksPanel.cpp

    r70617 r70664  
    100100    m_pBookmarksComboBox = new QComboBox(this);
    101101    QFontMetrics fontMetrics = m_pBookmarksComboBox->fontMetrics();
    102     AssertPtrReturnVoid(m_pBookmarksComboBox);
    103     m_pBookmarksComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
    104     m_pBookmarksComboBox->setMaximumWidth(fontMetrics.width('a') * (m_iMaxBookmarkTextLength + 2));
    105     /* Make sure we have 0th item in our combo box. */
    106     m_pBookmarksComboBox->insertItem(0, "");
    107     mainLayout()->addWidget(m_pBookmarksComboBox, 2);
     102    if (m_pBookmarksComboBox)
     103    {
     104        m_pBookmarksComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
     105        m_pBookmarksComboBox->setMaximumWidth(fontMetrics.width('a') * (m_iMaxBookmarkTextLength + 2));
     106        /* Make sure we have 0th item in our combo box. */
     107        m_pBookmarksComboBox->insertItem(0, "");
     108        mainLayout()->addWidget(m_pBookmarksComboBox, 2);
     109    }
    108110
    109111    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 
     112    if (m_pGotoSelectedBookmark)
     113    {
     114        mainLayout()->addWidget(m_pGotoSelectedBookmark, 0);
     115        m_pGotoSelectedBookmark->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
     116    }
    114117
    115118    m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2);
    116     AssertPtrReturnVoid(m_pNextPrevButtons);
    117     m_pNextPrevButtons->setEnabled(0, false);
    118     m_pNextPrevButtons->setEnabled(1, false);
     119    if (m_pNextPrevButtons)
     120    {
     121        m_pNextPrevButtons->setEnabled(0, false);
     122        m_pNextPrevButtons->setEnabled(1, false);
    119123#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));
     124        /* No icons on the Mac: */
     125        m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this));
     126        m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
    123127#endif /* !VBOX_WS_MAC */
    124     mainLayout()->addWidget(m_pNextPrevButtons);
    125     m_pNextPrevButtons->setEnabled(0, true);
    126     m_pNextPrevButtons->setEnabled(1, true);
     128        mainLayout()->addWidget(m_pNextPrevButtons);
     129        m_pNextPrevButtons->setEnabled(0, true);
     130        m_pNextPrevButtons->setEnabled(1, true);
     131    }
    127132
    128133    m_pDeleteCurrentButton = new QIToolButton(this);
    129     AssertPtrReturnVoid(m_pDeleteCurrentButton);
    130     mainLayout()->addWidget(m_pDeleteCurrentButton, 0);
    131     m_pDeleteCurrentButton->setIcon(m_pDeleteCurrentButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
     134    if (m_pDeleteCurrentButton)
     135    {
     136        mainLayout()->addWidget(m_pDeleteCurrentButton, 0);
     137        m_pDeleteCurrentButton->setIcon(m_pDeleteCurrentButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
     138    }
    132139
    133140    m_pDeleteAllButton = new QIToolButton(this);
    134     AssertPtrReturnVoid(m_pDeleteAllButton);
    135     mainLayout()->addWidget(m_pDeleteAllButton, 0);
     141    if (m_pDeleteAllButton)
     142    {
     143        mainLayout()->addWidget(m_pDeleteAllButton, 0);
     144    }
    136145
    137146    mainLayout()->addStretch(4);
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.cpp

    r70610 r70664  
    7676    /* Create widget: */
    7777    UIVMLogViewerWidget *pWidget = new UIVMLogViewerWidget(EmbedTo_Dialog, this, m_comMachine);
    78     AssertPtrReturnVoid(pWidget);
     78    if (pWidget)
    7979    {
    8080        /* Configure widget: */
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp

    r70663 r70664  
    157157    {
    158158        m_pRemoveTermButton = new QToolButton(this);
    159         AssertReturnVoid(m_pRemoveTermButton);
    160         m_pRemoveTermButton->setIcon(m_pRemoveTermButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
    161         m_pRemoveTermButton->hide();
     159        if (m_pRemoveTermButton)
     160        {
     161            m_pRemoveTermButton->setIcon(m_pRemoveTermButton->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
     162            m_pRemoveTermButton->hide();
     163            connect(m_pRemoveTermButton, &QToolButton::clicked, this, &UIVMFilterLineEdit::sltRemoveFilterTerm);
     164        }
    162165
    163166        m_pClearAllButton = new QToolButton(this);
    164         AssertReturnVoid(m_pClearAllButton);
    165         m_pClearAllButton->setIcon(m_pRemoveTermButton->style()->standardIcon(QStyle::SP_LineEditClearButton));
    166 
    167         connect(m_pRemoveTermButton, &QToolButton::clicked, this, &UIVMFilterLineEdit::sltRemoveFilterTerm);
    168         connect(m_pClearAllButton, &QToolButton::clicked, this, &UIVMFilterLineEdit::sltClearAll);
     167        if (m_pClearAllButton)
     168        {
     169            m_pClearAllButton->setIcon(m_pRemoveTermButton->style()->standardIcon(QStyle::SP_LineEditClearButton));
     170            connect(m_pClearAllButton, &QToolButton::clicked, this, &UIVMFilterLineEdit::sltClearAll);
     171        }
    169172    }
    170173
     
    356359
    357360    m_pFilterComboBox = new QComboBox(this);
    358     AssertPtrReturnVoid(m_pFilterComboBox);
     361    if (m_pFilterComboBox)
    359362    {
    360363        m_pFilterComboBox->setEditable(true);
     
    368371
    369372    m_pAddFilterTermButton = new QIToolButton(this);
    370     AssertPtrReturnVoid(m_pAddFilterTermButton);
     373    if (m_pAddFilterTermButton)
    371374    {
    372375        m_pAddFilterTermButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));
     
    375378
    376379    m_pFilterTermsLineEdit = new UIVMFilterLineEdit(this);
    377     AssertPtrReturnVoid(m_pFilterTermsLineEdit);
     380    if (m_pFilterTermsLineEdit)
    378381    {
    379382        mainLayout()->addWidget(m_pFilterTermsLineEdit, 4);
     
    382385
    383386    m_pResultLabel = new QLabel(this);
    384     AssertPtrReturnVoid(m_pResultLabel);
     387    if (m_pResultLabel)
    385388    {
    386389        mainLayout()->addWidget(m_pResultLabel,0);
     
    388391        /* Create filter-label: */
    389392//         m_pFilterLabel = new QLabel(this);
    390 //         AssertPtrReturnVoid(m_pFilterLabel);
     393//         if (m_pFilterLabel)
    391394//         {
    392395//             /* Configure filter-label: */
     
    406409    /* Create radio-button container: */
    407410    m_pRadioButtonContainer = new QFrame;
    408     AssertPtrReturnVoid(m_pRadioButtonContainer);
     411    if (m_pRadioButtonContainer)
    409412    {
    410413        /* Configure container: */
     
    413416        /* Create container layout: */
    414417        QHBoxLayout *pContainerLayout = new QHBoxLayout(m_pRadioButtonContainer);
    415         AssertPtrReturnVoid(pContainerLayout);
     418        if (pContainerLayout)
    416419        {
    417420            /* Configure layout: */
     
    427430            /* Create button-group: */
    428431            m_pButtonGroup = new QButtonGroup(this);
    429             AssertPtrReturnVoid(m_pButtonGroup);
     432            if (m_pButtonGroup)
    430433            {
    431434                /* Create 'Or' radio-button: */
    432435                m_pOrRadioButton = new QRadioButton;
    433                 AssertPtrReturnVoid(m_pOrRadioButton);
     436                if (m_pOrRadioButton)
    434437                {
    435438                    /* Configure radio-button: */
     
    444447                /* Create 'And' radio-button: */
    445448                m_pAndRadioButton = new QRadioButton;
    446                 AssertPtrReturnVoid(m_pAndRadioButton);
     449                if (m_pAndRadioButton)
    447450                {
    448451                    /* Configure radio-button: */
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.h

    r70645 r70664  
    6666    virtual void prepareConnections() /* override */;
    6767
    68     /** Handles the translation event. */
    6968    void retranslateUi() /* override */;
    7069    /** Handles Qt @a pEvent, used for keyboard processing. */
    7170    bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
    72     /** Handles the Qt show @a pEvent. */
    7371    void showEvent(QShowEvent *pEvent) /* override */;
    7472
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.cpp

    r70539 r70664  
    7474{
    7575    m_pMainLayout = new QHBoxLayout(this);
    76     AssertPtrReturnVoid(m_pMainLayout);
    77     m_pMainLayout->setContentsMargins(0, 0, 0, 0);
    78     m_pMainLayout->setSpacing(2);
    79 
     76    if (m_pMainLayout)
     77    {
     78        m_pMainLayout->setContentsMargins(0, 0, 0, 0);
     79        m_pMainLayout->setSpacing(2);
     80    }
    8081    m_pCloseButton = new UIMiniCancelButton(this);
    81     AssertPtrReturnVoid(m_pCloseButton);
    82     m_pMainLayout->addWidget(m_pCloseButton, 0, Qt::AlignLeft);
     82    if (m_pCloseButton)
     83    {
     84        m_pMainLayout->addWidget(m_pCloseButton, 0, Qt::AlignLeft);
     85    }
    8386}
    8487
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.cpp

    r70645 r70664  
    185185    /* Create search-editor: */
    186186    m_pSearchEditor = new UISearchField(this);
    187     AssertPtrReturnVoid(m_pSearchEditor);
     187    if (m_pSearchEditor)
    188188    {
    189189        /* Configure search-editor: */
     
    195195    /* Create search-label: */
    196196    m_pSearchLabel = new QLabel(this);
    197     AssertPtrReturnVoid(m_pSearchLabel);
     197    if (m_pSearchLabel)
    198198    {
    199199        /* Configure search-label: */
     
    211211    /* Create Next/Prev button-box: */
    212212    m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2);
    213     AssertPtrReturnVoid(m_pNextPrevButtons);
     213    if (m_pNextPrevButtons)
    214214    {
    215215        /* Configure Next/Prev button-box: */
     
    227227    /* Create case-sensitive checkbox: */
    228228    m_pCaseSensitiveCheckBox = new QCheckBox;
    229     AssertPtrReturnVoid(m_pCaseSensitiveCheckBox);
     229    if (m_pCaseSensitiveCheckBox)
    230230    {
    231231        /* Configure font: */
     
    240240
    241241    m_pMatchWholeWordCheckBox = new QCheckBox(this);
    242     AssertPtrReturnVoid(m_pMatchWholeWordCheckBox);
     242    if (m_pMatchWholeWordCheckBox)
    243243    {
    244244        /* Configure focus for case-sensitive checkbox: */
     
    254254
    255255    m_pHighlightAllCheckBox = new QCheckBox(this);
    256     AssertPtrReturnVoid(m_pHighlightAllCheckBox);
     256    if (m_pHighlightAllCheckBox)
    257257    {
    258258        /* Configure font: */
     
    268268    /* Create warning-icon: */
    269269    m_pWarningIcon = new QLabel(this);
    270     AssertPtrReturnVoid(m_pWarningIcon);
     270    if (m_pWarningIcon)
    271271    {
    272272        /* Confifure warning-icon: */
     
    281281    /* Create warning-label: */
    282282    m_pInfoLabel = new QLabel(this);
    283     AssertPtrReturnVoid(m_pInfoLabel);
     283    if (m_pInfoLabel)
    284284    {
    285285        /* Configure warning-label: */
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSearchPanel.h

    r70581 r70664  
    5656protected:
    5757
    58 
    59     /** Prepares widgets. */
    6058    virtual void prepareWidgets() /* override */;
    6159    virtual void prepareConnections() /* override */;
    62     /** Handles translation event. */
    6360    virtual void retranslateUi() /* override */;
    6461    /** Handles Qt key-press @a pEevent. */
     
    6663    /** Handles Qt @a pEvent, used for keyboard processing. */
    6764    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
    68     /** Handles Qt show @a pEvent. */
    6965    virtual void showEvent(QShowEvent *pEvent) /* override */;
    7066    virtual void hideEvent(QHideEvent* pEvent) /* override */;
     
    8682    enum SearchDirection { ForwardSearch, BackwardSearch };
    8783
    88     /** Clear the result of highlight */
     84    /** Clear the highlighting */
    8985    void clearHighlight();
    9086    void clearHighlighting(int count);
     
    105101    /** Constructs the find flags for QTextDocument::find function. */
    106102    QTextDocument::FindFlags constructFindFlags(SearchDirection eDirection);
    107 
    108103
    109104    /** Holds the instance of search-label we create. */
     
    130125      n > 0: n matches found. */
    131126    int          m_iMatchCount;
    132     /** Stores relative positions of the lines of the matches. The values are [0,1] 0 being the first line 1 being the last. */
     127    /** Stores relative positions of the lines of the matches. The values are [0,1]
     128        0 being the first line 1 being the last. */
    133129    QVector<float> m_matchLocationVector;
    134130};
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r70663 r70664  
    385385    /* Create VM Log-Viewer container: */
    386386    m_pTabWidget = new QITabWidget(this);
    387     AssertPtrReturnVoid(m_pTabWidget);
     387    if (m_pTabWidget)
    388388    {
    389389        /* Add VM Log-Viewer container to main-layout: */
     
    393393    /* Create VM Log-Viewer search-panel: */
    394394    m_pSearchPanel = new UIVMLogViewerSearchPanel(this, this);
    395     AssertPtrReturnVoid(m_pSearchPanel);
     395    if (m_pSearchPanel)
    396396    {
    397397        /* Configure VM Log-Viewer search-panel: */
     
    406406    /* Create VM Log-Viewer filter-panel: */
    407407    m_pFilterPanel = new UIVMLogViewerFilterPanel(this, this);
    408     AssertPtrReturnVoid(m_pFilterPanel);
     408    if (m_pFilterPanel)
    409409    {
    410410        /* Configure VM Log-Viewer filter-panel: */
     
    418418
    419419    m_pBookmarksPanel = new UIVMLogViewerBookmarksPanel(this, this);
    420     AssertPtrReturnVoid(m_pBookmarksPanel);
     420    if (m_pBookmarksPanel)
    421421    {
    422422        installEventFilter(m_pBookmarksPanel);
     
    432432
    433433    m_pSettingsPanel = new UIVMLogViewerSettingsPanel(this, this);
    434     AssertPtrReturnVoid(m_pSettingsPanel);
     434    if (m_pSettingsPanel)
    435435    {
    436436        installEventFilter(m_pSettingsPanel);
    437437        m_pSettingsPanel->hide();
    438         /* Initialize settings' panel checkboxes: */
     438        /* Initialize settings' panel checkboxes and input fields: */
    439439        m_pSettingsPanel->setShowLineNumbers(m_bShowLineNumbers);
    440440        m_pSettingsPanel->setWrapLines(m_bWrapLines);
     
    452452    /* Create and configure 'Find' action: */
    453453    m_pActionFind = new QAction(this);
    454     AssertPtrReturnVoid(m_pActionFind);
     454    if (m_pActionFind)
    455455    {
    456456        m_pActionFind->setShortcut(QKeySequence("Ctrl+F"));
     
    461461    /* Create and configure 'Filter' action: */
    462462    m_pActionFilter = new QAction(this);
    463     AssertPtrReturnVoid(m_pActionFilter);
     463    if (m_pActionFilter)
    464464    {
    465465        m_pActionFilter->setShortcut(QKeySequence("Ctrl+T"));
     
    469469    /* Create and configure 'Bookmark' action: */
    470470    m_pActionBookmark = new QAction(this);
    471     AssertPtrReturnVoid(m_pActionBookmark);
     471    if (m_pActionBookmark)
    472472    {
    473473        /* tie Ctrl+D to save only if we show this in a dialog since Ctrl+D is
     
    481481    /* Create and configure 'Settings' action: */
    482482    m_pActionSettings = new QAction(this);
    483     AssertPtrReturnVoid(m_pActionSettings);
     483    if (m_pActionSettings)
    484484    {
    485485        m_pActionSettings->setCheckable(true);
     
    490490    /* Create and configure 'Refresh' action: */
    491491    m_pActionRefresh = new QAction(this);
    492     AssertPtrReturnVoid(m_pActionRefresh);
     492    if (m_pActionRefresh)
    493493    {
    494494        m_pActionRefresh->setShortcut(QKeySequence("F5"));
     
    498498    /* Create and configure 'Save' action: */
    499499    m_pActionSave = new QAction(this);
    500     AssertPtrReturnVoid(m_pActionSave);
     500    if (m_pActionSave)
    501501    {
    502502        /* tie Ctrl+S to save only if we show this in a dialog since Ctrl+S is
     
    546546    /* Create toolbar: */
    547547    m_pToolBar = new UIToolBar(parentWidget());
    548     AssertPtrReturnVoid(m_pToolBar);
     548    if (m_pToolBar)
    549549    {
    550550        /* Configure toolbar: */
     
    589589    /* Create 'LogViewer' menu: */
    590590    m_pMenu = new QMenu(this);
    591     AssertPtrReturnVoid(m_pMenu);
     591    if (m_pMenu)
    592592    {
    593593        if (m_pActionFind)
     
    834834void UIVMLogViewerWidget::createLogPage(const QString &strFileName, const QString &strLogContent, bool noLogsToShow /* = false */)
    835835{
    836     AssertPtrReturnVoid(m_pTabWidget);
     836    if (!m_pTabWidget)
     837        return;
    837838
    838839    /* Create page-container: */
    839840    UIVMLogPage* pLogPage = new UIVMLogPage(this);
    840     AssertPtrReturnVoid(pLogPage);
    841 
    842     connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltUpdateBookmarkPanel);
    843     connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIVMLogViewerWidget::sltLogPageFilteredChanged);
    844     /* Initialize setting for this log page */
    845     pLogPage->setShowLineNumbers(m_bShowLineNumbers);
    846     pLogPage->setWrapLines(m_bWrapLines);
    847     pLogPage->setFontSizeInPoints(m_iFontSizeInPoints);
    848 
    849     /* Set the file name only if we really have log file to read. */
    850     if (!noLogsToShow)
    851         pLogPage->setFileName(strFileName);
    852 
    853     /* Add page-container to viewer-container: */
    854     int tabIndex = m_pTabWidget->insertTab(m_pTabWidget->count(), pLogPage, QFileInfo(strFileName).fileName());
    855 
    856     pLogPage->setTabIndex(tabIndex);
    857     m_logPageList.resize(m_pTabWidget->count());
    858     m_logPageList[tabIndex] = pLogPage;
    859 
    860     /* Set the log string of the UIVMLogPage: */
    861     pLogPage->setLogString(strLogContent);
    862     /* Set text edit since we want to display this text: */
    863     if (!noLogsToShow)
    864         pLogPage->setTextEditText(strLogContent);
    865     /* In case there are some errors append the error text as html: */
    866     else
    867     {
    868         pLogPage->setTextEditTextAsHtml(strLogContent);
    869         pLogPage->markForError();
     841    if (pLogPage)
     842    {
     843        connect(pLogPage, &UIVMLogPage::sigBookmarksUpdated, this, &UIVMLogViewerWidget::sltUpdateBookmarkPanel);
     844        connect(pLogPage, &UIVMLogPage::sigLogPageFilteredChanged, this, &UIVMLogViewerWidget::sltLogPageFilteredChanged);
     845        /* Initialize setting for this log page */
     846        pLogPage->setShowLineNumbers(m_bShowLineNumbers);
     847        pLogPage->setWrapLines(m_bWrapLines);
     848        pLogPage->setFontSizeInPoints(m_iFontSizeInPoints);
     849
     850        /* Set the file name only if we really have log file to read. */
     851        if (!noLogsToShow)
     852            pLogPage->setFileName(strFileName);
     853
     854        /* Add page-container to viewer-container: */
     855        int tabIndex = m_pTabWidget->insertTab(m_pTabWidget->count(), pLogPage, QFileInfo(strFileName).fileName());
     856
     857        pLogPage->setTabIndex(tabIndex);
     858        m_logPageList.resize(m_pTabWidget->count());
     859        m_logPageList[tabIndex] = pLogPage;
     860
     861        /* Set the log string of the UIVMLogPage: */
     862        pLogPage->setLogString(strLogContent);
     863        /* Set text edit since we want to display this text: */
     864        if (!noLogsToShow)
     865            pLogPage->setTextEditText(strLogContent);
     866        /* In case there are some errors append the error text as html: */
     867        else
     868        {
     869            pLogPage->setTextEditTextAsHtml(strLogContent);
     870            pLogPage->markForError();
     871        }
    870872    }
    871873}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette