Пример #1
0
void Tardis::redoAction()
{
    if (m_history.isEmpty() || m_historyIndex == m_history.count() - 1)
        return;

    bool done = false;

    m_busy = true;

    quint64 refTimestamp = m_history.at(m_historyIndex + 1).m_timestamp;

    while (!done)
    {
        m_historyIndex++;

        TardisAction action = m_history.at(m_historyIndex);
        qDebug() << "Redo action" << actionToString(action.m_action);

        int code = processAction(action, false);

        /* If there are active network connections, send the action there too */
        forwardActionToNetwork(code, action);

        /* Check if I am processing a batch of actions or a single one */
        if (m_historyIndex == m_history.count() - 1 ||
            action.m_timestamp - refTimestamp > TARDIS_ACTION_INTERTIME)
        {
            done = true;
        }
    }

    qDebug() << "History index:" << m_historyIndex;

    m_busy = false;
}
QVariant VKVisualMessageModel::data(const QModelIndex &index, int role) const {
    if (index.row() < 0 || index.row() >= rowCount()) {
        qDebug()<<"index is out of range"<<index.row()<<"row count"<<rowCount();
        return QVariant();
    }

    auto& obj = m_messages[index.row()];

    switch (role) {
    case eRoleActionMessages:
        return processAction(obj.message());
    case eRoleChatId:
        return obj.message()->chatId();
    case eRoleDate:
        return processDate(obj.message()->date());
    case eRoleIcon:
        return obj.message()->user()->iconSmall();
    case eRoleId:
        return obj.message()->id();
    case eRoleIncoming:
        return obj.message()->isIncoming();
    case eRoleIsRead:
        return obj.message()->isRead();
    case eRoleMsg:
        return obj.message()->body();
    case eRoleUserName:
        return obj.message()->user()->userName();
    default: {
        if (obj.contain(role)) {
            return obj.data(role);
        }
    }
    }
    return QVariant();
}
QAction *Menu::addAction(QAction *action, const style::icon *icon, const style::icon *iconOver) {
	connect(action, SIGNAL(changed()), this, SLOT(actionChanged()));
	_actions.push_back(action);

	auto createData = [icon, iconOver, action] {
		auto data = ActionData();
		data.icon = icon;
		data.iconOver = iconOver ? iconOver : icon;
		data.hasSubmenu = (action->menu() != nullptr);
		return data;
	};
	_actionsData.push_back(createData());

	auto newWidth = qMax(width(), _st.widthMin);
	newWidth = processAction(action, _actions.size() - 1, newWidth);
	auto newHeight = height() + (action->isSeparator() ? _separatorHeight : _itemHeight);
	resize(_forceWidth ? _forceWidth : newWidth, newHeight);
	if (_resizedCallback) {
		_resizedCallback();
	}
	updateSelected(QCursor::pos());
	update();

	return action;
}
Пример #4
0
void Tardis::undoAction()
{
    if (m_historyIndex == -1 || m_history.isEmpty())
        return;

    m_busy = true;

    quint64 refTimestamp = m_history.at(m_historyIndex).m_timestamp;

    while (1)
    {
        TardisAction action = m_history.at(m_historyIndex);

        if (refTimestamp - action.m_timestamp > TARDIS_ACTION_INTERTIME)
            break;

        qDebug() << "Undo action" << actionToString(action.m_action);

        m_historyIndex--;

        int code = processAction(action, true);

        /* If there are active network connections, send the action there too */
        forwardActionToNetwork(code, action);

        if (m_historyIndex == -1)
            break;
    }

    qDebug() << "History index:" << m_historyIndex;

    m_busy = false;
}
Пример #5
0
void PopupMenu::actionChanged() {
    int32 w = _padding.left() + _st.widthMin + _padding.right();
    for (int32 i = 0, l = _actions.size(); i < l; ++i) {
        w = processAction(_actions.at(i), i, w);
    }
    if (w != width()) {
        resize(w, height());
    }
    update();
}
void Menu::actionChanged() {
	auto newWidth = _st.widthMin;
	for (auto i = 0, count = _actions.size(); i != count; ++i) {
		newWidth = processAction(_actions[i], i, newWidth);
	}
	if (newWidth != width() && !_forceWidth) {
		resize(newWidth, height());
		if (_resizedCallback) {
			_resizedCallback();
		}
	}
	update();
}
Пример #7
0
    void UICommandDispatcher::onActionsAvailable() {
        LOG_DEBUG << "#";
        decltype(m_ActionsQueue) actions;
        {
            QMutexLocker locker(&m_Mutex);
            Q_UNUSED(locker);
            m_ActionsQueue.swap(actions);
        }

        for (auto &action: actions) {
            auto processedAction = processAction(action);
            emit dispatched(processedAction->m_CommandID, processedAction->m_Value);
        }
    }
Пример #8
0
QAction *PopupMenu::addAction(QAction *a) {
    connect(a, SIGNAL(changed()), this, SLOT(actionChanged()));
    _actions.push_back(a);
    if (a->menu()) {
        _menus.push_back(new PopupMenu(a->menu()));
        _menus.back()->deleteOnHide(false);
    } else {
        _menus.push_back(0);
    }
    _texts.push_back(QString());
    _shortcutTexts.push_back(QString());
    int32 w = processAction(a, _actions.size() - 1, width());
    resize(w, height() + (a->isSeparator() ? _separatorHeight : _itemHeight));
    update();

    return a;
}
/*****************************************************************************//**
* @brief Process json data from remote action
*
* @param pointer to the json data
* @param pointer to HUBACTION_DATA
* @param pointer to action status
* @param pointer to response message
* @return the function returns result in parameters
* @author Neal Shurmantine
* @version
* 08/08/2016    Created.
*******************************************************************************/
void RAS_ProcessActionResponseJSON(char *p_buff, HUBACTION_DATA *hubActionData,
                        eActionStatus *status,
                        eActionMessageId *msg)
{
    init_hubaction_data(hubActionData);
    parse_hubaction_update_data(p_buff, hubActionData);

    print_json_data(hubActionData);

    *status = processAction(hubActionData);
    if (*status == ACTION_STATUS_SUCCESS) {
        if ((hubActionData->schedule_modified==false) && (hubActionData->nest_cleared==false)) {
            LOG_LogEvent("Remote Action Received");
            printf("Scene %d Executed\n\n",hubActionData->resourceId1);
            RAS_RemoteConnectCheckTime = REMOTE_CONNECT_CHECK_TIME_NOW;
        }
        else if (hubActionData->schedule_modified==true) {
            LOG_LogEvent("Schedule Enable Modified");
            printf("Schedule Enable was modified\n");
            RDS_SyncDataImmediately(NULL_TOKEN);
        }
        else {
            LOG_LogEvent("Nest Struct Cleared");
            printf("Nest Struct Cleared\n");
            clearIntegrations();
            RDS_SyncDataImmediately(NULL_TOKEN);
        }
        *msg = ACTION_MESSAGE_SUCCESS;
    }
    else if (*status == ACTION_STATUS_NULL) {
#ifdef DEBUG_REMOTE_EVENTS
        printf("No Action Required\n\n");
#endif
    }
    else {
        printf("Scene %d Not Found\n\n",hubActionData->resourceId1);
    }
}
Пример #10
0
 void UICommandDispatcher::dispatchCommand(int commandID, const QVariant &value) {
     LOG_DEBUG << "#";
     processAction(std::make_shared<UIAction>(commandID, value));
 }
Пример #11
0
bool PRINT_SCP_EMULATOR_CLASS::processCommandDataset(DCM_COMMAND_CLASS *command_ptr, DCM_DATASET_CLASS *dataset_ptr)

//  DESCRIPTION     : Process the Print command (and dataset).
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	bool result;

	// handle individual commands
	switch(command_ptr->getCommandId())
	{
	case DIMSE_CMD_NACTION_RQ:
		// process the ACTION command
		result = processAction(command_ptr->getEncodePresentationContextId());
		break;
	case DIMSE_CMD_NCREATE_RQ:
	    if ((sopClassUidM == FILM_SESSION_SOP_CLASS_UID) ||
		    (dataset_ptr))
		{
			// process the CREATE command
            // - Basic Film Session may not define a dataset - but that is OK
			result = processCreate(command_ptr->getEncodePresentationContextId(), dataset_ptr);
		}
		else
		{
			// missing dataset
			UINT16 status = DCM_STATUS_PROCESSING_FAILURE;
			result = sendResponse(DIMSE_CMD_NCREATE_RSP,
				command_ptr->getEncodePresentationContextId(),
				status);
		}
		break;
	case DIMSE_CMD_NDELETE_RQ:
		// process the DELETE command
		result = processDelete(command_ptr->getEncodePresentationContextId());
		break;
	case DIMSE_CMD_NEVENTREPORT_RSP:
		// nothing to do here
		result = true;
		break;
	case DIMSE_CMD_NGET_RQ:
		// process the GET command
		result = processGet(command_ptr);
		break;
	case DIMSE_CMD_NSET_RQ:
		if (dataset_ptr)
		{
			// process the SET dataset
			result = processSet(command_ptr->getEncodePresentationContextId(), dataset_ptr);
		}
		else
		{
			// missing dataset
			UINT16 status = DCM_STATUS_PROCESSING_FAILURE;
			result = sendResponse(DIMSE_CMD_NSET_RSP,
				command_ptr->getEncodePresentationContextId(), 
				status);
		}
		break;
	default:
		{
			// unknown command
			UINT16 status = DCM_STATUS_UNRECOGNIZED_OPERATION;
			result = sendResponse(command_ptr->getCommandId(),
				command_ptr->getEncodePresentationContextId(), 
				status);
		}
		break;
	}

	// return result
	return result;
}