#include "dolphinview.h"
+#include <QAbstractItemView>
#include <QApplication>
#include <QClipboard>
#include <QKeyEvent>
m_mode(DolphinView::IconsView),
m_topLayout(0),
m_controller(0),
- m_fileItemDelegate(0),
m_viewAccessor(proxyModel),
m_selectionChangedTimer(0),
m_versionControlObserver(0),
// the file item delegate has been recreated, apply the current
// additional information manually
const KFileItemDelegate::InformationList infoList = props.additionalInfo();
- m_fileItemDelegate->setShowInformation(infoList);
+ m_viewAccessor.itemDelegate()->setShowInformation(infoList);
emit additionalInfoChanged();
// Not all view modes support categorized sorting. Adjust the sorting model
const KUrl viewPropsUrl = rootUrl();
ViewProperties props(viewPropsUrl);
props.setAdditionalInfo(info);
- m_fileItemDelegate->setShowInformation(info);
+ m_viewAccessor.itemDelegate()->setShowInformation(info);
emit additionalInfoChanged();
KFileItemDelegate::InformationList DolphinView::additionalInfo() const
{
- return m_fileItemDelegate->showInformation();
+ return m_viewAccessor.itemDelegate()->showInformation();
}
void DolphinView::reload()
}
m_controller->setUrl(url); // emits urlChanged, which we forward
- if (m_viewAccessor.prepareUrlChange(url)) {
- initializeView();
- }
+ m_viewAccessor.prepareUrlChange(url);
applyViewProperties();
loadDirectory(url);
props.setAdditionalInfo(info);
props.save();
- m_fileItemDelegate->setShowInformation(info);
+ m_viewAccessor.itemDelegate()->setShowInformation(info);
emit additionalInfoChanged();
}
showGroupInfo->setEnabled(enable);
showMimeInfo->setEnabled(enable);
- foreach (KFileItemDelegate::Information info, m_fileItemDelegate->showInformation()) {
+ foreach (KFileItemDelegate::Information info, m_viewAccessor.itemDelegate()->showInformation()) {
switch (info) {
case KFileItemDelegate::Size:
showSizeInfo->setChecked(true);
}
KFileItemDelegate::InformationList info = props.additionalInfo();
- if (info != m_fileItemDelegate->showInformation()) {
- m_fileItemDelegate->setShowInformation(info);
+ if (info != m_viewAccessor.itemDelegate()->showInformation()) {
+ m_viewAccessor.itemDelegate()->setShowInformation(info);
emit additionalInfoChanged();
}
view = 0;
m_viewAccessor.deleteView();
- m_fileItemDelegate = 0;
}
}
m_controller->setItemView(view);
- m_fileItemDelegate = new DolphinFileItemDelegate(view);
- m_fileItemDelegate->setShowToolTipWhenElided(false);
- m_fileItemDelegate->setMinimizedNameColumn(m_mode == DetailsView);
- view->setItemDelegate(m_fileItemDelegate);
-
// TODO: reactivate selection model
/*view->setModel(m_viewAccessor.proxyModel());
if (m_selectionModel != 0) {
}
-bool DolphinView::ViewAccessor::prepareUrlChange(const KUrl& url)
+void DolphinView::ViewAccessor::prepareUrlChange(const KUrl& url)
{
if (m_columnsContainer != 0) {
- return m_columnsContainer->showColumn(url);
+ m_columnsContainer->showColumn(url);
}
- return false;
}
QAbstractItemView* DolphinView::ViewAccessor::itemView() const
return 0;
}
+KFileItemDelegate* DolphinView::ViewAccessor::itemDelegate() const
+{
+ return static_cast<KFileItemDelegate*>(itemView()->itemDelegate());
+}
+
QWidget* DolphinView::ViewAccessor::layoutTarget() const
{
if (m_columnsContainer != 0) {
class DolphinController;
class DolphinColumnViewContainer;
class DolphinDetailsView;
-class DolphinFileItemDelegate;
class DolphinIconsView;
class DolphinMainWindow;
class DolphinModel;
void createView(QWidget* parent, DolphinController* controller, Mode mode);
void deleteView();
- bool prepareUrlChange(const KUrl& url);
+
+ /**
+ * Must be invoked before the URL has been changed and allows view implementations
+ * like the column view to create a new column.
+ */
+ void prepareUrlChange(const KUrl& url);
+
QAbstractItemView* itemView() const;
+ KFileItemDelegate* itemDelegate() const;
/**
* Returns the widget that should be added to the layout as target. Usually
QVBoxLayout* m_topLayout;
DolphinController* m_controller;
- DolphinFileItemDelegate* m_fileItemDelegate;
ViewAccessor m_viewAccessor;
QItemSelectionModel* m_selectionModel;
#include "viewextensionsfactory.h"
#include "dolphincontroller.h"
+#include "dolphinfileitemdelegate.h"
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
#include "dolphinviewautoscroller.h"
m_toolTipManager(0),
m_previewGenerator(0),
m_selectionManager(0),
- m_autoScroller(0)
+ m_autoScroller(0),
+ m_fileItemDelegate(0)
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
connect(controller, SIGNAL(currentIndexChanged(QModelIndex, QModelIndex)),
m_autoScroller, SLOT(handleCurrentIndexChanged(QModelIndex, QModelIndex)));
+ // initialize file item delegate
+ m_fileItemDelegate = new DolphinFileItemDelegate(view);
+ m_fileItemDelegate->setShowToolTipWhenElided(false);
+ view->setItemDelegate(m_fileItemDelegate);
+
view->viewport()->installEventFilter(this);
}
m_autoScroller->handleCurrentIndexChange(current, previous);
}
+DolphinFileItemDelegate* ViewExtensionsFactory::fileItemDelegate() const
+{
+ return m_fileItemDelegate;
+}
+
bool ViewExtensionsFactory::eventFilter(QObject* watched, QEvent* event)
{
Q_UNUSED(watched);