summaryrefslogtreecommitdiffstats
path: root/quanta/utility/tagactionmanager.cpp
blob: eaad16ec1dc381fbdbce105df1c041e51d8a797e (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
/***************************************************************************
                               tagactionmanager.cpp
                             -------------------
 
    copyright            : (C) 2004 - Paulo Moura Guedes
    email                : moura@tdewebdev.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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kstaticdeleter.h>
#include <kactioncollection.h>
#include <kaction.h>
#include <tdehtmlview.h>
#include <klocale.h>
#include <dom/dom_node.h>

#include <tqwidget.h>

#include "tagactionmanager.h"
#include "tagactionset.h"
#include "resource.h"
#include "wkafkapart.h"


TagActionManager* TagActionManager::s_mSelf = 0;
static KStaticDeleter<TagActionManager> staticDeleter;


TagActionManager::TagActionManager()
    : m_actionCollection(0)
{
    s_mSelf = this;
    initActions(KafkaDocument::ref()->getKafkaWidget()->view());
}

TagActionManager::~TagActionManager()
{}

TagActionManager* TagActionManager::self()
{
    if (!s_mSelf)
    {
        staticDeleter.setObject(s_mSelf, new TagActionManager());
    }

    return s_mSelf;
}

void TagActionManager::initActions(TQWidget* parent)
{
    Q_ASSERT(parent);
    
    m_actionCollection = new KActionCollection(parent);
    
    TagActionSet* general(new TagActionSet());
    general->initActions(parent);
    m_tagActionSets.append(general);
        
    TableTagActionSet* table(new TableTagActionSet());
    table->initActions(parent);
    m_tagActionSets.append(table);
}

void TagActionManager::fillWithTagActions(TQWidget* widget, DOM::Node const& node)
{
    TagActionSetAbstract* tagActionSet = 0;
    for(tagActionSet = m_tagActionSets.first(); tagActionSet; tagActionSet = m_tagActionSets.next())
        tagActionSet->fillWithTagActions(widget, node);
}

bool TagActionManager::canIndentDTD(TQString const& dtd)
{
    return (dtd.contains("HTML", false) ||
            dtd.contains("XML", false));
}