From: Peter Penz Date: Tue, 23 Jan 2007 21:44:52 +0000 (+0000) Subject: Get rid of some KDE 3 relicts. X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/78d1167c38be4318114aa8ae4b7d433c12f86b77?ds=inline Get rid of some KDE 3 relicts. svn path=/trunk/playground/utils/dolphin/; revision=626610 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index de81af06d..223d7f1c7 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -860,7 +860,7 @@ void DolphinMainWindow::showFilterBar() const KToggleAction* showFilterBarAction = static_cast(actionCollection()->action("show_filter_bar")); const bool show = showFilterBarAction->isChecked(); - m_activeView->slotShowFilterBar(show); + m_activeView->showFilterBar(show); } void DolphinMainWindow::zoomIn() diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 7d24ebca5..26259df87 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -22,9 +22,8 @@ #include -#include -#include // TODO #include +#include #include #include @@ -49,13 +48,12 @@ #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), @@ -91,17 +89,17 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow, 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); @@ -117,7 +115,7 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow, 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())); @@ -158,7 +156,7 @@ bool DolphinView::isActive() const 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; @@ -247,8 +245,11 @@ void DolphinView::renameSelectedItems() 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()); @@ -331,29 +332,6 @@ void DolphinView::refreshSettings() 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); @@ -448,7 +426,7 @@ void DolphinView::setUrlEditable(bool editable) m_urlNavigator->editUrl(editable); } -const Q3ValueList DolphinView::urlHistory(int& index) const +const QLinkedList DolphinView::urlHistory(int& index) const { return m_urlNavigator->history(index); } @@ -657,10 +635,6 @@ void DolphinView::triggerItem(const QModelIndex& 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()); @@ -674,41 +648,15 @@ void DolphinView::triggerItem(const QModelIndex& index) } } -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); @@ -724,7 +672,6 @@ void DolphinView::slotCompleted() while (it != end) { KFileItem* item = *it; - //view->insertItem(item); if (item->isDir()) { ++m_folderCount; } @@ -735,35 +682,18 @@ void DolphinView::slotCompleted() } 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(); @@ -775,16 +705,6 @@ void DolphinView::closeFilterBar() 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()) { @@ -810,7 +730,6 @@ void DolphinView::startDirLister(const KUrl& url, bool reload) m_statusBar->setProgress(0); } - m_refreshing = true; m_dirLister->stop(); m_dirLister->openUrl(url, false, reload); } @@ -903,26 +822,7 @@ QString DolphinView::selectionStatusBarText() const 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) { @@ -938,7 +838,30 @@ void DolphinView::declareViewActive() 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 diff --git a/src/dolphinview.h b/src/dolphinview.h index ba7242a8e..0d178fc51 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -22,56 +22,46 @@ #ifndef _DOLPHINVIEW_H_ #define _DOLPHINVIEW_H_ -#include -//Added by qt3to4: -#include -#include -#include -#include #include #include #include #include + #include +#include +#include #include +#include +#include +#include -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 */ class DolphinView : public QWidget { @@ -118,13 +108,13 @@ public: 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(); @@ -179,46 +169,46 @@ public: 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 urlHistory(int& index) const; + const QLinkedList urlHistory(int& index) const; /** * Returns true, if at least one item is selected. @@ -233,7 +223,7 @@ public: 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() */ @@ -252,7 +242,7 @@ public: 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. */ @@ -276,7 +266,7 @@ public: 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; @@ -314,19 +304,12 @@ public: /** 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. */ @@ -348,17 +331,24 @@ public slots: 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); /** @@ -381,7 +371,7 @@ signals: /** * 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); @@ -407,30 +397,28 @@ protected: 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); @@ -447,12 +435,6 @@ private: */ 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. @@ -477,7 +459,6 @@ private: QAbstractItemView* itemView() const; private: - bool m_refreshing; bool m_showProgress; Mode m_mode;