summaryrefslogtreecommitdiffstats
path: root/src/maxmin.ui.h
blob: 1902c2eae862f35c5d8376ec11c7d366e74a50fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/***************************************************************************
** $Id: maxmin.ui.h,v 1.12 2008/07/31 19:56:26 hoganrobert Exp $
 *   Copyright (C) 2006 - 2008 Robert Hogan                                *
 *   robert@roberthogan.net                                                *
 *                                                                         *
 *   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 St, Fifth Floor, Boston, MA 02110-1301, USA.              *
 ***************************************************************************/
#include "torkconfig.h"
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <ntqtooltip.h>
#include <ntqpopupmenu.h>

void MaxMin::init()
{

    TQStringList bandwidthSlots = TorkConfig::bandwidthSlots();
	for ( TQStringList::Iterator it = bandwidthSlots.begin(); it != bandwidthSlots.end(); ++it )
	{
		if ((*it).isEmpty())
			continue;

        new TQListViewItem(timedBandwidthList,(*it).section("\n",-5,-5),
            (*it).section("\n",-4,-4),(*it).section("\n",-3,-3),(*it).section("\n",-2,-2),(*it).section("\n",-1));
    }

}




void MaxMin::kcfg_DefaultMaxMinOptions_toggled( bool state )
{
    MaxMinOptions->setEnabled(!state);
    kcfg_UseScheduledBandwidth->setEnabled(!state);
    if (kcfg_UseScheduledBandwidth->isChecked())
        TimedBandwidth->setEnabled(!state);
    else
        TimedBandwidth->setEnabled(false);

    if (state){
        kcfg_BandwidthRate->setValue(TorkConfig::defaultBandwidthRate());
        kcfg_BandwidthBurst->setValue(TorkConfig::defaultBandwidthBurst());
        kcfg_MaxAdvertisedBandwidth->setValue(TorkConfig::defaultMaxAdvertisedBandwidth());
    }

}


void MaxMin::kcfg_BandwidthRate_valueChanged( int  newValue)
{
    if (newValue > kcfg_BandwidthBurst->value()){
        KMessageBox::information(this, "Largest Chunk of Bandwidth should be at least equal to the Bandwidth Rate");
        kcfg_BandwidthBurst->setValue(kcfg_BandwidthRate->value());
    }
}



void MaxMin::kcfg_BandwidthBurst_valueChanged( int  newValue)
{
    if (newValue < kcfg_BandwidthRate->value()){
        KMessageBox::information(this, "Largest Chunk of Bandwidth should be at least equal to the Bandwidth Rate");
        kcfg_BandwidthBurst->setValue(kcfg_BandwidthRate->value());
    }
}


void MaxMin::pushButton1_clicked()
{

    TQString bwtime = theTime->time().toString();
    TQString max = TQString("%1").arg(kcfg_BandwidthRate->value());
    TQString burst = TQString("%1").arg(kcfg_BandwidthBurst->value());
    TQString adv = TQString("%1").arg(kcfg_MaxAdvertisedBandwidth->value());

    new TQListViewItem(timedBandwidthList,bwtime,theDay->currentText(),max,burst,adv);

}

void MaxMin::timedBandwidthList_contextMenuRequested( TQListViewItem *, const TQPoint &point, int )
{

    TQPopupMenu *menu = new TQPopupMenu( timedBandwidthList );

    menu->clear();
    menu->insertItem( "Delete Entry", this,SLOT(slotDeleteEntry()) );
    menu->popup( point );

}


void MaxMin::slotDeleteEntry( )
{

    TQListViewItemIterator it(timedBandwidthList, TQListViewItemIterator::Selected);
    while ( it.current() ) {
        if (timedBandwidthList->isSelected( it.current()))
            delete it.current();
        ++it;
    }


}


void MaxMin::kcfg_UseScheduledBandwidth_toggled( bool state)
{
    TimedBandwidth->setEnabled(state);
}