cardsmodel.h

来自「程序代码使用说明: (1)所有源代码目录下都提供了Makefile(非Qt)」· C头文件 代码 · 共 68 行

H
68
字号
#ifndef CARDS_MODEL_H#define CARDS_MODEL_H#include <QAbstractTableModel>#include <QList>#include <QPoint>class QColor;class QImage;class CardsModel : public QAbstractTableModel{    Q_OBJECTpublic:    CardsModel(QObject* parent = 0);    ~CardsModel();    int rowCount(const QModelIndex & = QModelIndex()) const { return ROW_NUM; }    int columnCount(const QModelIndex & = QModelIndex()) const { return COL_NUM; }    QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const;    void move(const QModelIndex &index)    { move(index.column(), index.row()); }    void move(const QPoint &index)    { move(index.x(), index.y()); }    void moveLeft();    void moveRight();    void moveUp();    void moveDown();        static const int MAX_CARDS_NUM;public slots:    void randomize();    void reset();    void showNumber(bool checked);    void saveConfig();    void loadConfig();signals:    void gameWon();    void updateMenu(bool);protected:    void initMap();    void checkwin();    void sliceImage();private:    QPoint getEmptyPoint();    void move(int col, int row);    bool moveCards(int* pCol, int* pRow);    QList<int>    mCardsList;    QList<QImage> mImages;    bool isRandomized;    bool bShowNumber;        static const QString imgName;    static const int ROW_NUM;    static const int COL_NUM;};#endif //CARDS_MODEL_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?