diff --git a/Release/x64/qtTsOverlay_x64.dll b/Release/x64/qtTsOverlay_x64.dll index e409bf3155cfb355d27638f74ae9d9d3b6069d22..57befd5444ea8a8bb02f9e9fe9cb2e2bb837df44 100644 Binary files a/Release/x64/qtTsOverlay_x64.dll and b/Release/x64/qtTsOverlay_x64.dll differ diff --git a/Release/x64/qtTsOverlay_x64.exp b/Release/x64/qtTsOverlay_x64.exp index de87b36d9e9c083a64db213d5f30ff2a357b38af..1cc829e75929814c0aa87e441eaf617a8873ba8f 100644 Binary files a/Release/x64/qtTsOverlay_x64.exp and b/Release/x64/qtTsOverlay_x64.exp differ diff --git a/Release/x64/qtTsOverlay_x64.lib b/Release/x64/qtTsOverlay_x64.lib index a51018ac7de17254344fc0d44f7e98b572bbc444..133c651ae79aeb85a63665fc8a55769bf3f3d258 100644 Binary files a/Release/x64/qtTsOverlay_x64.lib and b/Release/x64/qtTsOverlay_x64.lib differ diff --git a/overlaycontroller.cpp b/overlaycontroller.cpp index 331c8fc6368306c797c62f74217b94362e892887..e170b16d8dabd0be30f4dc84c6cc40be8e8d5e93 100644 --- a/overlaycontroller.cpp +++ b/overlaycontroller.cpp @@ -11,14 +11,6 @@ //#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) //#endif -struct ChannelInfo { - uint64 id; - QString name; - uint64 parent; - QTreeWidgetItem* entry; - int order; -}; - enum nodeType { channel, client, @@ -45,6 +37,8 @@ OverlayController::OverlayController(const struct TS3Functions funcs, quint64 se m_tree = new ChannelListWidget; connect(m_tree->getTree(), &QTreeWidget::itemDoubleClicked, this, &OverlayController::treeItemClicked); + + updateChannelList(); } OverlayController::~OverlayController() @@ -57,6 +51,11 @@ OverlayController::~OverlayController() delete it; m_msgLines.clear(); + m_channelList.clear(); + + while (!m_clientList.isEmpty()) + delete m_clientList.takeFirst(); + delete m_debugWindow; delete m_tree; } @@ -213,12 +212,6 @@ void OverlayController::reset() } void OverlayController::updateChannelList() -{ - if (m_tree->isVisible()) - displayChannelList(); -} - -void OverlayController::displayChannelList() { // remove old stuff while (int nb = m_tree->getTree()->topLevelItemCount()) @@ -230,7 +223,6 @@ void OverlayController::displayChannelList() return; // get a list of all channels containing name, id, parent,.. - QVector<ChannelInfo> channelList; int i(0); while (channelIDList[i] != NULL) { @@ -251,16 +243,16 @@ void OverlayController::displayChannelList() else tmp.entry->setData(2, Qt::UserRole, channel); - channelList.push_back(tmp); + m_channelList.push_back(tmp); i++; } // for every channel - for (auto &parent : channelList) + for (auto &parent : m_channelList) { // collect all childs QVector<ChannelInfo> childs; - for (auto &child : channelList) + for (auto &child : m_channelList) if (child.parent == parent.id) childs.push_back(child); @@ -280,13 +272,13 @@ void OverlayController::displayChannelList() // get all toplvl channels QVector<ChannelInfo> topLvlList; - for (auto &it : channelList) + for (auto &it : m_channelList) if (it.parent == 0) topLvlList.push_back(it); // add toplvl to tree in correct order int prevID = 0; - while(!topLvlList.isEmpty()) + while (!topLvlList.isEmpty()) { int i; for (i = 0; i < topLvlList.size(); i++) @@ -297,8 +289,18 @@ void OverlayController::displayChannelList() m_tree->getTree()->addTopLevelItem(topLvlList.takeAt(i).entry); } - // insert clients - for (auto& it : channelList) + updateClientList(); + m_tree->getTree()->expandAll(); +} + +void OverlayController::updateClientList() +{ + //TODO: remove all clients + while (!m_clientList.isEmpty()) + delete m_clientList.takeFirst(); + + //add all clients + for (auto& it : m_channelList) { anyID* clientIDList; ts3.getChannelClientList(m_SCHID, it.id, &clientIDList); @@ -310,14 +312,16 @@ void OverlayController::displayChannelList() tmp->setData(0, Qt::DisplayRole, clientID2Name(m_SCHID, clientIDList[i])); tmp->setData(1, Qt::UserRole, clientIDList[i]); tmp->setData(2, Qt::UserRole, client); + m_clientList.push_back(tmp); it.entry->addChild(tmp); i++; } } +} - // display everything - m_tree->getTree()->expandAll(); +void OverlayController::displayChannelList() +{ m_tree->getTree()->adjustSize(); m_tree->adjustSize(); m_tree->show(); diff --git a/overlaycontroller.h b/overlaycontroller.h index 38fe858fc32fc662ca1318c5828044e0231cb4bb..86f30fef649422e0101af69f166eac4ee5a231c0 100644 --- a/overlaycontroller.h +++ b/overlaycontroller.h @@ -17,6 +17,14 @@ #define TIMEOUT 5000 +struct ChannelInfo { + uint64 id; + QString name; + uint64 parent; + QTreeWidgetItem* entry; + int order; +}; + class QTTSOVERLAY_EXPORT OverlayController : public QObject { Q_OBJECT @@ -36,6 +44,8 @@ private: QVector<QWidget*> m_speakers; QVector<QWidget*> m_msgLines; ChannelListWidget* m_tree; + QVector<ChannelInfo> m_channelList; + QVector<QTreeWidgetItem*> m_clientList; private: void deleteChatLine(QWidget* line, QTimer *timer = NULL); @@ -50,5 +60,6 @@ public: void debugPrint(QString text); void reset(); void updateChannelList(); + void updateClientList(); void displayChannelList(); }; diff --git a/plugin.cpp b/plugin.cpp index 695e98a78a15cd47b20d2dadcd26595ac18a96ea..79705beb19ea9cfd65fcfab5286b88d5b6a63d0a 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -354,34 +354,32 @@ void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int else if (newStatus == STATUS_CONNECTION_ESTABLISHED) { g_serverList.insert(serverConnectionHandlerID, new OverlayController(ts3Functions, serverConnectionHandlerID)); - - char* name; - ts3Functions.getServerVariableAsString(serverConnectionHandlerID, VIRTUALSERVER_NAME, &name); - - getController(serverConnectionHandlerID)->debugPrint(QString("Welcome at: %1").arg(name)); - ts3Functions.freeMemory(name); - - getController(serverConnectionHandlerID)->displayChannelList(); } } void ts3plugin_onNewChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID) { + //getController(serverConnectionHandlerID)->updateChannelList(); } void ts3plugin_onNewChannelCreatedEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) { + //getController(serverConnectionHandlerID)->updateChannelList(); } void ts3plugin_onDelChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) { + //getController(serverConnectionHandlerID)->updateChannelList(); } void ts3plugin_onChannelMoveEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 newChannelParentID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) { + //getController(serverConnectionHandlerID)->updateChannelList(); } void ts3plugin_onUpdateChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID) { + //getController(serverConnectionHandlerID)->updateChannelList(); } void ts3plugin_onUpdateChannelEditedEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) { + //getController(serverConnectionHandlerID)->updateChannelList(); } void ts3plugin_onUpdateClientEvent(uint64 serverConnectionHandlerID, anyID clientID, anyID invokerID, const char* invokerName, const char* invokerUniqueIdentifier) { @@ -389,7 +387,7 @@ void ts3plugin_onUpdateClientEvent(uint64 serverConnectionHandlerID, anyID clien void ts3plugin_onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* moveMessage) { - getController(serverConnectionHandlerID)->updateChannelList(); + getController(serverConnectionHandlerID)->updateClientList(); QString ClientName = clientID2Name(serverConnectionHandlerID, clientID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); @@ -422,7 +420,7 @@ void ts3plugin_onClientMoveSubscriptionEvent(uint64 serverConnectionHandlerID, a void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char* timeoutMessage) { - getController(serverConnectionHandlerID)->updateChannelList(); + getController(serverConnectionHandlerID)->updateClientList(); QString ClientName = clientID2Name(serverConnectionHandlerID, clientID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); @@ -447,7 +445,7 @@ void ts3plugin_onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID moverID, const char* moverName, const char* moverUniqueIdentifier, const char* moveMessage) { - getController(serverConnectionHandlerID)->updateChannelList(); + getController(serverConnectionHandlerID)->updateClientList(); QString ClientName = clientID2Name(serverConnectionHandlerID, clientID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); @@ -472,7 +470,7 @@ void ts3plugin_onClientMoveMovedEvent(uint64 serverConnectionHandlerID, anyID cl void ts3plugin_onClientKickFromChannelEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID kickerID, const char* kickerName, const char* kickerUniqueIdentifier, const char* kickMessage) { - getController(serverConnectionHandlerID)->updateChannelList(); + getController(serverConnectionHandlerID)->updateClientList(); QString ClientName = clientID2Name(serverConnectionHandlerID, clientID); QString oldChannel = channelID2Name(serverConnectionHandlerID, oldChannelID); @@ -486,7 +484,7 @@ void ts3plugin_onClientKickFromChannelEvent(uint64 serverConnectionHandlerID, an void ts3plugin_onClientKickFromServerEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, anyID kickerID, const char* kickerName, const char* kickerUniqueIdentifier, const char* kickMessage) { - getController(serverConnectionHandlerID)->updateChannelList(); + getController(serverConnectionHandlerID)->updateClientList(); QString ClientName = clientID2Name(serverConnectionHandlerID, clientID);