1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Cleanup of signal/slot handling between the dolphin view and the main window: now the main window listens to the signals from the dolphin view and connects to private slots (previously the dolphin view connected to public slots of the main window). Also prevent naming all slots by the prefix 'slot', describe instead what the method does.

svn path=/trunk/playground/utils/dolphin/; revision=611617
This commit is contained in:
Peter Penz 2006-12-08 23:41:08 +00:00
parent d7d4fb9d26
commit d8669c68e4
9 changed files with 234 additions and 191 deletions

View File

@ -28,13 +28,28 @@ DolphinIconsView::DolphinIconsView(DolphinView* parent) :
QListView(parent),
m_parentView( parent )
{
setResizeMode( QListView::Adjust );
setResizeMode(QListView::Adjust);
}
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);

View File

@ -42,6 +42,7 @@ public:
virtual ~DolphinIconsView();
protected:
virtual QStyleOptionViewItem viewOptions() const;
virtual void contextMenuEvent(QContextMenuEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);

View File

@ -218,6 +218,7 @@ void DolphinMainWindow::refreshViews()
url,
props.viewMode(),
props.isShowHiddenFilesEnabled());
connectViewSignals(i);
m_view[i]->show();
}
}
@ -229,24 +230,6 @@ void DolphinMainWindow::refreshViews()
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();
@ -259,13 +242,6 @@ void DolphinMainWindow::slotShowHiddenFilesChanged()
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;
@ -314,17 +290,36 @@ void DolphinMainWindow::slotSelectionChanged()
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);
}
void DolphinMainWindow::slotUndo()
void DolphinMainWindow::undo()
{
UndoManager::instance().undo(this);
}
void DolphinMainWindow::slotNewMainWindow()
void DolphinMainWindow::openNewMainWindow()
{
DolphinApplication::app()->createMainWindow()->show();
}
@ -826,6 +821,7 @@ void DolphinMainWindow::toggleSplitView()
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();
@ -1125,6 +1121,7 @@ void DolphinMainWindow::init()
homeUrl,
props.viewMode(),
props.isShowHiddenFilesEnabled());
connectViewSignals(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" );
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"));
@ -1201,7 +1198,7 @@ void DolphinMainWindow::setupActions()
// setup 'Edit' menu
UndoManager& undoManager = UndoManager::instance();
KStdAction::undo(this,
SLOT(slotUndo()),
SLOT(undo()),
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,
SLOT(slotRedo()),
SLOT(redo()),
actionCollection());
connect(&undoManager, SIGNAL(redoAvailable(bool)),
this, SLOT(slotRedoAvailable(bool)));
@ -1333,6 +1330,31 @@ void DolphinMainWindow::setupActions()
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
@ -1594,29 +1616,28 @@ void DolphinMainWindow::clearStatusBar()
m_activeView->statusBar()->clear();
}
void DolphinMainWindow::setupDockWidgets()
void DolphinMainWindow::connectViewSignals(int viewIndex)
{
QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
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)));
shortcutsDock->setObjectName("shortcutsDock");
shortcutsDock->setWidget(new BookmarksSidebarPage(this));
const UrlNavigator* navigator = view->urlNavigator();
connect(navigator, SIGNAL(urlChanged(const KUrl&)),
this, SLOT(slotUrlChanged(const KUrl&)));
connect(navigator, SIGNAL(historyChanged()),
this, SLOT(slotHistoryChanged()));
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);
}
#include "dolphinmainwindow.moc"

View File

@ -28,14 +28,15 @@
#include <kapplication.h>
#include <kmainwindow.h>
#include <q3valuelist.h>
#include <q3ptrlist.h>
#include <qstring.h>
//Added by qt3to4:
#include <QCloseEvent>
#include <ksortablelist.h>
#include <kvbox.h>
#include <q3valuelist.h>
#include <q3ptrlist.h>
#include <QCloseEvent>
#include <QString>
#include "dolphinview.h"
#include "undomanager.h"
@ -126,51 +127,6 @@ signals:
*/
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);
@ -371,6 +327,44 @@ private slots:
*/
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();
@ -394,6 +388,15 @@ private:
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;

View File

@ -21,15 +21,13 @@
#include "dolphinview.h"
#include <QItemSelectionModel>
#include <kdirmodel.h>
#include <qlayout.h>
//Added by qt3to4:
#include <Q3ValueList>
#include <QDropEvent>
#include <QMouseEvent>
#include <QVBoxLayout>
#include <kdirmodel.h>
#include <kfileitemdelegate.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 "filterbar.h"
DolphinView::DolphinView(DolphinMainWindow *mainWindow,
@ -57,10 +54,10 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
Mode mode,
bool showHiddenFiles) :
QWidget(parent),
m_mainWindow(mainWindow),
m_refreshing(false),
m_showProgress(false),
m_mode(mode),
m_mainWindow(mainWindow),
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);
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&)),
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);
@ -110,29 +94,37 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
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);
KFileItemDelegate* delegate = new KFileItemDelegate(this);
m_iconsView->setItemDelegate(delegate);
m_dirLister->setDelayedMimeTypes(true);
new KMimeTypeResolver( m_iconsView, model );
new KMimeTypeResolver(m_iconsView, model);
m_iconSize = K3Icon::SizeMedium;
m_filterBar = new FilterBar(mainWindow, this);
m_filterBar = new FilterBar(this);
m_filterBar->hide();
connect(m_filterBar, SIGNAL(signalFilterChanged(const QString&)),
connect(m_filterBar, SIGNAL(filterChanged(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);
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());
}
@ -176,7 +168,7 @@ void DolphinView::setMode(Mode mode)
applyModeToView();
startDirLister(m_urlNavigator->url());
emit signalModeChanged();
emit modeChanged();
}
DolphinView::Mode DolphinView::mode() const
@ -196,7 +188,7 @@ void DolphinView::setShowHiddenFilesEnabled(bool show)
m_dirLister->setShowingDotFiles(show);
emit signalShowHiddenFilesChanged();
emit showHiddenFilesChanged();
reload();
}
@ -362,9 +354,14 @@ void DolphinView::updateStatusBar()
}
}
void DolphinView::requestItemInfo(const KUrl& url)
void DolphinView::emitRequestItemInfo(const KUrl& url)
{
emit signalRequestItemInfo(url);
emit requestItemInfo(url);
}
bool DolphinView::isFilterBarVisible() const
{
return m_filterBar->isVisible();
}
bool DolphinView::isUrlEditable() const
@ -633,7 +630,7 @@ DolphinMainWindow* DolphinView::mainWindow() const
return m_mainWindow;
}
void DolphinView::slotUrlChanged(const KUrl& url)
void DolphinView::loadDirectory(const KUrl& url)
{
const ViewProperties props(url);
setMode(props.viewMode());
@ -646,14 +643,7 @@ void DolphinView::slotUrlChanged(const KUrl& 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)
@ -821,6 +811,17 @@ void DolphinView::slotGrabActivation()
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) {
@ -1029,13 +1030,11 @@ void DolphinView::slotChangeNameFilter(const QString& nameFilter)
}*/
}
bool DolphinView::isFilterBarVisible()
{
return m_filterBar->isVisible();
}
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:

View File

@ -313,19 +313,14 @@ public:
/**
* 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.
*/
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
@ -351,28 +346,28 @@ public slots:
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.
*/
void signalModeChanged();
void modeChanged();
/** 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. */
void signalSortingChanged(DolphinView::Sorting sorting);
void sortingChanged(DolphinView::Sorting sorting);
/** 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.
*/
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);
@ -382,20 +377,19 @@ signals:
* 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);
private slots:
void slotUrlChanged(const KUrl& kurl);
void loadDirectory(const KUrl& kurl);
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 slotGrabActivation();
void emitSelectionChangedSignal();
void closeFilterBar();
/**
* Is invoked shortly before the contents of a view implementation
@ -453,11 +448,11 @@ private:
*/
void applyModeToView();
DolphinMainWindow *m_mainWindow;
bool m_refreshing;
bool m_showProgress;
Mode m_mode;
DolphinMainWindow* m_mainWindow;
QVBoxLayout* m_topLayout;
UrlNavigator* m_urlNavigator;
DolphinIconsView* m_iconsView;

View File

@ -31,39 +31,36 @@
#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;
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);
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);
layout->addWidget(m_filterInput);
hLayout->addWidget(m_filterInput);
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_close, SIGNAL(clicked()), this, SLOT(hide()));
connect(m_close, SIGNAL(clicked()),
mainWindow, SLOT(slotShowFilterBarChanged()));
connect(m_close, SIGNAL(clicked()), this, SLOT(emitClose()));
}
FilterBar::~FilterBar()
@ -89,9 +86,13 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
{
QWidget::keyReleaseEvent(event);
if ((event->key() == Qt::Key_Escape)) {
hide();
m_mainWindow->slotShowFilterBarChanged();
emitClose();
}
}
void FilterBar::emitClose()
{
emit close();
}
#include "filterbar.moc"

View 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>
* @author Peter Penz <peter.penz@gmx.at>
*/
class FilterBar : public QWidget
{
Q_OBJECT
public:
FilterBar(DolphinMainWindow* mainWindow, QWidget *parent = 0, const char *name = 0);
FilterBar(QWidget* parent = 0);
virtual ~FilterBar();
signals:
@ -45,15 +46,22 @@ signals:
* 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);
private slots:
void emitClose();
private:
DolphinMainWindow *m_mainWindow;
QLabel* m_filter;
KLineEdit* m_filterInput;
QToolButton* m_close;

View File

@ -234,7 +234,7 @@ void InfoSidebarPage::connectToActiveView()
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&)));