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

List:       kde-commits
Subject:    KDE/kdepim/kontact/plugins/summary
From:       Allen Winter <winter () kde ! org>
Date:       2008-04-29 16:54:55
Message-ID: 1209488095.443942.17780.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 802501 by winterz:

Port Qt3 and K3 listwidget stuff to Qt4 QTreeWidget stuff


 M  +1 -1      CMakeLists.txt  
 M  +62 -66    kcmkontactsummary.cpp  
 M  +22 -25    kcmkontactsummary.h  


--- trunk/KDE/kdepim/kontact/plugins/summary/CMakeLists.txt #802500:802501
@@ -35,7 +35,7 @@
 
 
 
-kdepim4_link_unique_libraries(kcm_kontactsummary  ${KDE4_KUTILS_LIBS} \
${KDE4_KDE3SUPPORT_LIBS}) +kdepim4_link_unique_libraries(kcm_kontactsummary  \
${KDE4_KUTILS_LIBS})  
 install(TARGETS kcm_kontactsummary  DESTINATION ${PLUGIN_INSTALL_DIR})
 
--- trunk/KDE/kdepim/kontact/plugins/summary/kcmkontactsummary.cpp #802500:802501
@@ -1,64 +1,64 @@
 /*
-    This file is part of KDE Kontact.
+  This file is part of KDE Kontact.
 
-    Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+  Copyright (c) 2008 Allen Winter <winter@kde.org>
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-    GNU General Public License for more details.
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  You should have received a copy of the GNU General Public License along
+  with this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-    As a special exception, permission is given to link this program
-    with any edition of Qt, and distribute the resulting executable,
-    without including the source code for Qt in the source distribution.
+  As a special exception, permission is given to link this program
+  with any edition of Qt, and distribute the resulting executable,
+  without including the source code for Qt in the source distribution.
 */
 
+#include "kcmkontactsummary.h"
+#include "plugin.h"
+
 #include <kaboutdata.h>
 #include <kconfig.h>
 #include <kdebug.h>
 #include <kdialog.h>
 #include <kiconloader.h>
 #include <klocale.h>
-#include <plugin.h>
+#include <kdemacros.h>
 #include <kplugininfo.h>
 #include <kservicetypetrader.h>
 #include <kcomponentdata.h>
-#include <QLayout>
+
 #include <QLabel>
-#include <QPixmap>
-//Added by qt3to4:
 #include <QVBoxLayout>
+#include <QTreeWidgetItem>
 
-#include "kcmkontactsummary.h"
-
-#include <kdemacros.h>
-
 extern "C"
 {
   KDE_EXPORT KCModule *create_kontactsummary( QWidget *parent, const char * ) {
-    KComponentData inst("kcmkontactsummary");
-    return new KCMKontactSummary( inst,parent );
+    KComponentData inst( "kcmkontactsummary" );
+    return new KCMKontactSummary( inst, parent );
   }
 }
 
-class PluginItem : public Q3CheckListItem
+class PluginItem : public QTreeWidgetItem
 {
   public:
-    PluginItem( const KPluginInfo &info, K3ListView *parent )
-      : Q3CheckListItem( parent, QString(), Q3CheckListItem::CheckBox ),
-        mInfo( info )
+    PluginItem( const KPluginInfo &info, QTreeWidget *parent )
+      : QTreeWidgetItem( parent ), mInfo( info )
     {
-      QPixmap pm = KIconLoader::global()->loadIcon( mInfo.icon(), KIconLoader::Small \
                );
-      setPixmap( 0, pm );
+      setIcon( 0, KIcon( mInfo.icon() ) );
+      setText( 0, mInfo.name() );
+      setToolTip( 0, mInfo.comment() );
+      setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
     }
 
     KPluginInfo pluginInfo() const
@@ -68,12 +68,13 @@
 
     virtual QString text( int column ) const
     {
-      if ( column == 0 )
+      if ( column == 0 ) {
         return mInfo.name();
-      else if ( column == 1 )
+      } else if ( column == 1 ) {
         return mInfo.comment();
-      else
+      } else {
         return QString();
+      }
     }
 
   private:
@@ -81,11 +82,10 @@
 };
 
 PluginView::PluginView( QWidget *parent )
-  : K3ListView( parent )
+  : QTreeWidget( parent )
 {
-  addColumn( i18n( "Name" ) );
-  setAllColumnsShowFocus( true );
-  setFullWidth( true );
+  setColumnCount( 1 );
+  setHeaderLabel( i18nc( "@title:column plugin name", "Summary Plugin Name" ) );
 }
 
 PluginView::~PluginView()
@@ -95,11 +95,13 @@
 KCMKontactSummary::KCMKontactSummary( const KComponentData &inst, QWidget *parent )
   : KCModule( inst, parent )
 {
+  setButtons( NoAdditionalButton );
   QVBoxLayout *layout = new QVBoxLayout( this );
   layout->setSpacing( KDialog::spacingHint() );
   layout->setMargin( 0 );
 
-  QLabel *label = new QLabel( i18n( "Here you can select which summary plugins to \
have visible in your summary view." ), this ); +  QLabel *label =
+    new QLabel( i18n( "Select the plugin summaries to show on the summary page." ), \
this );  layout->addWidget( label );
 
   mPluginView = new PluginView( this );
@@ -107,8 +109,6 @@
 
   layout->setStretchFactor( mPluginView, 1 );
 
-  connect( mPluginView, SIGNAL( clicked( Q3ListViewItem* ) ),
-           this, SLOT( itemClicked( Q3ListViewItem* ) ) );
   load();
 
   KAboutData *about = new KAboutData( I18N_NOOP( "kontactsummary" ), 0,
@@ -116,7 +116,7 @@
                                       0, KLocalizedString(), \
                KAboutData::License_GPL,
                                       ki18n( "(c), 2004 Tobias Koenig" ) );
 
-  about->addAuthor( ki18n("Tobias Koenig"), KLocalizedString(), "tokoe@kde.org" );
+  about->addAuthor( ki18n( "Tobias Koenig" ), KLocalizedString(), "tokoe@kde.org" );
   setAboutData( about );
 }
 
@@ -141,56 +141,52 @@
     activeSummaries << "kontact_newstickerplugin";
     activeSummaries << "kontact_plannerplugin";
   } else {
-    activeSummaries = grp.readEntry( "ActiveSummaries" , QStringList() );
+    activeSummaries = grp.readEntry( "ActiveSummaries", QStringList() );
   }
 
   mPluginView->clear();
 
-  KPluginInfo::List pluginList = KPluginInfo::fromServices( offers, KConfigGroup( \
&config, "Plugins" ) ); +  KPluginInfo::List pluginList =
+    KPluginInfo::fromServices( offers, KConfigGroup( &config, "Plugins" ) );
   KPluginInfo::List::Iterator it;
   for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
     it->load();
 
-    if ( !it->isPluginEnabled() )
+    if ( !it->isPluginEnabled() ) {
       continue;
+    }
 
     QVariant var = it->property( "X-KDE-KontactPluginHasSummary" );
-    if ( !var.isValid() )
-      continue;
-
-    if ( var.toBool() == true ) {
+    if ( var.isValid() && var.toBool() == true ) {
       PluginItem *item = new PluginItem( *it, mPluginView );
 
-      if ( activeSummaries.contains( it->pluginName() )  )
-        item->setOn( true );
+      if ( activeSummaries.contains( it->pluginName() ) ) {
+        item->setCheckState( 0, Qt::Checked );
+      } else {
+        item->setCheckState( 0, Qt::Unchecked );
+      }
     }
   }
 }
 
 void KCMKontactSummary::save()
 {
+  kDebug();
   QStringList activeSummaries;
 
-  Q3ListViewItemIterator it( mPluginView, Q3ListViewItemIterator::Checked );
-  while ( it.current() ) {
-    PluginItem *item = static_cast<PluginItem*>( it.current() );
-    activeSummaries.append( item->pluginInfo().pluginName() );
+  QTreeWidgetItemIterator it( mPluginView );
+  while ( *it ) {
+    PluginItem *item = static_cast<PluginItem *>( *it );
+    if ( item->checkState( 0 ) == Qt::Checked ) {
+      activeSummaries.append( item->pluginInfo().pluginName() );
+    }
     ++it;
   }
 
   KConfig config( "kontact_summaryrc" );
   KConfigGroup grp( &config, QString() );
+  kDebug() << "saving activesummaries " << activeSummaries;
   grp.writeEntry( "ActiveSummaries", activeSummaries );
 }
 
-void KCMKontactSummary::defaults()
-{
-  emit changed( true );
-}
-
-void KCMKontactSummary::itemClicked( Q3ListViewItem* )
-{
-  emit changed( true );
-}
-
 #include "kcmkontactsummary.moc"
--- trunk/KDE/kdepim/kontact/plugins/summary/kcmkontactsummary.h #802500:802501
@@ -1,36 +1,37 @@
 /*
-    This file is part of KDE Kontact.
+  This file is part of KDE Kontact.
 
-    Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+  Copyright (c) 2008 Allen Winter <winter@kde.org>
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-    GNU General Public License for more details.
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  You should have received a copy of the GNU General Public License along
+  with this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-    As a special exception, permission is given to link this program
-    with any edition of Qt, and distribute the resulting executable,
-    without including the source code for Qt in the source distribution.
+  As a special exception, permission is given to link this program
+  with any edition of Qt, and distribute the resulting executable,
+  without including the source code for Qt in the source distribution.
 */
 
 #ifndef KCMKONTACTSUMMARY_H
 #define KCMKONTACTSUMMARY_H
 
 #include <kcmodule.h>
-#include <k3listview.h>
+#include <QTreeWidget>
 
 class KPluginInfo;
 
-class PluginView : public K3ListView
+class PluginView : public QTreeWidget
 {
   Q_OBJECT
 
@@ -44,15 +45,11 @@
   Q_OBJECT
 
   public:
-    explicit KCMKontactSummary( const KComponentData &inst,QWidget *parent = 0 );
+    explicit KCMKontactSummary( const KComponentData &inst, QWidget *parent = 0 );
 
-    virtual void load();
-    virtual void save();
-    virtual void defaults();
+    void load();
+    void save();
 
-  private slots:
-    void itemClicked( Q3ListViewItem* );
-
   private:
     PluginView *mPluginView;
 };


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

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