Defining data classes
We are building our gallery from the ground up. We will start with the implementation of our data classes to be able to properly write the database layer. The application aims to organize pictures into albums. Hence, the two obvious classes are Album
and Picture
. In our example, an album simply has a name. A Picture
class must belong to an Album
class and has a file path (the path on your filesystem where the original file is located).
The Album
class has already been created on project creation. Open the Album.h
file and update it to include the following implementation:
#include <QString> #include "gallery-core_global.h" class GALLERYCORESHARED_EXPORT Album { public: explicit Album(const QString& name = ""); int id() const; void setId(int id); QString name() const; void setName(const QString& name); private: int mId; QString mName; };
As you can see, the Album
class...