diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-11-04 02:53:05 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-11-04 02:53:05 +0100 |
commit | bb7e8985f6d189de0acac6a1c3033cb16378c1fb (patch) | |
tree | 7c2e88c7184a7f5acf5e7a03be5c5f0bf6904113 /logic/lists | |
parent | d6e4fb29713d6ce55b092c0e22412f6121e7f516 (diff) | |
download | MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.gz MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.lz MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.xz MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.zip |
Reformat and (slightly) decruft all the things.
Diffstat (limited to 'logic/lists')
-rw-r--r-- | logic/lists/BaseVersionList.cpp | 36 | ||||
-rw-r--r-- | logic/lists/BaseVersionList.h | 46 | ||||
-rw-r--r-- | logic/lists/ForgeVersionList.cpp | 2 | ||||
-rw-r--r-- | logic/lists/ForgeVersionList.h | 3 | ||||
-rw-r--r-- | logic/lists/IconList.cpp | 146 | ||||
-rw-r--r-- | logic/lists/IconList.h | 48 | ||||
-rw-r--r-- | logic/lists/InstanceList.cpp | 4 | ||||
-rw-r--r-- | logic/lists/InstanceList.h | 2 | ||||
-rw-r--r-- | logic/lists/JavaVersionList.cpp | 7 | ||||
-rw-r--r-- | logic/lists/JavaVersionList.h | 6 | ||||
-rw-r--r-- | logic/lists/LwjglVersionList.cpp | 2 | ||||
-rw-r--r-- | logic/lists/LwjglVersionList.h | 113 | ||||
-rw-r--r-- | logic/lists/MinecraftVersionList.cpp | 4 | ||||
-rw-r--r-- | logic/lists/MinecraftVersionList.h | 31 |
14 files changed, 255 insertions, 195 deletions
diff --git a/logic/lists/BaseVersionList.cpp b/logic/lists/BaseVersionList.cpp index 61da5eeb..6e2c5282 100644 --- a/logic/lists/BaseVersionList.cpp +++ b/logic/lists/BaseVersionList.cpp @@ -3,7 +3,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -16,12 +16,11 @@ #include "logic/lists/BaseVersionList.h" #include "logic/BaseVersion.h" -BaseVersionList::BaseVersionList(QObject *parent) : - QAbstractListModel(parent) +BaseVersionList::BaseVersionList(QObject *parent) : QAbstractListModel(parent) { } -BaseVersionPtr BaseVersionList::findVersion( const QString& descriptor ) +BaseVersionPtr BaseVersionList::findVersion(const QString &descriptor) { for (int i = 0; i < count(); i++) { @@ -43,13 +42,12 @@ QVariant BaseVersionList::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); - + if (index.row() > count()) return QVariant(); - - + BaseVersionPtr version = at(index.row()); - + switch (role) { case Qt::DisplayRole: @@ -57,20 +55,20 @@ QVariant BaseVersionList::data(const QModelIndex &index, int role) const { case NameColumn: return version->name(); - + case TypeColumn: return version->typeString(); - + default: return QVariant(); } - + case Qt::ToolTipRole: return version->descriptor(); - + case VersionPointerRole: return qVariantFromValue(version); - + default: return QVariant(); } @@ -85,27 +83,27 @@ QVariant BaseVersionList::headerData(int section, Qt::Orientation orientation, i { case NameColumn: return "Name"; - + case TypeColumn: return "Type"; - + default: return QVariant(); } - + case Qt::ToolTipRole: switch (section) { case NameColumn: return "The name of the version."; - + case TypeColumn: return "The version's type."; - + default: return QVariant(); } - + default: return QVariant(); } diff --git a/logic/lists/BaseVersionList.h b/logic/lists/BaseVersionList.h index d37431ed..5ac9369b 100644 --- a/logic/lists/BaseVersionList.h +++ b/logic/lists/BaseVersionList.h @@ -3,7 +3,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -25,12 +25,12 @@ class Task; /*! - * \brief Class that each instance type's version list derives from. - * Version lists are the lists that keep track of the available game versions - * for that instance. This list will not be loaded on startup. It will be loaded + * \brief Class that each instance type's version list derives from. + * Version lists are the lists that keep track of the available game versions + * for that instance. This list will not be loaded on startup. It will be loaded * when the list's load function is called. Before using the version list, you * should check to see if it has been loaded yet and if not, load the list. - * + * * Note that this class also inherits from QAbstractListModel. Methods from that * class determine how this version list shows up in a list view. Said methods * all have a default implementation, but they can be overridden by plugins to @@ -44,21 +44,21 @@ public: { VersionPointerRole = 0x34B1CB48 }; - + enum VListColumns { // First column - Name NameColumn = 0, - + // Second column - Type TypeColumn, - + // Third column - Timestamp TimeColumn }; - + explicit BaseVersionList(QObject *parent = 0); - + /*! * \brief Gets a task that will reload the version list. * Simply execute the task to load the list. @@ -66,24 +66,23 @@ public: * \return A pointer to a task that reloads the version list. */ virtual Task *getLoadTask() = 0; - - //! Checks whether or not the list is loaded. If this returns false, the list should be loaded. + + //! Checks whether or not the list is loaded. If this returns false, the list should be + //loaded. virtual bool isLoaded() = 0; - + //! Gets the version at the given index. virtual const BaseVersionPtr at(int i) const = 0; - + //! Returns the number of versions in the list. virtual int count() const = 0; - - + //////// List Model Functions //////// virtual QVariant data(const QModelIndex &index, int role) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; virtual int rowCount(const QModelIndex &parent) const; virtual int columnCount(const QModelIndex &parent) const; - - + /*! * \brief Finds a version by its descriptor. * \param The descriptor of the version to find. @@ -91,20 +90,21 @@ public: * one doesn't exist. */ virtual BaseVersionPtr findVersion(const QString &descriptor); - + /*! * \brief Gets the latest stable version of this instance type. * This is the version that will be selected by default. * By default, this is simply the first version in the list. */ virtual BaseVersionPtr getLatestStable() const; - + /*! * Sorts the version list. */ virtual void sort() = 0; - -protected slots: + +protected +slots: /*! * Updates this list with the given list of versions. * This is done by copying each version in the given list and inserting it @@ -117,5 +117,5 @@ protected slots: * then copies the versions and sets their parents correctly. * \param versions List of versions whose parents should be set. */ - virtual void updateListData(QList<BaseVersionPtr > versions) = 0; + virtual void updateListData(QList<BaseVersionPtr> versions) = 0; }; diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp index 27f567cd..b5e421af 100644 --- a/logic/lists/ForgeVersionList.cpp +++ b/logic/lists/ForgeVersionList.cpp @@ -21,7 +21,7 @@ #include <QtXml> #include <QRegExp> -#include <logger/QsLog.h> +#include "logger/QsLog.h" #define JSON_URL "http://files.minecraftforge.net/minecraftforge/json" diff --git a/logic/lists/ForgeVersionList.h b/logic/lists/ForgeVersionList.h index 52593f94..0d10e1f3 100644 --- a/logic/lists/ForgeVersionList.h +++ b/logic/lists/ForgeVersionList.h @@ -75,8 +75,7 @@ public: virtual BaseVersionPtr getLatestStable() const; virtual QVariant data(const QModelIndex &index, int role) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; virtual int columnCount(const QModelIndex &parent) const; protected: diff --git a/logic/lists/IconList.cpp b/logic/lists/IconList.cpp index 6988d02f..ecfb8c3c 100644 --- a/logic/lists/IconList.cpp +++ b/logic/lists/IconList.cpp @@ -1,3 +1,18 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "IconList.h" #include <pathutils.h> #include <QMap> @@ -27,22 +42,21 @@ public: } }; - IconList::IconList() : QAbstractListModel(), d(new Private()) { QDir instance_icons(":/icons/instances/"); auto file_info_list = instance_icons.entryInfoList(QDir::Files, QDir::Name); - for(auto file_info: file_info_list) + for (auto file_info : file_info_list) { QString key = file_info.baseName(); addIcon(key, key, file_info.absoluteFilePath(), true); } - + // FIXME: get from settings ensureFolderPathExists("icons"); QDir user_icons("icons"); file_info_list = user_icons.entryInfoList(QDir::Files, QDir::Name); - for(auto file_info: file_info_list) + for (auto file_info : file_info_list) { QString filename = file_info.absoluteFilePath(); QString key = file_info.baseName(); @@ -67,16 +81,17 @@ Qt::DropActions IconList::supportedDropActions() const return Qt::CopyAction; } -bool IconList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) +bool IconList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent) { if (action == Qt::IgnoreAction) - return true; + return true; // check if the action is supported if (!data || !(action & supportedDropActions())) return false; // files dropped from outside? - if(data->hasUrls()) + if (data->hasUrls()) { /* bool was_watching = is_watching; @@ -85,10 +100,10 @@ bool IconList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int */ auto urls = data->urls(); QStringList iconFiles; - for(auto url: urls) + for (auto url : urls) { // only local files may be dropped... - if(!url.isLocalFile()) + if (!url.isLocalFile()) continue; iconFiles += url.toLocalFile(); } @@ -102,73 +117,73 @@ bool IconList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int return false; } -Qt::ItemFlags IconList::flags ( const QModelIndex& index ) const +Qt::ItemFlags IconList::flags(const QModelIndex &index) const { - Qt::ItemFlags defaultFlags = QAbstractListModel::flags ( index ); + Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index); if (index.isValid()) return Qt::ItemIsDropEnabled | defaultFlags; else return Qt::ItemIsDropEnabled | defaultFlags; } -QVariant IconList::data ( const QModelIndex& index, int role ) const +QVariant IconList::data(const QModelIndex &index, int role) const { - if(!index.isValid()) + if (!index.isValid()) return QVariant(); - + int row = index.row(); - - if(row < 0 || row >= d->icons.size()) + + if (row < 0 || row >= d->icons.size()) return QVariant(); - - switch(role) + + switch (role) { - case Qt::DecorationRole: - return d->icons[row].icon; - case Qt::DisplayRole: - return d->icons[row].name; - case Qt::UserRole: - return d->icons[row].key; - default: - return QVariant(); + case Qt::DecorationRole: + return d->icons[row].icon; + case Qt::DisplayRole: + return d->icons[row].name; + case Qt::UserRole: + return d->icons[row].key; + default: + return QVariant(); } } -int IconList::rowCount ( const QModelIndex& parent ) const +int IconList::rowCount(const QModelIndex &parent) const { return d->icons.size(); } -void IconList::installIcons ( QStringList iconFiles ) +void IconList::installIcons(QStringList iconFiles) { - for(QString file: iconFiles) + for (QString file : iconFiles) { QFileInfo fileinfo(file); - if(!fileinfo.isReadable() || !fileinfo.isFile()) + if (!fileinfo.isReadable() || !fileinfo.isFile()) continue; QString target = PathCombine("icons", fileinfo.fileName()); - + QString suffix = fileinfo.suffix(); - if(suffix != "jpeg" && suffix != "png" && suffix != "jpg") + if (suffix != "jpeg" && suffix != "png" && suffix != "jpg") continue; - - if(!QFile::copy(file, target)) + + if (!QFile::copy(file, target)) continue; - + QString key = fileinfo.baseName(); addIcon(key, key, target); } } -bool IconList::deleteIcon ( QString key ) +bool IconList::deleteIcon(QString key) { int iconIdx = getIconIndex(key); - if(iconIdx == -1) + if (iconIdx == -1) return false; - auto & iconEntry = d->icons[iconIdx]; - if(iconEntry.is_builtin) + auto &iconEntry = d->icons[iconIdx]; + if (iconEntry.is_builtin) return false; - if(QFile::remove(iconEntry.filename)) + if (QFile::remove(iconEntry.filename)) { beginRemoveRows(QModelIndex(), iconIdx, iconIdx); d->icons.remove(iconIdx); @@ -178,35 +193,36 @@ bool IconList::deleteIcon ( QString key ) return true; } -bool IconList::addIcon ( QString key, QString name, QString path, bool is_builtin ) +bool IconList::addIcon(QString key, QString name, QString path, bool is_builtin) { auto iter = d->index.find(key); - if(iter != d->index.end()) + if (iter != d->index.end()) { - if(d->icons[*iter].is_builtin) + if (d->icons[*iter].is_builtin) return false; - + QIcon icon(path); - if(icon.isNull()) + if (icon.isNull()) return false; - - auto & oldOne = d->icons[*iter]; - - if(!QFile::remove(oldOne.filename)) + + auto &oldOne = d->icons[*iter]; + + if (!QFile::remove(oldOne.filename)) return false; // replace the icon oldOne = {key, name, icon, is_builtin, path}; - dataChanged(index(*iter),index(*iter)); + dataChanged(index(*iter), index(*iter)); return true; } else { QIcon icon(path); - if(icon.isNull()) return false; - + if (icon.isNull()) + return false; + // add a new icon - beginInsertRows(QModelIndex(), d->icons.size(),d->icons.size()); + beginInsertRows(QModelIndex(), d->icons.size(), d->icons.size()); d->icons.push_back({key, name, icon, is_builtin, path}); d->index[key] = d->icons.size() - 1; endInsertRows(); @@ -218,39 +234,37 @@ void IconList::reindex() { d->index.clear(); int i = 0; - for(auto& iter: d->icons) + for (auto &iter : d->icons) { d->index[iter.key] = i; i++; } } - -QIcon IconList::getIcon ( QString key ) +QIcon IconList::getIcon(QString key) { int icon_index = getIconIndex(key); - if(icon_index != -1) + if (icon_index != -1) return d->icons[icon_index].icon; - + // Fallback for icons that don't exist. icon_index = getIconIndex("infinity"); - - if(icon_index != -1) + + if (icon_index != -1) return d->icons[icon_index].icon; return QIcon(); } -int IconList::getIconIndex ( QString key ) +int IconList::getIconIndex(QString key) { - if(key == "default") + if (key == "default") key = "infinity"; - + auto iter = d->index.find(key); - if(iter != d->index.end()) + if (iter != d->index.end()) return *iter; - - + return -1; } diff --git a/logic/lists/IconList.h b/logic/lists/IconList.h index cad80cdf..40ad043b 100644 --- a/logic/lists/IconList.h +++ b/logic/lists/IconList.h @@ -1,3 +1,18 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #pragma once #include <QMutex> @@ -11,28 +26,29 @@ class IconList : public QAbstractListModel public: IconList(); virtual ~IconList(); - - QIcon getIcon ( QString key ); - int getIconIndex ( QString key ); - - virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; - virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const; - + + QIcon getIcon(QString key); + int getIconIndex(QString key); + + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + bool addIcon(QString key, QString name, QString path, bool is_builtin = false); bool deleteIcon(QString key); - + virtual QStringList mimeTypes() const; virtual Qt::DropActions supportedDropActions() const; - virtual bool dropMimeData ( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ); - virtual Qt::ItemFlags flags ( const QModelIndex& index ) const; - - void installIcons ( QStringList iconFiles ); - + virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent); + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + + void installIcons(QStringList iconFiles); + private: // hide copy constructor - IconList ( const IconList & ) = delete; + IconList(const IconList &) = delete; // hide assign op - IconList& operator= ( const IconList & ) = delete; + IconList &operator=(const IconList &) = delete; void reindex(); - Private* d; + Private *d; }; diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp index b42d7b7a..4446ff22 100644 --- a/logic/lists/InstanceList.cpp +++ b/logic/lists/InstanceList.cpp @@ -29,7 +29,7 @@ #include "logic/lists/IconList.h" #include "logic/BaseInstance.h" #include "logic/InstanceFactory.h" -#include <logger/QsLog.h> +#include "logger/QsLog.h" const static int GROUP_FILE_FORMAT_VERSION = 1; @@ -423,7 +423,7 @@ bool InstanceProxyModel::subSortLessThan(const QModelIndex &left, BaseInstance *pdataLeft = static_cast<BaseInstance *>(left.internalPointer()); BaseInstance *pdataRight = static_cast<BaseInstance *>(right.internalPointer()); QString sortMode = MMC->settings()->get("InstSortMode").toString(); - if(sortMode == "LastLaunch") + if (sortMode == "LastLaunch") { return pdataLeft->lastLaunch() > pdataRight->lastLaunch(); } diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h index 3cde6bf5..c3e3561d 100644 --- a/logic/lists/InstanceList.h +++ b/logic/lists/InstanceList.h @@ -98,7 +98,7 @@ signals: public slots: - void on_InstFolderChanged(const Setting & setting, QVariant value); + void on_InstFolderChanged(const Setting &setting, QVariant value); private slots: diff --git a/logic/lists/JavaVersionList.cpp b/logic/lists/JavaVersionList.cpp index 5389c4cc..3dc1969b 100644 --- a/logic/lists/JavaVersionList.cpp +++ b/logic/lists/JavaVersionList.cpp @@ -20,7 +20,7 @@ #include <QtXml> #include <QRegExp> -#include <logger/QsLog.h> +#include "logger/QsLog.h" #include <logic/JavaUtils.h> JavaVersionList::JavaVersionList(QObject *parent) : BaseVersionList(parent) @@ -32,7 +32,6 @@ Task *JavaVersionList::getLoadTask() return new JavaListLoadTask(this); } - const BaseVersionPtr JavaVersionList::at(int i) const { return m_vlist.at(i); @@ -187,11 +186,11 @@ void JavaListLoadTask::executeTask() QList<JavaVersionPtr> javas = ju.FindJavaPaths(); QList<BaseVersionPtr> javas_bvp; - for(int i = 0; i < javas.length(); i++) + for (int i = 0; i < javas.length(); i++) { BaseVersionPtr java = std::dynamic_pointer_cast<BaseVersion>(javas.at(i)); - if(java) + if (java) { javas_bvp.append(java); } diff --git a/logic/lists/JavaVersionList.h b/logic/lists/JavaVersionList.h index 23bccfe4..4826ca0c 100644 --- a/logic/lists/JavaVersionList.h +++ b/logic/lists/JavaVersionList.h @@ -64,11 +64,11 @@ public: virtual BaseVersionPtr getTopRecommended() const; virtual QVariant data(const QModelIndex &index, int role) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; virtual int columnCount(const QModelIndex &parent) const; -public slots: +public +slots: virtual void updateListData(QList<BaseVersionPtr> versions); protected: diff --git a/logic/lists/LwjglVersionList.cpp b/logic/lists/LwjglVersionList.cpp index 6bf401ec..3333e86c 100644 --- a/logic/lists/LwjglVersionList.cpp +++ b/logic/lists/LwjglVersionList.cpp @@ -20,7 +20,7 @@ #include <QtXml> #include <QRegExp> -#include <logger/QsLog.h> +#include "logger/QsLog.h" #define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss" diff --git a/logic/lists/LwjglVersionList.h b/logic/lists/LwjglVersionList.h index 99712292..fa57e8eb 100644 --- a/logic/lists/LwjglVersionList.h +++ b/logic/lists/LwjglVersionList.h @@ -3,7 +3,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -28,20 +28,30 @@ typedef std::shared_ptr<LWJGLVersion> PtrLWJGLVersion; class LWJGLVersion : public QObject { Q_OBJECT - - LWJGLVersion(const QString &name, const QString &url, QObject *parent = 0) : - QObject(parent), m_name(name), m_url(url) { } + + LWJGLVersion(const QString &name, const QString &url, QObject *parent = 0) + : QObject(parent), m_name(name), m_url(url) + { + } + public: - + static PtrLWJGLVersion Create(const QString &name, const QString &url, QObject *parent = 0) { return PtrLWJGLVersion(new LWJGLVersion(name, url, parent)); - }; - - QString name() const { return m_name; } - - QString url() const { return m_url; } - + } + ; + + QString name() const + { + return m_name; + } + + QString url() const + { + return m_url; + } + protected: QString m_name; QString m_url; @@ -52,64 +62,87 @@ class LWJGLVersionList : public QAbstractListModel Q_OBJECT public: explicit LWJGLVersionList(QObject *parent = 0); - - bool isLoaded() { return m_vlist.length() > 0; } - + + bool isLoaded() + { + return m_vlist.length() > 0; + } + const PtrLWJGLVersion getVersion(const QString &versionName); - PtrLWJGLVersion at(int index) { return m_vlist[index]; } - const PtrLWJGLVersion at(int index) const { return m_vlist[index]; } - - int count() const { return m_vlist.length(); } - + PtrLWJGLVersion at(int index) + { + return m_vlist[index]; + } + const PtrLWJGLVersion at(int index) const + { + return m_vlist[index]; + } + + int count() const + { + return m_vlist.length(); + } + virtual QVariant data(const QModelIndex &index, int role) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; - virtual int rowCount(const QModelIndex &parent) const { return count(); } + virtual int rowCount(const QModelIndex &parent) const + { + return count(); + } virtual int columnCount(const QModelIndex &parent) const; - + virtual bool isLoading() const; - virtual bool errored() const { return m_errored; } - - virtual QString lastErrorMsg() const { return m_lastErrorMsg; } - -public slots: + virtual bool errored() const + { + return m_errored; + } + + virtual QString lastErrorMsg() const + { + return m_lastErrorMsg; + } + +public +slots: /*! * Loads the version list. * This is done asynchronously. On success, the loadListFinished() signal will - * be emitted. The list model will be reset as well, resulting in the modelReset() - * signal being emitted. Note that the model will be reset before loadListFinished() is emitted. + * be emitted. The list model will be reset as well, resulting in the modelReset() + * signal being emitted. Note that the model will be reset before loadListFinished() is + * emitted. * If loading the list failed, the loadListFailed(QString msg), * signal will be emitted. */ virtual void loadList(); - + signals: /*! * Emitted when the list either starts or finishes loading. * \param loading Whether or not the list is loading. */ void loadingStateUpdated(bool loading); - + void loadListFinished(); - + void loadListFailed(QString msg); - + private: QList<PtrLWJGLVersion> m_vlist; - + QNetworkReply *m_netReply; QNetworkReply *reply; - + bool m_loading; bool m_errored; QString m_lastErrorMsg; - + void failed(QString msg); - + void finished(); - + void setLoading(bool loading); - -private slots: + +private +slots: virtual void netRequestComplete(); }; - diff --git a/logic/lists/MinecraftVersionList.cpp b/logic/lists/MinecraftVersionList.cpp index dd26714a..2a9c0d3b 100644 --- a/logic/lists/MinecraftVersionList.cpp +++ b/logic/lists/MinecraftVersionList.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013 Andrew Okin +/* Copyright 2013 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ */ #include "MinecraftVersionList.h" -#include <MultiMC.h> +#include "MultiMC.h" #include <QtXml> diff --git a/logic/lists/MinecraftVersionList.h b/logic/lists/MinecraftVersionList.h index ed68efbb..90b1ae86 100644 --- a/logic/lists/MinecraftVersionList.h +++ b/logic/lists/MinecraftVersionList.h @@ -1,9 +1,9 @@ -/* Copyright 2013 Andrew Okin +/* Copyright 2013 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -32,43 +32,44 @@ class MinecraftVersionList : public BaseVersionList Q_OBJECT public: friend class MCVListLoadTask; - + explicit MinecraftVersionList(QObject *parent = 0); - + virtual Task *getLoadTask(); virtual bool isLoaded(); virtual const BaseVersionPtr at(int i) const; virtual int count() const; virtual void sort(); - + virtual BaseVersionPtr getLatestStable() const; - + protected: QList<BaseVersionPtr> m_vlist; - + bool m_loaded = false; - -protected slots: + +protected +slots: virtual void updateListData(QList<BaseVersionPtr> versions); }; class MCVListLoadTask : public Task { Q_OBJECT - + public: explicit MCVListLoadTask(MinecraftVersionList *vlist); ~MCVListLoadTask(); - + virtual void executeTask(); - -protected slots: + +protected +slots: void list_downloaded(); - + protected: QNetworkReply *vlistReply; MinecraftVersionList *m_list; MinecraftVersion *m_currentStable; QSet<QString> legacyWhitelist; }; - |