示例#1
0
//static
bool KexiContextMenuUtils::updateTitle(QPopupMenu *menu, const QString& objectName, 
	const QString& objectTypeName, const QString& iconName)
{
	if (!menu || objectName.isEmpty() || objectTypeName.isEmpty())
		return false;
	const int id = menu->idAt(0);
	QMenuItem *item = menu->findItem(id);
	if (!item)
		return false;
	KPopupTitle *title = dynamic_cast<KPopupTitle *>(item->widget());
	if (!title)
		return false;

/*! @todo look at makeFirstCharacterUpperCaseInCaptions setting [bool]
 (see doc/dev/settings.txt) */
	QString realTitle( i18n("Object name : Object type", "%1 : %2")
		.arg( objectName[0].upper() + objectName.mid(1) )
		.arg( objectTypeName ));

	if (iconName.isEmpty())
		title->setTitle(realTitle);
	else {
		QPixmap pixmap(SmallIcon( iconName ));
		title->setTitle(realTitle, &pixmap);
	}
	return true;
}
示例#2
0
// Obsolete
void KPopupMenu::setTitle(const QString &title)
{
    KPopupTitle *titleItem = new KPopupTitle();
    titleItem->setTitle(title);
    insertItem(titleItem);
    d->m_lastTitle = title;
}
示例#3
0
int KPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id,
                            int index)
{
    KPopupTitle *titleItem = new KPopupTitle();
    titleItem->setTitle(text, &icon);
    return(insertItem(titleItem, id, index));
}