[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/kopete
From: Lamarque Souza <lamarque () gmail ! com>
Date: 2011-02-05 1:15:38
Message-ID: 20110205011538.B2F38AC8C7 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1218856 by lvsouza:
Sorts accounts before adding them to the status bar.
Implementation relys on allPluginsLoaded working as expected.
I have been using this change for a week, no problems so far.
M +40 -14 kopetewindow.cpp
--- trunk/KDE/kdenetwork/kopete/kopete/kopetewindow.cpp #1218855:1218856
@@ -311,14 +311,6 @@
connect ( Kopete::IdentityManager::self(), SIGNAL ( identityUnregistered \
( const Kopete::Identity* ) ),
this, SLOT ( slotIdentityUnregistered ( const Kopete::Identity* \
) ) );
- //Connect the appropriate account signals
- /* Please note that I tried to put this in the slotAllPluginsLoaded() \
function
- * but it seemed to break the account icons in the statusbar --Matt */
- connect ( Kopete::AccountManager::self(), SIGNAL ( accountRegistered ( \
Kopete::Account* ) ),
- this, SLOT ( slotAccountRegistered ( Kopete::Account* ) ) );
- connect ( Kopete::AccountManager::self(), SIGNAL ( accountUnregistered ( \
const Kopete::Account* ) ),
- this, SLOT ( slotAccountUnregistered ( const Kopete::Account* ) \
) );
-
connect ( d->autoHideTimer, SIGNAL ( timeout() ), this, SLOT ( \
slotAutoHide() ) ); connect ( d->contactlist, SIGNAL( \
visibleContentHeightChanged() ), this, SLOT ( slotStartAutoResizeTimer() ) \
); connect ( d->autoResizeTimer, SIGNAL ( timeout() ), this, SLOT ( \
slotUpdateSize() ) ); @@ -339,11 +331,6 @@
foreach ( Kopete::Identity *i, identityList )
slotIdentityRegistered ( i );
- // If some account already loaded, build the status icon
- QList<Kopete::Account *> accountList = \
Kopete::AccountManager::self()->accounts();
- foreach ( Kopete::Account *a, accountList )
- slotAccountRegistered ( a );
-
//install an event filter for the quick search toolbar so we can
//catch the hide events
toolBar ( "quickSearchBar" )->installEventFilter ( this );
@@ -665,6 +652,9 @@
Kopete::AppearanceSettings::self()->writeConfig();
}
+bool compareOnlineStatus(const Kopete::Account *a, const Kopete::Account \
*b); +bool invertedCompareOnlineStatus(const Kopete::Account *a, const \
Kopete::Account *b); +
void KopeteWindow::slotConfigChanged()
{
bool groupContactByGroupModel = \
qobject_cast<Kopete::UI::ContactListTreeModel*>( d->model ); @@ -727,6 \
+717,7 @@ else
{
QList<Kopete::Account *> accountList = \
Kopete::AccountManager::self()->accounts(); + qSort(accountList.begin(), \
accountList.end(), invertedCompareOnlineStatus); foreach ( Kopete::Account \
*account, accountList ) {
KopeteAccountStatusBarIcon *sbIcon = new KopeteAccountStatusBarIcon ( \
account, d->statusBarWidget ); @@ -912,6 +903,20 @@
KConfigGroup cg( KGlobal::config(), "General Options" );
+ // If some account already loaded, build the status icon
+ QList<Kopete::Account *> accountList = \
Kopete::AccountManager::self()->accounts(); + qSort(accountList.begin(), \
accountList.end(), invertedCompareOnlineStatus); + foreach ( \
Kopete::Account *a, accountList ) + slotAccountRegistered ( a );
+
+ //Connect the appropriate account signals
+ /* Please note that I tried to put this in the slotAllPluginsLoaded() \
function + * but it seemed to break the account icons in the statusbar \
--Matt */ + connect ( Kopete::AccountManager::self(), SIGNAL ( \
accountRegistered ( Kopete::Account* ) ), + this, SLOT ( \
slotAccountRegistered ( Kopete::Account* ) ) ); + connect ( \
Kopete::AccountManager::self(), SIGNAL ( accountUnregistered ( const \
Kopete::Account* ) ), + this, SLOT ( slotAccountUnregistered ( \
const Kopete::Account* ) ) ); +
if ( d->showIdentityIcons )
{
QString identityId = cg.readEntry( "ShownIdentityId", \
Kopete::IdentityManager::self()->defaultIdentity()->id() ); @@ -1039,9 \
+1044,28 @@
bool compareOnlineStatus(const Kopete::Account *a, const Kopete::Account \
*b) {
- return (a->myself()->onlineStatus().status() > \
b->myself()->onlineStatus().status()); + int c = 0;
+
+ if (a->identity() && b->identity()) {
+ c = QString::localeAwareCompare(a->identity()->label(), \
b->identity()->label()); }
+ if (c == 0) {
+ c = a->myself()->onlineStatus().status() - \
b->myself()->onlineStatus().status(); +
+ if (c == 0) {
+ return (QString::localeAwareCompare(a->protocol()->displayName(), \
b->protocol()->displayName()) < 0); + }
+ return (c > 0);
+ }
+ return (c < 0);
+}
+
+bool invertedCompareOnlineStatus(const Kopete::Account *a, const \
Kopete::Account *b) +{
+ return !compareOnlineStatus(a, b);
+}
+
void KopeteWindow::makeTrayToolTip()
{
//FIXME: maybe use identities here?
@@ -1193,6 +1217,7 @@
popup->addTitle ( qApp->windowIcon(), KGlobal::caption() );
QList<Kopete::Account *> accountList = \
Kopete::AccountManager::self()->accounts(); + qSort(accountList.begin(), \
accountList.end(), invertedCompareOnlineStatus); foreach ( Kopete::Account \
*account, accountList ) {
KActionMenu *menu = new KActionMenu ( account->accountId(), account );
@@ -1270,6 +1295,7 @@
{
bool changed = false;
QList<Kopete::Account*> accountList = \
Kopete::AccountManager::self()->accounts(); + qSort(accountList.begin(), \
accountList.end(), invertedCompareOnlineStatus); foreach ( Kopete::Account \
*account, accountList ) {
Kopete::Contact *self = account->myself();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic