25 #include <QtCore/QFile>
26 #include <QtGui/QWidget>
27 #include <QtCore/QTimer>
28 #include <QtGui/QLayout>
29 #include <QtGui/QImage>
30 #include <QtGui/QFont>
31 #include <QtGui/QComboBox>
32 #include <QtGui/QPushButton>
33 #include <QtCore/QMutableVectorIterator>
34 #include <QtCore/QRect>
35 #include <QtGui/QPainter>
36 #include <QtGui/QScrollArea>
37 #include <QtGui/QApplication>
38 #include <QtGui/QTextDocument>
66 #include "ui_DownloadDialog.h"
96 m_currentProvider(0), m_currentFeed(0), m_root(0), m_sorting(0), m_engine(0)
99 setFrameStyle(QFrame::Plain | QFrame::StyledPanel);
100 setVerticalScrollMode(ScrollPerPixel);
115 m_currentProvider = provider;
116 m_currentFeed = feed;
122 m_sorting = sortType;
128 m_currentFeed = feed;
146 void ItemsView::buildContents()
150 m_root->setBackgroundRole(QPalette::Base);
151 QVBoxLayout* _layout =
new QVBoxLayout(m_root);
153 if (m_currentFeed != NULL) {
171 Entry::List::iterator it = entries.begin(), iEnd = entries.end();
172 for (
unsigned row = 0; it != iEnd; ++it) {
173 Entry* entry = (*it);
176 QHBoxLayout * itemLayout =
new QHBoxLayout;
177 _layout->addLayout(itemLayout);
180 part->setBackgroundRole(row & 1 ? QPalette::AlternateBase : QPalette::Base);
181 itemLayout->addWidget(part);
183 QVBoxLayout * previewLayout =
new QVBoxLayout;
184 itemLayout->insertLayout(0, previewLayout);
192 if (!imageurl.isEmpty()) {
194 f->setFrameStyle(QFrame::Panel | QFrame::Sunken);
196 f->setFixedSize(64, 64);
199 previewLayout->addWidget(f);
204 m_views.insert(entry, part);
216 connect(
this, SIGNAL(linkActivated(
QString)), SLOT(urlSelected(
QString)));
228 QString idString = QString::number((
unsigned long)entry);
243 void EntryView::buildContents()
277 if (!m_entry->
version().isEmpty()) titleString +=
" v." + Qt::escape(m_entry->
version());
283 int starPixels = 11 + 11 * (m_entry->
rating() / 10);
284 QString starsString =
"<div style='width: " + QString::number(starPixels) +
"px; background-image: url(" + starIconPath +
"); background-repeat: repeat-x;'> </div>";
285 int grayPixels = 22 + 22 * (m_entry->
rating() / 20);
286 starsString =
"<div style='width: " + QString::number(grayPixels) +
"px;background-image: url(" + starBgIconPath +
"); background-repeat: repeat-x;'>" + starsString +
" </div>";
293 if (!emailString.isEmpty()) {
294 authorString =
"<a href='mailto:" + Qt::escape(emailString) +
"'>"
295 + Qt::escape(authorString) +
"</a>";
300 statusIcon + Qt::escape(titleString) +
"<br />"
305 if (m_entry->
rating() > 0) {
306 t +=
i18n(
"Rating: ") + QString::number(m_entry->
rating())
311 t +=
i18n(
"Downloads: ") + QString::number(m_entry->
downloads())
315 if (!authorString.isEmpty()) {
316 t +=
"<em>" + authorString +
"</em>, ";
319 +
"<br />" +
"</body></html>";
324 void EntryView::setTheAaronnesqueStyle()
326 QString hoverColor =
"#000000";
327 QString hoverBackground =
"#f8f8f8";
333 s +=
"body { background-color: white; color: black; padding: 0; margin: 0; }";
334 s +=
"table, td, th { padding: 0; margin: 0; text-align: left; }";
335 s +=
"input { color: #000080; font-size:120%; }";
338 s +=
".itemBox { background-color: white; color: black; width: 100%; border-bottom: 1px solid gray; margin: 0px 0px; }";
339 s +=
".itemBox:hover { background-color: " + hoverBackground +
"; color: " + hoverColor +
"; }";
342 s +=
".leftColumn { width: 100px; height:100%; text-align: center; }";
343 s +=
".leftImage {}";
344 s +=
".leftButton {}";
345 s +=
".leftProgressContainer { width: 82px; height: 10px; background-color: transparent; }";
346 s +=
".leftProgressBar { left: 1px; width: 0px; top: 1px; height: 8px; background-color: red; }";
347 s +=
".contentsColumn { vertical-align: top; }";
348 s +=
".contentsHeader { width: 100%; font-size: 120%; font-weight: bold; border-bottom: 1px solid #c8c8c8; }";
349 s +=
".contentsBody {}";
350 s +=
".contentsFooter {}";
351 s +=
".star { width: 0px; height: 24px; background-image: url(" + starIconPath +
"); background-repeat: repeat-x; }";
352 s +=
".starbg { width: 110px; height: 24px; background-image: url(" + starBgIconPath +
"); background-repeat: repeat-x; }";
356 void EntryView::urlSelected(
const QString &link)
361 QString urlProtocol = url.protocol();
364 if (urlProtocol ==
"mailto") {
369 }
else if (urlProtocol ==
"item") {
372 unsigned long itemPointer = urlPath.toULong(&ok);
374 kWarning() <<
"ItemsView: error converting item pointer.";
380 if (entry != m_entry) {
381 kWarning() <<
"ItemsView: error retrieving item pointer.";
394 #include "itemsview.moc"