QString ExchangeApproveDialog::contactName(const Jid &AContactJid, bool AWithJid) const
{
	IRosterItem ritem = FRoster->findItem(AContactJid);
	QString name = !ritem.name.isEmpty() ? ritem.name : AContactJid.uBare();
	if (AWithJid && !ritem.name.isEmpty())
		name = QString("%1 <%2>").arg(name,AContactJid.uBare());
	return name;
}
EditBookmarksDialog::EditBookmarksDialog(IBookmarks *ABookmarks, const Jid &AStreamJid, const QList<IBookmark> &AList, QWidget *AParent) : QDialog(AParent)
{
	REPORT_VIEW;
	ui.setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose,true);
	setWindowTitle(tr("Edit bookmarks - %1").arg(AStreamJid.uBare()));
	IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(this,MNI_BOOKMARKS_EDIT,0,0,"windowIcon");

	FBookmarks = ABookmarks;
	FStreamJid = AStreamJid;

	ui.tbwBookmarks->setRowCount(AList.count());
	for (int row=0; row<AList.count(); ++row)
	{
		IBookmark bookmark = AList.at(row);
		setBookmarkToRow(row,bookmark);
	}

	QHeaderView *header = ui.tbwBookmarks->horizontalHeader();
	header->setSectionsClickable(true);
	header->setSectionResizeMode(COL_NAME,QHeaderView::ResizeToContents);
	header->setSectionResizeMode(COL_VALUE,QHeaderView::Stretch);
	header->setSectionResizeMode(COL_NICK,QHeaderView::ResizeToContents);
	header->hideSection(COL_SORT);
	connect(header,SIGNAL(sectionClicked(int)),SLOT(onSortingStateChange(int)));

	connect(ui.pbtAdd,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtEdit,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtDelete,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtMoveUp,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtMoveDown,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.bbxButtons,SIGNAL(accepted()),SLOT(onDialogAccepted()));

	connect(ui.tbwBookmarks,SIGNAL(itemDoubleClicked(QTableWidgetItem *)),SLOT(onTableItemDoubleClicked(QTableWidgetItem *)));
}
SubscriptionDialog::SubscriptionDialog(IRosterChanger *ARosterChanger, const Jid &AStreamJid, const Jid &AContactJid,
	const QString &ANotify, const QString &AMessage, QWidget *AParent) : QDialog(AParent)
{
	REPORT_VIEW;
	ui.setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose,true);
	setWindowTitle(tr("Subscription request - %1").arg(AStreamJid.uBare()));
	IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(this,MNI_RCHANGER_SUBSCRIBTION,0,0,"windowIcon");

	FStreamJid = AStreamJid;
	FContactJid = AContactJid;
	FRosterChanger = ARosterChanger;

	QToolBar *toolBar = new QToolBar(this);
	toolBar->setIconSize(QSize(16,16));
	ui.lytMainLayout->setMenuBar(toolBar);
	FToolBarChanger = new ToolBarChanger(toolBar);

	ui.lblNotify->setText(ANotify);
	if (!AMessage.isEmpty())
		ui.lblMessage->setText(AMessage);
	else
		ui.lblMessage->setVisible(false);

	connect(ui.btbDialogButtons,SIGNAL(accepted()),SLOT(onDialogAccepted()));
	connect(ui.btbDialogButtons,SIGNAL(rejected()),SLOT(onDialogRejected()));

	initialize();
}