| 118 | } |
| 119 | |
| 120 | Monitor::TreeNode* |
| 121 | Monitor::MonitorDataStorage::getProcessNode( |
| 122 | const ProcessKey& key, |
| 123 | bool& create |
| 124 | ) |
| 125 | { |
| 126 | // HOST |
| 127 | |
| 128 | TreeNode* hostNode = 0; |
| 129 | HostToTreeMap::iterator hostLocation |
| 130 | = this->hostToTreeMap_.find( key.host); |
| 131 | if( hostLocation == this->hostToTreeMap_.end()) { |
| 132 | // We are done if not creating a new node. |
| 133 | if( !create) return 0; |
| 134 | |
| 135 | // We need to add a new host. Host nodes are children of the |
| 136 | // root node. |
| 137 | TreeNode* root = this->model_->modelRoot(); |
| 138 | |
| 139 | // Host first. |
| 140 | QList<QVariant> list; |
| 141 | list << QString("Host") << QString( QObject::tr( key.host.c_str())); |
| 142 | hostNode = new TreeNode( list, root); |
| 143 | root->append( hostNode); |
| 144 | |
| 145 | // Install the new node. |
| 146 | this->hostToTreeMap_[ key.host] |
| 147 | = std::make_pair( hostNode->row(), hostNode); |
| 148 | |
| 149 | } else { |
| 150 | // Retain the current host node. |
| 151 | hostNode = hostLocation->second.second; |
| 152 | } |
| 153 | |
| 154 | // PROCESS |
| 155 | |
| 156 | TreeNode* pidNode = 0; |
| 157 | ProcessToTreeMap::iterator pidLocation |
| 158 | = this->processToTreeMap_.find( key); |
| 159 | if( pidLocation == this->processToTreeMap_.end()) { |
| 160 | // We are done if not creating a new node. |
| 161 | if( !create) return 0; |
| 162 | |
| 163 | // We need to add a new PID. PID nodes are children of the host |
| 164 | // nodes. We just found the relevant host node. |
| 165 | |
| 166 | // PID data. |
| 167 | QList<QVariant> list; |
| 168 | list << QString("Process") << QString::number( key.pid); |
| 169 | pidNode = new TreeNode( list, hostNode); |
| 170 | hostNode->append( pidNode); |
| 171 | |
| 172 | // Install the new node. |
| 173 | this->processToTreeMap_[ key] |
| 174 | = std::make_pair( pidNode->row(), pidNode); |
| 175 | |
| 176 | } else { |
| 177 | pidNode = pidLocation->second.second; |
no test coverage detected