2 This file is part of the KDE project
3 Copyright (C) 1998-2005 David Faure <faure@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
23 #include "KonqViewAdaptor.h"
24 #include "konqsettingsxt.h"
25 #include "konqframestatusbar.h"
27 #include <konq_events.h>
28 #include "konqviewmanager.h"
30 #include "konqbrowseriface.h"
31 #include <kparts/statusbarextension.h>
32 #include <kparts/browserextension.h>
34 #include "konqhistorymanager.h"
35 #include "konqpixmapprovider.h"
40 #include <kmessagebox.h>
44 #include <kio/jobuidelegate.h>
45 #include <ktoggleaction.h>
47 #include <QtGui/QApplication>
48 #include <QtCore/QArgument>
49 #include <QtCore/QObject>
50 #include <QtCore/QByteRef>
51 #include <QtCore/QEvent>
52 #include <QtGui/QKeyEvent>
53 #include <QtCore/QFile>
54 #include <QtGui/QScrollArea>
55 #include <kjobuidelegate.h>
57 //#define DEBUG_HISTORY
59 KonqView::KonqView( KonqViewFactory
&viewFactory
,
61 KonqMainWindow
*mainWindow
,
62 const KService::Ptr
&service
,
63 const KService::List
&partServiceOffers
,
64 const KService::List
&appServiceOffers
,
65 const QString
&serviceType
,
69 m_pKonqFrame
= viewFrame
;
70 m_pKonqFrame
->setView( this );
72 m_sLocationBarURL
= "";
73 m_pageSecurity
= KonqMainWindow::NotCrypted
;
74 m_bLockHistory
= false;
76 m_pMainWindow
= mainWindow
;
80 m_randID
= KRandom::random();
83 m_partServiceOffers
= partServiceOffers
;
84 m_appServiceOffers
= appServiceOffers
;
85 m_serviceType
= serviceType
;
87 m_bAllowHTML
= m_pMainWindow
->isHTMLAllowed();
88 m_lstHistoryIndex
= -1;
90 m_bPendingRedirection
= false;
91 m_bPassiveMode
= passiveMode
;
92 m_bLockedLocation
= false;
93 m_bLinkedView
= false;
95 m_bToggleView
= false;
96 m_bHierarchicalView
= false;
97 m_bDisableScrolling
= false;
98 m_bGotIconURL
= false;
99 m_bPopupMenuEnabled
= true;
100 m_browserIface
= new KonqBrowserInterface( this );
101 m_bBackRightClick
= KonqSettings::backRightClick();
102 m_bFollowActive
= false;
103 m_bBuiltinView
= false;
104 m_bURLDropHandling
= false;
106 switchView( viewFactory
);
109 KonqView::~KonqView()
111 //kDebug(1202) << "KonqView::~KonqView : part = " << m_pPart;
113 if (KonqMainWindow::s_crashlog_file
) {
116 part_url
= m_pPart
->url().url();
117 if (part_url
.isNull())
120 line
= ( QString("close(%1):%2\n").arg(m_randID
,0,16).arg(part_url
) ).toUtf8();
121 KonqMainWindow::s_crashlog_file
->write(line
, line
.length());
122 KonqMainWindow::s_crashlog_file
->flush();
125 // We did so ourselves for passive views
128 finishedWithCurrentURL();
129 if ( isPassiveMode() )
130 disconnect( m_pPart
, SIGNAL( destroyed() ), m_pMainWindow
->viewManager(), SLOT( slotObjectDestroyed() ) );
136 //kDebug(1202) << "KonqView::~KonqView " << this << " done";
139 void KonqView::openUrl( const KUrl
&url
, const QString
& locationBarURL
,
140 const QString
& nameFilter
, bool tempFile
)
142 kDebug(1202) << "KonqView::openUrl url=" << url
<< " locationBarURL=" << locationBarURL
;
145 if (KonqMainWindow::s_crashlog_file
) {
148 part_url
= m_pPart
->url().url();
149 if (part_url
.isNull())
152 QString url_url
= url
.url();
153 if (url_url
.isNull())
154 url_url
= QString("");
158 line
= ( QString("closed(%1):%2\n").arg(m_randID
,0,16).arg(part_url
) ).toUtf8();
159 KonqMainWindow::s_crashlog_file
->write(line
,line
.length());
160 line
= ( QString("opened(%3):%4\n").arg(m_randID
,0,16).arg(url_url
) ).toUtf8();
161 KonqMainWindow::s_crashlog_file
->write(line
,line
.length());
162 KonqMainWindow::s_crashlog_file
->flush();
165 KParts::OpenUrlArguments args
= m_pPart
->arguments();
166 KParts::BrowserExtension
*ext
= browserExtension();
167 KParts::BrowserArguments browserArgs
;
169 browserArgs
= ext
->browserArguments();
171 // Typing "Enter" again after the URL of an aborted view, triggers a reload.
172 if ( m_bAborted
&& m_pPart
&& m_pPart
->url() == url
&& !browserArgs
.doPost())
174 if ( !prepareReload( args
, browserArgs
, false /* not softReload */ ) )
176 m_pPart
->setArguments( args
);
180 kDebug(1202) << "m_bLockedLocation=" << m_bLockedLocation
<< " browserArgs.lockHistory()=" << browserArgs
.lockHistory();
182 if ( browserArgs
.lockHistory() )
185 if ( !m_bLockHistory
)
187 // Store this new URL in the history, removing any existing forward history.
188 // We do this first so that everything is ready if a part calls completed().
189 createHistoryEntry();
191 m_bLockHistory
= false;
193 callExtensionStringMethod( "setNameFilter", nameFilter
);
194 if ( m_bDisableScrolling
)
195 callExtensionMethod( "disableScrolling" );
197 setLocationBarURL( locationBarURL
);
198 setPageSecurity(KonqMainWindow::NotCrypted
);
200 if ( !args
.reload() )
202 // Save the POST data that is necessary to open this URL
203 // (so that reload can re-post it)
204 m_doPost
= browserArgs
.doPost();
205 m_postContentType
= browserArgs
.contentType();
206 m_postData
= browserArgs
.postData
;
208 m_pageReferrer
= args
.metaData()["referrer"];
212 // Store the path to the tempfile. Yes, we could store a bool only,
213 // but this would be more dangerous. If anything goes wrong in the code,
214 // we might end up deleting a real file.
215 if ( url
.isLocalFile() )
216 m_tempFile
= url
.path();
218 kWarning(1202) << "Tempfile option is set, but URL is remote: " << url
;
221 aboutToOpenURL( url
, args
);
223 m_pPart
->openUrl( url
);
225 updateHistoryEntry(false /* don't save location bar URL yet */);
226 // add pending history entry
227 KonqHistoryManager::kself()->addPending( url
, locationBarURL
, QString());
230 kDebug(1202) << "Current position : " << historyIndex();
234 void KonqView::switchView( KonqViewFactory
&viewFactory
)
236 //kDebug(1202) << "KonqView::switchView";
238 m_pPart
->widget()->hide();
240 KParts::ReadOnlyPart
*oldPart
= m_pPart
;
241 m_pPart
= m_pKonqFrame
->attach( viewFactory
); // creates the part
243 // Set the statusbar in the BE asap to avoid a KMainWindow statusbar being created.
244 KParts::StatusBarExtension
* sbext
= statusBarExtension();
246 sbext
->setStatusBar( frame()->statusbar() );
248 // Activate the new part
251 m_pPart
->setObjectName( oldPart
->objectName() );
252 emit
sigPartChanged( this, oldPart
, m_pPart
);
260 prop
= m_service
->property( "X-KDE-BrowserView-FollowActive");
261 if (prop
.isValid() && prop
.toBool())
263 //kDebug(1202) << "KonqView::switchView X-KDE-BrowserView-FollowActive -> setFollowActive";
264 setFollowActive(true);
267 prop
= m_service
->property( "X-KDE-BrowserView-Built-Into" );
268 m_bBuiltinView
= (prop
.isValid() && prop
.toString() == "konqueror");
270 if ( !m_pMainWindow
->viewManager()->isLoadingProfile() )
272 // Honor "non-removeable passive mode" (like the dirtree)
273 prop
= m_service
->property( "X-KDE-BrowserView-PassiveMode");
274 if ( prop
.isValid() && prop
.toBool() )
276 kDebug(1202) << "KonqView::switchView X-KDE-BrowserView-PassiveMode -> setPassiveMode";
277 setPassiveMode( true ); // set as passive
280 // Honor "linked view"
281 prop
= m_service
->property( "X-KDE-BrowserView-LinkedView");
282 if ( prop
.isValid() && prop
.toBool() )
284 setLinkedView( true ); // set as linked
285 // Two views : link both
286 if (m_pMainWindow
->viewCount() <= 2) // '1' can happen if this view is not yet in the map
288 KonqView
* otherView
= m_pMainWindow
->otherView( this );
290 otherView
->setLinkedView( true );
295 prop
= m_service
->property( "X-KDE-BrowserView-HierarchicalView");
296 if ( prop
.isValid() && prop
.toBool() )
298 kDebug() << "KonqView::switchView X-KDE-BrowserView-HierarchicalView -> setHierarchicalView";
299 setHierarchicalView( true ); // set as hierarchial
303 setHierarchicalView( false );
307 bool KonqView::changeViewMode( const QString
&serviceType
,
308 const QString
&serviceName
,
309 bool forceAutoEmbed
)
311 // Caller should call stop first.
312 assert ( !m_bLoading
);
314 kDebug(1202) << "changeViewMode: serviceType is " << serviceType
315 << " serviceName is " << serviceName
316 << " current service name is " << m_service
->desktopEntryName();
318 if ( KMimeType::mimeType(serviceType
) && KMimeType::mimeType(serviceType
)->is(m_serviceType
) && (serviceName
.isEmpty() || serviceName
== m_service
->desktopEntryName()) )
321 if ( isLockedViewMode() )
323 //kDebug(1202) << "This view's mode is locked - can't change";
324 return false; // we can't do that if our view mode is locked
327 kDebug(1202) << "Switching view modes...";
328 KService::List partServiceOffers
, appServiceOffers
;
329 KService::Ptr service
;
330 KonqFactory konqFactory
;
331 KonqViewFactory viewFactory
= konqFactory
.createView( serviceType
, serviceName
, &service
, &partServiceOffers
, &appServiceOffers
, forceAutoEmbed
);
333 if ( viewFactory
.isNull() )
335 // Revert location bar's URL to the working one
336 if(currentHistoryEntry())
337 setLocationBarURL( currentHistoryEntry()->locationBarURL
);
341 m_serviceType
= serviceType
;
342 m_partServiceOffers
= partServiceOffers
;
343 m_appServiceOffers
= appServiceOffers
;
345 // Check if that's already the kind of part we have -> no need to recreate it
346 // Note: we should have an operator= for KService...
347 if ( m_service
&& m_service
->entryPath() == service
->entryPath() )
349 kDebug( 1202 ) << "KonqView::changeViewMode. Reusing service. Service type set to " << m_serviceType
;
350 if ( m_pMainWindow
->currentView() == this )
351 m_pMainWindow
->updateViewModeActions();
357 switchView( viewFactory
);
360 if ( m_pMainWindow
->viewManager()->activePart() != m_pPart
)
362 // Make the new part active. Note that we don't do it each time we
363 // open a URL (becomes awful in view-follows-view mode), but we do
364 // each time we change the view mode.
365 // We don't do it in switchView either because it's called from the constructor too,
366 // where the location bar url isn't set yet.
367 //kDebug(1202) << "Giving focus to new part " << m_pPart;
368 m_pMainWindow
->viewManager()->setActivePart( m_pPart
);
373 void KonqView::connectPart()
375 //kDebug(1202) << "KonqView::connectPart";
376 connect( m_pPart
, SIGNAL( started( KIO::Job
* ) ),
377 this, SLOT( slotStarted( KIO::Job
* ) ) );
378 connect( m_pPart
, SIGNAL( completed() ),
379 this, SLOT( slotCompleted() ) );
380 connect( m_pPart
, SIGNAL( completed(bool) ),
381 this, SLOT( slotCompleted(bool) ) );
382 connect( m_pPart
, SIGNAL( canceled( const QString
& ) ),
383 this, SLOT( slotCanceled( const QString
& ) ) );
384 connect( m_pPart
, SIGNAL( setWindowCaption( const QString
& ) ),
385 this, SLOT( setCaption( const QString
& ) ) );
386 if (!internalViewMode().isEmpty()) {
387 // Update checked action in "View Mode" menu when switching view mode in dolphin
388 connect(m_pPart
, SIGNAL(viewModeChanged()),
389 m_pMainWindow
, SLOT(slotInternalViewModeChanged()));
392 KParts::BrowserExtension
*ext
= browserExtension();
396 ext
->setBrowserInterface( m_browserIface
);
398 connect( ext
, SIGNAL( openUrlRequestDelayed(const KUrl
&, const KParts::OpenUrlArguments
&, const KParts::BrowserArguments
&) ),
399 m_pMainWindow
, SLOT( slotOpenURLRequest( const KUrl
&, const KParts::OpenUrlArguments
&, const KParts::BrowserArguments
& ) ) );
401 if ( m_bPopupMenuEnabled
)
403 m_bPopupMenuEnabled
= false; // force
404 enablePopupMenu( true );
407 connect( ext
, SIGNAL( setLocationBarUrl( const QString
& ) ),
408 this, SLOT( setLocationBarURL( const QString
& ) ) );
410 connect( ext
, SIGNAL( setIconUrl( const KUrl
& ) ),
411 this, SLOT( setIconURL( const KUrl
& ) ) );
413 connect( ext
, SIGNAL( setPageSecurity( int ) ),
414 this, SLOT( setPageSecurity( int ) ) );
416 connect( ext
, SIGNAL( createNewWindow(const KUrl
&, const KParts::OpenUrlArguments
&, const KParts::BrowserArguments
&, const KParts::WindowArgs
&, KParts::ReadOnlyPart
**) ),
417 m_pMainWindow
, SLOT( slotCreateNewWindow( const KUrl
&, const KParts::OpenUrlArguments
&, const KParts::BrowserArguments
&, const KParts::WindowArgs
&, KParts::ReadOnlyPart
**) ) );
419 connect( ext
, SIGNAL( loadingProgress( int ) ),
420 m_pKonqFrame
->statusbar(), SLOT( slotLoadingProgress( int ) ) );
422 connect( ext
, SIGNAL( speedProgress( int ) ),
423 m_pKonqFrame
->statusbar(), SLOT( slotSpeedProgress( int ) ) );
425 connect( ext
, SIGNAL( selectionInfo( const KFileItemList
& ) ),
426 this, SLOT( slotSelectionInfo( const KFileItemList
& ) ) );
428 connect( ext
, SIGNAL( mouseOverInfo( const KFileItem
& ) ),
429 this, SLOT( slotMouseOverInfo( const KFileItem
& ) ) );
431 connect( ext
, SIGNAL( openUrlNotify() ),
432 this, SLOT( slotOpenURLNotify() ) );
434 connect( ext
, SIGNAL( enableAction( const char *, bool ) ),
435 this, SLOT( slotEnableAction( const char *, bool ) ) );
437 connect( ext
, SIGNAL( setActionText( const char *, const QString
& ) ),
438 this, SLOT( slotSetActionText( const char *, const QString
& ) ) );
440 connect( ext
, SIGNAL( moveTopLevelWidget( int, int ) ),
441 this, SLOT( slotMoveTopLevelWidget( int, int ) ) );
443 connect( ext
, SIGNAL( resizeTopLevelWidget( int, int ) ),
444 this, SLOT( slotResizeTopLevelWidget( int, int ) ) );
446 connect( ext
, SIGNAL( requestFocus(KParts::ReadOnlyPart
*) ),
447 this, SLOT( slotRequestFocus(KParts::ReadOnlyPart
*) ) );
449 if (service()->desktopEntryName() != "konq_sidebartng") {
450 connect( ext
, SIGNAL( infoMessage( const QString
& ) ),
451 m_pKonqFrame
->statusbar(), SLOT( message( const QString
& ) ) );
454 SIGNAL( addWebSideBar(const KUrl
&, const QString
&) ),
456 SLOT( slotAddWebSideBar(const KUrl
&, const QString
&) ) );
460 QVariant urlDropHandling
;
463 urlDropHandling
= ext
->property( "urlDropHandling" );
465 urlDropHandling
= QVariant( true );
467 // Handle url drops if
468 // a) either the property says "ok"
470 // b) the part is a plain krop (no BE)
471 m_bURLDropHandling
= ( urlDropHandling
.type() == QVariant::Bool
&&
472 urlDropHandling
.toBool() );
474 m_pPart
->widget()->installEventFilter( this );
476 if (m_bBackRightClick
) {
477 QAbstractScrollArea
* scrollArea
= ::qobject_cast
<QAbstractScrollArea
*>( m_pPart
->widget() );
479 scrollArea
->viewport()->installEventFilter( this );
484 // KonqDirPart signal
485 if ( ::qobject_cast
<KonqDirPart
*>(m_pPart
) )
487 connect( m_pPart
, SIGNAL( findOpen( KonqDirPart
* ) ),
488 m_pMainWindow
, SLOT( slotFindOpen( KonqDirPart
* ) ) );
493 void KonqView::slotEnableAction( const char * name
, bool enabled
)
495 if ( m_pMainWindow
->currentView() == this )
496 m_pMainWindow
->enableAction( name
, enabled
);
497 // Otherwise, we don't have to do anything, the state of the action is
498 // stored inside the browser-extension.
501 void KonqView::slotSetActionText( const char* name
, const QString
& text
)
503 if ( m_pMainWindow
->currentView() == this )
504 m_pMainWindow
->setActionText( name
, text
);
505 // Otherwise, we don't have to do anything, the state of the action is
506 // stored inside the browser-extension.
509 void KonqView::slotMoveTopLevelWidget( int x
, int y
)
511 KonqFrameContainerBase
* container
= frame()->parentContainer();
512 // If tabs are shown, only accept to move the whole window if there's only one tab.
513 if ( container
->frameType() != "Tabs" || static_cast<KonqFrameTabs
*>(container
)->count() == 1 )
514 m_pMainWindow
->move( x
, y
);
517 void KonqView::slotResizeTopLevelWidget( int w
, int h
)
519 KonqFrameContainerBase
* container
= frame()->parentContainer();
520 // If tabs are shown, only accept to resize the whole window if there's only one tab.
521 // ### Maybe we could store the size requested by each tab and resize the window to the biggest one.
522 if ( container
->frameType() != "Tabs" || static_cast<KonqFrameTabs
*>(container
)->count() == 1 )
523 m_pMainWindow
->resize( w
, h
);
526 void KonqView::slotStarted( KIO::Job
* job
)
528 //kDebug(1202) << "KonqView::slotStarted" << job;
533 // Manage passwords properly...
534 kDebug(7035) << "slotStarted: Window ID = " << m_pMainWindow
->window()->winId();
535 job
->ui()->setWindow (m_pMainWindow
->window());
537 connect( job
, SIGNAL( percent( KJob
*, unsigned long ) ), this, SLOT( slotPercent( KJob
*, unsigned long ) ) );
538 connect( job
, SIGNAL( speed( KJob
*, unsigned long ) ), this, SLOT( slotSpeed( KJob
*, unsigned long ) ) );
539 connect( job
, SIGNAL( infoMessage( KJob
*, const QString
&, const QString
& ) ), this, SLOT( slotInfoMessage( KJob
*, const QString
& ) ) );
543 void KonqView::slotRequestFocus( KParts::ReadOnlyPart
* )
545 m_pMainWindow
->viewManager()->showTab(this);
548 void KonqView::setLoading( bool loading
, bool hasPending
/*= false*/)
550 //kDebug(1202) << "KonqView::setLoading loading=" << loading << " hasPending=" << hasPending;
551 m_bLoading
= loading
;
552 m_bPendingRedirection
= hasPending
;
553 if ( m_pMainWindow
->currentView() == this )
554 m_pMainWindow
->updateToolBarActions( hasPending
);
556 m_pMainWindow
->viewManager()->setLoading( this, loading
|| hasPending
);
559 void KonqView::slotPercent( KJob
*, unsigned long percent
)
561 m_pKonqFrame
->statusbar()->slotLoadingProgress( percent
);
564 void KonqView::slotSpeed( KJob
*, unsigned long bytesPerSecond
)
566 m_pKonqFrame
->statusbar()->slotSpeedProgress( bytesPerSecond
);
569 void KonqView::slotInfoMessage( KJob
*, const QString
&msg
)
571 m_pKonqFrame
->statusbar()->message( msg
);
574 void KonqView::slotCompleted()
576 slotCompleted( false );
579 void KonqView::slotCompleted( bool hasPending
)
581 //kDebug(1202) << "KonqView::slotCompleted hasPending=" << hasPending;
582 m_pKonqFrame
->statusbar()->slotLoadingProgress( -1 );
584 if ( ! m_bLockHistory
)
586 // Success... update history entry, including location bar URL
587 updateHistoryEntry( true );
589 if ( m_bAborted
) // remove the pending entry on error
590 KonqHistoryManager::kself()->removePending( url() );
591 else if ( currentHistoryEntry() ) // register as proper history entry
592 KonqHistoryManager::kself()->confirmPending(url(), typedUrl(),
593 currentHistoryEntry()->title
);
595 emit
viewCompleted( this );
597 setLoading( false, hasPending
);
599 if (!m_bGotIconURL
&& !m_bAborted
)
601 if ( KonqSettings::enableFavicon() == true )
603 // Try to get /favicon.ico
604 if ( supportsMimeType( "text/html" ) && url().protocol().startsWith( "http" ) )
605 KonqPixmapProvider::self()->downloadHostIcon( url().url() );
610 void KonqView::slotCanceled( const QString
& errorMsg
)
612 kDebug(1202) << "KonqView::slotCanceled";
613 // The errorMsg comes from the ReadOnlyPart's job.
614 // It should probably be used in a KMessageBox
615 // Let's use the statusbar for now
616 m_pKonqFrame
->statusbar()->message( errorMsg
);
621 void KonqView::slotSelectionInfo( const KFileItemList
&items
)
623 KonqFileSelectionEvent
ev( items
, m_pPart
);
624 QApplication::sendEvent( m_pMainWindow
, &ev
);
627 void KonqView::slotMouseOverInfo( const KFileItem
& item
)
629 KonqFileMouseOverEvent
ev( item
, m_pPart
);
630 QApplication::sendEvent( m_pMainWindow
, &ev
);
633 void KonqView::setLocationBarURL( const KUrl
& locationBarURL
)
635 setLocationBarURL( locationBarURL
.pathOrUrl() );
638 void KonqView::setLocationBarURL( const QString
& locationBarURL
)
640 //kDebug(1202) << "KonqView::setLocationBarURL " << locationBarURL << " this=" << this;
642 m_sLocationBarURL
= locationBarURL
;
643 if ( m_pMainWindow
->currentView() == this )
645 //kDebug(1202) << "is current view " << this;
646 m_pMainWindow
->setLocationBarURL( m_sLocationBarURL
);
647 m_pMainWindow
->setPageSecurity( m_pageSecurity
);
649 if (!m_bPassiveMode
) setTabIcon( KUrl( m_sLocationBarURL
) );
652 void KonqView::setIconURL( const KUrl
& iconURL
)
653 // This function sets the favIcon in konqui's window if enabled,
654 // thus it is responsible for the icon in the taskbar.
655 // It does not set the tab's favIcon.
657 if ( KonqSettings::enableFavicon() )
659 KonqPixmapProvider::self()->setIconForUrl( m_sLocationBarURL
, iconURL
.url() );
660 m_bGotIconURL
= true;
664 void KonqView::setPageSecurity( int pageSecurity
)
666 m_pageSecurity
= (KonqMainWindow::PageSecurity
)pageSecurity
;
668 if ( m_pMainWindow
->currentView() == this )
669 m_pMainWindow
->setPageSecurity( m_pageSecurity
);
672 void KonqView::setTabIcon( const KUrl
&url
)
674 if (!m_bPassiveMode
) frame()->setTabIcon( url
, 0L );
677 void KonqView::setCaption( const QString
& caption
)
679 if (caption
.isEmpty()) return;
681 QString adjustedCaption
= caption
;
682 // For local URLs we prefer to use only the directory name
683 if (url().isLocalFile())
685 // Is the caption a URL? If so, is it local? If so, only display the filename!
687 if (url
.isValid() && url
.isLocalFile() && url
.fileName() == this->url().fileName())
688 adjustedCaption
= url
.fileName();
691 m_caption
= adjustedCaption
;
692 if (!m_bPassiveMode
) frame()->setTitle( adjustedCaption
, 0L );
695 void KonqView::slotOpenURLNotify()
698 kDebug(1202) << "KonqView::slotOpenURLNotify";
700 updateHistoryEntry(true);
701 createHistoryEntry();
702 if ( m_pMainWindow
->currentView() == this )
703 m_pMainWindow
->updateToolBarActions();
706 void KonqView::createHistoryEntry()
708 // First, remove any forward history
709 HistoryEntry
* current
= currentHistoryEntry();
713 kDebug(1202) << "Truncating history";
715 while ( current
!= m_lstHistory
.last() )
716 delete m_lstHistory
.takeLast();
718 // Append a new entry
720 kDebug(1202) << "Append a new entry";
722 m_lstHistory
.append( new HistoryEntry
);
723 setHistoryIndex( m_lstHistory
.count()-1 ); // made current
725 kDebug(1202) << "at=" << historyIndex() << " count=" << m_lstHistory
.count();
729 void KonqView::updateHistoryEntry( bool saveLocationBarURL
)
731 Q_ASSERT( !m_bLockHistory
); // should never happen
733 HistoryEntry
* current
= currentHistoryEntry();
737 if ( browserExtension() )
739 current
->buffer
= QByteArray(); // Start with empty buffer.
740 QDataStream
stream( ¤t
->buffer
, QIODevice::WriteOnly
);
742 browserExtension()->saveState( stream
);
746 kDebug(1202) << "Saving part URL : " << m_pPart
->url() << " in history position " << historyIndex();
748 current
->url
= m_pPart
->url();
750 if (saveLocationBarURL
)
753 kDebug(1202) << "Saving location bar URL : " << m_sLocationBarURL
<< " in history position " << historyIndex();
755 current
->locationBarURL
= m_sLocationBarURL
;
756 current
->pageSecurity
= m_pageSecurity
;
759 kDebug(1202) << "Saving title : " << m_caption
<< " in history position " << historyIndex();
761 current
->title
= m_caption
;
762 current
->strServiceType
= m_serviceType
;
763 current
->strServiceName
= m_service
->desktopEntryName();
765 current
->doPost
= m_doPost
;
766 current
->postData
= m_doPost
? m_postData
: QByteArray();
767 current
->postContentType
= m_doPost
? m_postContentType
: QString();
768 current
->pageReferrer
= m_pageReferrer
;
771 void KonqView::goHistory( int steps
)
773 // This is called by KonqBrowserInterface
774 if ( m_pMainWindow
->currentView() == this )
775 m_pMainWindow
->viewManager()->setActivePart( part() );
777 // Delay the go() call (we need to return to the caller first)
778 m_pMainWindow
->slotGoHistoryActivated( steps
);
781 void KonqView::go( int steps
)
783 if ( !steps
) // [WildFox] i bet there are sites on the net with stupid devs who do that :)
786 kDebug(1202) << "KonqView::go(0)";
788 // [David] and you're right. And they expect that it reloads, apparently.
789 // [George] I'm going to make nspluginviewer rely on this too. :-)
790 m_pMainWindow
->slotReload();
794 int newPos
= historyIndex() + steps
;
796 kDebug(1202) << "go : steps=" << steps
797 << " newPos=" << newPos
798 << " m_lstHistory.count()=" << m_lstHistory
.count();
800 if( newPos
< 0 || newPos
>= m_lstHistory
.count() )
805 setHistoryIndex( newPos
); // sets current item
808 kDebug(1202) << "New position " << historyIndex();
814 void KonqView::restoreHistory()
816 HistoryEntry
h( *currentHistoryEntry() ); // make a copy of the current history entry, as the data
817 // the pointer points to will change with the following calls
820 kDebug(1202) << "Restoring servicetype/name, and location bar URL from history : " << h
.locationBarURL
;
822 setLocationBarURL( h
.locationBarURL
);
823 setPageSecurity( h
.pageSecurity
);
825 if ( ! changeViewMode( h
.strServiceType
, h
.strServiceName
) )
827 kWarning(1202) << "Couldn't change view mode to " << h
.strServiceType
828 << " " << h
.strServiceName
;
834 aboutToOpenURL( h
.url
);
836 if ( browserExtension() )
838 //kDebug(1202) << "Restoring view from stream";
839 QDataStream
stream( h
.buffer
);
841 browserExtension()->restoreState( stream
);
844 m_postContentType
= h
.postContentType
;
845 m_postData
= h
.postData
;
846 m_pageReferrer
= h
.pageReferrer
;
849 m_pPart
->openUrl( h
.url
);
851 if ( m_pMainWindow
->currentView() == this )
852 m_pMainWindow
->updateToolBarActions();
855 kDebug(1202) << "New position (2) " << historyIndex();
859 const HistoryEntry
* KonqView::historyAt(int pos
)
861 return m_lstHistory
.value(pos
);
864 void KonqView::copyHistory( KonqView
*other
)
866 qDeleteAll( m_lstHistory
);
867 m_lstHistory
.clear();
869 foreach ( HistoryEntry
* he
, other
->m_lstHistory
)
870 m_lstHistory
.append( new HistoryEntry( *he
) );
871 setHistoryIndex(other
->historyIndex());
874 KUrl
KonqView::url() const
877 return m_pPart
->url();
880 KUrl
KonqView::upUrl() const
884 currentURL
= m_pRun
->url();
886 currentURL
= m_sLocationBarURL
;
887 return currentURL
.upUrl();
890 void KonqView::setRun( KonqRun
* run
)
894 // Tell the KonqRun to abort, but don't delete it ourselves.
895 // It could be showing a message box right now. It will delete itself anyway.
897 // finish() will be emitted later (when back to event loop)
898 // and we don't want it to call slotRunFinished (which stops the animation and stop button).
899 m_pRun
->disconnect( m_pMainWindow
);
901 frame()->unsetCursor();
904 frame()->setCursor( Qt::BusyCursor
);
908 void KonqView::stop()
910 //kDebug(1202) << "KonqView::stop()";
912 finishedWithCurrentURL();
913 if ( m_bLoading
|| m_bPendingRedirection
)
915 // aborted -> confirm the pending url. We might as well remove it, but
916 // we decided to keep it :)
917 KonqHistoryManager::kself()->confirmPending( url(), m_sTypedURL
);
919 //kDebug(1202) << "m_pPart->closeUrl()";
922 m_pKonqFrame
->statusbar()->slotLoadingProgress( -1 );
923 setLoading( false, false );
927 // Revert to working URL - unless the URL was typed manually
928 // This is duplicated with KonqMainWindow::slotRunFinished, but we can't call it
929 // since it relies on sender()...
930 if ( currentHistoryEntry() && m_pRun
->typedUrl().isEmpty() ) { // not typed
931 setLocationBarURL( currentHistoryEntry()->locationBarURL
);
932 setPageSecurity( currentHistoryEntry()->pageSecurity
);
936 m_pKonqFrame
->statusbar()->slotLoadingProgress( -1 );
938 if ( !m_bLockHistory
&& m_lstHistory
.count() > 0 )
939 updateHistoryEntry(true);
942 void KonqView::finishedWithCurrentURL()
944 if ( !m_tempFile
.isEmpty() )
946 kDebug(1202) << "######### Deleting tempfile after use:" << m_tempFile
;
947 QFile::remove( m_tempFile
);
952 void KonqView::setPassiveMode( bool mode
)
954 // In theory, if m_bPassiveMode is true and mode is false,
955 // the part should be removed from the part manager,
956 // and if the other way round, it should be readded to the part manager...
957 m_bPassiveMode
= mode
;
959 if ( mode
&& m_pMainWindow
->viewCount() > 1 && m_pMainWindow
->currentView() == this )
961 KParts::Part
* part
= m_pMainWindow
->viewManager()->chooseNextView( this )->part(); // switch active part
962 m_pMainWindow
->viewManager()->setActivePart( part
);
965 // Update statusbar stuff
966 m_pMainWindow
->viewManager()->viewCountChanged();
969 void KonqView::setHierarchicalView( bool mode
)
971 m_bHierarchicalView
=mode
;
976 void KonqView::setLinkedView( bool mode
)
978 m_bLinkedView
= mode
;
979 if ( m_pMainWindow
->currentView() == this )
980 m_pMainWindow
->linkViewAction()->setChecked( mode
);
981 frame()->statusbar()->setLinkedView( mode
);
984 void KonqView::setLockedLocation( bool b
)
986 m_bLockedLocation
= b
;
989 void KonqView::aboutToOpenURL( const KUrl
&url
, const KParts::OpenUrlArguments
&args
)
991 KParts::OpenUrlEvent
ev( m_pPart
, url
, args
);
992 QApplication::sendEvent( m_pMainWindow
, &ev
);
994 m_bGotIconURL
= false;
998 void KonqView::setPartMimeType()
1000 KParts::OpenUrlArguments
args( m_pPart
->arguments() );
1001 args
.setMimeType( m_serviceType
);
1002 m_pPart
->setArguments( args
);
1005 QStringList
KonqView::frameNames() const
1007 return childFrameNames( m_pPart
);
1010 QStringList
KonqView::childFrameNames( KParts::ReadOnlyPart
*part
)
1014 KParts::BrowserHostExtension
*hostExtension
= KParts::BrowserHostExtension::childObject( part
);
1016 if ( !hostExtension
)
1019 res
+= hostExtension
->frameNames();
1021 const QList
<KParts::ReadOnlyPart
*> children
= hostExtension
->frames();
1022 QListIterator
<KParts::ReadOnlyPart
*> i(children
);
1024 res
+= childFrameNames( i
.next() );
1029 KParts::BrowserHostExtension
* KonqView::hostExtension( KParts::ReadOnlyPart
*part
, const QString
&name
)
1031 KParts::BrowserHostExtension
*ext
= KParts::BrowserHostExtension::childObject( part
);
1036 if ( ext
->frameNames().contains( name
) )
1039 const QList
<KParts::ReadOnlyPart
*> children
= ext
->frames();
1040 QListIterator
<KParts::ReadOnlyPart
*> i(children
);
1043 KParts::BrowserHostExtension
*childHost
= hostExtension( i
.next(), name
);
1052 bool KonqView::callExtensionMethod( const char *methodName
)
1054 QObject
*obj
= KParts::BrowserExtension::childObject( m_pPart
);
1055 if ( !obj
) // not all views have a browser extension !
1058 return QMetaObject::invokeMethod( obj
, methodName
, Qt::DirectConnection
);
1061 bool KonqView::callExtensionBoolMethod( const char *methodName
, bool value
)
1063 QObject
*obj
= KParts::BrowserExtension::childObject( m_pPart
);
1064 if ( !obj
) // not all views have a browser extension !
1067 return QMetaObject::invokeMethod( obj
, methodName
, Qt::DirectConnection
, Q_ARG(bool,value
));
1070 bool KonqView::callExtensionStringMethod( const char *methodName
, const QString
&value
)
1072 QObject
*obj
= KParts::BrowserExtension::childObject( m_pPart
);
1073 if ( !obj
) // not all views have a browser extension !
1076 return QMetaObject::invokeMethod( obj
, methodName
, Qt::DirectConnection
, Q_ARG(QString
, value
));
1079 bool KonqView::callExtensionURLMethod( const char *methodName
, const KUrl
& value
)
1081 QObject
*obj
= KParts::BrowserExtension::childObject( m_pPart
);
1082 if ( !obj
) // not all views have a browser extension !
1085 return QMetaObject::invokeMethod( obj
, methodName
, Qt::DirectConnection
, Q_ARG(KUrl
, value
));
1088 void KonqView::setViewName( const QString
&name
)
1090 //kDebug() << "KonqView::setViewName this=" << this << " name=" << name;
1092 m_pPart
->setObjectName( name
);
1095 QString
KonqView::viewName() const
1097 return m_pPart
? m_pPart
->objectName() : QString();
1100 void KonqView::enablePopupMenu( bool b
)
1102 Q_ASSERT( m_pMainWindow
);
1104 KParts::BrowserExtension
*ext
= browserExtension();
1109 if ( m_bPopupMenuEnabled
== b
)
1112 // enable context popup
1114 m_bPopupMenuEnabled
= true;
1116 connect( ext
, SIGNAL(popupMenu(QPoint
,KFileItemList
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)),
1117 m_pMainWindow
, SLOT(slotPopupMenu(QPoint
,KFileItemList
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)) );
1119 connect( ext
, SIGNAL(popupMenu(QPoint
,KUrl
,mode_t
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)),
1120 m_pMainWindow
, SLOT(slotPopupMenu(QPoint
,KUrl
,mode_t
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)) );
1122 else // disable context popup
1124 m_bPopupMenuEnabled
= false;
1126 disconnect( ext
, SIGNAL(popupMenu(QPoint
,KFileItemList
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)),
1127 m_pMainWindow
, SLOT(slotPopupMenu(QPoint
,KFileItemList
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)) );
1129 disconnect( ext
, SIGNAL(popupMenu(QPoint
,KUrl
,mode_t
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)),
1130 m_pMainWindow
, SLOT(slotPopupMenu(QPoint
,KUrl
,mode_t
,KParts::OpenUrlArguments
,KParts::BrowserArguments
,KParts::BrowserExtension::PopupFlags
,KParts::BrowserExtension::ActionGroupMap
)) );
1132 enableBackRightClick( m_bBackRightClick
);
1135 // caller should ensure that this is called only when b changed, or for new parts
1136 void KonqView::enableBackRightClick( bool b
)
1138 m_bBackRightClick
= b
;
1140 connect( this, SIGNAL( backRightClick() ),
1141 m_pMainWindow
, SLOT( slotBack() ) );
1143 disconnect( this, SIGNAL( backRightClick() ),
1144 m_pMainWindow
, SLOT( slotBack() ) );
1147 void KonqView::reparseConfiguration()
1149 callExtensionMethod( "reparseConfiguration" );
1150 const bool b
= KonqSettings::backRightClick();
1151 if ( m_bBackRightClick
!= b
) {
1152 QAbstractScrollArea
* scrollArea
= ::qobject_cast
<QAbstractScrollArea
*>( m_pPart
->widget() );
1154 if ( m_bBackRightClick
) {
1155 scrollArea
->viewport()->installEventFilter( this );
1157 scrollArea
->viewport()->removeEventFilter( this );
1160 enableBackRightClick( b
);
1164 void KonqView::disableScrolling()
1166 m_bDisableScrolling
= true;
1167 callExtensionMethod( "disableScrolling" );
1170 QString
KonqView::dbusObjectPath()
1172 // TODO maybe this can be improved?
1173 // E.g. using the part's name, but we'd have to update the name in setViewName maybe?
1174 // And to make sure it's a valid dbus object path like in kmainwindow...
1175 static int s_viewNumber
= 0;
1176 if ( m_dbusObjectPath
.isEmpty() ) {
1177 m_dbusObjectPath
= m_pMainWindow
->dbusName() + '/' + QString::number( ++s_viewNumber
);
1178 new KonqViewAdaptor( this );
1179 QDBusConnection::sessionBus().registerObject( m_dbusObjectPath
, this );
1181 return m_dbusObjectPath
;
1184 QString
KonqView::partObjectPath()
1189 const QVariant dcopProperty
= m_pPart
->property( "dbusObjectPath" );
1190 return dcopProperty
.toString();
1193 bool KonqView::eventFilter( QObject
*obj
, QEvent
*e
)
1197 // kDebug() << "--" << obj->className() << "--" << e->type() << "--" ;
1198 if ( e
->type() == QEvent::DragEnter
&& m_bURLDropHandling
&& obj
== m_pPart
->widget() )
1200 QDragEnterEvent
*ev
= static_cast<QDragEnterEvent
*>( e
);
1202 if ( KUrl::List::canDecode( ev
->mimeData() ) )
1204 KUrl::List lstDragURLs
= KUrl::List::fromMimeData( ev
->mimeData() );
1206 QList
<QWidget
*> children
= qFindChildren
<QWidget
*>( m_pPart
->widget() );
1208 if ( !lstDragURLs
.isEmpty()
1209 && !lstDragURLs
.first().url().startsWith( "javascript:", Qt::CaseInsensitive
) && // ### this looks like a hack to me
1210 ev
->source() != m_pPart
->widget() &&
1211 !children
.contains( ev
->source() ) )
1212 ev
->acceptProposedAction();
1215 else if ( e
->type() == QEvent::Drop
&& m_bURLDropHandling
&& obj
== m_pPart
->widget() )
1217 QDropEvent
*ev
= static_cast<QDropEvent
*>( e
);
1219 KUrl::List lstDragURLs
= KUrl::List::fromMimeData( ev
->mimeData() );
1220 KParts::BrowserExtension
*ext
= browserExtension();
1221 if ( !lstDragURLs
.isEmpty() && ext
&& lstDragURLs
.first().isValid() )
1222 emit ext
->openUrlRequest( lstDragURLs
.first() ); // this will call m_pMainWindow::slotOpenURLRequest delayed
1225 if ( m_bBackRightClick
)
1227 if ( e
->type() == QEvent::ContextMenu
)
1229 QContextMenuEvent
*ev
= static_cast<QContextMenuEvent
*>( e
);
1230 if ( ev
->reason() == QContextMenuEvent::Mouse
)
1235 else if ( e
->type() == QEvent::MouseButtonPress
)
1237 QMouseEvent
*ev
= static_cast<QMouseEvent
*>( e
);
1238 if ( ev
->button() == Qt::RightButton
)
1243 else if ( e
->type() == QEvent::MouseButtonRelease
)
1245 QMouseEvent
*ev
= static_cast<QMouseEvent
*>( e
);
1246 if ( ev
->button() == Qt::RightButton
)
1248 emit
backRightClick();
1252 else if ( e
->type() == QEvent::MouseMove
)
1254 QMouseEvent
*ev
= static_cast<QMouseEvent
*>( e
);
1255 if ( ev
->button() == Qt::RightButton
)
1257 obj
->removeEventFilter( this );
1258 QMouseEvent
me( QEvent::MouseButtonPress
, ev
->pos(), Qt::RightButton
, Qt::RightButton
, Qt::NoModifier
);
1259 QApplication::sendEvent( obj
, &me
);
1260 QContextMenuEvent
ce( QContextMenuEvent::Mouse
, ev
->pos(), ev
->globalPos() );
1261 QApplication::sendEvent( obj
, &ce
);
1262 obj
->installEventFilter( this );
1268 if ( e
->type() == QEvent::FocusIn
)
1270 setActiveComponent();
1275 void KonqView::setActiveComponent()
1277 if ( m_bBuiltinView
|| !m_pPart
->componentData().isValid() /*never!*/)
1278 KGlobal::setActiveComponent( KGlobal::mainComponent() );
1280 KGlobal::setActiveComponent( m_pPart
->componentData() );
1283 bool KonqView::prepareReload( KParts::OpenUrlArguments
& args
, KParts::BrowserArguments
& browserArgs
, bool softReload
)
1285 args
.setReload( true );
1287 browserArgs
.softReload
= true;
1289 // Repost form data if this URL is the result of a POST HTML form.
1290 if ( m_doPost
&& !browserArgs
.redirectedRequest() )
1292 if ( KMessageBox::warningContinueCancel( 0, i18n(
1293 "The page you are trying to view is the result of posted form data. "
1294 "If you resend the data, any action the form carried out (such as search or online purchase) will be repeated. "),
1295 i18n( "Warning" ), KGuiItem(i18n( "Resend" )) ) == KMessageBox::Continue
)
1297 browserArgs
.setDoPost( true );
1298 browserArgs
.setContentType( m_postContentType
);
1299 browserArgs
.postData
= m_postData
;
1305 args
.metaData()["referrer"] = m_pageReferrer
;
1310 KParts::BrowserExtension
* KonqView::browserExtension() const
1312 return KParts::BrowserExtension::childObject( m_pPart
);
1315 KParts::StatusBarExtension
* KonqView::statusBarExtension() const
1317 return KParts::StatusBarExtension::childObject( m_pPart
);
1320 bool KonqView::supportsMimeType( const QString
&mimeType
) const
1322 KMimeType::Ptr mime
= KMimeType::mimeType( mimeType
);
1325 const QStringList lst
= serviceTypes();
1326 for( QStringList::ConstIterator it
= lst
.begin(); it
!= lst
.end(); ++it
) {
1327 if ( mime
->is(*it
) ) // same as mime == *it, but also respect inheritance, mimeType can be a subclass
1333 void HistoryEntry::saveConfig( KConfigGroup
& config
, const QString
&prefix
)
1335 config
.writeEntry( QString::fromLatin1( "Url" ).prepend( prefix
), url
.url() );
1336 config
.writeEntry( QString::fromLatin1( "LocationBarURL" ).prepend( prefix
), locationBarURL
);
1337 config
.writeEntry( QString::fromLatin1( "Title" ).prepend( prefix
), title
);
1338 config
.writeEntry( QString::fromLatin1( "Buffer" ).prepend( prefix
), buffer
);
1339 config
.writeEntry( QString::fromLatin1( "StrServiceType" ).prepend( prefix
), strServiceType
);
1340 config
.writeEntry( QString::fromLatin1( "StrServiceName" ).prepend( prefix
), strServiceName
);
1341 config
.writeEntry( QString::fromLatin1( "PostData" ).prepend( prefix
), postData
);
1342 config
.writeEntry( QString::fromLatin1( "PostContentType" ).prepend( prefix
), postContentType
);
1343 config
.writeEntry( QString::fromLatin1( "DoPost" ).prepend( prefix
), doPost
);
1344 config
.writeEntry( QString::fromLatin1( "PageReferrer" ).prepend( prefix
), pageReferrer
);
1345 config
.writeEntry( QString::fromLatin1( "PageSecurity" ).prepend( prefix
), (int)pageSecurity
);
1348 void HistoryEntry::loadItem( const KConfigGroup
& config
, const QString
&prefix
)
1350 url
= KUrl(config
.readEntry( QString::fromLatin1( "Url" ).prepend( prefix
), "" ));
1351 locationBarURL
= config
.readEntry( QString::fromLatin1( "LocationBarURL" ).prepend( prefix
), "" );
1352 title
= config
.readEntry( QString::fromLatin1( "Title" ).prepend( prefix
), "" );
1353 buffer
= config
.readEntry( QString::fromLatin1( "Buffer" ).prepend( prefix
), QByteArray() );
1354 strServiceType
= config
.readEntry( QString::fromLatin1( "StrServiceType" ).prepend( prefix
), "" );
1355 strServiceName
= config
.readEntry( QString::fromLatin1( "StrServiceName" ).prepend( prefix
), "" );
1356 postData
= config
.readEntry( QString::fromLatin1( "PostData" ).prepend( prefix
), QByteArray() );
1357 postContentType
= config
.readEntry( QString::fromLatin1( "PostContentType" ).prepend( prefix
), "" );
1358 doPost
= config
.readEntry( QString::fromLatin1( "DoPost" ).prepend( prefix
), false );
1359 pageReferrer
= config
.readEntry( QString::fromLatin1( "PageReferrer" ).prepend( prefix
), "" );
1360 pageSecurity
= (KonqMainWindow::PageSecurity
)config
.readEntry( QString::fromLatin1( "PageSecurity" ).prepend( prefix
), 0 );
1363 void KonqView::saveConfig( KConfigGroup
& config
, const QString
&prefix
, const KonqFrameBase::Options
&options
)
1365 config
.writeEntry( QString::fromLatin1( "ServiceType" ).prepend( prefix
), serviceType() );
1366 config
.writeEntry( QString::fromLatin1( "ServiceName" ).prepend( prefix
), service()->desktopEntryName() );
1367 config
.writeEntry( QString::fromLatin1( "PassiveMode" ).prepend( prefix
), isPassiveMode() );
1368 config
.writeEntry( QString::fromLatin1( "LinkedView" ).prepend( prefix
), isLinkedView() );
1369 config
.writeEntry( QString::fromLatin1( "ToggleView" ).prepend( prefix
), isToggleView() );
1370 config
.writeEntry( QString::fromLatin1( "LockedLocation" ).prepend( prefix
), isLockedLocation() );
1372 if (options
& KonqFrameBase::saveURLs
) {
1373 config
.writePathEntry( QString::fromLatin1( "URL" ).prepend( prefix
), url().url() );
1374 } else if(options
& KonqFrameBase::saveHistoryItems
) {
1376 updateHistoryEntry(true);
1377 QList
<HistoryEntry
*>::Iterator it
= m_lstHistory
.begin();
1378 for ( uint i
= 0; it
!= m_lstHistory
.end(); ++it
, ++i
) {
1379 (*it
)->saveConfig(config
, QString::fromLatin1( "HistoryItem" ) + QString::number(i
).prepend( prefix
));
1381 config
.writeEntry( QString::fromLatin1( "CurrentHistoryItem" ).prepend( prefix
), m_lstHistoryIndex
);
1382 config
.writeEntry( QString::fromLatin1( "NumberOfHistoryItems" ).prepend( prefix
), historyLength() );
1386 void KonqView::loadHistoryConfig(const KConfigGroup
& config
, const QString
&prefix
)
1388 // First, remove any history
1389 qDeleteAll(m_lstHistory
);
1390 m_lstHistory
.clear();
1392 const int m_lstHistorySize
= config
.readEntry( QString::fromLatin1( "NumberOfHistoryItems" ).prepend( prefix
), 0 );
1394 // No history to restore..
1395 if (m_lstHistorySize
== 0) {
1396 createHistoryEntry();
1400 // restore history list
1401 for ( int i
= 0; i
< m_lstHistorySize
; ++i
)
1403 HistoryEntry
* historyEntry
= new HistoryEntry
;
1404 historyEntry
->loadItem(config
, QString::fromLatin1( "HistoryItem" ) + QString::number(i
).prepend( prefix
));
1406 m_lstHistory
.append( historyEntry
);
1409 // set and load the correct history index
1410 setHistoryIndex( config
.readEntry( QString::fromLatin1( "CurrentHistoryItem" ).prepend( prefix
), historyLength()-1 ) );
1415 QString
KonqView::internalViewMode() const
1417 const QVariant viewModeProperty
= m_pPart
->property("currentViewMode");
1418 return viewModeProperty
.toString();
1421 void KonqView::setInternalViewMode(const QString
& viewMode
)
1423 m_pPart
->setProperty("currentViewMode", viewMode
);
1426 #include "konqview.moc"