tweak and document abstract page
authorsheepluva
Mon, 24 Oct 2011 20:01:25 +0200
changeset 6200 6a4ace88d85a
parent 6199 582e85254110
child 6201 d88e7f6cf499
tweak and document abstract page
QTfrontend/ui/page/AbstractPage.cpp
QTfrontend/ui/page/AbstractPage.h
QTfrontend/ui/page/pageeditteam.cpp
QTfrontend/ui/page/pageinfo.cpp
QTfrontend/ui/page/pagenetgame.cpp
QTfrontend/ui/widget/HistoryLineEdit.h
QTfrontend/ui/widget/SmartLineEdit.h
QTfrontend/ui/widget/chatwidget.h
--- a/QTfrontend/ui/page/AbstractPage.cpp	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/page/AbstractPage.cpp	Mon Oct 24 20:01:25 2011 +0200
@@ -16,6 +16,11 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+/**
+ * @file
+ * @brief AbstractPage class implementation
+ */
+
 #include "AbstractPage.h"
 
 AbstractPage::AbstractPage(QWidget* parent)
@@ -52,13 +57,13 @@
     connectSignals();
 }
 
-QPushButton * AbstractPage::formattedButton(const QString & btname, bool hasIcon)
+QPushButton * AbstractPage::formattedButton(const QString & name, bool hasIcon)
 {
     QPushButton * btn = new QPushButton(this);
 
     if (hasIcon)
     {
-        const QIcon& lp=QIcon(btname);
+        const QIcon& lp=QIcon(name);
         QSize sz = lp.actualSize(QSize(65535, 65535));
         btn->setIcon(lp);
         btn->setFixedSize(sz);
@@ -69,28 +74,21 @@
     else
     {
         btn->setFont(*font14);
-        btn->setText(btname);
+        btn->setText(name);
     }
     return btn;
 }
 
-QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, bool hasIcon)
+QPushButton * AbstractPage::addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan, int columnSpan, bool hasIcon)
 {
-    QPushButton * btn = formattedButton(btname, hasIcon);
-    grid->addWidget(btn, wy, wx);
+    QPushButton * btn = formattedButton(name, hasIcon);
+    grid->addWidget(btn, row, column, rowSpan, columnSpan);
     return btn;
 }
 
-QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon)
+QPushButton * AbstractPage::addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon)
 {
-    QPushButton * btn = formattedButton(btname, hasIcon);
-    grid->addWidget(btn, wy, wx, rowSpan, columnSpan);
-    return btn;
-}
-
-QPushButton * AbstractPage::addButton(const QString & btname, QBoxLayout* box, int where, bool hasIcon)
-{
-    QPushButton * btn = formattedButton(btname, hasIcon);
+    QPushButton * btn = formattedButton(name, hasIcon);
     box->addWidget(btn, where);
     return btn;
 }
--- a/QTfrontend/ui/page/AbstractPage.h	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/page/AbstractPage.h	Mon Oct 24 20:01:25 2011 +0200
@@ -16,6 +16,11 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
+/**
+ * @file
+ * @brief AbstractPage class definition
+ */
+
 #ifndef ABSTRACTPAGE_H
 #define ABSTRACTPAGE_H
 
@@ -52,44 +57,105 @@
     Q_OBJECT
 
     signals:
+        /**
+         * @brief This signal is emitted when going back to the previous is
+         * requested - e.g. when the back-button is clicked.
+         */
         void goBack();
 
     protected:
-        // constructor and virtual destructor
+        /**
+         * @brief Class constructor
+         *
+         * @param parent parent widget.
+         */
         AbstractPage(QWidget * parent = 0);
 
-        // call this in the constructor of your subclass
+        /// Class Destructor
+        virtual ~AbstractPage() {};
+
+        /// Call this in the constructor of your subclass.
         void initPage();
 
-        // the following methods are used during page construction
+        /**
+         * @brief Used during page construction.
+         * You MUST implement this method in your subclass.
+         *
+         * Use it to define the main layout (no behavior) of the page.
+         */
+        virtual QLayout * bodyLayoutDefinition() = 0;
 
-            // you MUST implement this method in your subclass
-            // only define layout, not behavior in here
-            virtual QLayout * bodyLayoutDefinition() = 0;
+        /**
+         * @brief Used during page construction.
+         * You can implement this method in your subclass.
+         *
+         * Use it to define layout (not behavior) of the page's footer.
+         */
+        virtual QLayout * footerLayoutDefinition() { return NULL; };
 
-            // you CAN implement this method in your subclass
-            virtual QLayout * footerLayoutDefinition() { return NULL; };
+        /**
+         * @brief Used during page construction.
+         * You can implement this method in your subclass.
+         *
+         * This is a good place to connect signals within your page in order
+         * to get the desired page behavior.<br />
+         * Keep in mind not to expose twidgets as public!
+         * instead define a signal with a meaningful name and connect the widget
+         * signals to your page signals
+         */
+        virtual void connectSignals() {};
 
-            // you CAN but most likely want to implement this method in your subclass
-            // keep in mind not to expose twidgets as public!
-            // instead define a signal with a meaningful name and connect the widget
-            // signals to your page signals
-            virtual void connectSignals() {};
+        /**
+         * @brief Creates a default formatted button for this page.
+         *
+         * @param name name of the button - used as its text if not hasIcon.
+         * @param hasIcon set to true if this is a picture button.
+         *
+         * @return the button.
+         */
+        QPushButton * formattedButton(const QString & name, bool hasIcon = false);
 
-        virtual ~AbstractPage() {};
+        /**
+         * @brief Creates a default formatted button and adds it to a
+         * grid layout at the location specified.
+         *
+         * @param name label or path to icon of the button (depends on hasIcon)
+         * @param grid pointer of the grid layout in which to insert the button.
+         * @param row layout row index in which to insert the button.
+         * @param column layout column index in which to insert the button.
+         * @param rowSpan how many layout rows the button will span.
+         * @param columnSpan how many layout columns the button will span.
+         * @param hasIcon set to true if this is a picture button.
+         *
+         * @return the button.
+         */
+        QPushButton * addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan = 1, int columnSpan = 1, bool hasIcon = false);
 
-        QPushButton * formattedButton(const QString & btname, bool hasIcon = false);
-        QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, bool hasIcon = false);
-        QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon = false);
-        QPushButton * addButton(const QString & btname, QBoxLayout * box, int where, bool hasIcon = false);
+        /**
+         * @brief Creates a default formatted button and adds it to a
+         * grid layout at the location specified.
+         *
+         * @param name label or path to icon of the button (depends on hasIcon)
+         * @param box pointer of the box layout in which to insert the button.
+         * @param where layout ndex in which to insert the button.
+         * @param hasIcon set to true if this is a picture button.
+         *
+         * @return the button.
+         */
+        QPushButton * addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon = false);
 
+        /**
+         * @brief Changes visibility of the back-button.
+         *
+         * @param visible set to true if the button should be visible.
+         */
         void setBackButtonVisible(bool visible = true);
 
-        QFont * font14;
+        QFont * font14; ///< used font
 
     private:
 
-        QPushButton * btnBack;
+        QPushButton * btnBack; ///< back button
 };
 
 #endif
--- a/QTfrontend/ui/page/pageeditteam.cpp	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/page/pageeditteam.cpp	Mon Oct 24 20:01:25 2011 +0200
@@ -77,10 +77,10 @@
         HHNameEdit[i]->setMinimumWidth(120);
         GBHLayout->addWidget(HHNameEdit[i], i, 1);
 
-        btnRandomHogName[i] = addButton(":/res/dice.png", GBHLayout, i, 3, true);
+        btnRandomHogName[i] = addButton(":/res/dice.png", GBHLayout, i, 3, 1, 1, true);
     }
 
-    btnRandomTeam = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, false);
+    btnRandomTeam = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, 1);
 
     vbox1->addWidget(GBoxHedgehogs);
 
--- a/QTfrontend/ui/page/pageinfo.cpp	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/page/pageinfo.cpp	Mon Oct 24 20:01:25 2011 +0200
@@ -17,6 +17,7 @@
  */
 
 #include <QGridLayout>
+#include <QHBoxLayout>
 #include <QPushButton>
 
 #include "pageinfo.h"
@@ -38,8 +39,8 @@
 
 QLayout * PageInfo::footerLayoutDefinition()
 {
-    QGridLayout * bottomLayout = new QGridLayout();
-    BtnSnapshots = addButton(":/res/Star.png", bottomLayout, 1, 1, true);
+    QHBoxLayout * bottomLayout = new QHBoxLayout();
+    BtnSnapshots = addButton(":/res/Star.png", bottomLayout, 0, true);
     bottomLayout->setAlignment(BtnSnapshots, Qt::AlignRight | Qt::AlignVCenter);
     return bottomLayout;
 }
--- a/QTfrontend/ui/page/pagenetgame.cpp	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/page/pagenetgame.cpp	Mon Oct 24 20:01:25 2011 +0200
@@ -76,7 +76,7 @@
 
 
     bottomLayout->addWidget(leRoomName);
-    BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1, false);
+    BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1);
 
     bottomLayout->addStretch();
     bottomLayout->addWidget(BtnGo);
--- a/QTfrontend/ui/widget/HistoryLineEdit.h	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/widget/HistoryLineEdit.h	Mon Oct 24 20:01:25 2011 +0200
@@ -37,7 +37,7 @@
 class QLineEdit;
 
 /**
- * @brief A <code>QLineEdit</code> that features a history of previous contents,
+ * @brief <code>QLineEdit</code> that features a history of previous contents,
  *        re-selectable using the arrow keys.
  *
  * Note: Public methods for accessing history are <b>thread-safe</b>.
--- a/QTfrontend/ui/widget/SmartLineEdit.h	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/widget/SmartLineEdit.h	Mon Oct 24 20:01:25 2011 +0200
@@ -37,7 +37,7 @@
 #include "HistoryLineEdit.h"
 
 /**
- * @brief A {@link HistoryLineEdit} that features auto-completion with TAB key
+ * @brief {@link HistoryLineEdit} that features auto-completion with TAB key
  *         and clear with ESC key.
  *
  * Notes:
--- a/QTfrontend/ui/widget/chatwidget.h	Mon Oct 24 11:14:09 2011 +0200
+++ b/QTfrontend/ui/widget/chatwidget.h	Mon Oct 24 20:01:25 2011 +0200
@@ -37,7 +37,7 @@
 class QListWidget;
 class QSettings;
 
-/// This class is for custom nickname sorting
+/// Class for custom nickname sorting
 class ListWidgetNickItem : public QListWidgetItem
 {
 public:
@@ -55,7 +55,7 @@
 
 
 /**
- * @brief A chat widget.
+ * @brief Chat widget.
  *
  * By default uses :res/css/chat.css as style sheet for chat.
  * See \repo{res/css/chat.css} for a more detailed description.