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

List:       kde-pim
Subject:    PATCH - Re: [Kde-pim] commit of address formatting and printing code
From:       Anders Lund <anders.lund () lund ! tdcadsl ! dk>
Date:       2002-11-29 0:20:56
[Download RAW message or body]

On Thursday 28 November 2002 21:07, Anders Lund wrote:
> Therefore, I want to get everything to compile here to ensure it works
> before sending a patch, please be patient with me :) - I should be ready
> sometime tonight, or at least tomorrow.

Well, here you go.

The patch + the ui files should do. The patch contains changes in 
printingwizard_base which are meaningless, since that file should be removed.

The two ui files should probably be renamed. Suggestions wellcome...

Still to be handled is checking on leaving the selection page.

Let me know if anything is missing or not wroking...

-anders
["contactselection.ui" (application/x-designer)]
["contactselection.ui.h" (text/x-chdr)]

/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/


void ContactSelection::filterChanged( int )
{
  rbUseFilter->setChecked( true );
}


void ContactSelection::categoryClicked( QListViewItem *i )
{
  if ( dynamic_cast<QCheckListItem*>(i)->isOn() )
      rbCategoryMembers->setChecked(true);
}

["kaddressbook_printing.diff" (text/x-diff)]

? contactselection.ui
? contactselection.ui.h
? kaddressbook_printing.diff
? stylepage.ui
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/Makefile.am,v
retrieving revision 1.8
diff -u -r1.8 Makefile.am
--- Makefile.am	2002/09/21 23:52:27	1.8
+++ Makefile.am	2002/11/29 00:10:53
@@ -5,7 +5,8 @@
 
 libprinter_la_METASOURCES = AUTO
 
-libprinter_la_SOURCES = printingwizard_base.ui \
+libprinter_la_SOURCES = stylepage.ui \
+        contactselection.ui \
 	printingwizard.cpp \
 	printstyle.cpp \
 	printprogress_base.ui printprogress.cpp \
@@ -13,7 +14,7 @@
 	ds_appearance.ui \
 	mikesstyle.cpp 
 
-EXTRA_DIST = printingwizard_base.ui \
+EXTRA_DIST = stylepage.ui contactselection.ui \
 	printingwizard.cpp printingwizard.h \
 	printstyle.cpp printstyle.h \
 	printprogress.cpp printprogress.h \
Index: printingwizard.cpp
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printingwizard.cpp,v
retrieving revision 1.9
diff -u -r1.9 printingwizard.cpp
--- printingwizard.cpp	2002/09/15 02:21:39	1.9
+++ printingwizard.cpp	2002/11/29 00:10:53
@@ -20,6 +20,8 @@
 #include <qpixmap.h>
 #include <qlabel.h>
 #include <qpushbutton.h>
+#include <qlistview.h>
+#include <qheader.h>
 
 #include <kdebug.h>
 #include <kprinter.h>
@@ -33,6 +35,7 @@
 #include "printprogress.h"
 #include "detailledstyle.h"
 #include "mikesstyle.h"
+#include "../kabprefs.h"
 
 namespace KABPrinting {
 
@@ -44,14 +47,35 @@
         : PrintingWizard(printer, doc, selection, parent, name),
           style(0)
     {
-        mBasicPage=new BasicPage(this);
-        mBasicPage->rbSelection->setEnabled(!selection.isEmpty());
-        connect(mBasicPage->cbStyle, SIGNAL(activated(int)),
+        mContactSelection = new ContactSelection( this );
+        mContactSelection->rbSelection->setEnabled( !selection.isEmpty() );
+        insertPage( mContactSelection, i18n("Chose Contacts to Print"), -1 );
+        // add filters to the filter combo
+        mFilters = Filter::restore( kapp->config(), "Filter" );
+        for ( Filter::List::iterator it = mFilters.begin(); it != mFilters.end(); ++it )
+        {
+          mContactSelection->cmbFilters->insertItem( (*it).name() );
+        }
+        mContactSelection->rbUseFilter->setEnabled( mFilters.count() > 0 );
+        
+        // add categories to the categories listview
+        mContactSelection->lvCategories->header()->hide();
+        QStringList cl( KABPrefs::instance()->mCustomCategories );
+        for ( QStringList::Iterator it1 = cl.begin(); it1 != cl.end(); ++it1 )
+        {
+          new QCheckListItem( mContactSelection->lvCategories, *it1, QCheckListItem::CheckBox );
+        }
+        mContactSelection->rbCategoryMembers->setEnabled( cl.count() > 0 );
+        
+        setAppropriate(mContactSelection, true);
+        
+        
+        mStylePage = new StylePage( this );
+        connect(mStylePage->cbStyle, SIGNAL(activated(int)),
                 SLOT(slotStyleSelected(int)));
-        insertPage(mBasicPage, i18n("General"), -1);
-        setAppropriate(mBasicPage, true);
+        insertPage(mStylePage, i18n("Chose Printing Style"), -1);
         registerStyles();
-        if(mBasicPage->cbStyle->count()>0)
+        if(mStylePage->cbStyle->count()>0)
         {
             slotStyleSelected(0);
         }
@@ -72,10 +96,10 @@
         styleFactories.append(new DetailledPrintStyleFactory(this));
         styleFactories.append(new MikesStyleFactory(this));
 
-        mBasicPage->cbStyle->clear();
+        mStylePage->cbStyle->clear();
         for(unsigned int i=0; i<styleFactories.count(); ++i)
         {
-            mBasicPage->cbStyle->insertItem(styleFactories.at(i)->description());
+            mStylePage->cbStyle->insertItem(styleFactories.at(i)->description());
         }
     }
 
@@ -84,7 +108,7 @@
       if ( index < 0 || (unsigned)index >= styleFactories.count() )
         return;
 
-      setFinishEnabled( mBasicPage, false );
+      setFinishEnabled( mStylePage, false );
 
       if ( style )
         style->hidePages();
@@ -103,9 +127,9 @@
       style->showPages();
 
       const QPixmap& preview = style->preview();
-      mBasicPage->plPreview->setPixmap( preview );
+      /*mBasicPage->plPreview*/mStylePage->lPreview->setPixmap( preview );
       if ( preview.isNull() )
-        mBasicPage->plPreview->setText( i18n( "(No preview available.)" ) );
+        /*mBasicPage->plPreview*/mStylePage->lPreview->setText( i18n( "(No preview available.)" ) );
 
       setFinishEnabled( page( pageCount() - 1 ), true );
     }
@@ -131,10 +155,50 @@
         QStringList contacts;
         if(style!=0)
         {
-            if(mBasicPage->rbSelection->isChecked())
+            if(mContactSelection->rbSelection->isChecked())
             {
                 contacts=mSelection;
-            } else {
+            }
+            else if ( mContactSelection->rbUseFilter->isChecked() )
+            {
+                // find contacts that can pass selected filter
+                Filter::List::iterator itf;
+                for ( itf = mFilters.begin(); itf != mFilters.end(); ++itf )
+                    if ( (*itf).name() == mContactSelection->cmbFilters->currentText() )
+                        break;
+                KABC::AddressBook::Iterator iter;
+                for(iter=document()->begin(); iter!=document()->end(); ++iter)
+                {
+                    if ( (*itf).filterAddressee( *iter) )
+                      contacts << (*iter).uid();
+                }
+                
+            }
+            else if ( mContactSelection->rbCategoryMembers->isChecked() )
+            {
+                // find members of checked categories
+                QStringList selectedCategories;
+                QListViewItemIterator it( mContactSelection->lvCategories );
+                for( ; it.current(); ++it )
+                {
+                  if ( dynamic_cast<QCheckListItem*>(it.current())->isOn() )
+                    selectedCategories << it.current()->text( 0 );
+                }
+                KABC::AddressBook::Iterator iter;
+                for(iter=document()->begin(); iter!=document()->end(); ++iter)
+                {
+                    QStringList l ((*iter).categories());
+                    for ( QStringList::Iterator itc = l.begin(); itc != l.end(); ++itc )
+                      if ( selectedCategories.contains( *itc ) )
+                      {
+                           contacts << (*iter).uid();
+                           break;
+                      }
+                }
+               
+            } 
+            else 
+            {
                 // create a string list of all entries:
                 KABC::AddressBook::Iterator iter;
                 for(iter=document()->begin(); iter!=document()->end(); ++iter)
Index: printingwizard.h
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printingwizard.h,v
retrieving revision 1.5
diff -u -r1.5 printingwizard.h
--- printingwizard.h	2002/09/07 15:15:46	1.5
+++ printingwizard.h	2002/11/29 00:10:53
@@ -22,12 +22,16 @@
 #include <qstringlist.h>
 
 #include "../kaddressbookprinter.h"
+#include "../filter.h"
 #include "kabc/addressbook.h"
 #include "printstyle.h"
 
 // ----- the general page:
-#include "printingwizard_base.h"
+//#include "printingwizard_base.h"
+#include "stylepage.h"
+#include "contactselection.h"
 
+
 class KPrinter;
 class QVBoxLayout;
 
@@ -65,9 +69,12 @@
     protected:
         QPtrList<PrintStyleFactory> styleFactories;
         QPtrList<PrintStyle> mStyleList;
+        Filter::List mFilters;
         PrintStyle *style;
         /** The general page. */
-        BasicPage *mBasicPage;
+        //BasicPage *mBasicPage;
+        StylePage *mStylePage;
+        ContactSelection *mContactSelection;
         QVBoxLayout* pageLayout;
         /** Overloaded accept slot. This is used to do the actual
             printing without having the wizard disappearing
Index: printingwizard_base.ui
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printingwizard_base.ui,v
retrieving revision 1.4
diff -u -r1.4 printingwizard_base.ui
--- printingwizard_base.ui	2002/08/01 00:10:18	1.4
+++ printingwizard_base.ui	2002/11/29 00:10:53
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
 <class>BasicPage</class>
 <widget class="QWidget">
     <property name="name">
@@ -88,7 +88,7 @@
             <property name="title">
                 <string>Print Which Contacts</string>
             </property>
-            <vbox>
+            <grid>
                 <property name="name">
                     <cstring>unnamed</cstring>
                 </property>
@@ -98,26 +98,80 @@
                 <property name="spacing">
                     <number>6</number>
                 </property>
-                <widget class="QRadioButton">
+                <widget class="QComboBox" row="2" column="1">
                     <property name="name">
-                        <cstring>rbSelection</cstring>
-                    </property>
-                    <property name="text">
-                        <string>Selection</string>
+                        <cstring>cmbFilters</cstring>
                     </property>
                 </widget>
-                <widget class="QRadioButton">
+                <widget class="QRadioButton" row="0" column="0" rowspan="1" colspan="2">
                     <property name="name">
                         <cstring>rbWholeBook</cstring>
                     </property>
                     <property name="text">
-                        <string>All entries</string>
+                        <string>&amp;All Contacts</string>
                     </property>
                     <property name="checked">
                         <bool>true</bool>
                     </property>
                 </widget>
-            </vbox>
+                <widget class="QRadioButton" row="1" column="0" rowspan="1" colspan="2">
+                    <property name="name">
+                        <cstring>rbSelection</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Selected Contacts</string>
+                    </property>
+                </widget>
+                <widget class="QRadioButton" row="2" column="0">
+                    <property name="name">
+                        <cstring>rbUseFilter</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Contacts Matching &amp;Filter</string>
+                    </property>
+                </widget>
+                <widget class="QRadioButton" row="3" column="0">
+                    <property name="name">
+                        <cstring>rbCategoryMembers</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Category &amp;Members</string>
+                    </property>
+                </widget>
+                <widget class="QListView" row="4" column="0" rowspan="1" colspan="2">
+                    <column>
+                        <property name="text">
+                            <string>Column 1</string>
+                        </property>
+                        <property name="clickable">
+                            <bool>true</bool>
+                        </property>
+                        <property name="resizable">
+                            <bool>true</bool>
+                        </property>
+                    </column>
+                    <property name="name">
+                        <cstring>lvCategories</cstring>
+                    </property>
+                </widget>
+                <spacer row="5" column="0">
+                    <property name="name">
+                        <cstring>spacer2</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Vertical</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Expanding</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>41</width>
+                            <height>121</height>
+                        </size>
+                    </property>
+                </spacer>
+            </grid>
         </widget>
         <widget class="QLayoutWidget" row="1" column="1">
             <property name="name">
@@ -186,8 +240,26 @@
         </widget>
     </grid>
 </widget>
+<connections>
+    <connection>
+        <sender>cmbFilters</sender>
+        <signal>activated(int)</signal>
+        <receiver>BasicPage</receiver>
+        <slot>filterChanged(int)</slot>
+    </connection>
+    <connection>
+        <sender>lvCategories</sender>
+        <signal>clicked(QListViewItem*)</signal>
+        <receiver>BasicPage</receiver>
+        <slot>categoryClicked(QListViewItem*)</slot>
+    </connection>
+</connections>
 <includes>
     <include location="local" impldecl="in implementation">printingwizard_base.ui.h</include>
 </includes>
+<slots>
+    <slot>filterChanged( int )</slot>
+    <slot>categoryClicked( QListViewItem * i )</slot>
+</slots>
 <layoutdefaults spacing="6" margin="11"/>
 </UI>
Index: printingwizard_base.ui.h
===================================================================
RCS file: /home/kde/kdepim/kaddressbook/printing/printingwizard_base.ui.h,v
retrieving revision 1.2
diff -u -r1.2 printingwizard_base.ui.h
--- printingwizard_base.ui.h	2002/05/28 03:59:25	1.2
+++ printingwizard_base.ui.h	2002/11/29 00:10:53
@@ -6,3 +6,16 @@
 ** a constructor, and a destroy() slot in place of a destructor.
 *****************************************************************************/
 
+
+
+void BasicPage::filterChanged( int )
+{
+  rbUseFilter->setChecked(true);
+}
+
+void BasicPage::categoryClicked( QListViewItem *i )
+{
+  if ( dynamic_cast<QCheckListItem*>(i)->isOn() )
+      rbCategoryMembers->setChecked(true);
+}
+

["stylepage.ui" (application/x-designer)]
_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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