• 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
findbarsourceview.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 #include "findbarsourceview.h"
19 
20 #include <KLocale>
21 #include <KLineEdit>
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  FindBarBase::messageInfo( backward, isAutoSearch, found );
57 }
58 
59 
60 void FindBarSourceView::clearSelections()
61 {
62  QTextCursor textCursor = mView->textCursor();
63  textCursor.clearSelection();
64  textCursor.setPosition( 0 );
65  mView->setTextCursor( textCursor );
66 
67  FindBarBase::clearSelections();
68 }
69 
70 void FindBarSourceView::updateHighLight(bool)
71 {
72  clearSelections();
73 }
74 
75 void FindBarSourceView::updateSensitivity(bool)
76 {
77  QTextDocument::FindFlags searchOptions = 0;
78  if ( mCaseSensitiveAct->isChecked() )
79  searchOptions |= QTextDocument::FindCaseSensitively;
80  mLastSearchStr = mSearch->text();
81  const bool found = mView->find( mLastSearchStr, searchOptions );
82  setFoundMatch( found );
83 }
84 
85 
86 #include "findbarsourceview.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::FindBarSourceView::~FindBarSourceView
~FindBarSourceView()
Definition: findbarsourceview.cpp:32
MessageViewer::FindBarBase::messageInfo
void messageInfo(bool backward, bool isAutoSearch, bool found)
Definition: findbarbase.cpp:143
findbarsourceview.h
MessageViewer::FindBarSourceView::FindBarSourceView
FindBarSourceView(QPlainTextEdit *view, QWidget *parent=0)
Definition: findbarsourceview.cpp:27
QPlainTextEdit
MessageViewer::FindBarBase::mCaseSensitiveAct
QAction * mCaseSensitiveAct
Definition: findbarbase.h:71
MessageViewer::FindBarBase::mSearch
KLineEdit * mSearch
Definition: findbarbase.h:70
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