~showard314/ubuntu/natty/qtiplot/Python2.7_fix

« back to all changes in this revision

Viewing changes to qtiplot/src/TitlePicker.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2008-01-16 21:47:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080116214714-4nuye1xparrschj1
Tags: 0.9.3~rc2-2
Disable demo mode. (Closes: #461127)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
    File                 : TitlePicker.cpp
3
3
    Project              : QtiPlot
4
4
    --------------------------------------------------------------------
5
 
    Copyright            : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
6
 
    Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
 
5
    Copyright            : (C) 2007 by Ion Vasilief
 
6
    Email (use @ for *)  : ion_vasilief*yahoo.fr
7
7
    Description          : Title picker
8
 
                           
 
8
 
9
9
 ***************************************************************************/
10
10
 
11
11
/***************************************************************************
32
32
#include <qwt_text_label.h>
33
33
 
34
34
#include <QMouseEvent>
 
35
#include <QPen>
35
36
 
36
37
TitlePicker::TitlePicker(QwtPlot *plot):
37
38
        QObject(plot)
38
 
{
 
39
{
 
40
    d_selected = false;
39
41
        title = (QwtTextLabel *)plot->titleLabel();
40
42
        title->setFocusPolicy(Qt::StrongFocus);
41
43
        if (title)
46
48
{
47
49
        if (object != (QObject *)title)
48
50
                return FALSE;
49
 
        
50
 
    if ( object->inherits("QwtTextLabel") && e->type() == QEvent::MouseButtonDblClick)
51
 
                {
 
51
 
 
52
    if ( object->inherits("QwtTextLabel") && e->type() == QEvent::MouseButtonDblClick){
52
53
        emit doubleClicked();
 
54
                d_selected = true;
53
55
        return TRUE;
54
 
                }
55
 
 
56
 
         if ( object->inherits("QwtTextLabel") &&  e->type() == QEvent::MouseButtonPress )
57
 
         {
58
 
                 const QMouseEvent *me = (const QMouseEvent *)e;        
 
56
    }
 
57
 
 
58
         if ( object->inherits("QwtTextLabel") &&  e->type() == QEvent::MouseButtonPress ){
 
59
                 const QMouseEvent *me = (const QMouseEvent *)e;
 
60
 
59
61
                 emit clicked();
60
62
 
61
 
                 if (me->button()==Qt::RightButton)
62
 
                         emit showTitleMenu();
 
63
                 if (me->button() == Qt::RightButton)
 
64
                        emit showTitleMenu();
 
65
         else if (me->button() == Qt::LeftButton)
 
66
                        setSelected();
 
67
 
63
68
                 return !(me->modifiers() & Qt::ShiftModifier);
64
69
    }
65
70
 
66
 
        if ( object->inherits("QwtTextLabel") && 
67
 
        e->type() == QEvent::KeyPress)
68
 
                {
69
 
                switch (((const QKeyEvent *)e)->key()) 
 
71
        if ( object->inherits("QwtTextLabel") &&
 
72
        e->type() == QEvent::KeyPress){
 
73
                switch (((const QKeyEvent *)e)->key())
70
74
                        {
71
 
                        case Qt::Key_Delete: 
72
 
                        emit removeTitle();     
 
75
                        case Qt::Key_Delete:
 
76
                        emit removeTitle();
73
77
            return TRUE;
74
78
                        }
75
79
                }
76
80
 
77
81
    return QObject::eventFilter(object, e);
78
82
}
 
83
 
 
84
void TitlePicker::setSelected(bool select)
 
85
{
 
86
    if (!title || d_selected == select)
 
87
        return;
 
88
 
 
89
    d_selected = select;
 
90
 
 
91
    QwtText text = title->text();
 
92
    if (select)
 
93
        text.setBackgroundPen(QPen(Qt::blue));
 
94
    else
 
95
        text.setBackgroundPen(QPen(Qt::NoPen));
 
96
 
 
97
    ((QwtPlot *)parent())->setTitle(text);
 
98
}