1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Moshe Wagner. <moshe.wagner@gmail.com>
*/
#include "bookfind.h"
#include "ui_bookfind.h"
#include "functions.h"
#ifndef MOBILE
#include "desktopapp.h"
#endif
bookfind::bookfind(QWidget *parent, BookList& booklist) : QDialog(parent), m_ui(new Ui::bookfind), mBookList(booklist)
{
m_ui->setupUi(this);
if (LANG == "Hebrew") toRTL();
}
void bookfind::toRTL()
{
this->setLayoutDirection(Qt::RightToLeft);
}
bookfind::~bookfind()
{
delete m_ui;
}
void bookfind::on_lineEdit_textEdited(QString text)
{
reBuildList(text);
}
void bookfind::reBuildList(QString text)
{
m_ui->listWidget->clear();
if ( text != "")
{
QListWidgetItem *item = NULL;
for (unsigned int i=0; i<mBookList.size(); i++)
{
if (!mBookList[i]->IsDir())
{
QString bookname = mBookList[i]->getNormallDisplayName();
//Mixed display book
if ( !mBookList[i]->ShowAlone() ) bookname = bookname + " [תצוגה משולבת]";
if ( m_ui->radioButton->isChecked())
{
if ( bookname.indexOf(text) != -1)
{
item = new QListWidgetItem();
item->setText(bookname);
m_ui->listWidget->addItem(item);
item->setData(Qt::UserRole, mBookList[i]->getUniqueId());
}
}
else
{
if (bookname.startsWith(text))
{
item = new QListWidgetItem();
item->setText( bookname );
m_ui->listWidget->addItem(item);
item->setData(Qt::UserRole, mBookList[i]->getUniqueId());
}
}
}
}
}
}
void bookfind::on_radioButton_2_toggled(bool checked)
{
reBuildList( m_ui->lineEdit->text() );
}
void bookfind::on_pushButton_2_clicked()
{
close();
}
void bookfind::on_pushButton_clicked()
{
QListWidgetItem *item = m_ui->listWidget->currentItem();
if ( item )
{
int bookid = item->data(Qt::UserRole).toInt();
emit openBook(bookid);
close();
}
}
void bookfind::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
{
int bookid = item->data(Qt::UserRole).toInt();
emit openBook( bookid );
}
|