add and initialize status object */
| 1398 | |
| 1399 | /* add and initialize status object */ |
| 1400 | void MainWindow::initializeStatusObject(QObject *pObject, bool bConnect) |
| 1401 | { |
| 1402 | if (m_apStatusObjects.find(pObject) != m_apStatusObjects.end()) { |
| 1403 | /* already added */ |
| 1404 | return; |
| 1405 | } |
| 1406 | |
| 1407 | m_apStatusObjects.insert(m_apStatusObjects.end(), pObject); |
| 1408 | |
| 1409 | //std::string statusString; |
| 1410 | |
| 1411 | QMenu *pMenu = dynamic_cast<QMenu*>(pObject); |
| 1412 | if (pMenu) { |
| 1413 | /* initialize menu */ |
| 1414 | QActionGroup *pGroup = new QActionGroup(pMenu); |
| 1415 | |
| 1416 | QAction *pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), pMenu); |
| 1417 | pAction->setData(RS_STATUS_ONLINE); |
| 1418 | pAction->setCheckable(true); |
| 1419 | pMenu->addAction(pAction); |
| 1420 | pGroup->addAction(pAction); |
| 1421 | |
| 1422 | pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), pMenu); |
| 1423 | pAction->setData(RS_STATUS_BUSY); |
| 1424 | pAction->setCheckable(true); |
| 1425 | pMenu->addAction(pAction); |
| 1426 | pGroup->addAction(pAction); |
| 1427 | |
| 1428 | pAction = new QAction(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), pMenu); |
| 1429 | pAction->setData(RS_STATUS_AWAY); |
| 1430 | pAction->setCheckable(true); |
| 1431 | pMenu->addAction(pAction); |
| 1432 | pGroup->addAction(pAction); |
| 1433 | |
| 1434 | if (bConnect) { |
| 1435 | connect(pMenu, SIGNAL(triggered (QAction*)), this, SLOT(statusChangedMenu(QAction*))); |
| 1436 | } |
| 1437 | } else { |
| 1438 | /* initialize combobox */ |
| 1439 | RSComboBox *pComboBox = dynamic_cast<RSComboBox*>(pObject); |
| 1440 | if (pComboBox) { |
| 1441 | pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_ONLINE)), StatusDefs::name(RS_STATUS_ONLINE), RS_STATUS_ONLINE); |
| 1442 | pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_BUSY)), StatusDefs::name(RS_STATUS_BUSY), RS_STATUS_BUSY); |
| 1443 | pComboBox->addItem(QIcon(StatusDefs::imageStatus(RS_STATUS_AWAY)), StatusDefs::name(RS_STATUS_AWAY), RS_STATUS_AWAY); |
| 1444 | |
| 1445 | if (bConnect) { |
| 1446 | connect(pComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int))); |
| 1447 | } |
| 1448 | } |
| 1449 | /* add more objects here */ |
| 1450 | } |
| 1451 | |
| 1452 | if (m_bStatusLoadDone) { |
| 1453 | /* loadOwnStatus done, set own status directly */ |
| 1454 | StatusInfo statusInfo; |
| 1455 | if (rsStatus->getOwnStatus(statusInfo)) { |
| 1456 | setStatusObject(pObject, statusInfo.status); |
| 1457 | } |
no test coverage detected