Subversion Repositories svn1

Rev

Rev 386 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
274 david 1
/*============================================================================ 
2
** Copyright (C) 1998-2012 Vix Technology, All rights reserved
3
**============================================================================
4
**
5
**  Project/Product : 
6
**  Filename        : qmteamselector.cpp
7
**  Author(s)       : DDP
8
**
9
**  Description     : Based on a QSpinBox with features
10
**                      Return - will emit signal
11
**                      All text is selected on focus
12
**
13
**  Information     :
14
**   Compiler       : ANSI C++
15
**   Target         : 
16
**
17
***==========================================================================*/
18
 
273 david 19
#include "qmteamselector.h"
20
#include <QKeyEvent>
21
 
274 david 22
/*----------------------------------------------------------------------------
23
** FUNCTION           : Constructor
24
**
25
** DESCRIPTION        :
26
**
27
**
28
** INPUTS             :
29
**
30
** RETURNS            :
31
**
32
----------------------------------------------------------------------------*/
33
 
34
 
275 david 35
QmTeamSelector::QmTeamSelector(QWidget *parent): QSpinBox(parent)
273 david 36
{
274 david 37
    /*
38
    **  Create a single shot timer to assist in selecting text in the Widget
39
    **  Use an interval of zero for immediate action
40
    */
41
    timer.setSingleShot(true);
42
    timer.setInterval(0);
43
    connect(&timer, SIGNAL(timeout()), this, SLOT(selectControl()));
273 david 44
}
45
 
274 david 46
/*----------------------------------------------------------------------------
47
** FUNCTION           : focusInEvent
48
**
49
** DESCRIPTION        : Overide the parent function of the same name
50
**                      Used to trigger a timer to select all text once
51
**                      The user has entered the Widget
52
**
53
**                      Calling selectALL() directly does not select all the text
54
**                      It is called on a zero-length timer as that works.
55
**
56
** INPUTS             :
57
**
58
** RETURNS            :
59
**
60
----------------------------------------------------------------------------*/
61
 
62
 
273 david 63
void QmTeamSelector::focusInEvent(QFocusEvent * event)
64
{
274 david 65
    //qDebug("QmTeamSelector::focusInEvent");
390 david 66
    Q_UNUSED(event);
274 david 67
    timer.start();
273 david 68
}
69
 
274 david 70
/*----------------------------------------------------------------------------
71
** FUNCTION           : selectControl
72
**
73
** DESCRIPTION        : Timer call back function
74
**                      Select all text in the Widget
75
**
76
** INPUTS             :
77
**
78
** RETURNS            :
79
**
80
----------------------------------------------------------------------------*/
81
 
82
void QmTeamSelector::selectControl(void)
83
{
84
    //qDebug("QmTeamSelector::selectControl");
85
    selectAll();
86
}
87
 
88
/*----------------------------------------------------------------------------
89
** FUNCTION           : keyPressEvent
90
**
91
** DESCRIPTION        : Detect and report "RETURN" key
92
**                      Force all text in the Widget to be selected
93
**
94
** INPUTS             :
95
**
96
** RETURNS            :
97
**
98
----------------------------------------------------------------------------*/
99
 
273 david 100
void QmTeamSelector::keyPressEvent(QKeyEvent * event)
101
{
274 david 102
    //qDebug("QmTeamSelector::keyPressEvent");
273 david 103
    if(event->key() == Qt::Key_Return)
104
    {
274 david 105
        //qDebug("QmTeamSelector::keyPressEvent - return Pressed");
273 david 106
        emit teamSelected( );
274 david 107
        timer.start();
273 david 108
    }
109
    else
110
    {
111
        QSpinBox::keyPressEvent(event);
112
    }
113
}
114