1999-03-30 13:18:19 +00:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
Copyright (C) 1998, 1999 David Faure <faure@kde.org>
|
1999-11-28 03:26:15 +00:00
|
|
|
|
1999-05-20 06:39:06 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
1999-03-30 13:18:19 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1999-11-28 03:26:15 +00:00
|
|
|
|
1999-05-20 06:39:06 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
1999-03-30 13:18:19 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1999-05-20 06:39:06 +00:00
|
|
|
General Public License for more details.
|
1999-11-28 03:26:15 +00:00
|
|
|
|
1999-05-20 06:39:06 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
1999-03-30 13:18:19 +00:00
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
1999-11-28 03:26:15 +00:00
|
|
|
*/
|
1999-03-30 13:18:19 +00:00
|
|
|
|
2000-07-04 16:33:30 +00:00
|
|
|
#include <qfile.h>
|
|
|
|
|
2000-05-20 19:53:10 +00:00
|
|
|
#include "konq_view.h"
|
2000-05-20 20:53:19 +00:00
|
|
|
#include "KonqViewIface.h"
|
2000-02-23 21:05:24 +00:00
|
|
|
#include "konq_factory.h"
|
1999-03-31 00:07:13 +00:00
|
|
|
#include "konq_frame.h"
|
2000-05-20 19:53:10 +00:00
|
|
|
#include "konq_mainwindow.h"
|
1999-06-19 18:02:20 +00:00
|
|
|
#include "konq_propsview.h"
|
1999-10-17 15:31:19 +00:00
|
|
|
#include "konq_run.h"
|
2000-04-10 01:25:09 +00:00
|
|
|
#include "konq_events.h"
|
1999-10-31 17:42:40 +00:00
|
|
|
#include "konq_viewmgr.h"
|
2001-03-02 22:51:39 +00:00
|
|
|
#include "konq_browseriface.h"
|
2000-02-19 23:29:44 +00:00
|
|
|
#include <kio/job.h>
|
1999-04-04 02:01:25 +00:00
|
|
|
|
2000-11-27 23:59:03 +00:00
|
|
|
#include <konq_historymgr.h>
|
2001-01-09 18:44:49 +00:00
|
|
|
#include <konq_pixmapprovider.h>
|
2000-11-25 17:06:48 +00:00
|
|
|
|
1999-10-17 15:31:19 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <kdebug.h>
|
2000-10-22 13:17:06 +00:00
|
|
|
#include <klocale.h>
|
2000-11-26 00:56:16 +00:00
|
|
|
#include <kurldrag.h>
|
1999-10-17 15:31:19 +00:00
|
|
|
|
2000-01-20 20:48:29 +00:00
|
|
|
#include <qapplication.h>
|
2000-05-10 13:23:48 +00:00
|
|
|
#include <qmetaobject.h>
|
2000-11-26 00:56:16 +00:00
|
|
|
#include <qobjectlist.h>
|
2000-01-20 20:48:29 +00:00
|
|
|
|
2000-03-19 16:32:52 +00:00
|
|
|
#include <kparts/factory.h>
|
|
|
|
|
2000-01-08 21:22:21 +00:00
|
|
|
template class QList<HistoryEntry>;
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
KonqView::KonqView( KonqViewFactory &viewFactory,
|
|
|
|
KonqFrame* viewFrame,
|
|
|
|
KonqMainWindow *mainWindow,
|
|
|
|
const KService::Ptr &service,
|
|
|
|
const KTrader::OfferList &partServiceOffers,
|
|
|
|
const KTrader::OfferList &appServiceOffers,
|
2000-07-13 19:48:39 +00:00
|
|
|
const QString &serviceType,
|
|
|
|
bool passiveMode
|
2000-05-20 17:27:38 +00:00
|
|
|
)
|
1999-03-31 00:07:13 +00:00
|
|
|
{
|
1999-07-11 19:17:27 +00:00
|
|
|
m_pKonqFrame = viewFrame;
|
2000-05-20 17:27:38 +00:00
|
|
|
m_pKonqFrame->setView( this );
|
1999-04-26 01:30:46 +00:00
|
|
|
|
1999-04-05 13:38:52 +00:00
|
|
|
m_sLocationBarURL = "";
|
2000-03-13 02:30:02 +00:00
|
|
|
m_bLockHistory = false;
|
2000-05-20 17:27:38 +00:00
|
|
|
m_pMainWindow = mainWindow;
|
1999-06-28 13:53:26 +00:00
|
|
|
m_pRun = 0L;
|
2000-05-20 13:37:31 +00:00
|
|
|
m_pPart = 0L;
|
2000-05-20 20:53:19 +00:00
|
|
|
m_dcopObject = 0L;
|
2000-01-16 14:05:27 +00:00
|
|
|
|
1999-10-29 21:35:22 +00:00
|
|
|
m_service = service;
|
2000-03-27 14:05:13 +00:00
|
|
|
m_partServiceOffers = partServiceOffers;
|
|
|
|
m_appServiceOffers = appServiceOffers;
|
2000-01-24 12:25:08 +00:00
|
|
|
m_serviceType = serviceType;
|
1999-11-28 03:26:15 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
m_bAllowHTML = m_pMainWindow->isHTMLAllowed();
|
2000-03-13 02:30:02 +00:00
|
|
|
m_lstHistory.setAutoDelete( true );
|
1999-08-03 19:23:33 +00:00
|
|
|
m_bLoading = false;
|
2000-07-13 19:48:39 +00:00
|
|
|
m_bPassiveMode = passiveMode;
|
2000-06-18 18:16:16 +00:00
|
|
|
m_bLockedLocation = false;
|
2000-04-16 23:43:46 +00:00
|
|
|
m_bLinkedView = false;
|
2000-05-07 12:30:25 +00:00
|
|
|
m_bAborted = false;
|
2000-06-14 22:59:01 +00:00
|
|
|
m_bToggleView = false;
|
2001-03-31 07:44:58 +00:00
|
|
|
m_bGotIconURL = false;
|
2001-05-16 19:36:01 +00:00
|
|
|
m_bPopupMenuEnabled = true;
|
2001-03-02 22:51:39 +00:00
|
|
|
m_browserIface = new KonqBrowserInterface( this, "browseriface" );
|
2000-03-19 16:32:52 +00:00
|
|
|
|
2000-07-02 14:42:11 +00:00
|
|
|
switchView( viewFactory );
|
1999-03-30 13:18:19 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
KonqView::~KonqView()
|
1999-03-30 13:18:19 +00:00
|
|
|
{
|
2000-05-20 17:27:38 +00:00
|
|
|
//kdDebug(1202) << "KonqView::~KonqView : part = " << m_pPart << endl;
|
2000-03-19 16:32:52 +00:00
|
|
|
|
2000-12-02 15:17:15 +00:00
|
|
|
// We did so ourselves for passive views
|
|
|
|
if ( isPassiveMode() && m_pPart )
|
|
|
|
disconnect( m_pPart, SIGNAL( destroyed() ), m_pMainWindow->viewManager(), SLOT( slotObjectDestroyed() ) );
|
|
|
|
|
2000-05-20 13:37:31 +00:00
|
|
|
delete m_pPart;
|
1999-11-11 22:47:40 +00:00
|
|
|
delete (KonqRun *)m_pRun;
|
2000-05-20 17:27:38 +00:00
|
|
|
//kdDebug(1202) << "KonqView::~KonqView " << this << " done" << endl;
|
1999-03-31 00:07:13 +00:00
|
|
|
}
|
|
|
|
|
2000-07-02 14:42:11 +00:00
|
|
|
void KonqView::openURL( const KURL &url, const QString & locationBarURL, const QString & nameFilter )
|
1999-04-04 02:01:25 +00:00
|
|
|
{
|
2000-08-10 10:32:42 +00:00
|
|
|
kdDebug(1202) << "KonqView::openURL url=" << url.url() << " locationBarURL=" << locationBarURL << endl;
|
2000-04-12 21:06:41 +00:00
|
|
|
setServiceTypeInExtension();
|
|
|
|
|
2000-04-13 14:53:03 +00:00
|
|
|
if ( !m_bLockHistory )
|
|
|
|
{
|
|
|
|
// Store this new URL in the history, removing any existing forward history.
|
|
|
|
// We do this first so that everything is ready if a part calls completed().
|
|
|
|
createHistoryEntry();
|
|
|
|
} else
|
|
|
|
m_bLockHistory = false;
|
1999-10-17 15:31:19 +00:00
|
|
|
|
2000-07-02 14:42:11 +00:00
|
|
|
callExtensionStringMethod( "setNameFilter(QString)", nameFilter );
|
|
|
|
setLocationBarURL( locationBarURL );
|
|
|
|
|
2000-05-07 12:30:25 +00:00
|
|
|
KParts::BrowserExtension *ext = browserExtension();
|
2000-05-31 10:12:55 +00:00
|
|
|
KParts::URLArgs args;
|
|
|
|
if ( ext )
|
|
|
|
args = ext->urlArgs();
|
2000-06-03 13:26:49 +00:00
|
|
|
|
2000-05-31 10:12:55 +00:00
|
|
|
if ( m_bAborted && m_pPart && m_pPart->url() == url )
|
2000-05-07 12:30:25 +00:00
|
|
|
{
|
|
|
|
args.reload = true;
|
2000-06-01 12:48:52 +00:00
|
|
|
if ( ext )
|
|
|
|
ext->setURLArgs( args );
|
2000-05-07 12:30:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_bAborted = false;
|
|
|
|
|
2000-05-20 13:37:31 +00:00
|
|
|
m_pPart->openURL( url );
|
2000-01-21 14:12:51 +00:00
|
|
|
|
2000-05-31 10:12:55 +00:00
|
|
|
sendOpenURLEvent( url, args );
|
2000-03-13 02:30:02 +00:00
|
|
|
|
2000-07-14 21:54:29 +00:00
|
|
|
updateHistoryEntry(false /* don't save location bar URL yet */);
|
2000-11-25 17:06:48 +00:00
|
|
|
// add pending history entry
|
2001-01-11 17:22:53 +00:00
|
|
|
KonqHistoryManager::kself()->addPending( url, locationBarURL, QString::null);
|
2000-04-13 14:53:03 +00:00
|
|
|
|
2000-07-23 00:59:21 +00:00
|
|
|
//kdDebug(1202) << "Current position : " << m_lstHistory.at() << endl;
|
1999-04-04 12:40:19 +00:00
|
|
|
}
|
|
|
|
|
2000-07-02 14:42:11 +00:00
|
|
|
void KonqView::switchView( KonqViewFactory &viewFactory )
|
1999-04-04 12:40:19 +00:00
|
|
|
{
|
2000-05-20 17:27:38 +00:00
|
|
|
kdDebug(1202) << "KonqView::switchView" << endl;
|
2000-05-20 13:37:31 +00:00
|
|
|
if ( m_pPart )
|
|
|
|
m_pPart->widget()->hide();
|
2000-01-16 14:05:27 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
KParts::ReadOnlyPart *oldPart = m_pPart;
|
2000-06-22 22:13:27 +00:00
|
|
|
m_pPart = m_pKonqFrame->attach( viewFactory ); // creates the part
|
|
|
|
|
2000-07-02 11:41:01 +00:00
|
|
|
// Activate the new part
|
2000-05-20 17:27:38 +00:00
|
|
|
if ( oldPart )
|
1999-12-18 23:00:06 +00:00
|
|
|
{
|
2000-05-20 17:27:38 +00:00
|
|
|
emit sigPartChanged( this, oldPart, m_pPart );
|
|
|
|
delete oldPart;
|
1999-12-18 23:00:06 +00:00
|
|
|
}
|
2000-01-16 14:05:27 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
connectPart();
|
2000-04-05 22:28:34 +00:00
|
|
|
|
2000-10-21 11:15:10 +00:00
|
|
|
if ( !m_pMainWindow->viewManager()->isLoadingProfile() )
|
2000-04-05 22:28:34 +00:00
|
|
|
{
|
2000-10-21 11:15:10 +00:00
|
|
|
// Honour "non-removeable passive mode" (like the dirtree)
|
|
|
|
QVariant prop = m_service->property( "X-KDE-BrowserView-PassiveMode");
|
|
|
|
if ( prop.isValid() && prop.toBool() )
|
|
|
|
{
|
2000-12-02 15:17:15 +00:00
|
|
|
kdDebug() << "KonqView::switchView X-KDE-BrowserView-PassiveMode -> setPassiveMode" << endl;
|
2000-10-21 11:15:10 +00:00
|
|
|
setPassiveMode( true ); // set as passive
|
|
|
|
}
|
2000-04-16 23:43:46 +00:00
|
|
|
|
2000-10-21 11:15:10 +00:00
|
|
|
// Honour "linked view"
|
|
|
|
prop = m_service->property( "X-KDE-BrowserView-LinkedView");
|
|
|
|
if ( prop.isValid() && prop.toBool() )
|
2000-04-22 23:42:10 +00:00
|
|
|
{
|
2000-10-21 11:15:10 +00:00
|
|
|
setLinkedView( true ); // set as linked
|
|
|
|
// Two views : link both
|
|
|
|
if (m_pMainWindow->viewCount() <= 2) // '1' can happen if this view is not yet in the map
|
|
|
|
{
|
|
|
|
KonqView * otherView = m_pMainWindow->otherView( this );
|
|
|
|
if (otherView)
|
|
|
|
otherView->setLinkedView( true );
|
|
|
|
}
|
2000-04-22 23:42:10 +00:00
|
|
|
}
|
2000-04-05 22:28:34 +00:00
|
|
|
}
|
1999-04-04 20:22:18 +00:00
|
|
|
}
|
1999-04-04 12:40:19 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
bool KonqView::changeViewMode( const QString &serviceType,
|
2000-07-02 14:42:11 +00:00
|
|
|
const QString &serviceName )
|
1999-04-04 20:22:18 +00:00
|
|
|
{
|
2000-07-02 11:41:01 +00:00
|
|
|
// Caller should call stop first.
|
|
|
|
assert ( !m_bLoading );
|
2000-04-09 23:02:05 +00:00
|
|
|
|
2000-05-13 19:41:52 +00:00
|
|
|
kdDebug(1202) << "changeViewMode: serviceType is " << serviceType
|
|
|
|
<< " serviceName is " << serviceName
|
2000-08-29 07:35:23 +00:00
|
|
|
<< " current service name is " << m_service->desktopEntryName() << endl;
|
2000-05-13 19:41:52 +00:00
|
|
|
|
1999-10-29 21:35:22 +00:00
|
|
|
if ( !m_service->serviceTypes().contains( serviceType ) ||
|
2000-08-29 07:35:23 +00:00
|
|
|
( !serviceName.isEmpty() && serviceName != m_service->desktopEntryName() ) )
|
1999-04-04 20:22:18 +00:00
|
|
|
{
|
1999-04-04 02:01:25 +00:00
|
|
|
|
2000-06-22 20:15:40 +00:00
|
|
|
if ( isLockedViewMode() )
|
2000-08-12 12:10:44 +00:00
|
|
|
{
|
|
|
|
kdDebug(1202) << "This view's mode is locked - can't change" << endl;
|
|
|
|
return false; // we can't do that if our view mode is locked
|
|
|
|
}
|
2000-06-18 20:15:08 +00:00
|
|
|
|
2000-06-22 22:13:27 +00:00
|
|
|
kdDebug(1202) << "Switching view modes..." << endl;
|
2000-03-27 14:05:13 +00:00
|
|
|
KTrader::OfferList partServiceOffers, appServiceOffers;
|
2000-03-19 02:16:17 +00:00
|
|
|
KService::Ptr service = 0L;
|
2000-03-27 14:05:13 +00:00
|
|
|
KonqViewFactory viewFactory = KonqFactory::createView( serviceType, serviceName, &service, &partServiceOffers, &appServiceOffers );
|
2000-01-16 14:05:27 +00:00
|
|
|
|
1999-12-18 23:00:06 +00:00
|
|
|
if ( viewFactory.isNull() )
|
2000-04-09 23:02:05 +00:00
|
|
|
{
|
|
|
|
// Revert location bar's URL to the working one
|
2000-09-26 16:52:16 +00:00
|
|
|
if(history().current())
|
|
|
|
setLocationBarURL( history().current()->locationBarURL );
|
1999-12-18 23:00:06 +00:00
|
|
|
return false;
|
2000-04-09 23:02:05 +00:00
|
|
|
}
|
2000-01-16 14:05:27 +00:00
|
|
|
|
1999-10-29 21:35:22 +00:00
|
|
|
m_service = service;
|
2000-03-27 14:05:13 +00:00
|
|
|
m_partServiceOffers = partServiceOffers;
|
|
|
|
m_appServiceOffers = appServiceOffers;
|
1999-10-29 21:35:22 +00:00
|
|
|
m_serviceType = serviceType;
|
|
|
|
|
2000-07-02 14:42:11 +00:00
|
|
|
switchView( viewFactory );
|
2000-05-24 22:22:38 +00:00
|
|
|
|
2000-07-14 21:54:29 +00:00
|
|
|
// Make the new part active. Note that we don't do it each time we
|
2000-05-24 22:22:38 +00:00
|
|
|
// open a URL (becomes awful in view-follows-view mode), but we do
|
|
|
|
// each time we change the view mode.
|
|
|
|
// We don't do it in switchView either because it's called from the constructor too,
|
|
|
|
// where the location bar url isn't set yet.
|
2000-07-23 00:59:21 +00:00
|
|
|
kdDebug(1202) << "Giving focus to new part " << m_pPart << endl;
|
2000-07-14 21:54:29 +00:00
|
|
|
m_pMainWindow->viewManager()->setActivePart( m_pPart );
|
1999-10-29 21:35:22 +00:00
|
|
|
}
|
2000-10-09 19:30:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_serviceType = serviceType;
|
|
|
|
kdDebug() << "KonqView::changeViewMode service type set to " << m_serviceType << endl;
|
|
|
|
// Re-query the trader
|
|
|
|
KonqFactory::getOffers( m_serviceType, &m_partServiceOffers, &m_appServiceOffers );
|
|
|
|
if ( m_pMainWindow->currentView() == this )
|
|
|
|
m_pMainWindow->updateViewModeActions();
|
|
|
|
}
|
1999-10-29 21:35:22 +00:00
|
|
|
return true;
|
1999-04-04 02:01:25 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::connectPart( )
|
1999-04-04 02:01:25 +00:00
|
|
|
{
|
2000-05-20 17:27:38 +00:00
|
|
|
//kdDebug(1202) << "KonqView::connectPart" << endl;
|
2000-05-20 13:37:31 +00:00
|
|
|
connect( m_pPart, SIGNAL( started( KIO::Job * ) ),
|
2000-02-19 23:54:11 +00:00
|
|
|
this, SLOT( slotStarted( KIO::Job * ) ) );
|
2000-05-20 13:37:31 +00:00
|
|
|
connect( m_pPart, SIGNAL( completed() ),
|
2000-01-20 01:51:19 +00:00
|
|
|
this, SLOT( slotCompleted() ) );
|
2001-01-10 21:00:55 +00:00
|
|
|
connect( m_pPart, SIGNAL( completed(bool) ),
|
|
|
|
this, SLOT( slotCompleted(bool) ) );
|
2001-05-09 17:58:32 +00:00
|
|
|
connect( m_pPart, SIGNAL( canceled( const QString & ) ),
|
2000-01-20 01:51:19 +00:00
|
|
|
this, SLOT( slotCanceled( const QString & ) ) );
|
2001-05-09 17:58:32 +00:00
|
|
|
connect( m_pPart, SIGNAL( setWindowCaption( const QString & ) ),
|
|
|
|
this, SLOT( setCaption( const QString & ) ) );
|
1999-10-17 15:31:19 +00:00
|
|
|
|
2000-01-17 20:55:27 +00:00
|
|
|
KParts::BrowserExtension *ext = browserExtension();
|
2000-01-16 14:05:27 +00:00
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
if ( !ext )
|
2000-01-16 14:05:27 +00:00
|
|
|
return;
|
|
|
|
|
2001-03-02 22:51:39 +00:00
|
|
|
ext->setBrowserInterface( m_browserIface );
|
|
|
|
|
2000-09-24 18:29:02 +00:00
|
|
|
connect( ext, SIGNAL( openURLRequestDelayed( const KURL &, const KParts::URLArgs &) ),
|
2000-06-18 12:03:29 +00:00
|
|
|
m_pMainWindow, SLOT( slotOpenURLRequest( const KURL &, const KParts::URLArgs & ) ) );
|
2000-01-16 14:05:27 +00:00
|
|
|
|
2001-05-16 19:36:01 +00:00
|
|
|
if ( m_bPopupMenuEnabled )
|
|
|
|
{
|
|
|
|
m_bPopupMenuEnabled = false; // force
|
|
|
|
enablePopupMenu( true );
|
|
|
|
}
|
2000-03-11 08:49:21 +00:00
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
connect( ext, SIGNAL( setLocationBarURL( const QString & ) ),
|
2000-04-09 23:02:05 +00:00
|
|
|
this, SLOT( setLocationBarURL( const QString & ) ) );
|
1999-10-17 15:31:19 +00:00
|
|
|
|
2000-12-12 23:45:29 +00:00
|
|
|
connect( ext, SIGNAL( setIconURL( const KURL & ) ),
|
|
|
|
this, SLOT( setIconURL( const KURL & ) ) );
|
|
|
|
|
2000-02-27 21:53:33 +00:00
|
|
|
connect( ext, SIGNAL( createNewWindow( const KURL &, const KParts::URLArgs & ) ),
|
2000-05-20 17:27:38 +00:00
|
|
|
m_pMainWindow, SLOT( slotCreateNewWindow( const KURL &, const KParts::URLArgs & ) ) );
|
1999-10-17 15:31:19 +00:00
|
|
|
|
2000-09-07 15:38:25 +00:00
|
|
|
connect( ext, SIGNAL( createNewWindow( const KURL &, const KParts::URLArgs &, const KParts::WindowArgs &, KParts::ReadOnlyPart *& ) ),
|
|
|
|
m_pMainWindow, SLOT( slotCreateNewWindow( const KURL &, const KParts::URLArgs &, const KParts::WindowArgs &, KParts::ReadOnlyPart *& ) ) );
|
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
connect( ext, SIGNAL( loadingProgress( int ) ),
|
2000-04-02 23:49:07 +00:00
|
|
|
m_pKonqFrame->statusbar(), SLOT( slotLoadingProgress( int ) ) );
|
1999-10-17 15:31:19 +00:00
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
connect( ext, SIGNAL( speedProgress( int ) ),
|
2000-04-02 23:49:07 +00:00
|
|
|
m_pKonqFrame->statusbar(), SLOT( slotSpeedProgress( int ) ) );
|
1999-10-17 15:31:19 +00:00
|
|
|
|
2000-05-31 10:12:55 +00:00
|
|
|
connect( ext, SIGNAL( infoMessage( const QString & ) ),
|
2000-07-23 00:59:21 +00:00
|
|
|
m_pKonqFrame->statusbar(), SLOT( message( const QString & ) ) );
|
2000-06-03 13:26:49 +00:00
|
|
|
|
2000-04-10 15:59:25 +00:00
|
|
|
connect( ext, SIGNAL( selectionInfo( const KFileItemList & ) ),
|
2000-07-23 00:59:21 +00:00
|
|
|
this, SLOT( slotSelectionInfo( const KFileItemList & ) ) );
|
2000-03-30 10:05:32 +00:00
|
|
|
|
2000-03-30 09:31:47 +00:00
|
|
|
connect( ext, SIGNAL( openURLNotify() ),
|
2000-07-23 00:59:21 +00:00
|
|
|
this, SLOT( slotOpenURLNotify() ) );
|
2000-11-05 01:30:07 +00:00
|
|
|
|
2000-12-08 21:36:09 +00:00
|
|
|
connect( ext, SIGNAL( enableAction( const char *, bool ) ),
|
|
|
|
this, SLOT( slotEnableAction( const char *, bool ) ) );
|
|
|
|
|
2000-11-05 01:30:07 +00:00
|
|
|
callExtensionBoolMethod( "setSaveViewPropertiesLocally(bool)", m_pMainWindow->saveViewPropertiesLocally() );
|
|
|
|
|
2000-11-26 00:56:16 +00:00
|
|
|
QVariant urlDropHandling;
|
|
|
|
|
|
|
|
if ( browserExtension() )
|
|
|
|
urlDropHandling = browserExtension()->property( "urlDropHandling" );
|
|
|
|
else
|
|
|
|
urlDropHandling = QVariant( true, 0 );
|
|
|
|
|
|
|
|
// install the event filter when
|
|
|
|
// a) either the property says "ok"
|
|
|
|
// or
|
|
|
|
// b) the part is a plain krop (no BE)
|
|
|
|
if ( urlDropHandling.type() == QVariant::Bool &&
|
|
|
|
urlDropHandling.toBool() )
|
|
|
|
m_pPart->widget()->installEventFilter( this );
|
2001-01-12 20:12:07 +00:00
|
|
|
|
|
|
|
// KonqDirPart signal
|
|
|
|
if ( m_pPart->inherits("KonqDirPart") )
|
|
|
|
{
|
|
|
|
connect( m_pPart, SIGNAL( findOpen( KonqDirPart * ) ),
|
|
|
|
m_pMainWindow, SLOT( slotFindOpen( KonqDirPart * ) ) );
|
|
|
|
}
|
1999-04-04 02:01:25 +00:00
|
|
|
}
|
|
|
|
|
2000-12-08 21:36:09 +00:00
|
|
|
void KonqView::slotEnableAction( const char * name, bool enabled )
|
|
|
|
{
|
2000-12-10 23:07:56 +00:00
|
|
|
if ( m_pMainWindow->currentView() == this )
|
|
|
|
m_pMainWindow->enableAction( name, enabled );
|
|
|
|
// Otherwise, we don't have to do anything, the state of the action is
|
|
|
|
// stored inside the browser-extension.
|
2000-12-08 21:36:09 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::slotStarted( KIO::Job * job )
|
2000-01-20 01:51:19 +00:00
|
|
|
{
|
2000-05-20 17:27:38 +00:00
|
|
|
//kdDebug(1202) << "KonqView::slotStarted" << job << endl;
|
2000-01-20 01:51:19 +00:00
|
|
|
m_bLoading = true;
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
if ( m_pMainWindow->currentView() == this )
|
|
|
|
m_pMainWindow->updateToolBarActions();
|
2000-01-20 01:51:19 +00:00
|
|
|
|
2000-02-19 23:54:11 +00:00
|
|
|
if (job)
|
2000-01-20 01:51:19 +00:00
|
|
|
{
|
2000-04-04 00:34:10 +00:00
|
|
|
connect( job, SIGNAL( percent( KIO::Job *, unsigned long ) ), this, SLOT( slotPercent( KIO::Job *, unsigned long ) ) );
|
2000-04-02 23:00:05 +00:00
|
|
|
connect( job, SIGNAL( speed( KIO::Job *, unsigned long ) ), this, SLOT( slotSpeed( KIO::Job *, unsigned long ) ) );
|
2000-05-30 09:17:18 +00:00
|
|
|
connect( job, SIGNAL( infoMessage( KIO::Job *, const QString & ) ), this, SLOT( slotInfoMessage( KIO::Job *, const QString & ) ) );
|
2000-01-20 01:51:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::slotPercent( KIO::Job *, unsigned long percent )
|
2000-01-20 01:51:19 +00:00
|
|
|
{
|
2000-04-04 00:34:10 +00:00
|
|
|
m_pKonqFrame->statusbar()->slotLoadingProgress( percent );
|
2000-01-20 01:51:19 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::slotSpeed( KIO::Job *, unsigned long bytesPerSecond )
|
2000-01-20 01:51:19 +00:00
|
|
|
{
|
2000-04-02 23:49:07 +00:00
|
|
|
m_pKonqFrame->statusbar()->slotSpeedProgress( bytesPerSecond );
|
2000-01-20 01:51:19 +00:00
|
|
|
}
|
|
|
|
|
2000-05-30 09:17:18 +00:00
|
|
|
void KonqView::slotInfoMessage( KIO::Job *, const QString &msg )
|
|
|
|
{
|
2000-05-31 10:12:55 +00:00
|
|
|
m_pKonqFrame->statusbar()->message( msg );
|
|
|
|
}
|
2000-05-30 09:17:18 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::slotCompleted()
|
2001-01-10 21:00:55 +00:00
|
|
|
{
|
2001-01-11 17:22:53 +00:00
|
|
|
slotCompleted( false );
|
2001-01-10 21:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KonqView::slotCompleted( bool hasPending )
|
2000-01-20 01:51:19 +00:00
|
|
|
{
|
2000-07-28 22:25:36 +00:00
|
|
|
kdDebug(1202) << "KonqView::slotCompleted" << endl;
|
2000-01-20 01:51:19 +00:00
|
|
|
m_bLoading = false;
|
2000-04-02 23:49:07 +00:00
|
|
|
m_pKonqFrame->statusbar()->slotLoadingProgress( -1 );
|
2000-01-20 01:51:19 +00:00
|
|
|
|
2000-12-02 15:17:15 +00:00
|
|
|
if ( m_pMainWindow->currentView() == this )
|
2001-01-10 21:00:55 +00:00
|
|
|
m_pMainWindow->updateToolBarActions( hasPending );
|
2000-12-02 15:17:15 +00:00
|
|
|
|
|
|
|
if ( ! m_bLockHistory )
|
|
|
|
{
|
|
|
|
// Success... update history entry (mostly for location bar URL)
|
|
|
|
updateHistoryEntry(true);
|
2000-04-12 21:06:41 +00:00
|
|
|
|
2000-12-02 15:17:15 +00:00
|
|
|
if ( m_bAborted ) // remove the pending entry on error
|
2001-01-11 17:22:53 +00:00
|
|
|
KonqHistoryManager::kself()->removePending( url() );
|
2000-12-02 15:17:15 +00:00
|
|
|
else // register as proper history entry
|
2001-01-11 17:22:53 +00:00
|
|
|
KonqHistoryManager::kself()->confirmPending(url(), typedURL(),
|
|
|
|
m_lstHistory.current()->title);
|
2000-11-25 17:06:48 +00:00
|
|
|
|
2000-12-02 15:17:15 +00:00
|
|
|
emit viewCompleted( this );
|
|
|
|
}
|
2001-01-10 21:00:55 +00:00
|
|
|
m_bLoading = hasPending;
|
2001-03-31 07:44:58 +00:00
|
|
|
|
|
|
|
if (!m_bGotIconURL)
|
|
|
|
{
|
|
|
|
KConfig *config = KGlobal::config();
|
|
|
|
config->setGroup( "HTML Settings" );
|
|
|
|
|
|
|
|
if ( config->readBoolEntry( "EnableFavicon", true ) == true )
|
|
|
|
{
|
|
|
|
// Try to get /favicon.ico
|
|
|
|
if ( m_serviceType == "text/html" && url().protocol().left(4) == "http" )
|
|
|
|
KonqPixmapProvider::self()->downloadHostIcon( url() );
|
|
|
|
}
|
|
|
|
}
|
2000-01-20 01:51:19 +00:00
|
|
|
}
|
|
|
|
|
2000-07-21 13:26:33 +00:00
|
|
|
void KonqView::slotCanceled( const QString & errorMsg )
|
2000-01-20 01:51:19 +00:00
|
|
|
{
|
2000-08-10 10:32:42 +00:00
|
|
|
kdDebug(1202) << "KonqView::slotCanceled" << endl;
|
2000-07-21 13:26:33 +00:00
|
|
|
// The errorMsg comes from the ReadOnlyPart's job.
|
|
|
|
// It should probably be used in a KMessageBox
|
|
|
|
// Let's use the statusbar for now
|
|
|
|
m_pKonqFrame->statusbar()->message( errorMsg );
|
2000-05-07 12:30:25 +00:00
|
|
|
m_bAborted = true;
|
2000-11-25 17:06:48 +00:00
|
|
|
slotCompleted();
|
2000-01-20 01:51:19 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::slotSelectionInfo( const KFileItemList &items )
|
2000-04-10 01:25:09 +00:00
|
|
|
{
|
2000-05-20 13:37:31 +00:00
|
|
|
KonqFileSelectionEvent ev( items, m_pPart );
|
2000-05-20 17:27:38 +00:00
|
|
|
QApplication::sendEvent( m_pMainWindow, &ev );
|
2000-04-10 01:25:09 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::setLocationBarURL( const QString & locationBarURL )
|
2000-04-09 23:02:05 +00:00
|
|
|
{
|
2000-07-14 21:54:29 +00:00
|
|
|
//kdDebug(1202) << "KonqView::setLocationBarURL " << locationBarURL << " this=" << this << endl;
|
2000-04-09 23:02:05 +00:00
|
|
|
m_sLocationBarURL = locationBarURL;
|
2000-05-20 17:27:38 +00:00
|
|
|
if ( m_pMainWindow->currentView() == this )
|
2000-04-09 23:02:05 +00:00
|
|
|
{
|
2000-07-14 21:54:29 +00:00
|
|
|
//kdDebug(1202) << "is current view " << this << endl;
|
2000-05-20 17:27:38 +00:00
|
|
|
m_pMainWindow->setLocationBarURL( m_sLocationBarURL );
|
2000-04-09 23:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-12 23:45:29 +00:00
|
|
|
void KonqView::setIconURL( const KURL & iconURL )
|
|
|
|
{
|
2001-01-09 18:44:49 +00:00
|
|
|
KonqPixmapProvider::self()->setIconForURL( m_sLocationBarURL, iconURL );
|
2001-03-31 07:44:58 +00:00
|
|
|
m_bGotIconURL = true;
|
2000-12-12 23:45:29 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::slotOpenURLNotify()
|
2000-04-13 14:53:03 +00:00
|
|
|
{
|
2000-07-14 21:54:29 +00:00
|
|
|
updateHistoryEntry(true);
|
2000-10-06 20:24:00 +00:00
|
|
|
createHistoryEntry();
|
|
|
|
if ( m_pMainWindow->currentView() == this )
|
|
|
|
m_pMainWindow->updateToolBarActions();
|
2000-04-13 14:53:03 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::createHistoryEntry()
|
1999-04-04 15:47:38 +00:00
|
|
|
{
|
2000-03-19 20:31:43 +00:00
|
|
|
// First, remove any forward history
|
|
|
|
HistoryEntry * current = m_lstHistory.current();
|
|
|
|
if (current)
|
1999-04-04 15:47:38 +00:00
|
|
|
{
|
2000-05-13 20:44:19 +00:00
|
|
|
//kdDebug(1202) << "Truncating history" << endl;
|
2000-03-19 20:31:43 +00:00
|
|
|
m_lstHistory.at( m_lstHistory.count() - 1 ); // go to last one
|
|
|
|
for ( ; m_lstHistory.current() != current ; )
|
|
|
|
{
|
|
|
|
if ( !m_lstHistory.removeLast() ) // and remove from the end (faster and easier)
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
// Now current is the current again.
|
1999-04-04 15:47:38 +00:00
|
|
|
}
|
2000-03-19 20:31:43 +00:00
|
|
|
// Append a new entry
|
2000-04-22 23:42:10 +00:00
|
|
|
//kdDebug(1202) << "Append a new entry" << endl;
|
2000-03-19 20:31:43 +00:00
|
|
|
m_lstHistory.append( new HistoryEntry ); // made current
|
2000-05-13 20:44:19 +00:00
|
|
|
//kdDebug(1202) << "at=" << m_lstHistory.at() << " count=" << m_lstHistory.count() << endl;
|
|
|
|
assert( m_lstHistory.at() == (int) m_lstHistory.count() - 1 );
|
2000-03-19 20:31:43 +00:00
|
|
|
}
|
2000-03-13 02:30:02 +00:00
|
|
|
|
2000-07-14 21:54:29 +00:00
|
|
|
void KonqView::updateHistoryEntry( bool saveLocationBarURL )
|
2000-03-19 20:31:43 +00:00
|
|
|
{
|
2000-04-13 14:53:03 +00:00
|
|
|
ASSERT( !m_bLockHistory ); // should never happen
|
2000-04-14 23:12:39 +00:00
|
|
|
|
2000-03-13 02:30:02 +00:00
|
|
|
HistoryEntry * current = m_lstHistory.current();
|
|
|
|
assert( current ); // let's see if this happens
|
|
|
|
if ( current == 0L) // empty history
|
|
|
|
{
|
2000-05-13 20:44:19 +00:00
|
|
|
kdWarning(1202) << "Creating item because history is empty !" << endl;
|
2000-03-13 02:30:02 +00:00
|
|
|
current = new HistoryEntry;
|
|
|
|
m_lstHistory.append( current );
|
|
|
|
}
|
1999-07-03 14:09:28 +00:00
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
if ( browserExtension() )
|
2000-01-16 14:05:27 +00:00
|
|
|
{
|
2000-03-13 02:30:02 +00:00
|
|
|
QDataStream stream( current->buffer, IO_WriteOnly );
|
1999-10-26 17:49:55 +00:00
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
browserExtension()->saveState( stream );
|
2000-01-16 14:05:27 +00:00
|
|
|
}
|
1999-10-26 17:49:55 +00:00
|
|
|
|
2000-07-14 21:54:29 +00:00
|
|
|
//kdDebug(1202) << "Saving part URL : " << m_pPart->url().url() << " in history position " << m_lstHistory.at() << endl;
|
2000-05-20 13:37:31 +00:00
|
|
|
current->url = m_pPart->url();
|
2000-07-14 21:54:29 +00:00
|
|
|
|
|
|
|
if (saveLocationBarURL)
|
|
|
|
{
|
|
|
|
//kdDebug(1202) << "Saving location bar URL : " << m_sLocationBarURL << " in history position " << m_lstHistory.at() << endl;
|
|
|
|
current->locationBarURL = m_sLocationBarURL;
|
|
|
|
}
|
2001-01-11 22:38:58 +00:00
|
|
|
//kdDebug(1202) << "Saving title : " << m_caption << " in history position " << m_lstHistory.at() << endl;
|
|
|
|
current->title = m_caption;
|
2000-03-13 02:30:02 +00:00
|
|
|
current->strServiceType = m_serviceType;
|
2000-08-29 07:35:23 +00:00
|
|
|
current->strServiceName = m_service->desktopEntryName();
|
1999-04-04 20:22:18 +00:00
|
|
|
}
|
|
|
|
|
2001-03-01 21:55:50 +00:00
|
|
|
void KonqView::goHistory( int steps )
|
|
|
|
{
|
2001-03-05 17:00:23 +00:00
|
|
|
// This is called by KonqBrowserInterface
|
2001-03-01 21:55:50 +00:00
|
|
|
if ( m_pMainWindow->currentView() == this )
|
|
|
|
m_pMainWindow->viewManager()->setActivePart( part() );
|
|
|
|
|
|
|
|
// Delay the go() call (we need to return to the caller first)
|
|
|
|
m_pMainWindow->slotGoHistoryActivated( steps );
|
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::go( int steps )
|
1999-04-04 20:22:18 +00:00
|
|
|
{
|
2001-03-01 20:22:26 +00:00
|
|
|
if ( !steps ) // [WildFox] i bet there are sites on the net with stupid devs who do that :)
|
|
|
|
return;
|
|
|
|
|
2000-07-02 11:41:01 +00:00
|
|
|
stop();
|
2000-04-05 22:02:57 +00:00
|
|
|
|
2000-03-13 02:30:02 +00:00
|
|
|
int newPos = m_lstHistory.at() + steps;
|
2000-07-14 21:54:29 +00:00
|
|
|
/*kdDebug(1202) << "go : steps=" << steps
|
2000-05-13 20:44:19 +00:00
|
|
|
<< " newPos=" << newPos
|
|
|
|
<< " m_lstHistory.count()=" << m_lstHistory.count()
|
2000-07-14 21:54:29 +00:00
|
|
|
<< endl; */
|
2001-03-01 20:22:26 +00:00
|
|
|
if( newPos < 0 || (uint)newPos >= m_lstHistory.count() )
|
|
|
|
return;
|
|
|
|
|
2000-03-13 02:30:02 +00:00
|
|
|
// Yay, we can move there without a loop !
|
2000-04-14 23:12:39 +00:00
|
|
|
HistoryEntry *currentHistoryEntry = m_lstHistory.at( newPos ); // sets current item
|
2000-03-19 16:32:52 +00:00
|
|
|
|
2000-04-14 23:12:39 +00:00
|
|
|
assert( currentHistoryEntry );
|
2000-03-13 02:30:02 +00:00
|
|
|
assert( newPos == m_lstHistory.at() ); // check we moved (i.e. if I understood the docu)
|
2000-04-14 23:12:39 +00:00
|
|
|
assert( currentHistoryEntry == m_lstHistory.current() );
|
2000-04-24 17:53:09 +00:00
|
|
|
//kdDebug(1202) << "New position " << m_lstHistory.at() << endl;
|
2000-02-19 23:29:44 +00:00
|
|
|
|
2000-04-14 23:12:39 +00:00
|
|
|
HistoryEntry h( *currentHistoryEntry ); // make a copy of the current history entry, as the data
|
|
|
|
// the pointer points to will change with the following calls
|
2000-04-16 23:43:46 +00:00
|
|
|
|
2000-04-24 17:53:09 +00:00
|
|
|
//kdDebug(1202) << "Restoring servicetype/name, and location bar URL from history : " << h.locationBarURL << endl;
|
2000-07-02 11:41:01 +00:00
|
|
|
setLocationBarURL( h.locationBarURL );
|
|
|
|
m_sTypedURL = QString::null;
|
2000-07-02 14:42:11 +00:00
|
|
|
if ( ! changeViewMode( h.strServiceType, h.strServiceName ) )
|
1999-10-29 21:35:22 +00:00
|
|
|
{
|
2000-04-14 23:12:39 +00:00
|
|
|
kdWarning(1202) << "Couldn't change view mode to " << h.strServiceType
|
|
|
|
<< " " << h.strServiceName << endl;
|
2000-04-05 22:02:57 +00:00
|
|
|
return /*false*/;
|
1999-11-28 03:26:15 +00:00
|
|
|
}
|
1999-10-29 21:35:22 +00:00
|
|
|
|
2000-04-12 08:39:25 +00:00
|
|
|
setServiceTypeInExtension();
|
2000-04-12 21:06:41 +00:00
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
if ( browserExtension() )
|
2000-01-16 14:05:27 +00:00
|
|
|
{
|
2000-07-14 21:54:29 +00:00
|
|
|
//kdDebug(1202) << "Restoring view from stream" << endl;
|
2000-04-14 23:12:39 +00:00
|
|
|
QDataStream stream( h.buffer, IO_ReadOnly );
|
2000-01-16 14:05:27 +00:00
|
|
|
|
2000-01-16 22:49:55 +00:00
|
|
|
browserExtension()->restoreState( stream );
|
2000-01-16 14:05:27 +00:00
|
|
|
}
|
|
|
|
else
|
2000-05-20 13:37:31 +00:00
|
|
|
m_pPart->openURL( h.url );
|
1999-10-31 12:53:14 +00:00
|
|
|
|
2000-06-12 22:24:43 +00:00
|
|
|
//m_bAborted = false; // should we do that ?
|
|
|
|
|
2000-04-14 23:12:39 +00:00
|
|
|
sendOpenURLEvent( h.url );
|
2000-01-23 18:55:33 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
if ( m_pMainWindow->currentView() == this )
|
|
|
|
m_pMainWindow->updateToolBarActions();
|
1999-04-04 20:22:18 +00:00
|
|
|
|
2000-04-24 17:53:09 +00:00
|
|
|
//kdDebug(1202) << "New position (2) " << m_lstHistory.at() << endl;
|
1999-04-04 20:22:18 +00:00
|
|
|
}
|
|
|
|
|
2000-10-20 07:59:55 +00:00
|
|
|
void KonqView::copyHistory( KonqView *other )
|
|
|
|
{
|
|
|
|
m_lstHistory.clear();
|
|
|
|
|
|
|
|
QListIterator<HistoryEntry> it( other->m_lstHistory );
|
|
|
|
for (; it.current(); ++it )
|
|
|
|
m_lstHistory.append( new HistoryEntry( *it.current() ) );
|
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
KURL KonqView::url()
|
1999-04-05 13:32:21 +00:00
|
|
|
{
|
2000-05-20 13:37:31 +00:00
|
|
|
assert( m_pPart );
|
|
|
|
return m_pPart->url();
|
1999-10-17 15:31:19 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::setRun( KonqRun * run )
|
1999-10-17 15:31:19 +00:00
|
|
|
{
|
2001-01-07 00:01:04 +00:00
|
|
|
if ( m_pRun )
|
|
|
|
delete m_pRun;
|
2000-02-23 21:05:24 +00:00
|
|
|
m_pRun = run;
|
1999-10-17 15:31:19 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::stop()
|
1999-10-17 15:31:19 +00:00
|
|
|
{
|
2000-07-02 11:41:01 +00:00
|
|
|
kdDebug(1202) << "KonqView::stop()" << endl;
|
2000-05-07 12:30:25 +00:00
|
|
|
m_bAborted = false;
|
2000-04-16 23:43:46 +00:00
|
|
|
if ( m_bLoading )
|
1999-11-18 20:34:02 +00:00
|
|
|
{
|
2000-11-25 17:06:48 +00:00
|
|
|
// aborted -> confirm the pending url. We might as well remove it, but
|
|
|
|
// we decided to keep it :)
|
2001-01-11 17:22:53 +00:00
|
|
|
KonqHistoryManager::kself()->confirmPending( url(), m_sTypedURL );
|
2000-11-25 17:06:48 +00:00
|
|
|
|
2000-08-10 10:32:42 +00:00
|
|
|
//kdDebug(1202) << "m_pPart->closeURL()" << endl;
|
2000-05-20 13:37:31 +00:00
|
|
|
m_pPart->closeURL();
|
2000-05-07 12:30:25 +00:00
|
|
|
m_bAborted = true;
|
2000-07-02 11:41:01 +00:00
|
|
|
m_pKonqFrame->statusbar()->slotLoadingProgress( -1 );
|
|
|
|
m_bLoading = false;
|
1999-11-18 20:34:02 +00:00
|
|
|
}
|
2000-07-14 21:54:29 +00:00
|
|
|
if ( m_pRun )
|
2000-07-02 11:41:01 +00:00
|
|
|
{
|
2000-07-14 21:54:29 +00:00
|
|
|
// Revert to working URL - unless the URL was typed manually
|
|
|
|
// This is duplicated with KonqMainWindow::slotRunFinished, but we can't call it
|
|
|
|
// since it relies on sender()...
|
2001-01-06 23:12:24 +00:00
|
|
|
if ( history().current() && m_pRun->typedURL().isEmpty() ) // not typed
|
2000-07-14 21:54:29 +00:00
|
|
|
setLocationBarURL( history().current()->locationBarURL );
|
|
|
|
|
2000-04-09 23:02:05 +00:00
|
|
|
delete static_cast<KonqRun *>(m_pRun); // should set m_pRun to 0L
|
2000-07-02 11:41:01 +00:00
|
|
|
m_pKonqFrame->statusbar()->slotLoadingProgress( -1 );
|
|
|
|
}
|
|
|
|
if ( !m_bLockHistory && m_lstHistory.count() > 0 )
|
2000-07-14 21:54:29 +00:00
|
|
|
updateHistoryEntry(true);
|
1999-04-05 13:32:21 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::setPassiveMode( bool mode )
|
1999-10-31 17:42:40 +00:00
|
|
|
{
|
2000-07-13 19:48:39 +00:00
|
|
|
// In theory, if m_bPassiveMode is true and mode is false,
|
|
|
|
// the part should be removed from the part manager,
|
|
|
|
// and if the other way round, it should be readded to the part manager...
|
1999-10-31 17:42:40 +00:00
|
|
|
m_bPassiveMode = mode;
|
1999-11-14 10:24:11 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
if ( mode && m_pMainWindow->viewCount() > 1 && m_pMainWindow->currentView() == this )
|
2000-07-23 00:59:21 +00:00
|
|
|
{
|
|
|
|
KParts::Part * part = m_pMainWindow->viewManager()->chooseNextView( this )->part(); // switch active part
|
|
|
|
m_pMainWindow->viewManager()->setActivePart( part );
|
|
|
|
}
|
1999-11-29 15:14:27 +00:00
|
|
|
|
2000-05-13 23:44:59 +00:00
|
|
|
// Update statusbar stuff
|
2000-05-20 17:27:38 +00:00
|
|
|
m_pMainWindow->viewManager()->viewCountChanged();
|
2000-04-16 23:43:46 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::setLinkedView( bool mode )
|
2000-04-16 23:43:46 +00:00
|
|
|
{
|
|
|
|
m_bLinkedView = mode;
|
2000-06-22 20:15:40 +00:00
|
|
|
if ( m_pMainWindow->currentView() == this )
|
|
|
|
m_pMainWindow->linkViewAction()->setChecked( mode );
|
2000-04-16 23:51:47 +00:00
|
|
|
frame()->statusbar()->setLinkedView( mode );
|
1999-10-31 17:42:40 +00:00
|
|
|
}
|
1999-11-28 03:26:15 +00:00
|
|
|
|
2000-12-13 00:20:09 +00:00
|
|
|
void KonqView::setLockedLocation( bool b )
|
|
|
|
{
|
2001-01-14 20:35:25 +00:00
|
|
|
m_bLockedLocation = b;
|
2000-12-13 00:20:09 +00:00
|
|
|
}
|
|
|
|
|
2000-05-31 10:12:55 +00:00
|
|
|
void KonqView::sendOpenURLEvent( const KURL &url, const KParts::URLArgs &args )
|
2000-01-21 14:12:51 +00:00
|
|
|
{
|
2000-05-31 10:12:55 +00:00
|
|
|
KParts::OpenURLEvent ev( m_pPart, url, args );
|
2000-05-20 17:27:38 +00:00
|
|
|
QApplication::sendEvent( m_pMainWindow, &ev );
|
2000-06-12 22:24:43 +00:00
|
|
|
|
|
|
|
// We also do here what we want to do after opening an URL, whether a new one
|
|
|
|
// or one from the history (common stuff).
|
2001-03-31 07:44:58 +00:00
|
|
|
m_bGotIconURL = false;
|
2000-03-19 16:32:52 +00:00
|
|
|
}
|
2000-04-12 08:39:25 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
void KonqView::setServiceTypeInExtension()
|
2000-03-19 16:32:52 +00:00
|
|
|
{
|
2000-04-12 21:06:41 +00:00
|
|
|
KParts::BrowserExtension *ext = browserExtension();
|
2000-04-12 08:39:25 +00:00
|
|
|
if ( !ext )
|
|
|
|
return;
|
2000-04-12 21:06:41 +00:00
|
|
|
|
2000-04-12 08:39:25 +00:00
|
|
|
KParts::URLArgs args( ext->urlArgs() );
|
|
|
|
args.serviceType = m_serviceType;
|
|
|
|
ext->setURLArgs( args );
|
2000-04-12 21:06:41 +00:00
|
|
|
}
|
2000-04-12 08:39:25 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
QStringList KonqView::frameNames() const
|
2000-04-19 13:18:59 +00:00
|
|
|
{
|
2000-05-20 13:37:31 +00:00
|
|
|
return childFrameNames( m_pPart );
|
2000-04-21 19:34:42 +00:00
|
|
|
}
|
2000-04-19 13:18:59 +00:00
|
|
|
|
2000-05-20 17:27:38 +00:00
|
|
|
QStringList KonqView::childFrameNames( KParts::ReadOnlyPart *part )
|
2000-04-19 13:18:59 +00:00
|
|
|
{
|
|
|
|
QStringList res;
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-10-22 20:05:06 +00:00
|
|
|
KParts::BrowserHostExtension *hostExtension = KParts::BrowserHostExtension::childObject( part );
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-04-19 13:18:59 +00:00
|
|
|
if ( !hostExtension )
|
|
|
|
return res;
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-04-19 13:18:59 +00:00
|
|
|
res += hostExtension->frameNames();
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-04-19 13:18:59 +00:00
|
|
|
const QList<KParts::ReadOnlyPart> children = hostExtension->frames();
|
|
|
|
QListIterator<KParts::ReadOnlyPart> it( children );
|
|
|
|
for (; it.current(); ++it )
|
|
|
|
res += childFrameNames( it.current() );
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-04-19 13:18:59 +00:00
|
|
|
return res;
|
2000-04-21 19:34:42 +00:00
|
|
|
}
|
2000-04-19 13:18:59 +00:00
|
|
|
|
2000-07-02 11:41:01 +00:00
|
|
|
KParts::BrowserHostExtension* KonqView::hostExtension( KParts::ReadOnlyPart *part, const QString &name )
|
2000-04-19 13:18:59 +00:00
|
|
|
{
|
2000-10-22 20:05:06 +00:00
|
|
|
KParts::BrowserHostExtension *ext = KParts::BrowserHostExtension::childObject( part );
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-04-19 13:18:59 +00:00
|
|
|
if ( !ext )
|
|
|
|
return 0;
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-04-19 13:18:59 +00:00
|
|
|
if ( ext->frameNames().contains( name ) )
|
|
|
|
return ext;
|
2000-04-21 19:34:42 +00:00
|
|
|
|
2000-04-19 13:18:59 +00:00
|
|
|
const QList<KParts::ReadOnlyPart> children = ext->frames();
|
|
|
|
QListIterator<KParts::ReadOnlyPart> it( children );
|
|
|
|
for (; it.current(); ++it )
|
|
|
|
{
|
|
|
|
KParts::BrowserHostExtension *childHost = hostExtension( it.current(), name );
|
|
|
|
if ( childHost )
|
|
|
|
return childHost;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-11-28 14:20:49 +00:00
|
|
|
bool KonqView::callExtensionMethod( const char *methodName )
|
2000-05-10 13:23:48 +00:00
|
|
|
{
|
2000-10-22 20:05:06 +00:00
|
|
|
QObject *obj = KParts::BrowserExtension::childObject( m_pPart );
|
2000-05-10 13:23:48 +00:00
|
|
|
// assert(obj); Hmm, not all views have a browser extension !
|
|
|
|
if ( !obj )
|
2000-11-28 14:20:49 +00:00
|
|
|
return false;
|
2000-05-10 13:23:48 +00:00
|
|
|
|
|
|
|
QMetaData * mdata = obj->metaObject()->slot( methodName );
|
|
|
|
if( mdata )
|
2000-11-28 14:20:49 +00:00
|
|
|
{
|
2000-05-10 13:23:48 +00:00
|
|
|
(obj->*(mdata->ptr))();
|
2000-11-28 14:20:49 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
return false;
|
2000-05-10 13:23:48 +00:00
|
|
|
}
|
|
|
|
|
2000-11-28 14:20:49 +00:00
|
|
|
bool KonqView::callExtensionBoolMethod( const char *methodName, bool value )
|
2000-05-10 13:23:48 +00:00
|
|
|
{
|
2000-10-22 20:05:06 +00:00
|
|
|
QObject *obj = KParts::BrowserExtension::childObject( m_pPart );
|
2000-05-10 13:23:48 +00:00
|
|
|
// assert(obj); Hmm, not all views have a browser extension !
|
|
|
|
if ( !obj )
|
2000-11-28 14:20:49 +00:00
|
|
|
return false;
|
2000-05-10 13:23:48 +00:00
|
|
|
|
|
|
|
typedef void (QObject::*BoolMethod)(bool);
|
|
|
|
QMetaData * mdata = obj->metaObject()->slot( methodName );
|
|
|
|
if( mdata )
|
2000-11-28 14:20:49 +00:00
|
|
|
{
|
2000-05-10 13:23:48 +00:00
|
|
|
(obj->*((BoolMethod)mdata->ptr))(value);
|
2000-11-28 14:20:49 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
return false;
|
2000-05-13 19:41:52 +00:00
|
|
|
}
|
2000-05-10 13:23:48 +00:00
|
|
|
|
2000-11-28 14:20:49 +00:00
|
|
|
bool KonqView::callExtensionStringMethod( const char *methodName, QString value )
|
2000-07-02 11:41:01 +00:00
|
|
|
{
|
2000-10-22 20:05:06 +00:00
|
|
|
QObject *obj = KParts::BrowserExtension::childObject( m_pPart );
|
2000-07-02 11:41:01 +00:00
|
|
|
// assert(obj); Hmm, not all views have a browser extension !
|
|
|
|
if ( !obj )
|
2000-11-28 14:20:49 +00:00
|
|
|
return false;
|
2000-07-02 11:41:01 +00:00
|
|
|
|
2000-07-13 17:45:06 +00:00
|
|
|
//kdDebug(1202) << "KonqView::callExtensionStringMethod " << methodName << endl;
|
2000-07-02 11:41:01 +00:00
|
|
|
typedef void (QObject::*StringMethod)(QString);
|
|
|
|
QMetaData * mdata = obj->metaObject()->slot( methodName );
|
|
|
|
if( mdata )
|
|
|
|
{
|
|
|
|
(obj->*((StringMethod)mdata->ptr))(value);
|
2000-11-28 14:20:49 +00:00
|
|
|
return true;
|
2000-07-13 17:45:06 +00:00
|
|
|
//kdDebug(1202) << "Call done" << endl;
|
2000-11-28 14:20:49 +00:00
|
|
|
};
|
|
|
|
return false;
|
2000-07-02 11:41:01 +00:00
|
|
|
}
|
|
|
|
|
2000-10-15 16:09:09 +00:00
|
|
|
void KonqView::setViewName( const QString &name )
|
|
|
|
{
|
|
|
|
m_name = name;
|
|
|
|
if ( m_pPart )
|
|
|
|
m_pPart->setName( m_name.local8Bit().data() );
|
|
|
|
}
|
|
|
|
|
2001-05-15 16:04:39 +00:00
|
|
|
void KonqView::enablePopupMenu( bool b )
|
|
|
|
{
|
|
|
|
ASSERT( m_pMainWindow );
|
|
|
|
|
|
|
|
KParts::BrowserExtension *ext = browserExtension();
|
|
|
|
|
|
|
|
if ( !ext )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// enable context popup
|
|
|
|
if ( !m_bPopupMenuEnabled && b ) {
|
|
|
|
m_bPopupMenuEnabled = true;
|
|
|
|
|
|
|
|
connect( ext, SIGNAL( popupMenu( const QPoint &, const KFileItemList & ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( const QPoint &, const KFileItemList & ) ) );
|
|
|
|
|
|
|
|
connect( ext, SIGNAL( popupMenu( const QPoint &, const KURL &, const QString &, mode_t ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( const QPoint &, const KURL &, const QString &, mode_t ) ) );
|
|
|
|
|
|
|
|
connect( ext, SIGNAL( popupMenu( KXMLGUIClient *, const QPoint &, const KFileItemList & ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( KXMLGUIClient *, const QPoint &, const KFileItemList & ) ) );
|
|
|
|
|
|
|
|
connect( ext, SIGNAL( popupMenu( KXMLGUIClient *, const QPoint &, const KURL &, const QString &, mode_t ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( KXMLGUIClient *, const QPoint &, const KURL &, const QString &, mode_t ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// disable context popup
|
|
|
|
if ( m_bPopupMenuEnabled && !b ) {
|
|
|
|
m_bPopupMenuEnabled = false;
|
|
|
|
|
|
|
|
disconnect( ext, SIGNAL( popupMenu( const QPoint &, const KFileItemList & ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( const QPoint &, const KFileItemList & ) ) );
|
|
|
|
|
|
|
|
disconnect( ext, SIGNAL( popupMenu( const QPoint &, const KURL &, const QString &, mode_t ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( const QPoint &, const KURL &, const QString &, mode_t ) ) );
|
|
|
|
|
|
|
|
disconnect( ext, SIGNAL( popupMenu( KXMLGUIClient *, const QPoint &, const KFileItemList & ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( KXMLGUIClient *, const QPoint &, const KFileItemList & ) ) );
|
|
|
|
|
|
|
|
disconnect( ext, SIGNAL( popupMenu( KXMLGUIClient *, const QPoint &, const KURL &, const QString &, mode_t ) ),
|
|
|
|
m_pMainWindow, SLOT( slotPopupMenu( KXMLGUIClient *, const QPoint &, const KURL &, const QString &, mode_t ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-20 20:53:19 +00:00
|
|
|
KonqViewIface * KonqView::dcopObject()
|
|
|
|
{
|
|
|
|
if ( !m_dcopObject )
|
|
|
|
m_dcopObject = new KonqViewIface( this );
|
|
|
|
return m_dcopObject;
|
|
|
|
}
|
|
|
|
|
2000-11-26 00:56:16 +00:00
|
|
|
bool KonqView::eventFilter( QObject *obj, QEvent *e )
|
|
|
|
{
|
|
|
|
if ( m_pPart && obj != m_pPart->widget() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( e->type() == QEvent::DragEnter )
|
|
|
|
{
|
|
|
|
QDragEnterEvent *ev = static_cast<QDragEnterEvent *>( e );
|
|
|
|
|
|
|
|
if ( QUriDrag::canDecode( ev ) )
|
|
|
|
{
|
|
|
|
KURL::List lstDragURLs;
|
|
|
|
bool ok = KURLDrag::decode( ev, lstDragURLs );
|
|
|
|
|
|
|
|
QObjectList *children = m_pPart->widget()->queryList( "QWidget" );
|
|
|
|
|
|
|
|
if ( ok &&
|
|
|
|
!lstDragURLs.first().url().contains( "javascript:", false ) && // ### this looks like a hack to me
|
|
|
|
ev->source() != m_pPart->widget() &&
|
|
|
|
children &&
|
|
|
|
children->findRef( ev->source() ) == -1 )
|
|
|
|
ev->acceptAction();
|
|
|
|
|
|
|
|
delete children;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( e->type() == QEvent::Drop )
|
|
|
|
{
|
|
|
|
QDropEvent *ev = static_cast<QDropEvent *>( e );
|
|
|
|
|
|
|
|
KURL::List lstDragURLs;
|
|
|
|
bool ok = KURLDrag::decode( ev, lstDragURLs );
|
|
|
|
|
|
|
|
KParts::BrowserExtension *ext = browserExtension();
|
|
|
|
if ( ok && ext )
|
|
|
|
emit ext->openURLRequest( lstDragURLs.first() ); // this will call m_pMainWindow::slotOpenURLRequest delayed
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2000-05-20 19:53:10 +00:00
|
|
|
#include "konq_view.moc"
|