source: branches/4.5.1/src/scripttools/debugging/qscriptdebuggercodefinderwidget.cpp@ 559

Last change on this file since 559 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 8.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtSCriptTools module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qscriptdebuggercodefinderwidget_p.h"
43#include "qscriptdebuggercodefinderwidgetinterface_p_p.h"
44
45#include <QtGui/qboxlayout.h>
46#include <QtGui/qlineedit.h>
47#include <QtGui/qcheckbox.h>
48#include <QtGui/qlabel.h>
49#include <QtGui/qtoolbutton.h>
50#include <QtGui/qevent.h>
51#include <QtCore/qdebug.h>
52
53QT_BEGIN_NAMESPACE
54
55class QScriptDebuggerCodeFinderWidgetPrivate
56 : public QScriptDebuggerCodeFinderWidgetInterfacePrivate
57{
58 Q_DECLARE_PUBLIC(QScriptDebuggerCodeFinderWidget)
59public:
60 QScriptDebuggerCodeFinderWidgetPrivate();
61 ~QScriptDebuggerCodeFinderWidgetPrivate();
62
63 // private slots
64 void _q_updateButtons();
65 void _q_onTextChanged(const QString &);
66 void _q_next();
67 void _q_previous();
68
69 int findOptions() const;
70
71 QLineEdit *editFind;
72 QCheckBox *checkCase;
73 QLabel *labelWrapped;
74 QToolButton *toolNext;
75 QToolButton *toolClose;
76 QToolButton *toolPrevious;
77 QCheckBox *checkWholeWords;
78};
79
80QScriptDebuggerCodeFinderWidgetPrivate::QScriptDebuggerCodeFinderWidgetPrivate()
81{
82}
83
84QScriptDebuggerCodeFinderWidgetPrivate::~QScriptDebuggerCodeFinderWidgetPrivate()
85{
86}
87
88void QScriptDebuggerCodeFinderWidgetPrivate::_q_updateButtons()
89{
90 if (editFind->text().isEmpty()) {
91 toolPrevious->setEnabled(false);
92 toolNext->setEnabled(false);
93 } else {
94 toolPrevious->setEnabled(true);
95 toolNext->setEnabled(true);
96 }
97}
98
99int QScriptDebuggerCodeFinderWidgetPrivate::findOptions() const
100{
101 int flags = 0;
102 if (checkCase->isChecked())
103 flags |= QTextDocument::FindCaseSensitively;
104 if (checkWholeWords->isChecked())
105 flags |= QTextDocument::FindWholeWords;
106 return flags;
107}
108
109void QScriptDebuggerCodeFinderWidgetPrivate::_q_onTextChanged(const QString &text)
110{
111 emit q_func()->findRequest(text, findOptions() | 0x100);
112}
113
114void QScriptDebuggerCodeFinderWidgetPrivate::_q_next()
115{