#include <assert.h>
-#include <QItemSelectionModel>
-#include <Q3ValueList> // TODO
#include <QDropEvent>
+#include <QItemSelectionModel>
#include <QMouseEvent>
#include <QVBoxLayout>
#include "urlnavigator.h"
#include "viewproperties.h"
-DolphinView::DolphinView(DolphinMainWindow *mainWindow,
- QWidget *parent,
+DolphinView::DolphinView(DolphinMainWindow* mainWindow,
+ QWidget* parent,
const KUrl& url,
Mode mode,
bool showHiddenFiles) :
QWidget(parent),
- m_refreshing(false),
m_showProgress(false),
m_mode(mode),
m_iconSize(0),
m_dirLister->setDelayedMimeTypes(true);
connect(m_dirLister, SIGNAL(clear()),
- this, SLOT(slotClear()));
+ this, SLOT(updateStatusBar()));
connect(m_dirLister, SIGNAL(percent(int)),
- this, SLOT(slotPercent(int)));
+ this, SLOT(updateProgress(int)));
connect(m_dirLister, SIGNAL(deleteItem(KFileItem*)),
- this, SLOT(slotDeleteItem(KFileItem*)));
+ this, SLOT(updateStatusBar()));
connect(m_dirLister, SIGNAL(completed()),
- this, SLOT(slotCompleted()));
+ this, SLOT(updateItemCount()));
connect(m_dirLister, SIGNAL(infoMessage(const QString&)),
- this, SLOT(slotInfoMessage(const QString&)));
+ this, SLOT(showInfoMessage(const QString&)));
connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
- this, SLOT(slotErrorMessage(const QString&)));
+ this, SLOT(showErrorMessage(const QString&)));
m_dirModel = new KDirModel();
m_dirModel->setDirLister(m_dirLister);
m_filterBar = new FilterBar(this);
m_filterBar->hide();
connect(m_filterBar, SIGNAL(filterChanged(const QString&)),
- this, SLOT(slotChangeNameFilter(const QString&)));
+ this, SLOT(changeNameFilter(const QString&)));
connect(m_filterBar, SIGNAL(closed()),
this, SLOT(closeFilterBar()));
void DolphinView::setMode(Mode mode)
{
if (mode == m_mode) {
- return; // the wished mode is already set
+ return; // the wished mode is already set
}
m_mode = mode;
assert(replaceIndex >= 0);
for (int i = 0; i < urlsCount; ++i) {
const KUrl& source = urls[i];
+ QString number;
+ number.setNum(i + 1);
+
QString name(newName);
- name.replace(replaceIndex, 1, renameIndexPresentation(i + 1, urlsCount));
+ name.replace(replaceIndex, 1, number);
if (source.fileName() != name) {
KUrl dest(source.upUrl());
startDirLister(m_urlNavigator->url());
}
-void DolphinView::updateStatusBar()
-{
- // As the item count information is less important
- // in comparison with other messages, it should only
- // be shown if:
- // - the status bar is empty or
- // - shows already the item count information or
- // - shows only a not very important information
- // - if any progress is given don't show the item count info at all
- const QString msg(m_statusBar->message());
- const bool updateStatusBarMsg = (msg.isEmpty() ||
- (msg == m_statusBar->defaultText()) ||
- (m_statusBar->type() == DolphinStatusBar::Information)) &&
- (m_statusBar->progress() == 100);
-
- const QString text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
- m_statusBar->setDefaultText(text);
-
- if (updateStatusBarMsg) {
- m_statusBar->setMessage(text, DolphinStatusBar::Default);
- }
-}
-
void DolphinView::emitRequestItemInfo(const KUrl& url)
{
emit requestItemInfo(url);
m_urlNavigator->editUrl(editable);
}
-const Q3ValueList<UrlNavigator::HistoryElem> DolphinView::urlHistory(int& index) const
+const QLinkedList<UrlNavigator::HistoryElem> DolphinView::urlHistory(int& index) const
{
return m_urlNavigator->history(index);
}
// and the local path is /windows/C: For the Url the space info is related
// to the root partition (and hence wrong) and for the local path the space
// info is related to the windows partition (-> correct).
- //m_dirLister->stop();
- //m_dirLister->openUrl(item->url());
- //return;
-
const QString localPath(item->localPath());
if (localPath.isEmpty()) {
setUrl(item->url());
}
}
-void DolphinView::slotPercent(int percent)
+void DolphinView::updateProgress(int percent)
{
if (m_showProgress) {
m_statusBar->setProgress(percent);
}
}
-void DolphinView::slotClear()
-{
- //fileView()->clearView();
- updateStatusBar();
-}
-
-void DolphinView::slotDeleteItem(KFileItem* item)
-{
- //fileView()->removeItem(item);
- updateStatusBar();
-}
-
-void DolphinView::slotCompleted()
+void DolphinView::updateItemCount()
{
- m_refreshing = true;
-
- //KFileView* view = fileView();
- //view->clearView();
-
- // TODO: in Qt4 the code should get a lot
- // simpler and nicer due to Interview...
- /*if (m_iconsView != 0) {
- m_iconsView->beginItemUpdates();
- }
- if (m_iconsView != 0) {
- m_iconsView->beginItemUpdates();
- }*/
-
if (m_showProgress) {
m_statusBar->setProgressText(QString::null);
m_statusBar->setProgress(100);
while (it != end) {
KFileItem* item = *it;
- //view->insertItem(item);
if (item->isDir()) {
++m_folderCount;
}
}
updateStatusBar();
-
- /*if (m_iconsView != 0) {
- // Prevent a flickering of the icon view widget by giving a small
- // timeslot to swallow asynchronous update events.
- m_iconsView->setUpdatesEnabled(false);
- QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
- }
-
- if (m_iconsView != 0) {
- m_iconsView->endItemUpdates();
- m_refreshing = false;
- }*/
}
-void DolphinView::slotInfoMessage(const QString& msg)
+void DolphinView::showInfoMessage(const QString& msg)
{
m_statusBar->setMessage(msg, DolphinStatusBar::Information);
}
-void DolphinView::slotErrorMessage(const QString& msg)
+void DolphinView::showErrorMessage(const QString& msg)
{
m_statusBar->setMessage(msg, DolphinStatusBar::Error);
}
-void DolphinView::slotGrabActivation()
-{
- mainWindow()->setActiveView(this);
-}
-
void DolphinView::emitSelectionChangedSignal()
{
emit selectionChanged();
emit showFilterBarChanged(false);
}
-void DolphinView::slotContentsMoving(int x, int y)
-{
- if (!m_refreshing) {
- // Only emit a 'contents moved' signal if the user
- // moved the content by adjusting the sliders. Adjustments
- // resulted by refreshing a directory should not be respected.
- emit contentsMoved(x, y);
- }
-}
-
void DolphinView::startDirLister(const KUrl& url, bool reload)
{
if (!url.isValid()) {
m_statusBar->setProgress(0);
}
- m_refreshing = true;
m_dirLister->stop();
m_dirLister->openUrl(url, false, reload);
}
return text;
}
-QString DolphinView::renameIndexPresentation(int index, int itemCount) const
-{
- // assure that the string reprentation for all indicess have the same
- // number of characters based on the given number of items
- QString str(QString::number(index));
- int chrCount = 1;
- while (itemCount >= 10) {
- ++chrCount;
- itemCount /= 10;
- }
- str.reserve(chrCount);
-
- const int insertCount = chrCount - str.length();
- for (int i = 0; i < insertCount; ++i) {
- str.insert(0, '0');
- }
- return str;
-}
-
-void DolphinView::slotShowFilterBar(bool show)
+void DolphinView::showFilterBar(bool show)
{
assert(m_filterBar != 0);
if (show) {
mainWindow()->setActiveView( this );
}
-void DolphinView::slotChangeNameFilter(const QString& nameFilter)
+void DolphinView::updateStatusBar()
+{
+ // As the item count information is less important
+ // in comparison with other messages, it should only
+ // be shown if:
+ // - the status bar is empty or
+ // - shows already the item count information or
+ // - shows only a not very important information
+ // - if any progress is given don't show the item count info at all
+ const QString msg(m_statusBar->message());
+ const bool updateStatusBarMsg = (msg.isEmpty() ||
+ (msg == m_statusBar->defaultText()) ||
+ (m_statusBar->type() == DolphinStatusBar::Information)) &&
+ (m_statusBar->progress() == 100);
+
+ const QString text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText());
+ m_statusBar->setDefaultText(text);
+
+ if (updateStatusBarMsg) {
+ m_statusBar->setMessage(text, DolphinStatusBar::Default);
+ }
+}
+
+void DolphinView::changeNameFilter(const QString& nameFilter)
{
// The name filter of KDirLister does a 'hard' filtering, which
// means that only the items are shown where the names match
#ifndef _DOLPHINVIEW_H_
#define _DOLPHINVIEW_H_
-#include <qwidget.h>
-//Added by qt3to4:
-#include <QDropEvent>
-#include <Q3ValueList>
-#include <QMouseEvent>
-#include <QVBoxLayout>
#include <kparts/part.h>
#include <kfileitem.h>
#include <kfileiconview.h>
#include <kio/job.h>
+
#include <urlnavigator.h>
+#include <QDropEvent>
+#include <QLinkedList>
#include <QListView>
+#include <QMouseEvent>
+#include <QVBoxLayout>
+#include <QWidget>
-class QPainter;
+class FilterBar;
class KUrl;
class KDirModel;
-class QLineEdit;
class UrlNavigator;
-class QTimer;
-class Q3IconViewItem;
-class Q3ListViewItem;
-class Q3VBoxLayout;
-class DolphinMainWindow;
class DolphinDetailsView;
class DolphinDirLister;
-class DolphinStatusBar;
class DolphinIconsView;
-class DolphinDetailsView;
+class DolphinMainWindow;
class DolphinSortFilterProxyModel;
-class ViewProperties;
-class KProgress;
-class KDirModel;
-class FilterBar;
-
+class DolphinStatusBar;
class QModelIndex;
+class QPainter;
+class QTimer;
+class ViewProperties;
/**
* @short Represents a view for the directory content
- * including the navigation bar and status bar.
+ * including the navigation bar and status bar.
*
- * View modes for icons, details and previews are supported. Currently
+ * View modes for icons and details are supported. Currently
* Dolphin allows to have up to two views inside the main window.
*
* @see DolphinIconsView
* @see DolphinDetailsView
* @see UrlNavigator
* @see DolphinStatusBar
- *
- * @author Peter Penz <peter.penz@gmx.at>
*/
class DolphinView : public QWidget
{
virtual ~DolphinView();
/**
- * Sets the current active Url.
- * The signals UrlNavigator::urlChanged and UrlNavigator::historyChanged
+ * Sets the current active URL.
+ * The signals UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
* are submitted.
*/
void setUrl(const KUrl& url);
- /** Returns the current active Url. */
+ /** Returns the current active URL. */
const KUrl& url() const;
void requestActivation();
void invertSelection();
/**
- * Goes back one step in the Url history. The signals
- * UrlNavigator::urlChanged and UrlNavigator::historyChanged
+ * Goes back one step in the URL history. The signals
+ * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
* are submitted.
*/
void goBack();
/**
* Goes forward one step in the Url history. The signals
- * UrlNavigator::urlChanged and UrlNavigator::historyChanged
+ * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
* are submitted.
*/
void goForward();
/**
* Goes up one step of the Url path. The signals
- * UrlNavigator::urlChanged and UrlNavigator::historyChanged
+ * UrlNavigator::urlChanged() and UrlNavigator::historyChanged()
* are submitted.
*/
void goUp();
/**
- * Goes to the home Url. The signals UrlNavigator::urlChanged
- * and UrlNavigator::historyChanged are submitted.
+ * Goes to the home URL. The signals UrlNavigator::urlChanged()
+ * and UrlNavigator::historyChanged() are submitted.
*/
void goHome();
/**
- * Sets the Url of the navigation bar to an editable state
+ * Sets the URL of the navigation bar to an editable state
* if \a editable is true. If \a editable is false, each part of
* the location is presented by a button for a fast navigation.
*/
void setUrlEditable(bool editable);
/**
- * Returns the complete Url history. The index 0 indicates the oldest
+ * Returns the complete URL history. The index 0 indicates the oldest
* history element.
* @param index Output parameter which indicates the current
* index of the location.
*/
- const Q3ValueList<UrlNavigator::HistoryElem> urlHistory(int& index) const;
+ const QLinkedList<UrlNavigator::HistoryElem> urlHistory(int& index) const;
/**
* Returns true, if at least one item is selected.
KFileItemList selectedItems() const;
/**
- * Returns a list of Urls for all selected items. An empty list
+ * Returns a list of URLs for all selected items. An empty list
* is returned, if no item is selected.
* @see DolphinView::selectedItems()
*/
void openContextMenu(KFileItem* fileInfo, const QPoint& pos);
/**
- * Renames the filename of the source Url by the new file name.
+ * Renames the filename of the source URL by the new file name.
* If the new file name already exists, a dialog is opened which
* asks the user to enter a new name.
*/
int contentsY() const;
/**
- * Returns true, if the Url shown by the navigation bar is editable.
+ * Returns true, if the URL shown by the navigation bar is editable.
* @see UrlNavigator
*/
bool isUrlEditable() const;
/** Refreshs the view settings by reading out the stored settings. */
void refreshSettings();
- /**
- * Updates the number of items (= number of files + number of
- * directories) in the statusbar. If files are selected, the number
- * of selected files and the sum of the filesize is shown.
- */
- void updateStatusBar();
-
/** Returns the UrlNavigator of the view for read access. */
const UrlNavigator* urlNavigator() const { return m_urlNavigator; }
/**
* Triggers to request user information for the item given
- * by the Url \a url. The signal requestItemInfo is emitted,
+ * by the URL \a url. The signal requestItemInfo is emitted,
* which provides a way for widgets to get an indication to update
* the item information.
*/
const KUrl& url);
/**
- * Slot that popups the filter bar like FireFox popups his Search bar.
+ * Popups the filter bar above the status bar if \a show is true.
*/
- void slotShowFilterBar(bool show);
+ void showFilterBar(bool show);
/**
* Declare this View as the activeview of the mainWindow()
*/
void declareViewActive();
+ /**
+ * Updates the number of items (= number of files + number of
+ * directories) in the statusbar. If files are selected, the number
+ * of selected files and the sum of the filesize is shown.
+ */
+ void updateStatusBar();
+
signals:
- /** Is emitted if Url of the view has been changed to \a url. */
+ /** Is emitted if URL of the view has been changed to \a url. */
void urlChanged(const KUrl& url);
/**
/**
* Is emitted if information of an item is requested to be shown e. g. in the sidebar.
- * It the Url is empty, no item information request is pending.
+ * It the U is empty, no item information request is pending.
*/
void requestItemInfo(const KUrl& url);
private slots:
void loadDirectory(const KUrl& kurl);
void triggerItem(const QModelIndex& index);
-
- void slotPercent(int percent);
- void slotClear();
- void slotDeleteItem(KFileItem* item);
- void slotCompleted();
- void slotInfoMessage(const QString& msg);
- void slotErrorMessage(const QString& msg);
- void slotGrabActivation();
- void emitSelectionChangedSignal();
- void closeFilterBar();
+ void updateProgress(int percent);
/**
- * Is invoked shortly before the contents of a view implementation
- * has been moved and emits the signal contentsMoved. Note that no
- * signal is emitted when the contents moving is only temporary by
- * e. g. reloading a directory.
+ * Updates the number of items (= number of directories + number of files)
+ * and shows this information in the statusbar.
*/
- void slotContentsMoving(int x, int y);
+ void updateItemCount();
+
+ /** 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);
+
+ void emitSelectionChangedSignal();
+ void closeFilterBar();
/**
* Filters the currently shown items by \a nameFilter. All items
* which contain the given filter string will be shown.
*/
- void slotChangeNameFilter(const QString& nameFilter);
+ void changeNameFilter(const QString& nameFilter);
private:
void startDirLister(const KUrl& url, bool reload = false);
*/
QString selectionStatusBarText() const;
- /**
- * Returns the string representation for the index \a index
- * for renaming \itemCount items.
- */
- QString renameIndexPresentation(int index, int itemCount) const;
-
/**
* Creates a new view representing the given view mode (DolphinView::viewMode()).
* The current view will get deleted.
QAbstractItemView* itemView() const;
private:
- bool m_refreshing;
bool m_showProgress;
Mode m_mode;