[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/kopete
From: Roman Jarosz <kedgedev () gmail ! com>
Date: 2009-04-02 21:32:49
Message-ID: 1238707969.174532.5887.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 948387 by rjarosz:
Allow user to move/copy metaContact from menu.
M +6 -1 contactlist/contactlisttreemodel.cpp
M +69 -7 contactlist/kopetecontactlistview.cpp
M +2 -0 contactlist/kopetecontactlistview.h
M +21 -11 contactlist/kopetegrouplistaction.cpp
M +0 -2 contactlist/kopetegrouplistaction.h
M +1 -0 contactlist/kopeteitembase.h
M +8 -1 kopeteui.rc
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/contactlisttreemodel.cpp \
#948386:948387 @@ -317,7 +317,12 @@
}
if ( mcmi )
- return metaContactData( mcmi->metaContact(), role );
+ {
+ if ( role == Kopete::Items::MetaContactGroupRole )
+ return qVariantFromValue( (QObject*)mcmi->parent()->group() );
+ else
+ return metaContactData( mcmi->metaContact(), role );
+ }
return QVariant();
}
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopetecontactlistview.cpp \
#948386:948387 @@ -165,13 +165,12 @@
d->actionStartChat = KopeteStdAction::chat( this, SLOT(startChat()), ac );
ac->addAction( "contactStartChat", d->actionStartChat );
-// FIXME: Do we need this with drag&drop support?
-// d->actionMove = new KopeteGroupListAction( i18n( "&Move To" ), QLatin1String( \
"edit-cut" ),
-// KShortcut(), this, SLOT( \
slotMoveToGroup() ), ac );
-// ac->addAction( "contactMove", d->actionMove );
-// d->actionCopy = new KopeteGroupListAction( i18n( "&Copy To" ), QLatin1String( \
"edit-copy" ),
-// KShortcut(), this, SLOT( \
slotCopyToGroup() ), ac );
-// ac->addAction( "contactCopy", d->actionCopy );
+ d->actionMove = new KopeteGroupListAction( i18n( "&Move To" ), QLatin1String( \
"edit-cut" ), + KShortcut(), this, \
SLOT( moveToGroup() ), ac ); + ac->addAction( "contactMove", d->actionMove );
+ d->actionCopy = new KopeteGroupListAction( i18n( "&Copy To" ), QLatin1String( \
"edit-copy" ), + KShortcut(), this, \
SLOT( copyToGroup() ), ac ); + ac->addAction( "contactCopy", d->actionCopy );
d->actionMakeMetaContact = new KAction(KIcon("list-add-user"), i18n("Merge Meta \
Contacts"), ac); ac->addAction( "makeMetaContact", d->actionMakeMetaContact );
@@ -425,6 +424,69 @@
Kopete::ContactList::self()->removeGroup( group );
}
+void KopeteContactListView::moveToGroup()
+{
+ Q_ASSERT(model());
+ QModelIndexList indexList = selectedIndexes();
+ if ( indexList.count() != 1 )
+ return;
+
+ QModelIndex index = indexList.first();
+ if ( index.data( Kopete::Items::TypeRole ) == Kopete::Items::MetaContact && \
d->actionMove->currentAction() ) + {
+ Kopete::MetaContact* metaContact = metaContactFromIndex( index );
+ foreach( Kopete::Contact *c, metaContact->contacts() )
+ {
+ if ( !c->account()->isConnected() )
+ return; // Some contact is offline we can't move it
+ }
+
+ bool ok = false;
+ uint groupId = d->actionMove->currentAction()->data().toUInt( &ok );
+ if ( !ok )
+ return;
+
+ Kopete::Group *toGroup = Kopete::ContactList::self()->group( groupId );
+ if ( !toGroup )
+ return;
+
+ QObject* groupObject = qVariantValue<QObject*>( index.data( \
Kopete::Items::MetaContactGroupRole ) ); + Kopete::Group* fromGroup = \
qobject_cast<Kopete::Group*>(groupObject); +
+ metaContact->moveToGroup( fromGroup, toGroup );
+ }
+}
+
+void KopeteContactListView::copyToGroup()
+{
+ Q_ASSERT(model());
+ QModelIndexList indexList = selectedIndexes();
+ if ( indexList.count() != 1 )
+ return;
+
+ QModelIndex index = indexList.first();
+ if ( index.data( Kopete::Items::TypeRole ) == Kopete::Items::MetaContact && \
d->actionCopy->currentAction() ) + {
+ Kopete::MetaContact* metaContact = metaContactFromIndex( index );
+ foreach( Kopete::Contact *c, metaContact->contacts() )
+ {
+ if ( !c->account()->isConnected() )
+ return; // Some contact is offline we can't copy it
+ }
+
+ bool ok = false;
+ uint groupId = d->actionCopy->currentAction()->data().toUInt( &ok );
+ if ( !ok )
+ return;
+
+ Kopete::Group *toGroup = Kopete::ContactList::self()->group( groupId );
+ if ( !toGroup )
+ return;
+
+ metaContact->addToGroup( toGroup );
+ }
+}
+
void KopeteContactListView::startChat()
{
Kopete::MetaContact* metaContact = metaContactFromIndex( currentIndex() );
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopetecontactlistview.h \
#948386:948387 @@ -84,6 +84,8 @@
void sendEmail();
void addTemporaryContact();
void removeGroupOrMetaContact();
+ void moveToGroup();
+ void copyToGroup();
Q_SIGNALS:
void visibleContentHeightChanged();
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopetegrouplistaction.cpp \
#948386:948387 @@ -49,21 +49,31 @@
void KopeteGroupListAction::slotUpdateList()
{
- QStringList groupList;
+ QMap<QString, uint> groupMap;
- // Add groups to our list
- QList<Kopete::Group*> groups = Kopete::ContactList::self()->groups();
- QList<Kopete::Group*>::iterator it, itEnd = groups.end();
- for ( it = groups.begin(); it != itEnd; ++it )
+ // Add groups to our map
+ foreach ( const Kopete::Group* group, Kopete::ContactList::self()->groups() )
{
- if((*it)->type() == Kopete::Group::Normal)
- groupList.append( (*it)->displayName() );
+ if( group->type() == Kopete::Group::Normal )
+ groupMap.insertMulti( group->displayName(), group->groupId() ); // Use \
insertMulti to be safer }
- groupList.sort();
- groupList.prepend(QString::null); //add a separator; //krazy:exclude=nullstrassign \
for old broken gcc
- groupList.prepend( i18n("Top Level") ); //the top-level group, with the id 0
- setItems( groupList );
+ clear();
+
+ KAction* topLevelAction = addAction( Kopete::Group::topLevel()->displayName() );
+ topLevelAction->setData( Kopete::Group::topLevel()->groupId() );
+
+ QAction* separator = new QAction( this );
+ separator->setSeparator( true );
+ addAction( separator );
+
+ QMapIterator<QString, uint> it( groupMap );
+ while ( it.hasNext() )
+ {
+ it.next();
+ QAction* action = addAction( it.key() );
+ action->setData( it.value() );
+ }
}
#include "kopetegrouplistaction.moc"
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopetegrouplistaction.h \
#948386:948387 @@ -34,8 +34,6 @@
protected slots:
void slotUpdateList();
-private:
- QStringList m_groupList;
};
#endif // KOPETEGROUPLISTACTION_H
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopeteitembase.h #948386:948387
@@ -50,6 +50,7 @@
const int ObjectRole = Qt::UserRole + 112;
const int ExpandStateRole = Qt::UserRole + 113;
const int HasNewMessageRole = Qt::UserRole + 114;
+ const int MetaContactGroupRole = Qt::UserRole + 115;
/* Item type role values */
enum Type { Group, MetaContact };
--- trunk/KDE/kdenetwork/kopete/kopete/kopeteui.rc #948386:948387
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui>
-<kpartgui name="kopete" version="27">
+<kpartgui name="kopete" version="28">
<MenuBar>
<Menu name="file" noMerge="1">
<text>&File</text>
@@ -19,6 +19,8 @@
<Action name="contactStartChat" />
<Action name="contactSendFile" />
<Separator lineSeparator="true" />
+ <Action name="contactMove" />
+ <Action name="contactCopy" />
<Action name="contactAddContact" />
<Action name="contactAddTemporaryContact" />
<Action name="contactRemove" />
@@ -66,6 +68,11 @@
<Action name="contactSyncKABC"/>
</Menu>
<Separator lineSeparator="true" />
+ <Menu name="contact_popup_groups">
+ <text>&Groups</text>
+ <Action name="contactMove" />
+ <Action name="contactCopy" />
+ </Menu>
<Action name="contactAddContact" />
<Action name="contactAddTemporaryContact" />
<Action name="contactRemove" />
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic