42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
1 |
/****************************************************************************
|
2 |
** Hyne Final Fantasy VIII Save Editor
|
|
124
by myst6re
Merging Qt5 branch in trunk: |
3 |
** Copyright (C) 2009-2013 Arzel Jérôme <myst6re@gmail.com>
|
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
4 |
**
|
5 |
** This program is free software: you can redistribute it and/or modify
|
|
6 |
** it under the terms of the GNU General Public License as published by
|
|
7 |
** the Free Software Foundation, either version 3 of the License, or
|
|
8 |
** (at your option) any later version.
|
|
9 |
**
|
|
10 |
** This program is distributed in the hope that it will be useful,
|
|
11 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
** GNU General Public License for more details.
|
|
14 |
**
|
|
15 |
** You should have received a copy of the GNU General Public License
|
|
16 |
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
****************************************************************************/
|
|
18 |
||
19 |
#ifndef DEF_SAVECARDVIEW
|
|
20 |
#define DEF_SAVECARDVIEW
|
|
21 |
||
134
by myst6re
Re-enabling compatibility with Qt4, but without QTaskbarButton, because it uses winextras now (available since Qt 5.2). |
22 |
#include "QtWidgets.h" |
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
23 |
#include "SavecardData.h" |
24 |
#include "SavecardWidget.h" |
|
25 |
||
26 |
class SavecardWidget; |
|
27 |
||
28 |
class SavecardView : public QWidget |
|
29 |
{
|
|
30 |
Q_OBJECT
|
|
31 |
||
32 |
public: |
|
33 |
SavecardView(SavecardWidget *parent=0); |
|
34 |
virtual ~SavecardView(); |
|
35 |
||
36 |
void clear(); |
|
37 |
||
38 |
SavecardData *savecard() const; |
|
39 |
void setSavecard(SavecardData *save); |
|
40 |
||
41 |
void moveCursor(int saveID); |
|
42 |
||
58
by myst6re
Editors: |
43 |
inline static QSize saveSize() { |
44
by myst6re
Optimize draw functions. |
44 |
return QSize(saveWidth(), saveHeight()); |
45 |
}
|
|
67
by myst6re
SaveCardView: Some modifications to make the code more readable (for size/position). |
46 |
inline QPoint savePoint(int saveID) { |
47 |
return QPoint((width() - saveWidth()) / 2, |
|
48 |
saveID * saveHeight()); |
|
44
by myst6re
Optimize draw functions. |
49 |
}
|
67
by myst6re
SaveCardView: Some modifications to make the code more readable (for size/position). |
50 |
inline QRect saveRect(int saveID) { |
44
by myst6re
Optimize draw functions. |
51 |
return QRect(savePoint(saveID), saveSize()); |
52 |
}
|
|
58
by myst6re
Editors: |
53 |
inline static int saveWidth() { return 672; } |
54 |
inline static int saveHeight() { return 106; } |
|
67
by myst6re
SaveCardView: Some modifications to make the code more readable (for size/position). |
55 |
inline static int horizontalMargin() { return 36; } |
44
by myst6re
Optimize draw functions. |
56 |
void updateSave(int saveID, bool withCursor=false); |
57 |
void updateSaves(const QList<int> &saveIDs, bool withCursor=false); |
|
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
58 |
virtual QSize sizeHint() const; |
59 |
virtual QSize minimumSizeHint() const; |
|
60 |
// public function to draw a save preview
|
|
110
by myst6re
Reenabling animation in save icons [SF#4]. |
61 |
static void renderSave(QPainter *painter, const SaveData *saveData, int currentIconFrame=0, const QRect &sourceRect=QRect()); |
62 |
static void renderSave(QPixmap *pixmap, const SaveData *saveData, int currentIconFrame=0, const QRect &sourceRect=QRect()); |
|
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
63 |
static void drawFrame(QPainter *painter, int width, int height); |
64 |
static void num2pix(QPainter *painter, QImage *numberPixmap, int x, int y, quint32 num, quint8 space=1, QChar fill=QChar(' '), int color=0); |
|
65 |
public slots: |
|
66 |
void properties(int saveID=-1); |
|
67 |
private slots: |
|
68 |
void notifyFileChanged(const QString &path); |
|
69 |
void edit(int saveID=-1); |
|
70 |
void exportPC(int saveID=-1); |
|
71 |
void newGame(int saveID=-1); |
|
72 |
void removeSave(int saveID=-1); |
|
67
by myst6re
SaveCardView: Some modifications to make the code more readable (for size/position). |
73 |
void refreshIcon(SaveData *saveData); |
110
by myst6re
Reenabling animation in save icons [SF#4]. |
74 |
void nextIcon(); |
44
by myst6re
Optimize draw functions. |
75 |
void drop(); |
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
76 |
signals: |
77 |
void changed(); |
|
78 |
void released(SaveData *saveData); |
|
79 |
private: |
|
80 |
void moveDraggedSave(int saveID); |
|
81 |
void replaceSaveData(int saveID, const QByteArray &mimeData); |
|
82 |
void setDropIndicator(int saveID); |
|
44
by myst6re
Optimize draw functions. |
83 |
void setBlackSave(int saveID); |
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
84 |
int saveID(const QPoint &pos) const; |
85 |
void restore(int saveID); |
|
110
by myst6re
Reenabling animation in save icons [SF#4]. |
86 |
static void renderSave(QPainter *painter, const SaveData *saveData, const QPixmap &menuBg, const QPixmap &fontPixmap, QImage &numberPixmap, int currentIconFrame=0, const QRect &sourceRect=QRect()); |
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
87 |
static void colors(QImage *image, int color); |
88 |
||
89 |
int cursorID, blackID, dropIndicatorID; |
|
90 |
bool isExternalDrag; |
|
91 |
int _dragStart; |
|
92 |
bool notify; |
|
93 |
SavecardData *_data; |
|
94 |
SavecardWidget *_parent; |
|
95 |
int mouseMove; |
|
96 |
QPoint startPos; |
|
97 |
QByteArray *lastDropData; |
|
98 |
int lastDropID; |
|
110
by myst6re
Reenabling animation in save icons [SF#4]. |
99 |
int currentSaveIconFrame; |
42
by myst6re
New list view that use a simple QScrollArea/QWidget instead of a QListWidget with widget items. |
100 |
protected: |
101 |
virtual void paintEvent(QPaintEvent *event); |
|
102 |
virtual void mousePressEvent(QMouseEvent *event); |
|
103 |
virtual void mouseMoveEvent(QMouseEvent *event); |
|
104 |
virtual void mouseReleaseEvent(QMouseEvent *event); |
|
105 |
virtual void contextMenuEvent(QContextMenuEvent *event); |
|
106 |
virtual void changeEvent(QEvent *event); |
|
107 |
virtual void dragEnterEvent(QDragEnterEvent *event); |
|
108 |
virtual void dragMoveEvent(QDragMoveEvent *event); |
|
109 |
virtual void dragLeaveEvent(QDragLeaveEvent *event); |
|
110 |
virtual void dropEvent(QDropEvent *event); |
|
111 |
};
|
|
112 |
||
113 |
#endif // DEF_SAVECARDVIEW |