| 188 | } |
| 189 | |
| 190 | int CWakeOnLanModel::AddItem(QSharedPointer<CParameterWakeOnLan> para) |
| 191 | { |
| 192 | if(!para) |
| 193 | return -1; |
| 194 | QString szIp = para->m_Net.GetHost(); |
| 195 | if(szIp.isEmpty()) { |
| 196 | qCritical(log) << "The ip is empty"; |
| 197 | return -1; |
| 198 | } |
| 199 | foreach(auto p, m_Data) |
| 200 | { |
| 201 | if(p->m_Net.GetHost() == szIp){ |
| 202 | qDebug(log) << szIp << "is existed"; |
| 203 | return 0; |
| 204 | } |
| 205 | } |
| 206 | bool check = connect(para.data(), SIGNAL(sigHostStateChanged()), |
| 207 | this, SLOT(slotHostStateChanged())); |
| 208 | Q_ASSERT(check); |
| 209 | beginResetModel(); |
| 210 | m_Data.push_back(para); |
| 211 | endResetModel(); |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | bool CWakeOnLanModel::removeRows(int row, int count, const QModelIndex &parent) |
| 216 | { |