summaryrefslogtreecommitdiffstats
path: root/konqueror/sidebar/konqsidebar.cpp
blob: 774ad8509c8f7cbbadde19d04ee1066ee1e02273 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
/***************************************************************************
                               konqsidebar.cpp
                             -------------------
    begin                : Sat June 2 16:25:27 CEST 2001
    copyright            : (C) 2001 Joseph Wenninger
    email                : jowenn@kde.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 "konqsidebar.h"
#include "konqsidebariface_p.h"

#include <konq_events.h>
#include <kdebug.h>
#include <tqapplication.h>
#include <tdeaccelmanager.h>

KonqSidebar::KonqSidebar( TQWidget *parentWidget, const char *widgetName,
                          TQObject *parent, const char *name, bool universalMode )
: KParts::ReadOnlyPart(parent, name),KonqSidebarIface()
{
	// we need an instance
	setInstance( KonqSidebarFactory::instance() );
	m_extension = 0;
	// this should be your custom internal widget
	m_widget = new Sidebar_Widget( parentWidget, this, widgetName ,universalMode, parentWidget->topLevelWidget()->property("currentProfile").toString() );
	m_extension = new KonqSidebarBrowserExtension( this, m_widget,"KonqSidebar::BrowserExtension" );
	connect(m_widget,TQT_SIGNAL(started(TDEIO::Job *)),
		this, TQT_SIGNAL(started(TDEIO::Job*)));
	connect(m_widget,TQT_SIGNAL(completed()),this,TQT_SIGNAL(completed()));
	connect(m_extension, TQT_SIGNAL(addWebSideBar(const KURL&, const TQString&)),
		m_widget, TQT_SLOT(addWebSideBar(const KURL&, const TQString&)));
        TDEAcceleratorManager::setNoAccel(m_widget);
	setWidget(m_widget);
}

TDEInstance *KonqSidebar::getInstance()
{
	kdDebug() << "KonqSidebar::getInstance()" << endl;
	return KonqSidebarFactory::instance(); 
}

KonqSidebar::~KonqSidebar()
{
}

bool KonqSidebar::openFile()
{
	return true;
}

bool KonqSidebar::openURL(const KURL &url) {
	if (m_widget)
		return m_widget->openURL(url);
	else return false;
} 

void KonqSidebar::customEvent(TQCustomEvent* ev)
{
	if (KonqFileSelectionEvent::test(ev) ||
	    KonqFileMouseOverEvent::test(ev) ||
	    KonqConfigEvent::test(ev))
	{
		// Forward the event to the widget
		TQApplication::sendEvent( m_widget, ev );
	}
}



// It's usually safe to leave the factory code alone.. with the
// notable exception of the TDEAboutData data
#include <tdeaboutdata.h>
#include <tdelocale.h>
#include <kinstance.h>

TDEInstance*  KonqSidebarFactory::s_instance = 0L;
TDEAboutData* KonqSidebarFactory::s_about = 0L;

KonqSidebarFactory::KonqSidebarFactory()
    : KParts::Factory()
{
}

KonqSidebarFactory::~KonqSidebarFactory()
{
	delete s_instance;
	s_instance = 0L;
	delete s_about;
	s_about = 0L;
}

KParts::Part* KonqSidebarFactory::createPartObject( TQWidget *parentWidget, const char *widgetName,
                                                        TQObject *parent, const char *name,
                                                        const char * /*classname*/, const TQStringList &args )
{
    // Create an instance of our Part
    KonqSidebar* obj = new KonqSidebar( parentWidget, widgetName, parent, name, args.contains("universal") );

    // See if we are to be read-write or not
//    if (TQCString(classname) == "KParts::ReadOnlyPart")
  //      obj->setReadWrite(false);

    return obj;
}

TDEInstance* KonqSidebarFactory::instance()
{
	if( !s_instance )
	{
		s_about = new TDEAboutData("konqsidebartng", I18N_NOOP("Extended Sidebar"), "0.1");
		s_about->addAuthor("Joseph WENNINGER", 0, "jowenn@bigfoot.com");
		s_instance = new TDEInstance(s_about);
	}
	return s_instance;
}

K_EXPORT_COMPONENT_FACTORY( konq_sidebar, KonqSidebarFactory )

#include "konqsidebar.moc"