Use kdelibs coding style
This commit is contained in:
parent
0084798a2c
commit
d965371d23
31 changed files with 201 additions and 234 deletions
|
@ -24,14 +24,16 @@
|
|||
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace Danbooru {
|
||||
namespace Danbooru
|
||||
{
|
||||
|
||||
DanbooruPoolModel::DanbooruPoolModel(QObject* parent): QAbstractTableModel(parent)
|
||||
DanbooruPoolModel::DanbooruPoolModel(QObject *parent): QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const QStringList DanbooruPoolModel::m_headerNames = { i18n("ID"),
|
||||
i18n("Name"), i18n("Posts"), i18n("Description") };
|
||||
i18n("Name"), i18n("Posts"), i18n("Description")
|
||||
};
|
||||
|
||||
DanbooruPoolModel::~DanbooruPoolModel()
|
||||
{
|
||||
|
@ -60,7 +62,7 @@ int DanbooruPoolModel::columnCount(const QModelIndex &parent) const
|
|||
return 4;
|
||||
}
|
||||
|
||||
QVariant DanbooruPoolModel::data(const QModelIndex& index, int role) const
|
||||
QVariant DanbooruPoolModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
return QVariant();
|
||||
|
@ -74,7 +76,7 @@ QVariant DanbooruPoolModel::data(const QModelIndex& index, int role) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
DanbooruPool* pool = m_items.at(index.row());
|
||||
DanbooruPool *pool = m_items.at(index.row());
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
||||
|
@ -105,7 +107,7 @@ QVariant DanbooruPoolModel::headerData(int section, Qt::Orientation orientation,
|
|||
|
||||
void DanbooruPoolModel::clear()
|
||||
{
|
||||
if (m_items.isEmpty()) {
|
||||
if (m_items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,11 +117,9 @@ void DanbooruPoolModel::clear()
|
|||
endResetModel();
|
||||
}
|
||||
|
||||
DanbooruPool* DanbooruPoolModel::poolAt(int index) const
|
||||
DanbooruPool *DanbooruPoolModel::poolAt(int index) const
|
||||
{
|
||||
return m_items.at(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Danbooru
|
|
@ -23,7 +23,8 @@
|
|||
#include <QVector>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace Danbooru {
|
||||
namespace Danbooru
|
||||
{
|
||||
|
||||
class DanbooruPool;
|
||||
|
||||
|
@ -32,7 +33,7 @@ class DanbooruPoolModel: public QAbstractTableModel
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DanbooruPoolModel(QObject* parent=0);
|
||||
DanbooruPoolModel(QObject *parent = 0);
|
||||
~DanbooruPoolModel();
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
|
@ -40,8 +41,7 @@ public:
|
|||
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
|
||||
void clear();
|
||||
DanbooruPool* poolAt(int index) const;
|
||||
|
||||
DanbooruPool *poolAt(int index) const;
|
||||
|
||||
private:
|
||||
QVector<DanbooruPool *> m_items;
|
||||
|
@ -52,9 +52,6 @@ public Q_SLOTS:
|
|||
|
||||
};
|
||||
|
||||
|
||||
} // namespace Danbooru
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -17,7 +17,6 @@
|
|||
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
// Own
|
||||
|
||||
#include "danboorupostmodel.h"
|
||||
|
@ -80,41 +79,38 @@ QVariant DanbooruPostModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
switch(role) {
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
QVariant variant;
|
||||
variant.setValue(post);
|
||||
switch (role) {
|
||||
case Qt::DisplayRole: {
|
||||
QVariant variant;
|
||||
variant.setValue(post);
|
||||
|
||||
return variant;
|
||||
}
|
||||
return variant;
|
||||
}
|
||||
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
const QPixmap pixmap = post->pixmap();
|
||||
return pixmap;
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
return post->fileUrl().fileName();
|
||||
case FileUrlRole:
|
||||
return post->fileUrl();
|
||||
case ThumbUrlRole:
|
||||
return post->thumbnailUrl();
|
||||
case SizeRole:
|
||||
return post->size();
|
||||
case ResolutionRole:
|
||||
return QSize(post->width(), post->height());
|
||||
case RatingRole:
|
||||
return post->rating();
|
||||
case TagRole:
|
||||
{
|
||||
QStringList tagList = post->tags().toList();
|
||||
return tagList;
|
||||
}
|
||||
case SampleUrlRole:
|
||||
return post->sampleUrl();
|
||||
default:
|
||||
return QVariant();
|
||||
case Qt::DecorationRole: {
|
||||
const QPixmap pixmap = post->pixmap();
|
||||
return pixmap;
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
return post->fileUrl().fileName();
|
||||
case FileUrlRole:
|
||||
return post->fileUrl();
|
||||
case ThumbUrlRole:
|
||||
return post->thumbnailUrl();
|
||||
case SizeRole:
|
||||
return post->size();
|
||||
case ResolutionRole:
|
||||
return QSize(post->width(), post->height());
|
||||
case RatingRole:
|
||||
return post->rating();
|
||||
case TagRole: {
|
||||
QStringList tagList = post->tags().toList();
|
||||
return tagList;
|
||||
}
|
||||
case SampleUrlRole:
|
||||
return post->sampleUrl();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DANBOORUPOSTMODEL_H
|
||||
#define DANBOORUPOSTMODEL_H
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
* along with Danbooru Client. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "danboorutagmodel.h"
|
||||
#include "libdanbooru/danboorutag.h"
|
||||
#include "danbooru_client_debug.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace Danbooru {
|
||||
namespace Danbooru
|
||||
{
|
||||
|
||||
DanbooruTagModel::DanbooruTagModel(QObject *parent): QAbstractListModel(parent)
|
||||
{
|
||||
|
@ -38,7 +38,6 @@ DanbooruTagModel::~DanbooruTagModel()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int DanbooruTagModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
@ -51,7 +50,7 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
DanbooruTag* tag = m_items.at(index.row());
|
||||
DanbooruTag *tag = m_items.at(index.row());
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
return i18np("%1 (%2 post)", "%1 (%2 posts)", tag->name(), tag->count());
|
||||
|
@ -66,18 +65,18 @@ QVariant DanbooruTagModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
DanbooruTag* DanbooruTagModel::itemAt(int index) const
|
||||
DanbooruTag *DanbooruTagModel::itemAt(int index) const
|
||||
{
|
||||
return m_items.at(index);
|
||||
}
|
||||
|
||||
void DanbooruTagModel::addTag(DanbooruTag* tag)
|
||||
void DanbooruTagModel::addTag(DanbooruTag *tag)
|
||||
{
|
||||
if (!tag) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(tag->count() == 0) {
|
||||
if (tag->count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -86,9 +85,10 @@ void DanbooruTagModel::addTag(DanbooruTag* tag)
|
|||
endInsertRows();
|
||||
}
|
||||
|
||||
void DanbooruTagModel::clear() {
|
||||
void DanbooruTagModel::clear()
|
||||
{
|
||||
|
||||
if (m_items.isEmpty()) {
|
||||
if (m_items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,22 +23,23 @@
|
|||
#include <QAbstractListModel>
|
||||
#include <QVector>
|
||||
|
||||
namespace Danbooru {
|
||||
namespace Danbooru
|
||||
{
|
||||
|
||||
class DanbooruTag;
|
||||
|
||||
class DanbooruTagModel: public QAbstractListModel
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DanbooruTagModel(QObject* parent=0);
|
||||
explicit DanbooruTagModel(QObject *parent = 0);
|
||||
~DanbooruTagModel();
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
||||
void clear();
|
||||
DanbooruTag* itemAt(int index) const;
|
||||
DanbooruTag *itemAt(int index) const;
|
||||
|
||||
enum TagRoles {
|
||||
// Needed for sorting through the proxy model
|
||||
|
@ -46,14 +47,13 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
QVector<DanbooruTag*> m_items;
|
||||
QVector<DanbooruTag *> m_items;
|
||||
|
||||
public Q_SLOTS:
|
||||
void addTag(Danbooru::DanbooruTag* tag);
|
||||
void addTag(Danbooru::DanbooruTag *tag);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace Danbooru
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue