• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KParts

  • sources
  • kde-4.12
  • kdelibs
  • kparts
part.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3  (C) 1999-2005 David Faure <faure@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library 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.
9 
10  This library 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  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "part.h"
22 #include <kprotocolinfo.h>
23 #include "event.h"
24 #include "plugin.h"
25 #include "mainwindow.h"
26 #include "partmanager.h"
27 #include "browserextension.h"
28 
29 #include <QtGui/QApplication>
30 #include <QtCore/QFile>
31 #include <QtCore/QFileInfo>
32 #include <QtGui/QPainter>
33 #include <QtCore/QPoint>
34 
35 #include <kdirnotify.h>
36 #include <kfiledialog.h>
37 #include <kcomponentdata.h>
38 #include <kio/job.h>
39 #include <kio/jobuidelegate.h>
40 #include <klocale.h>
41 #include <kmessagebox.h>
42 #include <kstandarddirs.h>
43 #include <ktemporaryfile.h>
44 #include <kxmlguifactory.h>
45 
46 #include <stdio.h>
47 #include <unistd.h>
48 #include <assert.h>
49 #include <kdebug.h>
50 #include <kiconloader.h>
51 
52 using namespace KParts;
53 
54 namespace KParts
55 {
56 
57 class PartBasePrivate
58 {
59 public:
60  Q_DECLARE_PUBLIC(PartBase)
61 
62  PartBasePrivate(PartBase *q): q_ptr(q)
63  {
64  m_pluginLoadingMode = PartBase::LoadPlugins;
65  m_pluginInterfaceVersion = 0;
66  m_obj = 0;
67  }
68 
69  virtual ~PartBasePrivate()
70  {
71  }
72 
73  PartBase *q_ptr;
74  PartBase::PluginLoadingMode m_pluginLoadingMode;
75  int m_pluginInterfaceVersion;
76  QObject *m_obj;
77 };
78 
79 class PartPrivate: public PartBasePrivate
80 {
81 public:
82  Q_DECLARE_PUBLIC(Part)
83 
84  PartPrivate(Part *q)
85  : PartBasePrivate(q),
86  m_iconLoader(0),
87  m_bSelectable(true),
88  m_autoDeleteWidget(true),
89  m_autoDeletePart(true),
90  m_manager(0)
91  {
92  }
93 
94  ~PartPrivate()
95  {
96  }
97 
98  KIconLoader* m_iconLoader;
99  bool m_bSelectable;
100  bool m_autoDeleteWidget;
101  bool m_autoDeletePart;
102  PartManager * m_manager;
103  QPointer<QWidget> m_widget;
104 };
105 
106 }
107 
108 PartBase::PartBase()
109  : d_ptr(new PartBasePrivate(this))
110 {
111 }
112 
113 PartBase::PartBase(PartBasePrivate &dd)
114  : d_ptr(&dd)
115 {
116 }
117 
118 PartBase::~PartBase()
119 {
120  delete d_ptr;
121 }
122 
123 void PartBase::setPartObject( QObject *obj )
124 {
125  Q_D(PartBase);
126 
127  d->m_obj = obj;
128 }
129 
130 QObject *PartBase::partObject() const
131 {
132  Q_D(const PartBase);
133 
134  return d->m_obj;
135 }
136 
137 void PartBase::setComponentData(const KComponentData &componentData)
138 {
139  setComponentData(componentData, true);
140 }
141 
142 void PartBase::setComponentData(const KComponentData &componentData, bool bLoadPlugins)
143 {
144  Q_D(PartBase);
145 
146  KXMLGUIClient::setComponentData(componentData);
147  KGlobal::locale()->insertCatalog(componentData.catalogName());
148  // install 'instancename'data resource type
149  KGlobal::dirs()->addResourceType(QString(componentData.componentName() + "data").toUtf8(),
150  "data", componentData.componentName());
151  if (bLoadPlugins) {
152  loadPlugins(d->m_obj, this, componentData);
153  }
154 }
155 
156 void PartBase::loadPlugins(QObject *parent, KXMLGUIClient *parentGUIClient, const KComponentData &instance)
157 {
158  Q_D(PartBase);
159 
160  if( d->m_pluginLoadingMode != DoNotLoadPlugins )
161  Plugin::loadPlugins( parent, parentGUIClient, instance, d->m_pluginLoadingMode == LoadPlugins, d->m_pluginInterfaceVersion );
162 }
163 
164 void PartBase::setPluginLoadingMode( PluginLoadingMode loadingMode )
165 {
166  Q_D(PartBase);
167 
168  d->m_pluginLoadingMode = loadingMode;
169 }
170 
171 void KParts::PartBase::setPluginInterfaceVersion( int version )
172 {
173  Q_D(PartBase);
174 
175  d->m_pluginInterfaceVersion = version;
176 }
177 
178 Part::Part( QObject *parent )
179  : QObject( parent ), PartBase( *new PartPrivate(this) )
180 {
181  PartBase::setPartObject( this );
182 }
183 
184 Part::Part(PartPrivate &dd, QObject *parent)
185  : QObject( parent ), PartBase( dd )
186 {
187  PartBase::setPartObject( this );
188 }
189 
190 Part::~Part()
191 {
192  Q_D(Part);
193 
194  //kDebug(1000) << this;
195 
196  if ( d->m_widget )
197  {
198  // We need to disconnect first, to avoid calling it !
199  disconnect( d->m_widget, SIGNAL(destroyed()),
200  this, SLOT(slotWidgetDestroyed()) );
201  }
202 
203  if ( d->m_manager )
204  d->m_manager->removePart(this);
205 
206  if ( d->m_widget && d->m_autoDeleteWidget )
207  {
208  kDebug(1000) << "deleting widget" << d->m_widget << d->m_widget->objectName();
209  delete static_cast<QWidget*>(d->m_widget);
210  }
211 
212  delete d->m_iconLoader;
213 }
214 
215 void Part::embed( QWidget * parentWidget )
216 {
217  if ( widget() )
218  {
219  widget()->setParent( parentWidget, 0 );
220  widget()->setGeometry( 0, 0, widget()->width(), widget()->height() );
221  widget()->show();
222  }
223 }
224 
225 QWidget *Part::widget()
226 {
227  Q_D(Part);
228 
229  return d->m_widget;
230 }
231 
232 void Part::setAutoDeleteWidget(bool autoDeleteWidget)
233 {
234  Q_D(Part);
235  d->m_autoDeleteWidget = autoDeleteWidget;
236 }
237 
238 void Part::setAutoDeletePart(bool autoDeletePart)
239 {
240  Q_D(Part);
241  d->m_autoDeletePart = autoDeletePart;
242 }
243 
244 
245 
246 KIconLoader* Part::iconLoader()
247 {
248  Q_D(Part);
249 
250  if (!d->m_iconLoader) {
251  Q_ASSERT(componentData().isValid());
252  d->m_iconLoader = new KIconLoader( componentData() );
253  }
254  return d->m_iconLoader;
255 }
256 
257 void Part::setManager( PartManager *manager )
258 {
259  Q_D(Part);
260 
261  d->m_manager = manager;
262 }
263 
264 PartManager *Part::manager() const
265 {
266  Q_D(const Part);
267 
268  return d->m_manager;
269 }
270 
271 Part *Part::hitTest( QWidget *widget, const QPoint & )
272 {
273  Q_D(Part);
274 
275  if ( (QWidget *)d->m_widget != widget )
276  return 0;
277 
278  return this;
279 }
280 
281 void Part::setWidget( QWidget *widget )
282 {
283  Q_D(Part);
284  d->m_widget = widget;
285  connect( d->m_widget, SIGNAL(destroyed()),
286  this, SLOT(slotWidgetDestroyed()), Qt::UniqueConnection );
287 }
288 
289 void Part::setSelectable( bool selectable )
290 {
291  Q_D(Part);
292 
293  d->m_bSelectable = selectable;
294 }
295 
296 bool Part::isSelectable() const
297 {
298  Q_D(const Part);
299 
300  return d->m_bSelectable;
301 }
302 
303 void Part::customEvent( QEvent *ev )
304 {
305  if ( PartActivateEvent::test( ev ) )
306  {
307  partActivateEvent( static_cast<PartActivateEvent *>(ev) );
308  return;
309  }
310 
311  if ( PartSelectEvent::test( ev ) )
312  {
313  partSelectEvent( static_cast<PartSelectEvent *>(ev) );
314  return;
315  }
316 
317  if ( GUIActivateEvent::test( ev ) )
318  {
319  guiActivateEvent( static_cast<GUIActivateEvent *>(ev) );
320  return;
321  }
322 
323  QObject::customEvent( ev );
324 }
325 
326 void Part::partActivateEvent( PartActivateEvent * )
327 {
328 }
329 
330 void Part::partSelectEvent( PartSelectEvent * )
331 {
332 }
333 
334 void Part::guiActivateEvent( GUIActivateEvent * )
335 {
336 }
337 
338 QWidget *Part::hostContainer( const QString &containerName )
339 {
340  if ( !factory() )
341  return 0;
342 
343  return factory()->container( containerName, this );
344 }
345 
346 void Part::slotWidgetDestroyed()
347 {
348  Q_D(Part);
349 
350  d->m_widget = 0;
351  if (d->m_autoDeletePart) {
352  kDebug(1000) << "deleting part" << objectName();
353  delete this; // ouch, this should probably be deleteLater()
354  }
355 }
356 
357 void Part::loadPlugins()
358 {
359  PartBase::loadPlugins(this, this, componentData());
360 }
361 
363 
364 namespace KParts
365 {
366 
367 class ReadOnlyPartPrivate: public PartPrivate
368 {
369 public:
370  Q_DECLARE_PUBLIC(ReadOnlyPart)
371 
372  ReadOnlyPartPrivate(ReadOnlyPart *q): PartPrivate(q)
373  {
374  m_job = 0;
375  m_statJob = 0;
376  m_uploadJob = 0;
377  m_showProgressInfo = true;
378  m_saveOk = false;
379  m_waitForSave = false;
380  m_duringSaveAs = false;
381  m_bTemp = false;
382  m_bAutoDetectedMime = false;
383  }
384 
385  ~ReadOnlyPartPrivate()
386  {
387  }
388 
389  void _k_slotJobFinished( KJob * job );
390  void _k_slotStatJobFinished(KJob * job);
391  void _k_slotGotMimeType(KIO::Job *job, const QString &mime);
392  bool openLocalFile();
393  void openRemoteFile();
394 
395  KIO::FileCopyJob * m_job;
396  KIO::StatJob * m_statJob;
397  KIO::FileCopyJob * m_uploadJob;
398  KUrl m_originalURL; // for saveAs
399  QString m_originalFilePath; // for saveAs
400  bool m_showProgressInfo : 1;
401  bool m_saveOk : 1;
402  bool m_waitForSave : 1;
403  bool m_duringSaveAs : 1;
404 
408  bool m_bTemp: 1;
409 
410  // whether the mimetype in the arguments was detected by the part itself
411  bool m_bAutoDetectedMime : 1;
412 
416  KUrl m_url;
417 
421  QString m_file;
422 
423  OpenUrlArguments m_arguments;
424 };
425 
426 class ReadWritePartPrivate: public ReadOnlyPartPrivate
427 {
428 public:
429  Q_DECLARE_PUBLIC(ReadWritePart)
430 
431  ReadWritePartPrivate(ReadWritePart *q): ReadOnlyPartPrivate(q)
432  {
433  m_bModified = false;
434  m_bReadWrite = true;
435  m_bClosing = false;
436  }
437 
438  void _k_slotUploadFinished( KJob * job );
439 
440  void prepareSaving();
441 
442  bool m_bModified;
443  bool m_bReadWrite;
444  bool m_bClosing;
445  QEventLoop m_eventLoop;
446 };
447 
448 }
449 
450 ReadOnlyPart::ReadOnlyPart( QObject *parent )
451  : Part( *new ReadOnlyPartPrivate(this), parent )
452 {
453 }
454 
455 ReadOnlyPart::ReadOnlyPart( ReadOnlyPartPrivate &dd, QObject *parent )
456  : Part( dd, parent )
457 {
458 }
459 
460 ReadOnlyPart::~ReadOnlyPart()
461 {
462  ReadOnlyPart::closeUrl();
463 }
464 
465 KUrl ReadOnlyPart::url() const
466 {
467  Q_D(const ReadOnlyPart);
468 
469  return d->m_url;
470 }
471 
472 void ReadOnlyPart::setUrl(const KUrl &url)
473 {
474  Q_D(ReadOnlyPart);
475 
476  d->m_url = url;
477  emit urlChanged( url );
478 }
479 
480 QString ReadOnlyPart::localFilePath() const
481 {
482  Q_D(const ReadOnlyPart);
483 
484  return d->m_file;
485 }
486 
487 void ReadOnlyPart::setLocalFilePath( const QString &localFilePath )
488 {
489  Q_D(ReadOnlyPart);
490 
491  d->m_file = localFilePath;
492 }
493 
494 #ifndef KDE_NO_DEPRECATED
495 bool ReadOnlyPart::isLocalFileTemporary() const
496 {
497  Q_D(const ReadOnlyPart);
498 
499  return d->m_bTemp;
500 }
501 #endif
502 
503 #ifndef KDE_NO_DEPRECATED
504 void ReadOnlyPart::setLocalFileTemporary( bool temp )
505 {
506  Q_D(ReadOnlyPart);
507 
508  d->m_bTemp = temp;
509 }
510 #endif
511 
512 void ReadOnlyPart::setProgressInfoEnabled( bool show )
513 {
514  Q_D(ReadOnlyPart);
515 
516  d->m_showProgressInfo = show;
517 }
518 
519 bool ReadOnlyPart::isProgressInfoEnabled() const
520 {
521  Q_D(const ReadOnlyPart);
522 
523  return d->m_showProgressInfo;
524 }
525 
526 #ifndef KDE_NO_COMPAT
527 void ReadOnlyPart::showProgressInfo( bool show )
528 {
529  Q_D(ReadOnlyPart);
530 
531  d->m_showProgressInfo = show;
532 }
533 #endif
534 
535 bool ReadOnlyPart::openUrl( const KUrl &url )
536 {
537  Q_D(ReadOnlyPart);
538 
539  if ( !url.isValid() )
540  return false;
541  if (d->m_bAutoDetectedMime) {
542  d->m_arguments.setMimeType(QString());
543  d->m_bAutoDetectedMime = false;
544  }
545  OpenUrlArguments args = d->m_arguments;
546  if ( !closeUrl() )
547  return false;
548  d->m_arguments = args;
549  setUrl(url);
550 
551  d->m_file.clear();
552 
553  if (d->m_url.isLocalFile()) {
554  d->m_file = d->m_url.toLocalFile();
555  return d->openLocalFile();
556  } else if (KProtocolInfo::protocolClass(url.protocol()) == ":local") {
557  // Maybe we can use a "local path", to avoid a temp copy?
558  KIO::JobFlags flags = d->m_showProgressInfo ? KIO::DefaultFlags : KIO::HideProgressInfo;
559  d->m_statJob = KIO::mostLocalUrl(d->m_url, flags);
560  d->m_statJob->ui()->setWindow( widget() ? widget()->topLevelWidget() : 0 );
561  connect(d->m_statJob, SIGNAL(result(KJob*)), this, SLOT(_k_slotStatJobFinished(KJob*)));
562  return true;
563  } else {
564  d->openRemoteFile();
565  return true;
566  }
567 }
568 
569 bool ReadOnlyPart::openFile()
570 {
571  kWarning(1000) << "Default implementation of ReadOnlyPart::openFile called!"
572  << metaObject()->className() << "should reimplement either openUrl or openFile.";
573  return false;
574 }
575 
576 bool ReadOnlyPartPrivate::openLocalFile()
577 {
578  Q_Q(ReadOnlyPart);
579  emit q->started( 0 );
580  m_bTemp = false;
581  // set the mimetype only if it was not already set (for example, by the host application)
582  if (m_arguments.mimeType().isEmpty()) {
583  // get the mimetype of the file
584  // using findByUrl() to avoid another string -> url conversion
585  KMimeType::Ptr mime = KMimeType::findByUrl(m_url, 0, true /* local file*/);
586  if (mime) {
587  m_arguments.setMimeType(mime->name());
588  m_bAutoDetectedMime = true;
589  }
590  }
591  const bool ret = q->openFile();
592  if (ret) {
593  emit q->setWindowCaption(m_url.prettyUrl());
594  emit q->completed();
595  } else {
596  emit q->canceled(QString());
597  }
598  return ret;
599 }
600 
601 void ReadOnlyPartPrivate::openRemoteFile()
602 {
603  Q_Q(ReadOnlyPart);
604  m_bTemp = true;
605  // Use same extension as remote file. This is important for mimetype-determination (e.g. koffice)
606  QString fileName = m_url.fileName();
607  QFileInfo fileInfo(fileName);
608  QString ext = fileInfo.completeSuffix();
609  QString extension;
610  if (!ext.isEmpty() && m_url.query().isNull()) // not if the URL has a query, e.g. cgi.pl?something
611  extension = '.'+ext; // keep the '.'
612  KTemporaryFile tempFile;
613  tempFile.setSuffix(extension);
614  tempFile.setAutoRemove(false);
615  tempFile.open();
616  m_file = tempFile.fileName();
617 
618  KUrl destURL;
619  destURL.setPath( m_file );
620  KIO::JobFlags flags = m_showProgressInfo ? KIO::DefaultFlags : KIO::HideProgressInfo;
621  flags |= KIO::Overwrite;
622  m_job = KIO::file_copy(m_url, destURL, 0600, flags);
623  m_job->ui()->setWindow(q->widget() ? q->widget()->topLevelWidget() : 0);
624  emit q->started(m_job);
625  QObject::connect(m_job, SIGNAL(result(KJob*)), q, SLOT(_k_slotJobFinished(KJob*)));
626  QObject::connect(m_job, SIGNAL(mimetype(KIO::Job*,QString)),
627  q, SLOT(_k_slotGotMimeType(KIO::Job*,QString)));
628 }
629 
630 void ReadOnlyPart::abortLoad()
631 {
632  Q_D(ReadOnlyPart);
633 
634  if ( d->m_statJob ) {
635  //kDebug(1000) << "Aborting job" << d->m_statJob;
636  d->m_statJob->kill();
637  d->m_statJob = 0;
638  }
639  if ( d->m_job ) {
640  //kDebug(1000) << "Aborting job" << d->m_job;
641  d->m_job->kill();
642  d->m_job = 0;
643  }
644 }
645 
646 bool ReadOnlyPart::closeUrl()
647 {
648  Q_D(ReadOnlyPart);
649 
650  abortLoad(); //just in case
651 
652  d->m_arguments = KParts::OpenUrlArguments();
653 
654  if ( d->m_bTemp )
655  {
656  QFile::remove( d->m_file );
657  d->m_bTemp = false;
658  }
659  // It always succeeds for a read-only part,
660  // but the return value exists for reimplementations
661  // (e.g. pressing cancel for a modified read-write part)
662  return true;
663 }
664 
665 void ReadOnlyPartPrivate::_k_slotStatJobFinished(KJob * job)
666 {
667  Q_ASSERT(job == m_statJob);
668  m_statJob = 0;
669 
670  // We could emit canceled on error, but we haven't even emitted started yet,
671  // this could maybe confuse some apps? So for now we'll just fallback to KIO::get
672  // and error again. Well, maybe this even helps with wrong stat results.
673  if (!job->error()) {
674  const KUrl localUrl = static_cast<KIO::StatJob*>(job)->mostLocalUrl();
675  if (localUrl.isLocalFile()) {
676  m_file = localUrl.toLocalFile();
677  (void)openLocalFile();
678  return;
679  }
680  }
681  openRemoteFile();
682 }
683 
684 void ReadOnlyPartPrivate::_k_slotJobFinished( KJob * job )
685 {
686  Q_Q(ReadOnlyPart);
687 
688  assert( job == m_job );
689  m_job = 0;
690  if (job->error())
691  emit q->canceled( job->errorString() );
692  else
693  {
694  if ( q->openFile() ) {
695  emit q->setWindowCaption( m_url.prettyUrl() );
696  emit q->completed();
697  } else emit q->canceled(QString());
698  }
699 }
700 
701 void ReadOnlyPartPrivate::_k_slotGotMimeType(KIO::Job *job, const QString &mime)
702 {
703  kDebug(1000) << mime;
704  Q_ASSERT(job == m_job); Q_UNUSED(job)
705  // set the mimetype only if it was not already set (for example, by the host application)
706  if (m_arguments.mimeType().isEmpty()) {
707  m_arguments.setMimeType(mime);
708  m_bAutoDetectedMime = true;
709  }
710 }
711 
712 void ReadOnlyPart::guiActivateEvent( GUIActivateEvent * event )
713 {
714  Q_D(ReadOnlyPart);
715 
716  if (event->activated())
717  {
718  if (!d->m_url.isEmpty())
719  {
720  kDebug(1000) << d->m_url;
721  emit setWindowCaption( d->m_url.prettyUrl() );
722  } else emit setWindowCaption( "" );
723  }
724 }
725 
726 bool ReadOnlyPart::openStream( const QString& mimeType, const KUrl& url )
727 {
728  Q_D(ReadOnlyPart);
729 
730  OpenUrlArguments args = d->m_arguments;
731  if ( !closeUrl() )
732  return false;
733  d->m_arguments = args;
734  setUrl( url );
735  return doOpenStream( mimeType );
736 }
737 
738 bool ReadOnlyPart::writeStream( const QByteArray& data )
739 {
740  return doWriteStream( data );
741 }
742 
743 bool ReadOnlyPart::closeStream()
744 {
745  return doCloseStream();
746 }
747 
748 BrowserExtension* ReadOnlyPart::browserExtension() const
749 {
750  return findChild<KParts::BrowserExtension *>();
751 }
752 
753 void KParts::ReadOnlyPart::setArguments(const OpenUrlArguments& arguments)
754 {
755  Q_D(ReadOnlyPart);
756  d->m_arguments = arguments;
757  d->m_bAutoDetectedMime = arguments.mimeType().isEmpty();
758 }
759 
760 OpenUrlArguments KParts::ReadOnlyPart::arguments() const
761 {
762  Q_D(const ReadOnlyPart);
763  return d->m_arguments;
764 }
765 
767 
768 
769 ReadWritePart::ReadWritePart( QObject *parent )
770  : ReadOnlyPart( *new ReadWritePartPrivate(this), parent )
771 {
772 }
773 
774 ReadWritePart::~ReadWritePart()
775 {
776  // parent destructor will delete temp file
777  // we can't call our own closeUrl() here, because
778  // "cancel" wouldn't cancel anything. We have to assume
779  // the app called closeUrl() before destroying us.
780 }
781 
782 void ReadWritePart::setReadWrite( bool readwrite )
783 {
784  Q_D(ReadWritePart);
785 
786  // Perhaps we should check isModified here and issue a warning if true
787  d->m_bReadWrite = readwrite;
788 }
789 
790 void ReadWritePart::setModified( bool modified )
791 {
792  Q_D(ReadWritePart);
793 
794  kDebug(1000) << "setModified(" << (modified ? "true" : "false") << ")";
795  if ( !d->m_bReadWrite && modified )
796  {
797  kError(1000) << "Can't set a read-only document to 'modified' !" << endl;
798  return;
799  }
800  d->m_bModified = modified;
801 }
802 
803 void ReadWritePart::setModified()
804 {
805  setModified( true );
806 }
807 
808 bool ReadWritePart::queryClose()
809 {
810  Q_D(ReadWritePart);
811 
812  if ( !isReadWrite() || !isModified() )
813  return true;
814 
815  QString docName = url().fileName();
816  if (docName.isEmpty()) docName = i18n( "Untitled" );
817 
818  QWidget *parentWidget=widget();
819  if(!parentWidget) parentWidget=QApplication::activeWindow();
820 
821  int res = KMessageBox::warningYesNoCancel( parentWidget,
822  i18n( "The document \"%1\" has been modified.\n"
823  "Do you want to save your changes or discard them?" , docName ),
824  i18n( "Close Document" ), KStandardGuiItem::save(), KStandardGuiItem::discard() );
825 
826  bool abortClose=false;
827  bool handled=false;
828 
829  switch(res) {
830  case KMessageBox::Yes :
831  sigQueryClose(&handled,&abortClose);
832  if (!handled)
833  {
834  if (d->m_url.isEmpty())
835  {
836  KUrl url = KFileDialog::getSaveUrl(KUrl(), QString(), parentWidget);
837  if (url.isEmpty())
838  return false;
839 
840  saveAs( url );
841  }
842  else
843  {
844  save();
845  }
846  } else if (abortClose) return false;
847  return waitSaveComplete();
848  case KMessageBox::No :
849  return true;
850  default : // case KMessageBox::Cancel :
851  return false;
852  }
853 }
854 
855 bool ReadWritePart::closeUrl()
856 {
857  abortLoad(); //just in case
858  if ( isReadWrite() && isModified() )
859  {
860  if (!queryClose())
861  return false;
862  }
863  // Not modified => ok and delete temp file.
864  return ReadOnlyPart::closeUrl();
865 }
866 
867 bool ReadWritePart::closeUrl( bool promptToSave )
868 {
869  return promptToSave ? closeUrl() : ReadOnlyPart::closeUrl();
870 }
871 
872 bool ReadWritePart::save()
873 {
874  Q_D(ReadWritePart);
875 
876  d->m_saveOk = false;
877  if ( d->m_file.isEmpty() ) // document was created empty
878  d->prepareSaving();
879  if( saveFile() )
880  return saveToUrl();
881  else
882  emit canceled(QString());
883  return false;
884 }
885 
886 bool ReadWritePart::saveAs( const KUrl & kurl )
887 {
888  Q_D(ReadWritePart);
889 
890  if (!kurl.isValid())
891  {
892  kError(1000) << "saveAs: Malformed URL " << kurl.url() << endl;
893  return false;
894  }
895  d->m_duringSaveAs = true;
896  d->m_originalURL = d->m_url;
897  d->m_originalFilePath = d->m_file;
898  d->m_url = kurl; // Store where to upload in saveToURL
899  d->prepareSaving();
900  bool result = save(); // Save local file and upload local file
901  if (result) {
902  emit urlChanged( d->m_url );
903  emit setWindowCaption( d->m_url.prettyUrl() );
904  } else {
905  d->m_url = d->m_originalURL;
906  d->m_file = d->m_originalFilePath;
907  d->m_duringSaveAs = false;
908  d->m_originalURL = KUrl();
909  d->m_originalFilePath.clear();
910  }
911 
912  return result;
913 }
914 
915 // Set m_file correctly for m_url
916 void ReadWritePartPrivate::prepareSaving()
917 {
918  // Local file
919  if ( m_url.isLocalFile() )
920  {
921  if ( m_bTemp ) // get rid of a possible temp file first
922  { // (happens if previous url was remote)
923  QFile::remove( m_file );
924  m_bTemp = false;
925  }
926  m_file = m_url.toLocalFile();
927  }
928  else
929  { // Remote file
930  // We haven't saved yet, or we did but locally - provide a temp file
931  if ( m_file.isEmpty() || !m_bTemp )
932  {
933  KTemporaryFile tempFile;
934  tempFile.setAutoRemove(false);
935  tempFile.open();
936  m_file = tempFile.fileName();
937  m_bTemp = true;
938  }
939  // otherwise, we already had a temp file
940  }
941 }
942 
943 bool ReadWritePart::saveToUrl()
944 {
945  Q_D(ReadWritePart);
946 
947  if ( d->m_url.isLocalFile() )
948  {
949  setModified( false );
950  emit completed();
951  // if m_url is a local file there won't be a temp file -> nothing to remove
952  assert( !d->m_bTemp );
953  d->m_saveOk = true;
954  d->m_duringSaveAs = false;
955  d->m_originalURL = KUrl();
956  d->m_originalFilePath.clear();
957  return true; // Nothing to do
958  }
959  else
960  {
961  if (d->m_uploadJob)
962  {
963  QFile::remove(d->m_uploadJob->srcUrl().toLocalFile());
964  d->m_uploadJob->kill();
965  d->m_uploadJob = 0;
966  }
967  KTemporaryFile *tempFile = new KTemporaryFile();
968  tempFile->open();
969  QString uploadFile = tempFile->fileName();
970  delete tempFile;
971  KUrl uploadUrl;
972  uploadUrl.setPath( uploadFile );
973  // Create hardlink
974  if (::link(QFile::encodeName(d->m_file), QFile::encodeName(uploadFile)) != 0)
975  {
976  // Uh oh, some error happened.
977  return false;
978  }
979  d->m_uploadJob = KIO::file_move( uploadUrl, d->m_url, -1, KIO::Overwrite );
980  d->m_uploadJob->ui()->setWindow( widget() ? widget()->topLevelWidget() : 0 );
981  connect( d->m_uploadJob, SIGNAL(result(KJob*)), this, SLOT(_k_slotUploadFinished(KJob*)) );
982  return true;
983  }
984 }
985 
986 void ReadWritePartPrivate::_k_slotUploadFinished( KJob * )
987 {
988  Q_Q(ReadWritePart);
989 
990  if (m_uploadJob->error())
991  {
992  QFile::remove(m_uploadJob->srcUrl().toLocalFile());
993  QString error = m_uploadJob->errorString();
994  m_uploadJob = 0;
995  if (m_duringSaveAs) {
996  q->setUrl(m_originalURL);
997  m_file = m_originalFilePath;
998  }
999  emit q->canceled( error );
1000  }
1001  else
1002  {
1003  KUrl dirUrl( m_url );
1004  dirUrl.setPath( dirUrl.directory() );
1005  ::org::kde::KDirNotify::emitFilesAdded( dirUrl.url() );
1006 
1007  m_uploadJob = 0;
1008  q->setModified( false );
1009  emit q->completed();
1010  m_saveOk = true;
1011  }
1012  m_duringSaveAs = false;
1013  m_originalURL = KUrl();
1014  m_originalFilePath.clear();
1015  if (m_waitForSave) {
1016  m_eventLoop.quit();
1017  }
1018 }
1019 
1020 bool ReadWritePart::isReadWrite() const
1021 {
1022  Q_D(const ReadWritePart);
1023 
1024  return d->m_bReadWrite;
1025 }
1026 
1027 bool ReadWritePart::isModified() const
1028 {
1029  Q_D(const ReadWritePart);
1030 
1031  return d->m_bModified;
1032 }
1033 
1034 bool ReadWritePart::waitSaveComplete()
1035 {
1036  Q_D(ReadWritePart);
1037 
1038  if (!d->m_uploadJob)
1039  return d->m_saveOk;
1040 
1041  d->m_waitForSave = true;
1042 
1043  d->m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
1044 
1045  d->m_waitForSave = false;
1046 
1047  return d->m_saveOk;
1048 }
1049 
1051 
1052 class KParts::OpenUrlArgumentsPrivate : public QSharedData
1053 {
1054 public:
1055  OpenUrlArgumentsPrivate()
1056  : reload(false),
1057  actionRequestedByUser(true),
1058  xOffset(0),
1059  yOffset(0),
1060  mimeType(),
1061  metaData()
1062  {}
1063  bool reload;
1064  bool actionRequestedByUser;
1065  int xOffset;
1066  int yOffset;
1067  QString mimeType;
1068  QMap<QString, QString> metaData;
1069 };
1070 
1071 KParts::OpenUrlArguments::OpenUrlArguments()
1072  : d(new OpenUrlArgumentsPrivate)
1073 {
1074 }
1075 
1076 KParts::OpenUrlArguments::OpenUrlArguments(const OpenUrlArguments &other)
1077  : d(other.d)
1078 {
1079 }
1080 
1081 KParts::OpenUrlArguments & KParts::OpenUrlArguments::operator=( const OpenUrlArguments &other)
1082 {
1083  d = other.d;
1084  return *this;
1085 }
1086 
1087 KParts::OpenUrlArguments::~OpenUrlArguments()
1088 {
1089 }
1090 
1091 bool KParts::OpenUrlArguments::reload() const
1092 {
1093  return d->reload;
1094 }
1095 
1096 void KParts::OpenUrlArguments::setReload(bool b)
1097 {
1098  d->reload = b;
1099 }
1100 
1101 int KParts::OpenUrlArguments::xOffset() const
1102 {
1103  return d->xOffset;
1104 }
1105 
1106 void KParts::OpenUrlArguments::setXOffset(int x)
1107 {
1108  d->xOffset = x;
1109 }
1110 
1111 int KParts::OpenUrlArguments::yOffset() const
1112 {
1113  return d->yOffset;
1114 }
1115 
1116 void KParts::OpenUrlArguments::setYOffset(int y)
1117 {
1118  d->yOffset = y;
1119 }
1120 
1121 QString KParts::OpenUrlArguments::mimeType() const
1122 {
1123  return d->mimeType;
1124 }
1125 
1126 void KParts::OpenUrlArguments::setMimeType(const QString& mime)
1127 {
1128  d->mimeType = mime;
1129 }
1130 
1131 QMap<QString, QString> & KParts::OpenUrlArguments::metaData()
1132 {
1133  return d->metaData;
1134 }
1135 
1136 const QMap<QString, QString> & KParts::OpenUrlArguments::metaData() const
1137 {
1138  return d->metaData;
1139 }
1140 
1141 bool KParts::OpenUrlArguments::actionRequestedByUser() const
1142 {
1143  return d->actionRequestedByUser;
1144 }
1145 
1146 void KParts::OpenUrlArguments::setActionRequestedByUser(bool userRequested)
1147 {
1148  d->actionRequestedByUser = userRequested;
1149 }
1150 
1151 #include "part.moc"
KParts::ReadWritePart::saveToUrl
virtual bool saveToUrl()
Save the file.
Definition: part.cpp:943
KParts::BrowserExtension
The Browser Extension is an extension (yes, no kidding) to KParts::ReadOnlyPart, which allows a bette...
Definition: browserextension.h:320
KParts::ReadOnlyPart::isLocalFileTemporary
bool isLocalFileTemporary() const
Definition: part.cpp:495
KParts::ReadOnlyPart::setLocalFilePath
void setLocalFilePath(const QString &localFilePath)
Sets the local file path associated with this part.
Definition: part.cpp:487
i18n
QString i18n(const char *text)
KParts::ReadWritePart::ReadWritePart
ReadWritePart(QObject *parent=0)
Constructor See parent constructor for instructions.
Definition: part.cpp:769
KIO::Overwrite
KMessageBox::No
KParts::ReadWritePart::saveAs
virtual bool saveAs(const KUrl &url)
Save the file to a new location.
Definition: part.cpp:886
KParts::Part::~Part
virtual ~Part()
Destructor.
Definition: part.cpp:190
KParts::GUIActivateEvent::test
static bool test(const QEvent *event)
Definition: event.cpp:101
kdebug.h
KXMLGUIClient
KStandardGuiItem::discard
KGuiItem discard()
KParts::ReadOnlyPart::showProgressInfo
void showProgressInfo(bool show)
Definition: part.cpp:527
KParts::ReadOnlyPart::~ReadOnlyPart
virtual ~ReadOnlyPart()
Destructor.
Definition: part.cpp:460
KStandardDirs::addResourceType
bool addResourceType(const char *type, const QString &relativename, bool priority=true)
KParts::ReadWritePart::waitSaveComplete
bool waitSaveComplete()
Waits for any pending upload job to finish and returns whether the last save() action was successful...
Definition: part.cpp:1034
KParts::OpenUrlArguments::metaData
QMap< QString, QString > & metaData()
Meta-data to associate with the KIO operation that will be used to open the URL.
Definition: part.cpp:1131
KParts::ReadOnlyPart::urlChanged
void urlChanged(const KUrl &url)
Emitted by the part when url() changes.
KParts::PartBase::d_ptr
PartBasePrivate * d_ptr
Definition: part.h:184
KParts::OpenUrlArguments::actionRequestedByUser
bool actionRequestedByUser() const
True if the user requested that the URL be opened.
Definition: part.cpp:1141
KParts::PartBase::DoNotLoadPlugins
Don't load any plugins at all.
Definition: part.h:123
KParts::OpenUrlArguments::setActionRequestedByUser
void setActionRequestedByUser(bool userRequested)
Definition: part.cpp:1146
kfiledialog.h
KParts::ReadOnlyPart::openFile
virtual bool openFile()
If the part uses the standard implementation of openUrl(), it must reimplement this, to open the local file.
Definition: part.cpp:569
KParts::PartActivateEvent
This event is sent by the part manager when the active part changes.
Definition: event.h:82
kdirnotify.h
partmanager.h
mimetype
MimetypeJob * mimetype(const KUrl &url, JobFlags flags=DefaultFlags)
KParts::ReadOnlyPart::completed
void completed()
Emit this when you have completed loading data.
KIO::HideProgressInfo
KParts::ReadWritePart::save
virtual bool save()
Save the file in the location from which it was opened.
Definition: part.cpp:872
KParts::Part::loadPlugins
void loadPlugins()
Load this part's plugins now.
Definition: part.cpp:357
QWidget
KParts::PartBase::setPartObject
void setPartObject(QObject *object)
Internal method.
Definition: part.cpp:123
KGlobal::dirs
KStandardDirs * dirs()
KParts::ReadOnlyPart::isProgressInfoEnabled
bool isProgressInfoEnabled() const
Returns whether the part shows the progress info dialog used by internal KIO job. ...
Definition: part.cpp:519
plugin.h
kxmlguifactory.h
kError
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KParts::ReadOnlyPart::browserExtension
BrowserExtension * browserExtension() const
This convenience method returns the browserExtension for this part, or 0 if there isn't any...
Definition: part.cpp:748
KParts::Part::embed
virtual void embed(QWidget *parentWidget)
Embed this part into a host widget.
Definition: part.cpp:215
KParts::Part::widget
virtual QWidget * widget()
Definition: part.cpp:225
KParts::OpenUrlArguments::OpenUrlArguments
OpenUrlArguments()
Definition: part.cpp:1071
KIO::StatJob
KParts::ReadWritePart::setModified
void setModified()
Call setModified() whenever the contents get modified.
Definition: part.cpp:803
kiconloader.h
KIO::file_move
FileCopyJob * file_move(const KUrl &src, const KUrl &dest, int permissions=-1, JobFlags flags=DefaultFlags)
KUrl::toLocalFile
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
KXMLGUIClient::factory
KXMLGUIFactory * factory() const
KParts::ReadOnlyPart::setUrl
void setUrl(const KUrl &url)
Sets the url associated with this part.
Definition: part.cpp:472
KParts::PartBase::LoadPlugins
Load new plugins automatically.
Definition: part.h:130
QString
KTemporaryFile
KParts::Part
Base class for parts.
Definition: part.h:215
KIO::mostLocalUrl
StatJob * mostLocalUrl(const KUrl &url, JobFlags flags=DefaultFlags)
KTemporaryFile::setSuffix
void setSuffix(const QString &suffix)
KParts::PartActivateEvent::test
static bool test(const QEvent *event)
Definition: event.cpp:156
KParts::ReadWritePart::queryClose
virtual bool queryClose()
If the document has been modified, ask the user to save changes.
Definition: part.cpp:808
QObject
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
klocale.h
KParts::ReadWritePart::closeUrl
virtual bool closeUrl()
Called when closing the current url (e.g.
Definition: part.cpp:855
KParts::OpenUrlArguments::mimeType
QString mimeType() const
The mimetype to use when opening the url, when known by the calling application.
Definition: part.cpp:1121
KUrl
KParts::ReadWritePart::saveFile
virtual bool saveFile()=0
Save to a local file.
KParts::ReadWritePart
Base class for an "editor" part.
Definition: part.h:745
KUrl::setPath
void setPath(const QString &path)
KParts::PartBase::~PartBase
virtual ~PartBase()
Destructor.
Definition: part.cpp:118
KIO::DefaultFlags
KComponentData::catalogName
QString catalogName() const
KParts::Part::customEvent
virtual void customEvent(QEvent *event)
Definition: part.cpp:303
KParts::ReadOnlyPart::abortLoad
void abortLoad()
Definition: part.cpp:630
KMessageBox::warningYesNoCancel
static int warningYesNoCancel(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &buttonYes=KStandardGuiItem::yes(), const KGuiItem &buttonNo=KStandardGuiItem::no(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
KParts::OpenUrlArguments::setXOffset
void setXOffset(int x)
Definition: part.cpp:1106
KParts::ReadOnlyPart::writeStream
bool writeStream(const QByteArray &data)
Send some data to the part.
Definition: part.cpp:738
KParts::PartBase
Base class for all parts.
Definition: part.h:64
KIO::file_copy
FileCopyJob * file_copy(const KUrl &src, const KUrl &dest, int permissions=-1, JobFlags flags=DefaultFlags)
KParts::Part::hitTest
virtual Part * hitTest(QWidget *widget, const QPoint &globalPos)
Returns the part (this, or a child part) at the given global position.
Definition: part.cpp:271
KParts::ReadOnlyPart::canceled
void canceled(const QString &errMsg)
Emit this if loading is canceled by the user or by an error.
KParts::OpenUrlArguments::~OpenUrlArguments
~OpenUrlArguments()
Definition: part.cpp:1087
KXMLGUIClient::componentData
virtual KComponentData componentData() const
KParts::OpenUrlArguments::operator=
OpenUrlArguments & operator=(const OpenUrlArguments &other)
Definition: part.cpp:1081
KUrl::protocol
QString protocol() const
KParts::ReadWritePart::sigQueryClose
void sigQueryClose(bool *handled, bool *abortClosing)
set handled to true, if you don't want the default handling set abortClosing to true, if you handled the request, but for any reason don't want to allow closing the document
KParts::Part::setWindowCaption
void setWindowCaption(const QString &caption)
Emitted by the part, to set the caption of the window(s) hosting this part.
KParts::PartBase::setPluginLoadingMode
void setPluginLoadingMode(PluginLoadingMode loadingMode)
Set how plugins should be loaded.
Definition: part.cpp:164
mainwindow.h
KParts::PartBase::partObject
QObject * partObject() const
Definition: part.cpp:130
KParts::ReadWritePart::isReadWrite
bool isReadWrite() const
Definition: part.cpp:1020
KParts::OpenUrlArguments::xOffset
int xOffset() const
xOffset is the horizontal scrolling of the part's widget (in case it's a scrollview).
Definition: part.cpp:1101
KParts::Part::hostContainer
QWidget * hostContainer(const QString &containerName)
Convenience method for KXMLGUIFactory::container.
Definition: part.cpp:338
link
CopyJob * link(const KUrl &src, const KUrl &destDir, JobFlags flags=DefaultFlags)
KComponentData::componentName
QString componentName() const
KParts::Part::partActivateEvent
virtual void partActivateEvent(PartActivateEvent *event)
Convenience method which is called when the Part received a PartActivateEvent .
Definition: part.cpp:326
KParts::PartBase::setPluginInterfaceVersion
void setPluginInterfaceVersion(int version)
If you change the binary interface offered by your part, you can avoid crashes from old plugins lying...
Definition: part.cpp:171
KParts::ReadOnlyPart::url
KUrl url() const
Returns the URL currently opened in this part.
KProtocolInfo::protocolClass
static QString protocolClass(const QString &protocol)
KXMLGUIClient::setComponentData
virtual void setComponentData(const KComponentData &componentData)
KParts::Part::slotWidgetDestroyed
void slotWidgetDestroyed()
Definition: part.cpp:346
reload
const KShortcut & reload()
KParts::GUIActivateEvent
This event is sent to a Part when its GUI has been activated or deactivated.
Definition: event.h:59
KParts::ReadOnlyPart::openStream
bool openStream(const QString &mimeType, const KUrl &url)
Initiate sending data to this part.
Definition: part.cpp:726
jobuidelegate.h
KLocale::insertCatalog
void insertCatalog(const QString &catalog)
kprotocolinfo.h
KParts::Part::setSelectable
virtual void setSelectable(bool selectable)
Definition: part.cpp:289
KParts::GUIActivateEvent::activated
bool activated() const
Definition: event.cpp:96
KParts::OpenUrlArguments::reload
bool reload() const
Definition: part.cpp:1091
KParts::ReadOnlyPart::arguments
OpenUrlArguments arguments() const
Definition: part.cpp:760
KParts::Part::setWidget
virtual void setWidget(QWidget *widget)
Set the main widget.
Definition: part.cpp:281
KParts::PartBase::PluginLoadingMode
PluginLoadingMode
We have three different policies, whether to load new plugins or not.
Definition: part.h:119
KGlobal::locale
KLocale * locale()
KParts::Part::partSelectEvent
virtual void partSelectEvent(PartSelectEvent *event)
Convenience method which is called when the Part received a PartSelectEvent .
Definition: part.cpp:330
job.h
QSharedData
KParts::OpenUrlArguments::setReload
void setReload(bool b)
Indicates that the url should be loaded from the network even if it matches the current url of the pa...
Definition: part.cpp:1096
KParts::ReadOnlyPart::closeUrl
virtual bool closeUrl()
Called when closing the current url (e.g.
Definition: part.cpp:646
ktemporaryfile.h
KParts::ReadOnlyPart::setArguments
void setArguments(const OpenUrlArguments &arguments)
Sets the arguments to use for the next openUrl call.
Definition: part.cpp:753
KParts::Part::Part
Part(QObject *parent=0)
Constructor.
Definition: part.cpp:178
KParts::ReadOnlyPart::setLocalFileTemporary
void setLocalFileTemporary(bool temp)
Definition: part.cpp:504
KParts::Part::isSelectable
bool isSelectable() const
Returns whether the part is selectable or not.
Definition: part.cpp:296
KParts::ReadOnlyPart::setProgressInfoEnabled
void setProgressInfoEnabled(bool show)
Call this to turn off the progress info dialog used by the internal KIO job.
Definition: part.cpp:512
KParts::Part::iconLoader
KIconLoader * iconLoader()
Use this icon loader to load any icons that are specific to this part, i.e.
Definition: part.cpp:246
QPoint
KUrl::fileName
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
event.h
KParts::OpenUrlArguments::setMimeType
void setMimeType(const QString &mime)
Definition: part.cpp:1126
KIO::FileCopyJob
kstandarddirs.h
KParts::OpenUrlArguments::setYOffset
void setYOffset(int y)
Definition: part.cpp:1116
KParts::PartBase::PartBase
PartBase()
Constructor.
Definition: part.cpp:108
KParts::Part::manager
PartManager * manager() const
Returns the part manager handling this part, if any (0L otherwise).
Definition: part.cpp:264
KParts::ReadOnlyPart::closeStream
bool closeStream()
Terminate the sending of data to the part.
Definition: part.cpp:743
KIO::Job
KParts::OpenUrlArguments::yOffset
int yOffset() const
yOffset is the vertical scrolling of the part's widget (in case it's a scrollview).
Definition: part.cpp:1111
KParts::Part::setManager
virtual void setManager(PartManager *manager)
Definition: part.cpp:257
KParts::PartBase::loadPlugins
void loadPlugins(QObject *parent, KXMLGUIClient *parentGUIClient, const KComponentData &componentData)
Load the Plugins honoring the PluginLoadingMode.
Definition: part.cpp:156
KParts::Part::setAutoDeletePart
void setAutoDeletePart(bool autoDeletePart)
By default, the part deletes itself when its widget is deleted.
Definition: part.cpp:238
KParts::ReadOnlyPart::openUrl
virtual bool openUrl(const KUrl &url)
Only reimplement openUrl if you don't want the network transparency support to download from the url ...
Definition: part.cpp:535
KParts::ReadWritePart::setReadWrite
virtual void setReadWrite(bool readwrite=true)
Changes the behavior of this part to readonly or readwrite.
Definition: part.cpp:782
kWarning
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KStandardGuiItem::save
KGuiItem save()
KParts::PartManager
The part manager is an object which knows about a collection of parts (even nested ones) and handles ...
Definition: partmanager.h:47
KXMLGUIFactory::container
QWidget * container(const QString &containerName, KXMLGUIClient *client, bool useTagName=false)
KParts::PartBase::setComponentData
virtual void setComponentData(const KComponentData &componentData)
Set the componentData(KComponentData) for this part.
Definition: part.cpp:137
KParts::Part::guiActivateEvent
virtual void guiActivateEvent(GUIActivateEvent *event)
Convenience method which is called when the Part received a GUIActivateEvent .
Definition: part.cpp:334
browserextension.h
KParts::PartSelectEvent::test
static bool test(const QEvent *event)
Definition: event.cpp:212
KMessageBox::Yes
KUrl::url
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
KParts::Plugin::loadPlugins
static void loadPlugins(QObject *parent, const KComponentData &instance)
Load the plugin libraries from the directories appropriate to instance and make the Plugin objects ch...
Definition: plugin.cpp:136
kcomponentdata.h
KParts::ReadWritePart::~ReadWritePart
virtual ~ReadWritePart()
Destructor Applications using a ReadWritePart should make sure, before destroying it...
Definition: part.cpp:774
KUrl::isLocalFile
bool isLocalFile() const
kmessagebox.h
QEvent
KParts::ReadOnlyPart::guiActivateEvent
virtual void guiActivateEvent(GUIActivateEvent *event)
Reimplemented from Part, so that the window caption is set to the current url (decoded) when the part...
Definition: part.cpp:712
KJob
KComponentData
KParts::ReadOnlyPart::ReadOnlyPart
ReadOnlyPart(QObject *parent=0)
Constructor See also Part for the setXXX methods to call.
Definition: part.cpp:450
QMap< QString, QString >
KParts::ReadWritePart::isModified
bool isModified() const
Definition: part.cpp:1027
part.h
KParts::OpenUrlArguments
OpenUrlArguments is the set of arguments that specify how a URL should be opened by KParts::ReadOnlyP...
Definition: part.h:404
KIconLoader
KParts::Part::setAutoDeleteWidget
void setAutoDeleteWidget(bool autoDeleteWidget)
By default, the widget is deleted by the part when the part is deleted.
Definition: part.cpp:232
KParts::PartSelectEvent
This event is sent when a part is selected or deselected.
Definition: event.h:103
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:488
KParts::ReadOnlyPart::localFilePath
QString localFilePath() const
Returns the local file path associated with this part.
Definition: part.cpp:480
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KParts

Skip menu "KParts"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal