2011-05-31 17:22:24 +02:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
2012-02-06 11:00:18 +01:00
|
|
|
** This file is part of Installer Framework
|
2011-05-31 17:22:24 +02:00
|
|
|
**
|
2012-02-06 11:00:18 +01:00
|
|
|
** Copyright (c) 2011-2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-05-31 17:22:24 +02:00
|
|
|
**
|
2012-02-06 11:30:37 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-05-31 17:22:24 +02:00
|
|
|
**
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
**
|
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2012-02-06 11:00:18 +01:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** Other Usage
|
2011-05-31 17:22:24 +02:00
|
|
|
**
|
2012-02-06 11:00:18 +01:00
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
**
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
2012-02-06 11:30:37 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-05-31 17:22:24 +02:00
|
|
|
**
|
|
|
|
**************************************************************************/
|
2012-02-06 11:00:18 +01:00
|
|
|
|
2011-05-31 17:22:24 +02:00
|
|
|
#include "updatesettingswidget.h"
|
|
|
|
#include "ui_updatesettingswidget.h"
|
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
#include <common/repository.h>
|
2011-05-31 17:22:24 +02:00
|
|
|
#include "updatesettings.h"
|
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
#include <QtCore/QDateTime>
|
|
|
|
|
|
|
|
#include <QtGui/QStringListModel>
|
2011-05-31 17:22:24 +02:00
|
|
|
|
|
|
|
using namespace QInstaller;
|
|
|
|
|
|
|
|
class UpdateSettingsWidget::Private
|
|
|
|
{
|
|
|
|
public:
|
2011-06-01 14:07:47 +02:00
|
|
|
Private(UpdateSettingsWidget *qq)
|
|
|
|
: q(qq),
|
|
|
|
initialized(false)
|
2011-05-31 17:22:24 +02:00
|
|
|
{
|
2011-06-01 14:07:47 +02:00
|
|
|
ui.setupUi(q);
|
2011-05-31 17:22:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void addUpdateSource()
|
|
|
|
{
|
|
|
|
const int newRow = model.rowCount();
|
2011-06-01 15:29:31 +02:00
|
|
|
if (model.insertRow(newRow))
|
2011-06-01 14:07:47 +02:00
|
|
|
ui.treeViewUpdateSources->edit(model.index(newRow, 0));
|
2011-05-31 17:22:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void removeUpdateSource()
|
|
|
|
{
|
2011-06-01 14:07:47 +02:00
|
|
|
model.removeRow(ui.treeViewUpdateSources->currentIndex().row());
|
2011-05-31 17:22:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2011-06-01 14:07:47 +02:00
|
|
|
UpdateSettingsWidget *const q;
|
2011-05-31 17:22:24 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
bool initialized;
|
|
|
|
QStringListModel model;
|
2011-06-01 14:07:47 +02:00
|
|
|
UpdateSettings settings;
|
|
|
|
|
|
|
|
Ui::UpdateSettingsWidget ui;
|
2011-05-31 17:22:24 +02:00
|
|
|
};
|
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
|
|
|
|
// -- UpdateSettingsWidget
|
|
|
|
|
|
|
|
UpdateSettingsWidget::UpdateSettingsWidget(QWidget *parent)
|
|
|
|
: QWidget(parent),
|
|
|
|
d(new Private(this))
|
2011-05-31 17:22:24 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateSettingsWidget::~UpdateSettingsWidget()
|
|
|
|
{
|
2011-06-01 14:07:47 +02:00
|
|
|
delete d;
|
2011-05-31 17:22:24 +02:00
|
|
|
}
|
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
void UpdateSettingsWidget::showEvent(QShowEvent *event)
|
2011-05-31 17:22:24 +02:00
|
|
|
{
|
2011-06-01 14:07:47 +02:00
|
|
|
Q_UNUSED(event)
|
2011-06-01 15:29:31 +02:00
|
|
|
if (d->initialized)
|
2011-05-31 17:22:24 +02:00
|
|
|
return;
|
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
d->ui.checkBoxCheckForUpdates->setChecked(d->settings.updateInterval() > 0);
|
|
|
|
d->ui.checkBoxCheckOnlyImportant->setChecked(d->settings.checkOnlyImportantUpdates());
|
2011-06-01 15:29:31 +02:00
|
|
|
switch (qAbs(d->settings.updateInterval())) {
|
2011-05-31 17:22:24 +02:00
|
|
|
case UpdateSettings::Daily:
|
2011-06-01 14:07:47 +02:00
|
|
|
d->ui.comboBoxFrequency->setCurrentIndex(0);
|
2011-05-31 17:22:24 +02:00
|
|
|
break;
|
|
|
|
case UpdateSettings::Weekly:
|
2011-06-01 14:07:47 +02:00
|
|
|
d->ui.comboBoxFrequency->setCurrentIndex(1);
|
2011-05-31 17:22:24 +02:00
|
|
|
break;
|
|
|
|
case UpdateSettings::Monthly:
|
2011-06-01 14:07:47 +02:00
|
|
|
d->ui.comboBoxFrequency->setCurrentIndex(2);
|
2011-05-31 17:22:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
connect(d->ui.buttonCheckNow, SIGNAL(clicked()), this, SIGNAL(checkForUpdates()));
|
|
|
|
connect(d->ui.buttonAddUpdateSource, SIGNAL(clicked()), this, SLOT(addUpdateSource()));
|
|
|
|
connect(d->ui.buttonRemoveUpdateSource, SIGNAL(clicked()), this, SLOT(removeUpdateSource()));
|
2011-05-31 17:22:24 +02:00
|
|
|
|
|
|
|
QStringList reps;
|
2011-06-01 14:07:47 +02:00
|
|
|
foreach (const Repository &repository, d->settings.repositories())
|
|
|
|
reps.append(repository.url().toString());
|
2011-05-31 17:22:24 +02:00
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
d->model.setStringList(reps);
|
|
|
|
d->ui.treeViewUpdateSources->setModel(&d->model);
|
2011-05-31 17:22:24 +02:00
|
|
|
|
2011-06-01 14:07:47 +02:00
|
|
|
d->ui.labelLastUpdateResult->clear();
|
2011-06-01 15:29:31 +02:00
|
|
|
if (!d->settings.lastResult().isEmpty()) {
|
2011-06-01 14:07:47 +02:00
|
|
|
d->ui.labelLastUpdateResult->setText(d->settings.lastResult() + QLatin1Char('\n')
|
|
|
|
+ d->settings.lastCheck().toString());
|
|
|
|
}
|
2011-05-31 17:22:24 +02:00
|
|
|
d->initialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateSettingsWidget::accept()
|
|
|
|
{
|
2011-06-01 14:07:47 +02:00
|
|
|
switch(d->ui.comboBoxFrequency->currentIndex()) {
|
2011-05-31 17:22:24 +02:00
|
|
|
case 0:
|
2011-06-01 14:07:47 +02:00
|
|
|
d->settings.setUpdateInterval(UpdateSettings::Daily);
|
2011-05-31 17:22:24 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-06-01 14:07:47 +02:00
|
|
|
d->settings.setUpdateInterval(UpdateSettings::Weekly);
|
2011-05-31 17:22:24 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-06-01 14:07:47 +02:00
|
|
|
d->settings.setUpdateInterval(UpdateSettings::Monthly);
|
2011-05-31 17:22:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2011-06-01 14:07:47 +02:00
|
|
|
|
2011-06-01 15:29:31 +02:00
|
|
|
if (!d->ui.checkBoxCheckForUpdates->isChecked())
|
2011-06-01 14:07:47 +02:00
|
|
|
d->settings.setUpdateInterval(-d->settings.updateInterval());
|
|
|
|
d->settings.setCheckOnlyImportantUpdates(d->ui.checkBoxCheckOnlyImportant->isChecked());
|
|
|
|
|
2011-11-15 12:37:01 +01:00
|
|
|
QSet<Repository> repositories;
|
2011-06-01 14:07:47 +02:00
|
|
|
foreach (const QString &url, d->model.stringList())
|
2011-11-15 12:37:01 +01:00
|
|
|
repositories.insert(Repository(QUrl(url), false));
|
2011-06-01 14:07:47 +02:00
|
|
|
d->settings.setRepositories(repositories);
|
2011-05-31 17:22:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "moc_updatesettingswidget.cpp"
|