diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-14 20:46:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-14 20:49:50 +0300 |
commit | fe70719d67a964c9e8d961818641ae41e0a94670 (patch) | |
tree | 72a7bfd32316228b0b63f51c9db7f04f82d9b83a /src | |
parent | bc3fd285b51fbcb02958307e76b4bca8aabb1792 (diff) | |
download | manaverse-fe70719d67a964c9e8d961818641ae41e0a94670.tar.gz manaverse-fe70719d67a964c9e8d961818641ae41e0a94670.tar.bz2 manaverse-fe70719d67a964c9e8d961818641ae41e0a94670.tar.xz manaverse-fe70719d67a964c9e8d961818641ae41e0a94670.zip |
Move guitableactionlistener into separate file.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/gui/widgets/guitable.cpp | 54 | ||||
-rw-r--r-- | src/listeners/guitableactionlistener.cpp | 60 | ||||
-rw-r--r-- | src/listeners/guitableactionlistener.h | 52 |
5 files changed, 117 insertions, 53 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 309599268..290468537 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -847,6 +847,8 @@ SET(SRCS events/event.h listeners/focuslistener.h listeners/guiconfiglistener.h + listeners/guitableactionlistener.cpp + listeners/guitableactionlistener.h listeners/inventorylistener.h events/inputguievent.h input/key.h diff --git a/src/Makefile.am b/src/Makefile.am index 84357074b..9d8554701 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -162,6 +162,8 @@ manaplus_SOURCES += events/actionevent.h \ events/event.h \ listeners/focuslistener.h \ listeners/guiconfiglistener.h \ + listeners/guitableactionlistener.cpp \ + listeners/guitableactionlistener.h \ listeners/inventorylistener.h \ render/graphics.h \ events/inputguievent.h \ diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 6feed2b12..298348f78 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -31,6 +31,7 @@ #include "input/keydata.h" #include "listeners/actionlistener.h" +#include "listeners/guitableactionlistener.h" #include "render/graphics.h" @@ -41,59 +42,6 @@ float GuiTable::mAlpha = 1.0; -class GuiTableActionListener final : public ActionListener -{ -public: - GuiTableActionListener(GuiTable *restrict _table, - Widget *restrict _widget, - int _row, int _column); - - A_DELETE_COPY(GuiTableActionListener) - - ~GuiTableActionListener(); - - void action(const ActionEvent& actionEvent) override final; - -protected: - GuiTable *mTable; - int mRow; - int mColumn; - Widget *mWidget; -}; - - -GuiTableActionListener::GuiTableActionListener(GuiTable *restrict table, - Widget *restrict widget, - int row, int column) : - ActionListener(), - mTable(table), - mRow(row), - mColumn(column), - mWidget(widget) -{ - if (widget) - { - widget->addActionListener(this); - widget->setParent(table); - } -} - -GuiTableActionListener::~GuiTableActionListener() -{ - if (mWidget) - { - mWidget->removeActionListener(this); - mWidget->setParent(nullptr); - } -} - -void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED) -{ - mTable->setSelected(mRow, mColumn); - mTable->distributeActionEvent(); -} - - GuiTable::GuiTable(const Widget2 *const widget, TableModel *const initial_model, const bool opacity) : diff --git a/src/listeners/guitableactionlistener.cpp b/src/listeners/guitableactionlistener.cpp new file mode 100644 index 000000000..df9b46130 --- /dev/null +++ b/src/listeners/guitableactionlistener.cpp @@ -0,0 +1,60 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "listeners/guitableactionlistener.h" + +#include "gui/widgets/guitable.h" +#include "gui/widgets/widget.h" + +#include "debug.h" + +GuiTableActionListener::GuiTableActionListener(GuiTable *restrict table, + Widget *restrict widget, + int row, int column) : + ActionListener(), + mTable(table), + mRow(row), + mColumn(column), + mWidget(widget) +{ + if (widget) + { + widget->addActionListener(this); + widget->setParent(table); + } +} + +GuiTableActionListener::~GuiTableActionListener() +{ + if (mWidget) + { + mWidget->removeActionListener(this); + mWidget->setParent(nullptr); + } +} + +void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED) +{ + mTable->setSelected(mRow, mColumn); + mTable->distributeActionEvent(); +} + diff --git a/src/listeners/guitableactionlistener.h b/src/listeners/guitableactionlistener.h new file mode 100644 index 000000000..27352f71e --- /dev/null +++ b/src/listeners/guitableactionlistener.h @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef LISTENERS_GUITABLEACTIONLISTENER_H +#define LISTENERS_GUITABLEACTIONLISTENER_H + +#include "listeners/actionlistener.h" + +#include "localconsts.h" + +class GuiTable; + +class GuiTableActionListener final : public ActionListener +{ + public: + GuiTableActionListener(GuiTable *restrict _table, + Widget *restrict _widget, + int _row, int _column); + + A_DELETE_COPY(GuiTableActionListener) + + ~GuiTableActionListener(); + + void action(const ActionEvent& actionEvent) override final; + + protected: + GuiTable *mTable; + int mRow; + int mColumn; + Widget *mWidget; +}; + +#endif // GUITABLEACTIONLISTENER_H |