PresentUnit::PresentUnit( QWidget * parent, const char * name ) : QWidget( parent, name ) { _icon = new Icon( this ); _label = new Label( this ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->addWidget( _icon ); layout->addWidget( _label, 1 ); layout->activate(); connect( _icon, SIGNAL( sig_clicked() ), SIGNAL( sig_clicked() ) ); connect( _label, SIGNAL( sig_clicked() ), SIGNAL( sig_clicked() ) ); }
void ClearLabel::mousePressEvent(QMouseEvent *ev) { if(ev->buttons() & Qt::LeftButton) { emit sig_clicked(); } QLabel::mousePressEvent(ev); }
DisplayBothUnits::DisplayBothUnits( QWidget * parent, const char * name ) :QWidget( parent, name ) { _currentSide = -1; _currentNum = -1; _exchange = false; _lordLeft = 0; _lordRight = 0; _socket = 0; QSignalMapper * sigmapLeft = new QSignalMapper( this ); QSignalMapper * sigmapRight = new QSignalMapper( this ); QVBoxLayout * layV1 = new QVBoxLayout(); QVBoxLayout * layV2 = new QVBoxLayout(); layV1->addStretch( 1 ); layV2->addStretch( 1 ); for( int i = 0; i < MAX_UNIT; i++ ) { _unitLeft[i] = new PresentUnit( this ); layV1->addWidget( _unitLeft[i] ); layV1->addStretch( 1 ); sigmapLeft->setMapping( _unitLeft[i], i ); connect( _unitLeft[i], SIGNAL( sig_clicked() ), sigmapLeft, SLOT( map() ) ); _unitRight[i] = new PresentUnit( this ); layV2->addWidget( _unitRight[i] ); layV2->addStretch( 1 ); sigmapRight->setMapping( _unitRight[i], i ); connect( _unitRight[i], SIGNAL( sig_clicked() ), sigmapRight, SLOT( map() ) ); } QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->addLayout( layV1, 1 ); layout->addLayout( layV2, 1 ); layout->activate(); connect( sigmapLeft, SIGNAL( mapped( int ) ), SLOT( slot_unitLeft( int ) ) ); connect( sigmapRight, SIGNAL( mapped( int ) ), SLOT( slot_unitRight( int ) ) ); }
DisplayRessources::DisplayRessources( int nb, QWidget * parent, const char * name ) : QWidget( parent, name ) { _nbRessources = nb; QVBoxLayout * layout = new QVBoxLayout( this ); _title = new Sentence( this ); layout->addWidget( _title ); layout->addStretch( 1 ); _ressources = new RessourceIcon * [ nb ]; QSignalMapper * sigmap = new QSignalMapper( this ); for( int i = 0; i < nb; i+=3 ) { if( nb-i == 1 ) { _ressources[i] = new RessourceIcon( this ); _ressources[i]->setRessource( i ); layout->addWidget( _ressources[i] ); sigmap->setMapping( _ressources[i], i ); connect( _ressources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); } else if( nb-i == 2 ) { QHBoxLayout * layH = new QHBoxLayout(); _ressources[i] = new RessourceIcon( this ); _ressources[i]->setRessource( i ); layH->addStretch( 1 ); layH->addWidget( _ressources[i] ); layH->addStretch( 1 ); sigmap->setMapping( _ressources[i], i ); connect( _ressources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _ressources[i+1] = new RessourceIcon( this ); _ressources[i+1]->setRessource( i+1 ); layH->addWidget( _ressources[i+1] ); layH->addStretch( 1 ); sigmap->setMapping( _ressources[i+1], i+1 ); connect( _ressources[i+1], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); layout->addLayout( layH ); } else { QHBoxLayout * layH = new QHBoxLayout(); _ressources[i] = new RessourceIcon( this ); _ressources[i]->setRessource( i ); layH->addWidget( _ressources[i] ); sigmap->setMapping( _ressources[i], i ); connect( _ressources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _ressources[i+1] = new RessourceIcon( this ); _ressources[i+1]->setRessource( i+1 ); layH->addWidget( _ressources[i+1] ); sigmap->setMapping( _ressources[i+1], i+1 ); connect( _ressources[i+1], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _ressources[i+2] = new RessourceIcon( this ); _ressources[i+2]->setRessource( i+2 ); layH->addWidget( _ressources[i+2] ); sigmap->setMapping( _ressources[i+2], i+2 ); connect( _ressources[i+2], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); layout->addLayout( layH ); } } layout->activate(); connect( sigmap, SIGNAL( mapped( int ) ), SIGNAL( sig_ressource( int ) ) ); }