From 78baa8ff0275965b156a47a2969105cc55f9d170 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 12 Mar 2016 21:57:24 +0100 Subject: [PATCH] Changed: Methods to convert index from/to profile ID --- .../ryzom_installer/src/profilesmodel.cpp | 17 +++++++++++++++++ .../client/ryzom_installer/src/profilesmodel.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp index 13c9e00da..1977b423b 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.cpp @@ -46,3 +46,20 @@ bool CProfilesModel::save() const return true; } + +int CProfilesModel::getIndexFromProfileID(int profileId) const +{ + for(int i = 0; i < m_profiles.size(); ++i) + { + if (m_profiles[i].id == profileId) return i; + } + + return -1; +} + +int CProfilesModel::getProfileIDFromIndex(int index) const +{ + if (index < 0 || index >= m_profiles.size()) return -1; + + return m_profiles[index].id; +} diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h index 283be0c24..ea02f618c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesmodel.h @@ -25,6 +25,9 @@ public: bool save() const; + int getIndexFromProfileID(int profileId) const; + int getProfileIDFromIndex(int index) const; + private: CProfiles m_profiles; };