Example #1
0
void OptionsWidget_identityProfile::editProfileEntry()
{
	QTreeWidgetItem * pItem = (QTreeWidgetItem *)m_pTreeWidget->currentItem();
	if(!pItem)
		return;

	// Fill in the editor data
	KviIdentityProfile profile;
	profile.setName(pItem->text(0));
	profile.setNetwork(pItem->text(1));
	profile.setNick(pItem->text(2));
	profile.setAltNick(pItem->text(3));
	profile.setUserName(pItem->text(4));
	profile.setRealName(pItem->text(5));

	m_iCurrentEditedProfile=m_pTreeWidget->indexOfTopLevelItem(pItem);

	if(m_pEditor)
		delete m_pEditor;
	m_pEditor = new IdentityProfileEditor(this);
	if(m_pEditor->editProfile(&profile))
	{
		pItem->setText(0,profile.name());
		pItem->setText(1,profile.network());
		pItem->setText(2,profile.nick());
		pItem->setText(3,profile.altNick());
		pItem->setText(4,profile.userName());
		pItem->setText(5,profile.realName());
	}
}
Example #2
0
void OptionsWidget_identityProfile::addProfileEntry()
{
	KviIdentityProfile profile;
	m_iCurrentEditedProfile = -1;

	if(m_pEditor)
		delete m_pEditor;
	m_pEditor = new IdentityProfileEditor(this);

	if(m_pEditor->editProfile(&profile))
	{
		QTreeWidgetItem * pItem = new QTreeWidgetItem(m_pTreeWidget);
		pItem->setText(0,profile.name());
		pItem->setText(1,profile.network());
		pItem->setText(2,profile.nick());
		pItem->setText(3,profile.altNick());
		pItem->setText(4,profile.userName());
		pItem->setText(5,profile.realName());
	}
}
Example #3
0
OptionsWidget_identityProfile::OptionsWidget_identityProfile(QWidget * pParent)
: KviOptionsWidget(pParent)
{
	setObjectName("identity_profiles_option_widget");
	m_pEditor = 0;
	m_iCurrentEditedProfile = -1;

	createLayout();
	QGridLayout * pLayout = layout();

	KviIdentityProfileSet * pSet = KviIdentityProfileSet::instance();
	bool bEnabled = pSet ? (pSet->isEnabled() && !pSet->isEmpty()) : false;

	m_pProfilesCheck = new QCheckBox(__tr2qs_ctx("Enable Network Profiles","options"),this);
	KviTalToolTip::add(m_pProfilesCheck,__tr2qs_ctx("This check enables the use of network profiles","options"));
	m_pProfilesCheck->setChecked(bEnabled);
	pLayout->addWidget(m_pProfilesCheck,0,0,1,3);
	connect(m_pProfilesCheck,SIGNAL(toggled(bool)),this,SLOT(toggleControls()));

	// Profiles list
	m_pTreeWidget = new QTreeWidget(this);
	m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	m_pTreeWidget->setAllColumnsShowFocus(true);

	QStringList labels;
	labels.append(__tr2qs_ctx("Name","options"));
	labels.append(__tr2qs_ctx("Network","options"));
	labels.append(__tr2qs_ctx("Nickname","options"));
	labels.append(__tr2qs_ctx("Alt. Nick","options"));
	labels.append(__tr2qs_ctx("Username","options"));
	labels.append(__tr2qs_ctx("Realname","options"));
	m_pTreeWidget->setHeaderLabels(labels);

	KviTalToolTip::add(m_pTreeWidget, \
		__tr2qs_ctx("<center>This is a set of rules to use profiles." \
			"KVIrc will use them to handle the user connection " \
			"data before the data is sent to the IRC server.<br>" \
			"This is useful if a user wants to use different data " \
			"on different networks without changing them at every " \
			"connection attempt.","options"));
	pLayout->addWidget(m_pTreeWidget,1,0,1,3);
	connect(m_pTreeWidget,SIGNAL(itemSelectionChanged()),this,SLOT(toggleControls()));

	// Buttons box
	KviTalHBox * pBtnBox = new KviTalHBox(this);
	pLayout->addWidget(pBtnBox,2,0);

	m_pBtnAddProfile = new QPushButton(__tr2qs_ctx("Add Profile","options"),pBtnBox);
	connect(m_pBtnAddProfile,SIGNAL(clicked()),this,SLOT(addProfileEntry()));

	m_pBtnEditProfile = new QPushButton(__tr2qs_ctx("Edit Profile","options"),pBtnBox);
	connect(m_pBtnEditProfile,SIGNAL(clicked()),this,SLOT(editProfileEntry()));

	m_pBtnDelProfile = new QPushButton(__tr2qs_ctx("Delete Profile","options"),pBtnBox);
	connect(m_pBtnDelProfile,SIGNAL(clicked()),this,SLOT(delProfileEntry()));

	// Fill in the treewidget
	if(pSet && pSet->profiles())
	{
		QTreeWidgetItem * pItem;
		KviPointerList<KviIdentityProfile> * pList = pSet->profiles();
		for(KviIdentityProfile * pProfile = pList->first(); pProfile; pProfile = pList->next())
		{
			pItem = new QTreeWidgetItem(m_pTreeWidget);
			pItem->setText(0,pProfile->name());
			pItem->setText(1,pProfile->network());
			pItem->setText(2,pProfile->nick());
			pItem->setText(3,pProfile->altNick());
			pItem->setText(4,pProfile->userName());
			pItem->setText(5,pProfile->realName());
		}
	}

	toggleControls();
}