scriptingdocker.cpp 2.53 KB
Newer Older
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
/*
 * This file is part of the KDE project
 *
 * Copyright (C) 2006 by Sebastian Sauer (mail@dipe.org)
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include "scriptingdocker.h"

#include <QToolBar>
#include <QBoxLayout>
#include <QListView>
26
#include <QModelIndex>
27

28
29
#include <QRect>

30
#include <kdebug.h>
31
32
33
#include <klocale.h>
#include <kicon.h>

34
#include <core/manager.h>
35
36
37
38
39
40
41
#include <core/model.h>
#include <core/guiclient.h>

ScriptingDocker::ScriptingDocker(QWidget* parent, Kross::GUIClient* guiclient)
    : QWidget(parent)
    , m_guiclient(guiclient)
{
Sebastian Sauer's avatar
Sebastian Sauer committed
42
#if 0
43
44
45
46
47
    QBoxLayout* layout = new QVBoxLayout(this);
    layout->setMargin(0);
    setLayout(layout);

    m_view = new QListView(this);
48
49
    m_model = new Kross::ActionCollectionProxyModel(this);
    m_view->setModel(m_model);
50
51
52
53
54
55
56
57
58
59
60
    layout->addWidget(m_view, 1);

    QToolBar* tb = new QToolBar(this);
    layout->addWidget(tb);
    tb->setMovable(false);
    //tb->setOrientation(Qt::Vertical);
    //tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    tb->addAction(KIcon("player_play"), i18n("Run"), this, SLOT(runScript()) );
    tb->addAction(KIcon("player_stop"), i18n("Stop"), this, SLOT(stopScript()) );

    connect(m_view, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(runScript()));
Sebastian Sauer's avatar
Sebastian Sauer committed
61
#endif
62
63
64
65
66
67
68
69
}

ScriptingDocker::~ScriptingDocker()
{
}

void ScriptingDocker::runScript()
{
Sebastian Sauer's avatar
Sebastian Sauer committed
70
#if 0
71
72
73
    QModelIndex index = m_model->mapToSource( m_view->currentIndex() );
    if( index.isValid() ) {
        Kross::Action* action = static_cast< Kross::Action* >( index.internalPointer() );
74
        action->trigger(); // execute the script
75
    }
Sebastian Sauer's avatar
Sebastian Sauer committed
76
#endif
77
78
79
80
}

void ScriptingDocker::stopScript()
{
Sebastian Sauer's avatar
Sebastian Sauer committed
81
#if 0
82
83
84
85
    QModelIndex index = m_model->mapToSource( m_view->currentIndex() );
    if( index.isValid() ) {
        Kross::Action* action = static_cast< Kross::Action* >( index.internalPointer() );
        action->finalize();
86
    }
Sebastian Sauer's avatar
Sebastian Sauer committed
87
#endif
88
89
90
}

#include "scriptingdocker.moc"