summaryrefslogtreecommitdiff
path: root/src/gui/models
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-13 15:46:41 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-14 00:46:22 +0300
commit93feb7fbf408ccc9178832d5f21c3806cb2a9f16 (patch)
treeb0ee8c847e5933a86ea53dea5a3f87b8c6533191 /src/gui/models
parent99ecd9ba734a308ae374d4494856d8bb3617f8a0 (diff)
downloadmv-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.tar.gz
mv-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.tar.bz2
mv-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.tar.xz
mv-93feb7fbf408ccc9178832d5f21c3806cb2a9f16.zip
Add support for different groups of update servers reading from servers list.
Diffstat (limited to 'src/gui/models')
-rw-r--r--src/gui/models/updatelistmodel.h37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h
index 67fffc34e..0f1104200 100644
--- a/src/gui/models/updatelistmodel.h
+++ b/src/gui/models/updatelistmodel.h
@@ -25,17 +25,25 @@
#include "gui/models/listmodel.h"
-#include "net/logindata.h"
+#include "net/hostsgroup.h"
+
+#include "utils/stringvector.h"
#include "localconsts.h"
class UpdateListModel final : public ListModel
{
public:
- explicit UpdateListModel(LoginData *const data) :
+ explicit UpdateListModel(ServerInfo *const server) :
ListModel(),
- mLoginData(data)
+ mNames(),
+ mServer(server)
{
+ FOR_EACH(std::vector<HostsGroup>::const_iterator, it, server->updateHosts)
+ {
+ const HostsGroup &group = *it;
+ mNames.push_back(group.name);
+ }
}
A_DELETE_COPY(UpdateListModel)
@@ -45,20 +53,31 @@ class UpdateListModel final : public ListModel
int getNumberOfElements() override final
{
- if (!mLoginData)
- return 0;
- return CAST_S32(mLoginData->updateHosts.size());
+ return CAST_S32(mNames.size());
}
std::string getElementAt(int i) override final
{
- if (!mLoginData || i >= getNumberOfElements() || i < 0)
+ if (i >= getNumberOfElements() || i < 0)
return "???";
- return mLoginData->updateHosts[i];
+ return mNames[i];
+ }
+
+ HostsGroup &getSelectedGroup(const unsigned int sel)
+ {
+ if (sel >= mServer->updateHosts.size())
+ return mServer->updateHosts[0];
+ mServer->updateHosts[sel];
+ }
+
+ bool empty() const
+ {
+ return mNames.empty();
}
protected:
- LoginData *mLoginData;
+ StringVect mNames;
+ ServerInfo *mServer;
};
#endif // GUI_MODELS_UPDATELISTMODEL_H