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

List:       kde-commits
Subject:    playground/network/videocatcher/src
From:       Jonas Emanuel Müller <zanoi () zanoi ! net>
Date:       2010-12-05 18:55:53
Message-ID: 20101205185553.09F83AC8A4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1203939 by jonasemuller:

added offline support

 M  +29 -0     mainwindowkde.cpp  
 M  +2 -0      mainwindowkde.h  


--- trunk/playground/network/videocatcher/src/mainwindowkde.cpp #1203938:1203939
@@ -183,6 +183,9 @@
     d->m_autoRefreshChannelsTimer = new QTimer(this);
     initAutoRefreshChannels();
 
+    connect(Solid::Networking::notifier(), \
SIGNAL(statusChanged(Solid::Networking::Status)), +        \
SLOT(networkStatusChanged(Solid::Networking::Status))); +
     //workaround for Qt SQLite bug
     while (d->m_originalEpisodeModel->canFetchMore()) {
         d->m_originalEpisodeModel->fetchMore();
@@ -238,6 +241,10 @@
     refreshChannelAction->setIcon(KIcon("view-refresh"));
     refreshChannelAction->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Reload));
  refreshChannelAction->setStatusTip(i18n("Refresh selected channel"));
+    //if not connected to any network
+    if(Solid::Networking::status() != Solid::Networking::Connected && \
Solid::Networking::status() != Solid::Networking::Unknown) { +        \
refreshChannelAction->setEnabled(false); +    }
     actionCollection()->addAction("refresh", refreshChannelAction);
     connect(refreshChannelAction, SIGNAL(triggered()), this, \
SLOT(refreshChannel()));  
@@ -245,6 +252,10 @@
     refreshAllChannelsAction->setShortcuts(KShortcut("Ctrl+L"));
     refreshAllChannelsAction->setIcon(KIcon("view-refresh")); //"go-bottom"
     refreshAllChannelsAction->setStatusTip(i18n("Refresh all channels"));
+    //if not connected to any network
+    if(Solid::Networking::status() != Solid::Networking::Connected && \
Solid::Networking::status() != Solid::Networking::Unknown) { +        \
refreshAllChannelsAction->setEnabled(false); +    }
     actionCollection()->addAction("refreshAll", refreshAllChannelsAction);
     connect(refreshAllChannelsAction, SIGNAL(triggered()), this, \
SLOT(refreshAllChannels()));  
@@ -645,6 +656,8 @@
 void MainWindow::initAutoRefreshChannels()
 {
     d->m_autoRefreshChannelsTimer->stop(); //if timer is already running, stop it
+    //only set timer if connected to a network
+    if(Solid::Networking::status() == Solid::Networking::Connected || \
                Solid::Networking::status() == Solid::Networking::Unknown) { 
     if(d->m_channelModel->rowCount()) { //only set timer if there are any channels
         //get the refresh single channel refresh time from the settings and convert \
                it to milliseconds
         int singleChannelAutoRefreshInterval = \
Configure::channelRefreshInterval().toInt() * 60000; @@ -659,6 +672,7 @@
         d->m_autoRefreshChannelsTimer->start(autoRefreshInterval); //start counter \
with the calculated refresh time and calling autoRefreshChannels  }
 }
+}
 
 /** This is the slot that is called  by the timer to automatically refresh channels. \
                
  * It works by refreshing one channel at each call, and cycling through all \
available channels. @@ -1147,6 +1161,21 @@
     qApp->quit();
 }
 
+void MainWindow::networkStatusChanged(Solid::Networking::Status status)
+{
+    kDebug() << "network status changed";
+    //update automatic refresh, disables automatic refreshed if not connected to a \
network +    initAutoRefreshChannels();
+    if(Solid::Networking::status() == Solid::Networking::Connected || \
Solid::Networking::status() == Solid::Networking::Unknown) { +        \
action("refresh")->setEnabled(true); +        action("refreshAll")->setEnabled(true);
+        refreshAllChannels();
+    } else {
+        action("refresh")->setEnabled(false);
+        action("refreshAll")->setEnabled(false);
+    }
+}
+
 void MainWindow::episodeDoubleClicked(const QModelIndex &index) 
 {
     int status;
--- trunk/playground/network/videocatcher/src/mainwindowkde.h #1203938:1203939
@@ -31,6 +31,7 @@
 #include <QMap>
 
 #include <KXmlGuiWindow>
+#include <Solid/Networking>
 #include <kdeversion.h>
 
 class QTableView;
@@ -93,6 +94,7 @@
     void copyEpisodeURLToClipboard();
     void importChannels();
     void quit();
+    void networkStatusChanged(Solid::Networking::Status status);
 
 protected:
     void updatePlayMenu(const QString &mimeType);


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

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