2007-06-07 21:10:48 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DOLPHINVIEWCONTAINER_H
|
|
|
|
#define DOLPHINVIEWCONTAINER_H
|
|
|
|
|
|
|
|
#include <kfileitem.h>
|
|
|
|
#include <kfileitemdelegate.h>
|
2009-02-20 16:55:25 +00:00
|
|
|
#include <kglobalsettings.h>
|
2007-06-07 21:10:48 +00:00
|
|
|
#include <kio/job.h>
|
|
|
|
|
|
|
|
#include <kurlnavigator.h>
|
|
|
|
|
2010-10-10 17:11:55 +00:00
|
|
|
#include <QElapsedTimer>
|
|
|
|
#include <QWidget>
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2010-07-24 21:45:49 +00:00
|
|
|
#include <views/dolphinview.h>
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
class FilterBar;
|
|
|
|
class KUrl;
|
2007-09-17 04:02:17 +00:00
|
|
|
class DolphinModel;
|
2007-06-07 21:10:48 +00:00
|
|
|
class KUrlNavigator;
|
|
|
|
class DolphinDirLister;
|
2010-07-24 16:37:07 +00:00
|
|
|
class DolphinSearchBox;
|
2007-06-07 21:10:48 +00:00
|
|
|
class DolphinSortFilterProxyModel;
|
|
|
|
class DolphinStatusBar;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Represents a view for the directory content
|
|
|
|
* including the navigation bar, filter bar and status bar.
|
|
|
|
*
|
|
|
|
* View modes for icons, details and columns are supported. Currently
|
|
|
|
* Dolphin allows to have up to two views inside the main window.
|
|
|
|
*
|
|
|
|
* @see DolphinView
|
|
|
|
* @see FilterBar
|
|
|
|
* @see KUrlNavigator
|
|
|
|
* @see DolphinStatusBar
|
|
|
|
*/
|
|
|
|
class DolphinViewContainer : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2010-01-25 07:58:24 +00:00
|
|
|
DolphinViewContainer(const KUrl& url, QWidget* parent);
|
2007-06-07 21:10:48 +00:00
|
|
|
virtual ~DolphinViewContainer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current active URL, where all actions are applied.
|
|
|
|
* The URL navigator is synchronized with this URL.
|
|
|
|
*/
|
2010-01-25 07:58:24 +00:00
|
|
|
KUrl url() const;
|
2007-06-07 21:10:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If \a active is true, the view container will marked as active. The active
|
|
|
|
* view container is defined as view where all actions are applied to.
|
|
|
|
*/
|
|
|
|
void setActive(bool active);
|
|
|
|
bool isActive() const;
|
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
const DolphinStatusBar* statusBar() const;
|
|
|
|
DolphinStatusBar* statusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
const KUrlNavigator* urlNavigator() const;
|
|
|
|
KUrlNavigator* urlNavigator();
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
const DolphinView* view() const;
|
|
|
|
DolphinView* view();
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2008-10-06 18:15:53 +00:00
|
|
|
/**
|
|
|
|
* Refreshes the view container to get synchronized with the (updated) Dolphin settings.
|
|
|
|
*/
|
|
|
|
void refresh();
|
2007-06-07 21:10:48 +00:00
|
|
|
|
|
|
|
/** Returns true, if the filter bar is visible. */
|
|
|
|
bool isFilterBarVisible() const;
|
|
|
|
|
2010-07-24 16:37:07 +00:00
|
|
|
/**
|
|
|
|
* Enables the search mode, if \p enabled is true. In the search mode the URL navigator
|
|
|
|
* will be hidden and replaced by a line editor that allows to enter a search term.
|
|
|
|
*/
|
|
|
|
void setSearchModeEnabled(bool enabled);
|
|
|
|
bool isSearchModeEnabled() const;
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
public slots:
|
2009-11-19 19:38:34 +00:00
|
|
|
/**
|
|
|
|
* Sets the current active URL, where all actions are applied. The
|
|
|
|
* URL navigator is synchronized with this URL. The signals
|
|
|
|
* KUrlNavigator::urlChanged() and KUrlNavigator::historyChanged()
|
|
|
|
* are emitted.
|
|
|
|
* @see DolphinViewContainer::urlNavigator()
|
|
|
|
*/
|
|
|
|
void setUrl(const KUrl& url);
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
/**
|
|
|
|
* Popups the filter bar above the status bar if \a show is true.
|
|
|
|
*/
|
|
|
|
void showFilterBar(bool show);
|
|
|
|
|
2009-07-11 17:48:05 +00:00
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
* Is emitted whenever the filter bar has changed its visibility state.
|
|
|
|
*/
|
|
|
|
void showFilterBarChanged(bool shown);
|
|
|
|
|
2010-01-25 07:58:24 +00:00
|
|
|
/**
|
|
|
|
* Is emitted when the write state of the folder has been changed. The application
|
|
|
|
* should disable all actions like "Create New..." that depend on the write
|
|
|
|
* state.
|
|
|
|
*/
|
|
|
|
void writeStateChanged(bool isFolderWritable);
|
|
|
|
|
2009-11-19 19:38:34 +00:00
|
|
|
private slots:
|
2007-06-07 21:10:48 +00:00
|
|
|
/**
|
|
|
|
* Updates the number of items (= number of files + number of
|
|
|
|
* directories) in the statusbar. If files are selected, the number
|
2009-07-11 17:48:05 +00:00
|
|
|
* of selected files and the sum of the filesize is shown. The update
|
|
|
|
* is done asynchronously, as getting the sum of the
|
|
|
|
* filesizes can be an expensive operation.
|
2007-06-07 21:10:48 +00:00
|
|
|
*/
|
2009-07-11 17:48:05 +00:00
|
|
|
void delayedStatusBarUpdate();
|
2007-06-07 21:10:48 +00:00
|
|
|
|
|
|
|
/**
|
2009-07-11 17:48:05 +00:00
|
|
|
* Is invoked by DolphinViewContainer::delayedStatusBarUpdate() and
|
|
|
|
* updates the status bar synchronously.
|
2007-06-07 21:10:48 +00:00
|
|
|
*/
|
2009-07-11 17:48:05 +00:00
|
|
|
void updateStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2009-11-13 21:03:19 +00:00
|
|
|
void initializeProgress();
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
void updateProgress(int percent);
|
|
|
|
|
|
|
|
/**
|
2007-10-09 22:32:54 +00:00
|
|
|
* Assures that the viewport position is restored and updates the
|
|
|
|
* statusbar to reflect the current content.
|
2007-06-07 21:10:48 +00:00
|
|
|
*/
|
2007-10-09 22:32:54 +00:00
|
|
|
void slotDirListerCompleted();
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2007-08-28 17:50:54 +00:00
|
|
|
/**
|
2008-12-12 19:44:28 +00:00
|
|
|
* Handles clicking on an item. If the item is a directory, the
|
|
|
|
* directory is opened in the view. If the item is a file, the file
|
|
|
|
* gets started by the corresponding application.
|
2007-08-28 17:50:54 +00:00
|
|
|
*/
|
|
|
|
void slotItemTriggered(const KFileItem& item);
|
|
|
|
|
2008-12-12 19:44:28 +00:00
|
|
|
/**
|
|
|
|
* Opens a the file \a url by opening the corresponding application.
|
|
|
|
* Is connected with the signal urlIsFile() from DolphinDirLister and will
|
|
|
|
* get invoked if the user manually has entered a file into the URL navigator.
|
|
|
|
*/
|
|
|
|
void openFile(const KUrl& url);
|
|
|
|
|
2007-06-08 13:44:59 +00:00
|
|
|
/**
|
2007-07-08 20:31:36 +00:00
|
|
|
* Shows the information for the item \a item inside the statusbar. If the
|
|
|
|
* item is null, the default statusbar information is shown.
|
2007-06-08 13:44:59 +00:00
|
|
|
*/
|
2007-07-02 17:24:54 +00:00
|
|
|
void showItemInfo(const KFileItem& item);
|
2007-06-08 13:44:59 +00:00
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
/** Shows the information \a msg inside the statusbar. */
|
|
|
|
void showInfoMessage(const QString& msg);
|
|
|
|
|
|
|
|
/** Shows the error message \a msg inside the statusbar. */
|
|
|
|
void showErrorMessage(const QString& msg);
|
|
|
|
|
2007-11-17 00:08:54 +00:00
|
|
|
/** Shows the "operation completed" message \a msg inside the statusbar. */
|
|
|
|
void showOperationCompletedMessage(const QString& msg);
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
void closeFilterBar();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filters the currently shown items by \a nameFilter. All items
|
|
|
|
* which contain the given filter string will be shown.
|
|
|
|
*/
|
2007-10-09 22:32:54 +00:00
|
|
|
void setNameFilter(const QString& nameFilter);
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2007-06-13 17:08:39 +00:00
|
|
|
/**
|
|
|
|
* Marks the view container as active
|
|
|
|
* (see DolphinViewContainer::setActive()).
|
|
|
|
*/
|
|
|
|
void activate();
|
|
|
|
|
2007-09-24 13:50:31 +00:00
|
|
|
/**
|
2010-01-25 07:58:24 +00:00
|
|
|
* Saves the state of the current view: contents position,
|
|
|
|
* root URL, ...
|
2007-09-24 13:50:31 +00:00
|
|
|
*/
|
2010-01-25 07:58:24 +00:00
|
|
|
void saveViewState();
|
2007-09-24 13:50:31 +00:00
|
|
|
|
2007-09-25 09:02:29 +00:00
|
|
|
/**
|
2010-01-25 07:58:24 +00:00
|
|
|
* Restores the current view to show \a url and assures
|
|
|
|
* that the root URL of the view is respected.
|
2007-09-25 09:02:29 +00:00
|
|
|
*/
|
2010-01-25 07:58:24 +00:00
|
|
|
void slotUrlNavigatorLocationChanged(const KUrl& url);
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2008-10-01 21:39:35 +00:00
|
|
|
/**
|
|
|
|
* Is connected with the URL navigator and drops the URLs
|
|
|
|
* above the destination \a destination.
|
|
|
|
*/
|
|
|
|
void dropUrls(const KUrl& destination, QDropEvent* event);
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2008-10-24 19:52:28 +00:00
|
|
|
/**
|
|
|
|
* Is invoked when a redirection is done and changes the
|
|
|
|
* URL of the URL navigator to \a newUrl without triggering
|
|
|
|
* a reloading of the directory.
|
|
|
|
*/
|
|
|
|
void redirect(const KUrl& oldUrl, const KUrl& newUrl);
|
2007-09-25 09:02:29 +00:00
|
|
|
|
2008-12-19 06:41:26 +00:00
|
|
|
/** Requests the focus for the view \a m_view. */
|
|
|
|
void requestFocus();
|
|
|
|
|
2009-02-20 16:55:25 +00:00
|
|
|
/**
|
|
|
|
* Saves the currently used URL completion mode of
|
|
|
|
* the URL navigator.
|
|
|
|
*/
|
|
|
|
void saveUrlCompletionMode(KGlobalSettings::Completion completion);
|
|
|
|
|
2009-06-08 05:55:46 +00:00
|
|
|
void slotHistoryChanged();
|
|
|
|
|
2010-07-24 16:37:07 +00:00
|
|
|
/**
|
|
|
|
* Gets the search URL from the searchbox and starts searching.
|
|
|
|
* @param text Text the user has entered into the searchbox.
|
|
|
|
*/
|
|
|
|
void startSearching(const QString& text);
|
|
|
|
void closeSearchBox();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool isSearchUrl(const KUrl& url) const;
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
private:
|
2009-02-10 07:09:49 +00:00
|
|
|
bool m_isFolderWritable;
|
2007-06-07 21:10:48 +00:00
|
|
|
|
|
|
|
QVBoxLayout* m_topLayout;
|
|
|
|
KUrlNavigator* m_urlNavigator;
|
2010-07-24 16:37:07 +00:00
|
|
|
DolphinSearchBox* m_searchBox;
|
2007-06-07 21:10:48 +00:00
|
|
|
|
|
|
|
DolphinView* m_view;
|
|
|
|
|
|
|
|
FilterBar* m_filterBar;
|
2009-07-11 17:48:05 +00:00
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinStatusBar* m_statusBar;
|
2010-10-10 17:11:55 +00:00
|
|
|
QTimer* m_statusBarTimer; // Triggers a delayed update
|
|
|
|
QElapsedTimer m_statusBarTimestamp; // Time in ms since last update
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2007-09-17 04:02:17 +00:00
|
|
|
DolphinModel* m_dolphinModel;
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinDirLister* m_dirLister;
|
|
|
|
DolphinSortFilterProxyModel* m_proxyModel;
|
|
|
|
};
|
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
inline const DolphinStatusBar* DolphinViewContainer::statusBar() const
|
2007-06-14 17:46:12 +00:00
|
|
|
{
|
|
|
|
return m_statusBar;
|
|
|
|
}
|
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
inline DolphinStatusBar* DolphinViewContainer::statusBar()
|
2007-06-14 17:46:12 +00:00
|
|
|
{
|
|
|
|
return m_statusBar;
|
|
|
|
}
|
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
inline const KUrlNavigator* DolphinViewContainer::urlNavigator() const
|
2007-06-14 17:46:12 +00:00
|
|
|
{
|
|
|
|
return m_urlNavigator;
|
|
|
|
}
|
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
inline KUrlNavigator* DolphinViewContainer::urlNavigator()
|
2007-06-07 21:10:48 +00:00
|
|
|
{
|
|
|
|
return m_urlNavigator;
|
|
|
|
}
|
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
inline const DolphinView* DolphinViewContainer::view() const
|
2007-06-14 17:46:12 +00:00
|
|
|
{
|
|
|
|
return m_view;
|
|
|
|
}
|
|
|
|
|
2007-09-27 12:44:14 +00:00
|
|
|
inline DolphinView* DolphinViewContainer::view()
|
2007-06-07 21:10:48 +00:00
|
|
|
{
|
|
|
|
return m_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DOLPHINVIEWCONTAINER_H
|