summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/embedding/simple-embed/embedviewimp.cpp
blob: 87ae4f0075613abd9d5b7210f40c75be76d3adcd (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
//
// Author: Ian Reinhart Geiser <[email protected]>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <kjsembed/kjsembedpart.h>
#include <kjsembed/jsconsolewidget.h>
#include <kjsembed/jsbinding.h>

#include "embedviewimp.h"
#include <klineedit.h>
#include <tqgroupbox.h>

#include <tqdatetime.h>
#include <tqcolor.h>

EmbedViewImp::EmbedViewImp(TTQWidget *parent, const char *name)
    :EmbedView(parent, name)
{
    m_part = new KJSEmbed::KJSEmbedPart(0, "kjsembed_part", this,"JSEmbed");
    m_part->addObject(m_name, "Name");
    m_part->addObject(m_dept, "Dept");
    m_part->addObject(m_title, "Title");
    m_part->addObject(m_customOptions, "CustomOptions");
    m_part->addObject(this, "EmbedInterface");
}

void EmbedViewImp::okClicked()
{
    KJS::List args;
    KJS::Value val = m_part->callMethod("handleOk", args);
    TTQMap<TTQString, TTQVariant> personalData = KJSEmbed::convertToVariant(m_part->globalExec(), val).toMap();
    TTQDate birthday = personalData["birthday"].toDate();
    TTQColor eyecolor = personalData["eyeColor"].toColor();
    TTQString notes = personalData["notes"].toString();
    
    kdDebug() << "birthday: " << birthday << endl;
    kdDebug() << "eyecolor: " << eyecolor << endl;
    kdDebug() << "notes: " << notes << endl;
    
}

void EmbedViewImp::cancelClicked()
{
    m_name->setText("");
    m_title->setText("");
    m_dept->setText("");
}

void EmbedViewImp::consoleClicked()
{
    m_part->view()->setHidden(!m_part->view()->isHidden());
}

bool EmbedViewImp::runScript( const TTQString &file )
{
    return m_part->runFile(file, m_part->globalObject() );
}

TTQVariant EmbedViewImp::someValue() const
{
    TTQMap<TTQString,TTQVariant> returnMap;
    returnMap["name"] = m_name->text();	
    returnMap["title"] = m_title->text();	
    returnMap["dept"] = m_dept->text();	
    return TTQVariant(returnMap);
}

void EmbedViewImp::setSomeValue( const TTQVariant &val )
{
    TTQMap<TTQString,TTQVariant> map = val.toMap();
    m_name->setText(map["name"].toString());
    m_title->setText(map["title"].toString());
    m_dept->setText(map["dept"].toString());
}

#include "embedviewimp.moc"