Changeset View
Changeset View
Standalone View
Standalone View
src/ui/itemsgridviewdelegate.cpp
Context not available. | |||||
33 | #include <kratingwidget.h> | 33 | #include <kratingwidget.h> | ||
---|---|---|---|---|---|
34 | #include <ksqueezedtextlabel.h> | 34 | #include <ksqueezedtextlabel.h> | ||
35 | 35 | | |||
36 | #include "itemsmodel_p.h" | 36 | #include "core/itemsmodel_p.h" | ||
37 | 37 | | |||
38 | namespace KNS3 | 38 | namespace KNS3 | ||
39 | { | 39 | { | ||
Context not available. | |||||
41 | DelegateGridRatingWidget | 41 | DelegateGridRatingWidget | ||
42 | }; | 42 | }; | ||
43 | 43 | | |||
44 | ItemsGridViewDelegate::ItemsGridViewDelegate(QAbstractItemView *itemView, Engine *engine, QObject *parent) | 44 | ItemsGridViewDelegate::ItemsGridViewDelegate(QAbstractItemView *itemView, KNSCore::Engine *engine, QObject *parent) | ||
45 | : ItemsViewBaseDelegate(itemView, engine, parent) | 45 | : ItemsViewBaseDelegate(itemView, engine, parent) | ||
46 | , m_elementYPos(0) | 46 | , m_elementYPos(0) | ||
47 | { | 47 | { | ||
Context not available. | |||||
85 | const QStyleOptionViewItem &option, | 85 | const QStyleOptionViewItem &option, | ||
86 | const QPersistentModelIndex &index) const | 86 | const QPersistentModelIndex &index) const | ||
87 | { | 87 | { | ||
88 | const ItemsModel *model = qobject_cast<const ItemsModel *>(index.model()); | 88 | const KNSCore::ItemsModel *model = qobject_cast<const KNSCore::ItemsModel *>(index.model()); | ||
89 | if (!model) { | 89 | if (!model) { | ||
90 | qCDebug(KNEWSTUFF) << "WARNING - INVALID MODEL!"; | 90 | qCDebug(KNEWSTUFF) << "WARNING - INVALID MODEL!"; | ||
91 | return; | 91 | return; | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | EntryInternal entry = index.data(Qt::UserRole).value<KNS3::EntryInternal>(); | 94 | KNSCore::EntryInternal entry = index.data(Qt::UserRole).value<KNSCore::EntryInternal>(); | ||
95 | int elementYPos = PreviewHeight + ItemMargin + FrameThickness * 2; | 95 | int elementYPos = KNSCore::PreviewHeight + ItemMargin + FrameThickness * 2; | ||
96 | 96 | | |||
97 | //setup rating widget | 97 | //setup rating widget | ||
98 | KRatingWidget *rating = qobject_cast<KRatingWidget *>(widgets.at(DelegateGridRatingWidget)); | 98 | KRatingWidget *rating = qobject_cast<KRatingWidget *>(widgets.at(DelegateGridRatingWidget)); | ||
Context not available. | |||||
224 | painter->setPen(QPen(option.palette.text().color())); | 224 | painter->setPen(QPen(option.palette.text().color())); | ||
225 | } | 225 | } | ||
226 | 226 | | |||
227 | const ItemsModel *realmodel = qobject_cast<const ItemsModel *>(index.model()); | 227 | const KNSCore::ItemsModel *realmodel = qobject_cast<const KNSCore::ItemsModel *>(index.model()); | ||
228 | 228 | | |||
229 | if (realmodel->hasPreviewImages()) { | 229 | if (realmodel->hasPreviewImages()) { | ||
230 | int width = option.rect.width(); | 230 | int width = option.rect.width(); | ||
231 | 231 | | |||
232 | KNS3::EntryInternal entry = index.data(Qt::UserRole).value<KNS3::EntryInternal>(); | 232 | KNSCore::EntryInternal entry = index.data(Qt::UserRole).value<KNSCore::EntryInternal>(); | ||
233 | if (entry.previewUrl(EntryInternal::PreviewSmall1).isEmpty()) { | 233 | if (entry.previewUrl(KNSCore::EntryInternal::PreviewSmall1).isEmpty()) { | ||
234 | ; | 234 | ; | ||
235 | } else { | 235 | } else { | ||
236 | QPoint centralPoint(option.rect.left() + width / 2, option.rect.top() + ItemMargin + FrameThickness + PreviewHeight / 2); | 236 | QPoint centralPoint(option.rect.left() + width / 2, option.rect.top() + ItemMargin + FrameThickness + KNSCore::PreviewHeight / 2); | ||
237 | QImage image = entry.previewImage(EntryInternal::PreviewSmall1); | 237 | QImage image = entry.previewImage(KNSCore::EntryInternal::PreviewSmall1); | ||
238 | if (!image.isNull()) { | 238 | if (!image.isNull()) { | ||
239 | QPoint previewPoint(centralPoint.x() - image.width() / 2, centralPoint.y() - image.height() / 2); | 239 | QPoint previewPoint(centralPoint.x() - image.width() / 2, centralPoint.y() - image.height() / 2); | ||
240 | painter->drawImage(previewPoint, image); | 240 | painter->drawImage(previewPoint, image); | ||
Context not available. | |||||
243 | QPoint framePoint(centralPoint.x() - frameImageScaled.width() / 2, centralPoint.y() - frameImageScaled.height() / 2); | 243 | QPoint framePoint(centralPoint.x() - frameImageScaled.width() / 2, centralPoint.y() - frameImageScaled.height() / 2); | ||
244 | painter->drawPixmap(framePoint, frameImageScaled); | 244 | painter->drawPixmap(framePoint, frameImageScaled); | ||
245 | } else { | 245 | } else { | ||
246 | QPoint thumbnailPoint(option.rect.left() + ((width - PreviewWidth - FrameThickness * 2) / 2), option.rect.top() + ItemMargin); | 246 | QPoint thumbnailPoint(option.rect.left() + ((width - KNSCore::PreviewWidth - FrameThickness * 2) / 2), option.rect.top() + ItemMargin); | ||
247 | QRect rect(thumbnailPoint, QSize(PreviewWidth + FrameThickness * 2, PreviewHeight + FrameThickness * 2)); | 247 | QRect rect(thumbnailPoint, QSize(KNSCore::PreviewWidth + FrameThickness * 2, KNSCore::PreviewHeight + FrameThickness * 2)); | ||
248 | painter->drawText(rect, Qt::AlignCenter | Qt::TextWordWrap, i18n("Loading Preview")); | 248 | painter->drawText(rect, Qt::AlignCenter | Qt::TextWordWrap, i18n("Loading Preview")); | ||
249 | } | 249 | } | ||
250 | } | 250 | } | ||
Context not available. | |||||
306 | 306 | | |||
307 | void ItemsGridViewDelegate::displayOperationBar(const QRect &rect, const QModelIndex &index) | 307 | void ItemsGridViewDelegate::displayOperationBar(const QRect &rect, const QModelIndex &index) | ||
308 | { | 308 | { | ||
309 | KNS3::EntryInternal entry = index.data(Qt::UserRole).value<KNS3::EntryInternal>(); | 309 | KNSCore::EntryInternal entry = index.data(Qt::UserRole).value<KNSCore::EntryInternal>(); | ||
310 | if (m_installButton != 0) { | 310 | if (m_installButton != 0) { | ||
311 | if (m_installButton->menu() != 0) { | 311 | if (m_installButton->menu() != 0) { | ||
312 | QMenu *buttonMenu = m_installButton->menu(); | 312 | QMenu *buttonMenu = m_installButton->menu(); | ||
Context not available. | |||||
358 | m_installButton->setEnabled(enabled); | 358 | m_installButton->setEnabled(enabled); | ||
359 | if (installable && entry.downloadLinkCount() > 1) { | 359 | if (installable && entry.downloadLinkCount() > 1) { | ||
360 | QMenu *installMenu = new QMenu(m_installButton); | 360 | QMenu *installMenu = new QMenu(m_installButton); | ||
361 | foreach (const EntryInternal::DownloadLinkInformation &info, entry.downloadLinkInformationList()) { | 361 | foreach (const KNSCore::EntryInternal::DownloadLinkInformation &info, entry.downloadLinkInformationList()) { | ||
362 | QString text = info.name; | 362 | QString text = info.name; | ||
363 | if (!info.distributionType.trimmed().isEmpty()) { | 363 | if (!info.distributionType.trimmed().isEmpty()) { | ||
364 | text + " (" + info.distributionType.trimmed() + ')'; | 364 | text + " (" + info.distributionType.trimmed() + ')'; | ||
Context not available. |