[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/pim/contactsmenu
From:       Friedrich W. H. Kossebau <Friedrich.W.H () Kossebau ! de>
Date:       2006-02-28 23:58:56
Message-ID: 1141171136.266200.29834.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 514671 by kossebau:

Switch from a kicker menu to a kicker applet, getting more control about the button.
Or better: the buttons. There can be multiple buttons now next to each other,
buttons for single contacts, buttons for list of contacts with a given category 
or simply the list of all, like there used to be.

For the curious: 
In the temporary add button dialog enter the "name" of a contact, "C:category" for a \
category and "A:" for all.




 M  +4 -0      ChangeLog  
 M  +16 -14    Makefile.am  
 A             contactlistmenubuttonfiller.cpp   [License: LGPL (v2) (wrong address)]
 A             contactlistmenubuttonfiller.h   [License: LGPL (v2) (wrong address)]
 M  +30 -12    contactlistmenufiller.cpp  
 M  +2 -7      contactlistmenufiller.h  
 A             contactmenubuttonfiller.cpp   [License: LGPL (v2) (wrong address)]
 A             contactmenubuttonfiller.h   [License: LGPL (v2) (wrong address)]
 M  +0 -1      contactmenufiller.h  
 A             contactsapplet.cpp   contactsmenu.cpp#513413 [License: LGPL (v2) \
(wrong address)]  A             contactsapplet.desktop   contactsmenu.desktop#513413
 A             contactsapplet.h   contactsmenu.h#513413 [License: LGPL (v2) (wrong \
address)]  D             contactsmenu.cpp  
 D             contactsmenu.desktop  
 D             contactsmenu.h  
 A             libmenubutton (directory)  
 A             libmenubutton/Makefile.am  
 A             libmenubutton/menubutton.cpp   [License: LGPL (v2) (wrong address)]
 A             libmenubutton/menubutton.h   [License: LGPL (v2) (wrong address)]
 A             libmenubutton/menubuttonfiller.cpp   [License: LGPL (v2) (wrong \
address)]  A             libmenubutton/menubuttonfiller.h   [License: LGPL (v2) \
(wrong address)]  M  +15 -3     main.cpp  
 D             topcontactlistmenufiller.cpp  
 D             topcontactlistmenufiller.h  


--- trunk/playground/pim/contactsmenu/ChangeLog #514670:514671
@@ -1,3 +1,7 @@
+0.4.0
+* switch from simple menu to applet
+* 
+
 0.3.4:
 * support for phone calls (and fax) doing it like KAddressbook
 
--- trunk/playground/pim/contactsmenu/Makefile.am #514670:514671
@@ -1,32 +1,34 @@
-SUBDIRS = librss liblazyfillmenu
+SUBDIRS = librss liblazyfillmenu libmenubutton
 
-INCLUDES= -I$(srcdir)/liblazyfillmenu $(all_includes)
+INCLUDES= -I$(srcdir)/liblazyfillmenu -I$(srcdir)/libmenubutton $(all_includes)
 METASOURCES = AUTO
 
-kde_module_LTLIBRARIES = kickermenu_contactsmenu.la
+kde_module_LTLIBRARIES = contactsapplet.la
 
-kickermenu_contactsmenu_la_SOURCES = \
+contactsapplet_la_SOURCES = \
   emailmenufiller.cpp immenufiller.cpp phonemenufiller.cpp addressmenufiller.cpp \
   webmenufiller.cpp blogmenufiller.cpp \
-  contactmenufiller.cpp contactlistmenufiller.cpp topcontactlistmenufiller.cpp \
-  contactsmenu.cpp main.cpp
-kickermenu_contactsmenu_la_LDFLAGS = $(all_libraries) -module -avoid-version \
                -no-undefined
-kickermenu_contactsmenu_la_LIBADD = \
-  librss/librsslocal.la liblazyfillmenu/liblazyfillmenu.la \
+  contactmenufiller.cpp contactlistmenufiller.cpp \
+  contactmenubuttonfiller.cpp contactlistmenubuttonfiller.cpp \
+  contactsapplet.cpp main.cpp
+contactsapplet_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -avoid-version \
-no-undefined +contactsapplet_la_LIBADD = \
+  librss/librsslocal.la libmenubutton/libmenubutton.la \
liblazyfillmenu/liblazyfillmenu.la \  $(LIB_KDEUI) $(LIB_KIMPROXY) $(LIB_KABC)
 
-contactsmenu_DATA = contactsmenu.desktop
-contactsmenudir = $(kde_datadir)/kicker/menuext
+contactsapplet_DATA = contactsapplet.desktop
+contactsappletdir = $(kde_datadir)/kicker/applets
 
 noinst_HEADERS = \
   emailmenufiller.h immenufiller.h phonemenufiller.h addressmenufiller.h \
   webmenufiller.h blogmenufiller.h \
   addresseelistspan.h \
-  contactmenufiller.h contactlistmenufiller.h topcontactlistmenufiller.h \
-  contactsmenu.h
+  contactmenufiller.h contactlistmenufiller.h \
+  contactmenubuttonfiller.h contactlistmenubuttonfiller.h \
+  contactsapplet.h
 
 EXTRA_DIST = DESIGN
 
 messages: rc.cpp
 	$(EXTRACTRC) `find . -name \*.ui -o -name \*.rc` > rc.cpp
-	$(XGETTEXT) *.cpp -o $(podir)/libkickermenu_contactsmenu.pot
+	$(XGETTEXT) *.cpp -o $(podir)/contactsapplet.pot
--- trunk/playground/pim/contactsmenu/contactlistmenufiller.cpp #514670:514671
@@ -21,19 +21,38 @@
 #include <qpopupmenu.h>
 // kde specific
 #include <kiconloader.h>
+#include <klocale.h>
 // menu specific
 #include "lazyfillmenu.h"
 #include "contactmenufiller.h"
 #include "contactlistmenufiller.h"
 
 
-ContactListMenuFiller::ContactListMenuFiller( AddresseeListSpan Span, const QString \
&FirstToken, const QString &LastToken ) \
+ContactListMenuFiller::ContactListMenuFiller( const AddresseeListSpan Span, +        \
const QString &FirstToken, const QString &LastToken )  : ContactsSpan( Span ), \
UpperFirstEntryToken( FirstToken ), UpperLastEntryToken( LastToken ) +{
+}
 
+ContactListMenuFiller::ContactListMenuFiller( const AddresseeListSpan Span )
+ : ContactsSpan( Span )
 {
+    QString Dummy;
+    // we only need and can cre
+    if( Span.number() > 1 )
+    {
+        KABC::Addressee::List::ConstIterator it = ContactsSpan.begin();
+        const QString &FirstName = (*it).realName();
+        const QString &SecondName = (*++it).realName();
+        createTokens( UpperFirstEntryToken, Dummy, FirstName, SecondName );
+
+        it = ContactsSpan.end();
+        const QString &LastName = (*--it).realName();
+        const QString &PreLastName = (*--it).realName();
+        createTokens( Dummy, UpperLastEntryToken, PreLastName, LastName );
+    }
 }
 
-
 // TODO: calculate limit by screen size
 static const int Limit = 30;
 
@@ -74,7 +93,7 @@
 
         do
         {
-            AddresseeListSpan SubSpan( it, SizeSubMenus, ContactsSpan.end() );
+            const AddresseeListSpan SubSpan( it, SizeSubMenus, ContactsSpan.end() );
 
             // create shorts
             QString FirstEntryToken = NextFirstEntryToken;
@@ -83,24 +102,23 @@
             else
                 LastEntryToken = UpperLastEntryToken;
 
-            LazyFillMenu *SubMenu = createSubMenu(
-               new ContactListMenuFiller(SubSpan,FirstEntryToken,LastEntryToken), \
Menu ); +            MenuFiller *Filler = new ContactListMenuFiller( SubSpan, \
FirstEntryToken, LastEntryToken ); +            LazyFillMenu *SubMenu = new \
LazyFillMenu( Filler, false, Menu );  
             Menu->insertItem( SmallIconSet("contents"), \
protectAmpersand(FirstEntryToken+QString("...")+LastEntryToken), SubMenu );  }
         while( it != ContactsSpan.end() );
     }
-    else
+    else if( ContactsSpan.number() > 0 )
     {
         KABC::Addressee::List::ConstIterator it = ContactsSpan.begin();
 
         while( it != ContactsSpan.end() )
             ContactMenuFiller::createEntry( *it++, Menu );
     }
+    else
+    {
+        int id = Menu->insertItem( i18n("No Entries"), 0 );
+        Menu->setItemEnabled( id, false );
+    }
 }
-
-
-LazyFillMenu *ContactListMenuFiller::createSubMenu( MenuFiller *Filler, QPopupMenu \
                *Menu )
-{
-      return new LazyFillMenu( Filler, false, Menu );
-}
--- trunk/playground/pim/contactsmenu/contactlistmenufiller.h #514670:514671
@@ -32,23 +32,18 @@
 {
 public:
     ContactListMenuFiller( const AddresseeListSpan Span, const QString &FirstToken, \
const QString &LastToken ); +    explicit ContactListMenuFiller( const \
AddresseeListSpan Span );  
 public: // MenuFiller API
     virtual void fill( QPopupMenu *Menu );
 
 protected:
-    // reimplemented in subclass to collect created menu objects
-    // per default they are added to the parent menu to be autodeleted
-    virtual LazyFillMenu *createSubMenu( MenuFiller *Filler, QPopupMenu *Menu );
-
-
-protected:
     static void createTokens( QString &PreviousToken, QString &NextToken, 
                               const QString &Previous, const QString &Next );
 
 protected:
     /** sublist of contacts to care of */
-    AddresseeListSpan ContactsSpan;
+    const AddresseeListSpan ContactsSpan;
     /** */
     QString UpperFirstEntryToken;
     QString UpperLastEntryToken;
--- trunk/playground/pim/contactsmenu/contactmenufiller.h #514670:514671
@@ -44,7 +44,6 @@
     void launchAddressEditor() const;
 
 protected:
-    /** sublist of contacts to care of */
     const KABC::Addressee Contact;
 };
 
--- trunk/playground/pim/contactsmenu/main.cpp #514670:514671
@@ -17,7 +17,19 @@
     Boston, MA 02110-1301  USA
 */
 
-// menu specific
-#include "contactsmenu.h"
+// kde specific
+#include <kglobal.h>
+#include <klocale.h>
+#include <kconfig.h>
+// applet specific
+#include "contactsapplet.h"
 
-K_EXPORT_KICKER_MENUEXT(contactsmenu, ContactsMenu)
+
+extern "C"
+{
+    KDE_EXPORT KPanelApplet* init( QWidget *Parent, const QString& ConfigFile )
+    {
+        KGlobal::locale()->insertCatalogue( ContactsApplet::AppletName );
+        return new ContactsApplet( ConfigFile, Parent, ContactsApplet::AppletName);
+    }
+}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic