Okay, so I sent in a patch and got some feedback. All the changes requested were pretty minor, and are listed below:

  1. Remove excessive debug code
  2. Use static_cast around iterator dereferences
  3. Formatting changed to remain consistent with the remainder of the file.

As for #3, I noticed that some of files have the vim block in there somewhere. I also noticed that kdepim folks actually started making their codebase a little more friendly for emacs users (such as myself). For that purpose, I've attached to this the .emacs-dirvar file that I've used in all of the folders to this email. I'm not sure if there's a better way to do it or not. I have no interest in messing up formatting of code, and I know some folks are rather serious about making sure the files are using consistent formatting. Fair enough. I'll do what I can to respect that.

Without further ado, the patch is attached to this message. No functional changes were made. Enjoy.

--

~ Michael D. Stemle, Jr. <><

(A)bort, (R)etry, (I)nfluence with large hammer

Index: kopete/contactlist/kopetecontactlistview.h
===================================================================
--- kopete/contactlist/kopetecontactlistview.h	(revision 564994)
+++ kopete/contactlist/kopetecontactlistview.h	(working copy)
@@ -180,6 +180,8 @@
 
 	void slotTimeout();
 
+	void slotMakeMetaContact();
+
 private:
 	bool mShowAsTree;
 
@@ -206,6 +208,7 @@
 	KAction *actionProperties;
 	KAction *actionUndo;
 	KAction *actionRedo;
+	KAction *actionMakeMetaContact;
 
 	KopeteContactListViewPrivate *d;
 
Index: kopete/contactlist/kopetecontactlistview.cpp
===================================================================
--- kopete/contactlist/kopetecontactlistview.cpp	(revision 564994)
+++ kopete/contactlist/kopetecontactlistview.cpp	(working copy)
@@ -495,6 +495,9 @@
 	actionCopy = new KopeteGroupListAction( i18n( "&Copy To" ), QLatin1String( "editcopy" ), 0,
 														 this, SLOT( slotCopyToGroup() ), ac, "contactCopy" );
 
+	actionMakeMetaContact = KopeteStdAction::makeMetaContactFromSelected(this, SLOT(slotMakeMetaContact()),
+									     ac, "makeMetaContact");
+
 	actionRemove = KopeteStdAction::deleteContact( this, SLOT( slotRemove() ),
 		ac, "contactRemove" );
 	actionSendEmail = new KAction( KIcon("mail_generic"), i18n( "Send Email..." ), ac, "contactSendEmail" );
@@ -1449,6 +1452,9 @@
 		actionRename->setEnabled(false);
 		actionRemove->setEnabled(contacts.count()+groups.count());
 		actionAddContact->setEnabled(false);
+
+		actionMakeMetaContact->setText(i18n("Make Meta Contact"));
+		actionMakeMetaContact->setEnabled(contacts.count()); // Specifically for multiple contacts, not groups.
 	}
 
 	actionMove->setCurrentItem( -1 );
@@ -1878,7 +1884,6 @@
 	undoTimer.start(10*60*1000);
 }
 
-
 void KopeteContactListView::slotUndo()
 {
 	bool step = false;
@@ -2187,6 +2192,28 @@
 	actionRedo->setEnabled(false);
 }
 
+void KopeteContactListView::slotMakeMetaContact()
+{
+    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 = static_cast<Kopete::MetaContact*>(*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 564994)
+++ 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 564994)
+++ libkopete/kopetemetacontact.cpp	(working copy)
@@ -125,6 +125,21 @@
 	}
 }
 
+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 = static_cast<Kopete::Contact*>(*theContact);
+        one->setMetaContact(this);
+        count += 1;
+    }
+
+    return count;
+}
+
 void MetaContact::updateOnlineStatus()
 {
 	Kopete::OnlineStatus::StatusType newStatus = Kopete::OnlineStatus::Unknown;
Index: libkopete/kopetemetacontact.h
===================================================================
--- libkopete/kopetemetacontact.h	(revision 564994)
+++ 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 564994)
+++ libkopete/ui/kopetestdaction.h	(working copy)
@@ -63,6 +63,11 @@
 	static KAction *changeMetaContact(const QObject *recvr, const char *slot,
 		KActionCollection* parent, const char *name = 0);
 	/**
+	 * Make meta contact from selected contacts.
+	 */
+	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 564994)
+++ libkopete/ui/kopetestdaction.cpp	(working copy)
@@ -109,6 +109,11 @@
 	return createAction( i18n( "Cha&nge Meta Contact..." ), KIcon( "move" ), recvr, slot, parent, name );
 }
 
+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 );
;; -*- emacs-lisp -*-
;;
;; This file is processed by the dirvars emacs package.  Each variable
;; setting below is performed when this dirvars file is loaded.
;;
indent-tabs-mode: nil
tab-width: 4
c-basic-offset: 4
evaluate: (c-set-offset 'innamespace '0)
_______________________________________________
kopete-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kopete-devel

Reply via email to