Fix crash in dolphinpart when doing RMB on viewport.

Clean up unnecessary use of Q3ValueList.

svn path=/trunk/KDE/kdebase/apps/; revision=714532
This commit is contained in:
David Faure 2007-09-19 20:33:28 +00:00
parent 9d277154e1
commit ce3ec0d0e6
3 changed files with 35 additions and 9 deletions

View file

@ -46,7 +46,6 @@
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <Qt3Support/Q3ValueList>
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
const KFileItem& fileInfo, const KFileItem& fileInfo,
@ -435,10 +434,10 @@ QList<QAction*> DolphinContextMenu::insertActionItems(KMenu* popup,
actionsMenu->addMenu(menu); actionsMenu->addMenu(menu);
} }
Q3ValueList<KDesktopFileActions::Service> userServices = QList<KDesktopFileActions::Service> userServices =
KDesktopFileActions::userDefinedServices(*dirIt + *entryIt, true); KDesktopFileActions::userDefinedServices(*dirIt + *entryIt, true);
Q3ValueList<KDesktopFileActions::Service>::Iterator serviceIt; QList<KDesktopFileActions::Service>::const_iterator serviceIt;
for (serviceIt = userServices.begin(); serviceIt != userServices.end(); ++serviceIt) { for (serviceIt = userServices.begin(); serviceIt != userServices.end(); ++serviceIt) {
KDesktopFileActions::Service service = (*serviceIt); KDesktopFileActions::Service service = (*serviceIt);
if (!service.m_strIcon.isEmpty()) { if (!service.m_strIcon.isEmpty()) {

View file

@ -26,6 +26,7 @@
#include <kmessagebox.h> #include <kmessagebox.h>
#include <kparts/browserextension.h> #include <kparts/browserextension.h>
#include <kparts/genericfactory.h> #include <kparts/genericfactory.h>
#include <QApplication>
typedef KParts::GenericFactory<DolphinPart> DolphinPartFactory; typedef KParts::GenericFactory<DolphinPart> DolphinPartFactory;
K_EXPORT_COMPONENT_FACTORY(dolphinpart, DolphinPartFactory) K_EXPORT_COMPONENT_FACTORY(dolphinpart, DolphinPartFactory)
@ -80,6 +81,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
connect(m_view, SIGNAL(requestItemInfo(KFileItem)), connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(slotRequestItemInfo(KFileItem))); this, SLOT(slotRequestItemInfo(KFileItem)));
// TODO provide a way to switch from iconview to listview (and others)
// TODO connect to urlsDropped // TODO connect to urlsDropped
// TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
@ -90,6 +93,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
// TODO updating the paste action // TODO updating the paste action
// if (paste) emit m_extension->setActionText( "paste", actionText ); // if (paste) emit m_extension->setActionText( "paste", actionText );
// emit m_extension->enableAction( "paste", paste ); // emit m_extension->enableAction( "paste", paste );
// TODO updating the trash and del actions too - or removing special handling of those from konq?
} }
DolphinPart::~DolphinPart() DolphinPart::~DolphinPart()
@ -147,21 +152,43 @@ void DolphinPart::slotRequestItemInfo(const KFileItem& item)
void DolphinPart::slotItemTriggered(const KFileItem& item) void DolphinPart::slotItemTriggered(const KFileItem& item)
{ {
emit m_extension->openUrlRequest(item.url()); qDebug() << QApplication::mouseButtons();
if (QApplication::mouseButtons() & Qt::MidButton) {
qDebug() << "MMB!!" << item.mimetype();
if (item.mimeTypePtr()->is("inode/directory")) {
KParts::OpenUrlArguments args;
args.setMimeType( item.mimetype() );
emit m_extension->createNewWindow( item.url(), args );
} else {
qDebug() << "run()";
item.run();
}
} else {
// Left button. [Right button goes to slotOpenContextMenu before triggered can be emitted]
qDebug() << "LMB";
emit m_extension->openUrlRequest(item.url());
}
} }
void DolphinPart::slotOpenContextMenu(const KFileItem& item, const KUrl&) void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&)
{ {
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems;
// TODO KonqKfmIconView had if ( !rootItem->isWritable() ) // TODO KonqKfmIconView had if ( !rootItem->isWritable() )
// popupFlags |= KParts::BrowserExtension::NoDeletion; // popupFlags |= KParts::BrowserExtension::NoDeletion;
// and when clicking on the viewport: KFileItem item(_item);
// KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
if (item.isNull()) { // viewport context menu
popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
// TODO get m_dirLister->rootItem if possible. or via kdirmodel?
// and use this as fallback:
item = KFileItem( S_IFDIR, (mode_t)-1, url() );
}
// TODO port popupMenu to QList<KFileItem>
KFileItem* itemCopy = new KFileItem(item); // ugly KFileItem* itemCopy = new KFileItem(item); // ugly
KFileItemList items; items.append(itemCopy); KFileItemList items; items.append(itemCopy);
emit m_extension->popupMenu( 0, QCursor::pos(), items ); emit m_extension->popupMenu( 0, QCursor::pos(), items, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags );
delete itemCopy; delete itemCopy;
} }

View file

@ -425,7 +425,7 @@ void DolphinView::setUrl(const KUrl& url)
void DolphinView::mouseReleaseEvent(QMouseEvent* event) void DolphinView::mouseReleaseEvent(QMouseEvent* event)
{ {
QWidget::mouseReleaseEvent(event); QWidget::mouseReleaseEvent(event);
setActive(true);; setActive(true);
} }
void DolphinView::activate() void DolphinView::activate()
{ {