diff options
| author | Peter Penz <[email protected]> | 2009-08-28 21:04:15 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2009-08-28 21:04:15 +0000 |
| commit | 41c14c5f8ebc00ba443f13d300f5b445aee7aa1b (patch) | |
| tree | 480a235901910eaa707d50050cf6f37ee83ab30a /src/dolphinview.h | |
| parent | dcf397ae512850805dbe37fc03ece82be2660bd0 (diff) | |
I wanted to this for KDE 4.1 already, but well...
Columview refactoring: Get rid of "isColumnView()" special cases in DolphinView and the interface code duplications due to delegating non-QAbstractItemView interfaces to the column view. This reduces the code size + complexity a lot and will make future maintainance of the columnview and DolphinView a lot easier.
Currently there are some regressions in the column view, but this will be fixed during the next 14 days.
svn path=/trunk/KDE/kdebase/apps/; revision=1016776
Diffstat (limited to 'src/dolphinview.h')
| -rw-r--r-- | src/dolphinview.h | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/src/dolphinview.h b/src/dolphinview.h index 58924697e..93299b430 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -42,7 +42,7 @@ typedef KIO::FileUndoManager::CommandType CommandType; class DolphinController; -class DolphinColumnView; +class DolphinColumnViewContainer; class DolphinDetailsView; class DolphinFileItemDelegate; class DolphinIconsView; @@ -123,18 +123,12 @@ public: /** * @param parent Parent widget of the view. * @param url Specifies the content which should be shown. - * @param dirLister Used directory lister. The lister is not owned - * by the view and won't get deleted. - * @param dolphinModel Used directory model. The model is not owned - * by the view and won't get deleted. * @param proxyModel Used proxy model which specifies the sorting. The * model is not owned by the view and won't get * deleted. */ DolphinView(QWidget* parent, const KUrl& url, - KDirLister* dirLister, - DolphinModel* dolphinModel, DolphinSortFilterProxyModel* proxyModel); virtual ~DolphinView(); @@ -714,19 +708,10 @@ private: void loadDirectory(const KUrl& url, bool reload = false); /** - * Returns the URL where the view properties should be stored. Usually - * DolphinView::url() is returned, but in the case of a Column View the - * view properties are always stored in the directory represented by the - * first column. It is recommendend whenever using the ViewProperties class - * to use DolphinView::viewPropertiesUrl() as URL. - */ - KUrl viewPropertiesUrl() const; - - /** * Applies the view properties which are defined by the current URL - * m_url to the DolphinView properties. + * to the DolphinView properties. */ - void applyViewProperties(const KUrl& url); + void applyViewProperties(); /** * Creates a new view representing the given view mode (DolphinView::mode()). @@ -736,11 +721,7 @@ private: void deleteView(); - /** - * Returns a pointer to the currently used item view, which is either - * a ListView or a TreeView. - */ - QAbstractItemView* itemView() const; + void initializeView(); /** * Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder(). @@ -764,13 +745,6 @@ private: KUrl::List simplifiedSelectedUrls() const; /** - * Returns true, if the ColumnView is activated. As the column view - * requires some special handling for iterating through directories, - * this method has been introduced for convenience. - */ - bool isColumnViewActive() const; - - /** * Returns the MIME data for all selected items. */ QMimeData* selectionMimeData() const; @@ -784,6 +758,53 @@ private: void addNewFileNames(const QMimeData* mimeData); private: + /** + * Abstracts the access to the different view implementations + * for icons-, details- and column-view. + */ + class ViewAccessor + { + public: + ViewAccessor(DolphinSortFilterProxyModel* proxyModel); + + void createView(QWidget* parent, DolphinController* controller, Mode mode); + void deleteView(); + bool prepareUrlChange(const KUrl& url); + QAbstractItemView* itemView() const; + + /** + * Returns the widget that should be added to the layout as target. Usually + * the item view itself is returned, but in the case of the column view + * a container widget is returned. + */ + QWidget* layoutTarget() const; + + void setNameFilter(const QString& nameFilter); + + KUrl rootUrl() const; + + bool supportsCategorizedSorting() const; + bool hasExpandableFolders() const; + bool itemsExpandable() const; + + /** + * Returns true, if a reloading of the items is required + * when the additional information properties have been changed + * by the user. + */ + bool reloadOnAdditionalInfoChange() const; + + DolphinModel* dirModel() const; + DolphinSortFilterProxyModel* proxyModel() const; + KDirLister* dirLister() const; + + private: + DolphinIconsView* m_iconsView; + DolphinDetailsView* m_detailsView; + DolphinColumnViewContainer* m_columnsContainer; + DolphinSortFilterProxyModel* m_proxyModel; + }; + bool m_active : 1; bool m_showPreview : 1; bool m_loadingDirectory : 1; @@ -799,18 +820,12 @@ private: QVBoxLayout* m_topLayout; DolphinController* m_controller; - DolphinIconsView* m_iconsView; - DolphinDetailsView* m_detailsView; - DolphinColumnView* m_columnView; DolphinFileItemDelegate* m_fileItemDelegate; + ViewAccessor m_viewAccessor; QItemSelectionModel* m_selectionModel; QTimer* m_selectionChangedTimer; - DolphinModel* m_dolphinModel; - KDirLister* m_dirLister; - DolphinSortFilterProxyModel* m_proxyModel; - KFilePreviewGenerator* m_previewGenerator; ToolTipManager* m_toolTipManager; @@ -828,14 +843,9 @@ private: */ QSet<QString> m_newFileNames; - QAbstractItemView* m_expandedDragSource; + QAbstractItemView* m_expandedDragSource; // TODO: move to ViewAccessor }; -inline bool DolphinView::isColumnViewActive() const -{ - return m_columnView != 0; -} - /// Allow using DolphinView::Mode in QVariant Q_DECLARE_METATYPE(DolphinView::Mode) |
