Here is updated patch which apply on kopete from trunk. On Sunday 04 July 2010 02:14:47 Raphael Kubo da Costa wrote: > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > http://reviewboard.kde.org/r/2179/#review6362 > ----------------------------------------------------------- > > > Well, nobody has given a NACK yet, so I presume this is a tacit ACK :) > > Does this patch still apply fine to trunk? It'd be good to apply it now that > trunk is unfrozen for SC 4.6. > > - Raphael > > On 2009-11-18 04:12:17, Barry Carter wrote: > > ----------------------------------------------------------- > > This is an automatically generated e-mail. To reply, visit: > > http://reviewboard.kde.org/r/2179/ > > ----------------------------------------------------------- > > > > (Updated 2009-11-18 04:12:17) > > > > > > Review request for Kopete. > > > > > > Summary > > ------- > > > > This patch allows a new configuration option to be set which will show all > > offline users grouped into a folder called "Offline Users". > > > > When a contact comes online, the metacontact is removed from the offline > > group, and added to the normal group folder. Likewise when the contact > > goes offline, the contact is added to the offline users folder. > > > > Rules: > > If "Show Offline" is set, then the offline folder group is removed from > > view. If a search is in progress, the offline folder is removed from > > view. Using the proxyfilter lessThan, the Offline folder is always pushed > > to the bottom of the list. > > > > Protection: > > Removed right click access to the folder so no renaming etc can be done > > (wise?). Removed ability for a user to move a contact to the offline > > folder. > > > > Side Effects: > > The offline users folder is always visible even when not connected to a > > network. > > > > Implementation: > > The offline folder is a "special" group like temporary or toplevel. This > > allows it to hide away from the group menus while still being filterable. > > > > Future: > > Assuming anyone is interested in this feature, there are a couple of > > cosmetic changes that might be made. One is... The offline folder will > > never have an online contact, so instead of showing "Offline Users > > (0/1000)" it could be abbreviated to "Offline Users (1000)" > > > > Questions: > > If we simply call the folder "Offline" would we get better i18n? > > Is there a better way to do this? > > > > built against 0.80.2 > > > > > > Diffs > > ----- > > > > /branches/KDE/4.3/kdenetwork/kopete/kopete/config/appearance/appearancec > > onfig_contactlist.ui 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/kopete/contactlist/contactlistproxy > > model.cpp 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/kopete/contactlist/contactlisttreem > > odel.cpp 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/kopete/contactlist/kopetecontactlis > > tview.cpp 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/kopete/contactlist/kopeteitemdelega > > te.cpp 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/libkopete/contactlist/kopetecontact > > liststorage.cpp 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/libkopete/contactlist/xmlcontactsto > > rage.cpp 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/libkopete/kopeteappearancesettings. > > kcfg 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/libkopete/kopetecontactlist.cpp > > 1046954 /branches/KDE/4.3/kdenetwork/kopete/libkopete/kopetegroup.h > > 1046954 /branches/KDE/4.3/kdenetwork/kopete/libkopete/kopetegroup.cpp > > 1046954 > > /branches/KDE/4.3/kdenetwork/kopete/libkopete/kopetemetacontact.cpp > > 1046954> > > Diff: http://reviewboard.kde.org/r/2179/diff > > > > > > Testing > > ------- > > > > Tested against 0.80.2 in /branches/KDE/4.3/kdenetwork/ > > > > > > Screenshots > > ----------- > > > > Offline Users > > > > http://reviewboard.kde.org/r/2179/s/262/ > > > > Show offline contacts in a separate folder > > > > http://reviewboard.kde.org/r/2179/s/265/ > > > > Offline Users cleanup > > > > http://reviewboard.kde.org/r/2179/s/266/ > > > > Thanks, > > > > Barry
-- Pali Rohár pali.ro...@gmail.com
Index: kopete/kopete/contactlist/contactlistproxymodel.cpp =================================================================== --- kopete/kopete/contactlist/contactlistproxymodel.cpp (revision 1282230) +++ kopete/kopete/contactlist/contactlistproxymodel.cpp (working copy) @@ -79,6 +79,15 @@ default: QString leftName = left.data( Qt::DisplayRole ).toString(); QString rightName = right.data( Qt::DisplayRole ).toString(); + + // Force the offline group to the bottom + QObject* groupObjectLeft = qVariantValue<QObject*>( sourceModel()->data( left, Kopete::Items::ObjectRole ) ); + QObject* groupObjectRight = qVariantValue<QObject*>( sourceModel()->data( right, Kopete::Items::ObjectRole ) ); + + if ( groupObjectLeft == Kopete::Group::offline() ) + return false; + else if ( groupObjectRight == Kopete::Group::offline() ) + return true; return QString::localeAwareCompare( leftName, rightName ) < 0; } } @@ -130,6 +139,10 @@ int connectedContactsCount = model->data( current, Kopete::Items::ConnectedCountRole ).toInt(); int totalContactsCount = model->data( current, Kopete::Items::TotalCountRole ).toInt(); + bool isOfflineGroup = ( groupObject == Kopete::Group::offline() ); + if ( !filterRegExp().isEmpty() && isOfflineGroup ) + return false; + if ( !filterRegExp().isEmpty() ) { // This shows or hides the contacts group folder if something was found. @@ -158,12 +171,19 @@ } - if ( !showEmpty && totalContactsCount == 0 ) + if ( !Kopete::AppearanceSettings::self()->showOfflineGrouped() && isOfflineGroup ) return false; - if ( !showEmpty && !showOffline && connectedContactsCount == 0 ) + if ( !showEmpty && totalContactsCount == 0 && !isOfflineGroup) return false; + // dont display offline when viewing in grouped offline mode + if ( showOffline && isOfflineGroup ) + return false; + + if ( !showEmpty && !showOffline && connectedContactsCount == 0 && !isOfflineGroup ) + return false; + return true; } @@ -178,6 +198,17 @@ return searchContactInfo( mc, filterRegExp() ); } + // Get the MetaContacts parent group name + QObject* groupObject = qVariantValue<QObject*>( model->data( sourceParent, Kopete::Items::ObjectRole ) ); + + if ( Kopete::AppearanceSettings::self()->groupContactByGroup() && qobject_cast<Kopete::Group*>(groupObject) != 0 ) + { + // If this contact's group is called Offline, and we are not globally + // showing offline all users show the offline folder + if ( groupObject == Kopete::Group::offline() ) + return !showOffline; + } + bool alwaysVisible = model->data( current, Kopete::Items::AlwaysVisible ).toBool(); int mcStatus = model->data( current, Kopete::Items::OnlineStatusRole ).toInt(); if ( mcStatus <= OnlineStatus::Offline && !showOffline && !alwaysVisible ) Index: kopete/kopete/contactlist/contactlisttreemodel.cpp =================================================================== --- kopete/kopete/contactlist/contactlisttreemodel.cpp (revision 1282230) +++ kopete/kopete/contactlist/contactlisttreemodel.cpp (working copy) @@ -57,6 +57,14 @@ foreach( Kopete::Group* g, contact->groups() ) addMetaContactToGroup( contact, g ); + + if ( Kopete::AppearanceSettings::self()->showOfflineGrouped() ) + { + if ( !contact->isOnline() ) + addMetaContactToGroup( contact, Kopete::Group::offline() ); + else + removeMetaContactFromGroup( contact, Kopete::Group::offline() ); + } } void ContactListTreeModel::removeMetaContact( Kopete::MetaContact* contact ) @@ -273,7 +281,10 @@ switch ( role ) { case Qt::DisplayRole: - return i18n( "%1 (%2/%3)", g->displayName(), countConnected( gmi ), gmi->count() ); + if ( g == Kopete::Group::offline() ) + return i18n( "%1 (%2)", g->displayName(), gmi->count() ); + else + return i18n( "%1 (%2/%3)", g->displayName(), countConnected( gmi ), gmi->count() ); break; case Qt::DecorationRole: if ( g->isExpanded() ) @@ -585,6 +596,11 @@ // and now notify all the changes foreach(QModelIndex index, indexList) { + if ( !mc->isOnline() ) + addMetaContactToGroup( mc, Kopete::Group::offline() ); + else + removeMetaContactFromGroup( mc, Kopete::Group::offline() ); + // we need to emit the dataChanged signal to the groups this metacontact belongs to // so that proxy filtering is aware of the changes, first we have to update the parent // otherwise the group won't be expandable. Index: kopete/kopete/contactlist/kopeteitemdelegate.cpp =================================================================== --- kopete/kopete/contactlist/kopeteitemdelegate.cpp (revision 1282230) +++ kopete/kopete/contactlist/kopeteitemdelegate.cpp (working copy) @@ -188,7 +188,8 @@ QList<Kopete::Contact*> KopeteItemDelegate::filterContacts( const QList<Kopete::Contact*> contacts ) const { - if ( Kopete::AppearanceSettings::self()->showOfflineUsers() ) + if ( Kopete::AppearanceSettings::self()->showOfflineUsers() || + Kopete::AppearanceSettings::self()->showOfflineGrouped() ) return contacts; QAbstractItemView* itemView = qobject_cast<QAbstractItemView*>(parent()); Index: kopete/kopete/contactlist/kopetecontactlistview.cpp =================================================================== --- kopete/kopete/contactlist/kopetecontactlistview.cpp (revision 1282230) +++ kopete/kopete/contactlist/kopetecontactlistview.cpp (working copy) @@ -368,6 +368,10 @@ if ( group == Kopete::Group::topLevel() ) continue; + // Can't remove the offline group + if ( group == Kopete::Group::offline() ) + continue; + groupList.append( group ); if( !group->displayName().isEmpty() ) @@ -453,6 +457,10 @@ QObject* groupObject = qVariantValue<QObject*>( index.data( Kopete::Items::MetaContactGroupRole ) ); Kopete::Group* fromGroup = qobject_cast<Kopete::Group*>(groupObject); + // Can't move to the offline group manually + if ( toGroup == Kopete::Group::offline() ) + return; + metaContact->moveToGroup( fromGroup, toGroup ); } } @@ -483,6 +491,10 @@ if ( !toGroup ) return; + // Can't copy to the offline group manually + if ( toGroup == Kopete::Group::offline() ) + return; + metaContact->addToGroup( toGroup ); } } @@ -1010,6 +1022,9 @@ return; } + if ( group == Kopete::Group::offline() ) + return; + KMenu *popup = dynamic_cast<KMenu *>( window->factory()->container( "group_popup", window ) ); if ( popup ) { Index: kopete/kopete/config/appearance/appearanceconfig_contactlist.ui =================================================================== --- kopete/kopete/config/appearance/appearanceconfig_contactlist.ui (revision 1282230) +++ kopete/kopete/config/appearance/appearanceconfig_contactlist.ui (working copy) @@ -189,6 +189,19 @@ </widget> </item> <item> + <widget class="QCheckBox" name="kcfg_showOfflineGrouped"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Show offline contacts in a &separate folder</string> + </property> + </widget> + </item> + <item> <widget class="QCheckBox" name="kcfg_contactListTreeView"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> Index: kopete/libkopete/kopetegroup.h =================================================================== --- kopete/libkopete/kopetegroup.h (revision 1282230) +++ kopete/libkopete/kopetegroup.h (working copy) @@ -53,7 +53,7 @@ typedef QList<Group*> List; /** Kinds of groups. */ - enum GroupType { Normal=0, Temporary, TopLevel }; + enum GroupType { Normal=0, Temporary, TopLevel, Offline }; /** * \brief Create an empty group @@ -122,8 +122,13 @@ * \return a Group pointer to the temporary group */ static Group *temporary(); - + /** + * \return a Group pointer to the offline group + */ + static Group *offline(); + + /** * @internal */ void setGroupId( uint groupId ); @@ -162,10 +167,11 @@ static Group *s_topLevel; static Group *s_temporary; + static Group *s_offline; class Private; Private * const d; - + /** * @internal used to get reachabe contact to send message to thom. */ Index: kopete/libkopete/kopetegroup.cpp =================================================================== --- kopete/libkopete/kopetegroup.cpp (revision 1282230) +++ kopete/libkopete/kopetegroup.cpp (working copy) @@ -31,6 +31,7 @@ Group *Group::s_topLevel = 0L; Group *Group::s_temporary = 0L; +Group *Group::s_offline = 0L; Group * Group::topLevel() { if ( !s_topLevel ) @@ -47,6 +48,14 @@ return s_temporary; } +Group * Group::offline() +{ + if ( !s_offline ) + s_offline = new Group( i18n( "Offline Users" ), Group::Offline ); + + return s_offline; +} + uint Group::Private::uniqueGroupId = 0; Group::Group( const QString &_name ) @@ -81,6 +90,8 @@ s_topLevel=0L; if(d->type == Temporary) s_temporary=0L; + if(d->type == Offline) + s_offline=0L; delete d; } Index: kopete/libkopete/contactlist/xmlcontactstorage.cpp =================================================================== --- kopete/libkopete/contactlist/xmlcontactstorage.cpp (revision 1282230) +++ kopete/libkopete/contactlist/xmlcontactstorage.cpp (working copy) @@ -506,7 +506,7 @@ } // Don't overwrite type for Temporary and TopLevel groups - if ( group->type() != Kopete::Group::Temporary && group->type() != Kopete::Group::TopLevel ) + if ( group->type() != Kopete::Group::Temporary && group->type() != Kopete::Group::TopLevel && group->type() != Kopete::Group::Offline ) { QString type = element.attribute( QLatin1String( "type" ), QLatin1String( "standard" ) ); if ( type == QLatin1String( "temporary" ) ) @@ -525,6 +525,14 @@ return false; } } + else if ( type == QLatin1String( "offline" ) ) + { + if ( group->type() != Kopete::Group::Offline ) + { + parseGroup( Kopete::Group::offline(), element ); + return false; + } + } } QString view = element.attribute( QLatin1String( "view" ), QLatin1String( "expanded" ) ); @@ -561,6 +569,9 @@ case Kopete::Group::TopLevel: group->setDisplayName( QLatin1String( "Top-Level" ) ); break; + case Kopete::Group::Offline: + group->setDisplayName( QLatin1String( "Offline" ) ); + break; default: group->setLoading( false ); return false; @@ -748,6 +759,10 @@ case Kopete::Group::TopLevel: type = QLatin1String( "top-level" ); break; + case Kopete::Group::Offline: + type = QLatin1String( "offline" ); + break; + default: type = QLatin1String( "standard" ); // == Normal break; Index: kopete/libkopete/contactlist/kopetecontactliststorage.cpp =================================================================== --- kopete/libkopete/contactlist/kopetecontactliststorage.cpp (revision 1282230) +++ kopete/libkopete/contactlist/kopetecontactliststorage.cpp (working copy) @@ -80,6 +80,8 @@ return Kopete::Group::temporary(); if( type == Kopete::Group::TopLevel ) return Kopete::Group::topLevel(); + if( type == Kopete::Group::Offline ) + return Kopete::Group::offline(); foreach( Kopete::Group * group, d->groupList ) { Index: kopete/libkopete/kopeteappearancesettings.kcfg =================================================================== --- kopete/libkopete/kopeteappearancesettings.kcfg (revision 1282230) +++ kopete/libkopete/kopeteappearancesettings.kcfg (working copy) @@ -250,10 +250,14 @@ <default>false</default> <emit signal="contactListAppearanceChanged" /> </entry> - <entry key="showIdentityIcons" type="Bool"> <label>Show identities in status bar instead of accounts.</label> <default>true</default> </entry> + <entry key="showOfflineGrouped" type="Bool"> + <label>Show offline users in a seperate group.</label> + <default>false</default> + <emit signal="contactListAppearanceChanged" /> + </entry> </group> </kcfg> Index: kopete/libkopete/kopetecontactlist.cpp =================================================================== --- kopete/libkopete/kopetecontactlist.cpp (revision 1282230) +++ kopete/libkopete/kopetecontactlist.cpp (working copy) @@ -198,7 +198,9 @@ return Group::temporary(); if( type == Group::TopLevel ) return Group::topLevel(); - + if( type == Group::Offline ) + return Group::offline(); + if ( displayName == i18n ("Top Level") ) return Group::topLevel(); Index: kopete/libkopete/kopetemetacontact.cpp =================================================================== --- kopete/libkopete/kopetemetacontact.cpp (revision 1282230) +++ kopete/libkopete/kopetemetacontact.cpp (working copy) @@ -995,6 +995,9 @@ return; } + if ( to->type() == Group::Offline ) + return; + if ( isTemporary() && to->type() != Group::Temporary ) return;
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ kopete-devel mailing list kopete-devel@kde.org https://mail.kde.org/mailman/listinfo/kopete-devel