bool a = false;//查找区域是否相同的
QMap<int, MNdata_stru>::iterator it;
if (m_model->rowCount() != 0)
{
it = g_QMapParaData.end() - 1;
qDebug()<<"333333"<<it.key();
}
else
{
it = g_QMapParaData.end();
qDebug()<<"111111"<<it.key();
}
for (int i = 0; i < num; i++)
{
if (mn == g_QMapParaData[i].MN)
{
QMessageBox::warning(this, tr("提示"), tr("您添加的站点编号已经使用,请勿重复操作!"), QMessageBox::tr("确定"));
return;
}
else if (area == m_model->item(i)->text())
{
MNdata_stru temp_MNdata_stru;
temp_MNdata_stru.area = area;
temp_MNdata_stru.name = name;
temp_MNdata_stru.MN = mn;
QString temp_name = QString("%1(%2)").arg(name).arg(mn);
temp_MNdata_stru.itemStation = new QStandardItem(QIcon(QPixmap(":/image/res/house2.png")), temp_name);
qDebug() << "------------------------g_QMapParaData.count()" << g_QMapParaData.end().key();
int n = it.key();
qDebug()<<"444444"<<n;
g_QMapParaData.insert(n, temp_MNdata_stru);
m_model->item(i)->appendRow(g_QMapParaData[n].itemStation);
qDebug()<<"dddddddddddddddddddd"<<g_QMapParaData.count();
for(it=g_QMapParaData.begin();it!=g_QMapParaData.end();it++){
qDebug()<<"message"<<it.key()<<it.value().name;
}
a = true;
break;
}
}
if (!a)
{
QStandardItem *itemArea = new QStandardItem;
itemArea->setText(area);
m_model->appendRow(itemArea);//添加新区域
MNdata_stru temp_MNdata_stru;
temp_MNdata_stru.area = area;
temp_MNdata_stru.name = name;
temp_MNdata_stru.MN = mn;
QString temp_name = QString("%1(%2)").arg(name).arg(mn);
temp_MNdata_stru.itemStation = new QStandardItem(QIcon(QPixmap(":/image/res/house2.png")), temp_name);
qDebug() << "======================g_QMapParaData.count()" << g_QMapParaData.count();
int n = it.key();
qDebug()<<"222222"<<n;
g_QMapParaData.insert(n, temp_MNdata_stru);
m_model->item(num)->appendRow(g_QMapParaData[n].itemStation);
}
添加了两条信息,aa和bb。aa不显示是key重复了,为什么多出一条key为0的