mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 10:52:49 +00:00
kio: export KAbstractViewAdapter class
currently only the plasma folderview applet uses it but it has a copy of the header so better export it Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
19df721868
commit
102f74021f
7 changed files with 42 additions and 57 deletions
|
@ -38,6 +38,7 @@ set(kfile_LIB_SRCS
|
||||||
kurlnavigatortogglebutton.cpp
|
kurlnavigatortogglebutton.cpp
|
||||||
kurlnavigator.cpp
|
kurlnavigator.cpp
|
||||||
kurlnavigatormenu.cpp
|
kurlnavigatormenu.cpp
|
||||||
|
kdefaultviewadapter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(kfile SHARED ${kfile_LIB_SRCS})
|
add_library(kfile SHARED ${kfile_LIB_SRCS})
|
||||||
|
|
|
@ -17,52 +17,44 @@
|
||||||
* Boston, MA 02110-1301, USA. *
|
* Boston, MA 02110-1301, USA. *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "defaultviewadapter_p.h"
|
#include "kdefaultviewadapter_p.h"
|
||||||
|
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
namespace KIO
|
KDefaultViewAdapter::KDefaultViewAdapter(QAbstractItemView* view, QObject* parent) :
|
||||||
{
|
|
||||||
|
|
||||||
DefaultViewAdapter::DefaultViewAdapter(QAbstractItemView* view, QObject* parent) :
|
|
||||||
KAbstractViewAdapter(parent),
|
KAbstractViewAdapter(parent),
|
||||||
m_view(view)
|
m_view(view)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractItemModel *DefaultViewAdapter::model() const
|
QAbstractItemModel *KDefaultViewAdapter::model() const
|
||||||
{
|
{
|
||||||
return m_view->model();
|
return m_view->model();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize DefaultViewAdapter::iconSize() const
|
QSize KDefaultViewAdapter::iconSize() const
|
||||||
{
|
{
|
||||||
return m_view->iconSize();
|
return m_view->iconSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPalette DefaultViewAdapter::palette() const
|
QPalette KDefaultViewAdapter::palette() const
|
||||||
{
|
{
|
||||||
return m_view->palette();
|
return m_view->palette();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect DefaultViewAdapter::visibleArea() const
|
QRect KDefaultViewAdapter::visibleArea() const
|
||||||
{
|
{
|
||||||
return m_view->viewport()->rect();
|
return m_view->viewport()->rect();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect DefaultViewAdapter::visualRect(const QModelIndex& index) const
|
QRect KDefaultViewAdapter::visualRect(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
return m_view->visualRect(index);
|
return m_view->visualRect(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultViewAdapter::connect(Signal signal, QObject* receiver, const char* slot)
|
void KDefaultViewAdapter::connectScrollBar(QObject* receiver, const char* slot)
|
||||||
{
|
{
|
||||||
if (signal == ScrollBarValueChanged) {
|
|
||||||
QObject::connect(m_view->horizontalScrollBar(), SIGNAL(valueChanged(int)), receiver, slot);
|
QObject::connect(m_view->horizontalScrollBar(), SIGNAL(valueChanged(int)), receiver, slot);
|
||||||
QObject::connect(m_view->verticalScrollBar(), SIGNAL(valueChanged(int)), receiver, slot);
|
QObject::connect(m_view->verticalScrollBar(), SIGNAL(valueChanged(int)), receiver, slot);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,34 +17,30 @@
|
||||||
* Boston, MA 02110-1301, USA. *
|
* Boston, MA 02110-1301, USA. *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef DEFAULTVIEWADAPTER_H
|
#ifndef KDEFAULTVIEWADAPTER_H
|
||||||
#define DEFAULTVIEWADAPTER_H
|
#define KDEFAULTVIEWADAPTER_H
|
||||||
|
|
||||||
#include <kio/global.h>
|
#include "kabstractviewadapter.h"
|
||||||
#include "kabstractviewadapter_p.h"
|
|
||||||
|
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
|
|
||||||
namespace KIO
|
/**
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Implementation of the view adapter for the default case when
|
* Implementation of the view adapter for the default case when
|
||||||
* an instance of QAbstractItemView is used as view.
|
* an instance of QAbstractItemView is used as view.
|
||||||
*/
|
*/
|
||||||
class KIO_EXPORT DefaultViewAdapter : public KAbstractViewAdapter
|
class KDefaultViewAdapter : public KAbstractViewAdapter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DefaultViewAdapter(QAbstractItemView* view, QObject* parent);
|
KDefaultViewAdapter(QAbstractItemView* view, QObject* parent);
|
||||||
virtual QAbstractItemModel* model() const;
|
virtual QAbstractItemModel* model() const;
|
||||||
virtual QSize iconSize() const;
|
virtual QSize iconSize() const;
|
||||||
virtual QPalette palette() const;
|
virtual QPalette palette() const;
|
||||||
virtual QRect visibleArea() const;
|
virtual QRect visibleArea() const;
|
||||||
virtual QRect visualRect(const QModelIndex& index) const;
|
virtual QRect visualRect(const QModelIndex& index) const;
|
||||||
virtual void connect(Signal signal, QObject* receiver, const char* slot);
|
virtual void connectScrollBar(QObject* receiver, const char* slot);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAbstractItemView* m_view;
|
QAbstractItemView* m_view;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif // KDEFAULTVIEWADAPTER_H
|
|
@ -18,8 +18,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "kfilepreviewgenerator.h"
|
#include "kfilepreviewgenerator.h"
|
||||||
|
#include "kdefaultviewadapter_p.h"
|
||||||
|
|
||||||
#include "../kio/kio/defaultviewadapter_p.h" // KDE5 TODO: move this class here
|
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <kfileitem.h>
|
#include <kfileitem.h>
|
||||||
#include <kiconeffect.h>
|
#include <kiconeffect.h>
|
||||||
|
@ -466,8 +466,7 @@ KFilePreviewGenerator::Private::Private(KFilePreviewGenerator* parent,
|
||||||
m_scrollAreaTimer->setInterval(200);
|
m_scrollAreaTimer->setInterval(200);
|
||||||
connect(m_scrollAreaTimer, SIGNAL(timeout()),
|
connect(m_scrollAreaTimer, SIGNAL(timeout()),
|
||||||
q, SLOT(resumeIconUpdates()));
|
q, SLOT(resumeIconUpdates()));
|
||||||
m_viewAdapter->connect(KAbstractViewAdapter::ScrollBarValueChanged,
|
m_viewAdapter->connectScrollBar(q, SLOT(pauseIconUpdates()));
|
||||||
q, SLOT(pauseIconUpdates()));
|
|
||||||
|
|
||||||
m_changedItemsTimer = new QTimer(q);
|
m_changedItemsTimer = new QTimer(q);
|
||||||
m_changedItemsTimer->setSingleShot(true);
|
m_changedItemsTimer->setSingleShot(true);
|
||||||
|
@ -1159,7 +1158,7 @@ void KFilePreviewGenerator::Private::rowsAboutToBeRemoved(const QModelIndex& par
|
||||||
|
|
||||||
KFilePreviewGenerator::KFilePreviewGenerator(QAbstractItemView* parent) :
|
KFilePreviewGenerator::KFilePreviewGenerator(QAbstractItemView* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
d(new Private(this, new KIO::DefaultViewAdapter(parent, this), parent->model()))
|
d(new Private(this, new KDefaultViewAdapter(parent, this), parent->model()))
|
||||||
{
|
{
|
||||||
d->m_itemView = parent;
|
d->m_itemView = parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,12 @@
|
||||||
|
|
||||||
#include <kfile_export.h>
|
#include <kfile_export.h>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QObject>
|
||||||
|
#include <QAbstractItemView>
|
||||||
|
#include <QAbstractProxyModel>
|
||||||
|
|
||||||
class KAbstractViewAdapter;
|
class KAbstractViewAdapter;
|
||||||
class KDirModel;
|
class KDirModel;
|
||||||
#include <QAbstractItemView>
|
|
||||||
#include <QAbstractProxyModel>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generates previews for files of an item view.
|
* @brief Generates previews for files of an item view.
|
||||||
|
|
|
@ -31,7 +31,6 @@ set(kiocore_STAT_SRCS
|
||||||
kio/chmodjob.cpp
|
kio/chmodjob.cpp
|
||||||
kio/connection.cpp
|
kio/connection.cpp
|
||||||
kio/copyjob.cpp
|
kio/copyjob.cpp
|
||||||
kio/defaultviewadapter.cpp
|
|
||||||
kio/deletejob.cpp
|
kio/deletejob.cpp
|
||||||
kio/directorysizejob.cpp
|
kio/directorysizejob.cpp
|
||||||
kio/fileundomanager.cpp
|
kio/fileundomanager.cpp
|
||||||
|
@ -209,6 +208,7 @@ install(
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
kio/kabstractfileitemactionplugin.h
|
kio/kabstractfileitemactionplugin.h
|
||||||
|
kio/kabstractviewadapter.h
|
||||||
kio/kacl.h
|
kio/kacl.h
|
||||||
kio/kautomount.h
|
kio/kautomount.h
|
||||||
kio/kbuildsycocaprogressdialog.h
|
kio/kbuildsycocaprogressdialog.h
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef KABSTRACTVIEWADAPTER_H
|
#ifndef KABSTRACTVIEWADAPTER_H
|
||||||
#define KABSTRACTVIEWADAPTER_H
|
#define KABSTRACTVIEWADAPTER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <kio/kio_export.h>
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
@ -33,12 +33,9 @@
|
||||||
* for files. The interface allows KFilePreviewGenerator to be
|
* for files. The interface allows KFilePreviewGenerator to be
|
||||||
* independent from the view implementation.
|
* independent from the view implementation.
|
||||||
*/
|
*/
|
||||||
class KAbstractViewAdapter : public QObject
|
class KIO_EXPORT KAbstractViewAdapter : public QObject
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Signal { ScrollBarValueChanged };
|
|
||||||
|
|
||||||
KAbstractViewAdapter(QObject *parent) : QObject(parent) {}
|
KAbstractViewAdapter(QObject *parent) : QObject(parent) {}
|
||||||
virtual ~KAbstractViewAdapter() {}
|
virtual ~KAbstractViewAdapter() {}
|
||||||
virtual QAbstractItemModel *model() const = 0;
|
virtual QAbstractItemModel *model() const = 0;
|
||||||
|
@ -46,8 +43,8 @@ public:
|
||||||
virtual QPalette palette() const = 0;
|
virtual QPalette palette() const = 0;
|
||||||
virtual QRect visibleArea() const = 0;
|
virtual QRect visibleArea() const = 0;
|
||||||
virtual QRect visualRect(const QModelIndex &index) const = 0;
|
virtual QRect visualRect(const QModelIndex &index) const = 0;
|
||||||
virtual void connect(Signal signal, QObject *receiver, const char *slot) = 0;
|
virtual void connectScrollBar(QObject *receiver, const char *slot) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // KABSTRACTVIEWADAPTER_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue