43 QObject::connect(
db_, SIGNAL(databaseCleared()),
45 QObject::connect(
db_, SIGNAL(messagesAdded()),
60 if (index.parent().isValid() ||
61 static_cast<size_t>(index.row()) >
ordering_.size()) {
70 if (index.parent().isValid() ||
71 static_cast<size_t>(index.row()) >
ordering_.size()) {
75 std::string name =
ordering_[index.row()];
77 if (role == Qt::DisplayRole) {
79 snprintf(buffer,
sizeof(buffer),
"%s (%lu)",
81 data_.find(name)->second);
82 return QVariant(QString(buffer));
93 beginRemoveRows(QModelIndex(), 0,
ordering_.size()-1);
106 std::map<std::string, size_t>::iterator iter;
107 for (iter =
data_.begin(); iter !=
data_.end(); ++iter) {
111 Q_EMIT dataChanged(index(0), index(
data_.size()-1));
119 for (std::map<std::string, size_t>::const_iterator it = msg_counts.begin();
120 it != msg_counts.end();
123 if (!
data_.count(it->first)) {
124 beginInsertRows(QModelIndex(), i, i);
125 data_[it->first] = it->second;
129 data_[it->first] = it->second;
134 Q_EMIT dataChanged(index(0),
std::vector< std::string > ordering_
virtual int rowCount(const QModelIndex &parent) const
std::string nodeName(const QModelIndex &index) const
NodeListModel(LogDatabase *db)
std::map< std::string, size_t > data_
const std::map< std::string, size_t > & messageCounts() const
virtual QVariant data(const QModelIndex &index, int role) const
void handleDatabaseCleared()
void handleMessagesAdded()