]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Cleanup of signal/slot handling between the dolphin view and the main window: now...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 8 Dec 2006 23:41:08 +0000 (23:41 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 8 Dec 2006 23:41:08 +0000 (23:41 +0000)
svn path=/trunk/playground/utils/dolphin/; revision=611617

src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinview.cpp
src/dolphinview.h
src/filterbar.cpp
src/filterbar.h
src/infosidebarpage.cpp

index 8cec9bf7de0a933cad06085d766b7097fad7c726..98d1a05b12f48aed15925320eb27a4620c9c25fd 100644 (file)
@@ -28,13 +28,28 @@ DolphinIconsView::DolphinIconsView(DolphinView* parent) :
     QListView(parent),
     m_parentView( parent )
 {
     QListView(parent),
     m_parentView( parent )
 {
-    setResizeMode( QListView::Adjust );
+    setResizeMode(QListView::Adjust);
 }
 
 DolphinIconsView::~DolphinIconsView()
 {
 }
 
 }
 
 DolphinIconsView::~DolphinIconsView()
 {
 }
 
+QStyleOptionViewItem DolphinIconsView::viewOptions() const
+{
+    return QListView::viewOptions();
+
+    // TODO: the view options should been read from the settings;
+    // the following code is just for testing...
+    //QStyleOptionViewItem options = QListView::viewOptions();
+    //options.decorationAlignment = Qt::AlignRight;
+    //options.decorationPosition = QStyleOptionViewItem::Right;
+    //options.decorationSize = QSize(100, 100);
+    //options.showDecorationSelected = true;
+    //options.state = QStyle::State_MouseOver;
+    //return options;
+}
+
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QListView::contextMenuEvent(event);
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
     QListView::contextMenuEvent(event);
index 457b9ba626a789076658084cfe635c3f8bed72c6..53554740e7a5330c7ad54ad0cd868c9fd0c99ee0 100644 (file)
@@ -42,6 +42,7 @@ public:
     virtual ~DolphinIconsView();
 
 protected:
     virtual ~DolphinIconsView();
 
 protected:
+    virtual QStyleOptionViewItem viewOptions() const;
     virtual void contextMenuEvent(QContextMenuEvent* event);
     virtual void mouseReleaseEvent(QMouseEvent* event);
 
     virtual void contextMenuEvent(QContextMenuEvent* event);
     virtual void mouseReleaseEvent(QMouseEvent* event);
 
index 02787c2b72820836339221beabe532a4d2fb6326..8706316d835a2963a3afbd6d2d93de48e32294d5 100644 (file)
@@ -218,6 +218,7 @@ void DolphinMainWindow::refreshViews()
                                         url,
                                         props.viewMode(),
                                         props.isShowHiddenFilesEnabled());
                                         url,
                                         props.viewMode(),
                                         props.isShowHiddenFilesEnabled());
+            connectViewSignals(i);
             m_view[i]->show();
         }
     }
             m_view[i]->show();
         }
     }
@@ -229,24 +230,6 @@ void DolphinMainWindow::refreshViews()
     emit activeViewChanged();
 }
 
     emit activeViewChanged();
 }
 
-void DolphinMainWindow::slotHistoryChanged()
-{
-    updateHistory();
-}
-
-void DolphinMainWindow::slotUrlChanged(const KUrl& url)
-{
-    updateEditActions();
-    updateGoActions();
-    setCaption(url.fileName());
-}
-
-void DolphinMainWindow::slotUrlChangeRequest(const KUrl& url)
-{
-       clearStatusBar();
-       m_activeView->setUrl(url);
-}
-
 void DolphinMainWindow::slotViewModeChanged()
 {
     updateViewActions();
 void DolphinMainWindow::slotViewModeChanged()
 {
     updateViewActions();
@@ -259,13 +242,6 @@ void DolphinMainWindow::slotShowHiddenFilesChanged()
     showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled());
 }
 
     showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled());
 }
 
-void DolphinMainWindow::slotShowFilterBarChanged()
-{
-    KToggleAction* showFilterBarAction =
-        static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
-    showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
-}
-
 void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
 {
     QAction* action = 0;
 void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
 {
     QAction* action = 0;
@@ -314,17 +290,36 @@ void DolphinMainWindow::slotSelectionChanged()
     emit selectionChanged();
 }
 
     emit selectionChanged();
 }
 
-void DolphinMainWindow::slotRedo()
+void DolphinMainWindow::slotHistoryChanged()
+{
+    updateHistory();
+}
+
+void DolphinMainWindow::slotUrlChanged(const KUrl& url)
+{
+    updateEditActions();
+    updateGoActions();
+    setCaption(url.fileName());
+}
+
+void DolphinMainWindow::updateFilterBarAction(bool show)
+{
+    KToggleAction* showFilterBarAction =
+        static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
+    showFilterBarAction->setChecked(show);
+}
+
+void DolphinMainWindow::redo()
 {
     UndoManager::instance().redo(this);
 }
 
 {
     UndoManager::instance().redo(this);
 }
 
-void DolphinMainWindow::slotUndo()
+void DolphinMainWindow::undo()
 {
     UndoManager::instance().undo(this);
 }
 
 {
     UndoManager::instance().undo(this);
 }
 
-void DolphinMainWindow::slotNewMainWindow()
+void DolphinMainWindow::openNewMainWindow()
 {
     DolphinApplication::app()->createMainWindow()->show();
 }
 {
     DolphinApplication::app()->createMainWindow()->show();
 }
@@ -826,6 +821,7 @@ void DolphinMainWindow::toggleSplitView()
                                                m_view[PrimaryIdx]->url(),
                                                m_view[PrimaryIdx]->mode(),
                                                m_view[PrimaryIdx]->isShowHiddenFilesEnabled());
                                                m_view[PrimaryIdx]->url(),
                                                m_view[PrimaryIdx]->mode(),
                                                m_view[PrimaryIdx]->isShowHiddenFilesEnabled());
+        connectViewSignals(SecondaryIdx);
         m_splitter->addWidget(m_view[SecondaryIdx]);
         m_splitter->setSizes(QList<int>() << newWidth << newWidth);
         m_view[SecondaryIdx]->show();
         m_splitter->addWidget(m_view[SecondaryIdx]);
         m_splitter->setSizes(QList<int>() << newWidth << newWidth);
         m_view[SecondaryIdx]->show();
@@ -1125,6 +1121,7 @@ void DolphinMainWindow::init()
                                          homeUrl,
                                          props.viewMode(),
                                          props.isShowHiddenFilesEnabled());
                                          homeUrl,
                                          props.viewMode(),
                                          props.isShowHiddenFilesEnabled());
+    connectViewSignals(PrimaryIdx);
     m_view[PrimaryIdx]->show();
 
     m_activeView = m_view[PrimaryIdx];
     m_view[PrimaryIdx]->show();
 
     m_activeView = m_view[PrimaryIdx];
@@ -1171,7 +1168,7 @@ void DolphinMainWindow::setupActions()
 {
     // setup 'File' menu
     KAction *action = new KAction(KIcon("window_new"),  i18n( "New &Window" ), actionCollection(), "new_window" );
 {
     // setup 'File' menu
     KAction *action = new KAction(KIcon("window_new"),  i18n( "New &Window" ), actionCollection(), "new_window" );
-    connect(action, SIGNAL(triggered()), this, SLOT(slotNewMainWindow()));
+    connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
 
     KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder");
     createFolder->setIcon(KIcon("folder"));
 
     KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder");
     createFolder->setIcon(KIcon("folder"));
@@ -1201,7 +1198,7 @@ void DolphinMainWindow::setupActions()
     // setup 'Edit' menu
     UndoManager& undoManager = UndoManager::instance();
     KStdAction::undo(this,
     // setup 'Edit' menu
     UndoManager& undoManager = UndoManager::instance();
     KStdAction::undo(this,
-                     SLOT(slotUndo()),
+                     SLOT(undo()),
                      actionCollection());
     connect(&undoManager, SIGNAL(undoAvailable(bool)),
             this, SLOT(slotUndoAvailable(bool)));
                      actionCollection());
     connect(&undoManager, SIGNAL(undoAvailable(bool)),
             this, SLOT(slotUndoAvailable(bool)));
@@ -1209,7 +1206,7 @@ void DolphinMainWindow::setupActions()
             this, SLOT(slotUndoTextChanged(const QString&)));
 
     KStdAction::redo(this,
             this, SLOT(slotUndoTextChanged(const QString&)));
 
     KStdAction::redo(this,
-                     SLOT(slotRedo()),
+                     SLOT(redo()),
                      actionCollection());
     connect(&undoManager, SIGNAL(redoAvailable(bool)),
             this, SLOT(slotRedoAvailable(bool)));
                      actionCollection());
     connect(&undoManager, SIGNAL(redoAvailable(bool)),
             this, SLOT(slotRedoAvailable(bool)));
@@ -1333,6 +1330,31 @@ void DolphinMainWindow::setupActions()
     KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
 }
 
     KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
 }
 
+void DolphinMainWindow::setupDockWidgets()
+{
+    QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
+
+    shortcutsDock->setObjectName("shortcutsDock");
+    shortcutsDock->setWidget(new BookmarksSidebarPage(this));
+
+    shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_pane");
+    shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel"));
+    actionCollection()->insert(shortcutsDock->toggleViewAction());
+
+    addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
+
+    QDockWidget *infoDock = new QDockWidget(i18n("Information"));
+
+    infoDock->setObjectName("infoDock");
+    infoDock->setWidget(new InfoSidebarPage(this));
+
+    infoDock->toggleViewAction()->setObjectName("show_info_pane");
+    infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
+    actionCollection()->insert(infoDock->toggleViewAction());
+
+    addDockWidget(Qt::RightDockWidgetArea, infoDock);
+}
+
 void DolphinMainWindow::setupCreateNewMenuActions()
 {
     // Parts of the following code have been taken
 void DolphinMainWindow::setupCreateNewMenuActions()
 {
     // Parts of the following code have been taken
@@ -1594,29 +1616,28 @@ void DolphinMainWindow::clearStatusBar()
     m_activeView->statusBar()->clear();
 }
 
     m_activeView->statusBar()->clear();
 }
 
-void DolphinMainWindow::setupDockWidgets()
-{
-    QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
-
-    shortcutsDock->setObjectName("shortcutsDock");
-    shortcutsDock->setWidget(new BookmarksSidebarPage(this));
-
-    shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_pane");
-    shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel"));
-    actionCollection()->insert(shortcutsDock->toggleViewAction());
-
-    addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
+void DolphinMainWindow::connectViewSignals(int viewIndex)
+{
+    DolphinView* view = m_view[viewIndex];
+    connect(view, SIGNAL(modeChanged()),
+            this, SLOT(slotViewModeChanged()));
+    connect(view, SIGNAL(showHiddenFilesChanged()),
+            this, SLOT(slotShowHiddenFilesChanged()));
+    connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
+            this, SLOT(slotSortingChanged(DolphinView::Sorting)));
+    connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
+            this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
+    connect(view, SIGNAL(selectionChanged()),
+            this, SLOT(slotSelectionChanged()));
+    connect(view, SIGNAL(showFilterBarChanged(bool)),
+            this, SLOT(updateFilterBarAction(bool)));
+
+    const UrlNavigator* navigator = view->urlNavigator();
+    connect(navigator, SIGNAL(urlChanged(const KUrl&)),
+            this, SLOT(slotUrlChanged(const KUrl&)));
+    connect(navigator, SIGNAL(historyChanged()),
+            this, SLOT(slotHistoryChanged()));
 
 
-    QDockWidget *infoDock = new QDockWidget(i18n("Information"));
-
-    infoDock->setObjectName("infoDock");
-    infoDock->setWidget(new InfoSidebarPage(this));
-
-    infoDock->toggleViewAction()->setObjectName("show_info_pane");
-    infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
-    actionCollection()->insert(infoDock->toggleViewAction());
-
-    addDockWidget(Qt::RightDockWidgetArea, infoDock);
 }
 
 #include "dolphinmainwindow.moc"
 }
 
 #include "dolphinmainwindow.moc"
index 0e546511f79fb1d952f410bd1e5db9ae2050bfc1..064bf18676593df9dd964ab1592eebd3e65089f7 100644 (file)
 
 #include <kapplication.h>
 #include <kmainwindow.h>
 
 #include <kapplication.h>
 #include <kmainwindow.h>
+#include <ksortablelist.h>
+#include <kvbox.h>
+
 #include <q3valuelist.h>
 #include <q3ptrlist.h>
 #include <q3valuelist.h>
 #include <q3ptrlist.h>
-#include <qstring.h>
-//Added by qt3to4:
+
 #include <QCloseEvent>
 #include <QCloseEvent>
-#include <ksortablelist.h>
-#include <kvbox.h>
+#include <QString>
 
 #include "dolphinview.h"
 #include "undomanager.h"
 
 #include "dolphinview.h"
 #include "undomanager.h"
@@ -126,51 +127,6 @@ signals:
      */
     void selectionChanged();
 
      */
     void selectionChanged();
 
-public slots:
-    /**
-     * Updates the state of the 'Back' and 'Forward' menu
-     * actions corresponding the the current history.
-     */
-    void slotHistoryChanged();
-
-    /**
-     * Updates the caption of the main window and the state
-     * of all menu actions which depend from a changed Url.
-     */
-    void slotUrlChanged(const KUrl& url);
-
-    /**
-     * Go to the given Url.
-     */
-    void slotUrlChangeRequest(const KUrl& url);
-
-    /** Updates the state of all 'View' menu actions. */
-    void slotViewModeChanged();
-
-    /** Updates the state of the 'Show hidden files' menu action. */
-    void slotShowHiddenFilesChanged();
-
-    /** Updates the state of the 'Show filter bar' menu action. */
-    void slotShowFilterBarChanged();
-
-    /** Updates the state of the 'Sort by' actions. */
-    void slotSortingChanged(DolphinView::Sorting sorting);
-
-    /** Updates the state of the 'Sort Ascending/Descending' action. */
-    void slotSortOrderChanged(Qt::SortOrder order);
-
-    /** Updates the state of the 'Edit' menu actions. */
-    void slotSelectionChanged();
-
-    /** Executes Redo operation */
-    void slotRedo();
-
-    /** @see slotUndo() */
-    void slotUndo();
-
-    /** Open a  new mainwindow */
-    void slotNewMainWindow();
-
 protected:
     /** @see QMainWindow::closeEvent */
     virtual void closeEvent(QCloseEvent* event);
 protected:
     /** @see QMainWindow::closeEvent */
     virtual void closeEvent(QCloseEvent* event);
@@ -371,6 +327,44 @@ private slots:
      */
     void addUndoOperation(KJob* job);
 
      */
     void addUndoOperation(KJob* job);
 
+    /** Updates the state of all 'View' menu actions. */
+    void slotViewModeChanged();
+
+    /** Updates the state of the 'Show hidden files' menu action. */
+    void slotShowHiddenFilesChanged();
+
+    /** Updates the state of the 'Sort by' actions. */
+    void slotSortingChanged(DolphinView::Sorting sorting);
+
+    /** Updates the state of the 'Sort Ascending/Descending' action. */
+    void slotSortOrderChanged(Qt::SortOrder order);
+
+    /** Updates the state of the 'Edit' menu actions. */
+    void slotSelectionChanged();
+
+    /**
+     * Updates the state of the 'Back' and 'Forward' menu
+     * actions corresponding the the current history.
+     */
+    void slotHistoryChanged();
+
+    /**
+     * Updates the caption of the main window and the state
+     * of all menu actions which depend from a changed Url.
+     */
+    void slotUrlChanged(const KUrl& url);
+
+    /** Updates the state of the 'Show filter bar' menu action. */
+    void updateFilterBarAction(bool show);
+
+    /** Executes the redo operation (see UndoManager::Redo ()). */
+    void redo();
+
+    /** Executes the undo operation (see UndoManager::Undo()). */
+    void undo();
+
+    /** Open a new main window. */
+    void openNewMainWindow();
 
 private:
     DolphinMainWindow();
 
 private:
     DolphinMainWindow();
@@ -394,6 +388,15 @@ private:
                            const KUrl& dest);
     void clearStatusBar();
 
                            const KUrl& dest);
     void clearStatusBar();
 
+    /**
+     * Connects the signals from the created DolphinView with
+     * the index \a viewIndex with the corresponding slots of
+     * the DolphinMainWindow. This method must be invoked each
+     * time a DolphinView has been created.
+     */
+    void connectViewSignals(int viewIndex);
+
+private:
     QSplitter* m_splitter;
     DolphinView* m_activeView;
 
     QSplitter* m_splitter;
     DolphinView* m_activeView;
 
index 3aa4e54626f1cd0b0975282a8f4513e5875a3891..9a647af4daa0019bcbe9af9b6935b419607cf17c 100644 (file)
 #include "dolphinview.h"
 
 #include <QItemSelectionModel>
 #include "dolphinview.h"
 
 #include <QItemSelectionModel>
-
-#include <kdirmodel.h>
-
-#include <qlayout.h>
-//Added by qt3to4:
 #include <Q3ValueList>
 #include <QDropEvent>
 #include <QMouseEvent>
 #include <QVBoxLayout>
 #include <Q3ValueList>
 #include <QDropEvent>
 #include <QMouseEvent>
 #include <QVBoxLayout>
+
+#include <kdirmodel.h>
+#include <kfileitemdelegate.h>
 #include <kurl.h>
 #include <klocale.h>
 #include <kio/netaccess.h>
 #include <kurl.h>
 #include <klocale.h>
 #include <kio/netaccess.h>
@@ -48,7 +46,6 @@
 #include "undomanager.h"
 #include "renamedialog.h"
 #include "progressindicator.h"
 #include "undomanager.h"
 #include "renamedialog.h"
 #include "progressindicator.h"
-
 #include "filterbar.h"
 
 DolphinView::DolphinView(DolphinMainWindow *mainWindow,
 #include "filterbar.h"
 
 DolphinView::DolphinView(DolphinMainWindow *mainWindow,
@@ -57,10 +54,10 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
                          Mode mode,
                          bool showHiddenFiles) :
     QWidget(parent),
                          Mode mode,
                          bool showHiddenFiles) :
     QWidget(parent),
-    m_mainWindow(mainWindow),
     m_refreshing(false),
     m_showProgress(false),
     m_mode(mode),
     m_refreshing(false),
     m_showProgress(false),
     m_mode(mode),
+    m_mainWindow(mainWindow),
     m_statusBar(0),
     m_iconSize(0),
     m_folderCount(0),
     m_statusBar(0),
     m_iconSize(0),
     m_folderCount(0),
@@ -73,22 +70,9 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
     m_topLayout->setSpacing(0);
     m_topLayout->setMargin(0);
 
     m_topLayout->setSpacing(0);
     m_topLayout->setMargin(0);
 
-    connect(this, SIGNAL(signalModeChanged()),
-            mainWindow, SLOT(slotViewModeChanged()));
-    connect(this, SIGNAL(signalShowHiddenFilesChanged()),
-            mainWindow, SLOT(slotShowHiddenFilesChanged()));
-    connect(this, SIGNAL(signalSortingChanged(DolphinView::Sorting)),
-            mainWindow, SLOT(slotSortingChanged(DolphinView::Sorting)));
-    connect(this, SIGNAL(signalSortOrderChanged(Qt::SortOrder)),
-            mainWindow, SLOT(slotSortOrderChanged(Qt::SortOrder)));
-
     m_urlNavigator = new UrlNavigator(url, this);
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
     m_urlNavigator = new UrlNavigator(url, this);
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
-            this, SLOT(slotUrlChanged(const KUrl&)));
-    connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
-            mainWindow, SLOT(slotUrlChanged(const KUrl&)));
-    connect(m_urlNavigator, SIGNAL(historyChanged()),
-            mainWindow, SLOT(slotHistoryChanged()));
+            this, SLOT(loadDirectory(const KUrl&)));
 
     m_statusBar = new DolphinStatusBar(this);
 
 
     m_statusBar = new DolphinStatusBar(this);
 
@@ -110,29 +94,37 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
             this, SLOT(slotErrorMessage(const QString&)));
 
     m_iconsView = new DolphinIconsView(this);
             this, SLOT(slotErrorMessage(const QString&)));
 
     m_iconsView = new DolphinIconsView(this);
-    connect(m_iconsView, SIGNAL(clicked(const QModelIndex&)),
-            this, SLOT(triggerItem(const QModelIndex&)));
     applyModeToView();
 
     KDirModel* model = new KDirModel();
     model->setDirLister(m_dirLister);
     m_iconsView->setModel(model);
 
     applyModeToView();
 
     KDirModel* model = new KDirModel();
     model->setDirLister(m_dirLister);
     m_iconsView->setModel(model);
 
+    KFileItemDelegate* delegate = new KFileItemDelegate(this);
+    m_iconsView->setItemDelegate(delegate);
+
     m_dirLister->setDelayedMimeTypes(true);
     m_dirLister->setDelayedMimeTypes(true);
-    new KMimeTypeResolver( m_iconsView, model );
+    new KMimeTypeResolver(m_iconsView, model);
 
     m_iconSize = K3Icon::SizeMedium;
 
 
     m_iconSize = K3Icon::SizeMedium;
 
-    m_filterBar = new FilterBar(mainWindow, this);
+    m_filterBar = new FilterBar(this);
     m_filterBar->hide();
     m_filterBar->hide();
-    connect(m_filterBar, SIGNAL(signalFilterChanged(const QString&)),
+    connect(m_filterBar, SIGNAL(filterChanged(const QString&)),
            this, SLOT(slotChangeNameFilter(const QString&)));
            this, SLOT(slotChangeNameFilter(const QString&)));
+    connect(m_filterBar, SIGNAL(closed()),
+            this, SLOT(closeFilterBar()));
 
     m_topLayout->addWidget(m_urlNavigator);
     m_topLayout->addWidget(m_iconsView);
     m_topLayout->addWidget(m_filterBar);
     m_topLayout->addWidget(m_statusBar);
 
 
     m_topLayout->addWidget(m_urlNavigator);
     m_topLayout->addWidget(m_iconsView);
     m_topLayout->addWidget(m_filterBar);
     m_topLayout->addWidget(m_statusBar);
 
+    connect(m_iconsView, SIGNAL(clicked(const QModelIndex&)),
+            this, SLOT(triggerItem(const QModelIndex&)));
+    connect(m_iconsView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
+            this, SLOT(emitSelectionChangedSignal()));
+
     startDirLister(m_urlNavigator->url());
 }
 
     startDirLister(m_urlNavigator->url());
 }
 
@@ -176,7 +168,7 @@ void DolphinView::setMode(Mode mode)
     applyModeToView();
     startDirLister(m_urlNavigator->url());
 
     applyModeToView();
     startDirLister(m_urlNavigator->url());
 
-    emit signalModeChanged();
+    emit modeChanged();
 }
 
 DolphinView::Mode DolphinView::mode() const
 }
 
 DolphinView::Mode DolphinView::mode() const
@@ -196,7 +188,7 @@ void DolphinView::setShowHiddenFilesEnabled(bool show)
 
     m_dirLister->setShowingDotFiles(show);
 
 
     m_dirLister->setShowingDotFiles(show);
 
-    emit signalShowHiddenFilesChanged();
+    emit showHiddenFilesChanged();
 
     reload();
 }
 
     reload();
 }
@@ -362,9 +354,14 @@ void DolphinView::updateStatusBar()
     }
 }
 
     }
 }
 
-void DolphinView::requestItemInfo(const KUrl& url)
+void DolphinView::emitRequestItemInfo(const KUrl& url)
+{
+    emit requestItemInfo(url);
+}
+
+bool DolphinView::isFilterBarVisible() const
 {
 {
-    emit signalRequestItemInfo(url);
+  return m_filterBar->isVisible();
 }
 
 bool DolphinView::isUrlEditable() const
 }
 
 bool DolphinView::isUrlEditable() const
@@ -633,7 +630,7 @@ DolphinMainWindow* DolphinView::mainWindow() const
     return m_mainWindow;
 }
 
     return m_mainWindow;
 }
 
-void DolphinView::slotUrlChanged(const KUrl& url)
+void DolphinView::loadDirectory(const KUrl& url)
 {
     const ViewProperties props(url);
     setMode(props.viewMode());
 {
     const ViewProperties props(url);
     setMode(props.viewMode());
@@ -646,14 +643,7 @@ void DolphinView::slotUrlChanged(const KUrl& url)
     setSortOrder(props.sortOrder());
 
     startDirLister(url);
     setSortOrder(props.sortOrder());
 
     startDirLister(url);
-
-    // The selectionChanged signal is not emitted when a new view object is
-    // created. The application does not care whether a view is represented by a
-    // different instance, hence inform the application that the selection might have
-    // changed so that it can update it's actions.
-    mainWindow()->slotSelectionChanged();
-
-    emit signalUrlChanged(url);
+    emit urlChanged(url);
 }
 
 void DolphinView::triggerIconsViewItem(Q3IconViewItem* item)
 }
 
 void DolphinView::triggerIconsViewItem(Q3IconViewItem* item)
@@ -821,6 +811,17 @@ void DolphinView::slotGrabActivation()
     mainWindow()->setActiveView(this);
 }
 
     mainWindow()->setActiveView(this);
 }
 
+void DolphinView::emitSelectionChangedSignal()
+{
+    emit selectionChanged();
+}
+
+void DolphinView::closeFilterBar()
+{
+    m_filterBar->hide();
+    emit showFilterBarChanged(false);
+}
+
 void DolphinView::slotContentsMoving(int x, int y)
 {
     if (!m_refreshing) {
 void DolphinView::slotContentsMoving(int x, int y)
 {
     if (!m_refreshing) {
@@ -1029,13 +1030,11 @@ void DolphinView::slotChangeNameFilter(const QString& nameFilter)
     }*/
 }
 
     }*/
 }
 
-bool DolphinView::isFilterBarVisible()
-{
-  return m_filterBar->isVisible();
-}
-
 void DolphinView::applyModeToView()
 {
 void DolphinView::applyModeToView()
 {
+    //m_iconsView->setAlternatingRowColors(true);
+    m_iconsView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
     // TODO: the following code just tries to test some QListView capabilities
     switch (m_mode) {
         case IconsView:
     // TODO: the following code just tries to test some QListView capabilities
     switch (m_mode) {
         case IconsView:
index c78bc0b61e60646f160826ec74ce49a146b8ee8b..39fb7cc2645d960d0875f7e9bf76721d8b20cbcf 100644 (file)
@@ -313,19 +313,14 @@ public:
 
     /**
      * Triggers to request user information for the item given
 
     /**
      * Triggers to request user information for the item given
-     * by the Url \a url. The signal signalRequestItemInfo 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.
      */
      * which provides a way for widgets to get an indication to update
      * the item information.
      */
-    void requestItemInfo(const KUrl& url);
+    void emitRequestItemInfo(const KUrl& url);
 
 
-    /**
-     * Checks if the filter bar is visible.
-     *
-     * @return @c true Filter bar is visible.
-     * @return @c false Filter bar is not visible.
-     */
-    bool isFilterBarVisible();
+    /** Returns true, if the filter bar is visible. */
+    bool isFilterBarVisible() const;
 
     /**
      * Return the DolphinMainWindow this View belongs to. It is guranteed
 
     /**
      * Return the DolphinMainWindow this View belongs to. It is guranteed
@@ -351,28 +346,28 @@ public slots:
 
 signals:
     /** Is emitted if Url of the view has been changed to \a url. */
 
 signals:
     /** Is emitted if Url of the view has been changed to \a url. */
-    void signalUrlChanged(const KUrl& url);
+    void urlChanged(const KUrl& url);
 
     /**
      * Is emitted if the view mode (IconsView, DetailsView,
      * PreviewsView) has been changed.
      */
 
     /**
      * Is emitted if the view mode (IconsView, DetailsView,
      * PreviewsView) has been changed.
      */
-    void signalModeChanged();
+    void modeChanged();
 
     /** Is emitted if the 'show hidden files' property has been changed. */
 
     /** Is emitted if the 'show hidden files' property has been changed. */
-    void signalShowHiddenFilesChanged();
+    void showHiddenFilesChanged();
 
     /** Is emitted if the sorting by name, size or date has been changed. */
 
     /** Is emitted if the sorting by name, size or date has been changed. */
-    void signalSortingChanged(DolphinView::Sorting sorting);
+    void sortingChanged(DolphinView::Sorting sorting);
 
     /** Is emitted if the sort order (ascending or descending) has been changed. */
 
     /** Is emitted if the sort order (ascending or descending) has been changed. */
-    void signalSortOrderChanged(Qt::SortOrder order);
+    void sortOrderChanged(Qt::SortOrder order);
 
     /**
      * 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.
      */
 
     /**
      * 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.
      */
-    void signalRequestItemInfo(const KUrl& url);
+    void requestItemInfo(const KUrl& url);
 
     /** Is emitted if the contents has been moved to \a x, \a y. */
     void contentsMoved(int x, int y);
 
     /** Is emitted if the contents has been moved to \a x, \a y. */
     void contentsMoved(int x, int y);
@@ -382,20 +377,19 @@ signals:
      * be retrieved by mainWindow()->activeView()->selectedItems() or by
      * mainWindow()->activeView()->selectedUrls().
      */
      * be retrieved by mainWindow()->activeView()->selectedItems() or by
      * mainWindow()->activeView()->selectedUrls().
      */
-    void signalSelectionChanged();
+    void selectionChanged();
 
     /**
 
     /**
-     * Is emitted whenever the directory view is redirected by an ioslave
+     * Is emitted whenever the filter bar has been turned show or hidden.
      */
      */
-    void redirection(const KUrl& oldUrl, const KUrl& newUrl);
+    void showFilterBarChanged(bool shown);
 
 protected:
     /** @see QWidget::mouseReleaseEvent */
     virtual void mouseReleaseEvent(QMouseEvent* event);
 
 
 protected:
     /** @see QWidget::mouseReleaseEvent */
     virtual void mouseReleaseEvent(QMouseEvent* event);
 
-
 private slots:
 private slots:
-    void slotUrlChanged(const KUrl& kurl);
+    void loadDirectory(const KUrl& kurl);
     void triggerIconsViewItem(Q3IconViewItem *item);
     void triggerItem(const QModelIndex& index);
     void updateUrl();
     void triggerIconsViewItem(Q3IconViewItem *item);
     void triggerItem(const QModelIndex& index);
     void updateUrl();
@@ -406,8 +400,9 @@ private slots:
     void slotCompleted();
     void slotInfoMessage(const QString& msg);
     void slotErrorMessage(const QString& msg);
     void slotCompleted();
     void slotInfoMessage(const QString& msg);
     void slotErrorMessage(const QString& msg);
-
     void slotGrabActivation();
     void slotGrabActivation();
+    void emitSelectionChangedSignal();
+    void closeFilterBar();
 
     /**
      * Is invoked shortly before the contents of a view implementation
 
     /**
      * Is invoked shortly before the contents of a view implementation
@@ -453,11 +448,11 @@ private:
      */
     void applyModeToView();
 
      */
     void applyModeToView();
 
-    DolphinMainWindow *m_mainWindow;
     bool m_refreshing;
     bool m_showProgress;
     Mode m_mode;
 
     bool m_refreshing;
     bool m_showProgress;
     Mode m_mode;
 
+    DolphinMainWindow* m_mainWindow;
     QVBoxLayout* m_topLayout;
     UrlNavigator* m_urlNavigator;
     DolphinIconsView* m_iconsView;
     QVBoxLayout* m_topLayout;
     UrlNavigator* m_urlNavigator;
     DolphinIconsView* m_iconsView;
index dda36c1c4e9cfe478ca69b02860add97663fa3dc..48624a26ac2c7c9694e56c5483ac92fe425fceb7 100644 (file)
 
 #include "dolphinmainwindow.h"
 
 
 #include "dolphinmainwindow.h"
 
-FilterBar::FilterBar(DolphinMainWindow* mainWindow, QWidget *parent, const char *name) :
-    QWidget(parent, name),
-    m_mainWindow(mainWindow)
+FilterBar::FilterBar(QWidget* parent) :
+    QWidget(parent)
 {
     const int gap = 3;
 
 {
     const int gap = 3;
 
-    QVBoxLayout* foo = new QVBoxLayout(this);
-    foo->setMargin(0);
-    foo->addSpacing(gap);
+    QVBoxLayout* vLayout = new QVBoxLayout(this);
+    vLayout->setMargin(0);
+    vLayout->addSpacing(gap);
 
 
-    QHBoxLayout* layout = new QHBoxLayout(foo);
-    layout->setMargin(0);
-    layout->addSpacing(gap);
+    QHBoxLayout* hLayout = new QHBoxLayout(vLayout);
+    hLayout->setMargin(0);
+    hLayout->addSpacing(gap);
 
     m_filter = new QLabel(i18n("Filter:"), this);
 
     m_filter = new QLabel(i18n("Filter:"), this);
-    layout->addWidget(m_filter);
-    layout->addSpacing(KDialog::spacingHint());
+    hLayout->addWidget(m_filter);
+    hLayout->addSpacing(KDialog::spacingHint());
 
     m_filterInput = new KLineEdit(this);
     m_filter->setBuddy(m_filterInput);
 
     m_filterInput = new KLineEdit(this);
     m_filter->setBuddy(m_filterInput);
-    layout->addWidget(m_filterInput);
+    hLayout->addWidget(m_filterInput);
 
     m_close = new QToolButton(this);
     m_close->setAutoRaise(true);
     m_close->setIcon(QIcon(SmallIcon("fileclose")));
 
     m_close = new QToolButton(this);
     m_close->setAutoRaise(true);
     m_close->setIcon(QIcon(SmallIcon("fileclose")));
-    layout->addWidget(m_close);
-    layout->addSpacing(gap);
+    hLayout->addWidget(m_close);
+    hLayout->addSpacing(gap);
 
     connect(m_filterInput, SIGNAL(textChanged(const QString&)),
             this, SIGNAL(signalFilterChanged(const QString&)));
 
     connect(m_filterInput, SIGNAL(textChanged(const QString&)),
             this, SIGNAL(signalFilterChanged(const QString&)));
-    connect(m_close, SIGNAL(clicked()), this, SLOT(hide()));
-    connect(m_close, SIGNAL(clicked()),
-            mainWindow, SLOT(slotShowFilterBarChanged()));
+    connect(m_close, SIGNAL(clicked()), this, SLOT(emitClose()));
 }
 
 FilterBar::~FilterBar()
 }
 
 FilterBar::~FilterBar()
@@ -89,9 +86,13 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
 {
     QWidget::keyReleaseEvent(event);
     if ((event->key() == Qt::Key_Escape)) {
 {
     QWidget::keyReleaseEvent(event);
     if ((event->key() == Qt::Key_Escape)) {
-        hide();
-        m_mainWindow->slotShowFilterBarChanged();
+        emitClose();
     }
 }
 
     }
 }
 
+void FilterBar::emitClose()
+{
+    emit close();
+}
+
 #include "filterbar.moc"
 #include "filterbar.moc"
index 503938fc07f2ef04c9a45f01afb2a1b3c9ed4861..b1d60232c05c67faa27219f99fbcf2ca26d736b7 100644 (file)
@@ -31,13 +31,14 @@ class DolphinMainWindow;
  * @brief Provides an input field for filtering the currently shown items.
  *
  * @author Gregor Kališnik <gregor@podnapisi.net>
  * @brief Provides an input field for filtering the currently shown items.
  *
  * @author Gregor Kališnik <gregor@podnapisi.net>
+ * @author Peter Penz <peter.penz@gmx.at>
  */
 class FilterBar : public QWidget
 {
     Q_OBJECT
 
 public:
  */
 class FilterBar : public QWidget
 {
     Q_OBJECT
 
 public:
-    FilterBar(DolphinMainWindow* mainWindow, QWidget *parent = 0, const char *name = 0);
+    FilterBar(QWidget* parent = 0);
     virtual ~FilterBar();
 
 signals:
     virtual ~FilterBar();
 
 signals:
@@ -45,15 +46,22 @@ signals:
      * Signal that reports the name filter has been
      * changed to \a nameFilter.
      */
      * Signal that reports the name filter has been
      * changed to \a nameFilter.
      */
-    void signalFilterChanged(const QString& nameFilter);
+    void filterChanged(const QString& nameFilter);
+
+    /**
+     * Emitted as soon as the filterbar should get closed.
+     */
+    void closed();
 
 protected:
     virtual void hideEvent(QHideEvent* event);
     virtual void showEvent(QShowEvent* event);
     virtual void keyReleaseEvent(QKeyEvent* event);
 
 
 protected:
     virtual void hideEvent(QHideEvent* event);
     virtual void showEvent(QShowEvent* event);
     virtual void keyReleaseEvent(QKeyEvent* event);
 
+private slots:
+    void emitClose();
+
 private:
 private:
-    DolphinMainWindow *m_mainWindow;
     QLabel* m_filter;
     KLineEdit* m_filterInput;
     QToolButton* m_close;
     QLabel* m_filter;
     KLineEdit* m_filterInput;
     QToolButton* m_close;
index 0b1588e83ca8a1de3016d3542449e9037a7bee8c..3a8099d6e1ddae863240485c356f7cecb7f3146f 100644 (file)
@@ -234,7 +234,7 @@ void InfoSidebarPage::connectToActiveView()
     cancelRequest();
 
     DolphinView* view = mainWindow()->activeView();
     cancelRequest();
 
     DolphinView* view = mainWindow()->activeView();
-    connect(view, SIGNAL(signalRequestItemInfo(const KUrl&)),
+    connect(view, SIGNAL(requestItemInfo(const KUrl&)),
             this, SLOT(requestDelayedItemInfo(const KUrl&)));
     connect(view, SIGNAL(signalUrlChanged(const KUrl&)),
             this, SLOT(requestItemInfo(const KUrl&)));
             this, SLOT(requestDelayedItemInfo(const KUrl&)));
     connect(view, SIGNAL(signalUrlChanged(const KUrl&)),
             this, SLOT(requestItemInfo(const KUrl&)));