Permalink
Browse files

Minor fixes in the TableWidget class

  • Loading branch information...
1 parent 58472bc commit 0ff2f1b0e6332b4e9fa0a466ce3be93b51e35877 @Ignotus committed Aug 27, 2012
Showing with 20 additions and 8 deletions.
  1. +5 −0 include/point.hpp
  2. +2 −1 include/tablewidget.hpp
  3. +13 −7 tablewidget.cpp
View
@@ -39,6 +39,11 @@ namespace KDots
, m_y (-1)
{}
+ bool isInitialized () const
+ {
+ return m_x < 0 || m_y < 0;
+ }
+
inline Point (int x, int y)
: m_x (x)
, m_y (y)
View
@@ -47,11 +47,12 @@ namespace KDots
public:
TableWidget (const GameConfig& config, std::shared_ptr<IRival> rival,
QWidget *parent = 0);
- virtual ~TableWidget () {}
void undo ();
protected:
void mousePressEvent (QMouseEvent *event);
void paintEvent (QPaintEvent *event);
+ private slots:
+ void onStatusMessage ();
signals:
void updateStatusBar (const QString& msg);
};
View
@@ -60,7 +60,11 @@ namespace KDots
connect (m_table,
SIGNAL (nextPlayer(const Point&)),
this,
- SLOT (repaint ()));
+ SLOT (update ()));
+ connect (m_table,
+ SIGNAL (nextPlayer (const Point&)),
+ this,
+ SLOT (onStatusMessage ()));
}
namespace
@@ -73,6 +77,14 @@ namespace KDots
return cellHeight > cellWidth ? cellWidth : cellHeight;
}
}
+
+ void TableWidget::onStatusMessage ()
+ {
+ emit updateStatusBar (QString ("First:\t")
+ + QString::number (m_table->stepQueue ()->getMarks (FIRST))
+ + "\tSecond:\t"
+ + QString::number (m_table->stepQueue ()->getMarks (SECOND)));
+ }
void TableWidget::mousePressEvent (QMouseEvent *event)
{
@@ -113,7 +125,6 @@ namespace KDots
return;
m_table->pushPoint (Point (x, y));
- update ();
}
void TableWidget::undo ()
@@ -224,11 +235,6 @@ namespace KDots
const int dx = (rectange.width () - tableWidth) / 2;
const int dy = (rectange.height () - tableHeight) / 2;
painter.drawPixmap (dx, dy, pixmap);
-
- emit updateStatusBar (QString ("First:\t")
- + QString::number (m_table->stepQueue ()->getMarks (FIRST))
- + "\tSecond:\t"
- + QString::number (m_table->stepQueue ()->getMarks (SECOND)));
}
}

0 comments on commit 0ff2f1b

Please sign in to comment.