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

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • findbar
findbarmailwebview.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011, 2012, 2013 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 "viewer/mailwebview.h"
21 
22 #include <KLocale>
23 #include <KLineEdit>
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  FindBarBase::messageInfo( backward, isAutoSearch, found );
66 }
67 
68 void FindBarMailWebView::updateHighLight(bool highLight)
69 {
70 #ifndef MESSAGEVIEWER_FINDBAR_NO_HIGHLIGHT_ALL
71  bool found = false;
72  if ( highLight ) {
73  MailWebView::FindFlags searchOptions = MailWebView::FindWrapsAroundDocument;
74  if ( mCaseSensitiveAct->isChecked() )
75  searchOptions |= MailWebView::FindCaseSensitively;
76  searchOptions |= MailWebView::HighlightAllOccurrences;
77  found = mView->findText(mLastSearchStr, searchOptions);
78  } else {
79  found = mView->findText(QString(), MailWebView::HighlightAllOccurrences);
80  }
81  setFoundMatch( found );
82 #endif
83 }
84 
85 void FindBarMailWebView::updateSensitivity( bool sensitivity )
86 {
87  MailWebView::FindFlags searchOptions = MailWebView::FindWrapsAroundDocument;
88  if ( sensitivity ) {
89  searchOptions |= MailWebView::FindCaseSensitively;
90  mView->findText(QString(), MailWebView::HighlightAllOccurrences); //Clear an existing highligh
91  }
92 #ifndef MESSAGEVIEWER_FINDBAR_NO_HIGHLIGHT_ALL
93  if ( mHighlightAll->isChecked() )
94  searchOptions |= MailWebView::HighlightAllOccurrences;
95 #endif
96  const bool found = mView->findText(mLastSearchStr, searchOptions);
97  setFoundMatch( found );
98 }
99 
100 
101 void FindBarMailWebView::clearSelections()
102 {
103  mView->clearFindSelection();
104  FindBarBase::clearSelections();
105 }
106 
107 #include "findbarmailwebview.moc"
MessageViewer::FindBarBase
Definition: findbarbase.h:32
MessageViewer::FindBarBase::clearSelections
virtual void clearSelections()
Definition: findbarbase.cpp:212
MessageViewer::FindBarBase::setFoundMatch
void setFoundMatch(bool match)
Definition: findbarbase.cpp:155
MessageViewer::FindBarBase::mLastSearchStr
QString mLastSearchStr
Definition: findbarbase.h:69
QWidget
MessageViewer::FindBarBase::messageInfo
void messageInfo(bool backward, bool isAutoSearch, bool found)
Definition: findbarbase.cpp:143
findbarmailwebview.h
MessageViewer::MailWebView::FindBackward
Definition: mailwebview.h:65
MessageViewer::MailWebView::FindWrapsAroundDocument
Definition: mailwebview.h:64
MessageViewer::MailWebView
MailWebView extends KWebView so that it can emit the popupMenu() signal.
Definition: mailwebview.h:53
MessageViewer::MailWebView::clearFindSelection
void clearFindSelection()
Definition: mailwebview_textbrowser.cpp:302
MessageViewer::MailWebView::HighlightAllOccurrences
Definition: mailwebview.h:67
MessageViewer::MailWebView::FindCaseSensitively
Definition: mailwebview.h:66
mailwebview.h
MessageViewer::FindBarBase::mCaseSensitiveAct
QAction * mCaseSensitiveAct
Definition: findbarbase.h:71
MessageViewer::FindBarBase::mSearch
KLineEdit * mSearch
Definition: findbarbase.h:70
MessageViewer::FindBarBase::optionsMenu
QMenu * optionsMenu()
Definition: findbarbase.cpp:100
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:297
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 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

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