aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/byte_view_text.cpp
blob: e45ec3f4e9fe6a85c50fb3496bd7b9e82bf85edd (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/* byte_view_text.cpp
 *
 * $Id$
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * 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 "monospace_font.h"
#include "byte_view_text.h"

#include <epan/charsets.h>

#include <QTextCursor>
#include <QApplication>
#include <QMouseEvent>

// XXX - Use KHexEdit instead?
// http://api.kde.org/4.x-api/kdelibs-apidocs/interfaces/khexedit/html/index.html

ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTreeWidget *protoTree, unsigned int encoding) :
    QTextEdit(parent)
{
    setReadOnly(true);
    setLineWrapMode(QTextEdit::NoWrap);
    setCurrentFont(get_monospace_font());

    m_tvb = tvb;
    m_tree = tree;
    m_protoTree = protoTree;
    m_encoding = encoding;
    m_start = m_len = 0;

//    m_background = textBackgroundColor();
//    m_foreground = textColor();

//    g_log(NULL, G_LOG_LEVEL_DEBUG, "fg %d %d %d bg %d %d %d",
//          m_foreground.red(), m_foreground.green(), m_foreground.blue(),
//          m_background.red(), m_background.green(), m_background.blue()
//          );

    hexPrintCommon();
}

#define MAX_OFFSET_LEN   8      /* max length of hex offset of bytes */
#define BYTES_PER_LINE  16      /* max byte values in a line */
#define BITS_PER_LINE    8      /* max bit values in a line */
#define BYTE_VIEW_SEP    8      /* insert a space every BYTE_VIEW_SEP bytes */
#define HEX_DUMP_LEN    (BYTES_PER_LINE*3 + 1)
/* max number of characters hex dump takes -
   2 digits plus trailing blank
   plus separator between first and
   second 8 digits */
#define DATA_DUMP_LEN   (HEX_DUMP_LEN + 2 + BYTES_PER_LINE)
/* number of characters those bytes take;
   3 characters per byte of hex dump,
   2 blanks separating hex from ASCII,
   1 character per byte of ASCII dump */
#define MAX_LINE_LEN    (MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN)
/* number of characters per line;
   offset, 2 blanks separating offset
   from data dump, data dump */
#define MAX_LINES       100
#define MAX_LINES_LEN   (MAX_LINES*MAX_LINE_LEN)

// Copied from packet_hex_print_common
void
ByteViewText::hexPrintCommon()
{
    int            i = 0, j, k = 0, len;
    const guint8  *pd;
    QString        line;
    static guchar  hexchars[16] = {
        '0', '1', '2', '3', '4', '5', '6', '7',
        '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
//    static const guint8 bitmask[8] = {
//        0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
    guchar         c = '\0';

//    progdlg_t  *progbar = NULL;
//    float       progbar_val;
//    gboolean    progbar_stop_flag;
//    GTimeVal    progbar_start_time;
//    gchar       progbar_status_str[100];
//    int         progbar_nextstep;
//    int         progbar_quantum;

    setPlainText("");
    // Replaces get_byte_view_data_and_length().
    if (!m_tvb)
        return;
    len = tvb_length(m_tvb);
    pd = tvb_get_ptr(m_tvb, 0, -1);

    /*
     * How many of the leading digits of the offset will we supply?
     * We always supply at least 4 digits, but if the maximum offset
     * won't fit in 4 digits, we use as many digits as will be needed.
     */
    if (((len - 1) & 0xF0000000) != 0)
        m_useDigits = 8; /* need all 8 digits */
    else if (((len - 1) & 0x0F000000) != 0)
        m_useDigits = 7; /* need 7 digits */
    else if (((len - 1) & 0x00F00000) != 0)
        m_useDigits = 6; /* need 6 digits */
    else if (((len - 1) & 0x000F0000) != 0)
        m_useDigits = 5; /* need 5 digits */
    else
        m_useDigits = 4; /* we'll supply 4 digits */

    /* Update the progress bar when it gets to this value. */
//    if (len > MIN_PACKET_LENGTH){
//        progbar_nextstep = 0;
//    }else{
//        /* If length =< MIN_PACKET_LENGTH
//         * there is no need to calculate the progress
//         */
//        progbar_nextstep = len+1;
//    }

//    /* When we reach the value that triggers a progress bar update,
//       bump that value by this amount. */
//    progbar_quantum = len/N_PROGBAR_UPDATES;
//    /* Progress so far. */
//    progbar_val = 0.0f;

//    progbar_stop_flag = FALSE;
//    g_get_current_time(&progbar_start_time);

    while (i < len) {
        /* Create the progress bar if necessary.
           We check on every iteration of the loop, so that it takes no
           longer than the standard time to create it (otherwise, for a
           large packet, we might take considerably longer than that standard
           time in order to get to the next progress bar step). */
//        if ((progbar == NULL) && (len > MIN_PACKET_LENGTH))
//            progbar = delayed_create_progress_dlg("Processing", "Packet Details",
//                                                  TRUE,
//                                                  &progbar_stop_flag,
//                                                  &progbar_start_time,
//                                                  progbar_val);

        /* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
           when we update it, we have to run the GTK+ main loop to get it
           to repaint what's pending, and doing so may involve an "ioctl()"
           to see if there's any pending input from an X server, and doing
           that for every packet can be costly, especially on a big file. */
//        if (i >= progbar_nextstep) {

//            if (progbar != NULL) {
//                /* let's not divide by zero. I should never be started
//                 * with count == 0, so let's assert that
//                 */
//                g_assert(len > 0);
//                progbar_val = (gfloat) i / len;
//                g_snprintf(progbar_status_str, sizeof(progbar_status_str),
//                           "%4u of %u bytes", i, len);
//                update_progress_dlg(progbar, progbar_val, progbar_status_str);
//            }

//            progbar_nextstep += progbar_quantum;
//        }

//        if (progbar_stop_flag) {
//            /* Well, the user decided to abort the operation.  Just stop,
//           and arrange to return TRUE to our caller, so they know it
//           was stopped explicitly. */
//            break;
//        }

        /* Print the line number */
        j = m_useDigits;
        do {
            j--;
            c = (i >> (j*4)) & 0xF;
            line += hexchars[c];
        } while (j != 0);
        line += "  ";

        j   = i;
//        switch (recent.gui_bytes_view) {
//        case BYTES_HEX:
            k = i + BYTES_PER_LINE;
//            break;
//        case BYTES_BITS:
//            k = i + BITS_PER_LINE;
//            break;
//        default:
//            g_assert_not_reached();
//        }
        /* Print the hex bit */
        while (i < k) {
            if (i < len) {
//                switch (recent.gui_bytes_view) {
//                case BYTES_HEX:
                    line += hexchars[(pd[i] & 0xf0) >> 4];
                    line += hexchars[pd[i] & 0x0f];
//                    break;
//                case BYTES_BITS:
//                    for (b = 0; b < 8; b++) {
//                        line += (pd[i] & bitmask[b]) ? '1' : '0';
//                    }
//                    break;
//            default:
//                    g_assert_not_reached();
//                }
            } else {
//                switch (recent.gui_bytes_view) {
//                case BYTES_HEX:
                    line += "  ";
//                    break;
//                case BYTES_BITS:
//                    for (b = 0; b < 8; b++) {
//                        line += ' ';
//                    }
//                    break;
//            default:
//                    g_assert_not_reached();
//                }
            }
            i++;
            /* Inter byte space if not at end of line */
            if (i < k) {
                line += ' ';
                /* insert a space every BYTE_VIEW_SEP bytes */
                if( ( i % BYTE_VIEW_SEP ) == 0 ) {
                    line += ' ';
                }
            }
        }

        /* Print some space at the end of the line */
        line += "   ";

        /* Print the ASCII bit */
        i = j;

        while (i < k) {
            if (i < len) {
                if (m_encoding == PACKET_CHAR_ENC_CHAR_ASCII) {
                    c = pd[i];
                }
                else if (m_encoding == PACKET_CHAR_ENC_CHAR_EBCDIC) {
                    c = EBCDIC_to_ASCII1(pd[i]);
                }
                else {
                    g_assert_not_reached();
                }
                line += isprint(c) ? c : '.';
            } else {
                line += ' ';
            }
            i++;
            if (i < k) {
                /* insert a space every BYTE_VIEW_SEP bytes */
                if( ( i % BYTE_VIEW_SEP ) == 0 ) {
                    line += ' ';
                }
            }
        }
        line += '\n';
        if (line.length() >= (MAX_LINES_LEN - MAX_LINE_LEN)) {
            append(line);
            line.clear();
        }
    }

//    /* We're done printing the packets; destroy the progress bar if
//       it was created. */
//    if (progbar != NULL)
//        destroy_progress_dlg(progbar);

    if (line.length()) {
        append(line);
    }
}

bool ByteViewText::hasDataSource(tvbuff_t *ds_tvb) {
    if (ds_tvb != NULL && ds_tvb == m_tvb)
        return true;
    return false;
}

// Copied from packet_hex_apply_reverse_tag
void ByteViewText::highlight(int bstart, int blen, bool is_root) {
    m_start = bstart;
//    m_len = blen;

//    g_log(NULL, G_LOG_LEVEL_DEBUG, "hl %d %d %d %d", start, len, m_foreground.color().red(), m_background.color().red());
    QTextCursor cursor(textCursor());
    QTextCharFormat format = cursor.charFormat();

    QPalette pal = QApplication::palette();

    if (is_root) {
        cursor.movePosition(QTextCursor::Start);
        cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
        format.setForeground(pal.text());
        format.setBackground(pal.base());
        cursor.setCharFormat(format);
    }

    // XXX - We should probably use the same colors as the packet list and proto tree selections.
    // It isn't obvious how to fetch these.
    format.setForeground(is_root ? pal.text() : pal.base());
    format.setBackground(is_root ? pal.alternateBase() : pal.text());

    int bend = bstart + blen;
    int per_line = 0;
    int per_one = 0;
    int bits_per_one = 0;
    int hex_offset, ascii_offset;

    int start_line, start_line_pos;
    int stop_line, stop_line_pos;

    if (bstart == -1 || blen == -1)
        return;

//    /* Display with inverse video ? */
//    if (prefs.gui_hex_dump_highlight_style)
//        revstyle = "reverse";
//    else
//        revstyle = "bold";

//    switch (recent.gui_bytes_view) {
//    case BYTES_HEX:
        per_line = BYTES_PER_LINE;
        per_one  = 2+1;  /* "ff " */
        bits_per_one = 4;
//        break;
//    case BYTES_BITS:
//        per_line = BITS_PER_LINE;
//        per_one  = 8+1;  /* "10101010 " */
//        bits_per_one = 1;
//        break;
//    default:
//        g_assert_not_reached();
//    }

    start_line = bstart / per_line;
    start_line_pos = bstart % per_line;

    stop_line = bend / per_line;
    stop_line_pos = bend % per_line;

#define hex_fix(pos)   hex_offset + (pos * per_one) + (pos / BYTE_VIEW_SEP) - (pos == per_line)
#define ascii_fix(pos) pos + (pos / BYTE_VIEW_SEP) - (pos == per_line)

    hex_offset = m_useDigits + 2;
    ascii_offset = hex_fix(per_line) + 2;

    cursor.setPosition(0);
    cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, start_line);

//    if (mask == 0x00) {
        while (start_line <= stop_line) {
            int line_pos_end = (start_line == stop_line) ? stop_line_pos : per_line;
//            int first_block_adjust = (recent.gui_bytes_view == BYTES_HEX) ? (line_pos_end == per_line/2) : 0;
            int first_block_adjust = line_pos_end == per_line/2;

            if (start_line_pos == line_pos_end) break;

            // Should we just jump to absolute offsets instead?
            /* bits/hex */
            int cursor_start = hex_fix(start_line_pos);
            int cursor_len = hex_fix(line_pos_end) - cursor_start - 1 - first_block_adjust;
            cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, cursor_start);
            cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, cursor_len);
            cursor.setCharFormat(format);
            cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, ascii_offset - cursor_start - cursor_len);

            /* ascii */
            cursor_start = ascii_fix(start_line_pos);
            cursor_len = ascii_fix(line_pos_end) - cursor_start - first_block_adjust;
            cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, cursor_start);
            cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, cursor_len);
            cursor.setCharFormat(format);

            start_line_pos = 0;
            start_line++;
            // You are encouraged to make carriage return and line feed sound
            // effects as you read the next two lines.
            cursor.movePosition(QTextCursor::StartOfLine);
            cursor.movePosition(QTextCursor::Down);
        }

//    } else if (mask_le) { /* LSB of mask first (little-endian) */
//        while (start_line <= stop_line) {
//            int line_pos_end = (start_line == stop_line) ? stop_line_pos : per_line;
//            int line_pos = start_line_pos;

//            while (line_pos < line_pos_end) {
//                int lop = 8 / bits_per_one;
//                int mask_per_one = (1 << bits_per_one) - 1;
//                int ascii_on = 0;

//                while (lop--) {
//                    if ((mask & mask_per_one)) {
//                        /* bits/hex */
//                        gtk_text_buffer_get_iter_at_line_index(buf, &i_start, start_line, hex_fix(line_pos)+lop);
//                        gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, start_line, hex_fix(line_pos)+lop+1);
//                        gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop);

//                        ascii_on = 1;
//                    }
//                    mask >>= bits_per_one;
//                }

//                /* at least one bit of ascii was one -> turn ascii on */
//                if (ascii_on) {
//                    /* ascii */
//                    gtk_text_buffer_get_iter_at_line_index(buf, &i_start, start_line, ascii_fix(line_pos));
//                    gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, start_line, ascii_fix(line_pos)+1);
//                    gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop);
//                }

//                if (!mask)
//                    goto xend;

//                line_pos++;
//            }

//            start_line_pos = 0;
//            start_line++;
//        }
//    } else { /* mask starting from end (big-endian) */
//        while (start_line <= stop_line) {
//            int line_pos_start = (start_line == stop_line) ? start_line_pos : 0;
//            int line_pos = stop_line_pos-1;

//            while (line_pos >= line_pos_start) {
//                int lop = 8 / bits_per_one;
//                int mask_per_one = (1 << bits_per_one) - 1;
//                int ascii_on = 0;

//                while (lop--) {
//                    if ((mask & mask_per_one)) {
//                        /* bits/hex */
//                        gtk_text_buffer_get_iter_at_line_index(buf, &i_start, stop_line, hex_fix(line_pos)+lop);
//                        gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, stop_line, hex_fix(line_pos)+lop+1);
//                        gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop);

//                        ascii_on = 1;
//                    }
//                    mask >>= bits_per_one;
//                }

//                /* at least one bit of ascii was one -> turn ascii on */
//                if (ascii_on) {
//                    /* ascii */
//                    gtk_text_buffer_get_iter_at_line_index(buf, &i_start, stop_line, ascii_fix(line_pos));
//                    gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, stop_line, ascii_fix(line_pos)+1);
//                    gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop);
//                }

//                if (!mask)
//                    goto xend;

//                line_pos--;
//            }

//            stop_line_pos = per_line;
//            stop_line--;
//        }
//    }
//xend:

#undef hex_fix
#undef ascii_fix
}

// XXX - Copied from main_proto_draw.c
/* Which byte the offset is referring to. Associates
 * whitespace with the preceding digits. */
static int
byte_num(int offset, int start_point)
{
    return (offset - start_point) / 3;
}

// XXX - Copied from main_proto_draw.c
//static int
//bit_num(int offset, int start_point)
//{
//    return (offset - start_point) / 9;
//}

// XXX - Copied from main_proto_draw.c
static int
hex_view_get_byte(guint ndigits, int row, int column)
{
    int           byte;
    int           digits_start_1;
    int           digits_end_1;
    int           digits_start_2;
    int           digits_end_2;
    int           text_start_1;
    int           text_end_1;
    int           text_start_2;
    int           text_end_2;

    /*
     * The column of the first hex digit in the first half.
     * That starts after "ndigits" digits of offset and two
     * separating blanks.
     */
    digits_start_1 = ndigits + 2;

    /*
     * The column of the last hex digit in the first half.
     * There are BYTES_PER_LINE/2 bytes displayed in the first
     * half; there are 2 characters per byte, plus a separating
     * blank after all but the last byte's characters.
     */
    digits_end_1 = digits_start_1 + (BYTES_PER_LINE/2)*2 +
        (BYTES_PER_LINE/2 - 1);

    /*
     * The column of the first hex digit in the second half.
     * Add 2 for the 2 separating blanks between the halves.
     */
    digits_start_2 = digits_end_1 + 2;

    /*
     * The column of the last hex digit in the second half.
     * Add the same value we used to get "digits_end_1" from
     * "digits_start_1".
     */
    digits_end_2 = digits_start_2 + (BYTES_PER_LINE/2)*2 +
        (BYTES_PER_LINE/2 - 1);

    /*
     * The column of the first "text dump" character in the first half.
     * Add 3 for the 3 separating blanks between the hex and text dump.
     */
    text_start_1 = digits_end_2 + 3;

    /*
     * The column of the last "text dump" character in the first half.
     * There are BYTES_PER_LINE/2 bytes displayed in the first
     * half; there is 1 character per byte.
     *
     * Then subtract 1 to get the last column of the first half
     * rather than the first column after the first half.
     */
    text_end_1 = text_start_1 + BYTES_PER_LINE/2 - 1;

    /*
     * The column of the first "text dump" character in the second half.
     * Add back the 1 to get the first column after the first half,
     * and then add 1 for the separating blank between the halves.
     */
    text_start_2 = text_end_1 + 2;

    /*
     * The column of the last "text dump" character in second half.
     * Add the same value we used to get "text_end_1" from
     * "text_start_1".
     */
    text_end_2 = text_start_2 + BYTES_PER_LINE/2 - 1;

    /* Given the column and row, determine which byte offset
     * the user clicked on. */
    if (column >= digits_start_1 && column <= digits_end_1) {
        byte = byte_num(column, digits_start_1);
        if (byte == -1) {
            return byte;
        }
    }
    else if (column >= digits_start_2 && column <= digits_end_2) {
        byte = byte_num(column, digits_start_2);
        if (byte == -1) {
            return byte;
        }
        byte += 8;
    }
    else if (column >= text_start_1 && column <= text_end_1) {
        byte = column - text_start_1;
    }
    else if (column >= text_start_2 && column <= text_end_2) {
        byte = 8 + column - text_start_2;
    }
    else {
        /* The user didn't select a hex digit or
         * text-dump character. */
        return -1;
    }

    /* Add the number of bytes from the previous rows. */
    byte += row * BYTES_PER_LINE;

    return byte;
}

void ByteViewText::mousePressEvent (QMouseEvent * event) {
    if (event->button() == Qt::LeftButton) {
        int byte;
        QTextCursor cursor(cursorForPosition(event->pos()));
        field_info *fi;

        byte = hex_view_get_byte(m_useDigits, cursor.blockNumber(), cursor.columnNumber());
        fi = proto_find_field_from_offset(m_tree, byte, m_tvb);
        g_log(NULL, G_LOG_LEVEL_DEBUG, "byte %d  fi %p", byte, fi);

        if (fi && m_protoTree) {
            // XXX - This should probably be a ProtoTree method.
            QTreeWidgetItemIterator iter(m_protoTree);
            QVariant v;
            while (*iter) {
                v = (*iter)->data(0, Qt::UserRole);
                if (fi == (field_info *) v.value<void *>()) {
                    g_log(NULL, G_LOG_LEVEL_DEBUG, "found %p", fi);
                    m_protoTree->setCurrentItem((*iter));
                }

                iter++;
            }
        }
    }

    QWidget::mousePressEvent (event);
}