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

List:       kde-commits
Subject:    extragear/pim/mailody/src
From:       Tom Albers <tomalbers () kde ! nl>
Date:       2008-06-14 11:46:49
Message-ID: 1213444009.314426.15423.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 820464 by toma:

Only statics here, make it a namespace instead of a class.


 M  +12 -28    global.cpp  
 M  +15 -36    global.h  


--- trunk/extragear/pim/mailody/src/global.cpp #820463:820464
@@ -29,28 +29,11 @@
 #include <kpimidentities/identity.h>
 #include <kpimidentities/identitymanager.h>
 
-using namespace Mailody;
+namespace Mailody {
+namespace Global {
 
-Global *Global::m_instance = 0;
-
-Global::Global( QObject *parent, const char *name )
-        : QObject( parent )
+bool myEmail( const QString& email, bool refresh )
 {
-    setObjectName( name );
-}
-
-Global::~Global()
-{}
-
-Global* Global::instance()
-{
-    if ( !m_instance )
-        m_instance = new Global();
-    return m_instance;
-}
-
-bool Global::myEmail( const QString& email, bool refresh )
-{
     static QStringList emails;
     if ( refresh || !emails.count() )
         emails = identityManager()->allEmails();
@@ -65,18 +48,18 @@
     return false;
 }
 
-const KPIMIdentities::Identity Global::getIdentityForEmail( const QString& email )
+const KPIMIdentities::Identity getIdentityForEmail( const QString& email )
 {
     return identityManager()->identityForAddress( email );
 }
 
-void Global::timing( const QString& text, struct timeval tv1, struct timeval tv2 )
+void timing( const QString& text, struct timeval tv1, struct timeval tv2 )
 {
     kDebug() << "Time: " << text + ": " << ((( tv2.tv_sec-tv1.tv_sec )*1000000 +
                                             ( tv2.tv_usec-tv1.tv_usec ) )/1000 ) << " ms";
 }
 
-QString Global::highlightText( const QString& text )
+QString highlightText( const QString& text )
 {
     // make the quotation colors.
     QStringList temp = text.split( "\n" );
@@ -89,7 +72,7 @@
     return result;
 }
 
-QString Global::highlightParagraph( const QString& text )
+QString highlightParagraph( const QString& text )
 {
     bool found = false;
     QColor color;
@@ -117,14 +100,14 @@
         return text;
 }
 
-bool Global::connectionPossible()
+bool connectionPossible()
 {
     return Solid::Networking::status()==Solid::Networking::Connected ||
            Solid::Networking::status()==Solid::Networking::Unknown;
 }
 
 // from kmail
-KPIMIdentities::IdentityManager * Global::identityManager()
+KPIMIdentities::IdentityManager * identityManager()
 {
     static KPIMIdentities::IdentityManager *s_identityManager;
     if ( !s_identityManager ) {
@@ -135,7 +118,7 @@
     return s_identityManager;
 }
 
-QString Global::quote( const QString &text, bool stripSig )
+QString quote( const QString &text, bool stripSig )
 {
     // We only quote untill we match a "-- ". After that the code will buffer
     // the rest. If after the "-- " a ^> is matched, then the code is added
@@ -182,5 +165,6 @@
     }
     return result;
 }
+}
+}
 
-#include "global.moc"
--- trunk/extragear/pim/mailody/src/global.h #820463:820464
@@ -28,45 +28,27 @@
 
 #include <kpimidentities/identitymanager.h>
 
+namespace Mailody {
 
-namespace Mailody
-{
-
 static const char s_usehtml[] = "useHTMLPart";
 static const char s_preferhtml[] = "preferComposeHTML";
 static const char s_usesig[] = "useSig";
 static const char s_signature[] = "signature";
 static const char s_sigpos[] = "SigPos";
 
-/**
- * @class Global
- * This class consists of a few commonly used routines and values.
- * @author Tom Albers <tomalbers@kde.nl>
- */
-class Global : public QObject
+namespace Global 
 {
-    Q_OBJECT
-public:
-    /** Default constructor. */
-    explicit Global( QObject *parent = 0, const char *name = 0 );
-
-    /** Default destructor. */
-    ~Global();
-
     /**
-     * Returns an instance of RSIGlobals. Never create your own instance
-     * of RSIGlobals, but use this method instead to get the one and only
-     * instance.
-     */
-    static Global *instance();
-
-    /**
      * Will return the identites cached and not updated
      * during lifetime unless @p force is true
      * @param force refresh
      */
-    static bool myEmail( const QString& email, bool refresh=false );
-    static const KPIMIdentities::Identity getIdentityForEmail(
+    bool myEmail( const QString& email, bool refresh=false );
+
+    /** 
+     * Returns the identity which has @p email as address.
+     */
+    const KPIMIdentities::Identity getIdentityForEmail(
         const QString& email );
 
     /**
@@ -81,41 +63,38 @@
      *   gettimeofday(&tv2, 0);
      *   Global::timing("expensive stuff", tv1, tv2);
      */
-    static void timing( const QString& text, struct timeval tv1,
+    void timing( const QString& text, struct timeval tv1,
                         struct timeval tv2 );
 
     /**
      * this will color each paragraph with a color depending on the
      * quotatation level.
      */
-    static QString highlightText( const QString& text );
+    QString highlightText( const QString& text );
 
     /** this will color the text with a color depending on the quotation
      * level
      */
-    static QString highlightParagraph( const QString& text );
+    QString highlightParagraph( const QString& text );
 
     /**
      * This will report the network state of KDE.There is no need to
      * try to connect to a server when the computer is not connected
      * to a network.
      */
-    static bool connectionPossible();
+    bool connectionPossible();
 
     /**
      * Returns the identitymanager.
      */
-    static KPIMIdentities::IdentityManager * identityManager();
+    KPIMIdentities::IdentityManager * identityManager();
 
     /**
       * Alters @p text so it contains an extra > in front of each line;
       */
-    static QString quote( const QString &text, bool stripSig=true );
+    QString quote( const QString &text, bool stripSig=true );
+}
 
-private:
-    static Global* m_instance;
-};
-
 }
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

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