Frontend:
authorsmxx
Mon, 29 Mar 2010 18:50:22 +0000
changeset 3159 e5eff81d7635
parent 3158 9cd05b3353da
child 3160 f2a3d861b23a
Frontend: * Enabled deletion of teams * Buttons to modify teams (add/edit/delete) are now disabled if options menu is opened from within a game room / local game setup (might change once open issues are fixed) * No longer load/save ignore and friends lists in local game setup
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/pages.cpp
QTfrontend/team.cpp
QTfrontend/team.h
--- a/QTfrontend/hwform.cpp	Mon Mar 29 16:43:47 2010 +0000
+++ b/QTfrontend/hwform.cpp	Mon Mar 29 18:50:22 2010 +0000
@@ -137,6 +137,7 @@
     connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
     connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam()));
     connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam()));
+    connect(ui.pageOptions->BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(DeleteTeam()));
     connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions()));
     connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack()));
 
@@ -415,6 +416,9 @@
     if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) {
         QStringList tmNames = config->GetTeamsList();
         TeamSelWidget* curTeamSelWidget;
+        ui.pageOptions->BtnNewTeam->setEnabled(false);
+        ui.pageOptions->BtnEditTeam->setEnabled(false);
+        ui.pageOptions->BtnDeleteTeam->setEnabled(false);
 
         if(id == ID_PAGE_MULTIPLAYER) {
           curTeamSelWidget = ui.pageMultiplayer->teamsSelect;
@@ -445,12 +449,20 @@
         ui.pageGameStats->renderStats();
     }
 
+    if(id == ID_PAGE_MAIN)
+    {
+        ui.pageOptions->BtnNewTeam->setEnabled(true);
+        ui.pageOptions->BtnEditTeam->setEnabled(true);
+        ui.pageOptions->BtnDeleteTeam->setEnabled(true);
+    }
+
     // load and save ignore/friends lists
-    if(lastid == ID_PAGE_MULTIPLAYER || lastid == ID_PAGE_NETGAME) // leaving a room
+    if(lastid == ID_PAGE_NETGAME) // leaving a room
         ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text());
     else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby
         ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text());
-    if(id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) // joining a room
+
+    if(id == ID_PAGE_NETGAME) // joining a room
         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
     else if(id == ID_PAGE_ROOMSLIST) // joining the lobby
         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
@@ -547,6 +559,15 @@
     GoToPage(ID_PAGE_SETUP_TEAM);
 }
 
+void HWForm::DeleteTeam()
+{
+    editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText());
+    editedTeam->DeleteFile();
+
+    // Remove from lists
+    ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex());
+}
+
 void HWForm::RandomNames()
 {
     editedTeam->GetFromPage(this);
--- a/QTfrontend/hwform.h	Mon Mar 29 16:43:47 2010 +0000
+++ b/QTfrontend/hwform.h	Mon Mar 29 18:50:22 2010 +0000
@@ -82,6 +82,7 @@
     void IntermediateSetup();
     void NewTeam();
     void EditTeam();
+    void DeleteTeam();
     void RandomNames();
     void RandomName(const int &i);
     void TeamSave();
--- a/QTfrontend/pages.cpp	Mon Mar 29 16:43:47 2010 +0000
+++ b/QTfrontend/pages.cpp	Mon Mar 29 18:50:22 2010 +0000
@@ -418,8 +418,6 @@
             BtnDeleteTeam->setIconSize(pmDelete.size());
             BtnDeleteTeam->setIcon(pmDelete);
             BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6);
-            BtnDeleteTeam->setEnabled(false);
-            BtnDeleteTeam->setVisible(false); // hide for now
             GBTlayout->addWidget(BtnDeleteTeam, 0, 3);
 
             gbTBLayout->addWidget(teamsBox, 0, 0);
--- a/QTfrontend/team.cpp	Mon Mar 29 16:43:47 2010 +0000
+++ b/QTfrontend/team.cpp	Mon Mar 29 18:50:22 2010 +0000
@@ -180,6 +180,18 @@
     return true;
 }
 
+bool HWTeam::DeleteFile()
+{
+    if(m_isNetTeam)
+        return false;
+
+    QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
+    cfgfile.remove();
+
+        
+    return true;
+}
+
 bool HWTeam::SaveToFile()
 {
     if (OldTeamName != TeamName)
--- a/QTfrontend/team.h	Mon Mar 29 16:43:47 2010 +0000
+++ b/QTfrontend/team.h	Mon Mar 29 18:50:22 2010 +0000
@@ -55,6 +55,7 @@
         QColor teamColor;
 
         bool LoadFromFile();
+        bool DeleteFile();
         bool SaveToFile();
         void SetToPage(HWForm * hwform);
         void GetFromPage(HWForm * hwform);