summaryrefslogtreecommitdiffstats
path: root/application/pages/global
diff options
context:
space:
mode:
Diffstat (limited to 'application/pages/global')
-rw-r--r--application/pages/global/PackagesPage.cpp (renamed from application/pages/global/WonkoPage.cpp)117
-rw-r--r--application/pages/global/PackagesPage.h (renamed from application/pages/global/WonkoPage.h)14
-rw-r--r--application/pages/global/PackagesPage.ui (renamed from application/pages/global/WonkoPage.ui)12
3 files changed, 60 insertions, 83 deletions
diff --git a/application/pages/global/WonkoPage.cpp b/application/pages/global/PackagesPage.cpp
index 1a72b18d..e15ddbab 100644
--- a/application/pages/global/WonkoPage.cpp
+++ b/application/pages/global/PackagesPage.cpp
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-#include "WonkoPage.h"
-#include "ui_WonkoPage.h"
+#include "PackagesPage.h"
+#include "ui_PackagesPage.h"
#include <QDateTime>
#include <QSortFilterProxyModel>
@@ -23,33 +23,33 @@
#include "dialogs/ProgressDialog.h"
#include "VersionProxyModel.h"
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersionList.h"
-#include "wonko/WonkoVersion.h"
+#include "meta/Index.h"
+#include "meta/VersionList.h"
+#include "meta/Version.h"
#include "Env.h"
#include "MultiMC.h"
-static QString formatRequires(const WonkoVersionPtr &version)
+using namespace Meta;
+
+static QString formatRequires(const VersionPtr &version)
{
QStringList lines;
- for (const WonkoReference &ref : version->requires())
+ auto & reqs = version->requires();
+ auto iter = reqs.begin();
+ while (iter != reqs.end())
{
- const QString readable = ENV.wonkoIndex()->hasUid(ref.uid()) ? ENV.wonkoIndex()->getList(ref.uid())->humanReadable() : ref.uid();
- if (ref.version().isEmpty())
- {
- lines.append(readable);
- }
- else
- {
- lines.append(QString("%1 (%2)").arg(readable, ref.version()));
- }
+ auto &uid = iter.key();
+ auto &version = iter.value();
+ const QString readable = ENV.metadataIndex()->hasUid(uid) ? ENV.metadataIndex()->get(uid)->humanReadable() : uid;
+ lines.append(QString("%1 (%2)").arg(readable, version));
+ iter++;
}
return lines.join('\n');
}
-WonkoPage::WonkoPage(QWidget *parent) :
+PackagesPage::PackagesPage(QWidget *parent) :
QWidget(parent),
- ui(new Ui::WonkoPage)
+ ui(new Ui::PackagesPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
@@ -61,11 +61,11 @@ WonkoPage::WonkoPage(QWidget *parent) :
m_fileProxy->setFilterRole(Qt::DisplayRole);
m_fileProxy->setFilterKeyColumn(0);
m_fileProxy->sort(0);
- m_fileProxy->setSourceModel(ENV.wonkoIndex().get());
+ m_fileProxy->setSourceModel(ENV.metadataIndex().get());
ui->indexView->setModel(m_fileProxy);
m_filterProxy = new QSortFilterProxyModel(this);
- m_filterProxy->setSortRole(WonkoVersionList::SortRole);
+ m_filterProxy->setSortRole(VersionList::SortRole);
m_filterProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_filterProxy->setFilterRole(Qt::DisplayRole);
m_filterProxy->setFilterKeyColumn(0);
@@ -75,48 +75,48 @@ WonkoPage::WonkoPage(QWidget *parent) :
m_versionProxy = new VersionProxyModel(this);
m_filterProxy->setSourceModel(m_versionProxy);
- connect(ui->indexView->selectionModel(), &QItemSelectionModel::currentChanged, this, &WonkoPage::updateCurrentVersionList);
- connect(ui->versionsView->selectionModel(), &QItemSelectionModel::currentChanged, this, &WonkoPage::updateVersion);
- connect(m_filterProxy, &QSortFilterProxyModel::dataChanged, this, &WonkoPage::versionListDataChanged);
+ connect(ui->indexView->selectionModel(), &QItemSelectionModel::currentChanged, this, &PackagesPage::updateCurrentVersionList);
+ connect(ui->versionsView->selectionModel(), &QItemSelectionModel::currentChanged, this, &PackagesPage::updateVersion);
+ connect(m_filterProxy, &QSortFilterProxyModel::dataChanged, this, &PackagesPage::versionListDataChanged);
updateCurrentVersionList(QModelIndex());
updateVersion();
}
-WonkoPage::~WonkoPage()
+PackagesPage::~PackagesPage()
{
delete ui;
}
-QIcon WonkoPage::icon() const
+QIcon PackagesPage::icon() const
{
- return MMC->getThemedIcon("looney");
+ return MMC->getThemedIcon("packages");
}
-void WonkoPage::on_refreshIndexBtn_clicked()
+void PackagesPage::on_refreshIndexBtn_clicked()
{
- ProgressDialog(this).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
+ ENV.metadataIndex()->load();
}
-void WonkoPage::on_refreshFileBtn_clicked()
+void PackagesPage::on_refreshFileBtn_clicked()
{
- WonkoVersionListPtr list = ui->indexView->currentIndex().data(WonkoIndex::ListPtrRole).value<WonkoVersionListPtr>();
+ VersionListPtr list = ui->indexView->currentIndex().data(Index::ListPtrRole).value<VersionListPtr>();
if (!list)
{
return;
}
- ProgressDialog(this).execWithTask(list->remoteUpdateTask());
+ list->load();
}
-void WonkoPage::on_refreshVersionBtn_clicked()
+void PackagesPage::on_refreshVersionBtn_clicked()
{
- WonkoVersionPtr version = ui->versionsView->currentIndex().data(WonkoVersionList::WonkoVersionPtrRole).value<WonkoVersionPtr>();
+ VersionPtr version = ui->versionsView->currentIndex().data(VersionList::VersionPtrRole).value<VersionPtr>();
if (!version)
{
return;
}
- ProgressDialog(this).execWithTask(version->remoteUpdateTask());
+ version->load();
}
-void WonkoPage::on_fileSearchEdit_textChanged(const QString &search)
+void PackagesPage::on_fileSearchEdit_textChanged(const QString &search)
{
if (search.isEmpty())
{
@@ -129,7 +129,7 @@ void WonkoPage::on_fileSearchEdit_textChanged(const QString &search)
m_fileProxy->setFilterRegExp(".*" + parts.join(".*") + ".*");
}
}
-void WonkoPage::on_versionSearchEdit_textChanged(const QString &search)
+void PackagesPage::on_versionSearchEdit_textChanged(const QString &search)
{
if (search.isEmpty())
{
@@ -143,11 +143,11 @@ void WonkoPage::on_versionSearchEdit_textChanged(const QString &search)
}
}
-void WonkoPage::updateCurrentVersionList(const QModelIndex &index)
+void PackagesPage::updateCurrentVersionList(const QModelIndex &index)
{
if (index.isValid())
{
- WonkoVersionListPtr list = index.data(WonkoIndex::ListPtrRole).value<WonkoVersionListPtr>();
+ VersionListPtr list = index.data(Index::ListPtrRole).value<VersionListPtr>();
ui->versionsBox->setEnabled(true);
ui->refreshFileBtn->setEnabled(true);
ui->fileUidLabel->setEnabled(true);
@@ -156,19 +156,7 @@ void WonkoPage::updateCurrentVersionList(const QModelIndex &index)
ui->fileName->setText(list->name());
m_versionProxy->setSourceModel(list.get());
ui->refreshFileBtn->setText(tr("Refresh %1").arg(list->humanReadable()));
-
- if (!list->isLocalLoaded())
- {
- std::unique_ptr<Task> task = list->localUpdateTask();
- connect(task.get(), &Task::finished, this, [this, list]()
- {
- if (list->count() == 0 && !list->isRemoteLoaded())
- {
- ProgressDialog(this).execWithTask(list->remoteUpdateTask());
- }
- });
- ProgressDialog(this).execWithTask(task);
- }
+ list->load();
}
else
{
@@ -179,11 +167,11 @@ void WonkoPage::updateCurrentVersionList(const QModelIndex &index)
ui->fileNameLabel->setEnabled(false);
ui->fileName->clear();
m_versionProxy->setSourceModel(nullptr);
- ui->refreshFileBtn->setText(tr("Refresh ___"));
+ ui->refreshFileBtn->setText(tr("Refresh"));
}
}
-void WonkoPage::versionListDataChanged(const QModelIndex &tl, const QModelIndex &br)
+void PackagesPage::versionListDataChanged(const QModelIndex &tl, const QModelIndex &br)
{
if (QItemSelection(tl, br).contains(ui->versionsView->currentIndex()))
{
@@ -191,10 +179,10 @@ void WonkoPage::versionListDataChanged(const QModelIndex &tl, const QModelIndex
}
}
-void WonkoPage::updateVersion()
+void PackagesPage::updateVersion()
{
- WonkoVersionPtr version = std::dynamic_pointer_cast<WonkoVersion>(
- ui->versionsView->currentIndex().data(WonkoVersionList::VersionPointerRole).value<BaseVersionPtr>());
+ VersionPtr version = std::dynamic_pointer_cast<Version>(
+ ui->versionsView->currentIndex().data(VersionList::VersionPointerRole).value<BaseVersionPtr>());
if (version)
{
ui->refreshVersionBtn->setEnabled(true);
@@ -219,22 +207,11 @@ void WonkoPage::updateVersion()
ui->versionType->clear();
ui->versionRequiresLabel->setEnabled(false);
ui->versionRequires->clear();
- ui->refreshVersionBtn->setText(tr("Refresh ___"));
+ ui->refreshVersionBtn->setText(tr("Refresh"));
}
}
-void WonkoPage::opened()
+void PackagesPage::opened()
{
- if (!ENV.wonkoIndex()->isLocalLoaded())
- {
- std::unique_ptr<Task> task = ENV.wonkoIndex()->localUpdateTask();
- connect(task.get(), &Task::finished, this, [this]()
- {
- if (!ENV.wonkoIndex()->isRemoteLoaded())
- {
- ProgressDialog(this).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
- }
- });
- ProgressDialog(this).execWithTask(task);
- }
+ ENV.metadataIndex()->load();
}
diff --git a/application/pages/global/WonkoPage.h b/application/pages/global/PackagesPage.h
index 1d576c15..80c2886d 100644
--- a/application/pages/global/WonkoPage.h
+++ b/application/pages/global/PackagesPage.h
@@ -20,21 +20,21 @@
#include "pages/BasePage.h"
namespace Ui {
-class WonkoPage;
+class PackagesPage;
}
class QSortFilterProxyModel;
class VersionProxyModel;
-class WonkoPage : public QWidget, public BasePage
+class PackagesPage : public QWidget, public BasePage
{
Q_OBJECT
public:
- explicit WonkoPage(QWidget *parent = 0);
- ~WonkoPage();
+ explicit PackagesPage(QWidget *parent = 0);
+ ~PackagesPage();
- QString id() const override { return "wonko-global"; }
- QString displayName() const override { return tr("Wonko"); }
+ QString id() const override { return "packages-global"; }
+ QString displayName() const override { return tr("Packages"); }
QIcon icon() const override;
void opened() override;
@@ -48,7 +48,7 @@ private slots:
void versionListDataChanged(const QModelIndex &tl, const QModelIndex &br);
private:
- Ui::WonkoPage *ui;
+ Ui::PackagesPage *ui;
QSortFilterProxyModel *m_fileProxy;
QSortFilterProxyModel *m_filterProxy;
VersionProxyModel *m_versionProxy;
diff --git a/application/pages/global/WonkoPage.ui b/application/pages/global/PackagesPage.ui
index 2d14ceca..158bf1b4 100644
--- a/application/pages/global/WonkoPage.ui
+++ b/application/pages/global/PackagesPage.ui
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>WonkoPage</class>
- <widget class="QWidget" name="WonkoPage">
+ <class>PackagesPage</class>
+ <widget class="QWidget" name="PackagesPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>640</width>
- <height>480</height>
+ <width>636</width>
+ <height>621</height>
</rect>
</property>
<property name="windowTitle">
@@ -67,7 +67,7 @@
<item>
<widget class="QPushButton" name="refreshVersionBtn">
<property name="text">
- <string>Refresh ___</string>
+ <string>Refresh</string>
</property>
</widget>
</item>
@@ -180,7 +180,7 @@
<item>
<widget class="QPushButton" name="refreshFileBtn">
<property name="text">
- <string>Refresh ___</string>
+ <string>Refresh</string>
</property>
</widget>
</item>