void ChatWindow::updateConnection(ConnectionObject *connection) { if( connection == m_chatConnection ){ return; } disconnect( this, SLOT(connectionChanged()) ); disconnect( this, SLOT(connectionDestroyed()) ); m_chatConnection = connection; connect( m_chatConnection, SIGNAL(sigChange(ConnectionObject*)), this, SLOT(connectionChanged()) ); connect( m_chatConnection, SIGNAL(destroyed()), this, SLOT(connectionDestroyed()) ); connectionChanged(); }
void SerialPortEnumerator::refresh() { std::set<SerialPort *> portsToDisown = m_ownedPorts; QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); for (int i = 0; i < ports.size(); ++i) { QextPortInfo info = ports[i]; QHash<QString, SerialPort *>::const_iterator it = m_portMap.find(ports[i].physName); if (it == m_portMap.end()) { ConnectionPointer<SerialPort> portGuard(new SerialPort()); portGuard->setName(info.portName, /*isDefault=*/true); portGuard->setDeviceName(info.physName); portGuard->setFriendlyName(info.friendName); portGuard->setBaudRate(38400); portGuard->setDevNameEditable(false); QHash<QString, QVariant>::iterator cfgIt = m_connCfg.find(info.physName); if(cfgIt != m_connCfg.end() && (*cfgIt).type() == QVariant::Hash) portGuard->applyConfig((*cfgIt).toHash()); connect(portGuard.data(), SIGNAL(destroyed()), this, SLOT(connectionDestroyed())); m_portMap[info.physName] = portGuard.data(); sConMgr2.addConnection(portGuard.data()); m_ownedPorts.insert(portGuard.data()); portGuard->setRemovable(false); portGuard.take(); } else { SerialPort * port = it.value(); if (m_ownedPorts.find(port) == m_ownedPorts.end()) { m_ownedPorts.insert(port); port->setRemovable(false); port->addRef(); } else { portsToDisown.erase(port); } } } for (std::set<SerialPort *>::const_iterator it = portsToDisown.begin(); it != portsToDisown.end(); ++it) { SerialPort * port = *it; m_ownedPorts.erase(port); port->setRemovable(true); port->release(); } }
ChatWindow::ChatWindow( QString myName, ConnectionObject* connection, QWidget* parent) : QWidget(parent), m_myName(myName), m_chatConnection(connection) { if( m_chatConnection->getName() == "" ){ m_conName = QString(m_chatConnection->getIp() + ":" + QString::number(m_chatConnection->getClientPort()) ); } else { m_conName = m_chatConnection->getName(); } setWindowTitle(QString("Chat: %1 - KLan").arg(m_conName)); setupGui(); m_tableFormat = new QTextTableFormat(); m_tableFormat->setBorder(0); connect( m_sendBtn, SIGNAL(clicked()), this, SLOT(sendMessage()) ); connect( m_messageEdit, SIGNAL(returnPressed()), m_sendBtn, SLOT(click()) ); connect( m_chatConnection, SIGNAL(sigChange(ConnectionObject*)), this, SLOT(connectionChanged()) ); connect( m_chatConnection, SIGNAL(destroyed()), this, SLOT(connectionDestroyed()) ); }
void ConnectionManager2::addConnection(Connection * conn) { connect(conn, SIGNAL(destroying()), this, SLOT(connectionDestroyed())); m_conns.append(conn); emit connAdded(conn); }
DefaultConnection::~DefaultConnection() { disconnectFromHost(); emit connectionDestroyed(); }