KNewStuff
itemsgridviewdelegate.cpp
33 ItemsGridViewDelegate::ItemsGridViewDelegate(QAbstractItemView *itemView, KNSCore::Engine *engine, QObject *parent)
91 // assume all entries come with rating 0..100 but most are in the range 20 - 80, so 20 is 0 stars, 80 is 5 stars
113 titleLabel->resize(QSize(option.rect.width() - (ItemMargin * 2), option.fontMetrics.height() * 2));
119 title += QLatin1String("<b><a href=\"") + link.url() + QLatin1String("\">") + entry.name() + QLatin1String("</a></b>\n");
138 authorLabel->resize(QSize(option.rect.width() - (ItemMargin * 2), option.fontMetrics.height()));
148 text += QLatin1String("<p>") + i18nc("Show the author of this item in a list", "By <i>%1</i>", QLatin1String(" <a href=\"") + authorPage + QLatin1String("\">") + authorName + QLatin1String("</a>")) + QLatin1String("</p>\n");
150 text += QLatin1String("<p>") + i18nc("Show the author of this item in a list", "By <i>%1</i>", authorName) + QLatin1String(" <a href=\"mailto:") + email + QLatin1String("\">") + email + QLatin1String("</a></p>\n");
152 text += QLatin1String("<p>") + i18nc("Show the author of this item in a list", "By <i>%1</i>", authorName) + QLatin1String("</p>\n");
165 downloadLabel->resize(QSize(option.rect.width() - (ItemMargin * 2), option.fontMetrics.height()));
194 void ItemsGridViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
223 const KNSCore::ItemsModel *realmodel = qobject_cast<const KNSCore::ItemsModel *>(index.model());
232 QPoint centralPoint(option.rect.left() + width / 2, option.rect.top() + ItemMargin + FrameThickness + KNSCore::PreviewHeight / 2);
235 QPoint previewPoint(centralPoint.x() - image.width() / 2, centralPoint.y() - image.height() / 2);
238 QPixmap frameImageScaled = m_frameImage.scaled(image.width() + FrameThickness * 2, image.height() + FrameThickness * 2);
239 QPoint framePoint(centralPoint.x() - frameImageScaled.width() / 2, centralPoint.y() - frameImageScaled.height() / 2);
242 QPoint thumbnailPoint(option.rect.left() + ((width - KNSCore::PreviewWidth - FrameThickness * 2) / 2), option.rect.top() + ItemMargin);
243 QRect rect(thumbnailPoint, QSize(KNSCore::PreviewWidth + FrameThickness * 2, KNSCore::PreviewHeight + FrameThickness * 2));
252 QSize ItemsGridViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
260 size.setHeight(qMax(option.fontMetrics.height() * 13, ItemGridHeight)); // up to 6 lines of text, and two margins
276 this, static_cast<void(ItemsGridViewDelegate::*)()>(&ItemsGridViewDelegate::slotDetailsClicked));
284 connect(m_installButton, &QAbstractButton::clicked, this, &ItemsGridViewDelegate::slotInstallClicked);
285 connect(m_installButton, &QToolButton::triggered, this, &ItemsGridViewDelegate::slotInstallActionTriggered);
370 m_operationBar->move(rect.left() + (ItemGridWidth - m_operationBar->width()) / 2, rect.top() + m_elementYPos);
QString url(QUrl::FormattingOptions options) const const
void resize(int w, int h)
MouseButtonPress
void setHeight(int height)
void setRating(int rating)
int width() const const
int numberFans() const
How many people have marked themselves as fans of this entry.
Definition: entryinternal.cpp:328
InstantPopup
int downloadCount() const
Retrieve the download count for the object, which has been determined by its hosting sites and thus m...
Definition: entryinternal.cpp:318
virtual void setVisible(bool visible)
void save()
T value() const const
void setAlignment(Qt::Alignment)
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
bool isEmpty() const const
QImage previewImage(PreviewType type=PreviewSmall1) const
This will not be loaded automatically, instead use Engine to load the actual images.
Definition: entryinternal.cpp:288
void triggered(QAction *action)
AlignHCenter
width
bool isValid() const const
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
void installEventFilter(QObject *filterObj)
QUrl homepage() const
A link to a website containing information about this entry.
Definition: entryinternal.cpp:168
int top() const const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setPen(const QColor &color)
QList< DownloadLinkInformation > downloadLinkInformationList() const
A list of downloadable data for this entry.
Definition: entryinternal.cpp:411
int left() const const
void drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)
void setWidth(int width)
int downloadLinkCount() const
The number of available download options for this entry.
Definition: entryinternal.cpp:406
UserRole
bool isEmpty() const const
QString trimmed() const const
void clicked(bool checked)
int row() const const
void drawText(const QPointF &position, const QString &text)
ToolButtonFollowStyle
void deleteLater()
void setText(const QString &)
QPixmap scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const const
PE_PanelItemViewItem
QString previewUrl(PreviewType type=PreviewSmall1) const
Retrieve the file name of an image containing a preview of the object.
Definition: entryinternal.cpp:278
void setData(const QVariant &userData)
QString formatByteSize(double size, int precision=1, KFormat::BinaryUnitDialect dialect=KFormat::DefaultBinaryDialect, KFormat::BinarySizeUnits units=KFormat::DefaultBinaryUnits) const
int height() const const
QString i18ncp(const char *context, const char *singular, const char *plural, const TYPE &arg...)
void move(int x, int y)
void restore()
QString i18n(const char *text, const TYPE &arg...)
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, Qt::ImageConversionFlags flags)
const QAbstractItemModel * model() const const
QVariant data(int role) const const
QStyle * style()
int rating() const
Retrieve the rating for the object, which has been determined by its users and thus might change over...
Definition: entryinternal.cpp:298
KIOCORE_EXPORT CopyJob * link(const QUrl &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
TextWordWrap
virtual void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const =0
QIcon fromTheme(const QString &name)
void setToolTip(const QString &)
KNS3::Entry::Status status() const
Retrieves the entry's status.
Definition: entryinternal.cpp:376
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
T qobject_cast(QObject *object)
void setWordWrap(bool on)
State_MouseOver
void setSpacing(int spacing)
height
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.