• 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
findbarsourceview.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 #include "findbarsourceview.h"
19 #include "pimcommon/widgets/lineeditwithcompleter.h"
20 
21 #include <KLocalizedString>
22 #include <QPlainTextEdit>
23 #include <QAction>
24 
25 using namespace MessageViewer;
26 
27 FindBarSourceView::FindBarSourceView( QPlainTextEdit * view, QWidget * parent )
28  : FindBarBase( parent ), mView( view )
29 {
30 }
31 
32 FindBarSourceView::~FindBarSourceView()
33 {
34 }
35 
36 
37 void FindBarSourceView::searchText( bool backward, bool isAutoSearch )
38 {
39  QTextDocument::FindFlags searchOptions = 0;
40  if ( backward )
41  searchOptions |= QTextDocument::FindBackward;
42  if ( mCaseSensitiveAct->isChecked() )
43  searchOptions |= QTextDocument::FindCaseSensitively;
44 
45  if ( isAutoSearch ) {
46  QTextCursor cursor = mView->textCursor();
47  cursor.setPosition( cursor.selectionStart() );
48  mView->setTextCursor( cursor );
49  } else if( !mLastSearchStr.contains( mSearch->text(), Qt::CaseSensitive )) {
50  clearSelections();
51  }
52  mLastSearchStr = mSearch->text();
53  const bool found = mView->find( mLastSearchStr, searchOptions );
54 
55  setFoundMatch( found );
56 }
57 
58 
59 void FindBarSourceView::clearSelections()
60 {
61  QTextCursor textCursor = mView->textCursor();
62  textCursor.clearSelection();
63  textCursor.setPosition( 0 );
64  mView->setTextCursor( textCursor );
65 
66  FindBarBase::clearSelections();
67 }
68 
69 void FindBarSourceView::updateHighLight(bool)
70 {
71  clearSelections();
72 }
73 
74 void FindBarSourceView::updateSensitivity(bool)
75 {
76  QTextDocument::FindFlags searchOptions = 0;
77  if ( mCaseSensitiveAct->isChecked() )
78  searchOptions |= QTextDocument::FindCaseSensitively;
79  mLastSearchStr = mSearch->text();
80  const bool found = mView->find( mLastSearchStr, searchOptions );
81  setFoundMatch( found );
82 }
83 
84 
QWidget
QTextCursor
QWidget::cursor
QCursor cursor() const
QTextCursor::clearSelection
void clearSelection()
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
QTextCursor::selectionStart
int selectionStart() const
MessageViewer::FindBarBase::mLastSearchStr
QString mLastSearchStr
Definition: findbarbase.h:74
QPlainTextEdit::find
bool find(const QString &exp, QFlags< QTextDocument::FindFlag > options)
MessageViewer::FindBarSourceView::~FindBarSourceView
~FindBarSourceView()
Definition: findbarsourceview.cpp:32
QPlainTextEdit
QPlainTextEdit::textCursor
QTextCursor textCursor() const
findbarsourceview.h
MessageViewer::FindBarSourceView::FindBarSourceView
FindBarSourceView(QPlainTextEdit *view, QWidget *parent=0)
Definition: findbarsourceview.cpp:27
MessageViewer::FindBarBase::mSearch
PimCommon::LineEditWithCompleter * mSearch
Definition: findbarbase.h:75
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QPlainTextEdit::setTextCursor
void setTextCursor(const QTextCursor &cursor)
MessageViewer::FindBarBase::mCaseSensitiveAct
QAction * mCaseSensitiveAct
Definition: findbarbase.h:76
QTextDocument::FindFlags
typedef FindFlags
QTextCursor::setPosition
void setPosition(int pos, MoveMode m)
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