25#include <attica/provider.h>
30 :
QObject(widget->m_listView), m_engine(engine), ui(widget)
39void EntryDetails::init()
41 connect(ui->preview1, SIGNAL(clicked()),
this, SLOT(preview1Selected()));
42 connect(ui->preview2, SIGNAL(clicked()),
this, SLOT(preview2Selected()));
43 connect(ui->preview3, SIGNAL(clicked()),
this, SLOT(preview3Selected()));
45 ui->ratingWidget->setMaxRating(10);
46 ui->ratingWidget->setHalfStepsEnabled(
true);
49 connect(ui->installButton, SIGNAL(clicked()),
this, SLOT(install()));
50 connect(ui->uninstallButton, SIGNAL(clicked()),
this, SLOT(uninstall()));
52 connect(ui->updateButton, SIGNAL(clicked()),
this, SLOT(install()));
53 connect(ui->becomeFanButton, SIGNAL(clicked()),
this, SLOT(becomeFan()));
55 ui->installButton->setIcon(
KIcon(
"dialog-ok"));
56 ui->updateButton->setIcon(
KIcon(
"system-software-update"));
57 ui->uninstallButton->setIcon(
KIcon(
"edit-delete"));
71 entryChanged(m_entry);
73 m_engine->loadDetails(m_entry);
78 if (ui->detailsStack->currentIndex() == 0) {
87 ui->becomeFanButton->setEnabled(
false);
90 ui->m_titleWidget->setText(
i18n(
"Details for %1", m_entry.name()));
91 if (!m_entry.author().homepage().isEmpty()) {
92 ui->authorLabel->setText(
"<a href=\"" + m_entry.author().homepage() +
"\">" + m_entry.author().name() +
"</a>");
93 }
else if (!m_entry.author().email().isEmpty()) {
94 ui->authorLabel->setText(
"<a href=\"mailto:" + m_entry.author().email() +
"\">" + m_entry.author().name() +
"</a>");
96 ui->authorLabel->setText(m_entry.author().name());
99 QString summary =
replaceBBCode(m_entry.summary()).replace(
"\n",
"<br/>");
100 QString changelog =
replaceBBCode(m_entry.changelog()).replace(
"\n",
"<br/>");
102 QString description =
"<html><body>" + summary;
103 if (!changelog.isEmpty()) {
104 description +=
"<br/><p><b>" +
i18n(
"Changelog:") +
"</b><br/>" + changelog +
"</p>";
106 description +=
"</body></html>";
107 ui->descriptionLabel->setText(description);
109 QString homepageText(
"<a href=\"" + m_entry.homepage().url() +
"\">" +
110 i18nc(
"A link to the description of this Get Hot New Stuff item",
"Homepage") +
"</a>");
112 if (!m_entry.donationLink().isEmpty()) {
113 homepageText +=
"<br><a href=\"" + m_entry.donationLink() +
"\">" +
i18nc(
"A link to make a donation for a Get Hot New Stuff item (opens a web browser)",
"Make a donation") +
"</a>";
115 if (!m_entry.knowledgebaseLink().isEmpty()) {
116 homepageText +=
"<br><a href=\"" + m_entry.knowledgebaseLink() +
"\">"
117 +
i18ncp(
"A link to the knowledgebase (like a forum) (opens a web browser)",
"Knowledgebase (no entries)",
"Knowledgebase (%1 entries)", m_entry.numberKnowledgebaseEntries()) +
"</a>";
119 ui->homepageLabel->setText(homepageText);
120 ui->homepageLabel->setToolTip(
i18nc(
"Tooltip for a link in a dialog",
"Opens in a browser window"));
122 if (m_entry.rating() > 0) {
123 ui->ratingWidget->setVisible(
true);
124 disconnect(ui->ratingWidget, SIGNAL(ratingChanged(uint)),
this, SLOT(ratingChanged(uint)));
126 int rating = qMax(0, qMin(10, (m_entry.rating()-20)/6));
127 ui->ratingWidget->setRating(rating);
128 connect(ui->ratingWidget, SIGNAL(ratingChanged(uint)),
this, SLOT(ratingChanged(uint)));
130 ui->ratingWidget->setVisible(
false);
136 ui->preview1->setVisible(!hideSmallPreviews);
137 ui->preview2->setVisible(!hideSmallPreviews);
138 ui->preview3->setVisible(!hideSmallPreviews);
148 ui->previewBig->setVisible(
false);
164void EntryDetails::entryStatusChanged(
const KNS3::EntryInternal& entry)
170void EntryDetails::updateButtons()
172 if (ui->detailsStack->currentIndex() == 0) {
175 kDebug() <<
"update buttons: " << m_entry.status();
176 ui->installButton->setVisible(
false);
177 ui->uninstallButton->setVisible(
false);
178 ui->updateButton->setVisible(
false);
180 switch (m_entry.status()) {
182 ui->uninstallButton->setVisible(
true);
183 ui->uninstallButton->setEnabled(
true);
186 ui->updateButton->setVisible(
true);
187 ui->updateButton->setEnabled(
true);
188 ui->uninstallButton->setVisible(
true);
189 ui->uninstallButton->setEnabled(
true);
194 ui->installButton->setVisible(
true);
195 ui->installButton->setEnabled(
true);
199 ui->installButton->setVisible(
true);
200 ui->installButton->setEnabled(
false);
203 ui->updateButton->setVisible(
true);
204 ui->updateButton->setEnabled(
false);
205 ui->uninstallButton->setVisible(
true);
206 ui->uninstallButton->setEnabled(
false);
209 ui->installButton->setVisible(
true);
210 ui->installButton->setEnabled(
true);
214 if (ui->installButton->menu()) {
215 QMenu* buttonMenu = ui->installButton->menu();
217 ui->installButton->setMenu(0);
218 buttonMenu->deleteLater();
220 if (ui->installButton->isVisible() && m_entry.downloadLinkCount() > 1) {
221 KMenu * installMenu =
new KMenu(ui->installButton);
222 foreach (EntryInternal::DownloadLinkInformation info, m_entry.downloadLinkInformationList()) {
223 QString text = info.
name;
227 QAction* installAction = installMenu->addAction(KIcon(
"dialog-ok"), text);
228 installAction->setData(info.
id);
230 kDebug() <<
"links: " << m_entry.downloadLinkInformationList().size();
231 ui->installButton->setMenu(installMenu);
235void EntryDetails::install()
237 m_engine->install(m_entry);
240void EntryDetails::uninstall()
242 m_engine->uninstall(m_entry);
247 if (!(entry == m_entry)) {
263 ui->previewBig->setImage(m_currentPreview);
270void EntryDetails::preview1Selected()
275void EntryDetails::preview2Selected()
280void EntryDetails::preview3Selected()
285void EntryDetails::previewSelected(
int current)
288 m_currentPreview = m_entry.previewImage(type);
289 ui->previewBig->setImage(m_currentPreview);
292void EntryDetails::ratingChanged(uint rating)
295 kDebug() <<
"rating: " << rating <<
" -> " << rating*10;
296 m_engine->vote(m_entry, rating*10);
299void EntryDetails::becomeFan()
301 m_engine->becomeFan(m_entry);
304#include "entrydetailsdialog.moc"
bool userCanBecomeFan(const EntryInternal &entry)
void setEntry(const KNS3::EntryInternal &entry)
EntryDetails(Engine *engine, Ui::DownloadWidget *widget)
KNewStuff data entry container.
QImage previewImage(PreviewType type=PreviewSmall1) const
This will not be loaded automatically, instead use Engine to load the actual images.
QString i18n(const char *text)
QString i18nc(const char *ctxt, const char *text)
QString i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1)
QString replaceBBCode(const QString &unformattedText)
function to remove bb code formatting that opendesktop sends