Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
- Implemented "Set latest version" on the General Info page. Latest v…
Browse files Browse the repository at this point in the history
…ersion is obtained from http://www.phpbb.com/updatecheck/30x.txt
  • Loading branch information
Marek A. Ruszczyński committed Dec 14, 2008
1 parent 18a7953 commit d4af7f4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ModX.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
QT += network

CONFIG -= debug
CONFIG += release
TARGET = ModX
Expand Down
2 changes: 1 addition & 1 deletion pages/changelogpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ChangelogPage::ChangelogPage(QWidget *parent) :
ui.versionList->setSelectionMode(QAbstractItemView::SingleSelection);

connect(ui.versionList->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateEntry(const QItemSelection &, const QItemSelection &)));
connect(ui.version, SIGNAL(textChanged(const QString &)), this, SLOT(updateVersion(const QString &)));
connect(ui.version, SIGNAL(textChanged(const QString &)), this, SLOT(updateVersion(const QString &)));
connect(ui.add, SIGNAL(clicked()), this, SLOT(addVersion()));
connect(ui.remove, SIGNAL(clicked()), this, SLOT(removeVersion()));
}
Expand Down
5 changes: 0 additions & 5 deletions pages/filepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ void FilePage::updateFiles(bool /*checked*/)
setRootDir();
}

void FilePage::on_setLatestVersion_clicked()
{

}

void FilePage::changeEvent(QEvent *e)
{
switch(e->type()) {
Expand Down
1 change: 0 additions & 1 deletion pages/filepage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class FilePage : public Page {

protected slots:
void updateFiles(bool checked);
void on_setLatestVersion_clicked();

protected:
virtual void changeEvent(QEvent *e);
Expand Down
26 changes: 25 additions & 1 deletion pages/generalpage.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "generalpage.h"

#include "../modxdata.h"
#include "modxdata.h"

#include <QNetworkAccessManager>
#include <QNetworkReply>

GeneralPage::GeneralPage(QWidget *parent) :
Page(parent){
Expand All @@ -22,6 +25,8 @@ GeneralPage::GeneralPage(QWidget *parent) :
<< tr("Hard");

ui.installLevel->addItems(installationLevels);

manager = NULL;
}

void GeneralPage::setData(const ModXData *data)
Expand Down Expand Up @@ -50,6 +55,25 @@ void GeneralPage::getData(ModXData *data)
data->targetVersion = ui.targetVersion->text();
}

void GeneralPage::on_setLatestVersion_clicked()
{
if (manager == NULL)
{
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(handleNetworkReply(QNetworkReply *)));
}
manager->get(QNetworkRequest(QUrl("http://www.phpbb.com/updatecheck/30x.txt")));
}

void GeneralPage::handleNetworkReply(QNetworkReply *reply)
{
if (reply->error() != QNetworkReply::NoError)
{
return;
}
QString latestVersion(reply->readLine(1024));
ui.targetVersion->setText(latestVersion.trimmed());
}

void GeneralPage::changeEvent(QEvent *e)
{
Expand Down
8 changes: 8 additions & 0 deletions pages/generalpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "page.h"
#include "ui_generalpage.h"

class QNetworkAccessManager;
class QNetworkReply;

class GeneralPage : public Page {
Q_OBJECT
Q_DISABLE_COPY(GeneralPage)
Expand All @@ -14,10 +17,15 @@ class GeneralPage : public Page {
virtual void setData(const ModXData *data);
virtual void getData(ModXData *data);

protected slots:
void on_setLatestVersion_clicked();
void handleNetworkReply(QNetworkReply *reply);

protected:
virtual void changeEvent(QEvent *e);

private:
QNetworkAccessManager *manager;
Ui::GeneralPage ui;
};

Expand Down

0 comments on commit d4af7f4

Please sign in to comment.