2007-06-07 21:10:48 +00:00
|
|
|
/***************************************************************************
|
2011-02-04 14:57:33 +00:00
|
|
|
* Copyright (C) 2007 by Peter Penz <peter.penz19@gmail.com> *
|
2007-06-07 21:10:48 +00:00
|
|
|
* *
|
|
|
|
* 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
|
|
|
|
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KFileItem>
|
|
|
|
#include <KFileItemDelegate>
|
|
|
|
#include <KGlobalSettings>
|
|
|
|
#include <KIO/Job>
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KUrlNavigator>
|
2007-06-07 21:10:48 +00:00
|
|
|
|
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>
|
2012-08-10 15:49:39 +00:00
|
|
|
#include <config-apps.h>
|
|
|
|
|
|
|
|
#ifdef KActivities_FOUND
|
|
|
|
namespace KActivities {
|
|
|
|
class ResourceInstance;
|
|
|
|
}
|
|
|
|
#endif
|
2010-07-24 21:45:49 +00:00
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
class FilterBar;
|
2012-04-12 21:57:51 +00:00
|
|
|
class KMessageWidget;
|
2007-06-07 21:10:48 +00:00
|
|
|
class KUrl;
|
|
|
|
class KUrlNavigator;
|
2010-07-24 16:37:07 +00:00
|
|
|
class DolphinSearchBox;
|
2007-06-07 21:10:48 +00:00
|
|
|
class DolphinStatusBar;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Represents a view for the directory content
|
|
|
|
* including the navigation bar, filter bar and status bar.
|
|
|
|
*
|
2011-07-30 18:13:09 +00:00
|
|
|
* View modes for icons, compact and details are supported. Currently
|
2007-06-07 21:10:48 +00:00
|
|
|
* 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:
|
2012-04-12 21:57:51 +00:00
|
|
|
enum MessageType
|
|
|
|
{
|
|
|
|
Information,
|
|
|
|
Warning,
|
|
|
|
Error
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2012-04-26 06:31:46 +00:00
|
|
|
/**
|
|
|
|
* If \a grab is set to true, the container automatically grabs the focus
|
|
|
|
* as soon as the URL has been changed. Per default the grabbing
|
|
|
|
* of the focus is enabled.
|
|
|
|
*/
|
|
|
|
void setAutoGrabFocus(bool grab);
|
|
|
|
bool autoGrabFocus() 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
|
|
|
|
2012-04-12 21:57:51 +00:00
|
|
|
/**
|
|
|
|
* Shows the message \msg with the given type non-modal above
|
|
|
|
* the view-content.
|
|
|
|
*/
|
|
|
|
void showMessage(const QString& msg, MessageType type);
|
|
|
|
|
2008-10-06 18:15:53 +00:00
|
|
|
/**
|
|
|
|
* Refreshes the view container to get synchronized with the (updated) Dolphin settings.
|
|
|
|
*/
|
2012-01-30 15:36:40 +00:00
|
|
|
void readSettings();
|
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;
|
|
|
|
|
2012-06-02 13:45:40 +00:00
|
|
|
/**
|
|
|
|
* @return Text that should be used for the current URL when creating
|
|
|
|
* a new place.
|
|
|
|
*/
|
|
|
|
QString placesText() 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
|
|
|
/**
|
2010-11-05 17:12:35 +00:00
|
|
|
* Popups the filter bar above the status bar if \a visible is true.
|
2010-11-07 14:55:33 +00:00
|
|
|
* It \a visible is true, it is assured that the filter bar gains
|
|
|
|
* the keyboard focus.
|
2007-06-07 21:10:48 +00:00
|
|
|
*/
|
2010-11-05 17:12:35 +00:00
|
|
|
void setFilterBarVisible(bool visible);
|
2007-06-07 21:10:48 +00:00
|
|
|
|
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.
|
2011-03-23 23:45:14 +00:00
|
|
|
* Unless a previous OperationCompletedMessage was set very shortly before
|
|
|
|
* calling this method, it will be overwritten (see DolphinStatusBar::setMessage).
|
|
|
|
* Previous ErrorMessages however are always preserved.
|
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
|
|
|
|
2012-04-11 19:52:15 +00:00
|
|
|
void updateDirectoryLoadingProgress(int percent);
|
2012-04-10 14:30:50 +00:00
|
|
|
|
2012-04-11 19:52:15 +00:00
|
|
|
void updateDirectorySortingProgress(int percent);
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2010-12-10 22:54:37 +00:00
|
|
|
/**
|
|
|
|
* Updates the statusbar to show an undetermined progress with the correct
|
|
|
|
* context information whether a searching or a directory loading is done.
|
|
|
|
*/
|
2012-04-11 19:52:15 +00:00
|
|
|
void slotDirectoryLoadingStarted();
|
2010-12-10 22:54:37 +00:00
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
/**
|
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
|
|
|
*/
|
2012-04-11 19:52:15 +00:00
|
|
|
void slotDirectoryLoadingCompleted();
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2012-10-29 19:54:53 +00:00
|
|
|
/**
|
|
|
|
* Updates the statusbar to show, that the directory loading has
|
|
|
|
* been canceled.
|
|
|
|
*/
|
|
|
|
void slotDirectoryLoadingCanceled();
|
|
|
|
|
2012-06-13 13:15:54 +00:00
|
|
|
/**
|
|
|
|
* Is called if the URL set by DolphinView::setUrl() represents
|
|
|
|
* a file and not a directory. Takes care to activate the file.
|
|
|
|
*/
|
|
|
|
void slotUrlIsFileError(const KUrl& url);
|
|
|
|
|
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
|
|
|
*/
|
2011-08-29 18:13:39 +00:00
|
|
|
void slotItemActivated(const KFileItem& item);
|
2007-08-28 17:50:54 +00:00
|
|
|
|
2012-12-13 21:54:09 +00:00
|
|
|
/**
|
|
|
|
* Handles activation of multiple files. The files get started by
|
|
|
|
* the corresponding applications.
|
|
|
|
*/
|
|
|
|
void slotItemsActivated(const KFileItemList& items);
|
|
|
|
|
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
|
|
|
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
|
|
|
/**
|
2011-07-30 18:13:09 +00:00
|
|
|
* Is invoked if the signal urlAboutToBeChanged() from the DolphinView
|
|
|
|
* is emitted. Tries to save the view-state.
|
2007-09-24 13:50:31 +00:00
|
|
|
*/
|
2011-07-30 18:13:09 +00:00
|
|
|
void slotViewUrlAboutToBeChanged(const KUrl& url);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is invoked if the signal urlAboutToBeChanged() from the URL navigator
|
|
|
|
* is emitted. Tries to save the view-state.
|
|
|
|
*/
|
|
|
|
void slotUrlNavigatorLocationAboutToBeChanged(const KUrl& url);
|
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();
|
|
|
|
|
2012-12-29 17:49:51 +00:00
|
|
|
void slotReturnPressed();
|
|
|
|
|
2010-07-24 16:37:07 +00:00
|
|
|
/**
|
|
|
|
* Gets the search URL from the searchbox and starts searching.
|
|
|
|
*/
|
2012-05-10 20:40:51 +00:00
|
|
|
void startSearching();
|
2010-07-24 16:37:07 +00:00
|
|
|
void closeSearchBox();
|
|
|
|
|
2010-11-20 17:17:35 +00:00
|
|
|
/**
|
|
|
|
* Stops the loading of a directory. Is connected with the "stopPressed" signal
|
|
|
|
* from the statusbar.
|
|
|
|
*/
|
2012-04-12 21:57:51 +00:00
|
|
|
void stopDirectoryLoading();
|
|
|
|
|
|
|
|
void slotStatusBarZoomLevelChanged(int zoomLevel);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Slot that calls showMessage(msg, Error).
|
|
|
|
*/
|
|
|
|
void showErrorMessage(const QString& msg);
|
|
|
|
|
2010-07-24 16:37:07 +00:00
|
|
|
private:
|
2010-11-01 12:31:44 +00:00
|
|
|
/**
|
|
|
|
* @return True if the URL protocol is a search URL (e. g. nepomuksearch:// or filenamesearch://).
|
|
|
|
*/
|
2010-07-24 16:37:07 +00:00
|
|
|
bool isSearchUrl(const KUrl& url) const;
|
|
|
|
|
2011-07-30 18:13:09 +00:00
|
|
|
/**
|
|
|
|
* Saves the state of the current view: contents position,
|
|
|
|
* root URL, ...
|
|
|
|
*/
|
|
|
|
void saveViewState();
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
private:
|
|
|
|
QVBoxLayout* m_topLayout;
|
|
|
|
KUrlNavigator* m_urlNavigator;
|
2010-07-24 16:37:07 +00:00
|
|
|
DolphinSearchBox* m_searchBox;
|
2012-04-12 21:57:51 +00:00
|
|
|
KMessageWidget* m_messageWidget;
|
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
|
2012-04-26 06:31:46 +00:00
|
|
|
bool m_autoGrabFocus;
|
2012-08-10 15:49:39 +00:00
|
|
|
|
|
|
|
#ifdef KActivities_FOUND
|
|
|
|
private:
|
|
|
|
KActivities::ResourceInstance * m_activityResourceInstance;
|
|
|
|
#endif
|
2007-06-07 21:10:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOLPHINVIEWCONTAINER_H
|