int uctSort(NimGameState rootState, int maximumIterations, bool useRanks) { int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); // Get the number of processes int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); MctsNode root(0, NULL, &rootState); for(int i=0; i<maximumIterations; i++) { MctsNode* node = &root; NimGameState state = rootState.clone(); // std::cout<< "Copy Repr " << node->representation() << std::endl; while(node->actionsNotTaken.empty() && !node->childNodes.empty()) { // std::cout<< "Entering Selection Step" << std::endl; node = node->selectNextChildNode(); state.performAction(node->previousAction); } if(!node->actionsNotTaken.empty()) { // std::cout<< "Entering Expansion Step" << std::endl; std::random_shuffle(node->actionsNotTaken.begin(), node->actionsNotTaken.end()); int action = node->actionsNotTaken.back(); // std::cout<< "Action: " << action << std::endl; state.performAction(action); // std::cout<< state.representation() << std::endl; node = node->addChildNode(action, &state); // std::cout<< node->representation() << std::endl; } while(!state.getAvailableActions().empty()) { // std::cout<< "Entering Simulation Step" << std::endl; std::random_shuffle(node->actionsNotTaken.begin(), node->actionsNotTaken.end()); int action = node->actionsNotTaken.back(); state.performAction(action); } while(node->parentNode != NULL) { // std::cout<< "Entering Backpropagation Step" << std::endl; node->update(state.getValue(node->lastActivePlayer)); node = node->parentNode; } } if(useRanks && world_size > 1) { // Root synchronization std::string serialized = MctsNodeSerializer::Serialize(root); serialized += "#"; if (world_rank == 0) { //std::cout << "Sending:" << serialized.length() << "/" << DEFAULT_MESSAGE_SIZE << std::endl; //std::cout << "Rank 0, root looks before merge: " << serialized << std::endl; } if (serialized.length() > DEFAULT_MESSAGE_SIZE) { std::cout << "Error:" << serialized.length() << "/" << DEFAULT_MESSAGE_SIZE << std::endl; std::cout << "Seralized tree is too big!" << std::endl; return -1; } if (serialized.length() < DEFAULT_MESSAGE_SIZE) { serialized.resize(DEFAULT_MESSAGE_SIZE, '@'); } char *rcv_buffer = new char[DEFAULT_MESSAGE_SIZE * world_size]; MPI_Allgather((void*)serialized.c_str(), DEFAULT_MESSAGE_SIZE, MPI::CHAR, rcv_buffer, DEFAULT_MESSAGE_SIZE, MPI::CHAR, MPI_COMM_WORLD); std::string received(rcv_buffer, (unsigned long) (DEFAULT_MESSAGE_SIZE * world_size)); delete rcv_buffer; //long ct = std::count(received.begin(), received.end(), '@'); received.erase(std::remove(received.begin(), received.end(), '@'), received.end()); std::stringstream receivedDataStream(received); //std::cout << "All data: " << received << std::endl; std::string serializedTree; while (std::getline(receivedDataStream, serializedTree, '#')) { serializedTree = serializedTree.substr(0, serializedTree.length() - 1); if (world_rank == 0) { //std::cout << "Rank 0, deserialized new tree before unboxing: " << serializedTree << std::endl; //std::cout << serialized.length() << std::endl; //std::cout << "There was " << ct << "/" << DEFAULT_MESSAGE_SIZE*world_size << "empty chars in data for iteration " << i << std::endl; //std::cout << "Attempting to deserialize data: '" << serializedTree << "'" << std::endl; //std::cout << "Attempting to deserialize data.. '" << std::endl; MctsNode remoteTree = MctsNodeDeserializer::Deserialize(serializedTree); //std::cout << "Rank 0, root before merge: " << MctsNodeSerializer::Serialize(root) << std::endl; //std::cout << "Rank 0, newTree before merge: " << MctsNodeSerializer::Serialize(root) << std::endl; //std::cout << "Data deserialized" << std::endl; //std::cout << "Attempting to merge" << std::endl; MctsTreeMerger::MergeTrees(&root, &remoteTree); std::cout << "Rank 0, after merge: " << MctsNodeSerializer::Serialize(root) << std::endl; //std::cout << "Merge is done" << std::endl; } else { MctsNode remoteTree = MctsNodeDeserializer::Deserialize(serializedTree); MctsTreeMerger::MergeTrees(&root, &remoteTree); } } } std::sort(root.childNodes.begin(), root.childNodes.end(), compareNodesByVisists); MctsNode lastItem = root.childNodes.back(); // if(world_rank == 0) // { // //std::cout << MctsNodeSerializer::Serialize(root) << std::endl; // for(std::vector<MctsNode>::iterator it = root.childNodes.begin(); it != root.childNodes.end(); ++it) // { // std::cout << it->representation() << std::endl; // } // } // std::cout<< "RootState @exit: "<< rootState.representation() << std::endl; return lastItem.previousAction; }
void qmidinetJackMidiDevice::recvData ( unsigned char *data, unsigned short len, int port ) { emit received(QByteArray((const char *) data, len), port); }
CanReceiverFilter::CanReceiverFilter(ICanReceiver *source, QObject *parent) : QObject (parent), receivers () { connect(source, SIGNAL(received(CanFrame)), this, SLOT(processMessage(CanFrame))); }
void KJavaAppletContext::processCmd( QString cmd, QStringList args ) { received( cmd, args ); }
LightSettings::LightSettings( QWidget* parent, Qt::WFlags fl ) : QDialog( parent, fl), isStatusView( false ) { setWindowTitle(tr("Power Management")); QVBoxLayout * baseLayout = new QVBoxLayout( this ); baseLayout->setMargin( 0 ); QWidget * container = new QWidget(); QScrollArea *sView = new QScrollArea; sView->setFocusPolicy(Qt::NoFocus); sView->setFrameStyle(QFrame::NoFrame); sView->setWidget( container ); sView->setWidgetResizable( true ); sView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QVBoxLayout *lightLayout = new QVBoxLayout(container); lightLayout->setMargin( 0 ); b = new LightSettingsContainer(); QtopiaApplication::setInputMethodHint( b->interval_dim, QtopiaApplication::AlwaysOff ); QtopiaApplication::setInputMethodHint( b->interval_lightoff, QtopiaApplication::AlwaysOff ); QtopiaApplication::setInputMethodHint( b->interval_suspend, QtopiaApplication::AlwaysOff ); lightLayout->addWidget(b); baseLayout->addWidget(sView); // add context menu to push its status to Profiles contextMenu = QSoftMenuBar::menuFor( this ); QAction* actionCapture = new QAction( QIcon( ":icon/Note" ), tr( "Add to current profile" ), this ); contextMenu->addAction( actionCapture ); connect( actionCapture, SIGNAL(triggered()), this, SLOT(pushSettingStatus()) ); connect( qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(receive(QString,QByteArray)) ); connect( b->interval_dim, SIGNAL(valueChanged(int)), this, SLOT(updateLightOffMinValue(int)) ); connect( b->interval_dim, SIGNAL(valueChanged(int)), this, SLOT(updateSuspendMinValue(int)) ); connect( b->interval_lightoff, SIGNAL(valueChanged(int)), this, SLOT(updateSuspendMinValue(int)) ); b->officon->setPixmap(QPixmap(":image/off").scaled(24, 24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); b->brighticon->setPixmap(QPixmap(":image/Light").scaled(24, 24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); QSettings hwConfig("Trolltech", "Hardware"); hwConfig.beginGroup("PowerManagement"); lockMode.canSuspend = hwConfig.value("CanSuspendLock", false).toBool(); batteryMode.canSuspend = hwConfig.value("CanSuspend", false).toBool(); externalMode.canSuspend = hwConfig.value("CanSuspendAC", false).toBool(); hwConfig.endGroup(); b->notnetworkedsuspend->hide(); if (batteryMode.canSuspend || externalMode.canSuspend || lockMode.canSuspend) { b->interval_suspend->setEnabled(true); } else { b->interval_suspend->hide(); b->label_suspend->hide(); } QSettings config("Trolltech","qpe"); config.beginGroup("LockPower"); lockMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt(); lockMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt(); lockMode.intervalSuspend = config.value("Interval", 60).toInt(); lockMode.brightness = config.value("Brightness", 255).toInt(); lockMode.brightness = qMax(1,lockMode.brightness * qpe_sysBrightnessSteps() / 255); lockMode.initBrightness = lockMode.brightness; lockMode.dim = config.value("Dim", true).toBool(); lockMode.lightoff = config.value("LightOff", false).toBool(); lockMode.suspend = config.value("Suspend", true).toBool(); lockMode.networkedsuspend = config.value("NetworkedSuspend", true).toBool(); config.endGroup(); config.beginGroup("BatteryPower"); batteryMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt(); batteryMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt(); batteryMode.intervalSuspend = config.value("Interval", 60).toInt(); batteryMode.brightness = config.value("Brightness", 255).toInt(); batteryMode.brightness = qMax(1,batteryMode.brightness * qpe_sysBrightnessSteps() / 255); batteryMode.initBrightness = batteryMode.brightness; batteryMode.dim = config.value("Dim", true).toBool(); batteryMode.lightoff = config.value("LightOff", false).toBool(); batteryMode.suspend = config.value("Suspend", true).toBool(); batteryMode.networkedsuspend = config.value("NetworkedSuspend", true).toBool(); config.endGroup(); config.beginGroup("ExternalPower"); externalMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt(); externalMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt(); externalMode.intervalSuspend = config.value("Interval", 240).toInt(); externalMode.brightness = config.value("Brightness", 255).toInt(); externalMode.brightness = qMax(1,externalMode.brightness * qpe_sysBrightnessSteps() / 255); externalMode.initBrightness = externalMode.brightness; externalMode.dim = config.value("Dim", true).toBool(); externalMode.lightoff = config.value("LightOff", false).toBool(); //default to leave on externalMode.suspend = config.value("Suspend", true).toBool(); externalMode.networkedsuspend = config.value("NetworkedSuspend",false).toBool(); config.endGroup(); //must set min > 0 the screen will become completely black int maxbright = qpe_sysBrightnessSteps(); b->brightness->setMaximum( maxbright ); b->brightness->setMinimum( 1 ); b->brightness->setTickInterval( qMax(1,maxbright/16) ); b->brightness->setSingleStep( qMax(1,maxbright/16) ); b->brightness->setPageStep( qMax(1,maxbright/16) ); currentMode = &lockMode; applyMode(); connect(b->powerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(powerTypeChanged(int))); if ( powerStatus.wallStatus() == QPowerStatus::Available ) { b->powerSource->setCurrentIndex(1); } connect(b->brightness, SIGNAL(valueChanged(int)), this, SLOT(applyBrightness())); QtopiaChannel *channel = new QtopiaChannel("Qtopia/PowerStatus", this); connect(channel, SIGNAL(received(QString,QByteArray)), this, SLOT(sysMessage(QString,QByteArray))); }
/*! \fn void QCopChannel::receive(const QString& message, const QByteArray &data) Processes the incoming \a message and \a data. This function is called by the server when this object's channel receives new messages. Note that the default implementation simply emits the received() signal; reimplement this function to process the incoming \a message and \a data. Note that the format of the given \a data has to be well defined in order to extract the information it contains. In addition, it is recommended to use the DCOP convention. This is not a requirement, but you must ensure that the sender and receiver agree on the argument types. For example: \snippet doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp 0 The above code assumes that the \c message is a DCOP-style function signature and the \c data contains the function's arguments. \sa send(), channel(), received() */ void QCopChannel::receive(const QString& msg, const QByteArray &data) { emit received(msg, data); }
void StompInterpreter::receive(unsigned int _id, const char* _data, int _size) { Stomp::Frame received(_data, _size); switch(received.getCommand()) { case Stomp::CONNECT: { std::string session; std::string username = received.getHeaderValueFor("login"); std::string password = received.getHeaderValueFor("passcode"); if(m_login.login(username, password, session)) { StompSubscriberIterator it = ns_subscribers->find(_id); if(it != ns_subscribers->end()) { // from http://stomp.github.com//stomp-specification-1.1.html#Connecting it->second.session = session; it->second.username = username; std::stringstream ssid; ssid << _id; Stomp::Frame send; send.setCommand(Stomp::CONNECTED); send.addOrReplaceHeader(Stomp::Header("session", ssid.str())); m_websocket.send(_id, send.getFrameData()); } else { ns_error(_id, "CONNECT", "unknown internal user id"); } } else { ns_error(_id, "CONNECT", "LoginHandler error"); } break; } case Stomp::DISCONNECT: { StompSubscriberIterator it = ns_subscribers->find(_id); disconnect(_id); m_websocket.disconnect(_id); break; } case Stomp::SUBSCRIBE: { // from http://stomp.github.com//stomp-specification-1.1.html#SUBSCRIBE std::string subscribe_id = received.getHeaderValueFor("id"); std::string destination = received.getHeaderValueFor("destination"); StompSubscriberIterator it = ns_subscribers->find(_id); if(it != ns_subscribers->end()) { it->second.subscription = subscribe_id; it->second.destination = destination; if(m_chat.join(_id, it->second.username, destination)) { ns_receipt(_id, subscribe_id); } else { ns_error(_id, "SUBSCRIBE", "ChatHall error"); } } else { ns_error(_id, "SUBSCRIBE", "unknown internal user id"); disconnect(_id); m_websocket.disconnect(_id); } break; } case Stomp::SEND: { //from http://stomp.github.com//stomp-specification-1.1.html#SEND std::string destination = received.getHeaderValueFor("destination"); std::string message = received.getBody().str(); StompSubscriberIterator it = ns_subscribers->find(_id); if(it != ns_subscribers->end()) { if(m_chat.message(_id, destination, message)) { ns_receipt(_id, destination); } else { ns_error(_id, "SEND", "ChatHall error"); disconnect(_id); m_websocket.disconnect(_id); } } else { ns_error(_id, "SEND", "unknown internal user id"); disconnect(_id); m_websocket.disconnect(_id); } break; } default: { break; } } }
float ICMPEventArgs::percent() const { if (0 == _rtt.size()) return 0; return ((float) received() / (float) _rtt.size()) * (float) 100.0; }
void TagMessageSocket::vlenMessageCB( VarLengthMessage data ) { emit received( TagMessage::fromVarLengthMessage( data ) ); }
QPluginManager *manager = new QPluginManager( "qdsync", this ); foreach ( const QString &name, manager->list() ) { if ( name == "base" ) continue; QObject *object = manager->instance( name ); if ( Qtopia4SyncPlugin *plugin = qobject_cast<Qtopia4SyncPlugin*>(object) ) { sync->registerPlugin( plugin ); } else if ( Qtopia4SyncPluginFactory *pf = qobject_cast<Qtopia4SyncPluginFactory*>(object) ) { foreach ( const QString &name, pf->keys() ) { Qtopia4SyncPlugin *plugin = pf->plugin( name ); sync->registerPlugin( plugin ); } } } QCopChannel *chan = new QCopChannel( "QPE/QDSync", this ); connect( chan, SIGNAL(received(QString,QByteArray)), this, SLOT(qdMessage(QString,QByteArray)) ); } QDSync::~QDSync() { TRACE(QDSync) << "QDSync::~QDSync"; } void QDSync::appMessage( const QString &message, const QByteArray &data ) { TRACE(QDSync) << "QDSync::appMessage" << message; if ( message == "startup()" ) { QtopiaApplication::instance()->registerRunningTask("qdsync", this); startDaemons(); } else if ( message == "shutdown()" ) { stopDaemons();
void SkypeConnection::Notify(const QString &message){ kDebug(SKYPE_DEBUG_GLOBAL) << "Got message:" << message;//show what we have got emit received(message); }
int main(int argc, char *argv[]) { int socket_fd = 0; int port = 0; int argv_port_index = 0; int argv_host_index = 0; int read_bytes = 0; int write_bytes = 0; struct sockaddr_in serv_addr; struct hostent *server; char *server_name; char incoming[BUFFER_SIZE]; char outgoing[BUFFER_SIZE]; //Check args if (argc < 2) error("usage: ./client [hostname] port", ERR_USAGE); if (argc == 3) { argv_host_index = 1; argv_port_index = 2; server_name = argv[argv_host_index]; server = gethostbyname (server_name); if (server == NULL) error ("ERROR no such host", ERR_HOST); } if (argc == 2) { message ("\"localhost\" is assumed as host."); server = gethostbyname ("localhost"); argv_port_index = 1; } port = atoi (argv[argv_port_index]);//Ascii TO Int socket_fd = socket (IPV4, TCP, PROTOCOL);//creates an endpoint for communication and returns a file descriptor. if (socket_fd < 0) error ("ERROR opening socket", ERR_SOCKET); message ("Socket opened."); bzero ((char *) &serv_addr, sizeof(serv_addr));//Clear the struct sockaddr_in serv_addr serv_addr.sin_family = IPV4; bcopy ((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length); serv_addr.sin_port = htons(port); if (connect(socket_fd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) error ("ERROR connecting", ERR_CONNECTION); fprintf (stdout, "%sConnected with %s:%d %s\n", ANSI_GREEN, server->h_name, port, ANSI_RESET); //Start the loop of receiving/sending: do { bzero (incoming,BUFFER_SIZE); message ("Wait for a message"); read_bytes = read (socket_fd, incoming, BUFFER_SIZE-1); if (read_bytes < 0) error ("ERROR reading from socket", ERR_READING); received (incoming); bzero (outgoing, BUFFER_SIZE); message ("Write a message"); fgets (outgoing, BUFFER_SIZE-1, stdin); write_bytes = write(socket_fd,outgoing,strlen(outgoing)); if (write_bytes < 0) error ("ERROR writing to socket", ERR_WRITING); } while(!(outgoing[0] == 'e' && outgoing[1] == 'x' && outgoing[2] == 'i' && outgoing[3] == 't')); shutdown (socket_fd, SHUT_RDWR); close (socket_fd); return 0; }
void NutellaSearch::run() { std::string title, recv_title; std::string host, port; struct itimerval timer; char buffer[BUFSIZE]; int bytes_recv; // set up timer values to reset timer timer.it_value.tv_sec = 1; // trigger after 1 second timer.it_value.tv_usec = 0; timer.it_interval.tv_sec = 0; // don't reset the timer after expiration timer.it_interval.tv_usec = 0; while (1) { // prompt the user for input std::cout << "Enter movie title, or 'quit' to exit: " << std::flush; std::cin.clear(); std::getline(std::cin, title); if (title.size() <= 0) { std::cout << "Title invalid" << std::endl; continue; } else if (title.compare("quit") == 0) { // send SIGINT to all NutellaServer processes killpg(0, SIGINT); break; } // add .txt title += ".txt"; // multicast the title if (msend(this->q_msock, title.c_str(), title.size()) == -1) { perror("msend()"); continue; } int received_response = 0; // set up timeout timer setitimer(ITIMER_REAL, &timer, NULL); // wait for a reply or timeout do { if ((bytes_recv = mrecv(this->r_msock, buffer, BUFSIZE, WNOHANG)) > 0) { // parse the received value to ensure it is a response to // this query std::stringstream received(std::string(buffer, bytes_recv)); std::getline(received, recv_title); if (title.compare(recv_title) != 0) { // title didn't match continue; } std::getline(received, host); std::getline(received, port); if (this->vflag) { std::cout << "Received response:" << std::endl; std::cout << "\tTitle: " << recv_title << std::endl; std::cout << "\tHost: " << host << std::endl; std::cout << "\tPort: " << port << std::endl; } received_response = 1; break; } } while (NutellaSearch::check_mcast); if (vflag) std::cout << "NutellaSearch: Creating NutellaPlayer" << std::endl; if (received_response) { // create the Nutella Player NutellaPlayer *np = new NutellaPlayer(recv_title, host, atoi(port.c_str()), this->fps, this->fps_flag, this->tflag, this->vflag); np->run(); } } }
ControlWidget::ControlWidget( Database *database, PartymanConfigDialog *config, PartymanMainWindow *parent ) : QWidget( parent ) , mpConfig( config ) , mpPlaylist( parent ) , mpSatellite( Satellite::get() ) , mpGenericSatelliteHandler( 0 ) , mPartymanIcon( QIcon( ":/Partyman/Icon.png" ) ) , mStopIcon( QCommonStyle().standardIcon(QStyle::SP_MediaStop) /*QIcon(":/Stop.png")*/ ) , mPlayIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPlay) /*QIcon(":/Play.png")*/ ) , mPauseIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPause) /*QIcon(":/Pause.png")*/ ) , mSkipIcon( QCommonStyle().standardIcon(QStyle::SP_MediaSkipForward) /*QIcon(":/Skip.png")*/ ) , mLoadIcon( QIcon( ":/Partyman/Load.png" ) ) , mpSettingsButton( new QPushButton( tr("Settings"), this ) ) , mpStartButton( new QToolButton( /*tr("Connect"),*/ this ) ) , mpSkipButton( new QToolButton( /*mSkipIcon, tr("Next"),*/ this ) ) , mpTrayIcon( new QSystemTrayIcon( this ) ) , mpTrayIconStopMenu( new QMenu( this ) ) , mpTrayIconPlayMenu( new QMenu( this ) ) , mpStartButtonMenu( new QMenu( mpStartButton ) ) , mpPlayAction( mpTrayIconStopMenu->addAction( mPlayIcon, tr("Start" ) ) ) , mpSkipAction( mpTrayIconPlayMenu->addAction( mSkipIcon, tr("Next" ) ) ) , mpPauseAction( mpStartButtonMenu->addAction( mPauseIcon, tr("Pause" ) ) ) , mpStopAction( mpStartButtonMenu->addAction( mStopIcon, tr("Disconnect" ) ) ) , mpLoadAction( mpStartButtonMenu->addAction( mLoadIcon, tr("Load" ) ) ) , mpTrayIconClickTimer( new QTimer( this ) ) , mConnected( false ) , mPaused( false ) , mKioskMode( false ) , mpDerMixDprocess( new QProcess( this ) ) , mpLoggerProcess( new QProcess( this ) ) , mWaitForDerMixD( false ) , mDerMixDstarted( false ) , mLastP0p() { CrashCleanup::addObject( mpDerMixDprocess ); setAcceptDrops( true ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); mpSettingsButton->setObjectName( QString("SettingsButton") ); mpPlayer[0] = new PlayerWidget( 0, database, this ); mpPlayer[1] = new PlayerWidget( 1, database, this ); mpTrayIconClickTimer->setSingleShot( true ); QGridLayout *mainLayout = new QGridLayout( this ); mainLayout->setContentsMargins( 3, 3, 3 ,3 ); mainLayout->setSpacing( 5 ); mainLayout->addWidget( mpPlayer[0], 1, 0, 4, 1 ); mainLayout->addWidget( mpPlayer[1], 1, 2, 4, 1 ); mainLayout->addWidget( mpSettingsButton, 1, 1 ); mainLayout->addWidget( mpStartButton, 3, 1 ); mainLayout->addWidget( mpSkipButton, 4, 1 ); mainLayout->setColumnStretch( 0, 1 ); mainLayout->setColumnStretch( 2, 1 ); mainLayout->setRowStretch( 0, 1 ); mainLayout->setRowStretch( 5, 1 ); setLayout( mainLayout ); mpStartButton->setDefaultAction( mpPlayAction ); mpStartButton->setPopupMode( QToolButton::InstantPopup ); mpStartButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); mpStartButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); mpPlayAction->setCheckable( true ); mpPlayAction->setDisabled( true ); mpSkipButton->setDefaultAction( mpSkipAction ); mpSkipButton->setPopupMode( QToolButton::InstantPopup ); mpSkipButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); mpSkipButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); mpSkipAction->setCheckable( true ); mpSkipAction->setDisabled( true ); mpTrayIcon->setIcon( QIcon(":/Partyman/Icon.png") ); mpTrayIcon->setContextMenu( mpTrayIconStopMenu ); mpTrayIconPlayMenu->addAction( mpPauseAction ); mpTrayIconPlayMenu->addAction( mpStopAction ); connect( mpSettingsButton, SIGNAL(clicked()), mpConfig, SLOT(exec()) ); connect( mpStartButton, SIGNAL(clicked()), this, SLOT(initConnect()) ); connect( mpPlayAction, SIGNAL(triggered()), this, SLOT(initConnect()) ); connect( mpPauseAction, SIGNAL(triggered()), this, SLOT(handlePause()) ); connect( mpStopAction, SIGNAL(triggered()), this, SLOT(initDisconnect()) ); connect( mpLoadAction, SIGNAL(triggered()), this, SLOT(handleLoad()) ); connect( mpSkipAction, SIGNAL(triggered()), this, SLOT(handleSkipTrack()) ); connect( mpConfig, SIGNAL(configChanged()), this, SLOT(readConfig()) ); connect( mpPlayer[0], SIGNAL(trackPlaying(TrackInfo)), this, SLOT(handleTrackPlaying(TrackInfo)) ); connect( mpPlayer[1], SIGNAL(trackPlaying(TrackInfo)), this, SLOT(handleTrackPlaying(TrackInfo)) ); connect( mpTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleTrayIcon(QSystemTrayIcon::ActivationReason)) ); connect( mpTrayIconClickTimer, SIGNAL(timeout()), this, SLOT(handlePause()) ); connect( mpDerMixDprocess, SIGNAL(readyReadStandardError()), this, SLOT(handleDerMixDstartup()) ); connect( mpDerMixDprocess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(handleDerMixDfinish(int,QProcess::ExitStatus)) ); connect( mpDerMixDprocess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleDerMixDerror(QProcess::ProcessError)) ); if( mpSatellite ) { mpGenericSatelliteHandler = new GenericSatelliteHandler( mpSatellite, GenericSatelliteHandler::WithPingAndDialog, this ); connect( mpGenericSatelliteHandler, SIGNAL(updateConfig()), mpConfig, SLOT(readSettings()) ); connect( mpGenericSatelliteHandler, SIGNAL(anotherInstance()), this, SLOT(initDisconnect()) ); connect( mpSatellite, SIGNAL(received(QByteArray)), this, SLOT(handleSatellite(QByteArray)) ); } }
void CanServer::readData() { emit received(mClientConnection->readAll()); }
void received_(std::queue<Event> events) { while (!events.empty()) { received(events.front()); events.pop(); } }