1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
/*
* This file is part of GNUDoQ, Copyright (C) 2005-2006 Luc Vo Van
*
* GNUDoQ 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, or (at your option) any
* later version.
*
* GNUDoQ 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 GNUDoQ; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Class : Main UI
* Author : Luc Vo Van
* Original Date : September 2005
*
**/
#ifndef GNUDOQ_H
#define GNUDOQ_H
#include "ui_GNUDoQForm.h"
#include "GNUDoQBoxWidget.H"
#include <QMainWindow>
#include <QObject>
#include <QPrinter>
#include "sudoku.H"
using sudoku::Sudoku;
#include "sudoku-solve.H"
/** The main GNUDoQ UI class
* This class handles UI events and links them to the GNUDoku engine
* if necessary.
*/
class GNUDoQ : public QWidget
{
Q_OBJECT
public:
/** Class constructor
* Initializes a new instance of GNUDoQ
*
* @param parent Parent widget
*/
GNUDoQ(QWidget *parent = 0);
private slots:
/**
* Generates a new puzzle when the Generate button is clicked
*/
void on_btnGenerate_clicked();
/**
* Solves the puzzle when the Solve button is clicked
*/
void on_btnSolve_clicked();
/**
* Clears the player input when the Clear button is clicked
*/
void on_btnClear_clicked();
/**
* Prints out the current puzzle to the printer
*/
void on_btnPrint_clicked();
/**
* Quits the program
*/
void on_btnQuit_clicked();
/**
* Generates a puzzle from the puzzle code when RETURN is pressed
* on the QLineEdit lePuzzleCode
*/
void on_lePuzzleCode_returnPressed();
/**
* Shows the about form when the About button is clicked
*/
void on_btnLogoAbout_clicked();
/**
* Changes the difficulty level and displays it
*/
void on_sldDifficulty_valueChanged();
/**
* Loads the last saved puzzles with QSettings
*/
void LoadPuzzle();
/**
* Saves the current puzzle to disk with QSettings
*/
void SavePuzzle();
/**
* Checks if the player has inputted all his moves, in which case
* the Solve button will display "Verify" instead of "Solve".
*/
void TestSolveOrVerify();
private:
/**
* Generates a puzzle given a difficulty and a seed
* @param difficulty difficulty of the puzzle, from 0.0 to 1.0
* @param seed seed from which the puzzle will be constructed, use
* a random number to generate a random puzzle
*/
void GeneratePuzzle(float const difficulty, int const seed);
/**
* Solves the currently displayed puzzle, using the current
* player inputs
*/
void SolvePuzzle();
/**
* Gets the values from the player editable boxes (inputs)
* @param top GNUDoku variable
* @param flags GNUDoku variable
* @param visited GNUDoku variable
*/
int GetFromBoxes(Sudoku::attempt *top,
Sudoku::flags *flags,
char visited[]);
/**
* Fills the boxes in the grid with the puzzle's values.
* @param stack GNUDoku variable
* @param visited GNUDoku variable
*/
void FillBoxes(const Sudoku::attempt stack[],
const char visited[]);
/**
* Disconnects all receivers of the grid's boxes signals. This
* is used to speed up complete updates of the grid.
*/
void DisconnectBoxesValueChanged();
/**
* Connects all receivers to the grid's boxes signals.
*/
void ConnectBoxesValueChanged();
/**
* Clears all the boxes of the grid.
*/
void ClearBoxes();
/**
* Resets the player's inputs to 0. Equivalent to restarting
* the puzzle.
*/
void ResetPuzzle();
/**
* Returns a QString representation of the grid.
* @return QString representation of the grid
*/
QString DumpToString();
// The original code for this puzzle
QString m_sCurrentCode;
// The UI made with Designer
Ui::GNUDoQForm ui;
// The QWidgets that make up the grid
GNUDoQBoxWidget* m_Boxes[9][9];
// The printing object
QPrinter printer;
// The GNUDoQ version
static QString VERSION;
};
#endif
|