Skip to content

Commit 1d9cb0f

Browse files
committed
Bugs fixed
1 parent fb67c2a commit 1d9cb0f

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

downloaderui.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,24 @@ void DownloaderUI::initParser()
5353
connect(innerPage, SIGNAL(loadFinished(bool)), SLOT(parse(bool)));//connects with modules code and ID parsing
5454
connect(innerPage2, SIGNAL(loadFinished(bool)), SLOT(parse2(bool)));//connects with announcement parsing
5555
connect(innerPage3, SIGNAL(loadFinished(bool)), SLOT(parse3(bool)));//connects with exam details parsing
56-
removeTabs();//removes all the default tabs
56+
//removeTabs();//removes all the default tabs
5757
ModulesPageLoader();//Load announcement modules pages
5858
poll(); //Timer to poll every 1 hour
5959
}
6060

6161
//Preprocessing that clears default tabs
6262
void DownloaderUI::removeTabs()
6363
{
64-
//qDebug()<<ui->tabWidget_2->count();
65-
ui->tabWidget_2->setCurrentIndex(0);
66-
ui->tabWidget_2->removeTab(2);
67-
ui->tabWidget_2->removeTab(1);
64+
65+
// ui->tabWidget_2->setCurrentIndex(0);
66+
// ui->tabWidget_2->removeTab(2);
67+
// ui->tabWidget_2->removeTab(1);
68+
// ui->tabWidget_2->removeTab(0);
69+
for (int i = ui->tabWidget_2->count() - 1; i > ui->tabWidget_2->currentIndex(); --i) {
70+
ui->tabWidget_2->removeTab(i);
71+
}
6872
ui->tabWidget_2->removeTab(0);
69-
//qDebug()<<"Test here";
70-
//qDebug()<<ui->tabWidget_2->count();
73+
7174
}
7275

7376
//FILES UI
@@ -111,11 +114,12 @@ void DownloaderUI::poll()
111114
{
112115
QTimer *timer = new QTimer(this);
113116
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(ModulesPageLoader()));
114-
timer->start(3600000); //time specified in ms to poll modulesPageLoader every 1 hour first
117+
timer->start(3600000/2); //time specified in ms to poll modulesPageLoader every 1/2 hour first
115118
}
116119

117120
void DownloaderUI::ModulesPageLoader()
118121
{
122+
removeTabs();
119123
QString modules=QString("https://ivle.nus.edu.sg/api/Lapi.svc/Modules?APIKey=%1&AuthToken=%2&Duration=0&IncludeAllInfo=false").arg(APIKEY).arg(TOKEN);
120124
QUrl url2(modules);
121125
innerPage->setUrl(url2);

ivlefetcher.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ void IVLEFetcher::start(){
103103
return Promise::all(ps, this->session);
104104
})->then([=](const QVariant& data){
105105
emit statusUpdate(complete);
106-
timer->start(3600000);
106+
timer->start(3600000/2);//poll every half an hour
107107
qDebug()<<data;
108108
}, [=](const QVariant& error){
109109
if(error.toString() == "invalid token"){
110110
emit statusUpdate(invalidToken);
111111
} else {
112112
qDebug()<<"err"<<error;
113113
emit statusUpdate(networkError);
114-
timer->start(3600000);
114+
timer->start(3600000/2);//poll every half an hour
115115
}
116116
});
117117
}

0 commit comments

Comments
 (0)