📄 cardsmodel.h
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -