mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Moved all the extension code into dolphinpart_ext.*
REVIEW: 113132
This commit is contained in:
parent
2114210905
commit
e3b840e4aa
|
@ -616,89 +616,4 @@ bool DolphinPart::eventFilter(QObject* obj, QEvent* event)
|
|||
return KParts::ReadOnlyPart::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
|
||||
{
|
||||
KParts::BrowserExtension::restoreState(stream);
|
||||
m_part->view()->restoreState(stream);
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::saveState(QDataStream &stream)
|
||||
{
|
||||
KParts::BrowserExtension::saveState(stream);
|
||||
m_part->view()->saveState(stream);
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::cut()
|
||||
{
|
||||
m_part->view()->cutSelectedItems();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::copy()
|
||||
{
|
||||
m_part->view()->copySelectedItems();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::paste()
|
||||
{
|
||||
m_part->view()->paste();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::pasteTo(const KUrl&)
|
||||
{
|
||||
m_part->view()->pasteIntoFolder();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::reparseConfiguration()
|
||||
{
|
||||
m_part->view()->readSettings();
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart* part)
|
||||
: KParts::FileInfoExtension(part)
|
||||
{
|
||||
}
|
||||
|
||||
DolphinPart* DolphinPartFileInfoExtension::part() const
|
||||
{
|
||||
return static_cast<DolphinPart*>(parent());
|
||||
}
|
||||
|
||||
bool DolphinPartFileInfoExtension::hasSelection() const
|
||||
{
|
||||
return part()->view()->selectedItemsCount() > 0;
|
||||
}
|
||||
|
||||
KParts::FileInfoExtension::QueryModes DolphinPartFileInfoExtension::supportedQueryModes() const
|
||||
{
|
||||
return (KParts::FileInfoExtension::AllItems | KParts::FileInfoExtension::SelectedItems);
|
||||
}
|
||||
|
||||
KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode) const
|
||||
{
|
||||
KFileItemList list;
|
||||
|
||||
if (mode == KParts::FileInfoExtension::None)
|
||||
return list;
|
||||
|
||||
if (!(supportedQueryModes() & mode))
|
||||
return list;
|
||||
|
||||
switch (mode) {
|
||||
case KParts::FileInfoExtension::SelectedItems:
|
||||
if (hasSelection())
|
||||
return part()->view()->selectedItems();
|
||||
break;
|
||||
case KParts::FileInfoExtension::AllItems:
|
||||
return part()->view()->items();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
#include "dolphinpart.moc"
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#define DOLPHINPART_H
|
||||
|
||||
#include <kparts/part.h>
|
||||
#include <kparts/browserextension.h>
|
||||
#include <kparts/fileinfoextension.h>
|
||||
|
||||
#include <QItemSelectionModel>
|
||||
|
||||
|
@ -252,41 +250,4 @@ private:
|
|||
Q_DISABLE_COPY(DolphinPart)
|
||||
};
|
||||
|
||||
class DolphinPartBrowserExtension : public KParts::BrowserExtension
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DolphinPartBrowserExtension( DolphinPart* part )
|
||||
: KParts::BrowserExtension( part ), m_part(part) {}
|
||||
|
||||
virtual void restoreState(QDataStream &stream);
|
||||
virtual void saveState(QDataStream &stream);
|
||||
|
||||
public Q_SLOTS:
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void pasteTo(const KUrl&);
|
||||
void reparseConfiguration();
|
||||
|
||||
private:
|
||||
DolphinPart* m_part;
|
||||
};
|
||||
|
||||
|
||||
class DolphinPartFileInfoExtension : public KParts::FileInfoExtension
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DolphinPartFileInfoExtension(DolphinPart* part);
|
||||
|
||||
virtual QueryModes supportedQueryModes() const;
|
||||
virtual bool hasSelection() const;
|
||||
|
||||
virtual KFileItemList queryFor(QueryMode mode) const;
|
||||
protected:
|
||||
DolphinPart* part() const;
|
||||
};
|
||||
|
||||
#endif /* DOLPHINPART_H */
|
||||
|
|
|
@ -26,6 +26,92 @@
|
|||
|
||||
#include <KFileItemList>
|
||||
|
||||
|
||||
DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part)
|
||||
:KParts::BrowserExtension( part )
|
||||
,m_part(part)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
|
||||
{
|
||||
KParts::BrowserExtension::restoreState(stream);
|
||||
m_part->view()->restoreState(stream);
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::saveState(QDataStream &stream)
|
||||
{
|
||||
KParts::BrowserExtension::saveState(stream);
|
||||
m_part->view()->saveState(stream);
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::cut()
|
||||
{
|
||||
m_part->view()->cutSelectedItems();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::copy()
|
||||
{
|
||||
m_part->view()->copySelectedItems();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::paste()
|
||||
{
|
||||
m_part->view()->paste();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::pasteTo(const KUrl&)
|
||||
{
|
||||
m_part->view()->pasteIntoFolder();
|
||||
}
|
||||
|
||||
void DolphinPartBrowserExtension::reparseConfiguration()
|
||||
{
|
||||
m_part->view()->readSettings();
|
||||
}
|
||||
|
||||
|
||||
DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart* part)
|
||||
:KParts::FileInfoExtension(part)
|
||||
,m_part(part)
|
||||
{
|
||||
}
|
||||
|
||||
bool DolphinPartFileInfoExtension::hasSelection() const
|
||||
{
|
||||
return m_part->view()->selectedItemsCount() > 0;
|
||||
}
|
||||
|
||||
KParts::FileInfoExtension::QueryModes DolphinPartFileInfoExtension::supportedQueryModes() const
|
||||
{
|
||||
return (KParts::FileInfoExtension::AllItems | KParts::FileInfoExtension::SelectedItems);
|
||||
}
|
||||
|
||||
KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode) const
|
||||
{
|
||||
KFileItemList list;
|
||||
|
||||
if (mode == KParts::FileInfoExtension::None)
|
||||
return list;
|
||||
|
||||
if (!(supportedQueryModes() & mode))
|
||||
return list;
|
||||
|
||||
switch (mode) {
|
||||
case KParts::FileInfoExtension::SelectedItems:
|
||||
if (hasSelection())
|
||||
return m_part->view()->selectedItems();
|
||||
break;
|
||||
case KParts::FileInfoExtension::AllItems:
|
||||
return m_part->view()->items();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
DolphinPartListingFilterExtension::DolphinPartListingFilterExtension(DolphinPart* part)
|
||||
: KParts::ListingFilterExtension(part)
|
||||
, m_part(part)
|
||||
|
|
|
@ -20,11 +20,47 @@
|
|||
#ifndef DOLPHINPART_EXT_H
|
||||
#define DOLPHINPART_EXT_H
|
||||
|
||||
|
||||
#include <kparts/browserextension.h>
|
||||
#include <kparts/fileinfoextension.h>
|
||||
#include <kparts/listingextension.h>
|
||||
|
||||
class DolphinPart;
|
||||
|
||||
class DolphinPartBrowserExtension : public KParts::BrowserExtension
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DolphinPartBrowserExtension( DolphinPart* part );
|
||||
virtual void restoreState(QDataStream &stream);
|
||||
virtual void saveState(QDataStream &stream);
|
||||
|
||||
public Q_SLOTS:
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void pasteTo(const KUrl&);
|
||||
void reparseConfiguration();
|
||||
|
||||
private:
|
||||
DolphinPart* m_part;
|
||||
};
|
||||
|
||||
class DolphinPartFileInfoExtension : public KParts::FileInfoExtension
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DolphinPartFileInfoExtension(DolphinPart* part);
|
||||
|
||||
virtual QueryModes supportedQueryModes() const;
|
||||
virtual bool hasSelection() const;
|
||||
|
||||
virtual KFileItemList queryFor(QueryMode mode) const;
|
||||
|
||||
private:
|
||||
DolphinPart* m_part;
|
||||
};
|
||||
|
||||
class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
Loading…
Reference in a new issue