Ticket #36: offline-group.patch
| File offline-group.patch, 17.1 kB (added by amroth, 12 months ago) |
|---|
-
kmess/contactlistviewitem.cpp
31 31 #include "kmessdebug.h" 32 32 #include "currentaccount.h" 33 33 #include "contact/contact.h" 34 #include "contact/group.h" 34 35 #include "emoticonmanager.h" 36 #include "grouplistviewitem.h" 35 37 36 38 #ifdef KMESSDEBUG_CONTACTLISTVIEWITEM 37 39 #define KMESSDEBUG_CONTACTLISTVIEWITEM_GENERAL … … 385 387 // Update the visibility of the contact 386 388 void ContactListViewItem::slotUpdateVisiblity() 387 389 { 388 // Visibility depends on whether or not allowed and removed contacts are shown. 390 // Visibility of a contact depends on the list grouping mode, and on the contact status. 391 389 392 CurrentAccount *currentAccount = CurrentAccount::instance(); 393 int groupMode = currentAccount->getContactsGroupMode(); 394 GroupListViewItem *parent = static_cast<GroupListViewItem*>( QListViewItem::parent() ); 390 395 391 if(QListViewItem::parent() == 0 && ! currentAccount->getShowContactsByGroup()) 396 // Hide root items if contacts are grouped between online and offline; and when the contact without 397 // group is offline if contact sare divided in groups+offline contacts. 398 if( parent == 0 && 399 ( groupMode == Account::BYSTATUS || (groupMode == Account::MIXED && contact_->isOffline() ) ) ) 392 400 { 393 // Hide root items if contacts are shown in online/offline groups.394 setVisible(false);401 setVisible( false ); 402 return; 395 403 } 396 else if(contact_->isOffline() && ! currentAccount->getShowOfflineContacts()) 404 405 // Hide offline contacts in groups, when in mixed mode 406 if( groupMode == Account::MIXED && contact_->isOffline() 407 && parent && ! parent->getGroup()->isSpecialGroup() ) 397 408 { 398 // Hide if online contacts are not shown399 setVisible(false);409 setVisible( false ); 410 return; 400 411 } 412 413 // Hide if offline contacts are not shown 414 if( contact_->isOffline() && ! currentAccount->getShowOfflineContacts() ) 415 { 416 setVisible( false ); 417 return; 418 } 419 420 if( contact_->isFriend() ) 421 { 422 // Friends should always be visible 423 setVisible( true ); 424 } 425 else if( contact_->isAllowed() ) 426 { 427 // Whether or not allowed contacts are visible depends on the contact setting 428 setVisible( currentAccount->getShowAllowedContacts() ); 429 } 401 430 else 402 431 { 403 if(contact_->isFriend()) 404 { 405 // Friends should always be visible 406 setVisible(true); 407 } 408 else if(contact_->isAllowed()) 409 { 410 // Whether or not allowed contacts are visible depends on the contact setting 411 setVisible( currentAccount->getShowAllowedContacts() ); 412 } 413 else 414 { 415 // Whether or not removed contacts are visible depends on the contact setting 416 setVisible( currentAccount->getShowRemovedContacts() ); 417 } 432 // Whether or not removed contacts are visible depends on the contact setting 433 setVisible( currentAccount->getShowRemovedContacts() ); 418 434 } 419 435 } 420 436 -
kmess/kmess.cpp
631 631 void KMess::changeViewMode(int mode) 632 632 { 633 633 #ifdef KMESSTEST 634 ASSERT( ( mode == 0 ) || ( mode == 1) );634 ASSERT( ( mode >= 0 ) && ( mode <= 2 ) ); 635 635 #endif 636 if ( mode == 0 ) 636 637 switch( currentAccount_->getContactsGroupMode() ) 637 638 { 638 CurrentAccount::instance()->setShowContactsByGroup( true ); 639 case 0: CurrentAccount::instance()->setContactsGroupMode( Account::BYGROUP ); break; 640 case 1: CurrentAccount::instance()->setContactsGroupMode( Account::MIXED ); break; 641 case 2: CurrentAccount::instance()->setContactsGroupMode( Account::BYSTATUS ); break; 642 643 default: 644 kdDebug() << "KMess - changeViewMode() - WARNING - Invalid view mode = " << mode << endl; 645 break; 639 646 } 640 else if ( mode == 1 )641 {642 CurrentAccount::instance()->setShowContactsByGroup( false );643 }644 else645 {646 kdDebug() << "KMess - changeViewMode() - WARNING - Invalid view mode = " << mode << endl;647 }648 647 } 649 648 650 649 … … 885 884 showAllowedAction_->setChecked( currentAccount_->getShowAllowedContacts() ); 886 885 showOfflineAction_->setChecked( currentAccount_->getShowOfflineContacts() ); 887 886 showRemovedAction_->setChecked( currentAccount_->getShowRemovedContacts() ); 888 if ( currentAccount_->getShowContactsByGroup() ) 887 888 switch( currentAccount_->getContactsGroupMode() ) 889 889 { 890 viewMode_->setCurrentItem( 0 ); 890 case Account::BYSTATUS: viewMode_->setCurrentItem( 2 ); break; 891 case Account::MIXED: viewMode_->setCurrentItem( 1 ); break; 892 case Account::BYGROUP: 893 default: viewMode_->setCurrentItem( 0 ); break; 891 894 } 892 else 893 { 894 viewMode_->setCurrentItem( 1 ); 895 } 895 896 896 // Show the connected message 897 897 statusMessage( i18n("Connected"), TYPE_MESSAGE ); 898 898 -
kmess/account.cpp
65 65 savedChatDirectoryStructure_( 0 ), 66 66 shakeNudge_(true), 67 67 showAllowedContacts_(false), 68 showContactsByGroup_(true),68 contactsGroupMode_(BYGROUP), 69 69 showEmail_(true), 70 70 showMessageTime_(true), 71 71 showNowListening_(false), … … 128 128 account->getFriendlyName(), 129 129 account->getPassword() ); 130 130 setShowAllowedContacts ( account->getShowAllowedContacts() ); 131 set ShowContactsByGroup ( account->getShowContactsByGroup());131 setContactsGroupMode ( account->getContactsGroupMode() ); 132 132 setShowOfflineContacts ( account->getShowOfflineContacts() ); 133 133 setShowRemovedContacts ( account->getShowRemovedContacts() ); 134 134 setEmoticonStyle ( account->getEmoticonStyle() ); … … 189 189 setShowAllowedContacts( account->getShowAllowedContacts() ); 190 190 setShowOfflineContacts( account->getShowOfflineContacts() ); 191 191 setShowRemovedContacts( account->getShowRemovedContacts() ); 192 set ShowContactsByGroup( account->getShowContactsByGroup());192 setContactsGroupMode ( account->getContactsGroupMode() ); 193 193 setAutoreplyMessage ( account->getAutoreplyMessage() ); 194 194 setEmailSupported ( account->getEmailSupported() ); 195 195 setGuestAccount ( account->isGuestAccount() ); … … 488 488 489 489 490 490 491 // Read whether contacts are shown by group or by online/offline.492 bool Account::getShowContactsByGroup() const491 // Get how the contacts are grouped together in the contact list. 492 const int& Account::getContactsGroupMode() const 493 493 { 494 return showContactsByGroup_;494 return contactsGroupMode_; 495 495 } 496 496 497 497 … … 711 711 contactFont_.setUnderline ( config->readBoolEntry( "contactfontunderline", false ) ); 712 712 contactFont_.setPointSize ( config->readNumEntry ( "contactfontpointsize", 10 ) ); 713 713 contactFontColor_ = config->readEntry ( "contactfontcolor" , "#000000" ); 714 contactsGroupMode_ = config->readNumEntry ( "contactsGroupMode", 0 ); 714 715 customImageIndex_ = config->readNumEntry ( "customimageindex", 0 ); 715 716 doNotifyContactsOnline_ = config->readBoolEntry( "doNotifyContactsOnline", true ); 716 717 doNotifyContactsStatus_ = config->readBoolEntry( "doNotifyContactsStatus", false ); … … 738 739 savedChatDirectoryStructure_ = config->readNumEntry ( "savedChatDirectoryStructure", 0 ); 739 740 shakeNudge_ = config->readBoolEntry( "shakeNudge", true ); 740 741 showAllowedContacts_ = config->readBoolEntry( "showAllowed", false ); 741 showContactsByGroup_ = config->readBoolEntry( "showByGroup", true );742 742 showEmail_ = config->readBoolEntry( "showEmail", true ); 743 743 showImage_ = config->readBoolEntry( "showImage", true ); 744 744 showMessageTime_ = config->readBoolEntry( "showMessageTime", true ); … … 858 858 config->writeEntry( "savedChatDirectoryStructure", savedChatDirectoryStructure_ ); 859 859 config->writeEntry( "shakeNudge", shakeNudge_ ); 860 860 config->writeEntry( "showAllowed", showAllowedContacts_ ); 861 config->writeEntry( " showByGroup", showContactsByGroup_);861 config->writeEntry( "contactsGroupMode", contactsGroupMode_ ); 862 862 config->writeEntry( "showEmail", showEmail_ ); 863 863 config->writeEntry( "showMessageTime", showMessageTime_ ); 864 864 config->writeEntry( "showNowListening", showNowListening_ ); … … 1290 1290 1291 1291 1292 1292 1293 // Set whether contacts are shown by group or by online/offline.1294 void Account::set ShowContactsByGroup( bool showContactsByGroup)1293 // Change how the contacts are grouped together in the contact list. 1294 void Account::setContactsGroupMode( int contactsGroupMode ) 1295 1295 { 1296 if ( showContactsByGroup != showContactsByGroup_ )1296 if ( contactsGroupMode != contactsGroupMode_ ) 1297 1297 { 1298 showContactsByGroup_ = showContactsByGroup;1298 contactsGroupMode_ = contactsGroupMode; 1299 1299 emit changedViewMode(); 1300 1300 dirty_ = true; 1301 1301 #ifdef KMESSDEBUG_ACCOUNT_DIRTY 1302 kdDebug() << "Account::set ShowContactsByGroup(): Setting 'dirty' to true." << endl;1302 kdDebug() << "Account::setContactsGroupMode(): Setting 'dirty' to true." << endl; 1303 1303 #endif 1304 1304 } 1305 1305 } -
kmess/account.h
52 52 , BYDAY = 3 53 53 }; 54 54 55 // Groups organization 56 enum ListGroupMode { BYGROUP = 0 // Group all contacts by their group 57 , MIXED = 1 // As BYGROUP but all offline contacts group together 58 , BYSTATUS = 2 // Group contacts by status, online and offline 59 }; 60 55 61 // The constructor 56 62 Account(); 57 63 // The destructor … … 70 76 const QFont& getContactFont() const; 71 77 // Return the color of the forced contact font. 72 78 const QString& getContactFontColor() const; 79 // Get how the contacts are grouped together in the contact list. 80 const int& getContactsGroupMode() const; 73 81 // Read the email command used when not using hotmail 74 82 const QString& getEmailCommand() const; 75 83 // Return whether email notifications are supported … … 114 122 const int& getSavedChatDirectoryStructure() const; 115 123 // Read whether or not allowed contacts are shown. 116 124 bool getShowAllowedContacts() const; 117 // Read whether contacts are shown by group or by online/offline.118 bool getShowContactsByGroup() const;119 125 // Read whether the email information should be shown in the main view. 120 126 bool getShowEmail() const; 121 127 // Read the selected emoticon's list number … … 180 186 void setChatInformation( bool useContactFont, bool useEmoticons, bool useFontEffects, bool showMessageTime, bool groupFollowupMessages, const QString& chatStyle ); 181 187 // Set chat logging information 182 188 void setChatLoggingInformation( bool saveChats, const QString& saveChatPath, const int& directoryStructure ); 189 // Change how the contacts are grouped together in the contact list. 190 void setContactsGroupMode( int groupMode ); 183 191 // Set email information 184 192 void setEmailInformation( bool useHotmail, const QString& emailCommand, bool showEmail, bool showOtherFolders ); 185 193 // Set the font … … 218 226 void setNotifyEmails( bool doNotifyEmails ); 219 227 // Set whether or not allowed contacts are shown. 220 228 void setShowAllowedContacts( bool showAllowedContacts ); 221 // Set whether contacts are shown by group or by online/offline.222 void setShowContactsByGroup( bool showContactsByGroup );223 229 // Set whether offline contacts should be shown. 224 230 void setShowOfflineContacts( bool showOfflineContacts ); 225 231 // Set whether or not removed (reverse) contacts are shown. … … 307 313 bool shakeNudge_; 308 314 // Whether or not allowed contacts should be visible. 309 315 bool showAllowedContacts_; 310 // Whether contacts should be shown by group (true) or by online/offline status (false).311 bool showContactsByGroup_;316 // How contacts should be grouped together in the list. 317 int contactsGroupMode_; 312 318 // Whether or not to show any email notifications (the user may not 313 319 // have a hotmail account). 314 320 bool showEmail_; -
kmess/kmessinterface.cpp
278 278 #endif 279 279 280 280 viewMode_ = new KSelectAction( i18n("&Sort Contacts by"), "view_tree", 0, this, "viewmode"); 281 viewModes << i18n("Group") << i18n(" Online/Offline");281 viewModes << i18n("Group") << i18n("Groups/Offline") << i18n("Online/Offline"); 282 282 viewMode_->setItems(viewModes); 283 283 284 connect ( viewMode_, SIGNAL( activated( int ) ), this, SLOT( changeViewMode( int ) ) ); 284 285 285 286 showTransferAction_ = new KAction(i18n("Show &Transfer Window"), "cache", 0, -
kmess/kmessview.cpp
1363 1363 1364 1364 GroupListViewItem *item; 1365 1365 item = new GroupListViewItem(contactListView_, group); 1366 int groupMode = currentAccount_->getContactsGroupMode(); 1366 1367 1367 1368 if(! group->isSpecialGroup() || group->getId() == SpecialGroups::INDIVIDUALS) 1368 1369 { … … 1370 1371 connect(item, SIGNAL(moveToGroup(Group*)), this, SLOT(slotForwardMoveContact(Group*))); 1371 1372 connect(item, SIGNAL(copyToGroup(Group*)), this, SLOT(slotForwardCopyContact(Group*))); 1372 1373 // Hide normal group if user likes to sort contacts by online/offline state 1373 item->setVisible( currentAccount_->getShowContactsByGroup());1374 item->setVisible( groupMode != Account::BYSTATUS ); 1374 1375 } 1375 1376 else 1376 1377 { … … 1385 1386 } 1386 1387 else if(group->getId() == SpecialGroups::ONLINE) 1387 1388 { 1388 item->setVisible( ! currentAccount_->getShowContactsByGroup());1389 item->setVisible( groupMode == Account::BYSTATUS ); 1389 1390 } 1390 1391 else if(group->getId() == SpecialGroups::OFFLINE) 1391 1392 { 1392 item->setVisible( ! currentAccount_->getShowContactsByGroup() && 1393 currentAccount_->getShowOfflineContacts() ); 1393 item->setVisible( groupMode == Account::BYSTATUS && currentAccount_->getShowOfflineContacts() ); 1394 1394 } 1395 1395 } 1396 1396 } … … 1619 1619 // Read the settings 1620 1620 bool showAllowed = currentAccount_->getShowAllowedContacts(); 1621 1621 bool showRemoved = currentAccount_->getShowRemovedContacts(); 1622 bool showByGroup = currentAccount_->getShowContactsByGroup();1623 1622 bool showOffline = currentAccount_->getShowOfflineContacts(); 1623 int groupMode = currentAccount_->getContactsGroupMode(); 1624 1624 1625 kdDebug() << "TEST - Group mode: " << groupMode << endl; 1625 1626 QString groupId; 1626 1627 GroupListViewItem *groupItem = findFirstGroup(); 1627 1628 1628 while(groupItem != 0) 1629 1629 { 1630 1630 groupId = groupItem->getGroup()->getId(); 1631 1631 1632 kdDebug() << "TEST - name: " << groupItem->getGroup()->getName() << " - special: " << groupItem->getGroup()->isSpecialGroup() << endl; 1632 1633 // Hide or show the special groups 1633 1634 if(groupId == SpecialGroups::ALLOWED) 1634 1635 { … … 1640 1641 } 1641 1642 else if(groupId == SpecialGroups::ONLINE) 1642 1643 { 1643 groupItem->setVisible( ! showByGroup);1644 groupItem->setVisible( groupMode == Account::BYSTATUS ); 1644 1645 } 1645 1646 else if(groupId == SpecialGroups::OFFLINE) 1646 1647 { 1647 groupItem->setVisible( ! showByGroup && showOffline ); 1648 // Show both in groups+offline and online+offline display modes 1649 groupItem->setVisible( groupMode != Account::BYGROUP && showOffline ); 1648 1650 } 1649 1651 else 1650 1652 { … … 1652 1654 // This feature is used from slotUpdateViewMode() 1653 1655 if(! groupItem->getGroup()->isSpecialGroup()) 1654 1656 { 1655 groupItem->setVisible( showByGroup);1657 groupItem->setVisible( groupMode != Account::BYSTATUS ); 1656 1658 } 1659 else 1660 { 1661 groupItem->setVisible( true ); 1662 } 1657 1663 } 1658 1664 1659 1665 groupItem = findNextGroup(groupItem);
