From b2c6603542af1d5c34a3e252d9454ddf0b21fcc5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 20 Aug 2015 16:13:56 +0300 Subject: Add missing checks or attribute to other files. --- src/gui/widgets/guitable.cpp | 64 ++++++++++++++----------------------------- src/gui/widgets/guitable.h | 10 +++---- src/gui/widgets/popup.h | 2 +- src/gui/widgets/progressbar.h | 2 +- 4 files changed, 28 insertions(+), 50 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 6fa605c8b..0ab245695 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -89,11 +89,8 @@ void GuiTable::setModel(TableModel *const new_model) mModel = new_model; installActionListeners(); - if (new_model) - { - new_model->installListener(this); - recomputeDimensions(); - } + new_model->installListener(this); + recomputeDimensions(); } void GuiTable::recomputeDimensions() @@ -139,23 +136,17 @@ int GuiTable::getSelectedColumn() const int GuiTable::getRowHeight() const { - if (mModel) - return mModel->getRowHeight() + 4; // border - else - return 0; + return mModel->getRowHeight() + 4; // border } int GuiTable::getColumnWidth(const int i) const { - if (mModel) - return mModel->getColumnWidth(i) + 4; // border - else - return 0; + return mModel->getColumnWidth(i) + 4; // border } void GuiTable::setSelectedRow(const int selected) { - if (!mModel || !mSelectable) + if (!mSelectable) { mSelectedRow = -1; } @@ -184,27 +175,20 @@ void GuiTable::setSelectedRow(const int selected) void GuiTable::setSelectedColumn(const int selected) { - if (!mModel) + const int columns = mModel->getColumns(); + if ((selected >= columns && mWrappingEnabled) || + (selected < 0 && !mWrappingEnabled)) + { + mSelectedColumn = 0; + } + else if ((selected >= columns && !mWrappingEnabled) || + (selected < 0 && mWrappingEnabled)) { - mSelectedColumn = -1; + mSelectedColumn = columns - 1; } else { - const int columns = mModel->getColumns(); - if ((selected >= columns && mWrappingEnabled) || - (selected < 0 && !mWrappingEnabled)) - { - mSelectedColumn = 0; - } - else if ((selected >= columns && !mWrappingEnabled) || - (selected < 0 && mWrappingEnabled)) - { - mSelectedColumn = columns - 1; - } - else - { - mSelectedColumn = selected; - } + mSelectedColumn = selected; } } @@ -216,9 +200,6 @@ void GuiTable::uninstallActionListeners() void GuiTable::installActionListeners() { - if (!mModel) - return; - const int rows = mModel->getRows(); const int columns = mModel->getColumns(); @@ -241,7 +222,7 @@ void GuiTable::installActionListeners() // -- widget ops void GuiTable::draw(Graphics* graphics) { - if (!mModel || !getRowHeight()) + if (!getRowHeight()) return; BLOCK_START("GuiTable::draw") @@ -347,7 +328,7 @@ void GuiTable::draw(Graphics* graphics) void GuiTable::safeDraw(Graphics* graphics) { - if (!mModel || !getRowHeight()) + if (!getRowHeight()) return; BLOCK_START("GuiTable::draw") @@ -516,7 +497,7 @@ void GuiTable::keyPressed(KeyEvent& event) // -- MouseListener notifications void GuiTable::mousePressed(MouseEvent& event) { - if (!mModel || !mSelectable) + if (!mSelectable) return; if (event.getButton() == MouseButton::LEFT) @@ -611,7 +592,7 @@ int GuiTable::getRowForY(int y) const if (rowHeight > 0) row = y / rowHeight; - if (!mModel || row < 0 || row >= mModel->getRows()) + if (row < 0 || row >= mModel->getRows()) return -1; else return row; @@ -619,9 +600,6 @@ int GuiTable::getRowForY(int y) const int GuiTable::getColumnForX(int x) const { - if (!mModel) - return -1; - int column; int delta = 0; @@ -641,9 +619,9 @@ int GuiTable::getColumnForX(int x) const void GuiTable::setFocusHandler(FocusHandler *const focusHandler) { -// add check for focusHandler. may be need remove it? + // add check for focusHandler. may be need remove it? - if (!mModel || !focusHandler) + if (!focusHandler) return; Widget::setFocusHandler(focusHandler); diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 1743f06c6..51905b441 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -60,11 +60,6 @@ class GuiTable final : public Widget, ~GuiTable(); - /** - * Retrieves the active table model - */ - const TableModel *getModel() const A_WARN_UNUSED; - /** * Sets the table model * @@ -75,6 +70,11 @@ class GuiTable final : public Widget, */ void setModel(TableModel *const m); + /** + * Retrieves the active table model + */ + const TableModel *getModel() const A_WARN_UNUSED RETURNS_NONNULL; + void setSelected(const int row, const int column); int getSelectedRow() const A_WARN_UNUSED; diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 9f043114e..1a9d8d508 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -182,7 +182,7 @@ class Popup notfinal : public Container, private: std::string mPopupName; /**< Name of the popup */ - ImageCollection *mVertexes; + ImageCollection *mVertexes A_NONNULLPOINTER; int mMinWidth; /**< Minimum popup width */ int mMinHeight; /**< Minimum popup height */ int mMaxWidth; /**< Maximum popup width */ diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 4b45f1aab..f9a5f1e62 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -145,7 +145,7 @@ class ProgressBar final : public Widget, Color mBackgroundColorToGo; std::string mText; - ImageCollection *mVertexes; + ImageCollection *mVertexes A_NONNULLPOINTER; ProgressColorIdT mProgressPalette; unsigned int mPadding; unsigned int mFillPadding; -- cgit v1.2.3-70-g09d2