summaryrefslogtreecommitdiffstats
path: root/plugins/scheduler
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
commit9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0 (patch)
treed088b5210e77d9fa91d954d8550e00e372b47378 /plugins/scheduler
downloadktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.tar.gz
ktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.zip
Updated to final KDE3 ktorrent release (2.2.6)
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktorrent@1077377 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'plugins/scheduler')
-rw-r--r--plugins/scheduler/Makefile.am36
-rw-r--r--plugins/scheduler/bwscheduler.cpp282
-rw-r--r--plugins/scheduler/bwscheduler.h173
-rw-r--r--plugins/scheduler/bwspage.ui877
-rw-r--r--plugins/scheduler/bwsprefpage.cpp0
-rw-r--r--plugins/scheduler/bwsprefpage.h0
-rw-r--r--plugins/scheduler/bwsprefpagewidget.cpp291
-rw-r--r--plugins/scheduler/bwsprefpagewidget.h84
-rw-r--r--plugins/scheduler/bwswidget.cpp334
-rw-r--r--plugins/scheduler/bwswidget.h107
-rw-r--r--plugins/scheduler/cell-a-0000.pngbin0 -> 700 bytes
-rw-r--r--plugins/scheduler/cell-a-0001.pngbin0 -> 1003 bytes
-rw-r--r--plugins/scheduler/cell-a-0002.pngbin0 -> 1102 bytes
-rw-r--r--plugins/scheduler/cell-a-0003.pngbin0 -> 1174 bytes
-rw-r--r--plugins/scheduler/cell-a-0004.pngbin0 -> 744 bytes
-rw-r--r--plugins/scheduler/cell-b-0000.pngbin0 -> 672 bytes
-rw-r--r--plugins/scheduler/cell-b-0001.pngbin0 -> 979 bytes
-rw-r--r--plugins/scheduler/cell-b-0002.pngbin0 -> 1063 bytes
-rw-r--r--plugins/scheduler/cell-b-0003.pngbin0 -> 1119 bytes
-rw-r--r--plugins/scheduler/cell-b-0004.pngbin0 -> 728 bytes
-rw-r--r--plugins/scheduler/ktschedulerplugin.desktop26
-rw-r--r--plugins/scheduler/ktschedulerplugin.kcfg18
-rw-r--r--plugins/scheduler/ktschedulerpluginui.rc12
-rw-r--r--plugins/scheduler/schedulerpage.ui146
-rw-r--r--plugins/scheduler/schedulerplugin.cpp152
-rw-r--r--plugins/scheduler/schedulerplugin.h70
-rw-r--r--plugins/scheduler/schedulerpluginsettings.kcfgc7
-rw-r--r--plugins/scheduler/schedulerprefpage.cpp64
-rw-r--r--plugins/scheduler/schedulerprefpage.h53
-rw-r--r--plugins/scheduler/schedulerprefpagewidget.cpp83
-rw-r--r--plugins/scheduler/schedulerprefpagewidget.h50
31 files changed, 2865 insertions, 0 deletions
diff --git a/plugins/scheduler/Makefile.am b/plugins/scheduler/Makefile.am
new file mode 100644
index 0000000..b2c9760
--- /dev/null
+++ b/plugins/scheduler/Makefile.am
@@ -0,0 +1,36 @@
+INCLUDES = -I$(srcdir)/../../libktorrent $(all_includes)
+METASOURCES = AUTO
+kde_module_LTLIBRARIES = ktschedulerplugin.la
+noinst_HEADERS = schedulerplugin.h bwscheduler.h schedulerprefpagewidget.h \
+ bwsprefpagewidget.h bwswidget.h schedulerprefpage.h
+ktschedulerplugin_la_SOURCES = schedulerplugin.cpp \
+ schedulerpluginsettings.kcfgc bwscheduler.cpp schedulerprefpagewidget.cpp schedulerpage.ui bwspage.ui \
+ bwsprefpagewidget.cpp bwswidget.cpp schedulerprefpage.cpp
+
+# Libs needed by the plugin
+ktschedulerplugin_la_LIBADD = $(LIB_KHTML) $(LIB_KPARTS) \
+ ../../libktorrent/libktorrent.la \
+ $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KFILE)
+
+# LD flags for the plugin
+# -module says: this is a module, i.e. something you're going to dlopen
+# so e.g. it has no version number like a normal shared lib would have.
+ktschedulerplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+# rc file containing the GUI for the plugin
+# pluginsdir = $(kde_datadir)/ktschedulerplugin
+# plugins_DATA = ktschedulerpluginui.rc
+
+# Install the desktop file needed to detect the plugin
+kde_services_DATA = ktschedulerplugin.desktop
+
+kde_kcfg_DATA = ktschedulerplugin.kcfg
+
+kticonsdir = $(kde_datadir)/ktorrent/icons
+
+kticons_DATA = cell-a-0000.png cell-a-0001.png cell-a-0002.png cell-a-0003.png\
+ cell-a-0004.png cell-b-0000.png cell-b-0001.png cell-b-0002.png\
+ cell-b-0003.png cell-b-0004.png
+rcdir = $(kde_datadir)/ktorrent
+rc_DATA = ktschedulerpluginui.rc
+KDE_CXXFLAGS = $(USE_EXCEPTIONS) $(USE_RTTI)
diff --git a/plugins/scheduler/bwscheduler.cpp b/plugins/scheduler/bwscheduler.cpp
new file mode 100644
index 0000000..56375b5
--- /dev/null
+++ b/plugins/scheduler/bwscheduler.cpp
@@ -0,0 +1,282 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#include "bwscheduler.h"
+#include "schedulerpluginsettings.h"
+
+#include <torrent/globals.h>
+#include <torrent/queuemanager.h>
+
+#include <interfaces/coreinterface.h>
+#include <interfaces/torrentinterface.h>
+
+#include <net/socketmonitor.h>
+
+#include <util/constants.h>
+#include <util/log.h>
+
+#include <qdatetime.h>
+#include <qfile.h>
+#include <qptrlist.h>
+
+#include <kglobal.h>
+#include <kstandarddirs.h>
+
+using namespace bt;
+
+namespace kt
+{
+ // ****** BWS *----------------------------------------------------------------------
+ BWS::BWS()
+ {
+ m_schedule = new ScheduleCategory*[7];
+ for(int i=0; i<7; ++i)
+ m_schedule[i] = new ScheduleCategory[24];
+
+ reset();
+ }
+
+ BWS& kt::BWS::operator=(const BWS& b)
+ {
+ for(int i=0; i<7; ++i)
+ for(int j=0; j<24; ++j)
+ m_schedule[i][j] = b.m_schedule[i][j];
+
+ for(int i=0; i<3; ++i)
+ {
+ download[i] = b.download[i];
+ upload[i] = b.upload[i];
+ }
+
+ return *this;
+ }
+
+ int BWS::getDownload(int cat)
+ {
+ return download[cat];
+ }
+
+ int BWS::getUpload(int cat)
+ {
+ return upload[cat];
+ }
+
+ void BWS::setDownload(int cat, int val)
+ {
+ download[cat] = val;
+ }
+
+ void BWS::setUpload(int cat, int val)
+ {
+ upload[cat] = val;
+ }
+
+ void BWS::setCategory(int day, int hour, ScheduleCategory val)
+ {
+ m_schedule[day][hour] = val;
+ }
+
+ ScheduleCategory BWS::getCategory(int day, int hour)
+ {
+ return m_schedule[day][hour];
+ }
+
+ void BWS::reset()
+ {
+ for(int i=0; i<7; ++i)
+ for(int j=0; j<24; ++j)
+ m_schedule[i][j] = CAT_NORMAL;
+
+ for(int i=0; i<3; ++i)
+ {
+ download[i] = 0;
+ upload[i] = 0;
+ }
+ }
+
+ BWS::~BWS()
+ {
+ for(int i=0; i<7; ++i)
+ delete [] m_schedule[i];
+
+ delete [] m_schedule;
+ }
+
+ void BWS::debug()
+ {
+ for(int i=0; i<7; ++i)
+ {
+ Log & lg = Out();
+ for(int j=0; j<24; ++j)
+ lg << m_schedule[i][j];
+ lg << endl;
+ }
+ }
+
+ // ---- BWScheduler --------------------------------------------------------------------
+
+ BWScheduler::BWScheduler()
+ : m_core(0)
+ {
+ m_enabled = SchedulerPluginSettings::enableBWS();
+ loadSchedule();
+ }
+
+ BWScheduler::~BWScheduler()
+ {
+ }
+
+ void BWScheduler::setSchedule(const BWS& sch)
+ {
+ Out(SYS_SCD|LOG_NOTICE) << "BWS: Setting new schedule..." << endl;
+ m_schedule = sch;
+ saveSchedule();
+ trigger();
+ }
+
+ void BWScheduler::setCoreInterface(CoreInterface* core)
+ {
+ m_core = core;
+ }
+
+ void BWScheduler::trigger()
+ {
+ if(!m_enabled)
+ return;
+
+ QDateTime now = QDateTime::currentDateTime();
+
+ QString prefix = QString("BWS: %1 :: ").arg(now.toString());
+
+ int t1 = now.date().dayOfWeek();
+ int t2 = now.time().hour();
+ ScheduleCategory sch = m_schedule.getCategory(t1-1, t2);
+
+ switch(sch)
+ {
+ case CAT_NORMAL:
+ Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to NORMAL category" << endl;
+ Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+ .arg(m_core->getMaxUploadSpeed()).arg(m_core->getMaxDownloadSpeed()) << endl;
+ if(!m_core)
+ break;
+ m_core->setPausedState(false);
+ net::SocketMonitor::setDownloadCap(1024 * m_core->getMaxDownloadSpeed());
+ net::SocketMonitor::setUploadCap(1024 * m_core->getMaxUploadSpeed());
+ break;
+ case CAT_FIRST:
+ Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to FIRST category" << endl;
+ Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+ .arg(m_schedule.getUpload(0)).arg(m_schedule.getDownload(0)) << endl;
+ if(!m_core)
+ break;
+ m_core->setPausedState(false);
+ net::SocketMonitor::setDownloadCap(1024 * m_schedule.getDownload(0));
+ net::SocketMonitor::setUploadCap(1024 * m_schedule.getUpload(0));
+ break;
+ case CAT_SECOND:
+ Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to SECOND category" << endl;
+ Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+ .arg(m_schedule.getUpload(1)).arg(m_schedule.getDownload(1)) << endl;
+ if(!m_core)
+ break;
+ m_core->setPausedState(false);
+ net::SocketMonitor::setDownloadCap(1024 * m_schedule.getDownload(1));
+ net::SocketMonitor::setUploadCap(1024 * m_schedule.getUpload(1));
+ break;
+ case CAT_THIRD:
+ Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to THIRD category" << endl;
+ Out(SYS_SCD|LOG_NOTICE) << prefix << QString("%1 Up, %2 Down")
+ .arg(m_schedule.getUpload(2)).arg(m_schedule.getDownload(2)) << endl;
+ if(!m_core)
+ break;
+ m_core->setPausedState(false);
+ net::SocketMonitor::setDownloadCap(1024 * m_schedule.getDownload(2));
+ net::SocketMonitor::setUploadCap(1024 * m_schedule.getUpload(2));
+ break;
+ case CAT_OFF:
+ Out(SYS_SCD|LOG_NOTICE) << prefix << "Switching to OFF" << endl;
+
+ if(!m_core)
+ break;
+ m_core->setPausedState(true);
+ break;
+ }
+ }
+
+ void BWScheduler::loadSchedule()
+ {
+ QFile file(KGlobal::dirs()->saveLocation("data","ktorrent") + "bwschedule");
+
+ if(!file.exists())
+ return;
+
+ file.open(IO_ReadOnly);
+ QDataStream stream(&file);
+
+ int tmp;
+
+ //extract category values
+ for(int i=0; i<3; ++i)
+ {
+ stream >> tmp;
+ m_schedule.setDownload(i, tmp);
+ stream >> tmp;
+ m_schedule.setUpload(i, tmp);
+ }
+
+ //extract schedule
+ for(int i=0; i<7; ++i)
+ {
+ for(int j=0; j<24; ++j)
+ {
+ stream >> tmp;
+ m_schedule.setCategory(i, j, (ScheduleCategory) tmp);
+ }
+ }
+
+ file.close();
+ }
+
+ void BWScheduler::saveSchedule()
+ {
+ QFile file(KGlobal::dirs()->saveLocation("data","ktorrent") + "bwschedule");
+
+ file.open(IO_WriteOnly);
+ QDataStream stream(&file);
+
+ for(int i=0; i<3; ++i)
+ {
+ stream << m_schedule.getDownload(i);
+ stream << m_schedule.getUpload(i);
+ }
+
+ //Now schedule
+ for(int i=0; i<7; ++i)
+ for(int j=0; j<24; ++j)
+ stream << (int) m_schedule.getCategory(i, j);
+
+ file.close();
+ }
+
+ void BWScheduler::setEnabled(bool theValue)
+ {
+ m_enabled = theValue;
+ }
+}
diff --git a/plugins/scheduler/bwscheduler.h b/plugins/scheduler/bwscheduler.h
new file mode 100644
index 0000000..e752b1d
--- /dev/null
+++ b/plugins/scheduler/bwscheduler.h
@@ -0,0 +1,173 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#ifndef KTBWSCHEDULER_H
+#define KTBWSCHEDULER_H
+
+#include <interfaces/coreinterface.h>
+
+namespace kt
+{
+
+ typedef enum bws_category
+ {
+ CAT_NORMAL,
+ CAT_FIRST,
+ CAT_SECOND,
+ CAT_THIRD,
+ CAT_OFF
+ }ScheduleCategory;
+
+ /**
+ * @author Ivan Vasic <ivasic@gmail.com>
+ * @brief This class represents bandwidth schedule for the week.
+ * It simplifies usage of 2 dimensional schedule (array) and its transfer between classes.
+ */
+ class BWS
+ {
+ ///Schedule
+ ScheduleCategory** m_schedule;
+
+ ///Download categories
+ int download[3];
+ ///Upload categories
+ int upload[3];
+
+ public:
+ BWS();
+ BWS& operator=(const BWS& b);
+ ~BWS();
+
+ /**
+ * @brief Resets this schedule.
+ */
+ void reset();
+
+
+ /**
+ * Gets download rate for category <i>cat</i>.
+ * @param cat download category index
+ * @return Download rate in KB/s
+ */
+ int getDownload(int cat);
+
+ /**
+ * Gets upload rate for category <i>cat</i>.
+ * @param cat upload category index
+ * @return upload rate in KB/s
+ */
+ int getUpload(int cat);
+
+
+ /**
+ * @brief Gets category for specified <i>day</i> and <i>hour</i>.
+ * @param day Number of day in a week.
+ * @param hour Hour of the day.
+ * @return ScheduleCategory - category associated with that day/hour.
+ */
+ ScheduleCategory getCategory(int day, int hour);
+
+
+ /**
+ * @brief Sets download rate for a category.
+ * @param cat Category to set rate to.
+ * @param val Download rate to set to category in KB/s
+ */
+ void setDownload(int cat, int val);
+
+ /**
+ * @brief Sets upload rate for a category.
+ * @param cat Category to set rate to.
+ * @param val Upload rate to set to category in KB/s
+ */
+ void setUpload(int cat, int val);
+
+
+ /**
+ * @brief Sets category for specified <i>day</i>/<i>hour</i> combination.
+ * @param day Day of the week.
+ * @param hour Hour of the day.
+ * @param val Category value.
+ */
+ void setCategory(int day, int hour, ScheduleCategory val);
+
+ ///Prints schedule to LogViewer. Used only for debugging.
+ void debug();
+ };
+
+
+ /**
+ * @brief Bandwidth scheduler class.
+ * @author Ivan Vasic <ivasic@gmail.com>
+ * Singleton class. Used to keep bandwidth schedule and change download/upload rate as necessary.
+ */
+ class BWScheduler
+ {
+ public:
+ inline static BWScheduler& instance()
+ {
+ static BWScheduler self;
+ return self;
+ }
+ ~BWScheduler();
+
+ /**
+ * Triggers bandwidth limit changes (if needed).
+ */
+ void trigger();
+
+ /**
+ * Sets a new schedule.
+ * @param sch - new BWS schedule.
+ * @note Call trigger() after setting new schedule for changes to take effect.
+ */
+ void setSchedule(const BWS& sch);
+
+ /**
+ * Sets a pointer to CoreInterface.
+ * Needed for getting global bandwidth limits.
+ * @param core Pointer to CoreInterface
+ */
+ void setCoreInterface(CoreInterface* core);
+
+ ///Pauses all torrents (TURN OFF category)
+ void pauseAll();
+
+ ///Loads schedule from HD
+ void loadSchedule();
+ ///Saves schedule to HD
+ void saveSchedule();
+
+ void setEnabled(bool theValue);
+
+
+ protected:
+ BWScheduler();
+ BWScheduler(const BWScheduler&);
+ BWScheduler& operator=(const BWScheduler&);
+
+ BWS m_schedule;
+ CoreInterface* m_core;
+
+ bool m_enabled;
+ };
+}
+
+#endif
+
diff --git a/plugins/scheduler/bwspage.ui b/plugins/scheduler/bwspage.ui
new file mode 100644
index 0000000..af0e771
--- /dev/null
+++ b/plugins/scheduler/bwspage.ui
@@ -0,0 +1,877 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>BWSPage</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>BWSPage</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>718</width>
+ <height>530</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>750</width>
+ <height>540</height>
+ </size>
+ </property>
+ <property name="caption">
+ <string>Bandwidth scheduler</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>Fixed</enum>
+ </property>
+ <widget class="QLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>layout21</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>buttonGroup1</cstring>
+ </property>
+ <property name="title">
+ <string>Left click category</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="1" column="1">
+ <property name="name">
+ <cstring>radio2</cstring>
+ </property>
+ <property name="text">
+ <string>Categor&amp;y 1</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>pix1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>pix2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>pix3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>pix5</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="4" column="1">
+ <property name="name">
+ <cstring>radio5</cstring>
+ </property>
+ <property name="text">
+ <string>T&amp;urn off</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="1">
+ <property name="name">
+ <cstring>radio1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Normal</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>pix4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="3" column="1">
+ <property name="name">
+ <cstring>radio4</cstring>
+ </property>
+ <property name="text">
+ <string>Category &amp;3</string>
+ </property>
+ <property name="accel">
+ <string>Alt+3</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="2" column="1">
+ <property name="name">
+ <cstring>radio3</cstring>
+ </property>
+ <property name="text">
+ <string>Category &amp;2</string>
+ </property>
+ <property name="accel">
+ <string>Alt+2</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>buttonGroup1_2</cstring>
+ </property>
+ <property name="title">
+ <string>Right click category</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="1" column="1">
+ <property name="name">
+ <cstring>radio22</cstring>
+ </property>
+ <property name="text">
+ <string>Category &amp;1</string>
+ </property>
+ <property name="accel">
+ <string>Alt+1</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>pix12</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>pix22</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>pix32</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>pix52</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="4" column="1">
+ <property name="name">
+ <cstring>radio52</cstring>
+ </property>
+ <property name="text">
+ <string>T&amp;urn off</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="1">
+ <property name="name">
+ <cstring>radio12</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Normal</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>pix42</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>30</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="3" column="1">
+ <property name="name">
+ <cstring>radio42</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Category 3</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="2" column="1">
+ <property name="name">
+ <cstring>radio32</cstring>
+ </property>
+ <property name="text">
+ <string>Category &amp;2</string>
+ </property>
+ <property name="accel">
+ <string>Alt+2</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox" row="1" column="1">
+ <property name="name">
+ <cstring>groupCategories_2</cstring>
+ </property>
+ <property name="title">
+ <string>Categories</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel8_4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;1. Category&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel8_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;3. Category&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6_5</cstring>
+ </property>
+ <property name="text">
+ <string>download:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>dlCat1</cstring>
+ </property>
+ <property name="maxValue">
+ <number>30000</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6_4_4</cstring>
+ </property>
+ <property name="text">
+ <string>upload:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>ulCat1</cstring>
+ </property>
+ <property name="maxValue">
+ <number>30000</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel9_4</cstring>
+ </property>
+ <property name="text">
+ <string>KB/s *</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>download:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>dlCat2</cstring>
+ </property>
+ <property name="maxValue">
+ <number>30000</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6_4_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>upload:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>ulCat2</cstring>
+ </property>
+ <property name="maxValue">
+ <number>30000</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel9_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>KB/s *</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="5" column="0">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>download:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>dlCat3</cstring>
+ </property>
+ <property name="maxValue">
+ <number>30000</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel6_4_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>upload:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>ulCat3</cstring>
+ </property>
+ <property name="maxValue">
+ <number>30000</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel9_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>KB/s *</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel8_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;2. Category&lt;/b&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="kt::BWSWidget" row="0" column="0" rowspan="5" colspan="1">
+ <property name="name">
+ <cstring>m_bwsWidget</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>379</width>
+ <height>510</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>379</width>
+ <height>508</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout34</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>lblStatus</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel10</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>* zero means no limit</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer row="3" column="1">
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget" row="4" column="1">
+ <property name="name">
+ <cstring>layout32</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout31</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnSave</cstring>
+ </property>
+ <property name="text">
+ <string>Save to file</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnLoad</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Load from file</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnReset</cstring>
+ </property>
+ <property name="text">
+ <string>Reset schedule</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>36</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>pix_icon</cstring>
+ </property>
+ <property name="pixmap">
+ <pixmap>image0</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer14</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>35</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout29</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnOk</cstring>
+ </property>
+ <property name="text">
+ <string>O&amp;k</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnApply</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>kt::BWSWidget</class>
+ <header location="local">bwswidget.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image1</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="4833">789c8597596f23470e80dfe75718c3b7c182e9eabb11ec834fc9873cbeaf601fc86ec9966df994cfc5fef794483633934d10c836fcb9582cde55fee5dbd2d9de68e9db2f5f9ee7349fb64bed153d2d7deb5e66b38fdffef3efff7ef99aa64b8baf2c5b4abffeebcb57dc5c6a9720499290640b8613e110ff22eb941b07657e7256f90be742e4a7c6a9ed076791c7a1732efbd784d3f817615a71167db0e55c0a17ce95c88f8ced3c7e74d6f306cea29fd159f583b3e8a75367d18f5bce8df0b63389be67e3ccfcd97716fd78e22cfaf1d459edefedcbedbc63e75af4cf85b33edeb8616cfef1b5b39eb7e72cf6c28b7166fb53678df7b5b3fadf388b3d503a8b3d40c6b9eaa35767d9cf37c6a5e53f73d6f3769d55bedf5f2789ac6bfcf2de1fda33ce4cdfbb716eeb6fce1acf1de3c2f2bbe7acf573605cdafe2b67f5efd359f20bb97165febe38b3c453fd2bfa7cd0a67165fea97c9db416ff1de3b1e9d77a6d12567bf8c159ed9d1ab7969fc2b8d378e2ba304579c93769bd719457fd524f2184cae221f51bd250a8fd3c35ae4cfec1b8b6fa06e3c6eaffc859d651f215b2d0c7efdab8327b969d459e9e8d7bfd57c68df587c43be4c1e20b685c1b9f0b17c1e283cfce927f96f911ca40d63fcbce7afebd31eb3a91b3fa37376ead9e64dea5759606a94f546eb23499883d9bc69932bef4acf22cf594725c1f8bfca9b3c8d3aa711e82c82bb73de3817111a4fe2171d67e1a1b97ba8e87ce5a8f12bfb48b2cfae8ceb85206894f9666135bff2e5c45d6fae894a3393a3f5be13aaeb7729eca4ff2d6ce3f5b701ef2b1c95f0aa7715dfb4de657519675d0fc8d8c9ba0f527f12faab234fd8fc695f1ab716dfa3f84ebb2089dec5f779678d381711d74beae398b7f540b3751bfd6e39ab1c9033b6bbd07e326687dcb3c2da8ecf47cfa301e9bbe37e389c94b3c0a2edba0f5f361dc194b3c8b36eed77acf9c453fab7f6d95587e6e8d83c957c25dc9668fdc5fc538b2c6e3a6e754e7adcc836252b6a9d69bccffb2ad535d67e98fb2ab538befaab3e8439947e5b84e82f6ffa17165f1bd7096fcc1ccb8b67a981b375a0f20f92d2775b078493dd54c75aaef0de9dfba75167fea2eb2f683dc5771388d753fbe396b7fca7c6b52ea2c5e57ce621fcbfdd26464f1812767ed8f63e3ced665de34c464fe9e1bb3d5b3f45bc3dca67a7fc9fba7697b46a9bf66cc13cb8fcc8b66c2960f3832b6f3988dad1e2828b799c53371d6f9766b9c5b7f4afe286983f5c3aeb3be177ace6c1ecc9cb51f6a678def8a7169f351fca710f5a93d9db3d64febacf9981aa76a2f5e3b6b7d5d1af7f6df3aebfb67e4acf93f72d6f972675cd83c7d77d67cac3bebfdfce9acf7eb87b3c66b665cdabc5feed9f44bfd51caade59395dbc4fc3f33cecc9f9b9e35bf786fdccfffc459e7ffc059eb7fe2acefcfd459df13dbceda5f4367bddffed8affdf0665c243a6f769c351f6367f51f7ad6fcefcf9dd57e72567fd959e3dd3a6bbc3b677daf34ce6affadb3dadbdb57263a5f46ce7adf8e9dd5dededfbe5e2f9cb5de5b678df7bb71a5fa59f767dccf77cd57d6f7136c185b7e79d359f3159cf53df7e8acf19e19f7f57ee5acef9b0d67f5b733b6fa844b63f38f07ceea9fcc3fca5b9bef58199b3dbce5acefa53567bd6fee8c73d54f95b3fa3b34b6fcc3b3b3f6dba1b3f6afe6a788fb6bad9f1f3f08f19b90b18ddff0f3dafefc2fe4bb284948f1b7f1e2e73fca4ff012af708ad77883b77f2f8f33bc8b9aeff1011ff1099f718e2ff88a6ff88e1ff8196da33fc92fe30aaee21aaee3060e70889bb885dbb88323dc8d7a407df941be8dd2dfa3ec5e94dac7033cc4233cc6133cc5333cc78bffb327c18029669863812556d1ef1a9ba8168080a1850ec608daaf30814bb882296ec035dc486426700b33b8837b78c0213cc2133ce367af3f7a93c01c5e700b5ee10d6fe11d093ee01396610556f104d6601d36a2d77abf0da2f41036610bb6b1841d18c12e7c873dd887033884233886133885b318297d3fc558e114cee1021208d1e01432c8a180122aa8e3c5190f2322c63bb507995aea62bc37698c9f34a14bba822d9ad235ddd02dcde80e87744f0f7fc823d1233de1363d634d737aa1577aa3ebf8047ba70ffaa4655aa1555aa375b37f0c298e6923ca0fb0a1212cd3266dd136edd08876e93bedd13e1dd0211d997e88f6031dd3099d624e67744e17f15f8b40296594cb273ef61632aa5ff34515d5d43032707c19449fd6e993db283b8217ee62fc0630fa31bf1cdf037c493bb1724ef98a162d30e56bcae185467cc3b731dfa0f935f919dff13daef1033ff2133fc77d039e73d41da55ff90d268b8afba17ea27d30a18edff9833f7999577895d7a88421aff31b6fc0e04ff5c6314acc031ef2266cc4c7ce036ff12ca66a10ff75d95eacfd2ccf3b0bfd38e651ac93f7d83b77f84e47d1e6f1222e0bf9c5ef3ff7a3f690766f4ffd0490aa85affffbf5cbef985d44a8</data>
+ </image>
+ <image name="image1">
+ <data format="PNG" length="1122">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000042949444154388db5954d6c545514c77ff7de37eff1a6a550da994e5ba798868f948fc847a2a2911816c436b0a02ed0083161a1981877ee10d90aa94656063491882c5cd4c4b8103f20cd806909a98604da8482341de80cb69de9bcd799799d79efba980f1da3a80b4f727273939bdff99f9b93f3175a6b6a21849080020c4002a29a8f0a5dcd002803bed63a1035f0d0d0504b6f6fef51d7758fa4d3e98d8ee3fc03af128ee3303939399548242eb8aefb09300f78464de9f0f0f0d148cc7caf3d5424de97a7ec17104220242805520a44557bbd4b21f083801d33e63a6d1bc7bf19c6064e0319a35a58b9ae7ba43d54e4d7c54b64dc097c7f09d30ef04b36736983cc7c11b4456b9b492c5e20dc54a6540e00896a8268a7017010f8bcae1830d2e9f4c69ebe3c197782b2ce60d94ddc9b30f9feeb45ae5d7181c5ead35636ef08d3ffe26a76ee3208b4031a56d80aa00768fda362e9380e25bf80ef3b587613d7afc099533380a4b5dda46fcb5aa42998b9eb7173dce5e6788e434763ec7fc942532008ea436003660d2caa7f8d69c3bd8910674e4d033e83877ad8d36fb0aa4d6058658ac5358c5df6383bf480f31fdda5a3632bbbfb6da4ccd5c00a10b2012cc12fd97cfb5516f0187c25cee0619396480ec3ca909d0f3372d1e5f9fe66de3ad605587c712ec55256a2540d5519d19ae24a29057329839f7ecc138944d833102290f3184ae1e6d6f0e98739c61229e6d21eafbed1c9c8c5558c8f3ee4ceed76946a1c43d97091828585223e2eebfbc295f60d45de89707628cb58224577bc85a79e5d4d786581cddb9b0148259711b20145836221400416e0232d1f6595c9ce4538773ac7b54406f0b15784e8e80aa1ac2594190220d021e49f2437960156b70ba095e95f96f18acd8c263cc6122962b1167a7ba34cdd7ec8c977a699bed546722a8fc2a02b6e2185fff78ab586ce78894ddb9ab9f5738ed14b1e030756929d8ff2e4ae5544632b38f96e89a99b298ebd6950cc2d12ed0eb3618b26f520788462ad09877df60db600f0f1fb49c646f21c7ebd836dcf94e9d9b4c0db27d6d3bd36c6426a96bce731703046d7da129a4670836284a054869d4f1b1c7e2dca67676ef3c1898091ef5ad8bc358c3205c93bf7c9a40ad4c660f4728edd7bbb3142ea2fc1da711cfc200011e08b45f6bd1c261adbce9717928c5f9d63fc6a19f0014567773303073790f8214bd6f5282dfbb8b9fa1f6b40d7c1939393533b92e63ad9240990484aec7e41b27d579cbb531e0f67023492d86316ebb768ba1e0f786e6f37e56550c62237aee7011e54abd7c1412291b8a06de378b4d3c0b215da9708e5a3a442192085404a83d4accfecac067c0c43e13a70e3fa12e96409e0325000966bbb354465339d04a6f9dd15fe6dde07ce030780278088d05ad72cc9a6b2f2daaaa74d75a1f0e8d0d5f60b40868a8364ead6248430000b0857a126ffcdf396abf03ce089ffcb4c7f033046c6b4a995e7a00000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>btnOk</sender>
+ <signal>clicked()</signal>
+ <receiver>BWSPage</receiver>
+ <slot>btnOk_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>btnApply</sender>
+ <signal>clicked()</signal>
+ <receiver>BWSPage</receiver>
+ <slot>btnApply_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>btnSave</sender>
+ <signal>clicked()</signal>
+ <receiver>BWSPage</receiver>
+ <slot>btnSave_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>btnLoad</sender>
+ <signal>clicked()</signal>
+ <receiver>BWSPage</receiver>
+ <slot>btnLoad_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>btnReset</sender>
+ <signal>clicked()</signal>
+ <receiver>BWSPage</receiver>
+ <slot>btnReset_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>btnCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>BWSPage</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>radio1</tabstop>
+ <tabstop>radio2</tabstop>
+ <tabstop>radio3</tabstop>
+ <tabstop>radio4</tabstop>
+ <tabstop>radio5</tabstop>
+ <tabstop>dlCat1</tabstop>
+ <tabstop>ulCat1</tabstop>
+ <tabstop>dlCat2</tabstop>
+ <tabstop>ulCat2</tabstop>
+ <tabstop>dlCat3</tabstop>
+ <tabstop>ulCat3</tabstop>
+</tabstops>
+<slots>
+ <slot>btnOk_clicked()</slot>
+ <slot>btnApply_clicked()</slot>
+ <slot>btnCancel_clicked()</slot>
+ <slot>btnSave_clicked()</slot>
+ <slot>btnLoad_clicked()</slot>
+ <slot>btnReset_clicked()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>bwswidget.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/plugins/scheduler/bwsprefpage.cpp b/plugins/scheduler/bwsprefpage.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugins/scheduler/bwsprefpage.cpp
diff --git a/plugins/scheduler/bwsprefpage.h b/plugins/scheduler/bwsprefpage.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugins/scheduler/bwsprefpage.h
diff --git a/plugins/scheduler/bwsprefpagewidget.cpp b/plugins/scheduler/bwsprefpagewidget.cpp
new file mode 100644
index 0000000..0c44a43
--- /dev/null
+++ b/plugins/scheduler/bwsprefpagewidget.cpp
@@ -0,0 +1,291 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#include "bwspage.h"
+#include "bwsprefpagewidget.h"
+#include "bwscheduler.h"
+#include "bwswidget.h"
+#include "schedulerpluginsettings.h"
+
+#include <knuminput.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
+#include <kiconloader.h>
+#include <kstdguiitem.h>
+#include <kpushbutton.h>
+
+#include <qcombobox.h>
+#include <qfile.h>
+#include <qdatastream.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+
+namespace kt
+{
+
+ /* PREF PAGE WIDGET --------------------------------------------------------*/
+
+ BWSPrefPageWidget::BWSPrefPageWidget(QWidget* parent, const char* name, WFlags fl)
+ : BWSPage(parent,name,fl)
+ {
+
+ loadDefault();
+
+ lblStatus->clear();
+
+ pix_icon->setPixmap(KGlobal::iconLoader()->loadIcon("clock",KIcon::NoGroup));
+
+ btnOk->setGuiItem(KStdGuiItem::ok());
+ btnCancel->setGuiItem(KStdGuiItem::cancel());
+ btnApply->setGuiItem(KStdGuiItem::apply());
+ btnSave->setGuiItem(KStdGuiItem::saveAs());
+ btnLoad->setGuiItem(KStdGuiItem::open());
+ btnReset->setGuiItem(KStdGuiItem::reset());
+
+
+ bool use_colors = SchedulerPluginSettings::useColors();
+
+ if(use_colors) //set up colors
+ {
+ pix1->setPaletteBackgroundColor(QColor(30,165,105));
+ pix2->setPaletteBackgroundColor(QColor(195,195,70));
+ pix3->setPaletteBackgroundColor(QColor(195,195,70));
+ pix4->setPaletteBackgroundColor(QColor(195,195,70));
+ pix5->setPaletteBackgroundColor(QColor(190,30,30));
+
+ pix12->setPaletteBackgroundColor(QColor(30,165,105));
+ pix22->setPaletteBackgroundColor(QColor(195,195,70));
+ pix32->setPaletteBackgroundColor(QColor(195,195,70));
+ pix42->setPaletteBackgroundColor(QColor(195,195,70));
+ pix52->setPaletteBackgroundColor(QColor(190,30,30));
+ } else //set up pixmaps
+ {
+ pix1->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0000.png"))));
+ pix2->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0001.png"))));
+ pix3->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0002.png"))));
+ pix4->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0003.png"))));
+ pix5->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0004.png"))));
+
+ pix12->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0000.png"))));
+ pix22->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0001.png"))));
+ pix32->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0002.png"))));
+ pix42->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0003.png"))));
+ pix52->setPixmap(QPixmap(locate("data", QString("ktorrent/icons/cell-a-0004.png"))));
+ }
+
+ connect(radio1, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio2, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio3, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio4, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio5, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio12, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio22, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio32, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio42, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+ connect(radio52, SIGNAL(stateChanged(int)), this, SLOT(categoryChanged(int)));
+
+ //pre-check default categories (say 1 for left and 0 for right)
+ radio2->setChecked(true);
+ radio12->setChecked(true);
+
+ m_bwsWidget->setSchedule(schedule);
+ }
+
+ BWSPrefPageWidget::~BWSPrefPageWidget()
+ {}
+
+ void BWSPrefPageWidget::btnSave_clicked()
+ {
+ QString sf = KFileDialog::getSaveFileName("/home","*",this,i18n("Choose a filename to save under"));
+
+ if(sf.isEmpty())
+ return;
+
+ saveSchedule(sf);
+ }
+
+ void BWSPrefPageWidget::btnLoad_clicked()
+ {
+ QString lf = KFileDialog::getOpenFileName("/home", "*",this,i18n("Choose a file"));
+
+ if(lf.isEmpty())
+ return;
+
+ btnReset_clicked();
+ loadSchedule(lf);
+ }
+
+ void BWSPrefPageWidget::saveSchedule(QString& fn)
+ {
+ schedule = m_bwsWidget->schedule();
+
+ QFile file(fn);
+
+ file.open(IO_WriteOnly);
+ QDataStream stream(&file);
+
+ //First category
+ stream << dlCat1->value();
+ stream << ulCat1->value();
+
+ //Second category
+ stream << dlCat2->value();
+ stream << ulCat2->value();
+
+ //Third category
+ stream << dlCat3->value();
+ stream << ulCat3->value();
+
+ //Now schedule
+ for(int i=0; i<7; ++i)
+ for(int j=0; j<24; ++j)
+ stream << (int) schedule.getCategory(i, j);
+
+ file.close();
+ lblStatus->setText(i18n("Schedule saved."));
+ }
+
+ void BWSPrefPageWidget::loadSchedule(QString& fn, bool showmsg)
+ {
+ QFile file(fn);
+
+ if(!file.exists()) {
+ if(showmsg)
+ KMessageBox::error(this, i18n("File not found."), i18n("Error"));
+ return;
+ }
+
+ file.open(IO_ReadOnly);
+ QDataStream stream(&file);
+
+ int tmp;
+
+ stream >> tmp;
+ dlCat1->setValue(tmp);
+ stream >> tmp;
+ ulCat1->setValue(tmp);
+
+ stream >> tmp;
+ dlCat2->setValue(tmp);
+ stream >> tmp;
+ ulCat2->setValue(tmp);
+
+ stream >> tmp;
+ dlCat3->setValue(tmp);
+ stream >> tmp;
+ ulCat3->setValue(tmp);
+
+ for(int i=0; i<7; ++i) {
+ for(int j=0; j<24; ++j) {
+ stream >> tmp;
+ schedule.setCategory(i, j, (ScheduleCategory) tmp);
+ }
+ }
+
+ file.close();
+
+ m_bwsWidget->setSchedule(schedule);
+ lblStatus->setText(i18n("Schedule loaded."));
+ }
+
+ void BWSPrefPageWidget::loadDefault()
+ {
+ //read schedule from HD
+ QString fn = KGlobal::dirs()->saveLocation("data","ktorrent") + "bwschedule";
+ loadSchedule(fn, false);
+ }
+
+ void BWSPrefPageWidget::btnReset_clicked()
+ {
+ schedule.reset();
+ m_bwsWidget->resetSchedule();
+
+ dlCat1->setValue(0);
+ dlCat2->setValue(0);
+ dlCat3->setValue(0);
+
+ ulCat1->setValue(0);
+ ulCat2->setValue(0);
+ ulCat3->setValue(0);
+
+ lblStatus->clear();
+ }
+
+ void BWSPrefPageWidget::apply()
+ {
+ schedule = m_bwsWidget->schedule();
+
+ SchedulerPluginSettings::writeConfig();
+
+ //update category values...
+ schedule.setDownload(0, dlCat1->value());
+ schedule.setUpload(0, ulCat1->value());
+ schedule.setDownload(1, dlCat2->value());
+ schedule.setUpload(1, ulCat2->value());
+ schedule.setDownload(2, dlCat3->value());
+ schedule.setUpload(2, ulCat3->value());
+
+ //set new schedule
+ BWScheduler::instance().setSchedule(schedule);
+ }
+
+ void BWSPrefPageWidget::btnOk_clicked()
+ {
+ apply();
+ accept();
+ }
+
+ void BWSPrefPageWidget::btnApply_clicked()
+ {
+ apply();
+ }
+}
+
+void kt::BWSPrefPageWidget::categoryChanged(int)
+{
+ if(radio1->isChecked())
+ m_bwsWidget->setLeftCategory(0);
+ else if(radio2->isChecked())
+ m_bwsWidget->setLeftCategory(1);
+ else if(radio3->isChecked())
+ m_bwsWidget->setLeftCategory(2);
+ else if(radio4->isChecked())
+ m_bwsWidget->setLeftCategory(3);
+ else if(radio5->isChecked())
+ m_bwsWidget->setLeftCategory(4);
+
+ if(radio12->isChecked())
+ m_bwsWidget->setRightCategory(0);
+ else if(radio22->isChecked())
+ m_bwsWidget->setRightCategory(1);
+ else if(radio32->isChecked())
+ m_bwsWidget->setRightCategory(2);
+ else if(radio42->isChecked())
+ m_bwsWidget->setRightCategory(3);
+ else if(radio52->isChecked())
+ m_bwsWidget->setRightCategory(4);
+}
+
+
+
+#include "bwsprefpagewidget.moc"
diff --git a/plugins/scheduler/bwsprefpagewidget.h b/plugins/scheduler/bwsprefpagewidget.h
new file mode 100644
index 0000000..ca0e80b
--- /dev/null
+++ b/plugins/scheduler/bwsprefpagewidget.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#ifndef KTBWSPREFPAGEWIDGET_H
+#define KTBWSPREFPAGEWIDGET_H
+
+#include <qwidget.h>
+
+#include "bwspage.h"
+#include "bwscheduler.h"
+
+namespace kt
+{
+ /**
+ * @brief Bandwidth Scheduler page
+ * @author Ivan Vasic <ivasic@gmail.com>
+ */
+ class BWSPrefPageWidget : public BWSPage
+ {
+ Q_OBJECT
+ public:
+ BWSPrefPageWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~BWSPrefPageWidget();
+ /*$PUBLIC_FUNCTIONS$*/
+
+ /**
+ * @brief Loads default schedule.
+ * Default schedule is currently active (if enabled) and it's in ~/.kde/share/apps/ktorrent/bwschedule
+ */
+ void loadDefault();
+
+ /**
+ * Loads a schedule from HD.
+ * @param fn Schedule filename
+ * @param showmsg Should I show msgBox if file doesn't exist.
+ * @ref BWSPrefPageWidget::btnLoad_clicked()
+ * @ref BWSPrefPageWidget::loadDefault()
+ */
+ void loadSchedule(QString& fn, bool showmsg = true);
+
+ /**
+ * Saves current schedule to HD.
+ * @param fn Schedule filename.
+ */
+ void saveSchedule(QString& fn);
+
+
+ public slots:
+ /*$PUBLIC_SLOTS$*/
+ virtual void btnReset_clicked();
+ virtual void btnLoad_clicked();
+ virtual void btnSave_clicked();
+ virtual void btnApply_clicked();
+ virtual void btnOk_clicked();
+
+ private slots:
+ void categoryChanged(int);
+
+ ///Applies settings
+ void apply();
+
+ private:
+ BWS schedule;
+ };
+
+}
+
+#endif
diff --git a/plugins/scheduler/bwswidget.cpp b/plugins/scheduler/bwswidget.cpp
new file mode 100644
index 0000000..b430de3
--- /dev/null
+++ b/plugins/scheduler/bwswidget.cpp
@@ -0,0 +1,334 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#include "bwswidget.h"
+#include "schedulerpluginsettings.h"
+
+#include <klocale.h>
+#include <qstringlist.h>
+#include <qpixmap.h>
+#include <qtable.h>
+#include <qpainter.h>
+#include <qrect.h>
+#include <qfont.h>
+#include <qcolor.h>
+
+#include <kglobal.h>
+#include <kstandarddirs.h>
+
+namespace kt
+{
+ BWSWidget::BWSWidget(QWidget* parent, const char* name, bool useColors)
+ : QTable(parent,name), m_leftCategory(1), m_rightCategory(0), draw_focus(true), right_click(false), use_colors(useColors)
+ {
+ use_colors = SchedulerPluginSettings::useColors();
+
+ QStringList days;
+ QStringList hours;
+
+ days << i18n("MON") << i18n("TUE") << i18n("WED") << i18n("THU") << i18n("FRI") << i18n("SAT") << i18n("SUN");
+ hours <<
+ "00:00-00:59h" << "01:00-01:59h" <<
+ "02:00-02:59h" << "03:00-03:59h" <<
+ "04:00-04:59h" << "05:00-05:59h" <<
+ "06:00-06:59h" << "07:00-07:59h" <<
+ "08:00-08:59h" << "09:00-09:59h" <<
+ "10:00-10:59h" << "11:00-11:59h" <<
+ "12:00-12:59h" << "13:00-13:59h" <<
+ "14:00-14:59h" << "15:00-15:59h" <<
+ "16:00-16:59h" << "17:00-17:59h" <<
+ "18:00-18:59h" << "19:00-19:59h" <<
+ "20:00-20:59h" << "21:00-21:59h" <<
+ "22:00-22:59h" << "23:00-23:59h";
+
+ insertRows(0,24);
+ insertColumns(0,7);
+
+ setColumnLabels(days);
+ setRowLabels(hours);
+
+ setFocusPolicy(QWidget::StrongFocus);
+
+ QFont f;
+ f.setPointSize(8);
+ setFont(f);
+
+ for(int i=0; i<7; ++i) {
+ setColumnWidth(i,40);
+ setColumnStretchable(i, true);
+ }
+ for(int i=0; i<24; ++i) {
+ setColumnWidth(i,40);
+ setRowStretchable(i, true);
+ }
+
+ setColumnMovingEnabled(false);
+ setRowMovingEnabled(false);
+
+ setSorting(false);
+
+ adjustSize();
+
+ for(int i=0; i<5; ++i) {
+ m_pix[i] = 0;
+ m_pixf[i] = 0;
+ m_color[i] = 0;
+ m_colorf[i] = 0;
+ }
+
+ setType(use_colors);
+
+ resetSchedule();
+
+ setSelectionMode(QTable::NoSelection);
+
+ setHScrollBarMode(QTable::AlwaysOff);
+ setVScrollBarMode(QTable::AlwaysOff);
+
+ connect(this, SIGNAL(currentChanged( int, int )), this, SLOT(cellSelectionChanged( int, int )));
+ connect(this, SIGNAL(pressed(int, int, int, const QPoint&)), this, SLOT(cellMouseDown(int, int, int, const QPoint& )));
+ }
+
+ BWSWidget::~BWSWidget()
+ {
+ for(int i=0; i<5; ++i) {
+ if(m_pix[i])
+ delete m_pix[i];
+ if(m_pixf[i])
+ delete m_pixf[i];
+ }
+ }
+
+ void BWSWidget::paintFocus(QPainter* p, const QRect& cr)
+ {
+ int x = rowAt(cr.y());
+ int y = columnAt(cr.x());
+
+ if(x == 1 && y == 1) {
+ int trt = 0;
+ ++trt;
+ }
+
+ if(lastFocused.x != x || lastFocused.y != y)
+ updateCell(lastFocused.x, lastFocused.y);
+
+ if(draw_focus) {
+
+ if(right_click)
+ drawCell(p, m_rightCategory, true);
+ else
+ drawCell(p, m_leftCategory, true);
+
+ lastFocused.x = x;
+ lastFocused.y = y;
+ } else {
+ lastFocused.x = -1;
+ lastFocused.y = -1;
+ }
+ }
+
+ void BWSWidget::cellSelectionChanged(int row, int col)
+ {
+ if(right_click)
+ setText(row, col, QString::number(m_rightCategory));
+ else
+ setText(row, col, QString::number(m_leftCategory));
+ }
+
+ void BWSWidget::paintCell(QPainter* p, int row, int col, const QRect& cr, bool selected)
+ {
+ if(selected)
+ return;
+
+ bool ok;
+ int cat = text(row,col).toInt(&ok);
+ if((ok || cat == 0) && cat >= 0 && cat <= 4)
+ drawCell(p, cat);
+ else
+ setText(row,col,QString::number(0));
+ // QTable::paintCell(p,row,col,cr,selected);
+ }
+
+ void BWSWidget::resetSchedule()
+ {
+ for(int i=0; i<7; ++i)
+ for(int j=0; j<24; ++j)
+ setText(j,i, "0");
+ draw_focus = false;
+ clearSelection();
+ updateHeaderStates();
+ }
+
+ void BWSWidget::repaintWidget()
+ {
+ for(int i=0; i<7; ++i)
+ for(int j=0; j<24; ++j)
+ updateCell(j,i);
+ }
+
+ void BWSWidget::cellMouseDown(int row, int col, int button, const QPoint& mousePos)
+ {
+ right_click = button == 2;
+ draw_focus = true;
+ cellSelectionChanged(row,col);
+ }
+
+ void BWSWidget::clearSelect()
+ {
+ draw_focus = false;
+ clearSelection();
+ updateHeaderStates();
+ repaintWidget();
+ }
+
+ void BWSWidget::setLeftCategory(const int& theValue)
+ {
+ m_leftCategory = theValue;
+ }
+
+ void BWSWidget::setRightCategory(const int& theValue)
+ {
+ m_rightCategory = theValue;
+ }
+
+
+ void BWSWidget::setUseColors(bool theValue)
+ {
+ use_colors = theValue;
+ }
+
+ void BWSWidget::drawCell(QPainter* p, int category, bool focus)
+ {
+ if(use_colors) {
+ if(focus) {
+ p->fillRect(0,0,40,20,*m_colorf[category]);
+ } else {
+ p->fillRect(0,0,40,20,*m_color[category]);
+ }
+
+ switch(category) {
+ case 0:
+ // p->drawText(QRect(0,0,40,20), Qt::AlignCenter | Qt::SingleLine, "normalllll");
+ break;
+ case 1:
+ case 2:
+ case 3:
+ p->drawText(QRect(0,0,40,20), Qt::AlignCenter | Qt::SingleLine, QString::number(category));
+ break;
+ case 4:
+ p->drawText(QRect(0,0,40,20), Qt::AlignCenter | Qt::SingleLine, "off");
+ break;
+ }
+
+ p->drawRect(0,0,40,20);
+ } else {
+ if(focus)
+ p->drawPixmap(0,0,*m_pixf[category]);
+ else
+ p->drawPixmap(0,0, *m_pix[category]);
+ }
+ }
+
+ void BWSWidget::setType(bool color)
+ {
+ if(color) {
+ for(int i=0; i<5; ++i) {
+ if(m_pix[i])
+ delete m_pix[i];
+ if(m_pixf[i])
+ delete m_pixf[i];
+
+ m_pix[i] = 0;
+ m_pixf[i] = 0;
+ }
+
+ m_color[0] = new QColor(30,165,105);
+ m_color[1] = new QColor(195,195,70);
+ m_color[2] = new QColor(195,195,70);
+ m_color[3] = new QColor(195,195,70);
+ m_color[4] = new QColor(190,30,30);
+
+ m_colorf[0] = new QColor(40,200,130);
+ m_colorf[1] = new QColor(210,220,130);
+ m_colorf[2] = new QColor(210,220,130);
+ m_colorf[3] = new QColor(210,220,130);
+ m_colorf[4] = new QColor(230,40,40);
+
+ } else {
+ for(int i=0; i<5; ++i) {
+ if(m_color[i])
+ delete m_color[i];
+ if(m_colorf[i])
+ delete m_colorf[i];
+
+ m_color[i] = 0;
+ m_colorf[i] = 0;
+ }
+
+ m_pix[0] = new QPixmap(locate("data", QString("ktorrent/icons/cell-a-0000.png")));
+ m_pix[1] = new QPixmap(locate("data", QString("ktorrent/icons/cell-a-0001.png")));
+ m_pix[2] = new QPixmap(locate("data", QString("ktorrent/icons/cell-a-0002.png")));
+ m_pix[3] = new QPixmap(locate("data", QString("ktorrent/icons/cell-a-0003.png")));
+ m_pix[4] = new QPixmap(locate("data", QString("ktorrent/icons/cell-a-0004.png")));
+
+ m_pixf[0] = new QPixmap(locate("data", QString("ktorrent/icons/cell-b-0000.png")));
+ m_pixf[1] = new QPixmap(locate("data", QString("ktorrent/icons/cell-b-0001.png")));
+ m_pixf[2] = new QPixmap(locate("data", QString("ktorrent/icons/cell-b-0002.png")));
+ m_pixf[3] = new QPixmap(locate("data", QString("ktorrent/icons/cell-b-0003.png")));
+ m_pixf[4] = new QPixmap(locate("data", QString("ktorrent/icons/cell-b-0004.png")));
+ }
+
+ use_colors = color;
+
+ repaintWidget();
+ }
+
+ void BWSWidget::setSchedule(const BWS& theValue)
+ {
+ m_schedule = theValue;
+ for(int i=0; i<7; ++i)
+ for(int j=0; j<24; ++j)
+ setText(j,i, QString::number((int) m_schedule.getCategory(i,j)));
+ }
+
+ const BWS& BWSWidget::schedule()
+ {
+ for(int i=0; i<7; ++i)
+ {
+ for(int j=0; j<24; ++j)
+ {
+ bool ok;
+ ScheduleCategory cat = (ScheduleCategory) text(j,i).toInt(&ok);
+
+ if((ok || cat == 0) && cat >= 0 && cat <= 4) //precaution
+ m_schedule.setCategory(i,j, cat);
+ else
+ m_schedule.setCategory(i,j,(ScheduleCategory) 0);
+ }
+ }
+
+ return m_schedule;
+ }
+
+ void BWSWidget::focusOutEvent(QFocusEvent* e)
+ {
+ if(e->lostFocus())
+ clearSelect();
+ }
+}
diff --git a/plugins/scheduler/bwswidget.h b/plugins/scheduler/bwswidget.h
new file mode 100644
index 0000000..c035edb
--- /dev/null
+++ b/plugins/scheduler/bwswidget.h
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#ifndef KTBWSWIDGET_H
+#define KTBWSWIDGET_H
+
+#include <qtable.h>
+#include <qpixmap.h>
+#include <qpoint.h>
+#include <qcolor.h>
+
+#include "bwscheduler.h"
+
+namespace kt
+{
+ typedef struct _focusedCell
+ {
+ int x;
+ int y;
+ }
+ FocusedCell;
+
+ /**
+ * @brief Bandwidth scheduler widget.
+ * @author Ivan Vasić <ivasic@gmail.com>
+ * This class is a QTable with customized cells. It's used for bandwidth scheduling by painting each cell with mouse moves or keyboard.
+ */
+ class BWSWidget : public QTable
+ {
+ Q_OBJECT
+ public:
+ BWSWidget(QWidget* parent = 0, const char* name = 0, bool useColors = true);
+ ~BWSWidget();
+
+ ///Repaints the whole widget
+ void repaintWidget();
+
+ ///Clears selection (removes focus)
+ void clearSelect();
+
+ ///Sets category for left mouse click.
+ void setLeftCategory(const int& theValue);
+ ///Sets category for right mouse click.
+ void setRightCategory(const int& theValue);
+
+
+ /**
+ * Sets cell paint type.
+ * @param color TRUE - paints colors. FALSE - paints pixmaps.
+ */
+ void setType(bool color);
+
+ ///Returns current schedule.
+ const BWS& schedule();
+ ///Sets schedule.
+ void setSchedule(const BWS& theValue);
+
+ public slots:
+ void resetSchedule();
+ void setUseColors(bool theValue);
+
+ private slots:
+ void cellSelectionChanged(int row, int col);
+ void cellMouseDown(int row, int col, int button, const QPoint& mousePos);
+
+ private:
+ void paintFocus(QPainter* p, const QRect& cr);
+ void paintCell(QPainter* p, int row, int col, const QRect& cr, bool selected);
+ void drawCell(QPainter* p, int category, bool focus = false);
+ void focusOutEvent(QFocusEvent*);
+
+ QPixmap* m_pix[5];
+ QPixmap* m_pixf[5];
+
+ QColor* m_color[5];
+ QColor* m_colorf[5];
+
+ int m_leftCategory;
+ int m_rightCategory;
+
+ FocusedCell lastFocused;
+
+ bool draw_focus;
+ bool right_click;
+
+ bool use_colors;
+
+ BWS m_schedule;
+ };
+}
+#endif
diff --git a/plugins/scheduler/cell-a-0000.png b/plugins/scheduler/cell-a-0000.png
new file mode 100644
index 0000000..c3a7afd
--- /dev/null
+++ b/plugins/scheduler/cell-a-0000.png
Binary files differ
diff --git a/plugins/scheduler/cell-a-0001.png b/plugins/scheduler/cell-a-0001.png
new file mode 100644
index 0000000..7f93d4e
--- /dev/null
+++ b/plugins/scheduler/cell-a-0001.png
Binary files differ
diff --git a/plugins/scheduler/cell-a-0002.png b/plugins/scheduler/cell-a-0002.png
new file mode 100644
index 0000000..635377e
--- /dev/null
+++ b/plugins/scheduler/cell-a-0002.png
Binary files differ
diff --git a/plugins/scheduler/cell-a-0003.png b/plugins/scheduler/cell-a-0003.png
new file mode 100644
index 0000000..16f5080
--- /dev/null
+++ b/plugins/scheduler/cell-a-0003.png
Binary files differ
diff --git a/plugins/scheduler/cell-a-0004.png b/plugins/scheduler/cell-a-0004.png
new file mode 100644
index 0000000..db91d39
--- /dev/null
+++ b/plugins/scheduler/cell-a-0004.png
Binary files differ
diff --git a/plugins/scheduler/cell-b-0000.png b/plugins/scheduler/cell-b-0000.png
new file mode 100644
index 0000000..1c765f0
--- /dev/null
+++ b/plugins/scheduler/cell-b-0000.png
Binary files differ
diff --git a/plugins/scheduler/cell-b-0001.png b/plugins/scheduler/cell-b-0001.png
new file mode 100644
index 0000000..2fdfcc2
--- /dev/null
+++ b/plugins/scheduler/cell-b-0001.png
Binary files differ
diff --git a/plugins/scheduler/cell-b-0002.png b/plugins/scheduler/cell-b-0002.png
new file mode 100644
index 0000000..6ed81c0
--- /dev/null
+++ b/plugins/scheduler/cell-b-0002.png
Binary files differ
diff --git a/plugins/scheduler/cell-b-0003.png b/plugins/scheduler/cell-b-0003.png
new file mode 100644
index 0000000..847b3a4
--- /dev/null
+++ b/plugins/scheduler/cell-b-0003.png
Binary files differ
diff --git a/plugins/scheduler/cell-b-0004.png b/plugins/scheduler/cell-b-0004.png
new file mode 100644
index 0000000..458aae4
--- /dev/null
+++ b/plugins/scheduler/cell-b-0004.png
Binary files differ
diff --git a/plugins/scheduler/ktschedulerplugin.desktop b/plugins/scheduler/ktschedulerplugin.desktop
new file mode 100644
index 0000000..c208cb3
--- /dev/null
+++ b/plugins/scheduler/ktschedulerplugin.desktop
@@ -0,0 +1,26 @@
+[Desktop Entry]
+Name=SchedulerPlugin
+Name[bg]=Приставка за график
+Name[cs]=Modul plánování
+Name[da]=Skemalægger-Plugin
+Name[de]=Planer-Modul
+Name[el]=Πρόσθετο προγραμματισμού
+Name[et]=Ajastamisplugin
+Name[it]=Plugin pianificatore
+Name[nb]=Planleggermodul
+Name[nds]=Planer-Moduul
+Name[nl]=Plannerplugin
+Name[pl]=Wtyczka planowanie transferu
+Name[pt_BR]=Plugin de agendamento
+Name[sk]=Scheduler Plugin
+Name[sr]=Прикључак распоређивања
+Name[sr@Latn]=Priključak raspoređivanja
+Name[sv]=Insticksprogram för schemaläggning
+Name[tr]=Zamanlayıcı Eklentisi
+Name[uk]=Втулок розкладу
+Name[xx]=xxSchedulerPluginxx
+Name[zh_CN]=带宽规划器插件
+Name[zh_TW]=排程器外掛程式
+ServiceTypes=KTorrent/Plugin
+Type=Service
+X-KDE-Library=ktschedulerplugin
diff --git a/plugins/scheduler/ktschedulerplugin.kcfg b/plugins/scheduler/ktschedulerplugin.kcfg
new file mode 100644
index 0000000..7f752b3
--- /dev/null
+++ b/plugins/scheduler/ktschedulerplugin.kcfg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+
+ <kcfgfile name="ktschedulerpluginrc"/>
+ <group name="general">
+ <entry name="enableBWS" type="Bool">
+ <label>Enable bandwidth scheduler?</label>
+ <default>FALSE</default>
+ </entry>
+ <entry name="useColors" type="Bool">
+ <label>Use colors instead of pixmaps?</label>
+ <default>FALSE</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/plugins/scheduler/ktschedulerpluginui.rc b/plugins/scheduler/ktschedulerpluginui.rc
new file mode 100644
index 0000000..217e103
--- /dev/null
+++ b/plugins/scheduler/ktschedulerpluginui.rc
@@ -0,0 +1,12 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="ktorrent" version="1">
+ <MenuBar>
+ <Menu name="file">
+ <Action name="bwscheduler"/>
+ </Menu>
+ </MenuBar>
+
+ <ToolBar name="SchedulerToolbar" noMerge="1">
+ <Action name="bwscheduler"/>
+ </ToolBar>
+</kpartgui> \ No newline at end of file
diff --git a/plugins/scheduler/schedulerpage.ui b/plugins/scheduler/schedulerpage.ui
new file mode 100644
index 0000000..01a4f47
--- /dev/null
+++ b/plugins/scheduler/schedulerpage.ui
@@ -0,0 +1,146 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SchedulerPage</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SchedulerPage</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>570</width>
+ <height>401</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Scheduler Plugin Pref Page</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>useBS</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;bandwidth scheduler?</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBWS</cstring>
+ </property>
+ <property name="title">
+ <string>Bandwidth Scheduler</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>useColors</cstring>
+ </property>
+ <property name="text">
+ <string>Use colors instead of pi&amp;xmaps?</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="2">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>(Recommended for slower systems)</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="2" column="0">
+ <property name="name">
+ <cstring>btnEditBWS</cstring>
+ </property>
+ <property name="text">
+ <string>Edit s&amp;chedule</string>
+ </property>
+ </widget>
+ <spacer row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>spacer22</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer18</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>80</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>useBS</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupBWS</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>btnEditBWS</sender>
+ <signal>clicked()</signal>
+ <receiver>SchedulerPage</receiver>
+ <slot>btnEditBWS_clicked()</slot>
+ </connection>
+ <connection>
+ <sender>useColors</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>SchedulerPage</receiver>
+ <slot>useColors_toggled(bool)</slot>
+ </connection>
+</connections>
+<slots>
+ <slot>btnEditBWS_toggled(bool)</slot>
+ <slot>btnEditBWS_clicked()</slot>
+ <slot>useColors_toggled(bool)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/plugins/scheduler/schedulerplugin.cpp b/plugins/scheduler/schedulerplugin.cpp
new file mode 100644
index 0000000..7639293
--- /dev/null
+++ b/plugins/scheduler/schedulerplugin.cpp
@@ -0,0 +1,152 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#include <kgenericfactory.h>
+
+#include <interfaces/coreinterface.h>
+#include <interfaces/guiinterface.h>
+#include <util/constants.h>
+#include <util/log.h>
+
+#include <qstring.h>
+#include <qtimer.h>
+#include <qdatetime.h>
+
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kstdaction.h>
+#include <kiconloader.h>
+#include <kglobal.h>
+
+#include "schedulerplugin.h"
+#include "schedulerpluginsettings.h"
+#include "bwscheduler.h"
+#include "schedulerprefpage.h"
+#include "bwsprefpagewidget.h"
+
+#include <torrent/downloadcap.h>
+#include <torrent/uploadcap.h>
+#include <torrent/globals.h>
+
+using namespace bt;
+
+K_EXPORT_COMPONENT_FACTORY(ktschedulerplugin,KGenericFactory<kt::SchedulerPlugin>("schedulerplugin"))
+
+namespace kt
+{
+ const QString NAME = "Bandwith Scheduler";
+ const QString AUTHOR = "Ivan Vasic";
+ const QString EMAIL = "ivasic@gmail.com";
+ const QString DESCRIPTION = i18n("Bandwidth scheduling plugin");
+
+ SchedulerPlugin::SchedulerPlugin(QObject* parent, const char* name, const QStringList& args)
+ : Plugin(parent, name, args,NAME,i18n("Bandwidth Scheduler"),AUTHOR,EMAIL,DESCRIPTION, "clock")
+ {
+ setXMLFile("ktschedulerpluginui.rc");
+ bws_action = 0;
+ connect(&m_timer, SIGNAL(timeout()), this, SLOT(timer_triggered()));
+ }
+
+
+ SchedulerPlugin::~SchedulerPlugin()
+ {
+ }
+
+ void SchedulerPlugin::load()
+ {
+ Pref = new SchedulerPrefPage(this);
+ getGUI()->addPrefPage(Pref);
+ BWScheduler::instance().setCoreInterface(getCore());
+
+ QDateTime now = QDateTime::currentDateTime();
+
+ //each hour
+ QDateTime hour = now.addSecs(3600);
+ QTime t(hour.time().hour(), 0);
+
+ //each minute
+// QDateTime hour = now.addSecs(60);
+// QTime t(hour.time().hour(), hour.time().minute());
+
+ QDateTime round(hour.date(), t);
+
+ // add a 5 second safety margin (BUG: 131246)
+ int secs_to = now.secsTo(round) + 5;
+
+ m_timer.start(secs_to*1000);
+
+ BWScheduler::instance().trigger();
+
+// updateEnabledBWS();
+ bws_action = new KAction(i18n("Open Bandwidth Scheduler" ), "clock", 0, this,
+ SLOT(openBWS()), actionCollection(), "bwscheduler" );
+ }
+
+ void SchedulerPlugin::unload()
+ {
+ getGUI()->removePrefPage(Pref);
+ if(Pref)
+ delete Pref;
+ Pref = 0;
+
+ if(bws_action)
+ delete bws_action;
+ bws_action = 0;
+
+ m_timer.stop();
+ }
+
+ void SchedulerPlugin::timer_triggered()
+ {
+ m_timer.changeInterval(3600*1000);
+ QDateTime now = QDateTime::currentDateTime();
+ BWScheduler::instance().trigger();
+ }
+
+ void SchedulerPlugin::openBWS()
+ {
+ if(SchedulerPluginSettings::enableBWS())
+ {
+ BWSPrefPageWidget dlg;
+ dlg.exec();
+ }
+ else
+ KMessageBox::sorry(0, i18n("Bandwidth scheduler is disabled. Go to Preferences->Scheduler to enable it."));
+ }
+
+ void SchedulerPlugin::updateEnabledBWS()
+ {
+ if(SchedulerPluginSettings::enableBWS())
+ {
+ bws_action = new KAction(i18n("Open Bandwidth Scheduler" ), "clock", 0, this,
+ SLOT(openBWS()), actionCollection(), "bwscheduler" );
+ }
+ else
+ {
+ if(bws_action)
+ delete bws_action;
+ bws_action = 0;
+ }
+ }
+
+ bool SchedulerPlugin::versionCheck(const QString & version) const
+ {
+ return version == KT_VERSION_MACRO;
+ }
+}
diff --git a/plugins/scheduler/schedulerplugin.h b/plugins/scheduler/schedulerplugin.h
new file mode 100644
index 0000000..6828d0d
--- /dev/null
+++ b/plugins/scheduler/schedulerplugin.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#ifndef KTschedulerPLUGIN_H
+#define KTschedulerPLUGIN_H
+
+#include <interfaces/plugin.h>
+
+#include "schedulerprefpage.h"
+
+#include <qtimer.h>
+
+#include <kstdaction.h>
+
+class QString;
+
+
+namespace kt
+{
+ class BWSPrefPage;
+
+ /**
+ * @author Ivan Vasic <ivasic@gmail.com>
+ * @brief KTorrent scheduler plugin.
+ *
+ */
+ class SchedulerPlugin : public Plugin
+ {
+ Q_OBJECT
+ public:
+ SchedulerPlugin(QObject* parent, const char* name, const QStringList& args);
+ virtual ~SchedulerPlugin();
+
+ virtual void load();
+ virtual void unload();
+ virtual bool versionCheck(const QString& version) const;
+
+ void updateEnabledBWS();
+
+ public slots:
+ void timer_triggered();
+ void openBWS();
+
+ private:
+ QTimer m_timer;
+
+ /* BANDWIDTH SCHEDULE PLUGIN */
+ SchedulerPrefPage* Pref;
+ KAction* bws_action;
+ };
+
+}
+
+#endif
diff --git a/plugins/scheduler/schedulerpluginsettings.kcfgc b/plugins/scheduler/schedulerpluginsettings.kcfgc
new file mode 100644
index 0000000..f38f816
--- /dev/null
+++ b/plugins/scheduler/schedulerpluginsettings.kcfgc
@@ -0,0 +1,7 @@
+# Code generation options for kconfig_compiler
+File=ktschedulerplugin.kcfg
+ClassName=SchedulerPluginSettings
+Namespace=kt
+Singleton=true
+Mutators=true
+# will create the necessary code for setting those variables \ No newline at end of file
diff --git a/plugins/scheduler/schedulerprefpage.cpp b/plugins/scheduler/schedulerprefpage.cpp
new file mode 100644
index 0000000..fe82f34
--- /dev/null
+++ b/plugins/scheduler/schedulerprefpage.cpp
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+
+#include "schedulerprefpage.h"
+#include "bwsprefpagewidget.h"
+#include "schedulerplugin.h"
+#include "schedulerpluginsettings.h"
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+
+
+namespace kt
+{
+
+ SchedulerPrefPage::SchedulerPrefPage(SchedulerPlugin* plugin)
+ : PrefPageInterface(i18n("Scheduler"), i18n("Scheduler plugin options"), KGlobal::iconLoader()->loadIcon("clock",KIcon::NoGroup)), m_plugin(plugin)
+ {
+ widget = 0;
+ }
+
+
+ SchedulerPrefPage::~SchedulerPrefPage()
+ {}
+
+ bool SchedulerPrefPage::apply()
+ {
+ widget->apply();
+// m_plugin->updateEnabledBWS();
+ return true;
+ }
+
+ void SchedulerPrefPage::createWidget( QWidget * parent )
+ {
+ widget = new SchedulerPrefPageWidget(parent);
+ }
+
+ void SchedulerPrefPage::updateData()
+ {}
+
+ void SchedulerPrefPage::deleteWidget()
+ {
+ delete widget;
+ widget = 0;
+ }
+}
diff --git a/plugins/scheduler/schedulerprefpage.h b/plugins/scheduler/schedulerprefpage.h
new file mode 100644
index 0000000..a10a98a
--- /dev/null
+++ b/plugins/scheduler/schedulerprefpage.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+
+#ifndef KTSchedulerPREFPAGE_H
+#define KTSchedulerPREFPAGE_H
+
+#include <interfaces/prefpageinterface.h>
+
+#include "schedulerprefpagewidget.h"
+
+namespace kt
+{
+ class SchedulerPlugin;
+
+ /**
+ * @brief Scheduler Preferences Page.
+ * @author Ivan Vasic <ivasic@gmail.com>
+ */
+ class SchedulerPrefPage : public PrefPageInterface
+ {
+ public:
+ SchedulerPrefPage(SchedulerPlugin* plugin);
+ virtual ~SchedulerPrefPage();
+
+ virtual bool apply();
+ virtual void createWidget(QWidget* parent);
+ virtual void updateData();
+ virtual void deleteWidget();
+
+ private:
+ SchedulerPlugin* m_plugin;
+ SchedulerPrefPageWidget* widget;
+ };
+}
+
+#endif
diff --git a/plugins/scheduler/schedulerprefpagewidget.cpp b/plugins/scheduler/schedulerprefpagewidget.cpp
new file mode 100644
index 0000000..d6e73dd
--- /dev/null
+++ b/plugins/scheduler/schedulerprefpagewidget.cpp
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#include "schedulerprefpagewidget.h"
+#include "bwsprefpagewidget.h"
+#include "bwscheduler.h"
+#include "schedulerpluginsettings.h"
+
+#include <qcheckbox.h>
+#include <qtimer.h>
+#include <qpushbutton.h>
+#include <qgroupbox.h>
+
+namespace kt
+{
+
+ SchedulerPrefPageWidget::SchedulerPrefPageWidget(QWidget* parent, const char* name, WFlags fl)
+ : SchedulerPage(parent,name,fl)
+ {
+ groupBWS->setEnabled(false);
+ bool useit = SchedulerPluginSettings::enableBWS();
+ bool use_colors = SchedulerPluginSettings::useColors();
+ useBS->setChecked(useit);
+ useColors->setChecked(use_colors);
+ }
+
+
+ SchedulerPrefPageWidget::~SchedulerPrefPageWidget()
+ {}
+
+ void SchedulerPrefPageWidget::btnEditBWS_clicked()
+ {
+ BWSPrefPageWidget w(this);
+ w.exec();
+ }
+
+ void SchedulerPrefPageWidget::apply()
+ {
+ bool use_bws = useBS->isChecked();
+
+ SchedulerPluginSettings::setEnableBWS(use_bws);
+ SchedulerPluginSettings::setUseColors(useColors->isChecked());
+ SchedulerPluginSettings::writeConfig();
+
+ /* force trigger since the schedule has changed but after KTorrent::apply()
+ * Used QTimer with fixed interval - not very nice solution... */
+ if(useBS->isChecked())
+ QTimer::singleShot(1000, this, SLOT(scheduler_trigger()));
+
+ BWScheduler::instance().setEnabled(use_bws);
+ }
+
+ void SchedulerPrefPageWidget::scheduler_trigger()
+ {
+ BWScheduler::instance().trigger();
+ }
+
+ void SchedulerPrefPageWidget::useColors_toggled(bool)
+ {
+ SchedulerPluginSettings::setUseColors(useColors->isChecked());
+ SchedulerPluginSettings::writeConfig();
+ }
+
+}
+
+
+
diff --git a/plugins/scheduler/schedulerprefpagewidget.h b/plugins/scheduler/schedulerprefpagewidget.h
new file mode 100644
index 0000000..9f62c20
--- /dev/null
+++ b/plugins/scheduler/schedulerprefpagewidget.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ivan Vasić *
+ * ivasic@gmail.com *
+ * *
+ * 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. *
+ * *
+ * 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. *
+ ***************************************************************************/
+#ifndef KTSCHEDULERPREFPAGEWIDGET_H
+#define KTSCHEDULERPREFPAGEWIDGET_H
+
+#include <qwidget.h>
+#include "schedulerpage.h"
+
+namespace kt
+{
+ /**
+ * @brief Scheduler Preferences Page.
+ * @author Ivan Vasic <ivasic@gmail.com>
+ */
+ class SchedulerPrefPageWidget : public SchedulerPage
+ {
+ Q_OBJECT
+ public:
+ SchedulerPrefPageWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+
+ ~SchedulerPrefPageWidget();
+
+ void apply();
+
+ public slots:
+ virtual void btnEditBWS_clicked();
+ void scheduler_trigger();
+ virtual void useColors_toggled(bool);
+ };
+
+}
+
+#endif