MCPcopy Create free account
hub / github.com/RetroShare/RetroShare / initializeStatusObject

Method initializeStatusObject

retroshare-gui/src/gui/MainWindow.cpp:1400–1459  ·  view source on GitHub ↗

add and initialize status object */

Source from the content-addressed store, hash-verified

1398
1399/* add and initialize status object */
1400void 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 }

Callers 1

MessengerWindowMethod · 0.80

Calls 6

QIconClass · 0.85
setStatusObjectFunction · 0.85
findMethod · 0.80
insertMethod · 0.80
addActionMethod · 0.45
addItemMethod · 0.45

Tested by

no test coverage detected