Пример #1
0
//VOXOX CHANGE - Add support for ItemList style and change paint structure.
void QtUMGroup::paintForeground(QPainter * painter, const QStyleOptionViewItem & option) {
	QMutexLocker locker(&_mutex);	

	bool isGroupSelected = false;//VOXOX CHANGE by Rolando - 2009.09.03
	bool isGroupBlinking = false;//VOXOX CHANGE by Rolando - 2009.09.08 
	QtUMItemListStyle * itemListStyle = QtUMItemListStyle::getInstance();//VOXOX CHANGE by Rolando - 2009.09.07 
	
	isGroupBlinking = isBlinking();//VOXOX CHANGE by Rolando - 2009.09.03 
	isGroupSelected = _isSelected;//VOXOX CHANGE by Rolando - 2009.10.01 
	
	if(isGroupSelected)//VOXOX CHANGE by Rolando - 2009.09.04 
	{
		painter->setPen(itemListStyle->getSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.09.04 
	}
	else
	{
		if(isGroupBlinking){

			if(_blinkNow){//VOXOX CHANGE by Rolando - 2009.10.01 
				painter->setPen(itemListStyle->getGroupBlinkingFontColor());//VOXOX CHANGE by Rolando - 2009.10.01 
			}
			else{
				painter->setPen(itemListStyle->getNonSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.10.01 
			}
			
		}
		else{
			painter->setPen(itemListStyle->getNonSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.09.04 
		}
	}
	
	painter->drawPixmap(option.rect.left(),option.rect.top(),getGroupBackGround(option.rect,option, isGroupSelected, isGroupBlinking));

	QFont font = option.font;
	painter->setFont(font);

	QPixmap px;
	if (option.state & QStyle::State_Open) {
		px = itemListStyle->getGroupPixmapOpen();
	} else {
		px = itemListStyle->getGroupPixmapClose();
	}

	int x = option.rect.left();
	QRect r = option.rect;
	painter->drawPixmap(x, r.top() + 3, px);

	_posXArrowButton = x;//VOXOX CHANGE by Rolando - 2009.09.29 
	_posYArrowButton = r.top() + 3;//VOXOX CHANGE by Rolando - 2009.09.29 
	_widthArrowButton = px.width();//VOXOX CHANGE by Rolando - 2009.09.29 
	_heightArrowButton = px.height();//VOXOX CHANGE by Rolando - 2009.09.29 

	x += px.width() + 3;
	r.setLeft(x);
	int y = ((r.bottom()-r.top())-QFontMetrics(font).height())/2;
	r.setTop(y + r.top());

	painter->drawText(r, Qt::AlignLeft, getGroupName(), 0);


	//VOXOX CHANGE by Rolando - 2009.08.25 - getting corresponding close button
	QPixmap closeButtonPixmap;

	if ((option.state & QStyle::State_Selected) == QStyle::State_Selected) {
		closeButtonPixmap = QPixmap(":/pics/chat/umtreewidget/btn_close_selected.png");//VOXOX CHANGE by Rolando - 2009.08.25 

		painter->setPen(_fontColor);//VOXOX CHANGE by Rolando - 2009.09.07 
	} else {
		closeButtonPixmap = QPixmap(":/pics/chat/umtreewidget/btn_close_nonselected.png");//VOXOX CHANGE by Rolando - 2009.08.25 
		painter->setPen(_fontColor);//VOXOX CHANGE by Rolando - 2009.09.07 
	}

	//VOXOX CHANGE by Rolando - 2009.08.25 - painting the close button	
	_posXCloseButton = r.right() - closeButtonPixmap.width() - 5;//VOXOX CHANGE by Rolando - 2009.09.16 
	int centeredCloseButton_y = ((r.bottom() - r.top()) - closeButtonPixmap.size().height()) / 2;	
	painter->drawPixmap(_posXCloseButton, r.top() + centeredCloseButton_y, closeButtonPixmap);

	_posYCloseButton = r.top() + centeredCloseButton_y;
	_widthCloseButton =  closeButtonPixmap.width();//VOXOX CHANGE by Rolando - 2009.08.27
	_heightCloseButton = closeButtonPixmap.height();//VOXOX CHANGE by Rolando - 2009.08.27 	
	
}
Пример #2
0
void QtTreeViewDelegate::drawGroup(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const 
{
	QtContactListStyle * contactListStyle = QtContactListStyle::getInstance();
	painter->setPen(contactListStyle->getGroupFontColor());
	painter->drawPixmap(option.rect.left(),option.rect.top(),getGroupBackGround(option.rect,option));

	QFont font = option.font;
	painter->setFont(font);

	QPixmap px;
	if (option.state & QStyle::State_Open) 
	{
		px = contactListStyle->getGroupPixmapOpen();
	} 
	else 
	{
		px = contactListStyle->getGroupPixmapClose();
	}

	int x = option.rect.left();
	QRect r = option.rect;
	painter->drawPixmap(x, r.top() + 3, px);
	x += px.width() + 3;
	r.setLeft(x);
	int y = ((r.bottom()-r.top())-QFontMetrics(font).height())/2;
	r.setTop(y + r.top());
	r.setLeft(r.left() + 10);

	//VOXOX - JRT - 2009.05.04 -TODO: this is all business logic that should not be here.
	//	We should have a simple getGroupText() method that provides this.
	QString groupName;
	std::string groupId;
	std::string groupNameTmp;
	std::string groupContactsOnline;

	if (index.data().toString() == QtContactList::DEFAULT_GROUP_NAME) 
	{
		//VOXOX - JRT - 2009.09.03 - Add 0/0 for this special group.
		int total  = 0;
		int online = 0;

		_cWengoPhone.getCUserProfileHandler().getCUserProfile()->getCContactList().getContactList().getCounts( total, online );
		groupContactsOnline = " (" + String::fromNumber( online ) + "/" + String::fromNumber( total ) + ")";

		//VOXOX CHANGE CJC - We don't want to show ContactList when groups are hidden. We can't remove group, so just remove name.
		groupName    = tr("All");
		groupNameTmp = std::string(groupName.toUtf8().data());
	} 
	else 
	{
		groupName			= index.data().toString();
		groupId				= groupName.toStdString();
		groupNameTmp		= _cWengoPhone.getCUserProfileHandler().getCUserProfile()->getCContactList().getContactGroupName(groupId);
		groupContactsOnline = _cWengoPhone.getCUserProfileHandler().getCUserProfile()->getCContactList().getContactGroupContactsOnline(groupId);
	}

	groupName = QString::fromUtf8(groupNameTmp.c_str(), groupNameTmp.size()) + QString::fromUtf8(groupContactsOnline.c_str(), groupContactsOnline.size());
	//End business logic.

	QString str = groupName;
	painter->drawText(r, Qt::AlignLeft, str, 0);
}