Commit 08a8ca10 authored by twanvl's avatar twanvl

Put PackageUpdateList into its own file

parent e809c95a
......@@ -254,9 +254,9 @@ DownloadableInstaller::~DownloadableInstaller() {
// ----------------------------------------------------------------------------- : Installable package
InstallablePackage::InstallablePackage(const PackageVersionP& installed, const PackageDescriptionP& description)
: installed(installed)
, description(description)
InstallablePackage::InstallablePackage(const PackageDescriptionP& description, const PackageVersionP& installed)
: description(description)
, installed(installed)
, status(PACKAGE_INSTALLED)
, action(PACKAGE_NOTHING)
{}
......@@ -586,5 +586,5 @@ InstallablePackageP mse_installable_package() {
mse_description->position_hint = -100;
mse_description->icon = load_resource_image(_("installer_program"));
//mse_description->description = _LABEL_("magic set editor package");
return new_intrusive2<InstallablePackage>(mse_version,mse_description);
return new_intrusive2<InstallablePackage>(mse_description, mse_version);
}
......@@ -18,6 +18,13 @@ DECLARE_POINTER_TYPE(PackageDescription);
DECLARE_POINTER_TYPE(DownloadableInstaller);
DECLARE_POINTER_TYPE(InstallablePackage);
// The installer system consists of several layers:
// - Installer = an actual package available in memory, containing packages to be installed
// - DownloadableInstaller = an installar (possibly) not yet available, i.e. just its URL
// - PackageDescription = description of a package version
// - InstallablePackage = the complete status of a package, both local and remote
// ----------------------------------------------------------------------------- : Installer
/// A package that contains other packages that can be installed
......@@ -125,12 +132,13 @@ inline bool flag(int flags, int flag) { return (flags & flag) == flag; }
/// A package that can be installed, or is already installed
class InstallablePackage : public IntrusivePtrVirtualBase {
public:
//InstallablePackage();
/// A new package
InstallablePackage(const PackageDescriptionP&, const DownloadableInstallerP&);
InstallablePackage(const PackageVersionP&, const PackageDescriptionP&);
/// An installed package
InstallablePackage(const PackageDescriptionP&, const PackageVersionP&);
PackageVersionP installed; ///< The information of the installed package (if installed)
PackageDescriptionP description; ///< The details of the package. Either from the installed package or from an installer
PackageVersionP installed; ///< The information of the installed package (if installed)
DownloadableInstallerP installer; ///< The installer to install from (if updates are available)
PackageStatus status; ///< Status of installation
PackageAction action; ///< What to do with this package?
......
This diff is collapsed.
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_PACKAGE_UPDATE_LIST
#define HEADER_GUI_PACKAGE_UPDATE_LIST
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/control/tree_list.hpp>
#include <data/installer.hpp>
// ----------------------------------------------------------------------------- : PackageUpdateList
/// A list of installed and downloadable packages
class PackageUpdateList : public TreeList {
public:
PackageUpdateList(Window* parent, const InstallablePackages& packages, int id = wxID_ANY);
~PackageUpdateList();
inline InstallablePackageP getSelection() const {
return selection == NOTHING ? InstallablePackageP() : get(selection);
}
inline InstallablePackageP get(size_t item) const {
return static_pointer_cast<TreeItem>(items[item])->package;
}
protected:
// overridden methods from TreeList
virtual void initItems();
virtual void drawItem(DC& dc, size_t index, size_t column, int x, int y, bool selected) const;
virtual size_t columnCount() const { return 3; }
virtual String columnText(size_t column) const;
virtual int columnWidth(size_t column) const;
private:
const InstallablePackages& packages;
class TreeItem;
public:
typedef intrusive_ptr<TreeItem> TreeItemP;
private:
class TreeItem : public Item {
public:
TreeItem() : position_type(TYPE_OTHER), position_hint(1000000) {}
String label;
vector<TreeItemP> children;
InstallablePackageP package;
Bitmap icon, icon_grey;
// positioning
enum PackageType {
TYPE_PROG,
TYPE_LOCALE,
TYPE_GAME,
TYPE_STYLESHEET,
TYPE_EXPORT_TEMPLATE,
TYPE_SYMBOL_FONT,
TYPE_INCLUDE,
TYPE_FONT,
TYPE_OTHER,
} position_type;
int position_hint;
void add(const InstallablePackageP& package, const String& path, int level = -1);
void toItems(vector<TreeList::ItemP>& items);
void setIcon(const Image& image);
bool highlight() const;
static PackageType package_type(const PackageDescription& desc);
};
friend class PackageIconRequest;
};
// ----------------------------------------------------------------------------- : EOF
#endif
This diff is collapsed.
......@@ -20,9 +20,13 @@ class PackageInfoPanel;
/// A window that displays the installed packages and updates to them
class PackagesWindow : public wxDialog {
public:
/// Show the packages window, optionally downloading the package database from the website
PackagesWindow(Window* parent, bool download_package_list = true);
/// Show the packages window for an installer
PackagesWindow(Window* parent, const InstallerP& installer);
~PackagesWindow();
/// List of the packages shown in this window
InstallablePackages installable_packages;
private:
......@@ -42,6 +46,8 @@ class PackagesWindow : public wxDialog {
void onUpdateUI(wxUpdateUIEvent&);
void onIdle(wxIdleEvent&);
/// Check whether we have downloaded the list of installers
/** If the download is (partially) complete, update the installable_packages list */
bool checkInstallerList(bool refresh = true);
};
......
......@@ -1000,12 +1000,6 @@
<File
RelativePath=".\gui\new_window.hpp">
</File>
<File
RelativePath=".\gui\packages_window.cpp">
</File>
<File
RelativePath=".\gui\packages_window.hpp">
</File>
<File
RelativePath=".\gui\preferences_window.cpp">
</File>
......@@ -1025,17 +1019,33 @@
RelativePath=".\gui\thumbnail_thread.hpp">
</File>
<File
RelativePath=".\gui\update_checker.cpp">
RelativePath=".\gui\welcome_window.cpp">
</File>
<File
RelativePath=".\gui\update_checker.hpp">
RelativePath=".\gui\welcome_window.hpp">
</File>
<Filter
Name="package"
Filter="">
<File
RelativePath=".\gui\welcome_window.cpp">
RelativePath=".\gui\package_update_list.cpp">
</File>
<File
RelativePath=".\gui\welcome_window.hpp">
RelativePath=".\gui\package_update_list.hpp">
</File>
<File
RelativePath=".\gui\packages_window.cpp">
</File>
<File
RelativePath=".\gui\packages_window.hpp">
</File>
<File
RelativePath=".\gui\update_checker.cpp">
</File>
<File
RelativePath=".\gui\update_checker.hpp">
</File>
</Filter>
</Filter>
<Filter
Name="value"
......
......@@ -234,7 +234,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
PackageVersionP ver(new PackageVersion(
is_local ? PackageVersion::STATUS_LOCAL : PackageVersion::STATUS_GLOBAL));
ver->check_status(*pack);
packages_out.push_back(new_intrusive2<InstallablePackage>(ver, new_intrusive1<PackageDescription>(*pack)));
packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), ver));
} catch (const Error&) {}
++it2;
} else if ((*it1)->name < *it2) {
......@@ -246,7 +246,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
try {
PackagedP pack = ::packages.openAny(*it2, true);
(*it1)->check_status(*pack);
packages_out.push_back(new_intrusive2<InstallablePackage>(*it1, new_intrusive1<PackageDescription>(*pack)));
packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), *it1));
} catch (const Error&) { db_changed = true; }
++it1, ++it2;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment