remove index from ReleaseChannel

This commit is contained in:
RickyRister 2024-12-28 14:38:08 -08:00
parent c8d49b5bf9
commit f555f7e0d3
4 changed files with 6 additions and 12 deletions

View file

@ -21,11 +21,8 @@
#define GIT_SHORT_HASH_LEN 7 #define GIT_SHORT_HASH_LEN 7
int ReleaseChannel::sharedIndex = 0;
ReleaseChannel::ReleaseChannel() : netMan(new QNetworkAccessManager(this)), response(nullptr), lastRelease(nullptr) ReleaseChannel::ReleaseChannel() : netMan(new QNetworkAccessManager(this)), response(nullptr), lastRelease(nullptr)
{ {
index = sharedIndex++;
} }
ReleaseChannel::~ReleaseChannel() ReleaseChannel::~ReleaseChannel()

View file

@ -82,9 +82,6 @@ public:
~ReleaseChannel() override; ~ReleaseChannel() override;
protected: protected:
// shared by all instances
static int sharedIndex;
int index;
QNetworkAccessManager *netMan; QNetworkAccessManager *netMan;
QNetworkReply *response; QNetworkReply *response;
Release *lastRelease; Release *lastRelease;
@ -94,10 +91,6 @@ protected:
virtual QString getReleaseChannelUrl() const = 0; virtual QString getReleaseChannelUrl() const = 0;
public: public:
int getIndex() const
{
return index;
}
Release *getLastRelease() Release *getLastRelease()
{ {
return lastRelease; return lastRelease;

View file

@ -175,7 +175,7 @@ GeneralSettingsPage::GeneralSettingsPage()
// connect the ReleaseChannel combo box only after the entries are inserted in retranslateUi // connect the ReleaseChannel combo box only after the entries are inserted in retranslateUi
connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings, SLOT(setUpdateReleaseChannel(int))); connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings, SLOT(setUpdateReleaseChannel(int)));
updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannel()->getIndex()); updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannelIndex());
setLayout(mainLayout); setLayout(mainLayout);
} }
@ -309,7 +309,7 @@ void GeneralSettingsPage::retranslateUi()
int oldIndex = updateReleaseChannelBox.currentIndex(); int oldIndex = updateReleaseChannelBox.currentIndex();
updateReleaseChannelBox.clear(); updateReleaseChannelBox.clear();
for (ReleaseChannel *chan : settings.getUpdateReleaseChannels()) { for (ReleaseChannel *chan : settings.getUpdateReleaseChannels()) {
updateReleaseChannelBox.insertItem(chan->getIndex(), tr(chan->getName().toUtf8())); updateReleaseChannelBox.addItem(tr(chan->getName().toUtf8()));
} }
updateReleaseChannelBox.setCurrentIndex(oldIndex); updateReleaseChannelBox.setCurrentIndex(oldIndex);
} }

View file

@ -290,6 +290,10 @@ public:
{ {
return seenTips; return seenTips;
} }
int getUpdateReleaseChannelIndex() const
{
return updateReleaseChannel;
}
ReleaseChannel *getUpdateReleaseChannel() const ReleaseChannel *getUpdateReleaseChannel() const
{ {
return releaseChannels.at(qMax(0, updateReleaseChannel)); return releaseChannels.at(qMax(0, updateReleaseChannel));