~mzanetti/+junk/wifiscanner

« back to all changes in this revision

Viewing changes to app/WifiCanvas.qml

  • Committer: Michael Zanetti
  • Date: 2016-06-25 14:15:52 UTC
  • Revision ID: michael.zanetti@canonical.com-20160625141552-l1a9yy8zsnhp1ggt
fix things

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 */
16
16
 
17
 
import QtQuick 2.0
 
17
import QtQuick 2.4
18
18
import WiFi 1.0
19
 
import Ubuntu.Components 1.1
 
19
import Ubuntu.Components 1.3
20
20
 
21
21
Canvas {
22
22
    id: canvas
38
38
    property int slots: band == Iwlist.WiFiBand24GHz ? 19 : (extendedChannels ? 125 : 104)
39
39
    property real slotWidth: contentWidth / slots;
40
40
 
41
 
    property int selectedIndex: -1
 
41
    property string selectedHwAddr: ""
42
42
    property bool scanning: true
43
43
 
44
44
    property var allChannels: band == Iwlist.WiFiBand24GHz ? twoChannels : extendedChannels ? fiveChannelsFull : fiveChannels
47
47
    property var fiveChannels: [34,36,38,40,42,44,46,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,149,153,157,161,165]
48
48
 
49
49
    onBandChanged: requestPaint()
50
 
    onSelectedIndexChanged: requestPaint();
 
50
    onSelectedHwAddrChanged: requestPaint();
51
51
 
52
52
    onPaint: {
53
53
        var ctx = canvas.getContext('2d');
63
63
 
64
64
        canvas.paintGrid(ctx)
65
65
        enumerate(ctx)
66
 
        paintWifis(ctx, canvas.selectedIndex)
 
66
        paintWifis(ctx)
67
67
        ctx.restore();
68
68
 
69
69
    }
181
181
 
182
182
        // Paint the wifis
183
183
        for (var i = 0; i < wifiModel.count; i++) {
184
 
 
185
184
            // If we have an index, only paint that one
186
 
            if (canvas.selectedIndex != -1 && i != canvas.selectedIndex) continue;
187
 
 
188
185
            var item = wifiModel.get(i);
 
186
            if (canvas.selectedHwAddr != "" && item.hwAddr != canvas.selectedHwAddr) {
 
187
                print("selectedHwAddr is", canvas.selectedHwAddr, "Not painting", item.hwAddr)
 
188
                continue;
 
189
            }
 
190
 
189
191
 
190
192
            if (canvas.band != item.band) {
 
193
                print("Not for this band", canvas.band, item.band)
191
194
                continue;
192
195
            }
193
196
 
194
197
 
195
198
            var curveTopX = channelToX(item.channel)
196
199
            if (curveTopX == -1) {
 
200
                print("cureveTopX is -1. not painting wifi on channel", item.channel)
197
201
                continue;
198
202
            }
199
203