Run astyle-kdelibs on the source
This commit is contained in:
parent
4b85d63d68
commit
39aac8c95b
22 changed files with 1227 additions and 1264 deletions
|
@ -30,88 +30,90 @@
|
|||
#include <QDebug>
|
||||
#include <QPixmap>
|
||||
|
||||
namespace Danbooru {
|
||||
namespace Danbooru
|
||||
{
|
||||
|
||||
DanbooruPostModel::DanbooruPostModel(QObject* parent): QAbstractListModel(parent)
|
||||
{
|
||||
DanbooruPostModel::DanbooruPostModel(QObject *parent): QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DanbooruPostModel::~DanbooruPostModel()
|
||||
{
|
||||
|
||||
if (!m_items.isEmpty()) {
|
||||
qDeleteAll(m_items);
|
||||
m_items.clear();
|
||||
}
|
||||
}
|
||||
|
||||
DanbooruPostModel::~DanbooruPostModel()
|
||||
{
|
||||
int DanbooruPostModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_items.size();
|
||||
}
|
||||
|
||||
if (!m_items.isEmpty()) {
|
||||
qDeleteAll(m_items);
|
||||
m_items.clear();
|
||||
}
|
||||
}
|
||||
void DanbooruPostModel::addPost(Danbooru::DanbooruPost *post)
|
||||
{
|
||||
|
||||
int DanbooruPostModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return m_items.size();
|
||||
}
|
||||
beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
|
||||
m_items.append(post);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void DanbooruPostModel::addPost(Danbooru::DanbooruPost* post)
|
||||
{
|
||||
|
||||
beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
|
||||
m_items.append(post);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
QVariant DanbooruPostModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
|
||||
if (!index.isValid()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (index.row() >= m_items.size() || index.row() < 0) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (m_items.isEmpty()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
DanbooruPost* post = m_items.at(index.row());
|
||||
|
||||
if (!post) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
||||
QVariant variant;
|
||||
variant.setValue(post);
|
||||
|
||||
return variant;
|
||||
}
|
||||
|
||||
if (role == Qt::DecorationRole) {
|
||||
const QPixmap pixmap = post->pixmap();
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
if (role == Qt::ToolTipRole) {
|
||||
return post->fileUrl().fileName();
|
||||
}
|
||||
QVariant DanbooruPostModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
|
||||
if (!index.isValid()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void DanbooruPostModel::clear() {
|
||||
|
||||
if (m_items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginRemoveRows(QModelIndex(),0, m_items.size());
|
||||
qDeleteAll(m_items);
|
||||
m_items.clear();
|
||||
endRemoveRows();
|
||||
reset();
|
||||
if (index.row() >= m_items.size() || index.row() < 0) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (m_items.isEmpty()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
DanbooruPost *post = m_items.at(index.row());
|
||||
|
||||
if (!post) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
|
||||
QVariant variant;
|
||||
variant.setValue(post);
|
||||
|
||||
return variant;
|
||||
}
|
||||
|
||||
if (role == Qt::DecorationRole) {
|
||||
const QPixmap pixmap = post->pixmap();
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
if (role == Qt::ToolTipRole) {
|
||||
return post->fileUrl().fileName();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void DanbooruPostModel::clear()
|
||||
{
|
||||
|
||||
if (m_items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginRemoveRows(QModelIndex(), 0, m_items.size());
|
||||
qDeleteAll(m_items);
|
||||
m_items.clear();
|
||||
endRemoveRows();
|
||||
reset();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue