summaryrefslogtreecommitdiffstats
path: root/ksquirrel/ksquirrelpart/sq_glview.cpp
blob: 1624b7cf0372c7f4e1a3e090edfe49476b7c6a6b (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
/***************************************************************************
                          sq_glview.cpp  -  description
                             -------------------
    begin                : Thu Nov 29 2007
    copyright            : (C) 2007 by Baryshev Dmitry
    email                : ksquirrel.iv@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kglobal.h>

#include "sq_glview.h"

SQ_GLView * SQ_GLView::m_inst = 0;

/***************************************/

SQ_TextSetter::SQ_TextSetter(TQObject *tqparent) : TQObject(tqparent)
{
    dest = "---";
}

SQ_TextSetter::~SQ_TextSetter()
{}

void SQ_TextSetter::setText(const TQString &s)
{
    dest = s;

    emit changed();
}

/***************************************/

SQ_GLView::SQ_GLView() : TQObject()
{
    m_inst = this;

    map.insert("SBDecoded", new SQ_TextSetter(this));
    map.insert("SBFrame",   new SQ_TextSetter(this));
    map.insert("SBLoaded",  new SQ_TextSetter(this));
    map.insert("SBGLZoom",  new SQ_TextSetter(this));
    map.insert("SBGLAngle", new SQ_TextSetter(this));
    map.insert("SBFile",    new SQ_TextSetter(this));

    tmp = new SQ_TextSetter(this);

    SQ_Setters::iterator itEnd = map.end();

    for(SQ_Setters::iterator it = map.begin();it != itEnd;++it)
        connect(it.data(), TQT_SIGNAL(changed()), this, TQT_SLOT(slotChanged()));
}

SQ_GLView::~SQ_GLView()
{}

SQ_TextSetter* SQ_GLView::sbarWidget(const TQString &name)
{
    SQ_Setters::iterator it = map.find(name);

    return (it == map.end() ? tmp : it.data());
}

void SQ_GLView::resetStatusBar()
{
    SQ_Setters::iterator itEnd = map.end();

    for(SQ_Setters::iterator it = map.begin();it != itEnd;++it)
    {
        it.data()->blockSignals(true);
        it.data()->setText("---");
        it.data()->blockSignals(false);
    }

    slotChanged();
}

void SQ_GLView::slotChanged()
{
    TQString result;

    static const TQString &line = KGlobal::staticQString(" | ");

    result.append(map["SBDecoded"]->text());
    result.append(line);

    result.append(map["SBFrame"]->text());
    result.append(line);

    result.append(map["SBLoaded"]->text());
    result.append(line);

    result.append(map["SBGLZoom"]->text());
    result.append(line);

    result.append(map["SBGLAngle"]->text());
    result.append(line);

    result.append("<b>");
    result.append(map["SBFile"]->text());
    result.append("</b>");

    emit message(result);
}

#include "sq_glview.moc"