~moshe-wagner/orayta/Orayta-QT

« back to all changes in this revision

Viewing changes to searchform.cpp

  • Committer: moshe.wagner
  • Date: 2012-05-05 21:48:52 UTC
  • Revision ID: git-v1:70e09345355d8f7ecaf4ec2176a47d02dea9bcb7
Making the android branch into the main one

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This program is free software; you can redistribute it and/or modify
 
2
* it under the terms of the GNU General Public License version 2
 
3
* as published by the Free Software Foundation.
 
4
*
 
5
* This program is distributed in the hope that it will be useful,
 
6
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
7
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
8
* GNU General Public License for more details.
 
9
*
 
10
* You should have received a copy of the GNU General Public License
 
11
* along with this program; if not, write to the Free Software
 
12
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
13
*
 
14
* Author: Moshe Wagner. <moshe.wagner@gmail.com>
 
15
*/
 
16
 
 
17
#include "searchform.h"
 
18
 
 
19
SearchForm::SearchForm(QWidget *parent) : QDialog(parent), m_ui(new Ui::SearchForm)
 
20
{
 
21
    m_ui->setupUi(this);
 
22
 
 
23
    if (LANG == "Hebrew") toRTL();
 
24
 
 
25
    m_ui->lineEdit->setFocus();
 
26
 
 
27
}
 
28
 
 
29
void SearchForm::toRTL()
 
30
{
 
31
    this->setLayoutDirection(Qt::RightToLeft);
 
32
}
 
33
 
 
34
SearchForm::~SearchForm()
 
35
{
 
36
    delete m_ui;
 
37
}
 
38
 
 
39
void SearchForm::on_submit_clicked()
 
40
{
 
41
    QString otxt = m_ui->lineEdit->text();
 
42
    QString stxt = m_ui->lineEdit->text();
 
43
 
 
44
    if (m_ui->regexpCheckBox->isChecked())
 
45
    {
 
46
        emit Search(QRegExp(stxt), tr("RegExp: ") + otxt);
 
47
    }
 
48
    else
 
49
    {
 
50
        if ( m_ui->radioButton->isChecked() )
 
51
        {
 
52
            if ( m_ui->fullCheckBox->isChecked()) stxt = "[ :.,-]" + stxt + "[ :.,-]";
 
53
 
 
54
            QString pat = "";
 
55
 
 
56
            QStringList words = stxt.split(" ");
 
57
            for (int i=0; i<words.size(); i++)
 
58
            {
 
59
                if (words[i] != "") pat += allowNikudAndTeamim(words[i]);
 
60
                if ( i != words.size()-1 ) pat+= "|";
 
61
            }
 
62
            //print (pat);
 
63
 
 
64
            emit Search(QRegExp(pat), otxt);
 
65
        }
 
66
        else
 
67
        {
 
68
            stxt = allowNikudAndTeamim(stxt);
 
69
            if ( m_ui->fullCheckBox->isChecked()) stxt = "[ :.,-]" + stxt + "[ :.,-]";
 
70
 
 
71
            emit Search(QRegExp(stxt), otxt);
 
72
        }
 
73
    }
 
74
    close();
 
75
}
 
76
 
 
77
void SearchForm::on_cancel_clicked()
 
78
{
 
79
    close();
 
80
}
 
81
 
 
82
 
 
83
void SearchForm::on_regexpCheckBox_clicked(bool checked)
 
84
{
 
85
    m_ui->groupBox->setEnabled(!checked);
 
86
}