From kfm-devel Mon Aug 11 11:36:41 2003 From: Waldo Bastian Date: Mon, 11 Aug 2003 11:36:41 +0000 To: kfm-devel Subject: Re: Konqueror RMB popup menu & khtml referrer X-MARC-Message: https://marc.info/?l=kfm-devel&m=106060174822418 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_J/3N/z4gE+WM201" --Boundary-00=_J/3N/z4gE+WM201 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 11 August 2003 12:57, David Faure wrote: > On Sunday 10 August 2003 16:53, Waldo Bastian wrote: > > Hi David, > > > > I have a problem with konqie's popup menu. There are several actions th= at > > operate on the selected URL, such as "Open in New Window" and for those > > to work correctly, the referrer must be set correctly. Konqueror doesn't > > know how to do that, it only knows about the URL of the part as a whole, > > but it doesn't know about frames that may influence the referrer. So > > khtml should tell konqueror about the refererrer. > > This could be accessible via a property of the part.... > > > I have made a patch that makes it possible to attach the referrer to a > > KFileItem. > > I don't like this idea very much. KFileItems tend to be created in very > large number, and when listing /usr we really don't need a referrer per > item (ok an empty QString is only 4 bytes, but still...). I feel that > KFileItem is much too low-level for this kind of information. It doesn't cause any overhead, see attached patch.=20 > > now everything works great except that void > > KonqMainWindow::slotPopupMenu(...) sets "bool showPropsAndFileType" > > depending on the function signature that was used. > > Hmm, yeah, the problem of a generic framework which wants to adapt > popup menus to the kind of part requesting the popupmenu.... > > > Any ideas how to set showPropsAndFileType based on something else? > > Can I suggest to rewind a little bit on the possible solutions? > > We have 4 variants of the popupMenu signal already... I feel that this > should have been done with a struct as parameter instead, like we did with > URLArgs. What about adding a 5th popupMenu signal, with a struct as param? > In fact we could even use URLArgs for this, AFAICS, since opening the url > which the popup menu is about, is just like a openURL call - we need all > the URLArgs data, including all the metadata etc. > > So I'd suggest > void popupMenu( KXMLGUIClient *client, > const QPoint &global, const KURL &url, > const URLArgs& args, mode_t mode =3D (mode_t)-1 ); > > (Note that the URLArgs ship the mimetype already, in the "serviceType" > member). =46ine with me as well. I didn't want to add yet another popupMenu signal s= ince=20 we have so many already. Cheers, Waldo =2D --=20 bastian@kde.org -=3D|[ SuSE, The Linux Desktop Experts ]|=3D- bastian@suse.= com =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE/N3/JN4pvrENfboIRAqOFAJ46Se4ZZ6+sdAvj8bCQPdBuRoup4QCgmKsn LWvsZpoD3qAN3SHq3rIk1wM=3D =3DTesj =2D----END PGP SIGNATURE----- --Boundary-00=_J/3N/z4gE+WM201 Content-Type: text/x-diff; charset="iso-8859-1"; name="kfileitem.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kfileitem.patch" Index: kfileitem.cpp =================================================================== RCS file: /home/kde/kdelibs/kio/kio/kfileitem.cpp,v retrieving revision 1.147 diff -u -r1.147 kfileitem.cpp --- kfileitem.cpp 24 Jul 2003 11:04:59 -0000 1.147 +++ kfileitem.cpp 11 Aug 2003 11:29:19 -0000 @@ -780,6 +780,33 @@ return m_metaInfo; } +QString KFileItem::referrer() const +{ + // Extract it from the KIO::UDSEntry + KIO::UDSEntry::ConstIterator it = m_entry.begin(); + for( ; it != m_entry.end(); it++ ) + if ( (*it).m_uds == KIO::UDS_REFERRER ) + return (*it).m_str; + + return QString::null; +} + +void KFileItem::setReferrer(const QString &_referrer) +{ + KIO::UDSEntry::Iterator it = m_entry.begin(); + for( ; it != m_entry.end(); it++ ) + if ( (*it).m_uds == KIO::UDS_REFERRER ) + { + (*it).m_str = _referrer; + return; + } + + KIO::UDSAtom ref; + ref.m_uds = KIO::UDS_REFERRER; + ref.m_str = _referrer; + m_entry.prepend(ref); +} + void KFileItem::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } Index: kfileitem.h =================================================================== RCS file: /home/kde/kdelibs/kio/kio/kfileitem.h,v retrieving revision 1.85 diff -u -r1.85 kfileitem.h --- kfileitem.h 9 Dec 2002 12:20:28 -0000 1.85 +++ kfileitem.h 11 Aug 2003 11:29:19 -0000 @@ -432,6 +432,17 @@ */ void assign( const KFileItem & item ); + /** + * Returns the referrer to use when opening this item + * @since 3.2 + */ + QString referrer() const; + + /** + * Sets the referrer to use when opening this item + * @since 3.2 + */ + void setReferrer(const QString &_referrer); ///////////// --Boundary-00=_J/3N/z4gE+WM201--