and to match the BrowserExtension mouseOverInfo() signal.
Started to implement more of the part (e.g. spinning wheel in konq).
svn path=/trunk/KDE/kdebase/apps/; revision=682440
emit selectionChanged(selection);
}
-void DolphinMainWindow::slotRequestItemInfo(const KUrl& url)
+void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
{
- emit requestItemInfo(url);
+ emit requestItemInfo(item);
}
void DolphinMainWindow::slotHistoryChanged()
infoWidget, SLOT(setUrl(KUrl)));
connect(this, SIGNAL(selectionChanged(KFileItemList)),
infoWidget, SLOT(setSelection(KFileItemList)));
- connect(this, SIGNAL(requestItemInfo(KUrl)),
- infoWidget, SLOT(requestDelayedItemInfo(KUrl)));
+ connect(this, SIGNAL(requestItemInfo(KFileItem)),
+ infoWidget, SLOT(requestDelayedItemInfo(KFileItem)));
// setup "Tree View"
QDockWidget* treeViewDock = new QDockWidget(i18nc("@title:window", "Folders"));
this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation)));
connect(view, SIGNAL(selectionChanged(KFileItemList)),
this, SLOT(slotSelectionChanged(KFileItemList)));
- connect(view, SIGNAL(requestItemInfo(KUrl)),
- this, SLOT(slotRequestItemInfo(KUrl)));
+ connect(view, SIGNAL(requestItemInfo(KFileItem)),
+ this, SLOT(slotRequestItemInfo(KFileItem)));
connect(view, SIGNAL(activated()),
this, SLOT(toggleActiveView()));
/**
* Is emitted if information of an item is requested to be shown e. g. in the sidebar.
- * It the URL is empty, no item information request is pending.
+ * If item is null, no item information request is pending.
*/
- void requestItemInfo(const KUrl& url);
+ void requestItemInfo(const KFileItem& item);
protected:
/** @see QMainWindow::closeEvent */
void slotSelectionChanged(const KFileItemList& selection);
/** Emits the signal requestItemInfo(). */
- void slotRequestItemInfo(const KUrl& url);
+ void slotRequestItemInfo(const KFileItem&);
/**
* Updates the state of the 'Back' and 'Forward' menu
*/
#include "dolphinpart.h"
-#include <kparts/genericfactory.h>
-#include "dolphinview.h"
#include "dolphinsortfilterproxymodel.h"
-#include <kdirmodel.h>
+#include "dolphinview.h"
+
#include <kdirlister.h>
+#include <kdirmodel.h>
+#include <kmessagebox.h>
+#include <kparts/browserextension.h>
+#include <kparts/genericfactory.h>
typedef KParts::GenericFactory<DolphinPart> DolphinPartFactory;
K_EXPORT_COMPONENT_FACTORY(dolphinpart, DolphinPartFactory)
+class DolphinPartBrowserExtension : public KParts::BrowserExtension
+{
+public:
+ DolphinPartBrowserExtension( KParts::ReadOnlyPart* part )
+ : KParts::BrowserExtension( part ) {}
+};
+
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringList& args)
: KParts::ReadOnlyPart(parent)
{
Q_UNUSED(args)
setComponentData( DolphinPartFactory::componentData() );
- //setBrowserExtension( new DolphinPartBrowserExtension( this ) );
+ m_extension = new DolphinPartBrowserExtension(this);
m_dirLister = new KDirLister;
m_dirLister->setAutoUpdate(true);
m_dirLister->setMainWindow(parentWidget->topLevelWidget());
m_dirLister->setDelayedMimeTypes(true);
+ //connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotStarted()));
+ connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl)));
+ connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl)));
+
m_dirModel = new KDirModel(this);
m_dirModel->setDirLister(m_dirLister);
m_dirModel,
m_proxyModel);
setWidget(m_view);
+
+ connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(slotInfoMessage(QString)));
+ connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
+ // TODO connect to urlsDropped
+ // TOOD connect to requestContextMenu
+ connect(m_view, SIGNAL(selectionChanged(KFileItemList)), m_extension, SIGNAL(selectionInfo(KFileItemList)));
+
+ connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(slotRequestItemInfo(KFileItem)));
+
+ // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
+ // (sort of spacial navigation)
+
+ // TODO when clicking on a file we want to emit m_extension->openUrlRequest(url, args)
+ // to be able to embed the viewer
+
+ // TODO MMB-click should do something like KonqDirPart::mmbClicked
+
+ // TODO updating the paste action
+ // if (paste) emit m_extension->setActionText( "paste", actionText );
+ // emit m_extension->enableAction( "paste", paste );
}
DolphinPart::~DolphinPart()
bool DolphinPart::openUrl(const KUrl& url)
{
+ const QString prettyUrl = url.pathOrUrl();
+ setWindowCaption(prettyUrl);
+ m_extension->setLocationBarUrl(prettyUrl);
+ const KParts::URLArgs args = m_extension->urlArgs();
m_view->setUrl(url);
+ if (args.reload)
+ m_view->reload();
+ emit started(0); // get the wheel to spin
return true;
}
+void DolphinPart::slotCompleted(const KUrl& url)
+{
+ Q_UNUSED(url)
+ emit completed();
+}
+
+void DolphinPart::slotCanceled(const KUrl& url)
+{
+ slotCompleted(url);
+}
+
+void DolphinPart::slotInfoMessage(const QString& msg)
+{
+ emit setStatusBarText(msg);
+}
+
+void DolphinPart::slotErrorMessage(const QString& msg)
+{
+ KMessageBox::error(m_view, msg);
+}
+
+void DolphinPart::slotRequestItemInfo(const KFileItem& item)
+{
+ emit m_extension->mouseOverInfo(&item);
+}
+
#include "dolphinpart.moc"
#define DOLPHINPART_H
#include <kparts/part.h>
+class KFileItem;
+class DolphinPartBrowserExtension;
class DolphinSortFilterProxyModel;
class KDirModel;
class KDirLister;
protected:
virtual bool openFile() { return true; }
+private Q_SLOTS:
+ void slotCompleted(const KUrl& url);
+ void slotCanceled(const KUrl& url);
+ void slotInfoMessage(const QString& msg);
+ void slotErrorMessage(const QString& msg);
+ void slotRequestItemInfo(const KFileItem& item);
+
private:
DolphinView* m_view;
KDirLister* m_dirLister;
KDirModel* m_dirModel;
DolphinSortFilterProxyModel* m_proxyModel;
+ DolphinPartBrowserExtension* m_extension;
Q_DISABLE_COPY(DolphinPart)
};
const KFileItem* item = fileItem(index);
if (item != 0) {
- emit requestItemInfo(item->url());
+ emit requestItemInfo(*item);
}
}
void DolphinView::clearHoverInformation()
{
- emit requestItemInfo(KUrl());
+ emit requestItemInfo(KFileItem());
}
/**
* Is emitted if information of an item is requested to be shown e. g. in the sidebar.
- * It the URL is empty, no item information request is pending.
+ * If item is null, no item information request is pending.
*/
- void requestItemInfo(const KUrl& url);
+ void requestItemInfo(const KFileItem& item);
/** Is emitted if the contents has been moved to \a x, \a y. */
void contentsMoved(int x, int y);
m_mainWindow, SLOT(dropUrls(const KUrl::List&, const KUrl&)));
connect(m_view, SIGNAL(contentsMoved(int, int)),
this, SLOT(saveContentsPos(int, int)));
- connect(m_view, SIGNAL(requestItemInfo(const KUrl&)),
- this, SLOT(showItemInfo(const KUrl&)));
+ connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
+ this, SLOT(showItemInfo(KFileItem)));
connect(m_view, SIGNAL(errorMessage(const QString&)),
this, SLOT(showErrorMessage(const QString&)));
connect(m_view, SIGNAL(infoMessage(const QString&)),
QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
}
-void DolphinViewContainer::showItemInfo(const KUrl& url)
+void DolphinViewContainer::showItemInfo(const KFileItem& item)
{
- if (url.isEmpty()) {
+ if (item.isNull()) {
m_statusBar->clear();
- return;
- }
-
- const QModelIndex index = m_dirModel->indexForUrl(url);
- const KFileItem* item = m_dirModel->itemForIndex(index);
- if (item != 0) {
- m_statusBar->setMessage(item->getStatusBarInfo(), DolphinStatusBar::Default);
+ } else {
+ m_statusBar->setMessage(item.getStatusBarInfo(), DolphinStatusBar::Default);
}
}
* Shows the item information for the URL \a url inside the statusbar. If the
* URL is empty, the default statusbar information is shown.
*/
- void showItemInfo(const KUrl& url);
+ void showItemInfo(const KFileItem& item);
/** Shows the information \a msg inside the statusbar. */
void showInfoMessage(const QString& msg);