qcross/libqnono/nonogramproblem.h

76 lines
3.0 KiB
C++

/***************************************************************************
* Copyright (C) 2012 Stefan Bühler <stbuehler@web.de> *
* *
* 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 *
* (at your option) 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, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LIBQNONO_NONOGRAMPROBLEM_H
#define LIBQNONO_NONOGRAMPROBLEM_H
#include "nonogramimage.h"
#include "nonogramnumbers.h"
namespace libqnono {
class NonogramMarker;
class NonogramProblem {
public:
NonogramProblem();
NonogramProblem(const NonogramImage & solution);
NonogramProblem(QString name, quint16 timeout, const NonogramImage & solution);
QString name() const { return m_name; }
quint16 timeout() const { return m_timeout; }
const NonogramImage & solution() const { return m_solution; }
const NonogramNumbers & numbers() const { return m_numbers; }
QString packageIdentifier() const { return m_PackageIdentifier; }
int packageIndex() const { return m_PackageIndex; }
QSize size() const { return m_solution.size(); }
int width() const { return size().width(); }
int height() const { return size().height(); }
bool hasUniqueSolution() const;
/* edit problem: */
void setName(QString value) { m_name = value; }
void setTimeout(quint16 value) { m_timeout = value; }
void setPixel(int x, int y, bool value);
void fill(bool value);
void loadFromImage(const NonogramImage & solution);
bool readFromStream(QDataStream & stream, QString packageIdentifier = QString(), int packageIndex = -1);
void writeToStream(QDataStream & stream) const;
private:
NonogramImage m_solution;
NonogramNumbers m_numbers;
QString m_name;
quint16 m_timeout;
/* not saved directly */
QString m_PackageIdentifier;
int m_PackageIndex;
};
QDataStream & operator<<(QDataStream & stream, const NonogramProblem & problem);
QDataStream & operator>>(QDataStream & stream, NonogramProblem & problem);
}
#endif // LIBQNONO_NONOGRAMPROBLEM_H