• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.14
  • kdepim
  • messageviewer
  • findbar
findbarmailwebview.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2015 Laurent Montel <montel@kde.org>
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public License
14  * along with this library; see the file COPYING.LIB. If not, write to
15  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301, USA.
17  */
18 
19 #include "findbarmailwebview.h"
20 #include "pimcommon/widgets/lineeditwithcompleter.h"
21 #include "viewer/mailwebview.h"
22 
23 #include <KLocalizedString>
24 #include <QMenu>
25 using namespace MessageViewer;
26 
27 FindBarMailWebView::FindBarMailWebView( MailWebView * view, QWidget * parent )
28  : FindBarBase( parent ), mView( view )
29 {
30 #ifndef MESSAGEVIEWER_FINDBAR_NO_HIGHLIGHT_ALL
31  QMenu *options = optionsMenu();
32  mHighlightAll = options->addAction( i18n( "Highlight all matches" ) );
33  mHighlightAll->setCheckable( true );
34  connect( mHighlightAll, SIGNAL(toggled(bool)), this, SLOT(slotHighlightAllChanged(bool)) );
35 #endif
36 }
37 
38 FindBarMailWebView::~FindBarMailWebView()
39 {
40 }
41 
42 void FindBarMailWebView::searchText( bool backward, bool isAutoSearch )
43 {
44  MailWebView::FindFlags searchOptions = MailWebView::FindWrapsAroundDocument;
45 
46  if ( backward )
47  searchOptions |= MailWebView::FindBackward;
48  if ( mCaseSensitiveAct->isChecked() )
49  searchOptions |= MailWebView::FindCaseSensitively;
50 #ifndef MESSAGEVIEWER_FINDBAR_NO_HIGHLIGHT_ALL
51  if ( mHighlightAll->isChecked() )
52  searchOptions |= MailWebView::HighlightAllOccurrences;
53 #endif
54  const QString searchWord( mSearch->text() );
55  if( !isAutoSearch && !mLastSearchStr.contains( searchWord, Qt::CaseSensitive ) )
56  {
57  clearSelections();
58  }
59  mView->findText(QString(), MailWebView::HighlightAllOccurrences); //Clear an existing highligh
60 
61  mLastSearchStr = searchWord;
62  const bool found = mView->findText( mLastSearchStr, searchOptions );
63 
64  setFoundMatch( found );
65 }
66 
67 void FindBarMailWebView::updateHighLight(bool highLight)
68 {
69 #ifndef MESSAGEVIEWER_FINDBAR_NO_HIGHLIGHT_ALL
70  bool found = false;
71  if ( highLight ) {
72  MailWebView::FindFlags searchOptions = MailWebView::FindWrapsAroundDocument;
73  if ( mCaseSensitiveAct->isChecked() )
74  searchOptions |= MailWebView::FindCaseSensitively;
75  searchOptions |= MailWebView::HighlightAllOccurrences;
76  found = mView->findText(mLastSearchStr, searchOptions);
77  } else {
78  found = mView->findText(QString(), MailWebView::HighlightAllOccurrences);
79  }
80  setFoundMatch( found );
81 #endif
82 }
83 
84 void FindBarMailWebView::updateSensitivity( bool sensitivity )
85 {
86  MailWebView::FindFlags searchOptions = MailWebView::FindWrapsAroundDocument;
87  if ( sensitivity ) {
88  searchOptions |= MailWebView::FindCaseSensitively;
89  mView->findText(QString(), MailWebView::HighlightAllOccurrences); //Clear an existing highligh
90  }
91 #ifndef MESSAGEVIEWER_FINDBAR_NO_HIGHLIGHT_ALL
92  if ( mHighlightAll->isChecked() )
93  searchOptions |= MailWebView::HighlightAllOccurrences;
94 #endif
95  const bool found = mView->findText(mLastSearchStr, searchOptions);
96  setFoundMatch( found );
97 }
98 
99 
100 void FindBarMailWebView::clearSelections()
101 {
102  mView->clearFindSelection();
103  mLastSearchStr.clear();
104  FindBarBase::clearSelections();
105 }
106 
QWidget
MessageViewer::FindBarBase
Definition: findbarbase.h:34
MessageViewer::FindBarBase::clearSelections
virtual void clearSelections()
Definition: findbarbase.cpp:223
MessageViewer::FindBarBase::setFoundMatch
void setFoundMatch(bool match)
Definition: findbarbase.cpp:156
QAction::isChecked
bool isChecked() const
MessageViewer::FindBarBase::mLastSearchStr
QString mLastSearchStr
Definition: findbarbase.h:74
QMenu::addAction
void addAction(QAction *action)
findbarmailwebview.h
QString::clear
void clear()
MessageViewer::MailWebView::FindBackward
Definition: mailwebview.h:58
MessageViewer::MailWebView::FindWrapsAroundDocument
Definition: mailwebview.h:57
MessageViewer::MailWebView
MailWebView extends KWebView so that it can emit the popupMenu() signal.
Definition: mailwebview.h:47
MessageViewer::MailWebView::clearFindSelection
void clearFindSelection()
Definition: mailwebview_textbrowser.cpp:299
MessageViewer::MailWebView::HighlightAllOccurrences
Definition: mailwebview.h:60
MessageViewer::FindBarBase::mSearch
PimCommon::LineEditWithCompleter * mSearch
Definition: findbarbase.h:75
MessageViewer::MailWebView::FindCaseSensitively
Definition: mailwebview.h:59
QString
QMenu
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QAction::setCheckable
void setCheckable(bool)
mailwebview.h
MessageViewer::FindBarBase::mCaseSensitiveAct
QAction * mCaseSensitiveAct
Definition: findbarbase.h:76
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
MessageViewer::FindBarBase::optionsMenu
QMenu * optionsMenu()
Definition: findbarbase.cpp:112
MessageViewer::FindBarMailWebView::~FindBarMailWebView
~FindBarMailWebView()
Definition: findbarmailwebview.cpp:38
MessageViewer::FindBarMailWebView::FindBarMailWebView
FindBarMailWebView(MailWebView *view, QWidget *parent=0)
Definition: findbarmailwebview.cpp:27
MessageViewer::MailWebView::findText
bool findText(const QString &test, FindFlags flags)
Definition: mailwebview_textbrowser.cpp:294
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:45 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal