From 5944fa01d76b7624bb88672c48dd4c597e3c4f02 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 14 Nov 2008 12:12:35 +0100 Subject: searchbar --> findbar Yes, I know it's a search bar and finding is not granted. But I need to distingue between this and the "other" searchbar.. --- src/CMakeLists.txt | 2 +- src/browsermainwindow.cpp | 12 ++-- src/browsermainwindow.h | 7 +-- src/findbar.cpp | 125 ++++++++++++++++++++++++++++++++++++++++ src/findbar.h | 53 +++++++++++++++++ src/findwidget.cpp | 58 ------------------- src/findwidget.h | 33 ----------- src/searchbar.cpp | 141 ---------------------------------------------- src/searchbar.h | 58 ------------------- 9 files changed, 188 insertions(+), 301 deletions(-) create mode 100644 src/findbar.cpp create mode 100644 src/findbar.h delete mode 100644 src/findwidget.cpp delete mode 100644 src/findwidget.h delete mode 100644 src/searchbar.cpp delete mode 100644 src/searchbar.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a30af320..2f4ebb9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,7 @@ SET( rekonq_SRCS modelmenu.cpp networkaccessmanager.cpp searchlineedit.cpp - searchbar.cpp + findbar.cpp findwidget.cpp settings.cpp squeezelabel.cpp diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 717031a5..46510384 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -82,9 +82,9 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) addToolBarBreak(); layout->addWidget(m_tabWidget); - // Search Bar - m_searchBar = new SearchBar(centralWidget); - layout->addWidget(m_searchBar); + // Find Bar + m_findBar = new FindBar(centralWidget); + layout->addWidget(m_findBar); centralWidget->setLayout(layout); setCentralWidget(centralWidget); @@ -268,7 +268,7 @@ void BrowserMainWindow::setupMenu() editMenu->addSeparator(); - editMenu->addAction( KStandardAction::find(this, SLOT( slotViewSearchBar() ) , this ) ); + editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); editMenu->addAction( KStandardAction::findNext(this, SLOT( slotEditFindNext() ) , this ) ); editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotEditFindPrevious() ) , this ) ); @@ -671,9 +671,9 @@ bool ok; m_lastSearch = findWidg->*/ } -void BrowserMainWindow::slotViewSearchBar() +void BrowserMainWindow::slotViewFindBar() { - m_searchBar->show(); + m_findBar->show(); } void BrowserMainWindow::slotEditFindNext() diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 64962c58..cc206626 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -23,7 +23,7 @@ #define BROWSERMAINWINDOW_H // Local Includes -#include "searchbar.h" +#include "findbar.h" // KDE Includes #include @@ -96,7 +96,7 @@ private slots: void slotViewStatusbar(); void slotViewPageSource(); void slotViewFullScreen(bool enable); - void slotViewSearchBar(); + void slotViewFindBar(); void slotWebSearch(); void slotToggleInspector(bool enable); @@ -133,7 +133,6 @@ private: QAction *m_historyBack; KMenu *m_historyBackMenu; QAction *m_historyForward; -// KMenu *m_historyForwardMenu; KMenu *m_windowMenu; KAction *m_stop; @@ -147,7 +146,7 @@ private: KIcon m_reloadIcon; KIcon m_stopIcon; - SearchBar *m_searchBar; + FindBar *m_findBar; QString m_lastSearch; KBookmarkMenu* m_bookmarkMenu; diff --git a/src/findbar.cpp b/src/findbar.cpp new file mode 100644 index 00000000..ae64b7f6 --- /dev/null +++ b/src/findbar.cpp @@ -0,0 +1,125 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#include "findbar.h" +#include "moc_findbar.cpp" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +FindBar::FindBar(QWidget *parent) + : QWidget(parent) + , m_lineEdit(0) +{ + initializeFindWidget(); + + // we start off hidden + setMaximumHeight(0); +// m_widget->setGeometry(0, -1 * m_widget->height(), m_widget->width(), m_widget->height()); + hide(); + + new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(hide())); +} + +FindBar::~FindBar() +{ + delete m_lineEdit; +} + + +void FindBar::initializeFindWidget() +{ + QHBoxLayout *layout = new QHBoxLayout(); + + KToolBar *bar1 = new KToolBar(this); + bar1->addAction( KStandardAction::close(this, SLOT( hide() ) , this ) ); + layout->addWidget( bar1 ); + + QLabel *label = new QLabel("Find: "); + layout->addWidget( label ); + + m_lineEdit = new KLineEdit(); + connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); + connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); + layout->addWidget( m_lineEdit ); + + KToolBar *bar2 = new KToolBar(this); + bar2->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); + bar2->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); + layout->addWidget( bar2 ); + + layout->addStretch(); + + setLayout(layout); +} + + + +void FindBar::clear() +{ + m_lineEdit->setText(QString()); +} + + +void FindBar::showFind() +{ + if (!isVisible()) + { + show(); + } + m_lineEdit->setFocus(); + m_lineEdit->selectAll(); +} + + +void FindBar::resizeEvent(QResizeEvent *event) +{ +/* if (event->size().width() != m_widget->width()) + m_widget->resize(event->size().width(), m_widget->height()); + QWidget::resizeEvent(event);*/ +} + + +void FindBar::frameChanged(int frame) +{ +/* if (!m_widget) + return; + m_widget->move(0, frame); + int height = qMax(0, m_widget->y() + m_widget->height()); + setMinimumHeight(height); + setMaximumHeight(height);*/ +} + + +void FindBar::slotFindNext() +{} + +void FindBar::slotFindPrevious() +{} + diff --git a/src/findbar.h b/src/findbar.h new file mode 100644 index 00000000..214a06e2 --- /dev/null +++ b/src/findbar.h @@ -0,0 +1,53 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef FINDBAR_H +#define FINDBAR_H + +#include + +#include + +class FindBar : public QWidget +{ + Q_OBJECT + +public: + FindBar(QWidget *parent = 0); + ~FindBar(); + +public slots: + void clear(); + void showFind(); + void slotFindNext(); + void slotFindPrevious(); + +protected: + void resizeEvent(QResizeEvent *event); + +private slots: + void frameChanged(int frame); + +private: + void initializeFindWidget(); + + KLineEdit *m_lineEdit; +}; + +#endif diff --git a/src/findwidget.cpp b/src/findwidget.cpp deleted file mode 100644 index 4eb10e6b..00000000 --- a/src/findwidget.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#include "findwidget.h" - -#include -#include - -#include -#include -#include -#include - -FindWidget::FindWidget(QWidget * parent) : QWidget(parent) -{ - QHBoxLayout *layout = new QHBoxLayout(); - - KToolBar *bar1 = new KToolBar(this); - bar1->addAction( KStandardAction::close(this, SLOT( searchNow() ) , this ) ); - layout->addWidget( bar1 ); - - QLabel *label = new QLabel("Find: "); - layout->addWidget( label ); - - KLineEdit *findLineEdit = new KLineEdit(); - layout->addWidget( findLineEdit ); - - KToolBar *bar2 = new KToolBar(this); - bar2->addAction( KStandardAction::findNext(this, SLOT( searchNow() ) , this ) ); - bar2->addAction( KStandardAction::findPrev(this, SLOT( searchNow() ) , this ) ); - layout->addWidget( bar2 ); - - layout->addStretch(); - - setLayout(layout); -} - -QString FindWidget::searchNow() -{ - QString prova("adjam"); - return prova; -} diff --git a/src/findwidget.h b/src/findwidget.h deleted file mode 100644 index 5d8b7b28..00000000 --- a/src/findwidget.h +++ /dev/null @@ -1,33 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef FINDWIDGET_H -#define FINDWIDGET_H - -#include - -class FindWidget : public QWidget -{ -public: - FindWidget(QWidget * parent = 0); - - QString searchNow(); -}; - -#endif diff --git a/src/searchbar.cpp b/src/searchbar.cpp deleted file mode 100644 index b0e91fa9..00000000 --- a/src/searchbar.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright 2008 Benjamin C. Meyer - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#include "searchbar.h" -#include "moc_searchbar.cpp" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -SearchBar::SearchBar(QWidget *parent) - : QWidget(parent) - , m_object(0) - , m_widget(0) - , m_lineEdit(0) -{ - initializeSearchWidget(); - - // we start off hidden - setMaximumHeight(0); -// m_widget->setGeometry(0, -1 * m_widget->height(), m_widget->width(), m_widget->height()); - hide(); - - new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(hide())); -} - -SearchBar::~SearchBar() -{ - delete m_object; - delete m_widget; - delete m_lineEdit; -} - - -void SearchBar::initializeSearchWidget() -{ - QHBoxLayout *layout = new QHBoxLayout(); - - KToolBar *bar1 = new KToolBar(this); - bar1->addAction( KStandardAction::close(this, SLOT( hide() ) , this ) ); - layout->addWidget( bar1 ); - - QLabel *label = new QLabel("Find: "); - layout->addWidget( label ); - - m_lineEdit = new KLineEdit(); - connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); - connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); - layout->addWidget( m_lineEdit ); - - KToolBar *bar2 = new KToolBar(this); - bar2->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - bar2->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); - layout->addWidget( bar2 ); - - layout->addStretch(); - - setLayout(layout); -} - - -void SearchBar::setSearchBar(QObject *object) -{ - m_object = object; -} - - -QObject *SearchBar::getSearchBar() const -{ - return m_object; -} - - -void SearchBar::clear() -{ - m_lineEdit->setText(QString()); -} - - -void SearchBar::showFind() -{ - if (!isVisible()) - { - show(); - } - m_lineEdit->setFocus(); - m_lineEdit->selectAll(); -} - - -void SearchBar::resizeEvent(QResizeEvent *event) -{ -/* if (event->size().width() != m_widget->width()) - m_widget->resize(event->size().width(), m_widget->height()); - QWidget::resizeEvent(event);*/ -} - - -void SearchBar::frameChanged(int frame) -{ - if (!m_widget) - return; - m_widget->move(0, frame); - int height = qMax(0, m_widget->y() + m_widget->height()); - setMinimumHeight(height); - setMaximumHeight(height); -} - - -void SearchBar::slotFindNext() -{} - -void SearchBar::slotFindPrevious() -{} - diff --git a/src/searchbar.h b/src/searchbar.h deleted file mode 100644 index 287363c3..00000000 --- a/src/searchbar.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright 2008 Benjamin C. Meyer - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef SEARCHBAR_H -#define SEARCHBAR_H - -#include - -#include - -class SearchBar : public QWidget -{ - Q_OBJECT - -public: - SearchBar(QWidget *parent = 0); - ~SearchBar(); - void setSearchBar(QObject *); - QObject *getSearchBar() const; - -public slots: - void clear(); - void showFind(); - void slotFindNext(); - void slotFindPrevious(); - -protected: - void resizeEvent(QResizeEvent *event); - -private slots: - void frameChanged(int frame); - -private: - void initializeSearchWidget(); - QObject *m_object; - QWidget *m_widget; - - KLineEdit *m_lineEdit; -}; - -#endif -- cgit v1.2.1