00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#include <assert.h>
00029
#include "khtml_ext.h"
00030
#include "khtmlview.h"
00031
#include "khtml_pagecache.h"
00032
#include "rendering/render_form.h"
00033
#include "dom/html_form.h"
00034
#include "dom/html_image.h"
00035
#include <qclipboard.h>
00036
#include <qfileinfo.h>
00037
#include <qpopupmenu.h>
00038
#include <qmetaobject.h>
00039
#include <private/qucomextra_p.h>
00040
00041
#include <kdebug.h>
00042
#include <klocale.h>
00043
#include <kfiledialog.h>
00044
#include <kio/job.h>
00045
#include <kprocess.h>
00046
#include <ktoolbarbutton.h>
00047
#include <ktoolbar.h>
00048
#include <ksavefile.h>
00049
#include <kurldrag.h>
00050
#include <kstringhandler.h>
00051
#include <kapplication.h>
00052
#include <kmessagebox.h>
00053
#include <kstandarddirs.h>
00054
#include <krun.h>
00055
00056
#include "dom/dom_element.h"
00057
#include "misc/htmltags.h"
00058
00059 KHTMLPartBrowserExtension::KHTMLPartBrowserExtension(
KHTMLPart *parent,
const char *name )
00060 : KParts::BrowserExtension( parent,
name )
00061 {
00062 m_part = parent;
00063 setURLDropHandlingEnabled(
true );
00064
00065 enableAction(
"cut",
false );
00066 enableAction(
"copy",
false );
00067 enableAction(
"paste",
false );
00068
00069 m_connectedToClipboard =
false;
00070 }
00071
00072
int KHTMLPartBrowserExtension::xOffset()
00073 {
00074
return m_part->
view()->
contentsX();
00075 }
00076
00077
int KHTMLPartBrowserExtension::yOffset()
00078 {
00079
return m_part->
view()->
contentsY();
00080 }
00081
00082
void KHTMLPartBrowserExtension::saveState(
QDataStream &stream )
00083 {
00084
kdDebug( 6050 ) <<
"saveState!" <<
endl;
00085 m_part->
saveState( stream );
00086 }
00087
00088
void KHTMLPartBrowserExtension::restoreState(
QDataStream &stream )
00089 {
00090
kdDebug( 6050 ) <<
"restoreState!" <<
endl;
00091 m_part->
restoreState( stream );
00092 }
00093
00094
void KHTMLPartBrowserExtension::editableWidgetFocused(
QWidget *widget )
00095 {
00096 m_editableFormWidget = widget;
00097 updateEditActions();
00098
00099
if ( !m_connectedToClipboard && m_editableFormWidget )
00100 {
00101
connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
00102
this, SLOT( updateEditActions() ) );
00103
00104
if ( m_editableFormWidget->inherits(
"QLineEdit" ) || m_editableFormWidget->inherits(
"QTextEdit" ) )
00105
connect( m_editableFormWidget, SIGNAL( selectionChanged() ),
00106
this, SLOT( updateEditActions() ) );
00107
00108 m_connectedToClipboard =
true;
00109 }
00110 editableWidgetFocused();
00111 }
00112
00113
void KHTMLPartBrowserExtension::editableWidgetBlurred(
QWidget *widget )
00114 {
00115
QWidget *oldWidget = m_editableFormWidget;
00116
00117 m_editableFormWidget = 0;
00118
enableAction(
"cut",
false );
00119
enableAction(
"paste",
false );
00120 m_part->
emitSelectionChanged();
00121
00122
if ( m_connectedToClipboard )
00123 {
00124
disconnect( QApplication::clipboard(), SIGNAL( dataChanged() ),
00125
this, SLOT( updateEditActions() ) );
00126
00127
if ( oldWidget )
00128 {
00129
if ( oldWidget->inherits(
"QLineEdit" ) || oldWidget->inherits(
"QTextEdit" ) )
00130
disconnect( oldWidget, SIGNAL( selectionChanged() ),
00131
this, SLOT( updateEditActions() ) );
00132 }
00133
00134 m_connectedToClipboard =
false;
00135 }
00136 editableWidgetBlurred();
00137 }
00138
00139
void KHTMLPartBrowserExtension::setExtensionProxy(
KParts::BrowserExtension *proxy )
00140 {
00141
if ( m_extensionProxy )
00142 {
00143
disconnect( m_extensionProxy, SIGNAL(
enableAction(
const char *,
bool ) ),
00144
this, SLOT( extensionProxyActionEnabled(
const char *,
bool ) ) );
00145
if ( m_extensionProxy->inherits(
"KHTMLPartBrowserExtension" ) )
00146 {
00147
disconnect( m_extensionProxy, SIGNAL( editableWidgetFocused() ),
00148
this, SLOT( extensionProxyEditableWidgetFocused() ) );
00149
disconnect( m_extensionProxy, SIGNAL( editableWidgetBlurred() ),
00150
this, SLOT( extensionProxyEditableWidgetBlurred() ) );
00151 }
00152 }
00153
00154 m_extensionProxy = proxy;
00155
00156
if ( m_extensionProxy )
00157 {
00158
connect( m_extensionProxy, SIGNAL(
enableAction(
const char *,
bool ) ),
00159
this, SLOT( extensionProxyActionEnabled(
const char *,
bool ) ) );
00160
if ( m_extensionProxy->inherits(
"KHTMLPartBrowserExtension" ) )
00161 {
00162
connect( m_extensionProxy, SIGNAL( editableWidgetFocused() ),
00163
this, SLOT( extensionProxyEditableWidgetFocused() ) );
00164
connect( m_extensionProxy, SIGNAL( editableWidgetBlurred() ),
00165
this, SLOT( extensionProxyEditableWidgetBlurred() ) );
00166 }
00167
00168
enableAction(
"cut", m_extensionProxy->isActionEnabled(
"cut" ) );
00169
enableAction(
"copy", m_extensionProxy->isActionEnabled(
"copy" ) );
00170
enableAction(
"paste", m_extensionProxy->isActionEnabled(
"paste" ) );
00171 }
00172
else
00173 {
00174 updateEditActions();
00175
enableAction(
"copy",
false );
00176 }
00177 }
00178
00179
void KHTMLPartBrowserExtension::cut()
00180 {
00181
if ( m_extensionProxy )
00182 {
00183 callExtensionProxyMethod(
"cut()" );
00184
return;
00185 }
00186
00187
if ( !m_editableFormWidget )
00188
return;
00189
00190
if ( m_editableFormWidget->inherits(
"QLineEdit" ) )
00191 static_cast<QLineEdit *>( &(*m_editableFormWidget) )->cut();
00192
else if ( m_editableFormWidget->inherits(
"QTextEdit" ) )
00193 static_cast<QTextEdit *>( &(*m_editableFormWidget) )->cut();
00194 }
00195
00196
void KHTMLPartBrowserExtension::copy()
00197 {
00198
if ( m_extensionProxy )
00199 {
00200 callExtensionProxyMethod(
"copy()" );
00201
return;
00202 }
00203
00204
kdDebug( 6050 ) <<
"************! KHTMLPartBrowserExtension::copy()" <<
endl;
00205
if ( !m_editableFormWidget )
00206 {
00207
00208
QString text = m_part->
selectedText();
00209 text.
replace(
QChar( 0xa0 ),
' ' );
00210
QClipboard *cb =
QApplication::clipboard();
00211
disconnect( cb, SIGNAL( selectionChanged() ), m_part, SLOT( slotClearSelection() ) );
00212 cb->
setText(text);
00213
connect( cb, SIGNAL( selectionChanged() ), m_part, SLOT( slotClearSelection() ) );
00214 }
00215
else
00216 {
00217
if ( m_editableFormWidget->inherits(
"QLineEdit" ) )
00218 static_cast<QLineEdit *>( &(*m_editableFormWidget) )->copy();
00219
else if ( m_editableFormWidget->inherits(
"QTextEdit" ) )
00220 static_cast<QTextEdit *>( &(*m_editableFormWidget) )->copy();
00221 }
00222 }
00223
00224
void KHTMLPartBrowserExtension::paste()
00225 {
00226
if ( m_extensionProxy )
00227 {
00228 callExtensionProxyMethod(
"paste()" );
00229
return;
00230 }
00231
00232
if ( !m_editableFormWidget )
00233
return;
00234
00235
if ( m_editableFormWidget->inherits(
"QLineEdit" ) )
00236 static_cast<QLineEdit *>( &(*m_editableFormWidget) )->paste();
00237
else if ( m_editableFormWidget->inherits(
"QTextEdit" ) )
00238 static_cast<QTextEdit *>( &(*m_editableFormWidget) )->paste();
00239 }
00240
00241
void KHTMLPartBrowserExtension::callExtensionProxyMethod(
const char *method )
00242 {
00243
if ( !m_extensionProxy )
00244
return;
00245
00246
int slot = m_extensionProxy->metaObject()->findSlot( method );
00247
if ( slot == -1 )
00248
return;
00249
00250 QUObject o[ 1 ];
00251 m_extensionProxy->qt_invoke( slot, o );
00252 }
00253
00254
void KHTMLPartBrowserExtension::updateEditActions()
00255 {
00256
if ( !m_editableFormWidget )
00257 {
00258
enableAction(
"cut",
false );
00259
enableAction(
"paste",
false );
00260
return;
00261 }
00262
00263
00264
#ifndef QT_NO_MIMECLIPBOARD // Handle minimalized versions of Qt Embedded
00265
QMimeSource *data =
QApplication::clipboard()->data();
00266
enableAction(
"paste", data->
provides(
"text/plain" ) );
00267
#else
00268
QString data=
QApplication::clipboard()->text();
00269
enableAction(
"paste", data.
contains(
"://"));
00270
#endif
00271
00272
bool hasSelection =
false;
00273
00274
if ( m_editableFormWidget->inherits(
"QLineEdit" ) ) {
00275 hasSelection = static_cast<QLineEdit *>( &(*m_editableFormWidget) )->hasSelectedText();
00276 }
00277
else if ( m_editableFormWidget->inherits(
"QTextEdit" ) )
00278 {
00279 hasSelection = static_cast<QTextEdit *>( &(*m_editableFormWidget) )->hasSelectedText();
00280 }
00281
00282
enableAction(
"copy", hasSelection );
00283
enableAction(
"cut", hasSelection );
00284 }
00285
00286
void KHTMLPartBrowserExtension::extensionProxyEditableWidgetFocused() {
00287 editableWidgetFocused();
00288 }
00289
00290
void KHTMLPartBrowserExtension::extensionProxyEditableWidgetBlurred() {
00291 editableWidgetBlurred();
00292 }
00293
00294
void KHTMLPartBrowserExtension::extensionProxyActionEnabled(
const char *action,
bool enable )
00295 {
00296
00297
if ( strcmp( action,
"cut" ) == 0 ||
00298 strcmp( action,
"copy" ) == 0 ||
00299 strcmp( action,
"paste" ) == 0 ) {
00300
enableAction( action, enable );
00301 }
00302 }
00303
00304
void KHTMLPartBrowserExtension::reparseConfiguration()
00305 {
00306 m_part->
reparseConfiguration();
00307 }
00308
00309
void KHTMLPartBrowserExtension::print()
00310 {
00311 m_part->
view()->
print();
00312 }
00313
00314
class KHTMLPopupGUIClient::KHTMLPopupGUIClientPrivate
00315 {
00316
public:
00317
KHTMLPart *m_khtml;
00318
KURL m_url;
00319
KURL m_imageURL;
00320 };
00321
00322
00323 KHTMLPopupGUIClient::KHTMLPopupGUIClient(
KHTMLPart *khtml,
const QString &doc,
const KURL &url )
00324 :
QObject( khtml )
00325 {
00326 d =
new KHTMLPopupGUIClientPrivate;
00327 d->m_khtml = khtml;
00328 d->
m_url = url;
00329
bool isImage =
false;
00330 setInstance( khtml->
instance() );
00331
00332
DOM::Element e;
00333 e = khtml->
nodeUnderMouse();
00334
00335
if ( !e.
isNull() && (e.
elementId() == ID_IMG ||
00336 (e.
elementId() == ID_INPUT && !static_cast<DOM::HTMLInputElement>(e).src().isEmpty())))
00337 {
00338 isImage=
true;
00339 }
00340
00341
if ( url.
isEmpty() && !isImage )
00342 {
00343
KAction* copyAction =
KStdAction::copy( d->m_khtml->browserExtension(), SLOT(
copy() ), actionCollection(),
"copy" );
00344 copyAction->
setText(i18n(
"&Copy Text"));
00345 copyAction->
setEnabled(d->m_khtml->browserExtension()->isActionEnabled(
"copy" ));
00346 actionCollection()->insert( khtml->
actionCollection()->
action(
"selectAll" ) );
00347 actionCollection()->insert( khtml->
actionCollection()->
action(
"security" ) );
00348 actionCollection()->insert( khtml->
actionCollection()->
action(
"setEncoding" ) );
00349
new KAction( i18n(
"Stop Animations" ), 0,
this, SLOT( slotStopAnimations() ),
00350 actionCollection(),
"stopanimations" );
00351 }
00352
00353
if ( !url.
isEmpty() )
00354 {
00355
new KAction( i18n(
"&Save Link As..." ), 0,
this, SLOT( slotSaveLinkAs() ),
00356 actionCollection(),
"savelinkas" );
00357
new KAction( i18n(
"Copy Link Location" ), 0,
this, SLOT( slotCopyLinkLocation() ),
00358 actionCollection(),
"copylinklocation" );
00359 }
00360
00361
00362
if ( khtml->
parentPart() )
00363 {
00364
new KAction( i18n(
"Open in New &Window" ),
"window_new", 0,
this, SLOT( slotFrameInWindow() ),
00365 actionCollection(),
"frameinwindow" );
00366
new KAction( i18n(
"Open in &New Tab" ),
"tab_new", 0,
this, SLOT( slotFrameInTab() ),
00367 actionCollection(),
"frameintab" );
00368
new KAction( i18n(
"Reload Frame" ), 0,
this, SLOT( slotReloadFrame() ),
00369 actionCollection(),
"reloadframe" );
00370
new KAction( i18n(
"View Frame Source" ), 0, d->m_khtml, SLOT( slotViewDocumentSource() ),
00371 actionCollection(),
"viewFrameSource" );
00372
new KAction( i18n(
"View Frame Information" ), 0, d->m_khtml, SLOT( slotViewPageInfo() ), actionCollection(),
"viewFrameInfo" );
00373
00374
00375
00376
new KAction( i18n(
"Print Frame..." ),
"frameprint", 0, d->m_khtml->browserExtension(), SLOT(
print() ), actionCollection(),
"printFrame" );
00377
00378 actionCollection()->insert( khtml->
parentPart()->
actionCollection()->
action(
"viewDocumentSource" ) );
00379 actionCollection()->insert( khtml->
parentPart()->
actionCollection()->
action(
"viewPageInfo" ) );
00380 }
else {
00381 actionCollection()->insert( khtml->
actionCollection()->
action(
"viewDocumentSource" ) );
00382 actionCollection()->insert( khtml->
actionCollection()->
action(
"viewPageInfo" ) );
00383 }
00384
00385
if (isImage)
00386 {
00387
if ( e.
elementId() == ID_IMG )
00388 d->m_imageURL =
KURL( static_cast<DOM::HTMLImageElement>( e ).src().string() );
00389
else
00390 d->m_imageURL =
KURL( static_cast<DOM::HTMLInputElement>( e ).src().string() );
00391
new KAction( i18n(
"Save Image As..." ), 0,
this, SLOT( slotSaveImageAs() ),
00392 actionCollection(),
"saveimageas" );
00393
new KAction( i18n(
"Send Image" ), 0,
this, SLOT( slotSendImage() ),
00394 actionCollection(),
"sendimage" );
00395
00396
00397
new KAction( i18n(
"Copy Image Location" ), 0,
this, SLOT( slotCopyImageLocation() ),
00398 actionCollection(),
"copyimagelocation" );
00399
QString name =
KStringHandler::csqueeze(d->m_imageURL.fileName()+d->m_imageURL.query(), 25);
00400
new KAction( i18n(
"View Image (%1)" ).arg(
name.
replace(
"&",
"&&")), 0,
this, SLOT( slotViewImage() ),
00401 actionCollection(),
"viewimage" );
00402 }
00403
00404 setXML( doc );
00405 setDOMDocument(
QDomDocument(),
true );
00406
00407
QDomElement menu = domDocument().documentElement().namedItem(
"Menu" ).toElement();
00408
00409
if ( actionCollection()->count() > 0 )
00410 menu.insertBefore( domDocument().createElement(
"separator" ), menu.firstChild() );
00411 }
00412
00413 KHTMLPopupGUIClient::~KHTMLPopupGUIClient()
00414 {
00415
delete d;
00416 }
00417
00418
void KHTMLPopupGUIClient::slotSaveLinkAs()
00419 {
00420
KIO::MetaData metaData;
00421 metaData[
"referrer"] = d->m_khtml->referrer();
00422 saveURL( d->m_khtml->widget(), i18n(
"Save Link As" ), d->m_url, metaData );
00423 }
00424
00425
void KHTMLPopupGUIClient::slotSendImage()
00426 {
00427
QStringList urls;
00428 urls.append( d->m_imageURL.url());
00429
QString subject = d->m_imageURL.url();
00430 kapp->invokeMailer(QString::null, QString::null, QString::null, subject,
00431 QString::null,
00432 QString::null,
00433 urls);
00434
00435
00436 }
00437
00438
void KHTMLPopupGUIClient::slotSaveImageAs()
00439 {
00440
KIO::MetaData metaData;
00441 metaData[
"referrer"] = d->m_khtml->referrer();
00442 saveURL( d->m_khtml->widget(), i18n(
"Save Image As" ), d->m_imageURL, metaData );
00443 }
00444
00445
void KHTMLPopupGUIClient::slotCopyLinkLocation()
00446 {
00447
#ifndef QT_NO_MIMECLIPBOARD
00448
00449
KURL::List lst;
00450 lst.
append( d->m_url );
00451
QApplication::clipboard()->setSelectionMode(
true);
00452
QApplication::clipboard()->setData(
new KURLDrag( lst ) );
00453
QApplication::clipboard()->setSelectionMode(
false);
00454
QApplication::clipboard()->setData(
new KURLDrag( lst ) );
00455
#else
00456
QApplication::clipboard()->setText( d->m_url.url() );
00457
#endif
00458
}
00459
00460
void KHTMLPopupGUIClient::slotStopAnimations()
00461 {
00462 d->m_khtml->stopAnimations();
00463 }
00464
00465
void KHTMLPopupGUIClient::slotCopyImageLocation()
00466 {
00467
#ifndef QT_NO_MIMECLIPBOARD
00468
00469
KURL::List lst;
00470 lst.
append( d->m_imageURL);
00471
QApplication::clipboard()->setSelectionMode(
true);
00472
QApplication::clipboard()->setData(
new KURLDrag( lst ) );
00473
QApplication::clipboard()->setSelectionMode(
false);
00474
QApplication::clipboard()->setData(
new KURLDrag( lst ) );
00475
#else
00476
QApplication::clipboard()->setText(d->m_imageURL.url());
00477
#endif
00478
}
00479
00480
void KHTMLPopupGUIClient::slotViewImage()
00481 {
00482 d->m_khtml->browserExtension()->createNewWindow(d->m_imageURL);
00483 }
00484
00485
void KHTMLPopupGUIClient::slotReloadFrame()
00486 {
00487
KParts::URLArgs args( d->m_khtml->browserExtension()->urlArgs() );
00488 args.reload =
true;
00489 args.metaData()[
"referrer"] = d->m_khtml->pageReferrer();
00490
00491 d->m_khtml->closeURL();
00492 d->m_khtml->browserExtension()->setURLArgs( args );
00493 d->m_khtml->openURL( d->m_khtml->url() );
00494 }
00495
00496
void KHTMLPopupGUIClient::slotFrameInWindow()
00497 {
00498
KParts::URLArgs args( d->m_khtml->browserExtension()->urlArgs() );
00499 args.metaData()[
"referrer"] = d->m_khtml->pageReferrer();
00500 args.metaData()[
"forcenewwindow"] =
"true";
00501 emit d->m_khtml->browserExtension()->createNewWindow( d->m_khtml->url(), args );
00502 }
00503
00504
void KHTMLPopupGUIClient::slotFrameInTab()
00505 {
00506
KParts::URLArgs args( d->m_khtml->browserExtension()->urlArgs() );
00507 args.metaData()[
"referrer"] = d->m_khtml->pageReferrer();
00508 args.setNewTab(
true);
00509 emit d->m_khtml->browserExtension()->createNewWindow( d->m_khtml->url(), args );
00510 }
00511
00512
void KHTMLPopupGUIClient::saveURL(
QWidget *parent,
const QString &caption,
00513
const KURL &url,
00514
const QMap<QString, QString> &metadata,
00515
const QString &filter,
long cacheId,
00516
const QString & suggestedFilename )
00517 {
00518
QString name =
QString::fromLatin1(
"index.html" );
00519
if ( !suggestedFilename.
isEmpty() )
00520
name = suggestedFilename;
00521
else if ( !url.
fileName().
isEmpty() )
00522
name = url.
fileName();
00523
00524
KURL destURL;
00525
int query;
00526
do {
00527 query = KMessageBox::Yes;
00528 destURL =
KFileDialog::getSaveURL( name, filter, parent, caption );
00529
if( destURL.
isLocalFile() )
00530 {
00531
QFileInfo info( destURL.
path() );
00532
if( info.exists() )
00533 query =
KMessageBox::warningYesNo( parent, i18n(
"A file named \"%1\" already exists. " "Are you sure you want to overwrite it?" ).arg( info.fileName() ), i18n(
"Overwrite File?" ), i18n(
"Overwrite" ), KStdGuiItem::cancel() );
00534 }
00535 }
while ( query == KMessageBox::No );
00536
00537
if ( destURL.
isValid() )
00538 saveURL(url, destURL, metadata, cacheId);
00539 }
00540
00541
void KHTMLPopupGUIClient::saveURL(
const KURL &url,
const KURL &destURL,
00542
const QMap<QString, QString> &metadata,
00543
long cacheId )
00544 {
00545
if ( destURL.
isValid() )
00546 {
00547
bool saved =
false;
00548
if (
KHTMLPageCache::self()->
isComplete(cacheId))
00549 {
00550
if (destURL.
isLocalFile())
00551 {
00552
KSaveFile destFile(destURL.
path());
00553
if (destFile.status() == 0)
00554 {
00555
KHTMLPageCache::self()->
saveData(cacheId, destFile.dataStream());
00556 saved =
true;
00557 }
00558 }
00559
else
00560 {
00561
00562
KTempFile destFile;
00563
if (destFile.
status() == 0)
00564 {
00565
KHTMLPageCache::self()->
saveData(cacheId, destFile.
dataStream());
00566 destFile.
close();
00567
KURL url2 =
KURL();
00568 url2.
setPath(destFile.
name());
00569
KIO::move(url2, destURL);
00570 saved =
true;
00571 }
00572 }
00573 }
00574
if(!saved)
00575 {
00576
00577
00578
00579
00580
bool downloadViaKIO =
true;
00581
if ( !url.
isLocalFile() )
00582 {
00583
KConfig cfg(
"konquerorrc",
false,
false);
00584 cfg.setGroup(
"HTML Settings");
00585
QString downloadManger = cfg.readPathEntry(
"DownloadManager");
00586
if (!downloadManger.
isEmpty())
00587 {
00588
00589
kdDebug(1000) <<
"Using: "<<downloadManger <<
" as Download Manager" <<
endl;
00590
QString cmd =
KStandardDirs::findExe(downloadManger);
00591
if (cmd.
isEmpty())
00592 {
00593
QString errMsg=i18n(
"The Download Manager (%1) could not be found in your $PATH ").arg(downloadManger);
00594
QString errMsgEx= i18n(
"Try to reinstall it \n\nThe integration with Konqueror will be disabled!");
00595
KMessageBox::detailedSorry(0,errMsg,errMsgEx);
00596 cfg.writePathEntry(
"DownloadManager",QString::null);
00597 cfg.sync ();
00598 }
00599
else
00600 {
00601 downloadViaKIO =
false;
00602
KURL cleanDest = destURL;
00603 cleanDest.
setPass( QString::null );
00604 cmd +=
" " +
KProcess::quote(url.
url()) +
" " +
00605
KProcess::quote(cleanDest.
url());
00606
kdDebug(1000) <<
"Calling command "<<cmd<<
endl;
00607
KRun::runCommand(cmd);
00608 }
00609 }
00610 }
00611
00612
if ( downloadViaKIO )
00613 {
00614
KIO::Job *job =
KIO::copy( url, destURL );
00615 job->
setMetaData(metadata);
00616 job->
addMetaData(
"MaxCacheSize",
"0");
00617 job->
addMetaData(
"cache",
"cache");
00618 job->
setAutoErrorHandlingEnabled(
true );
00619 }
00620 }
00621 }
00622 }
00623
00624 KHTMLPartBrowserHostExtension::KHTMLPartBrowserHostExtension(
KHTMLPart *part )
00625 : KParts::BrowserHostExtension( part )
00626 {
00627 m_part = part;
00628 }
00629
00630 KHTMLPartBrowserHostExtension::~KHTMLPartBrowserHostExtension()
00631 {
00632 }
00633
00634
QStringList KHTMLPartBrowserHostExtension::frameNames()
const
00635
{
00636
return m_part->
frameNames();
00637 }
00638
00639
const QPtrList<KParts::ReadOnlyPart> KHTMLPartBrowserHostExtension::frames()
const
00640
{
00641
return m_part->frames();
00642 }
00643
00644
bool KHTMLPartBrowserHostExtension::openURLInFrame(
const KURL &url,
const KParts::URLArgs &urlArgs )
00645 {
00646
return m_part->openURLInFrame( url, urlArgs );
00647 }
00648
00649
void KHTMLPartBrowserHostExtension::virtual_hook(
int id,
void *data )
00650 {
00651
if (
id == VIRTUAL_FIND_FRAME_PARENT)
00652 {
00653 FindFrameParentParams *param = static_cast<FindFrameParentParams*>(data);
00654
KHTMLPart *parentPart = m_part->findFrameParent(param->callingPart, param->frame);
00655
if (parentPart)
00656 param->parent = parentPart->
browserHostExtension();
00657
return;
00658 }
00659 BrowserHostExtension::virtual_hook(
id, data );
00660 }
00661
00662
00663 KHTMLZoomFactorAction::KHTMLZoomFactorAction(
KHTMLPart *part,
bool direction,
const QString &text,
const QString &icon,
const QObject *receiver,
const char *slot,
QObject *parent,
const char *name )
00664 :
KAction( text, icon, 0, receiver, slot, parent,
name )
00665 {
00666 m_direction = direction;
00667 m_part = part;
00668
00669 m_popup =
new QPopupMenu;
00670 m_popup->insertItem( i18n(
"Default Font Size" ) );
00671
00672
int m = m_direction ? 1 : -1;
00673
00674
for (
int i = 1; i < 5; ++i )
00675 {
00676
int num = i * m;
00677
QString numStr =
QString::number( num );
00678
if ( num > 0 ) numStr.
prepend(
'+' );
00679
00680 m_popup->insertItem( i18n(
"Font Size %1" ).arg( numStr ) );
00681 }
00682
00683 connect( m_popup, SIGNAL( activated(
int ) ),
this, SLOT( slotActivated(
int ) ) );
00684 }
00685
00686 KHTMLZoomFactorAction::KHTMLZoomFactorAction(
KHTMLPart *part,
bool direction,
const QString &text,
const QString &icon,
const KShortcut &cut,
const QObject *receiver,
const char *slot,
QObject *parent,
const char *name )
00687 :
KAction( text, icon,
cut, receiver, slot, parent,
name )
00688 {
00689 m_direction = direction;
00690 m_part = part;
00691
00692 m_popup =
new QPopupMenu;
00693 m_popup->insertItem( i18n(
"Default Font Size" ) );
00694
00695
int m = m_direction ? 1 : -1;
00696
00697
for (
int i = 1; i < 5; ++i )
00698 {
00699
int num = i * m;
00700
QString numStr =
QString::number( num );
00701
if ( num > 0 ) numStr.
prepend(
'+' );
00702
00703 m_popup->insertItem( i18n(
"Font Size %1" ).arg( numStr ) );
00704 }
00705
00706 connect( m_popup, SIGNAL( activated(
int ) ),
this, SLOT( slotActivated(
int ) ) );
00707 }
00708
00709 KHTMLZoomFactorAction::~KHTMLZoomFactorAction()
00710 {
00711
delete m_popup;
00712 }
00713
00714
int KHTMLZoomFactorAction::plug(
QWidget *w,
int index )
00715 {
00716
int containerId =
KAction::plug( w, index );
00717
if ( containerId == -1 || !w->inherits(
"KToolBar" ) )
00718
return containerId;
00719
00720
KToolBarButton *button = static_cast<KToolBar *>( w )->getButton( itemId( containerId ) );
00721
if ( !button )
00722
return containerId;
00723
00724 button->
setDelayedPopup( m_popup );
00725
return containerId;
00726 }
00727
00728
void KHTMLZoomFactorAction::slotActivated(
int id )
00729 {
00730
int idx = m_popup->indexOf(
id );
00731
00732
if (idx == 0)
00733 m_part->setZoomFactor(100);
00734
else
00735 m_part->setZoomFactor(m_part->zoomFactor() + (m_direction ? 10 : -10) * idx);
00736 }
00737
00738
#include "khtml_ext.moc"
00739