Vidalia 0.3.1
UpdatesAvailableDialog.cpp
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file UpdatesAvailableDialog.cpp
13** \brief Displays a list of available updates and details, such as release
14** notes. The user can choose to either install the updates now or later, or
15** skip the updates entirely.
16*/
17
19#include "Vidalia.h"
20
21#include <QHeaderView>
22
23
25 QWidget *parent)
26 : QDialog(parent)
27{
28 ui.setupUi(this);
29
30 connect(ui.btnInstall, SIGNAL(clicked()),
31 this, SLOT(installUpdatesNow()));
32 connect(ui.btnInstallLater, SIGNAL(clicked()),
33 this, SLOT(installUpdatesLater()));
34
35 connect(ui.treeUpdates,
36 SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
37 this, SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
38
39 loadPackagesTable(packageList);
40}
41
42void
44{
45 ui.treeUpdates->header()->resizeSection(0, 240);
46 ui.treeUpdates->header()->setResizeMode(1, QHeaderView::ResizeToContents);
47 QDialog::showEvent(e);
48}
49
50void
52{
53 int row = 0;
54 QString language;
55 QTreeWidgetItem *item;
56
57 language = Vidalia::language();
58
59 foreach (PackageInfo package, packageList) {
60 item = new QTreeWidgetItem(ui.treeUpdates);
61
62 if (package.hasShortDescription(language))
63 item->setText(0, package.shortDescription(language));
64 else
65 item->setText(0, package.shortDescription("en"));
66
67 if (package.hasLongDescription(language))
68 item->setData(0, Qt::UserRole, package.longDescription(language));
69 else
70 item->setData(0, Qt::UserRole, package.longDescription("en"));
71
72 item->setText(1, package.version());
73 ui.treeUpdates->insertTopLevelItem(row++, item);
74 }
75}
76
77void
79 QTreeWidgetItem *previous)
80{
81 Q_UNUSED(previous);
82
83 ui.textDetails->clear();
84 if (current)
85 ui.textDetails->setText(current->data(0, Qt::UserRole).toString());
86}
87
88void
90{
92}
93
94void
96{
98}
99
QList< PackageInfo > PackageList
Definition: PackageInfo.h:93
stop errmsg connect(const QHostAddress &address, quint16 port)
QString longDescription(const QString &lang) const
Definition: PackageInfo.cpp:61
bool hasLongDescription(const QString &lang) const
Definition: PackageInfo.cpp:67
QString shortDescription(const QString &lang) const
Definition: PackageInfo.cpp:80
bool hasShortDescription(const QString &lang) const
Definition: PackageInfo.cpp:87
QString version() const
Definition: PackageInfo.cpp:49
UpdatesAvailableDialog(const PackageList &packageList, QWidget *parent=0)
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
void loadPackagesTable(const PackageList &packageList)
Ui::UpdatesAvailableDialog ui
virtual void showEvent(QShowEvent *e)
static QString language()
Definition: Vidalia.h:69