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

List:       kde-commits
Subject:    playground/games/kamala/src
From:       Stanislas Marquis <roundphi () gmail ! com>
Date:       2009-05-13 18:58:23
Message-ID: 1242241103.978148.5732.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 967692 by smarquis:

Added context menu to chart context menu event.

 M  +20 -2     core/collections/chartcollection.cpp  
 M  +5 -1      core/collections/chartcollection.h  
 M  +4 -0      core/krossmod.h  
 M  +1 -1      core/objects/context.h  
 M  +18 -4     gui/items/chartitem.cpp  


--- trunk/playground/games/kamala/src/core/collections/chartcollection.cpp #967691:967692
@@ -24,8 +24,10 @@
 #include <QObject>
 #include <KDebug>
 #include "../objects/chart.h"
+#include "../objects/context.h"
 #include "../objects/horoscope.h"
 #include "../preferences.h"
+#include "contextcollection.h"
 #include "horoscopecollection.h"
 #include "settingscollection.h"
 
@@ -111,11 +113,11 @@
     }
 }
 
-void ChartCollection::horoscopeChanged(HoroscopeCollection*, Horoscope *horo, Horoscope::Properties)
+void ChartCollection::contextChanged(ContextCollection*, Context *ctxt, Context::Properties)
 {
     foreach (Chart *ch, d->charts)
     {
-        if (ch->info() == horo)
+        if (ch->context() == ctxt)
         {
             ch->calc();
             emit chartChanged(this, ch);
@@ -135,6 +137,18 @@
     }
 }
 
+void ChartCollection::horoscopeChanged(HoroscopeCollection*, Horoscope *horo, Horoscope::Properties)
+{
+    foreach (Chart *ch, d->charts)
+    {
+        if (ch->info() == horo)
+        {
+            ch->calc();
+            emit chartChanged(this, ch);
+        }
+    }
+}
+
 void ChartCollection::horoscopeAboutToBeDeleted(Horoscope *horo)
 {
     foreach (Chart *ch, d->charts)
@@ -172,6 +186,10 @@
     connect(prefs, SIGNAL(saved(Preferences*)),
         coll, SLOT(preferencesSaved(Preferences*)));
 
+    ContextCollection *ctxtColl = ContextCollection::dbCollection();
+    connect(ctxtColl, SIGNAL(contextChanged(ContextCollection*, Context*, Context::Properties)),
+        coll, SLOT(contextChanged(ContextCollection*, Context*, Context::Properties)));
+
     SettingsCollection *settColl = SettingsCollection::dbCollection();
     connect(settColl, SIGNAL(settingsChanged(SettingsCollection*, Settings*, Settings::Properties)),
         coll, SLOT(settingsChanged(SettingsCollection*, Settings*, Settings::Properties)));
--- trunk/playground/games/kamala/src/core/collections/chartcollection.h #967691:967692
@@ -27,6 +27,7 @@
 #include <QList>
 #include <QObject>
 #include <QSharedDataPointer>
+#include "../objects/context.h"
 #include "../objects/horoscope.h"
 #include "../objects/settings.h"
 #include "../../kamala_export.h"
@@ -35,6 +36,7 @@
 {
 
 class Chart;
+class ContextCollection;
 class HoroscopeCollection;
 class Preferences;
 class SettingsCollection;
@@ -82,10 +84,12 @@
 
     void preferencesSaved(Preferences *prefs);
 
-    void horoscopeChanged(HoroscopeCollection*, Horoscope *horo, Horoscope::Properties);
+    void contextChanged(ContextCollection*, Context *ctxt, Context::Properties);
 
     void settingsChanged(SettingsCollection*, Settings *sett, Settings::Properties);
 
+    void horoscopeChanged(HoroscopeCollection*, Horoscope *horo, Horoscope::Properties);
+
     void horoscopeAboutToBeDeleted(Horoscope *horo);
 
     void slotChartChanged(Chart *ch);
--- trunk/playground/games/kamala/src/core/krossmod.h #967691:967692
@@ -29,6 +29,7 @@
 #include "collections/aspectcollection.h"
 #include "collections/aspectfiltercollection.h"
 #include "collections/aspectrestrictioncollection.h"
+#include "collections/contextcollection.h"
 #include "collections/chartcollection.h"
 #include "collections/horoscopecollection.h"
 #include "collections/keywordcollection.h"
@@ -77,6 +78,9 @@
     Q_SCRIPTABLE Preferences *preferences() const
         { return Preferences::self(); }
 
+    Q_SCRIPTABLE ContextCollection *contextCollection() const
+        { return ContextCollection::dbCollection(); }
+
     Q_SCRIPTABLE SettingsCollection *settingsCollection() const
         { return SettingsCollection::dbCollection(); }
 
--- trunk/playground/games/kamala/src/core/objects/context.h #967691:967692
@@ -264,7 +264,7 @@
     /** @brief Return swisseph flags corresponding to the context
     ** @return flags
     */
-    int swissephFlags() const;
+    Q_SCRIPTABLE int swissephFlags() const;
 
     /** @brief Set default values
     ** Copy default values from preferences (idx is set to 0, name and comments
--- trunk/playground/games/kamala/src/gui/items/chartitem.cpp #967691:967692
@@ -44,6 +44,7 @@
 #include <KSelectAction>
 #include "../../core/collections/aspectcollection.h"
 #include "../../core/collections/chartcollection.h"
+#include "../../core/collections/contextcollection.h"
 #include "../../core/collections/planetcollection.h"
 #include "../../core/collections/settingscollection.h"
 #include "../../core/collections/svgcollection.h"
@@ -409,18 +410,31 @@
 
     KActionMenu *menu = new KActionMenu("Settings", (QObject*) 0);
 
-    SettingsCollection *coll = SettingsCollection::dbCollection();
-    KSelectAction *settingsAction = coll->createSelectAction(m_chart->settings()->name());
+    SettingsCollection *settColl = SettingsCollection::dbCollection();
+    KSelectAction *settingsAction = settColl->createSelectAction(m_chart->settings()->name());
     menu->addAction(settingsAction);
 
+    ContextCollection *ctxtColl = ContextCollection::dbCollection();
+    KSelectAction *contextAction = ctxtColl->createSelectAction(m_chart->context()->name());
+    menu->addAction(contextAction);
+
     QAction *res = menu->menu()->exec(QCursor::pos());
 
-    if (res != 0 && res->text() != m_chart->settings()->name())
+    if (res != 0)
+    if (settingsAction->actions().contains(res)
+        && res->text() != m_chart->settings()->name())
     {
-        m_chart->setSettings(coll->settings(res->text()));
+        m_chart->setSettings(settColl->settings(res->text()));
         m_chart->calc();
         ChartCollection::openedCharts()->slotChartChanged(m_chart);
     }
+    else if (contextAction->actions().contains(res)
+        && res->text() != m_chart->context()->name())
+    {
+        m_chart->setContext(ctxtColl->context(res->text()));
+        m_chart->calc();
+        ChartCollection::openedCharts()->slotChartChanged(m_chart);
+    }
 
     settingsAction->clear();
     delete settingsAction;
[prev in list] [next in list] [prev in thread] [next in thread] 

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