# HG changeset patch # User displacer # Date 1140797172 0 # Node ID 27e2b5bb6d4bd90cb7c7c07ef21221b659b7e5d6 # Parent c3eda0c68cd65f2b241957bb255de5796b48d692 Scroll added to team control widget diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/frameTeam.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/frameTeam.cpp Fri Feb 24 16:06:12 2006 +0000 @@ -0,0 +1,39 @@ +#include "frameTeam.h" +#include "teamselhelper.h" + +#include +#include + +#include +using namespace std; + +FrameTeams::FrameTeams(QWidget* parent) : + QWidget(parent), mainLayout(this) +{ +} + +void FrameTeams::addTeam(tmprop team) +{ + TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, this); + int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height(); + teamToWidget.insert(make_pair(team, pTeamShowWidget)); + mainLayout.addWidget(pTeamShowWidget); + QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); + QCoreApplication::postEvent(parentWidget(), pevent); +} + +void FrameTeams::removeTeam(tmprop team) +{ + tmapTeamToWidget::iterator it=teamToWidget.find(team); + mainLayout.removeWidget(it->second); + delete it->second; + teamToWidget.erase(team); +} + +QWidget* FrameTeams::getTeamWidget(tmprop team) +{ + tmapTeamToWidget::iterator it=teamToWidget.find(team); + QWidget* ret = it!=teamToWidget.end() ? it->second : 0; + if(!ret) throw; // FIXME: this is debug exception + return ret; +} diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/frameTeam.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/frameTeam.h Fri Feb 24 16:06:12 2006 +0000 @@ -0,0 +1,27 @@ +#ifndef _FRAME_TEAM_INCLUDED +#define _FRAME_TEAM_INCLUDED + +#include + +#include "teamselect.h" +#include + +class FrameTeams : public QWidget +{ + Q_OBJECT + + public: + FrameTeams(QWidget* parent=0); + QWidget* getTeamWidget(tmprop team); + + public slots: + void addTeam(tmprop team); + void removeTeam(tmprop team); + + private: + QVBoxLayout mainLayout; + typedef map tmapTeamToWidget; + tmapTeamToWidget teamToWidget; +}; + +#endif // _FRAME_TAM_INCLUDED diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/hedgewars.pro --- a/QTfrontend/hedgewars.pro Sun Feb 05 18:51:54 2006 +0000 +++ b/QTfrontend/hedgewars.pro Fri Feb 24 16:06:12 2006 +0000 @@ -19,7 +19,9 @@ sha1.h \ netclient.h \ teamselect.h \ - teamselhelper.h + teamselhelper.h \ + frameTeam.h \ + vertScrollArea.h FORMS += hwform.ui @@ -31,8 +33,10 @@ sha1.cpp \ netclient.cpp \ teamselect.cpp \ - teamselhelper.cpp + teamselhelper.cpp \ + frameTeam.cpp \ + vertScrollArea.cpp TRANSLATIONS += translations/hedgewars_ru.ts -RESOURCES += hedgewars.qrc \ No newline at end of file +RESOURCES += hedgewars.qrc diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/teamselect.cpp --- a/QTfrontend/teamselect.cpp Sun Feb 05 18:51:54 2006 +0000 +++ b/QTfrontend/teamselect.cpp Fri Feb 24 16:06:12 2006 +0000 @@ -1,26 +1,26 @@ #include #include #include +#include #include +#include #include "teamselect.h" #include "teamselhelper.h" +#include "frameTeam.h" void TeamSelWidget::addTeam(tmprop team) { + frameDontPlaying->addTeam(team); curDontPlayingTeams.push_back(team); - TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team); - dontPlayingLayout->addWidget(pTeamShowWidget); - - teamToWidget.insert(make_pair(team, pTeamShowWidget)); - - QObject::connect(pTeamShowWidget, SIGNAL(teamStatusChanged(tmprop)), this, SLOT(changeTeamStatus(tmprop))); + QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(tmprop)), + this, SLOT(changeTeamStatus(tmprop))); } void TeamSelWidget::removeTeam(tmprop team) { - curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); + //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); } void TeamSelWidget::changeTeamStatus(tmprop team) @@ -38,38 +38,32 @@ curDontPlayingTeams.erase(itDontPlay); } - QGridLayout* pRemoveGrid; - QGridLayout* pAddGrid; - QWidget* newParent; + FrameTeams* pRemoveTeams; + FrameTeams* pAddTeams; if(itDontPlay==curDontPlayingTeams.end()) { - pRemoveGrid=playingLayout; - pAddGrid=dontPlayingLayout; - newParent=dontPlayingColorFrame; + pRemoveTeams=framePlaying; + pAddTeams=frameDontPlaying; } else { - pRemoveGrid=dontPlayingLayout; - pAddGrid=playingLayout; - newParent=playingColorFrame; + pRemoveTeams=frameDontPlaying; + pAddTeams=framePlaying; } - pRemoveGrid->removeWidget(teamToWidget[team]); - teamToWidget[team]->setParent(newParent); - pAddGrid->addWidget(teamToWidget[team]); + pAddTeams->addTeam(team); + pRemoveTeams->removeTeam(team); +} + +void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color) +{ + VertScrArea* area=new VertScrArea(color); + area->setWidget(pfteams); + mainLayout.addWidget(area, 50); } TeamSelWidget::TeamSelWidget(QWidget* parent) : QWidget(parent), mainLayout(this) { - playingColorFrame = new QFrame; - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Background, QColor("DarkTurquoise")); - playingColorFrame->setPalette(newPalette); - mainLayout.addWidget(playingColorFrame); - - dontPlayingColorFrame = new QFrame; - newPalette.setColor(QPalette::Background, QColor("LightGoldenrodYellow")); //BlanchedAlmond MistyRose honeydew PeachPuff LightCoral - dontPlayingColorFrame->setPalette(newPalette); - mainLayout.addWidget(dontPlayingColorFrame); - - playingLayout = new QGridLayout(playingColorFrame); - dontPlayingLayout = new QGridLayout(dontPlayingColorFrame); + framePlaying=new FrameTeams(); + frameDontPlaying=new FrameTeams(); + addScrArea(framePlaying, QColor("DarkTurquoise")); + addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow")); } diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/teamselect.h --- a/QTfrontend/teamselect.h Sun Feb 05 18:51:54 2006 +0000 +++ b/QTfrontend/teamselect.h Fri Feb 24 16:06:12 2006 +0000 @@ -3,16 +3,19 @@ #include #include -#include +class QFrame; #include #include +class TeamSelWidget; +class FrameTeams; + using namespace std; struct tmprop { - tmprop(QString nm) : teamName(nm){}; + tmprop(QString nm) : teamName(nm) {}; QString teamName; QString pixmapFileName; bool operator==(const tmprop& t1) const { @@ -36,16 +39,14 @@ void changeTeamStatus(tmprop team); private: - QVBoxLayout mainLayout; + void addScrArea(FrameTeams* pfteams, QColor color); + FrameTeams* frameDontPlaying; + FrameTeams* framePlaying; - QFrame* playingColorFrame; - QFrame* dontPlayingColorFrame; - QGridLayout* playingLayout; - QGridLayout* dontPlayingLayout; + QVBoxLayout mainLayout; list curPlayingTeams; list curDontPlayingTeams; - map teamToWidget; }; #endif // _TEAM_SELECT_INCLUDED diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/teamselhelper.cpp --- a/QTfrontend/teamselhelper.cpp Sun Feb 05 18:51:54 2006 +0000 +++ b/QTfrontend/teamselhelper.cpp Fri Feb 24 16:06:12 2006 +0000 @@ -3,6 +3,8 @@ #include #include +#include + void TeamLabel::teamButtonClicked() { emit teamActivated(text()); @@ -14,7 +16,7 @@ QLabel* pixlbl=new QLabel(); pixlbl->setPixmap(QPixmap("./Data/Graphics/thinking.png")); mainLayout.addWidget(pixlbl); - + TeamLabel* lbl=new TeamLabel(team.teamName); mainLayout.addWidget(lbl); diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/vertScrollArea.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/vertScrollArea.cpp Fri Feb 24 16:06:12 2006 +0000 @@ -0,0 +1,16 @@ +#include "vertScrollArea.h" + +#include + +VertScrArea::VertScrArea(QColor frameColor, QWidget * parent) : + QScrollArea(parent) +{ + QPalette newPalette = palette(); + newPalette.setColor(QPalette::Background, frameColor); + setPalette(newPalette); +} + +void VertScrArea::resizeEvent(QResizeEvent * event) +{ + widget()->resize(event->size().width(), widget()->sizeHint().height()); +} diff -r c3eda0c68cd6 -r 27e2b5bb6d4b QTfrontend/vertScrollArea.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/vertScrollArea.h Fri Feb 24 16:06:12 2006 +0000 @@ -0,0 +1,17 @@ +#ifndef _VERT_SCROLL_AREA_INCLUDED +#define _VERT_SCROLL_AREA_INCLUDED + +#include + +class VertScrArea : public QScrollArea +{ + Q_OBJECT + + public: + VertScrArea(QColor frameColor, QWidget * parent = 0); + + protected: + virtual void resizeEvent(QResizeEvent * event); +}; + +#endif // _VERT_SCROLL_AREA_INCLUDED