QTfrontend/frameTeam.cpp
author displacer
Fri, 24 Feb 2006 16:06:12 +0000
changeset 63 27e2b5bb6d4b
child 80 3c3dc6a148ca
permissions -rw-r--r--
Scroll added to team control widget
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     1
#include "frameTeam.h"
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     2
#include "teamselhelper.h"
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     3
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     4
#include <QResizeEvent>
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     5
#include <QCoreApplication>
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     6
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     7
#include <iostream>
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     8
using namespace std;
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
     9
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    10
FrameTeams::FrameTeams(QWidget* parent) :
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    11
  QWidget(parent), mainLayout(this)
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    12
{
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    13
}
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    14
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    15
void FrameTeams::addTeam(tmprop team)
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    16
{
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    17
  TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, this);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    18
  int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    19
  teamToWidget.insert(make_pair(team, pTeamShowWidget));
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    20
  mainLayout.addWidget(pTeamShowWidget);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    21
  QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    22
  QCoreApplication::postEvent(parentWidget(), pevent);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    23
}
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    24
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    25
void FrameTeams::removeTeam(tmprop team)
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    26
{
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    27
  tmapTeamToWidget::iterator it=teamToWidget.find(team);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    28
  mainLayout.removeWidget(it->second);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    29
  delete it->second;
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    30
  teamToWidget.erase(team);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    31
}
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    32
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    33
QWidget* FrameTeams::getTeamWidget(tmprop team)
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    34
{
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    35
  tmapTeamToWidget::iterator it=teamToWidget.find(team);
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    36
  QWidget* ret = it!=teamToWidget.end() ? it->second : 0;
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    37
  if(!ret) throw; // FIXME: this is debug exception
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    38
  return ret;
27e2b5bb6d4b Scroll added to team control widget
displacer
parents:
diff changeset
    39
}