[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    [kopete-devel] Proposed Changes: MetaContact Enhancements
From:       "Michael D. Stemle, Jr." <manchicken () notsosoft ! net>
Date:       2006-07-21 2:39:47
Message-ID: 200607202139.47510.manchicken () notsosoft ! net
[Download RAW message or body]

Hey all.  I propose the attached changes (based on SVN r564619) for kopete.  
With these changes you can select multiple contacts in your list, 
right-click, and then click the new "Make Meta Contact" context-menu item.  
This will bypass the existing metacontact dialog (though it doesn't replace 
it).  I've verified these changes on my machine.

I've also added the function 
Kopete::MetaContact::stealContactsFromMetaContact(Kopete::MetaContact *mc) so 
that you can steal the contacts from another meta-contact.  Not sure how 
useful this will be, but I didn't like the idea of putting it all into 
kopetecontactlistview.cpp...

Anyway, attached is the output from svn diff.  If you would prefer another 
format, please let me know.  Thanks!
-- 
~ Michael D. Stemle, Jr. <><
(A)bort, (R)etry, (I)nfluence with large hammer

["2006-07-02-metacontact-enhancements.svn-diffs" (text/x-diff)]

Index: kopete/contactlist/kopetecontactlistview.h
===================================================================
--- kopete/contactlist/kopetecontactlistview.h	(revision 564619)
+++ kopete/contactlist/kopetecontactlistview.h	(working copy)
@@ -180,6 +180,9 @@
 
 	void slotTimeout();
 
+	// BOK: For making meta contacts
+	void slotMakeMetaContact();
+
 private:
 	bool mShowAsTree;
 
@@ -206,6 +209,8 @@
 	KAction *actionProperties;
 	KAction *actionUndo;
 	KAction *actionRedo;
+	// BOK: Adding metacontact stuff.
+	KAction *actionMakeMetaContact;
 
 	KopeteContactListViewPrivate *d;
 
Index: kopete/contactlist/kopetecontactlistview.cpp
===================================================================
--- kopete/contactlist/kopetecontactlistview.cpp	(revision 564619)
+++ kopete/contactlist/kopetecontactlistview.cpp	(working copy)
@@ -495,6 +495,11 @@
 	actionCopy = new KopeteGroupListAction( i18n( "&Copy To" ), QLatin1String( \
"editcopy" ), 0,  this, SLOT( slotCopyToGroup() ), ac, "contactCopy" );
 
+	//BOK: Added slot for making meta contacts
+	actionMakeMetaContact = KopeteStdAction::makeMetaContactFromSelected(this, \
SLOT(slotMakeMetaContact()), +									     ac, "makeMetaContact");
+	  //	connect(actionMakeMetaContact, SIGNAL(triggered(bool)), this, \
SLOT(slotMakeMetaContact())); +
 	actionRemove = KopeteStdAction::deleteContact( this, SLOT( slotRemove() ),
 		ac, "contactRemove" );
 	actionSendEmail = new KAction( KIcon("mail_generic"), i18n( "Send Email..." ), ac, \
"contactSendEmail" ); @@ -1444,11 +1449,18 @@
 	}
 	else
 	{
+	  // BOK: manchicken -- ADD META-CONTACT ACTION HERE
 		actionRename->setText(i18n("Rename"));
 		actionRemove->setText(i18n("Remove"));
 		actionRename->setEnabled(false);
 		actionRemove->setEnabled(contacts.count()+groups.count());
 		actionAddContact->setEnabled(false);
+
+		kDebug( 14000 ) << "BOK BOK BAGAWK!!: Trying to create meta contact for " << \
contacts.count() << " contacts!" << endl; +		
+		// Add Make Meta Contact to the drop-down.
+		actionMakeMetaContact->setText(i18n("Make Meta Contact"));
+		actionMakeMetaContact->setEnabled(contacts.count()); // Specifically for multiple \
contacts, not groups.  }
 
 	actionMove->setCurrentItem( -1 );
@@ -1878,7 +1890,6 @@
 	undoTimer.start(10*60*1000);
 }
 
-
 void KopeteContactListView::slotUndo()
 {
 	bool step = false;
@@ -2187,6 +2198,29 @@
 	actionRedo->setEnabled(false);
 }
 
+void KopeteContactListView::slotMakeMetaContact() {
+  kDebug(14000) << "BOK BOK BAGAWK!!!" << k_funcinfo << endl;
+
+  QList<Kopete::MetaContact*> contacts = \
Kopete::ContactList::self()->selectedMetaContacts(); +  \
QList<Kopete::MetaContact*>::iterator cit, citEnd = contacts.end(); +  \
Kopete::MetaContact * first = (Kopete::MetaContact *) NULL; +
+  // Iterate through the selected contacts.
+  for( cit = contacts.begin(); cit != citEnd; ++cit ) {
+    Kopete::MetaContact* mc = (*cit);
+
+    if (!first) {
+      // Grab the first one.
+      first = mc;
+    } else {
+      // Have the first of all in the selected contacts steal the contacts from all \
the others. +      first->stealContactsFromMetaContact(mc);
+    }
+  }
+
+  return;
+}
+
 #include "kopetecontactlistview.moc"
 
 // vim: set noet ts=4 sts=4 sw=4:
Index: kopete/kopeteui.rc
===================================================================
--- kopete/kopeteui.rc	(revision 564619)
+++ kopete/kopeteui.rc	(working copy)
@@ -94,6 +94,8 @@
 		<Action name="contactProperties" />
 	</Menu>
 	<Menu name="contactlistitems_popup">
+		<Action name="makeMetaContact" />
+		<Separator lineSeparator="false"/>
 		<Action name="contactRemove" />
 	</Menu>
 	<Menu name="contactlist_popup">
Index: libkopete/kopetemetacontact.cpp
===================================================================
--- libkopete/kopetemetacontact.cpp	(revision 564619)
+++ libkopete/kopetemetacontact.cpp	(working copy)
@@ -125,6 +125,20 @@
 	}
 }
 
+int MetaContact::stealContactsFromMetaContact(MetaContact *mc) {
+  QList<Kopete::Contact*> foreignList = mc->contacts();
+  QList<Kopete::Contact *>::iterator theContact, stopit = foreignList.end();
+  int count = 0;
+
+  for (theContact = foreignList.begin(); theContact != stopit; ++theContact) {
+    Kopete::Contact *one = (*theContact);
+    one->setMetaContact(this);
+    count += 1;
+  }
+
+  return count;
+}
+
 void MetaContact::updateOnlineStatus()
 {
 	Kopete::OnlineStatus::StatusType newStatus = Kopete::OnlineStatus::Unknown;
Index: libkopete/kopetecontact.cpp
===================================================================
--- libkopete/kopetecontact.cpp	(revision 564619)
+++ libkopete/kopetecontact.cpp	(working copy)
@@ -325,6 +325,8 @@
 
 void Contact::setMetaContact( MetaContact *m )
 {
+  kDebug(14000) << "BOK BOK BAGAWK!!!" << k_funcinfo << endl;
+
 	MetaContact *old = d->metaContact;
 	if(old==m) //that make no sens
 		return;
Index: libkopete/kopetemetacontact.h
===================================================================
--- libkopete/kopetemetacontact.h	(revision 564619)
+++ libkopete/kopetemetacontact.h	(working copy)
@@ -287,6 +287,12 @@
 	void addContact( Contact *c );
 
 	/**
+	 * @brief Add all contacts from a MetaContact to this meta-contact.
+	 * @param mc The MetaContact to add contacts from.
+	 */
+	int stealContactsFromMetaContact(MetaContact *mc);
+
+	/**
 	 * @brief remove the contact from this metacontact
 	 *
 	 * set 'deleted' to true if the Contact is already deleted
Index: libkopete/ui/kopetestdaction.h
===================================================================
--- libkopete/ui/kopetestdaction.h	(revision 564619)
+++ libkopete/ui/kopetestdaction.h	(working copy)
@@ -63,6 +63,12 @@
 	static KAction *changeMetaContact(const QObject *recvr, const char *slot,
 		KActionCollection* parent, const char *name = 0);
 	/**
+	 * Make meta contact from selected contacts.
+	 * BOK: UNUSED!!! Do I really need it here?
+	 */
+	static KAction *makeMetaContactFromSelected( const QObject *recvr, const char \
*slot, +						     KActionCollection* parent, const char *name = 0);
+	/**
 	 * Standard action to add a group
 	 */
 	static KAction *addGroup(const QObject *recvr, const char *slot,
Index: libkopete/ui/kopetestdaction.cpp
===================================================================
--- libkopete/ui/kopetestdaction.cpp	(revision 564619)
+++ libkopete/ui/kopetestdaction.cpp	(working copy)
@@ -109,6 +109,12 @@
 	return createAction( i18n( "Cha&nge Meta Contact..." ), KIcon( "move" ), recvr, \
slot, parent, name );  }
 
+// BOK: Added standard action for making meta contact.
+KAction * KopeteStdAction::makeMetaContactFromSelected( const QObject *recvr, const \
char *slot, KActionCollection* parent, const char *name) +{
+  return createAction(i18n("Make Meta Contact..."), \
KIcon("move"),recvr,slot,parent,name); +}
+
 KAction * KopeteStdAction::deleteContact( const QObject *recvr, const char *slot, \
KActionCollection* parent, const char *name )  {
 	KAction *deleteAction = createAction( i18n( "&Delete Contact" ), KIcon( \
"delete_user" ), recvr, slot, parent, name );



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic