Example #1
0
/*
Function: displayIdentifierAttributes() const

Description: This function will print out all of the attributes associated 
with a symbol table entry. 
*/
void symbolTableEntry::displayIdentifierAttributes(int tabCount) const {
	int idNumTemp = 0;
	std::string idTemp = getIdentifierName();
	printTabs(tabCount);
	std::cout << "Identifier name: " << idTemp << std::endl;
	idTemp = getIdentifierType_String();
	printTabs(tabCount);
	std::cout << "Identifier type: " << idTemp << std::endl;
	printTabs(tabCount);
	std::cout << "Identifier value: ";
	printIdentifierValue(); 
	std::cout << std::endl;
	//!!!!!!!!!!!!!!!!! CHECK THIS LATER !!!!!!!!!!!
	
	if (isFunc) {
		idNumTemp = getNumParams(); 
		std::cout << "Identifier is a function." << std::endl;
		std::cout << "Identifier has " << idNumTemp << " parameters.";
		std::cout << std::endl; 
		std::cout << "Identifier parameters: " << std::endl;
		viewParams(); 
	}

	else if (isPtr) {
		idNumTemp = getNumPtrs();
		std::cout << "Identifier is a pointer." << std::endl;
		std::cout << "Identifier has " << idNumTemp << " parameters.";
		std::cout << std::endl; 
	}

	else if (isArr) {
		idNumTemp = getNumArrDims();
		std::cout << "Identifier is an array." << std::endl;
		std::cout << "Identifier has " << idNumTemp << " dimensions.";
		std::cout << std::endl;
		std::cout << "Identifier dimensions: " << std::endl;
		for (unsigned int i = 0; i < arrayDimensions.size(); i++) {
			std::cout << "Dimension #" << i << " :" << arrayDimensions[i] << std::endl; 
		} 
	}
}
    void ContactListItemHorizontalDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    {
        const auto searchMemberModel = qobject_cast<const Logic::SearchMembersModel*>(index.model());
        const auto membersModel = qobject_cast<const Logic::ChatMembersModel*>(index.model());

        bool isGroup = false;
        QString displayName, status, state;
        QString aimId;
        bool hasLastSeen = false, isChecked = false, isChatMember = false, isOfficial = false;
        QDateTime lastSeen;

        Data::Contact* contact_in_cl = nullptr;
        QString role;

        if (membersModel || searchMemberModel)
        {
            auto cont = index.data(Qt::DisplayRole).value<Data::ChatMemberInfo*>();
            displayName = cont->getFriendly();

            aimId = cont->AimId_;
            if (aimId != Ui::MyInfo()->aimId())
            {
                auto contact_item = Logic::getContactListModel()->getContactItem(aimId);
                if (contact_item)
                    contact_in_cl = contact_item->Get();
            }
        }
        else
        {
            contact_in_cl = index.data(Qt::DisplayRole).value<Data::Contact*>();
        }

        if (contact_in_cl)
        {
            isGroup = (contact_in_cl->GetType() == Data::GROUP);
            displayName = contact_in_cl->GetDisplayName();
            aimId = contact_in_cl->AimId_;
            status = contact_in_cl->StatusMsg_;
            state = contact_in_cl->State_;
            hasLastSeen = contact_in_cl->HasLastSeen_;
            lastSeen = contact_in_cl->LastSeen_;
            isChecked = contact_in_cl->IsChecked_;
            isOfficial = contact_in_cl->IsOfficial_;
        }

        //const bool isHovered = ((option.state & QStyle::State_MouseOver) && !isGroup) && !StateBlocked_ && !isSelected && hasMouseOver;

        painter->save();
        painter->setRenderHint(QPainter::Antialiasing);
        painter->translate(option.rect.topLeft());

        {
            const auto isMultichat = Logic::getContactListModel()->isChat(aimId);
            auto isDefault = false;

            const auto &avatar = Logic::GetAvatarStorage()->GetRounded(aimId, displayName, Utils::scale_bitmap(::ContactList::GetContactListParams().getAvatarSize())
                , isMultichat ? QString() : state, isDefault, false /* _regenerate */, ::ContactList::GetContactListParams().isCL());
            const ::ContactList::VisualDataBase visData(aimId, *avatar, state, status, false, false, displayName, hasLastSeen, lastSeen
                , isChecked, isChatMember, isOfficial, false /* draw last read */, QPixmap() /* last seen avatar*/, role, 0 /* unread count */, "" /* search_term */, false, false);

            ::ContactList::ViewParams viewParams(viewParams_.regim_, viewParams_.fixedWidth_, viewParams_.leftMargin_, viewParams_.rightMargin_);
            //::ContactList::RenderContactItem(*painter, visData, viewParams);

            auto contactList = ::ContactList::GetContactListParams();
            ::ContactList::RenderAvatar(*painter, Utils::scale_value(16), contactList.getAvatarY(), visData.Avatar_, contactList.getAvatarSize());
        }

        painter->restore();
    }