replace the DomainChangeListener class with a signal/slot combo

This commit is contained in:
Stephen Birarda 2014-01-14 11:38:05 -08:00
parent a8bbe41642
commit bdc31a3b48
4 changed files with 12 additions and 41 deletions

View file

@ -176,7 +176,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
nodeList->addHook(&_voxels);
nodeList->addHook(this);
nodeList->addDomainListener(this);
connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
// network receive thread and voxel parsing thread are both controlled by the --nonblocking command line
_enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking");
@ -265,7 +266,6 @@ Application::~Application() {
storeSizeAndPosition();
NodeList::getInstance()->removeHook(&_voxels);
NodeList::getInstance()->removeHook(this);
NodeList::getInstance()->removeDomainListener(this);
_sharedVoxelSystem.changeTree(new VoxelTree);
@ -4184,9 +4184,9 @@ void Application::updateWindowTitle(){
_window->setWindowTitle(title);
}
void Application::domainChanged(QString domain) {
void Application::domainChanged(const QString& domainHostname) {
// update the user's last domain in their Profile (which will propagate to data-server)
_profile.updateDomain(domain);
_profile.updateDomain(domainHostname);
updateWindowTitle();
@ -4199,7 +4199,7 @@ void Application::domainChanged(QString domain) {
_particleServerJurisdictions.clear();
// reset our persist thread
qDebug() << "domainChanged()... domain=" << domain << " swapping persist cache\n";
qDebug() << "domainChanged()... domain=" << domainHostname << " swapping persist cache\n";
updateLocalOctreeCache();
}

View file

@ -95,7 +95,7 @@ static const float NODE_KILLED_RED = 1.0f;
static const float NODE_KILLED_GREEN = 0.0f;
static const float NODE_KILLED_BLUE = 0.0f;
class Application : public QApplication, public NodeListHook, public PacketSenderNotify, public DomainChangeListener {
class Application : public QApplication, public NodeListHook, public PacketSenderNotify {
Q_OBJECT
friend class VoxelPacketProcessor;
@ -198,8 +198,6 @@ public:
virtual void nodeKilled(Node* node);
virtual void packetSentNotification(ssize_t length);
virtual void domainChanged(QString domain);
VoxelShader& getVoxelShader() { return _voxelShader; }
PointShader& getPointShader() { return _pointShader; }
FileLogger* getLogger() { return _logger; }
@ -214,6 +212,8 @@ public:
void setIsHighlightVoxel(bool isHighlightVoxel) { _isHighlightVoxel = isHighlightVoxel; }
public slots:
void domainChanged(const QString& domainHostname);
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
void exportVoxels();
void importVoxels();

View file

@ -103,7 +103,7 @@ void NodeList::setDomainHostname(const QString& domainHostname) {
// reset our _domainIP to the null address so that a lookup happens on next check in
_domainSockAddr.setAddress(QHostAddress::Null);
notifyDomainChanged();
emit domainChanged(_domainHostname);
}
}
@ -848,7 +848,7 @@ void NodeList::loadData(QSettings *settings) {
if (domainServerHostname.size() > 0) {
_domainHostname = domainServerHostname;
notifyDomainChanged();
emit domainChanged(_domainHostname);
}
settings->endGroup();
@ -942,21 +942,6 @@ void NodeListIterator::skipDeadAndStopIncrement() {
}
}
void NodeList::addDomainListener(DomainChangeListener* listener) {
_domainListeners.push_back(listener);
QString domain = _domainHostname.isEmpty() ? _domainSockAddr.getAddress().toString() : _domainHostname;
listener->domainChanged(domain);
}
void NodeList::removeDomainListener(DomainChangeListener* listener) {
for (int i = 0; i < _domainListeners.size(); i++) {
if (_domainListeners[i] == listener) {
_domainListeners.erase(_domainListeners.begin() + i);
return;
}
}
}
void NodeList::addHook(NodeListHook* hook) {
_hooks.push_back(hook);
}
@ -983,9 +968,3 @@ void NodeList::notifyHooksOfKilledNode(Node* node) {
_hooks[i]->nodeKilled(node);
}
}
void NodeList::notifyDomainChanged() {
for (int i = 0; i < _domainListeners.size(); i++) {
_domainListeners[i]->domainChanged(_domainHostname);
}
}

View file

@ -52,11 +52,6 @@ public:
virtual void nodeKilled(Node* node) = 0;
};
class DomainChangeListener {
public:
virtual void domainChanged(QString domain) = 0;
};
class NodeList : public QObject {
Q_OBJECT
public:
@ -134,14 +129,13 @@ public:
void notifyHooksOfAddedNode(Node* node);
void notifyHooksOfKilledNode(Node* node);
void addDomainListener(DomainChangeListener* listener);
void removeDomainListener(DomainChangeListener* listener);
const HifiSockAddr* getNodeActiveSocketOrPing(Node* node);
public slots:
void sendDomainServerCheckIn();
void pingInactiveNodes();
void removeSilentNodes();
signals:
void domainChanged(const QString& domainHostname);
private:
static NodeList* _sharedInstance;
@ -175,10 +169,8 @@ private:
void timePingReply(const HifiSockAddr& nodeAddress, unsigned char *packetData);
std::vector<NodeListHook*> _hooks;
std::vector<DomainChangeListener*> _domainListeners;
void resetDomainData(char domainField[], const char* domainData);
void notifyDomainChanged();
void domainLookup();
};