Browse Source

fix(chatgui): replace qDebug with DEBUG_INFO for online trace logs

topo_upd
Evgeny 3 months ago
parent
commit
cf46a59d3a
  1. 19
      tools/chatgui/src/channellist.cpp
  2. 3
      tools/chatgui/src/mainwindow.cpp

19
tools/chatgui/src/channellist.cpp

@ -7,9 +7,12 @@
#include <QPushButton> #include <QPushButton>
#include <QPainter> #include <QPainter>
#include <QPixmap> #include <QPixmap>
#include <QDebug>
#include <QMouseEvent> #include <QMouseEvent>
extern "C" {
#include "../../lib/debug_config.h"
}
/* QListView that prevents deselection, handles invite plus-button clicks */ /* QListView that prevents deselection, handles invite plus-button clicks */
class ChannelListView : public QListView { class ChannelListView : public QListView {
Q_OBJECT Q_OBJECT
@ -181,8 +184,8 @@ void ChannelList::loadChannels() {
item->setData(QString(), ChannelLastMessageRole); item->setData(QString(), ChannelLastMessageRole);
item->setData(makeChannelIcon(colors[ci % 6], letter), ChannelIconRole); item->setData(makeChannelIcon(colors[ci % 6], letter), ChannelIconRole);
m_model->appendRow(item); m_model->appendRow(item);
qDebug() << "ChannelList::loadChannels row=" << (m_model->rowCount()-1) DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "ChannelList::loadChannels row=%d cid='%s' name='%s'",
<< "cid='" << ch.channelId << "' name='" << ch.name << "'"; m_model->rowCount()-1, qPrintable(ch.channelId), qPrintable(ch.name));
ci++; ci++;
} }
@ -208,25 +211,25 @@ void ChannelList::selectChannel(const QString& channelId) {
void ChannelList::setChannelPeersOnline(const QString& channelId, int count) { void ChannelList::setChannelPeersOnline(const QString& channelId, int count) {
int found = 0; int found = 0;
qDebug() << "ChannelList::setChannelPeersOnline search='" << channelId DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "ChannelList::setChannelPeersOnline search='%s' online=%d rows=%d",
<< "' online=" << count << " rows=" << m_model->rowCount(); qPrintable(channelId), count, m_model->rowCount());
for (int row = 0; row < m_model->rowCount(); row++) { for (int row = 0; row < m_model->rowCount(); row++) {
QStandardItem* item = m_model->item(row); QStandardItem* item = m_model->item(row);
if (item) { if (item) {
QString itemCid = item->data(ChannelChannelIdRole).toString(); QString itemCid = item->data(ChannelChannelIdRole).toString();
int match = (itemCid == channelId) ? 1 : 0; int match = (itemCid == channelId) ? 1 : 0;
qDebug() << " row=" << row << "cid='" << itemCid << "' match=" << match; DEBUG_INFO(DEBUG_CATEGORY_DEBUG, " row=%d cid='%s' match=%d", row, qPrintable(itemCid), match);
if (match) { if (match) {
item->setData(count, ChannelPeersOnlineRole); item->setData(count, ChannelPeersOnlineRole);
item->setData(m_autoConnectActive ? 1 : 0, ChannelAutoConnectActiveRole); item->setData(m_autoConnectActive ? 1 : 0, ChannelAutoConnectActiveRole);
qDebug() << " SET online=" << count; DEBUG_INFO(DEBUG_CATEGORY_DEBUG, " SET online=%d", count);
found = 1; found = 1;
break; break;
} }
} }
} }
if (!found) if (!found)
qDebug() << " NOT FOUND in model"; DEBUG_INFO(DEBUG_CATEGORY_DEBUG, " NOT FOUND in model");
} }
void ChannelList::setAutoConnectActive(bool active) { void ChannelList::setAutoConnectActive(bool active) {

3
tools/chatgui/src/mainwindow.cpp

@ -297,7 +297,8 @@ void MainWindow::onAutoConnectStatus(uint8_t status, uint16_t /*total_tried*/,
void MainWindow::onChannelPeersOnline(const char* ch_id, int ch_id_len, uint16_t online) { void MainWindow::onChannelPeersOnline(const char* ch_id, int ch_id_len, uint16_t online) {
if (m_channelList) { if (m_channelList) {
QString cid = QString::fromUtf8(ch_id, ch_id_len); QString cid = QString::fromUtf8(ch_id, ch_id_len);
qDebug() << "MainWindow::onChannelPeersOnline cid=" << cid << "online=" << online; DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "MainWindow::onChannelPeersOnline cid=%s online=%u",
qPrintable(cid), online);
m_channelList->setChannelPeersOnline(cid, (int)online); m_channelList->setChannelPeersOnline(cid, (int)online);
} }
} }

Loading…
Cancel
Save