Fix i18n => IMAP Server:
[kdepim.git] / blogilo / src / bilbomedia.cpp
blob4955c01e3865e1384e0f0699960df8b1ea125580
1 /*
2 This file is part of Blogilo, A KDE Blogging Client
4 Copyright (C) 2008-2010 Mehrdad Momeny <mehrdad.momeny@gmail.com>
5 Copyright (C) 2008-2010 Golnaz Nilieh <g382nilieh@gmail.com>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of
10 the License or (at your option) version 3 or any later version
11 accepted by the membership of KDE e.V. (or its successor approved
12 by the membership of KDE e.V.), which shall act as a proxy
13 defined in Section 14 of version 3 of the license.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, see http://www.gnu.org/licenses/
24 #include "bilbomedia.h"
26 #include "blogilo_debug.h"
27 #include <QIcon>
28 #include <QPixmap>
29 #include <QUrl>
30 class Q_DECL_HIDDEN BilboMedia::Private
32 public:
33 Private()
34 : mBlogId(-1),
35 mMediaId(-1),
36 mIsUploaded(false),
37 mChecksum(0)
42 int mBlogId;
43 int mMediaId;
44 bool mIsUploaded;
45 QUrl mLocalUrl;
46 QUrl mRemoteUrl;
47 QString mMimeType;
48 QString mName;
49 quint16 mChecksum;
51 BilboMedia::BilboMedia(QObject *parent)
52 : QObject(parent), d(new Private)
54 d->mChecksum = 0;
57 BilboMedia::~BilboMedia()
59 delete d;
62 int BilboMedia::blogId() const
64 return d->mBlogId;
67 void BilboMedia::setBlogId(const int blog_id)
69 d->mBlogId = blog_id;
72 int BilboMedia::mediaId() const
74 return d->mMediaId;
77 void BilboMedia::setMediaId(const int media_id)
79 d->mMediaId = media_id;
82 bool BilboMedia::isUploaded() const
84 return d->mIsUploaded;
87 void BilboMedia::setUploaded(bool uploaded)
89 d->mIsUploaded = uploaded;
92 QUrl BilboMedia::localUrl() const
94 return d->mLocalUrl;
97 void BilboMedia::setLocalUrl(const QUrl &url)
99 d->mLocalUrl = url;
102 QUrl BilboMedia::remoteUrl() const
104 return d->mRemoteUrl;
107 void BilboMedia::setRemoteUrl(const QUrl &url)
109 d->mRemoteUrl = url;
112 QString BilboMedia::mimeType() const
114 return d->mMimeType;
117 void BilboMedia::setMimeType(const QString &type)
119 d->mMimeType = type;
122 QString BilboMedia::name() const
124 return d->mName;
127 void BilboMedia::setName(const QString &name)
129 d->mName = name;
132 QIcon BilboMedia::icon() const
134 QPixmap iconPic;
135 QString type;
136 type = this->mimeType();
137 if (type.contains(QStringLiteral("image")) && !this->localUrl().isEmpty()) {
138 iconPic.load(this->localUrl().toLocalFile());
139 // iconPic.scaled(64, 64, Qt::IgnoreAspectRatio);
140 iconPic.scaledToHeight(32);
141 if (!iconPic.isNull()) {
142 return QIcon(iconPic);
143 } else {
144 qCDebug(BLOGILO_LOG) << "iconPic is Null";
148 type.replace(QLatin1Char('/'), QLatin1Char('-'));
149 return QIcon(type);
152 quint16 BilboMedia::checksum() const
154 return d->mChecksum;
157 void BilboMedia::setCheckSum(quint16 sum)
159 d->mChecksum = sum;