forked from jbagg/QtZeroConf
modified sample for shareddata
This commit is contained in:
@@ -52,10 +52,10 @@ mainWindow::mainWindow()
|
|||||||
publishEnabled = 0;
|
publishEnabled = 0;
|
||||||
buildGUI();
|
buildGUI();
|
||||||
|
|
||||||
connect(&zeroConf, SIGNAL(serviceAdded(QZeroConfService *)), this, SLOT(addService(QZeroConfService *)));
|
connect(&zeroConf, SIGNAL(serviceAdded(QZeroConfService )), this, SLOT(addService(QZeroConfService )));
|
||||||
connect(&zeroConf, SIGNAL(serviceRemoved(QZeroConfService *)), this, SLOT(removeService(QZeroConfService *)));
|
connect(&zeroConf, SIGNAL(serviceRemoved(QZeroConfService )), this, SLOT(removeService(QZeroConfService )));
|
||||||
|
|
||||||
zeroConf.startBrowser("_qtzeroconf_test._tcp");
|
zeroConf.startBrowser("_workstation._tcp");
|
||||||
startPublish();
|
startPublish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,16 +126,16 @@ void mainWindow::stopPublish()
|
|||||||
|
|
||||||
// ---------- Discovery Callbacks ----------
|
// ---------- Discovery Callbacks ----------
|
||||||
|
|
||||||
void mainWindow::addService(QZeroConfService *zcs)
|
void mainWindow::addService(QZeroConfService zcs)
|
||||||
{
|
{
|
||||||
qint32 row;
|
qint32 row;
|
||||||
QTableWidgetItem *cell;
|
QTableWidgetItem *cell;
|
||||||
|
|
||||||
row = table.rowCount();
|
row = table.rowCount();
|
||||||
table.insertRow(row);
|
table.insertRow(row);
|
||||||
cell = new QTableWidgetItem(zcs->name);
|
cell = new QTableWidgetItem(zcs.name());
|
||||||
table.setItem(row, 0, cell);
|
table.setItem(row, 0, cell);
|
||||||
cell = new QTableWidgetItem(zcs->ip.toString());
|
cell = new QTableWidgetItem(zcs.ip().toString());
|
||||||
table.setItem(row, 1, cell);
|
table.setItem(row, 1, cell);
|
||||||
table.resizeColumnsToContents();
|
table.resizeColumnsToContents();
|
||||||
#if !(defined(Q_OS_IOS) || defined(Q_OS_ANDROID))
|
#if !(defined(Q_OS_IOS) || defined(Q_OS_ANDROID))
|
||||||
@@ -143,17 +143,17 @@ void mainWindow::addService(QZeroConfService *zcs)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainWindow::removeService(QZeroConfService *zcs)
|
void mainWindow::removeService(QZeroConfService zcs)
|
||||||
{
|
{
|
||||||
qint32 i, row;
|
qint32 i, row;
|
||||||
QTableWidgetItem *nameItem, *ipItem;
|
QTableWidgetItem *nameItem, *ipItem;
|
||||||
|
|
||||||
QList <QTableWidgetItem*> search = table.findItems(zcs->name, Qt::MatchExactly);
|
QList <QTableWidgetItem*> search = table.findItems(zcs.name(), Qt::MatchExactly);
|
||||||
for (i=0; i<search.size(); i++) {
|
for (i=0; i<search.size(); i++) {
|
||||||
nameItem = search.at(i);
|
nameItem = search.at(i);
|
||||||
row = nameItem->row();
|
row = nameItem->row();
|
||||||
ipItem = table.item(row, 1);
|
ipItem = table.item(row, 1);
|
||||||
if (table.item(row, 1)->text() == zcs->ip.toString()) { // match ip address in case of dual homed systems
|
if (table.item(row, 1)->text() == zcs.ip().toString()) { // match ip address in case of dual homed systems
|
||||||
delete nameItem;
|
delete nameItem;
|
||||||
delete ipItem;
|
delete ipItem;
|
||||||
table.removeRow(row);
|
table.removeRow(row);
|
||||||
|
@@ -48,8 +48,8 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void startPublish();
|
void startPublish();
|
||||||
void stopPublish();
|
void stopPublish();
|
||||||
void addService(QZeroConfService *item);
|
void addService(QZeroConfService item);
|
||||||
void removeService(QZeroConfService *item);
|
void removeService(QZeroConfService item);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WINDOW_H_ */
|
#endif /* WINDOW_H_ */
|
||||||
|
Reference in New Issue
Block a user