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

List:       kde-commits
Subject:    KDE/kdeplasma-addons/applets/weather
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2009-10-16 23:02:56
Message-ID: 1255734176.582167.32519.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1036300 by aseigo:

don't keep recreating the views time and again; just repopulate the data. not only \
less processing intensive, but less crashy


 M  +19 -12    weatherapplet.cpp  
 M  +1 -0      weatherapplet.h  


--- trunk/KDE/kdeplasma-addons/applets/weather/weatherapplet.cpp #1036299:1036300
@@ -64,6 +64,7 @@
         m_detailsModel(0),
         m_fiveDaysView(0),
         m_detailsView(0),
+        m_noticesView(0),
         m_setupLayout(0),
         m_graphicsWidget(0),
         m_titleFrame(new Plasma::Frame)
@@ -386,11 +387,9 @@
 
     m_tabBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
-    if (m_tabBar->count() > 0) {
-        // If we have items in tab clean it up first
-        while (m_tabBar->count()) {
-             m_tabBar->removeTab(0);
-        }
+    // If we have items in tab clean it up first
+    while (m_tabBar->count()) {
+        m_tabBar->takeTab(0);
     }
 
     // If we have a 5 day forecast, display it
@@ -399,9 +398,6 @@
             kDebug() << "Create 5 Days Plasma::WeatherView";
             m_fiveDaysView = new Plasma::WeatherView(m_tabBar);
             connect(m_fiveDaysView->nativeWidget()->header(), \
SIGNAL(sectionResized(int, int, int)), this, SLOT(fiveDaysColumnResized(int, int, \
                int)));
-
-
-
         }
 
         if (!m_fiveDaysModel) {
@@ -491,10 +487,8 @@
                     lowItems.append(lowItem);
                 }
             }
-
         }
 
-
         if (dayItems.count() > 0) {
             m_fiveDaysModel->appendRow(dayItems);
         }
@@ -515,10 +509,15 @@
             // If we have any items, display 5 Day tab, otherwise only details
             QString totalDays = i18ncp("Forecast period timeframe", "1 Day", "%1 \
Days", data["Total Weather Days"].toInt());  m_tabBar->addTab(totalDays, \
m_fiveDaysView); +        } else {
+            delete m_fiveDaysView;
+            m_fiveDaysView = 0;
         }
+    } else {
+        delete m_fiveDaysView;
+        m_fiveDaysView = 0;
     }
 
-
     // Details data
     if (!m_detailsView) {
         kDebug() << "Create Details Plasma::WeatherView";
@@ -622,6 +621,10 @@
 
     int rowCount = 0;
     if (data["Total Watches Issued"].toInt() > 0 || data["Total Warnings \
Issued"].toInt() > 0) { +        if (!m_noticesView) {
+            m_noticesView = new QGraphicsWidget;
+        }
+
         QGraphicsLinearLayout *noticeLayout = new \
QGraphicsLinearLayout(Qt::Vertical);  QPalette pal;
 
@@ -656,6 +659,7 @@
                 warningLayout->addItem(warnNotice, rowCount, 0);
                 rowCount++;
             }
+
             noticeLayout->addItem(warningLayout);
         }
 
@@ -695,7 +699,10 @@
             noticeLayout->addItem(watchLayout);
         }
 
-        m_tabBar->addTab(i18nc("weather notices", "Notices"), noticeLayout);
+        m_tabBar->addTab(i18nc("weather notices", "Notices"), m_noticesView);
+    } else {
+        delete m_noticesView;
+        m_noticesView = 0;
     }
 
     if (!m_setupLayout) {
--- trunk/KDE/kdeplasma-addons/applets/weather/weatherapplet.h #1036299:1036300
@@ -83,6 +83,7 @@
 
     Plasma::WeatherView *m_fiveDaysView;
     Plasma::WeatherView *m_detailsView;
+    QGraphicsWidget *m_noticesView;
 
     // Layout
     int m_setupLayout;


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

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