Implement contextMenu handling in dolphin part (for konqueror)

svn path=/trunk/KDE/kdebase/apps/; revision=705873
This commit is contained in:
David Faure 2007-08-28 19:48:36 +00:00
parent 9c7ccd477a
commit 246c18a93c
3 changed files with 40 additions and 7 deletions

View file

@ -72,11 +72,15 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
this, SLOT(slotErrorMessage(QString)));
connect(m_view, SIGNAL(itemTriggered(KFileItem)),
this, SLOT(slotItemTriggered(KFileItem)));
// TODO connect to urlsDropped
// TOOD connect to requestContextMenu
connect(m_view, SIGNAL(selectionChanged(QList<KFileItem>)), m_extension, SIGNAL(selectionInfo(QList<KFileItem>)));
connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),
this, SLOT(slotOpenContextMenu(KFileItem, const KUrl&)));
connect(m_view, SIGNAL(selectionChanged(QList<KFileItem>)),
m_extension, SIGNAL(selectionInfo(QList<KFileItem>)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(slotRequestItemInfo(KFileItem)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(slotRequestItemInfo(KFileItem)));
// TODO connect to urlsDropped
// TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
// (sort of spacial navigation)
@ -101,8 +105,8 @@ KAboutData* DolphinPart::createAboutData()
bool DolphinPart::openUrl(const KUrl& url)
{
const QString prettyUrl = url.pathOrUrl();
setWindowCaption(prettyUrl);
m_extension->setLocationBarUrl(prettyUrl);
emit setWindowCaption(prettyUrl);
emit m_extension->setLocationBarUrl(prettyUrl);
m_view->setUrl(url);
if (arguments().reload())
m_view->reload();
@ -141,4 +145,19 @@ void DolphinPart::slotItemTriggered(const KFileItem& item)
emit m_extension->openUrlRequest(item.url());
}
void DolphinPart::slotOpenContextMenu(const KFileItem& item, const KUrl&)
{
// TODO KonqKfmIconView had if ( !rootItem->isWritable() )
// popupFlags |= KParts::BrowserExtension::NoDeletion;
// and when clicking on the viewport:
// KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
KFileItem* itemCopy = new KFileItem(item); // ugly
KFileItemList items; items.append(itemCopy);
emit m_extension->popupMenu( 0, QCursor::pos(), items );
delete itemCopy;
}
#include "dolphinpart.moc"

View file

@ -51,8 +51,22 @@ private Q_SLOTS:
void slotCanceled(const KUrl& url);
void slotInfoMessage(const QString& msg);
void slotErrorMessage(const QString& msg);
/**
* Shows the information for the item \a item inside the statusbar. If the
* item is null, the default statusbar information is shown.
*/
void slotRequestItemInfo(const KFileItem& item);
/**
* Handles clicking on an item
*/
void slotItemTriggered(const KFileItem& item);
/**
* Opens the context menu on the current mouse position.
* @item File item context. If item is 0, the context menu
* should be applied to \a url.
* @url URL which contains \a item.
*/
void slotOpenContextMenu(const KFileItem& item, const KUrl& url);
private:
DolphinView* m_view;

View file

@ -177,7 +177,7 @@ private slots:
void changeNameFilter(const QString& nameFilter);
/**
* Opens the context menu on the current mouse postition.
* Opens the context menu on the current mouse position.
* @item File item context. If item is 0, the context menu
* should be applied to \a url.
* @url URL which contains \a item.