You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1399 lines
45 KiB
1399 lines
45 KiB
4 years ago
|
/*
|
||
15 years ago
|
This file is part of the KDE project
|
||
|
Copyright (C) 1998-2005 David Faure <faure@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.
|
||
|
|
||
|
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; see the file COPYING. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
|
||
|
#include "konq_view.h"
|
||
12 years ago
|
#include "tdeapplication.h"
|
||
15 years ago
|
#include "KonqViewIface.h"
|
||
|
#include "konq_settingsxt.h"
|
||
|
#include "konq_frame.h"
|
||
|
#include "konq_run.h"
|
||
|
#include "konq_events.h"
|
||
|
#include "konq_viewmgr.h"
|
||
|
#include "konq_tabs.h"
|
||
|
#include "konq_browseriface.h"
|
||
12 years ago
|
#include <tdeparts/statusbarextension.h>
|
||
|
#include <tdeparts/browserextension.h>
|
||
15 years ago
|
|
||
|
#include <konq_historymgr.h>
|
||
|
#include <konq_pixmapprovider.h>
|
||
|
|
||
|
#include <assert.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kcursor.h>
|
||
|
#include <kurldrag.h>
|
||
14 years ago
|
#include <tqscrollview.h>
|
||
15 years ago
|
|
||
14 years ago
|
#include <tqapplication.h>
|
||
|
#include <tqmetaobject.h>
|
||
|
#include <tqobjectlist.h>
|
||
15 years ago
|
#include <config.h>
|
||
14 years ago
|
#include <tqucomextra_p.h>
|
||
12 years ago
|
#include <tdemessagebox.h>
|
||
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
#include <fixx11h.h>
|
||
|
|
||
|
//#define DEBUG_HISTORY
|
||
|
|
||
14 years ago
|
template class TQPtrList<HistoryEntry>;
|
||
15 years ago
|
|
||
|
KonqView::KonqView( KonqViewFactory &viewFactory,
|
||
|
KonqFrame* viewFrame,
|
||
|
KonqMainWindow *mainWindow,
|
||
|
const KService::Ptr &service,
|
||
12 years ago
|
const TDETrader::OfferList &partServiceOffers,
|
||
|
const TDETrader::OfferList &appServiceOffers,
|
||
14 years ago
|
const TQString &serviceType,
|
||
15 years ago
|
bool passiveMode
|
||
|
)
|
||
|
{
|
||
|
m_pKonqFrame = viewFrame;
|
||
|
m_pKonqFrame->setView( this );
|
||
|
|
||
|
m_sLocationBarURL = "";
|
||
|
m_pageSecurity = KonqMainWindow::NotCrypted;
|
||
|
m_bLockHistory = false;
|
||
|
m_doPost = false;
|
||
|
m_pMainWindow = mainWindow;
|
||
|
m_pRun = 0L;
|
||
|
m_pPart = 0L;
|
||
|
m_dcopObject = 0L;
|
||
|
|
||
12 years ago
|
m_randID = TDEApplication::random();
|
||
15 years ago
|
|
||
|
m_service = service;
|
||
|
m_partServiceOffers = partServiceOffers;
|
||
|
m_appServiceOffers = appServiceOffers;
|
||
|
m_serviceType = serviceType;
|
||
|
|
||
|
m_bAllowHTML = m_pMainWindow->isHTMLAllowed();
|
||
|
m_lstHistory.setAutoDelete( true );
|
||
|
m_bLoading = false;
|
||
|
m_bPendingRedirection = false;
|
||
|
m_bPassiveMode = passiveMode;
|
||
|
m_bLockedLocation = false;
|
||
|
m_bLinkedView = false;
|
||
|
m_bAborted = false;
|
||
|
m_bToggleView = false;
|
||
|
m_bHierarchicalView = false;
|
||
|
m_bDisableScrolling = false;
|
||
|
m_bGotIconURL = false;
|
||
|
m_bPopupMenuEnabled = true;
|
||
|
m_browserIface = new KonqBrowserInterface( this, "browseriface" );
|
||
|
m_bBackRightClick = KonqSettings::backRightClick();
|
||
|
m_bFollowActive = false;
|
||
|
m_bBuiltinView = false;
|
||
|
m_bURLDropHandling = false;
|
||
|
|
||
|
switchView( viewFactory );
|
||
|
}
|
||
|
|
||
|
KonqView::~KonqView()
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqView::~KonqView : part = " << m_pPart << endl;
|
||
|
|
||
|
if (KonqMainWindow::s_crashlog_file) {
|
||
14 years ago
|
TQString part_url;
|
||
15 years ago
|
if (m_pPart)
|
||
|
part_url = m_pPart->url().url();
|
||
|
if (part_url.isNull())
|
||
|
part_url = "";
|
||
14 years ago
|
TQCString line;
|
||
13 years ago
|
line = ( TQString("close(%1):%2\n").arg(m_randID,0,16).arg(part_url) ).utf8();
|
||
15 years ago
|
KonqMainWindow::s_crashlog_file->writeBlock(line, line.length());
|
||
|
KonqMainWindow::s_crashlog_file->flush();
|
||
|
}
|
||
|
|
||
|
// We did so ourselves for passive views
|
||
|
if (m_pPart != 0L)
|
||
|
{
|
||
|
finishedWithCurrentURL();
|
||
|
if ( isPassiveMode() )
|
||
14 years ago
|
disconnect( m_pPart, TQT_SIGNAL( destroyed() ), m_pMainWindow->viewManager(), TQT_SLOT( slotObjectDestroyed() ) );
|
||
15 years ago
|
|
||
|
delete m_pPart;
|
||
|
}
|
||
|
|
||
|
setRun( 0L );
|
||
|
//kdDebug(1202) << "KonqView::~KonqView " << this << " done" << endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqView::openURL( const KURL &url, const TQString & locationBarURL,
|
||
|
const TQString & nameFilter, bool tempFile )
|
||
15 years ago
|
{
|
||
|
kdDebug(1202) << "KonqView::openURL url=" << url << " locationBarURL=" << locationBarURL << endl;
|
||
|
setServiceTypeInExtension();
|
||
|
|
||
|
if (KonqMainWindow::s_crashlog_file) {
|
||
14 years ago
|
TQString part_url;
|
||
15 years ago
|
if (m_pPart)
|
||
|
part_url = m_pPart->url().url();
|
||
|
if (part_url.isNull())
|
||
|
part_url = "";
|
||
|
|
||
14 years ago
|
TQString url_url = url.url();
|
||
15 years ago
|
if (url_url.isNull())
|
||
14 years ago
|
url_url = TQString("");
|
||
15 years ago
|
|
||
14 years ago
|
TQCString line;
|
||
15 years ago
|
|
||
13 years ago
|
line = ( TQString("closed(%1):%2\n").arg(m_randID,0,16).arg(part_url) ).utf8();
|
||
15 years ago
|
KonqMainWindow::s_crashlog_file->writeBlock(line,line.length());
|
||
13 years ago
|
line = ( TQString("opened(%3):%4\n").arg(m_randID,0,16).arg(url_url) ).utf8();
|
||
15 years ago
|
KonqMainWindow::s_crashlog_file->writeBlock(line,line.length());
|
||
|
KonqMainWindow::s_crashlog_file->flush();
|
||
|
}
|
||
|
|
||
|
KParts::BrowserExtension *ext = browserExtension();
|
||
|
KParts::URLArgs args;
|
||
|
if ( ext )
|
||
|
args = ext->urlArgs();
|
||
|
|
||
|
// Typing "Enter" again after the URL of an aborted view, triggers a reload.
|
||
|
if ( m_bAborted && m_pPart && m_pPart->url() == url && !args.doPost())
|
||
|
{
|
||
|
if ( !prepareReload( args ) )
|
||
|
return;
|
||
|
if ( ext )
|
||
|
ext->setURLArgs( args );
|
||
|
}
|
||
|
|
||
|
#ifdef DEBUG_HISTORY
|
||
|
kdDebug(1202) << "m_bLockedLocation=" << m_bLockedLocation << " args.lockHistory()=" << args.lockHistory() << endl;
|
||
|
#endif
|
||
|
if ( args.lockHistory() )
|
||
|
lockHistory();
|
||
|
|
||
|
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;
|
||
|
|
||
14 years ago
|
callExtensionStringMethod( "setNameFilter(const TQString&)", nameFilter );
|
||
15 years ago
|
if ( m_bDisableScrolling )
|
||
|
callExtensionMethod( "disableScrolling()" );
|
||
|
|
||
|
setLocationBarURL( locationBarURL );
|
||
|
setPageSecurity(KonqMainWindow::NotCrypted);
|
||
|
|
||
|
if ( !args.reload )
|
||
|
{
|
||
|
// Save the POST data that is necessary to open this URL
|
||
|
// (so that reload can re-post it)
|
||
|
m_doPost = args.doPost();
|
||
|
m_postContentType = args.contentType();
|
||
|
m_postData = args.postData;
|
||
|
// Save the referrer
|
||
|
m_pageReferrer = args.metaData()["referrer"];
|
||
|
}
|
||
|
|
||
|
if ( tempFile ) {
|
||
|
// Store the path to the tempfile. Yes, we could store a bool only,
|
||
|
// but this would be more dangerous. If anything goes wrong in the code,
|
||
|
// we might end up deleting a real file.
|
||
|
if ( url.isLocalFile() )
|
||
|
m_tempFile = url.path();
|
||
|
else
|
||
|
kdWarning(1202) << "Tempfile option is set, but URL is remote: " << url << endl;
|
||
|
}
|
||
|
|
||
|
aboutToOpenURL( url, args );
|
||
|
|
||
|
m_pPart->openURL( url );
|
||
|
|
||
|
updateHistoryEntry(false /* don't save location bar URL yet */);
|
||
|
// add pending history entry
|
||
14 years ago
|
KonqHistoryManager::kself()->addPending( url, locationBarURL, TQString::null);
|
||
15 years ago
|
|
||
|
#ifdef DEBUG_HISTORY
|
||
13 years ago
|
kdDebug(1202) << "Current position : " << m_lstHistory.at() << endl;
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
|
void KonqView::switchView( KonqViewFactory &viewFactory )
|
||
|
{
|
||
|
kdDebug(1202) << "KonqView::switchView" << endl;
|
||
|
if ( m_pPart )
|
||
|
m_pPart->widget()->hide();
|
||
|
|
||
|
KParts::ReadOnlyPart *oldPart = m_pPart;
|
||
|
m_pPart = m_pKonqFrame->attach( viewFactory ); // creates the part
|
||
|
|
||
12 years ago
|
// Set the statusbar in the BE asap to avoid a TDEMainWindow statusbar being created.
|
||
15 years ago
|
KParts::StatusBarExtension* sbext = statusBarExtension();
|
||
|
if ( sbext )
|
||
|
sbext->setStatusBar( frame()->statusbar() );
|
||
|
|
||
|
// Activate the new part
|
||
|
if ( oldPart )
|
||
|
{
|
||
|
m_pPart->setName( oldPart->name() );
|
||
|
emit sigPartChanged( this, oldPart, m_pPart );
|
||
|
delete oldPart;
|
||
|
}
|
||
|
|
||
|
connectPart();
|
||
|
|
||
14 years ago
|
TQVariant prop;
|
||
15 years ago
|
|
||
13 years ago
|
prop = m_service->property( "X-TDE-BrowserView-FollowActive");
|
||
15 years ago
|
if (prop.isValid() && prop.toBool())
|
||
|
{
|
||
13 years ago
|
//kdDebug(1202) << "KonqView::switchView X-TDE-BrowserView-FollowActive -> setFollowActive" <<endl;
|
||
15 years ago
|
setFollowActive(true);
|
||
|
}
|
||
|
|
||
13 years ago
|
prop = m_service->property( "X-TDE-BrowserView-Built-Into" );
|
||
15 years ago
|
m_bBuiltinView = (prop.isValid() && prop.toString() == "konqueror");
|
||
|
|
||
|
if ( !m_pMainWindow->viewManager()->isLoadingProfile() )
|
||
|
{
|
||
|
// Honour "non-removeable passive mode" (like the dirtree)
|
||
13 years ago
|
prop = m_service->property( "X-TDE-BrowserView-PassiveMode");
|
||
15 years ago
|
if ( prop.isValid() && prop.toBool() )
|
||
|
{
|
||
13 years ago
|
kdDebug(1202) << "KonqView::switchView X-TDE-BrowserView-PassiveMode -> setPassiveMode" << endl;
|
||
15 years ago
|
setPassiveMode( true ); // set as passive
|
||
|
}
|
||
|
|
||
|
// Honour "linked view"
|
||
13 years ago
|
prop = m_service->property( "X-TDE-BrowserView-LinkedView");
|
||
15 years ago
|
if ( prop.isValid() && prop.toBool() )
|
||
|
{
|
||
|
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 );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
prop = m_service->property( "X-TDE-BrowserView-HierarchicalView");
|
||
15 years ago
|
if ( prop.isValid() && prop.toBool() )
|
||
|
{
|
||
13 years ago
|
kdDebug() << "KonqView::switchView X-TDE-BrowserView-HierarchicalView -> setHierarchicalView" << endl;
|
||
15 years ago
|
setHierarchicalView( true ); // set as hierarchial
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
setHierarchicalView( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
bool KonqView::changeViewMode( const TQString &serviceType,
|
||
|
const TQString &serviceName,
|
||
15 years ago
|
bool forceAutoEmbed )
|
||
|
{
|
||
|
// Caller should call stop first.
|
||
|
assert ( !m_bLoading );
|
||
|
|
||
|
kdDebug(1202) << "changeViewMode: serviceType is " << serviceType
|
||
|
<< " serviceName is " << serviceName
|
||
|
<< " current service name is " << m_service->desktopEntryName() << endl;
|
||
|
|
||
|
if ( KMimeType::mimeType(serviceType)->is(m_serviceType) && (serviceName.isEmpty() || serviceName == m_service->desktopEntryName()) )
|
||
|
return true;
|
||
|
|
||
|
if ( isLockedViewMode() )
|
||
|
{
|
||
|
//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
|
||
|
}
|
||
|
|
||
|
kdDebug(1202) << "Switching view modes..." << endl;
|
||
12 years ago
|
TDETrader::OfferList partServiceOffers, appServiceOffers;
|
||
15 years ago
|
KService::Ptr service = 0L;
|
||
|
KonqViewFactory viewFactory = KonqFactory::createView( serviceType, serviceName, &service, &partServiceOffers, &appServiceOffers, forceAutoEmbed );
|
||
|
|
||
|
if ( viewFactory.isNull() )
|
||
|
{
|
||
|
// Revert location bar's URL to the working one
|
||
|
if(history().current())
|
||
|
setLocationBarURL( history().current()->locationBarURL );
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
m_serviceType = serviceType;
|
||
|
m_partServiceOffers = partServiceOffers;
|
||
|
m_appServiceOffers = appServiceOffers;
|
||
|
|
||
|
// Check if that's already the kind of part we have -> no need to recreate it
|
||
|
// Note: we should have an operator= for KService...
|
||
|
if ( m_service && m_service->desktopEntryPath() == service->desktopEntryPath() )
|
||
|
{
|
||
|
kdDebug( 1202 ) << "KonqView::changeViewMode. Reusing service. Service type set to " << m_serviceType << endl;
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
m_pMainWindow->updateViewModeActions();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m_service = service;
|
||
|
|
||
|
switchView( viewFactory );
|
||
|
}
|
||
|
|
||
|
if ( m_pMainWindow->viewManager()->activePart() != m_pPart )
|
||
|
{
|
||
|
// Make the new part active. Note that we don't do it each time we
|
||
|
// 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.
|
||
|
//kdDebug(1202) << "Giving focus to new part " << m_pPart << endl;
|
||
|
m_pMainWindow->viewManager()->setActivePart( m_pPart );
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
void KonqView::connectPart( )
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqView::connectPart" << endl;
|
||
12 years ago
|
connect( m_pPart, TQT_SIGNAL( started( TDEIO::Job * ) ),
|
||
|
this, TQT_SLOT( slotStarted( TDEIO::Job * ) ) );
|
||
14 years ago
|
connect( m_pPart, TQT_SIGNAL( completed() ),
|
||
|
this, TQT_SLOT( slotCompleted() ) );
|
||
|
connect( m_pPart, TQT_SIGNAL( completed(bool) ),
|
||
|
this, TQT_SLOT( slotCompleted(bool) ) );
|
||
|
connect( m_pPart, TQT_SIGNAL( canceled( const TQString & ) ),
|
||
|
this, TQT_SLOT( slotCanceled( const TQString & ) ) );
|
||
|
connect( m_pPart, TQT_SIGNAL( setWindowCaption( const TQString & ) ),
|
||
|
this, TQT_SLOT( setCaption( const TQString & ) ) );
|
||
15 years ago
|
|
||
|
KParts::BrowserExtension *ext = browserExtension();
|
||
|
|
||
|
if ( ext )
|
||
|
{
|
||
|
ext->setBrowserInterface( m_browserIface );
|
||
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( openURLRequestDelayed( const KURL &, const KParts::URLArgs &) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotOpenURLRequest( const KURL &, const KParts::URLArgs & ) ) );
|
||
15 years ago
|
|
||
|
if ( m_bPopupMenuEnabled )
|
||
|
{
|
||
|
m_bPopupMenuEnabled = false; // force
|
||
|
enablePopupMenu( true );
|
||
|
}
|
||
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( setLocationBarURL( const TQString & ) ),
|
||
|
this, TQT_SLOT( setLocationBarURL( const TQString & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( setIconURL( const KURL & ) ),
|
||
|
this, TQT_SLOT( setIconURL( const KURL & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( setPageSecurity( int ) ),
|
||
|
this, TQT_SLOT( setPageSecurity( int ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( createNewWindow( const KURL &, const KParts::URLArgs & ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotCreateNewWindow( const KURL &, const KParts::URLArgs & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( createNewWindow( const KURL &, const KParts::URLArgs &, const KParts::WindowArgs &, KParts::ReadOnlyPart *& ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotCreateNewWindow( const KURL &, const KParts::URLArgs &, const KParts::WindowArgs &, KParts::ReadOnlyPart *& ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( loadingProgress( int ) ),
|
||
|
m_pKonqFrame->statusbar(), TQT_SLOT( slotLoadingProgress( int ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( speedProgress( int ) ),
|
||
|
m_pKonqFrame->statusbar(), TQT_SLOT( slotSpeedProgress( int ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( selectionInfo( const KFileItemList & ) ),
|
||
|
this, TQT_SLOT( slotSelectionInfo( const KFileItemList & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( mouseOverInfo( const KFileItem * ) ),
|
||
|
this, TQT_SLOT( slotMouseOverInfo( const KFileItem * ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( openURLNotify() ),
|
||
|
this, TQT_SLOT( slotOpenURLNotify() ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( enableAction( const char *, bool ) ),
|
||
|
this, TQT_SLOT( slotEnableAction( const char *, bool ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( setActionText( const char *, const TQString& ) ),
|
||
|
this, TQT_SLOT( slotSetActionText( const char *, const TQString& ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( moveTopLevelWidget( int, int ) ),
|
||
|
this, TQT_SLOT( slotMoveTopLevelWidget( int, int ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( resizeTopLevelWidget( int, int ) ),
|
||
|
this, TQT_SLOT( slotResizeTopLevelWidget( int, int ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( requestFocus(KParts::ReadOnlyPart *) ),
|
||
|
this, TQT_SLOT( slotRequestFocus(KParts::ReadOnlyPart *) ) );
|
||
15 years ago
|
|
||
|
if (service()->desktopEntryName() != "konq_sidebartng") {
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( infoMessage( const TQString & ) ),
|
||
|
m_pKonqFrame->statusbar(), TQT_SLOT( message( const TQString & ) ) );
|
||
15 years ago
|
|
||
|
connect( ext,
|
||
14 years ago
|
TQT_SIGNAL( addWebSideBar(const KURL&, const TQString&) ),
|
||
15 years ago
|
m_pMainWindow,
|
||
14 years ago
|
TQT_SLOT( slotAddWebSideBar(const KURL&, const TQString&) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
callExtensionBoolMethod( "setSaveViewPropertiesLocally(bool)", m_pMainWindow->saveViewPropertiesLocally() );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQVariant urlDropHandling;
|
||
15 years ago
|
|
||
|
if ( ext )
|
||
|
urlDropHandling = ext->property( "urlDropHandling" );
|
||
|
else
|
||
6 years ago
|
urlDropHandling = TQVariant( true );
|
||
15 years ago
|
|
||
|
// Handle url drops if
|
||
|
// a) either the property says "ok"
|
||
|
// or
|
||
|
// b) the part is a plain krop (no BE)
|
||
14 years ago
|
m_bURLDropHandling = ( urlDropHandling.type() == TQVariant::Bool &&
|
||
15 years ago
|
urlDropHandling.toBool() );
|
||
|
|
||
|
m_pPart->widget()->installEventFilter( this );
|
||
|
|
||
14 years ago
|
if (m_bBackRightClick && m_pPart->widget()->inherits(TQSCROLLVIEW_OBJECT_NAME_STRING) )
|
||
15 years ago
|
{
|
||
14 years ago
|
(static_cast<TQScrollView *>(m_pPart->widget()))->viewport()->installEventFilter( this );
|
||
15 years ago
|
}
|
||
|
|
||
|
// KonqDirPart signal
|
||
|
if ( m_pPart->inherits("KonqDirPart") )
|
||
|
{
|
||
14 years ago
|
connect( m_pPart, TQT_SIGNAL( findOpen( KonqDirPart * ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotFindOpen( KonqDirPart * ) ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
void KonqView::slotEnableAction( const char * name, bool enabled )
|
||
|
{
|
||
|
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.
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqView::slotSetActionText( const char* name, const TQString& text )
|
||
15 years ago
|
{
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
m_pMainWindow->setActionText( name, text );
|
||
|
// Otherwise, we don't have to do anything, the state of the action is
|
||
|
// stored inside the browser-extension.
|
||
|
}
|
||
|
|
||
|
void KonqView::slotMoveTopLevelWidget( int x, int y )
|
||
|
{
|
||
|
KonqFrameContainerBase* container = frame()->parentContainer();
|
||
|
// If tabs are shown, only accept to move the whole window if there's only one tab.
|
||
|
if ( container->frameType() != "Tabs" || static_cast<KonqFrameTabs*>(container)->count() == 1 )
|
||
|
m_pMainWindow->move( x, y );
|
||
|
}
|
||
|
|
||
|
void KonqView::slotResizeTopLevelWidget( int w, int h )
|
||
|
{
|
||
|
KonqFrameContainerBase* container = frame()->parentContainer();
|
||
|
// If tabs are shown, only accept to resize the whole window if there's only one tab.
|
||
|
// ### Maybe we could store the size requested by each tab and resize the window to the biggest one.
|
||
|
if ( container->frameType() != "Tabs" || static_cast<KonqFrameTabs*>(container)->count() == 1 )
|
||
|
m_pMainWindow->resize( w, h );
|
||
|
}
|
||
|
|
||
12 years ago
|
void KonqView::slotStarted( TDEIO::Job * job )
|
||
15 years ago
|
{
|
||
|
//kdDebug(1202) << "KonqView::slotStarted" << job << endl;
|
||
|
setLoading( true );
|
||
|
|
||
|
if (job)
|
||
|
{
|
||
|
// Manage passwords properly...
|
||
|
if (m_pMainWindow)
|
||
|
{
|
||
13 years ago
|
kdDebug(7035) << "slotStarted: Window ID = " << m_pMainWindow->topLevelWidget()->winId() << endl;
|
||
|
job->setWindow (m_pMainWindow->topLevelWidget ());
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
connect( job, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ), this, TQT_SLOT( slotPercent( TDEIO::Job *, unsigned long ) ) );
|
||
|
connect( job, TQT_SIGNAL( speed( TDEIO::Job *, unsigned long ) ), this, TQT_SLOT( slotSpeed( TDEIO::Job *, unsigned long ) ) );
|
||
|
connect( job, TQT_SIGNAL( infoMessage( TDEIO::Job *, const TQString & ) ), this, TQT_SLOT( slotInfoMessage( TDEIO::Job *, const TQString & ) ) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
void KonqView::slotRequestFocus( KParts::ReadOnlyPart * )
|
||
|
{
|
||
|
m_pMainWindow->viewManager()->showTab(this);
|
||
|
}
|
||
|
|
||
|
void KonqView::setLoading( bool loading, bool hasPending /*= false*/)
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqView::setLoading loading=" << loading << " hasPending=" << hasPending << endl;
|
||
|
m_bLoading = loading;
|
||
|
m_bPendingRedirection = hasPending;
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
m_pMainWindow->updateToolBarActions( hasPending );
|
||
|
|
||
|
m_pMainWindow->viewManager()->setLoading( this, loading || hasPending );
|
||
|
}
|
||
|
|
||
12 years ago
|
void KonqView::slotPercent( TDEIO::Job *, unsigned long percent )
|
||
15 years ago
|
{
|
||
|
m_pKonqFrame->statusbar()->slotLoadingProgress( percent );
|
||
|
}
|
||
|
|
||
12 years ago
|
void KonqView::slotSpeed( TDEIO::Job *, unsigned long bytesPerSecond )
|
||
15 years ago
|
{
|
||
|
m_pKonqFrame->statusbar()->slotSpeedProgress( bytesPerSecond );
|
||
|
}
|
||
|
|
||
12 years ago
|
void KonqView::slotInfoMessage( TDEIO::Job *, const TQString &msg )
|
||
15 years ago
|
{
|
||
|
m_pKonqFrame->statusbar()->message( msg );
|
||
|
}
|
||
|
|
||
|
void KonqView::slotCompleted()
|
||
|
{
|
||
|
slotCompleted( false );
|
||
|
}
|
||
|
|
||
|
void KonqView::slotCompleted( bool hasPending )
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqView::slotCompleted hasPending=" << hasPending << endl;
|
||
|
m_pKonqFrame->statusbar()->slotLoadingProgress( -1 );
|
||
|
|
||
|
if ( ! m_bLockHistory )
|
||
|
{
|
||
|
// Success... update history entry, including location bar URL
|
||
|
updateHistoryEntry( true );
|
||
|
|
||
|
if ( m_bAborted ) // remove the pending entry on error
|
||
|
KonqHistoryManager::kself()->removePending( url() );
|
||
|
else if ( m_lstHistory.current() ) // register as proper history entry
|
||
|
KonqHistoryManager::kself()->confirmPending(url(), typedURL(),
|
||
|
m_lstHistory.current()->title);
|
||
|
|
||
|
emit viewCompleted( this );
|
||
|
}
|
||
|
setLoading( false, hasPending );
|
||
|
|
||
|
if (!m_bGotIconURL && !m_bAborted)
|
||
|
{
|
||
|
if ( KonqSettings::enableFavicon() == true )
|
||
|
{
|
||
|
// Try to get /favicon.ico
|
||
|
if ( supportsServiceType( "text/html" ) && url().protocol().startsWith( "http" ) )
|
||
|
KonqPixmapProvider::downloadHostIcon( url() );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqView::slotCanceled( const TQString & errorMsg )
|
||
15 years ago
|
{
|
||
|
kdDebug(1202) << "KonqView::slotCanceled" << endl;
|
||
|
// 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 );
|
||
|
m_bAborted = true;
|
||
|
slotCompleted();
|
||
|
}
|
||
|
|
||
|
void KonqView::slotSelectionInfo( const KFileItemList &items )
|
||
|
{
|
||
|
KonqFileSelectionEvent ev( items, m_pPart );
|
||
14 years ago
|
TQApplication::sendEvent( m_pMainWindow, &ev );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KonqView::slotMouseOverInfo( const KFileItem *item )
|
||
|
{
|
||
|
KonqFileMouseOverEvent ev( item, m_pPart );
|
||
14 years ago
|
TQApplication::sendEvent( m_pMainWindow, &ev );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KonqView::setLocationBarURL( const KURL& locationBarURL )
|
||
|
{
|
||
|
setLocationBarURL( locationBarURL.pathOrURL() );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqView::setLocationBarURL( const TQString & locationBarURL )
|
||
15 years ago
|
{
|
||
|
//kdDebug(1202) << "KonqView::setLocationBarURL " << locationBarURL << " this=" << this << endl;
|
||
|
|
||
|
m_sLocationBarURL = locationBarURL;
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
{
|
||
|
//kdDebug(1202) << "is current view " << this << endl;
|
||
|
m_pMainWindow->setLocationBarURL( m_sLocationBarURL );
|
||
|
m_pMainWindow->setPageSecurity( m_pageSecurity );
|
||
|
}
|
||
|
if (!m_bPassiveMode) setTabIcon( KURL::fromPathOrURL( m_sLocationBarURL ) );
|
||
|
}
|
||
|
|
||
|
void KonqView::setIconURL( const KURL & iconURL )
|
||
|
// This function sets the favIcon in konqui's window if enabled,
|
||
|
// thus it is responsible for the icon in the taskbar.
|
||
|
// It does not set the tab's favIcon.
|
||
|
{
|
||
|
kdDebug(1202) << "entering KonqView::setIconURL" << endl;
|
||
|
if ( KonqSettings::enableFavicon() )
|
||
|
{
|
||
|
KonqPixmapProvider::setIconForURL( KURL( m_sLocationBarURL ), iconURL );
|
||
|
m_bGotIconURL = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KonqView::setPageSecurity( int pageSecurity )
|
||
|
{
|
||
|
m_pageSecurity = (KonqMainWindow::PageSecurity)pageSecurity;
|
||
|
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
m_pMainWindow->setPageSecurity( m_pageSecurity );
|
||
|
}
|
||
|
|
||
|
void KonqView::setTabIcon( const KURL &url )
|
||
|
{
|
||
|
if (!m_bPassiveMode) frame()->setTabIcon( url, 0L );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqView::setCaption( const TQString & caption )
|
||
15 years ago
|
{
|
||
|
if (caption.isEmpty()) return;
|
||
|
|
||
14 years ago
|
TQString adjustedCaption = caption;
|
||
15 years ago
|
// For local URLs we prefer to use only the directory name
|
||
|
if (url().isLocalFile())
|
||
|
{
|
||
|
// Is the caption a URL? If so, is it local? If so, only display the filename!
|
||
|
KURL url = KURL::fromPathOrURL(caption);
|
||
|
if (url.isValid() && url.isLocalFile() && url.fileName() == this->url().fileName())
|
||
|
adjustedCaption = url.fileName();
|
||
|
}
|
||
|
|
||
|
m_caption = adjustedCaption;
|
||
|
if (!m_bPassiveMode) frame()->setTitle( adjustedCaption , 0L );
|
||
|
}
|
||
|
|
||
|
void KonqView::slotOpenURLNotify()
|
||
|
{
|
||
|
#ifdef DEBUG_HISTORY
|
||
|
kdDebug(1202) << "KonqView::slotOpenURLNotify" << endl;
|
||
|
#endif
|
||
|
updateHistoryEntry(true);
|
||
|
createHistoryEntry();
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
m_pMainWindow->updateToolBarActions();
|
||
|
}
|
||
|
|
||
|
void KonqView::createHistoryEntry()
|
||
|
{
|
||
|
// First, remove any forward history
|
||
|
HistoryEntry * current = m_lstHistory.current();
|
||
|
if (current)
|
||
|
{
|
||
|
#ifdef DEBUG_HISTORY
|
||
|
kdDebug(1202) << "Truncating history" << endl;
|
||
|
#endif
|
||
13 years ago
|
m_lstHistory.at( m_lstHistory.count() - 1 ); // go to last one
|
||
15 years ago
|
for ( ; m_lstHistory.current() != current ; )
|
||
|
{
|
||
|
if ( !m_lstHistory.removeLast() ) // and remove from the end (faster and easier)
|
||
|
assert(0);
|
||
|
// go to last one. The documentation says that removeLast()
|
||
|
// makes current() null if it's the last item. however in qt2
|
||
|
// the behaviour was different than the documentation. this is
|
||
|
// changed in qt3 to behave as documented ;-) (Simon)
|
||
13 years ago
|
m_lstHistory.at( m_lstHistory.count() - 1 );
|
||
15 years ago
|
}
|
||
|
// Now current is the current again.
|
||
|
}
|
||
|
// Append a new entry
|
||
|
#ifdef DEBUG_HISTORY
|
||
|
kdDebug(1202) << "Append a new entry" << endl;
|
||
|
#endif
|
||
|
m_lstHistory.append( new HistoryEntry ); // made current
|
||
|
#ifdef DEBUG_HISTORY
|
||
13 years ago
|
kdDebug(1202) << "at=" << m_lstHistory.at() << " count=" << m_lstHistory.count() << endl;
|
||
15 years ago
|
#endif
|
||
13 years ago
|
assert( m_lstHistory.at() == (int) m_lstHistory.count() - 1 );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KonqView::updateHistoryEntry( bool saveLocationBarURL )
|
||
|
{
|
||
|
Q_ASSERT( !m_bLockHistory ); // should never happen
|
||
|
|
||
|
HistoryEntry * current = m_lstHistory.current();
|
||
|
if ( !current )
|
||
|
return;
|
||
|
|
||
|
if ( browserExtension() )
|
||
|
{
|
||
14 years ago
|
current->buffer = TQByteArray(); // Start with empty buffer.
|
||
|
TQDataStream stream( current->buffer, IO_WriteOnly );
|
||
15 years ago
|
|
||
|
browserExtension()->saveState( stream );
|
||
|
}
|
||
|
|
||
|
#ifdef DEBUG_HISTORY
|
||
13 years ago
|
kdDebug(1202) << "Saving part URL : " << m_pPart->url() << " in history position " << m_lstHistory.at() << endl;
|
||
15 years ago
|
#endif
|
||
|
current->url = m_pPart->url();
|
||
|
|
||
|
if (saveLocationBarURL)
|
||
|
{
|
||
|
#ifdef DEBUG_HISTORY
|
||
13 years ago
|
kdDebug(1202) << "Saving location bar URL : " << m_sLocationBarURL << " in history position " << m_lstHistory.at() << endl;
|
||
15 years ago
|
#endif
|
||
|
current->locationBarURL = m_sLocationBarURL;
|
||
|
current->pageSecurity = m_pageSecurity;
|
||
|
}
|
||
|
#ifdef DEBUG_HISTORY
|
||
13 years ago
|
kdDebug(1202) << "Saving title : " << m_caption << " in history position " << m_lstHistory.at() << endl;
|
||
15 years ago
|
#endif
|
||
|
current->title = m_caption;
|
||
|
current->strServiceType = m_serviceType;
|
||
|
current->strServiceName = m_service->desktopEntryName();
|
||
|
|
||
|
current->doPost = m_doPost;
|
||
14 years ago
|
current->postData = m_doPost ? m_postData : TQByteArray();
|
||
|
current->postContentType = m_doPost ? m_postContentType : TQString::null;
|
||
15 years ago
|
current->pageReferrer = m_pageReferrer;
|
||
|
}
|
||
|
|
||
|
void KonqView::goHistory( int steps )
|
||
|
{
|
||
|
// This is called by KonqBrowserInterface
|
||
|
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 );
|
||
|
}
|
||
|
|
||
|
void KonqView::go( int steps )
|
||
|
{
|
||
|
if ( !steps ) // [WildFox] i bet there are sites on the net with stupid devs who do that :)
|
||
|
{
|
||
|
#ifdef DEBUG_HISTORY
|
||
|
kdDebug(1202) << "KonqView::go(0)" << endl;
|
||
|
#endif
|
||
|
// [David] and you're right. And they expect that it reloads, apparently.
|
||
|
// [George] I'm going to make nspluginviewer rely on this too. :-)
|
||
|
m_pMainWindow->slotReload();
|
||
|
return;
|
||
|
}
|
||
|
|
||
13 years ago
|
int newPos = m_lstHistory.at() + steps;
|
||
15 years ago
|
#ifdef DEBUG_HISTORY
|
||
|
kdDebug(1202) << "go : steps=" << steps
|
||
|
<< " newPos=" << newPos
|
||
|
<< " m_lstHistory.count()=" << m_lstHistory.count()
|
||
|
<< endl;
|
||
|
#endif
|
||
|
if( newPos < 0 || (uint)newPos >= m_lstHistory.count() )
|
||
|
return;
|
||
|
|
||
|
stop();
|
||
|
|
||
|
// Yay, we can move there without a loop !
|
||
13 years ago
|
HistoryEntry *currentHistoryEntry = m_lstHistory.at( newPos ); // sets current item
|
||
15 years ago
|
|
||
|
assert( currentHistoryEntry );
|
||
13 years ago
|
assert( newPos == m_lstHistory.at() ); // check we moved (i.e. if I understood the docu)
|
||
15 years ago
|
assert( currentHistoryEntry == m_lstHistory.current() );
|
||
|
#ifdef DEBUG_HISTORY
|
||
13 years ago
|
kdDebug(1202) << "New position " << m_lstHistory.at() << endl;
|
||
15 years ago
|
#endif
|
||
|
|
||
|
restoreHistory();
|
||
|
}
|
||
|
|
||
|
void KonqView::restoreHistory()
|
||
|
{
|
||
|
HistoryEntry h( *(m_lstHistory.current()) ); // make a copy of the current history entry, as the data
|
||
|
// the pointer points to will change with the following calls
|
||
|
|
||
|
#ifdef DEBUG_HISTORY
|
||
|
kdDebug(1202) << "Restoring servicetype/name, and location bar URL from history : " << h.locationBarURL << endl;
|
||
|
#endif
|
||
|
setLocationBarURL( h.locationBarURL );
|
||
|
setPageSecurity( h.pageSecurity );
|
||
14 years ago
|
m_sTypedURL = TQString::null;
|
||
15 years ago
|
if ( ! changeViewMode( h.strServiceType, h.strServiceName ) )
|
||
|
{
|
||
|
kdWarning(1202) << "Couldn't change view mode to " << h.strServiceType
|
||
|
<< " " << h.strServiceName << endl;
|
||
|
return /*false*/;
|
||
|
}
|
||
|
|
||
|
setServiceTypeInExtension();
|
||
|
|
||
|
aboutToOpenURL( h.url );
|
||
|
|
||
|
if ( browserExtension() )
|
||
|
{
|
||
|
//kdDebug(1202) << "Restoring view from stream" << endl;
|
||
14 years ago
|
TQDataStream stream( h.buffer, IO_ReadOnly );
|
||
15 years ago
|
|
||
|
browserExtension()->restoreState( stream );
|
||
|
|
||
|
m_doPost = h.doPost;
|
||
|
m_postContentType = h.postContentType;
|
||
|
m_postData = h.postData;
|
||
|
m_pageReferrer = h.pageReferrer;
|
||
|
}
|
||
|
else
|
||
|
m_pPart->openURL( h.url );
|
||
|
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
m_pMainWindow->updateToolBarActions();
|
||
|
|
||
|
#ifdef DEBUG_HISTORY
|
||
13 years ago
|
kdDebug(1202) << "New position (2) " << m_lstHistory.at() << endl;
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
|
const HistoryEntry * KonqView::historyAt(const int pos)
|
||
|
{
|
||
|
if(pos<0 || pos>=(int)m_lstHistory.count())
|
||
|
return 0L;
|
||
13 years ago
|
int oldpos = m_lstHistory.at();
|
||
|
const HistoryEntry* h = m_lstHistory.at(pos);
|
||
|
m_lstHistory.at( oldpos );
|
||
15 years ago
|
return h;
|
||
|
}
|
||
|
|
||
|
void KonqView::copyHistory( KonqView *other )
|
||
|
{
|
||
|
m_lstHistory.clear();
|
||
|
|
||
14 years ago
|
TQPtrListIterator<HistoryEntry> it( other->m_lstHistory );
|
||
15 years ago
|
for (; it.current(); ++it )
|
||
|
m_lstHistory.append( new HistoryEntry( *it.current() ) );
|
||
13 years ago
|
m_lstHistory.at(other->m_lstHistory.at());
|
||
15 years ago
|
}
|
||
|
|
||
|
KURL KonqView::url() const
|
||
|
{
|
||
|
assert( m_pPart );
|
||
|
return m_pPart->url();
|
||
|
}
|
||
|
|
||
|
KURL KonqView::upURL() const
|
||
|
{
|
||
|
KURL currentURL;
|
||
|
if ( m_pRun )
|
||
|
currentURL = m_pRun->url();
|
||
|
else
|
||
|
currentURL = KURL::fromPathOrURL( m_sLocationBarURL );
|
||
|
return currentURL.upURL();
|
||
|
}
|
||
|
|
||
|
void KonqView::setRun( KonqRun * run )
|
||
|
{
|
||
|
if ( m_pRun )
|
||
|
{
|
||
|
// Tell the KonqRun to abort, but don't delete it ourselves.
|
||
|
// It could be showing a message box right now. It will delete itself anyway.
|
||
|
m_pRun->abort();
|
||
|
// finish() will be emitted later (when back to event loop)
|
||
|
// and we don't want it to call slotRunFinished (which stops the animation and stop button).
|
||
|
m_pRun->disconnect( m_pMainWindow );
|
||
|
if ( !run )
|
||
|
frame()->unsetCursor();
|
||
|
}
|
||
|
else if ( run )
|
||
|
frame()->setCursor( KCursor::workingCursor() );
|
||
|
m_pRun = run;
|
||
|
}
|
||
|
|
||
|
void KonqView::stop()
|
||
|
{
|
||
|
//kdDebug(1202) << "KonqView::stop()" << endl;
|
||
|
m_bAborted = false;
|
||
|
finishedWithCurrentURL();
|
||
|
if ( m_bLoading || m_bPendingRedirection )
|
||
|
{
|
||
|
// aborted -> confirm the pending url. We might as well remove it, but
|
||
|
// we decided to keep it :)
|
||
|
KonqHistoryManager::kself()->confirmPending( url(), m_sTypedURL );
|
||
|
|
||
|
//kdDebug(1202) << "m_pPart->closeURL()" << endl;
|
||
|
m_pPart->closeURL();
|
||
|
m_bAborted = true;
|
||
|
m_pKonqFrame->statusbar()->slotLoadingProgress( -1 );
|
||
|
setLoading( false, false );
|
||
|
}
|
||
|
if ( m_pRun )
|
||
|
{
|
||
|
// 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()...
|
||
|
if ( history().current() && m_pRun->typedURL().isEmpty() ) { // not typed
|
||
|
setLocationBarURL( history().current()->locationBarURL );
|
||
|
setPageSecurity( history().current()->pageSecurity );
|
||
|
}
|
||
|
|
||
|
setRun( 0L );
|
||
|
m_pKonqFrame->statusbar()->slotLoadingProgress( -1 );
|
||
|
}
|
||
|
if ( !m_bLockHistory && m_lstHistory.count() > 0 )
|
||
|
updateHistoryEntry(true);
|
||
|
}
|
||
|
|
||
|
void KonqView::finishedWithCurrentURL()
|
||
|
{
|
||
|
if ( !m_tempFile.isEmpty() )
|
||
|
{
|
||
|
kdDebug(1202) << "######### Deleting tempfile after use:" << m_tempFile << endl;
|
||
14 years ago
|
TQFile::remove( m_tempFile );
|
||
|
m_tempFile = TQString::null;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
void KonqView::setPassiveMode( bool mode )
|
||
|
{
|
||
|
// 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...
|
||
|
m_bPassiveMode = mode;
|
||
|
|
||
|
if ( mode && m_pMainWindow->viewCount() > 1 && m_pMainWindow->currentView() == this )
|
||
|
{
|
||
|
KParts::Part * part = m_pMainWindow->viewManager()->chooseNextView( this )->part(); // switch active part
|
||
|
m_pMainWindow->viewManager()->setActivePart( part );
|
||
|
}
|
||
|
|
||
|
// Update statusbar stuff
|
||
|
m_pMainWindow->viewManager()->viewCountChanged();
|
||
|
}
|
||
|
|
||
|
void KonqView::setHierarchicalView( bool mode )
|
||
|
{
|
||
|
m_bHierarchicalView=mode;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void KonqView::setLinkedView( bool mode )
|
||
|
{
|
||
|
m_bLinkedView = mode;
|
||
|
if ( m_pMainWindow->currentView() == this )
|
||
|
m_pMainWindow->linkViewAction()->setChecked( mode );
|
||
|
frame()->statusbar()->setLinkedView( mode );
|
||
|
}
|
||
|
|
||
|
void KonqView::setLockedLocation( bool b )
|
||
|
{
|
||
|
m_bLockedLocation = b;
|
||
|
}
|
||
|
|
||
|
void KonqView::aboutToOpenURL( const KURL &url, const KParts::URLArgs &args )
|
||
|
{
|
||
|
KParts::OpenURLEvent ev( m_pPart, url, args );
|
||
14 years ago
|
TQApplication::sendEvent( m_pMainWindow, &ev );
|
||
15 years ago
|
|
||
|
m_bGotIconURL = false;
|
||
|
m_bAborted = false;
|
||
|
}
|
||
|
|
||
|
void KonqView::setServiceTypeInExtension()
|
||
|
{
|
||
|
KParts::BrowserExtension *ext = browserExtension();
|
||
|
if ( !ext )
|
||
|
return;
|
||
|
|
||
|
KParts::URLArgs args( ext->urlArgs() );
|
||
|
args.serviceType = m_serviceType;
|
||
|
ext->setURLArgs( args );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQStringList KonqView::frameNames() const
|
||
15 years ago
|
{
|
||
|
return childFrameNames( m_pPart );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQStringList KonqView::childFrameNames( KParts::ReadOnlyPart *part )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQStringList res;
|
||
15 years ago
|
|
||
|
KParts::BrowserHostExtension *hostExtension = KParts::BrowserHostExtension::childObject( part );
|
||
|
|
||
|
if ( !hostExtension )
|
||
|
return res;
|
||
|
|
||
|
res += hostExtension->frameNames();
|
||
|
|
||
14 years ago
|
const TQPtrList<KParts::ReadOnlyPart> children = hostExtension->frames();
|
||
|
TQPtrListIterator<KParts::ReadOnlyPart> it( children );
|
||
15 years ago
|
for (; it.current(); ++it )
|
||
|
res += childFrameNames( it.current() );
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
|
||
14 years ago
|
KParts::BrowserHostExtension* KonqView::hostExtension( KParts::ReadOnlyPart *part, const TQString &name )
|
||
15 years ago
|
{
|
||
|
KParts::BrowserHostExtension *ext = KParts::BrowserHostExtension::childObject( part );
|
||
|
|
||
|
if ( !ext )
|
||
|
return 0;
|
||
|
|
||
13 years ago
|
if ( ext->frameNames().contains( name ) )
|
||
15 years ago
|
return ext;
|
||
|
|
||
14 years ago
|
const TQPtrList<KParts::ReadOnlyPart> children = ext->frames();
|
||
|
TQPtrListIterator<KParts::ReadOnlyPart> it( children );
|
||
15 years ago
|
for (; it.current(); ++it )
|
||
|
{
|
||
|
KParts::BrowserHostExtension *childHost = hostExtension( it.current(), name );
|
||
|
if ( childHost )
|
||
|
return childHost;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
bool KonqView::callExtensionMethod( const char *methodName )
|
||
|
{
|
||
14 years ago
|
TQObject *obj = KParts::BrowserExtension::childObject( m_pPart );
|
||
15 years ago
|
if ( !obj ) // not all views have a browser extension !
|
||
|
return false;
|
||
|
|
||
13 years ago
|
int id = obj->metaObject()->findSlot( methodName );
|
||
15 years ago
|
if ( id == -1 )
|
||
|
return false;
|
||
14 years ago
|
TQUObject o[ 1 ];
|
||
15 years ago
|
|
||
13 years ago
|
obj->tqt_invoke( id, o );
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
|
||
|
bool KonqView::callExtensionBoolMethod( const char *methodName, bool value )
|
||
|
{
|
||
14 years ago
|
TQObject *obj = KParts::BrowserExtension::childObject( m_pPart );
|
||
15 years ago
|
if ( !obj ) // not all views have a browser extension !
|
||
|
return false;
|
||
|
|
||
13 years ago
|
int id = obj->metaObject()->findSlot( methodName );
|
||
15 years ago
|
if ( id == -1 )
|
||
|
return false;
|
||
14 years ago
|
TQUObject o[ 2 ];
|
||
15 years ago
|
|
||
14 years ago
|
static_TQUType_bool.set( o + 1, value );
|
||
15 years ago
|
|
||
13 years ago
|
obj->tqt_invoke( id, o );
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool KonqView::callExtensionStringMethod( const char *methodName, TQString value )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQObject *obj = KParts::BrowserExtension::childObject( m_pPart );
|
||
15 years ago
|
if ( !obj ) // not all views have a browser extension !
|
||
|
return false;
|
||
|
|
||
13 years ago
|
int id = obj->metaObject()->findSlot( methodName );
|
||
15 years ago
|
if ( id == -1 )
|
||
|
return false;
|
||
14 years ago
|
TQUObject o[ 2 ];
|
||
15 years ago
|
|
||
14 years ago
|
static_TQUType_TQString.set( o + 1, value );
|
||
15 years ago
|
|
||
13 years ago
|
obj->tqt_invoke( id, o );
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
|
||
|
bool KonqView::callExtensionURLMethod( const char *methodName, const KURL& value )
|
||
|
{
|
||
14 years ago
|
TQObject *obj = KParts::BrowserExtension::childObject( m_pPart );
|
||
15 years ago
|
if ( !obj ) // not all views have a browser extension !
|
||
|
return false;
|
||
|
|
||
13 years ago
|
int id = obj->metaObject()->findSlot( methodName );
|
||
15 years ago
|
if ( id == -1 )
|
||
|
return false;
|
||
14 years ago
|
TQUObject o[ 2 ];
|
||
15 years ago
|
|
||
14 years ago
|
static_TQUType_ptr.set( o + 1, &value );
|
||
15 years ago
|
|
||
13 years ago
|
obj->tqt_invoke( id, o );
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KonqView::setViewName( const TQString &name )
|
||
15 years ago
|
{
|
||
|
//kdDebug() << "KonqView::setViewName this=" << this << " name=" << name << endl;
|
||
|
if ( m_pPart )
|
||
|
m_pPart->setName( name.local8Bit().data() );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString KonqView::viewName() const
|
||
15 years ago
|
{
|
||
14 years ago
|
return m_pPart ? TQString::fromLocal8Bit( m_pPart->name() ) : TQString();
|
||
15 years ago
|
}
|
||
|
|
||
|
void KonqView::enablePopupMenu( bool b )
|
||
|
{
|
||
|
Q_ASSERT( m_pMainWindow );
|
||
|
|
||
|
KParts::BrowserExtension *ext = browserExtension();
|
||
|
|
||
|
if ( !ext )
|
||
|
return;
|
||
|
|
||
|
if ( m_bPopupMenuEnabled == b )
|
||
|
return;
|
||
|
|
||
|
// enable context popup
|
||
|
if ( b ) {
|
||
|
m_bPopupMenuEnabled = true;
|
||
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( popupMenu( const TQPoint &, const KFileItemList & ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( const TQPoint &, const KFileItemList & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( popupMenu( const TQPoint &, const KURL &, const TQString &, mode_t ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( const TQPoint &, const KURL &, const TQString &, mode_t ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( popupMenu( KXMLGUIClient *, const TQPoint &, const KFileItemList & ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( KXMLGUIClient *, const TQPoint &, const KFileItemList & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( popupMenu( KXMLGUIClient *, const TQPoint &, const KFileItemList &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( KXMLGUIClient *, const TQPoint &, const KFileItemList &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( popupMenu( KXMLGUIClient *, const TQPoint &, const KURL &, const TQString &, mode_t ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( KXMLGUIClient *, const TQPoint &, const KURL &, const TQString &, mode_t ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
connect( ext, TQT_SIGNAL( popupMenu( KXMLGUIClient *, const TQPoint &, const KURL &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags, mode_t ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( KXMLGUIClient *, const TQPoint &, const KURL &, const KParts::URLArgs &, KParts::BrowserExtension::PopupFlags, mode_t ) ) );
|
||
15 years ago
|
}
|
||
|
else // disable context popup
|
||
|
{
|
||
|
m_bPopupMenuEnabled = false;
|
||
|
|
||
14 years ago
|
disconnect( ext, TQT_SIGNAL( popupMenu( const TQPoint &, const KFileItemList & ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( const TQPoint &, const KFileItemList & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
disconnect( ext, TQT_SIGNAL( popupMenu( const TQPoint &, const KURL &, const TQString &, mode_t ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( const TQPoint &, const KURL &, const TQString &, mode_t ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
disconnect( ext, TQT_SIGNAL( popupMenu( KXMLGUIClient *, const TQPoint &, const KFileItemList & ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( KXMLGUIClient *, const TQPoint &, const KFileItemList & ) ) );
|
||
15 years ago
|
|
||
14 years ago
|
disconnect( ext, TQT_SIGNAL( popupMenu( KXMLGUIClient *, const TQPoint &, const KURL &, const TQString &, mode_t ) ),
|
||
|
m_pMainWindow, TQT_SLOT( slotPopupMenu( KXMLGUIClient *, const TQPoint &, const KURL &, const TQString &, mode_t ) ) );
|
||
15 years ago
|
}
|
||
|
enableBackRightClick( m_bBackRightClick );
|
||
|
}
|
||
|
|
||
|
// caller should ensure that this is called only when b changed, or for new parts
|
||
|
void KonqView::enableBackRightClick( bool b )
|
||
|
{
|
||
|
m_bBackRightClick = b;
|
||
|
if ( b )
|
||
14 years ago
|
connect( this, TQT_SIGNAL( backRightClick() ),
|
||
|
m_pMainWindow, TQT_SLOT( slotBack() ) );
|
||
15 years ago
|
else
|
||
14 years ago
|
disconnect( this, TQT_SIGNAL( backRightClick() ),
|
||
|
m_pMainWindow, TQT_SLOT( slotBack() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
void KonqView::reparseConfiguration()
|
||
|
{
|
||
|
callExtensionMethod( "reparseConfiguration()" );
|
||
|
bool b = KonqSettings::backRightClick();
|
||
|
if ( m_bBackRightClick != b )
|
||
|
{
|
||
14 years ago
|
if (m_bBackRightClick && m_pPart->widget()->inherits(TQSCROLLVIEW_OBJECT_NAME_STRING) )
|
||
15 years ago
|
{
|
||
14 years ago
|
(static_cast<TQScrollView *>(m_pPart->widget()))->viewport()->installEventFilter( this );
|
||
15 years ago
|
}
|
||
|
enableBackRightClick( b );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KonqView::disableScrolling()
|
||
|
{
|
||
|
m_bDisableScrolling = true;
|
||
|
callExtensionMethod( "disableScrolling()" );
|
||
|
}
|
||
|
|
||
|
KonqViewIface * KonqView::dcopObject()
|
||
|
{
|
||
|
if ( !m_dcopObject ) {
|
||
14 years ago
|
TQCString dcopName = name();
|
||
15 years ago
|
if ( dcopName.isEmpty() || dcopName == "unnamed" )
|
||
|
dcopName = viewName().utf8();
|
||
|
if ( dcopName.isEmpty() || dcopName == "unnamed" ) {
|
||
14 years ago
|
TQVariant dcopProperty = part()->property( "dcopObjectId" );
|
||
|
if ( dcopProperty.type() == TQVariant::CString )
|
||
15 years ago
|
dcopName = dcopProperty.toCString();
|
||
|
}
|
||
|
dcopName += "-view"; // to avoid having the same name as the part
|
||
|
m_dcopObject = new KonqViewIface( this, dcopName );
|
||
|
}
|
||
|
return m_dcopObject;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool KonqView::eventFilter( TQObject *obj, TQEvent *e )
|
||
15 years ago
|
{
|
||
|
if ( !m_pPart )
|
||
|
return false;
|
||
|
// kdDebug() << "--" << obj->className() << "--" << e->type() << "--" << endl;
|
||
14 years ago
|
if ( e->type() == TQEvent::DragEnter && m_bURLDropHandling && TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(m_pPart->widget()) )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQDragEnterEvent *ev = static_cast<TQDragEnterEvent *>( e );
|
||
15 years ago
|
|
||
|
if ( KURLDrag::canDecode( ev ) )
|
||
|
{
|
||
|
KURL::List lstDragURLs;
|
||
|
bool ok = KURLDrag::decode( ev, lstDragURLs );
|
||
|
|
||
14 years ago
|
TQObjectList *children = m_pPart->widget()->queryList( TQWIDGET_OBJECT_NAME_STRING );
|
||
15 years ago
|
|
||
|
if ( ok &&
|
||
13 years ago
|
!lstDragURLs.first().url().contains( "javascript:", false ) && // ### this looks like a hack to me
|
||
15 years ago
|
ev->source() != m_pPart->widget() &&
|
||
|
children &&
|
||
13 years ago
|
children->findRef( TQT_TQOBJECT(ev->source()) ) == -1 )
|
||
15 years ago
|
ev->acceptAction();
|
||
|
|
||
|
delete children;
|
||
|
}
|
||
|
}
|
||
14 years ago
|
else if ( e->type() == TQEvent::Drop && m_bURLDropHandling && TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(m_pPart->widget()) )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQDropEvent *ev = static_cast<TQDropEvent *>( e );
|
||
15 years ago
|
|
||
|
KURL::List lstDragURLs;
|
||
|
bool ok = KURLDrag::decode( ev, lstDragURLs );
|
||
|
|
||
|
KParts::BrowserExtension *ext = browserExtension();
|
||
|
if ( ok && ext && lstDragURLs.first().isValid() )
|
||
|
emit ext->openURLRequest( lstDragURLs.first() ); // this will call m_pMainWindow::slotOpenURLRequest delayed
|
||
|
}
|
||
|
|
||
|
if ( m_bBackRightClick )
|
||
|
{
|
||
14 years ago
|
if ( e->type() == TQEvent::ContextMenu )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQContextMenuEvent *ev = TQT_TQCONTEXTMENUEVENT( e );
|
||
14 years ago
|
if ( ev->reason() == TQContextMenuEvent::Mouse )
|
||
15 years ago
|
{
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
14 years ago
|
else if ( e->type() == TQEvent::MouseButtonPress )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQMouseEvent *ev = TQT_TQMOUSEEVENT( e );
|
||
|
if ( ev->button() == Qt::RightButton )
|
||
15 years ago
|
{
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
14 years ago
|
else if ( e->type() == TQEvent::MouseButtonRelease )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQMouseEvent *ev = TQT_TQMOUSEEVENT( e );
|
||
|
if ( ev->button() == Qt::RightButton )
|
||
15 years ago
|
{
|
||
|
emit backRightClick();
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
14 years ago
|
else if ( e->type() == TQEvent::MouseMove )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQMouseEvent *ev = TQT_TQMOUSEEVENT( e );
|
||
|
if ( ev->state() == Qt::RightButton )
|
||
15 years ago
|
{
|
||
|
obj->removeEventFilter( this );
|
||
14 years ago
|
TQMouseEvent me( TQEvent::MouseButtonPress, ev->pos(), 2, 2 );
|
||
|
TQApplication::sendEvent( obj, &me );
|
||
|
TQContextMenuEvent ce( TQContextMenuEvent::Mouse, ev->pos(), 2 );
|
||
|
TQApplication::sendEvent( obj, &ce );
|
||
15 years ago
|
obj->installEventFilter( this );
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( e->type() == TQEvent::FocusIn )
|
||
15 years ago
|
{
|
||
|
setActiveInstance();
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
void KonqView::setActiveInstance()
|
||
|
{
|
||
|
if ( m_bBuiltinView || !m_pPart->instance() /*never!*/)
|
||
12 years ago
|
TDEGlobal::_activeInstance = TDEGlobal::instance();
|
||
15 years ago
|
else
|
||
12 years ago
|
TDEGlobal::_activeInstance = m_pPart->instance();
|
||
15 years ago
|
}
|
||
|
|
||
|
bool KonqView::prepareReload( KParts::URLArgs& args )
|
||
|
{
|
||
|
args.reload = true;
|
||
|
// Repost form data if this URL is the result of a POST HTML form.
|
||
|
if ( m_doPost && !args.redirectedRequest() )
|
||
|
{
|
||
|
if ( KMessageBox::warningContinueCancel( 0, i18n(
|
||
|
"The page you are trying to view is the result of posted form data. "
|
||
|
"If you resend the data, any action the form carried out (such as search or online purchase) will be repeated. "),
|
||
|
i18n( "Warning" ), i18n( "Resend" ) ) == KMessageBox::Continue )
|
||
|
{
|
||
|
args.setDoPost( true );
|
||
|
args.setContentType( m_postContentType );
|
||
|
args.postData = m_postData;
|
||
|
}
|
||
|
else
|
||
|
return false;
|
||
|
}
|
||
|
// Re-set referrer
|
||
|
args.metaData()["referrer"] = m_pageReferrer;
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
KParts::BrowserExtension * KonqView::browserExtension() const
|
||
|
{
|
||
|
return KParts::BrowserExtension::childObject( m_pPart );
|
||
|
}
|
||
|
|
||
|
KParts::StatusBarExtension * KonqView::statusBarExtension() const
|
||
|
{
|
||
|
return KParts::StatusBarExtension::childObject( m_pPart );
|
||
|
}
|
||
|
|
||
14 years ago
|
bool KonqView::supportsServiceType( const TQString &serviceType ) const
|
||
15 years ago
|
{
|
||
14 years ago
|
const TQStringList lst = serviceTypes();
|
||
|
for( TQStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it ) {
|
||
15 years ago
|
if ( *it == serviceType )
|
||
|
return true;
|
||
|
// Maybe we should keep around a list of KServiceType::Ptr?
|
||
|
KMimeType::Ptr mime = KMimeType::mimeType( *it );
|
||
|
if ( mime && mime->is( serviceType ) ) // respect inheritance
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
#include "konq_view.moc"
|