--- queensgui/src/board.cpp 2007/07/19 23:44:01 4 +++ queensgui/src/board.cpp 2010/04/22 20:09:09 654 @@ -19,7 +19,11 @@ ***************************************************************************/ #include #include -#include +#include +//Added by qt3to4: +#include +#include +#include #include "board.h" @@ -28,6 +32,7 @@ : QWidget(parent, name) { m_sol = NULL; + m_drawmarkers = false; } @@ -39,23 +44,19 @@ void Board::setMatrix(Solution* sol) { - if (sol != NULL) + + if (m_sol != NULL) + { + delete m_sol; + m_sol = NULL; + } + + if (sol != NULL) m_sol = sol->copy(); this->repaint(true); } -void Board::setMatrix(IntSolution sol) -{ -#warning need a closer look -/* - m_hasData = true; - m_sol = Solution(); - for (int i=0;irepaint(true); -*/ -} void Board::paintEvent( QPaintEvent *event ) @@ -67,7 +68,7 @@ } if (m_sol != NULL) { - QBrush brush( black); + QBrush brush( Qt::black); p.setBrush( brush ); for (int i=0; i 0 && starty > 0) { + startx--; + starty--; + } + + while (stopx < (m_size-1) && stopy < (m_size-1) ) { + stopx++; + stopy++; + } + p.drawLine(QPoint( (startx*30)+5, (starty*30)+5), QPoint( (stopx*30)+25, (stopy*30)+25)); + + //next diagonal line + startx = stopx = x; + starty = stopy = y; + while (startx > 0 && starty < (m_size-1) ) { + startx--; + starty++; + } + while (stopx < (m_size-1) && stopy >0) { + stopx++; + stopy--; + } + + p.drawLine(QPoint( (startx*30)+5, (starty*30)+25), QPoint( (stopx*30)+25, (stopy*30)+5)); } void Board::mousePressEvent( QMouseEvent *event) { - if (event->button() == LeftButton) { + if (event->button() == Qt::LeftButton) { + m_drawmarkers = true; + m_markerPoint = event->pos(); this->repaint(true); - QPainter p( this ); - QPen bluePen( blue ); - p.setPen( bluePen ); - int x = event->x() / 30; - int y = event->y() / 30; - - p.drawLine( QPoint(5,(y*30)+15), QPoint( (m_size*30)-5, (y*30)+15) ); - p.drawLine( QPoint( (x*30)+15, 5), QPoint( (x*30)+15, (m_size*30)-5 ) ); - - QPen redPen( red ); - p.setPen( redPen ); - - int startx,stopx; - int starty,stopy; - starty = stopy = y; - startx = stopx = x; - - // f�rste skr� linie - while (startx > 0 && starty > 0) { - startx--; - starty--; - } - - while (stopx < (m_size-1) && stopy < (m_size-1) ) { - stopx++; - stopy++; - } - p.drawLine(QPoint( (startx*30)+5, (starty*30)+5), QPoint( (stopx*30)+25, (stopy*30)+25)); - - //n�ste skr� linie - startx = stopx = x; - starty = stopy = y; - while (startx > 0 && starty < (m_size-1) ) { - startx--; - starty++; - } - while (stopx < (m_size-1) && stopy >0) { - stopx++; - stopy--; - } - - p.drawLine(QPoint( (startx*30)+5, (starty*30)+25), QPoint( (stopx*30)+25, (stopy*30)+5)); } } @@ -133,6 +146,7 @@ delete m_sol; m_sol = NULL; } + m_size = size; this->setMaximumSize( (size * 30)+1, (size * 30)+1 ); this->setMinimumSize( size * 30, size * 30); @@ -143,7 +157,7 @@ if (m_sol == NULL) return; - QPopupMenu *contextMenu = new QPopupMenu( this ); + Q3PopupMenu *contextMenu = new Q3PopupMenu( this ); contextMenu->setCheckable( false ); contextMenu->insertItem("Rotate left", this, SLOT( rotateLeft() ) ); contextMenu->insertItem("Rotate right", this, SLOT( rotateRight() ) );