Subversion Repositories svn1-original

Rev

Rev 277 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 277 Rev 278
Line -... Line 1...
-
 
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
 
1
#include "qmteamselector.h"
19
#include "qmteamselector.h"
2
#include <QKeyEvent>
20
#include <QKeyEvent>
3
 
21
 
-
 
22
/*----------------------------------------------------------------------------
-
 
23
** FUNCTION           : Constructor
-
 
24
**
-
 
25
** DESCRIPTION        :
-
 
26
**
-
 
27
**
-
 
28
** INPUTS             :
-
 
29
**
-
 
30
** RETURNS            :
-
 
31
**
-
 
32
----------------------------------------------------------------------------*/
-
 
33
 
-
 
34
 
4
QmTeamSelector::QmTeamSelector()
35
QmTeamSelector::QmTeamSelector()
5
{
36
{
-
 
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
    */
6
    qDebug("QmTeamSelector");
41
    timer.setSingleShot(true);
-
 
42
    timer.setInterval(0);
-
 
43
    connect(&timer, SIGNAL(timeout()), this, SLOT(selectControl()));
7
}
44
}
8
 
45
 
-
 
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
 
9
void QmTeamSelector::focusInEvent(QFocusEvent * event)
63
void QmTeamSelector::focusInEvent(QFocusEvent * event)
10
{
64
{
11
    qDebug("QmTeamSelector::focusInEvent");
65
    //qDebug("QmTeamSelector::focusInEvent");
12
    //QSpinBox::focusInEvent(event);
-
 
13
    //selectAll();
66
    timer.start();
14
}
67
}
15
 
68
 
-
 
69
/*----------------------------------------------------------------------------
-
 
70
** FUNCTION           : selectControl
-
 
71
**
-
 
72
** DESCRIPTION        : Timer call back function
-
 
73
**                      Select all text in the Widget
-
 
74
**
-
 
75
** INPUTS             :
-
 
76
**
-
 
77
** RETURNS            :
-
 
78
**
-
 
79
----------------------------------------------------------------------------*/
-
 
80
 
-
 
81
void QmTeamSelector::selectControl(void)
-
 
82
{
-
 
83
    //qDebug("QmTeamSelector::selectControl");
-
 
84
    selectAll();
-
 
85
}
-
 
86
 
-
 
87
/*----------------------------------------------------------------------------
-
 
88
** FUNCTION           : keyPressEvent
-
 
89
**
-
 
90
** DESCRIPTION        : Detect and report "RETURN" key
-
 
91
**                      Force all text in the Widget to be selected
-
 
92
**
-
 
93
** INPUTS             :
-
 
94
**
-
 
95
** RETURNS            :
-
 
96
**
-
 
97
----------------------------------------------------------------------------*/
-
 
98
 
16
void QmTeamSelector::keyPressEvent(QKeyEvent * event)
99
void QmTeamSelector::keyPressEvent(QKeyEvent * event)
17
{
100
{
18
    qDebug("QmTeamSelector::keyPressEvent");
101
    //qDebug("QmTeamSelector::keyPressEvent");
19
    if(event->key() == Qt::Key_Return)
102
    if(event->key() == Qt::Key_Return)
20
    {
103
    {
21
        qDebug("QmTeamSelector::keyPressEvent - return Pressed");
104
        //qDebug("QmTeamSelector::keyPressEvent - return Pressed");
22
        emit teamSelected( );
105
        emit teamSelected( );
-
 
106
        timer.start();
23
    }
107
    }
24
    else
108
    else
25
    {
109
    {
26
        QSpinBox::keyPressEvent(event);
110
        QSpinBox::keyPressEvent(event);
27
    }
111
    }