1 /***************************************************************************
2 * Copyright (C) 2005 by Tarek Saidi *
3 * mail@tarek-saidi.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
22 #include "dialogs/SearchDlg.h"
25 SearchDialog::SearchDialog(IDatabase* database,IGroupHandle* Group,QWidget* parent):QDialog(parent)
28 QPushButton* Button_Search = ButtonBox->addButton(tr("Search"),QDialogButtonBox::ActionRole);
29 connect( Button_Search, SIGNAL( clicked() ), this, SLOT( OnSearch() ) );
30 connect( ButtonBox, SIGNAL( rejected() ), this, SLOT( OnClose() ) );
33 QBitArray searchOptions=config->searchOptions();
34 checkBox_Cs->setChecked(searchOptions.at(0));
35 checkBox_regExp->setChecked(searchOptions.at(1));
36 checkBox_Title->setChecked(searchOptions.at(2));
37 checkBox_Username->setChecked(searchOptions.at(3));
38 checkBox_Password->setChecked(searchOptions.at(4));
39 checkBox_Comment->setChecked(searchOptions.at(5));
40 checkBox_URL->setChecked(searchOptions.at(6));
41 checkBox_Attachment->setChecked(searchOptions.at(7));
43 checkBox_Recursive->setChecked(searchOptions.at(8));
45 checkBox_Recursive->setChecked(false);
46 checkBox_Recursive->setEnabled(false);
49 setMaximumSize(size());
50 setMinimumSize(size());
51 createBanner(&BannerPixmap,getPixmap("search"),tr("Search"),width());
54 SearchDialog::~SearchDialog()
56 QBitArray searchOptions(9);
57 searchOptions.setBit(0,checkBox_Cs->isChecked());
58 searchOptions.setBit(1,checkBox_regExp->isChecked());
59 searchOptions.setBit(2,checkBox_Title->isChecked());
60 searchOptions.setBit(3,checkBox_Username->isChecked());
61 searchOptions.setBit(4,checkBox_Password->isChecked());
62 searchOptions.setBit(5,checkBox_Comment->isChecked());
63 searchOptions.setBit(6,checkBox_URL->isChecked());
64 searchOptions.setBit(7,checkBox_Attachment->isChecked());
65 if(group) searchOptions.setBit(8,checkBox_Recursive->isChecked());
66 config->setSearchOptions(searchOptions);
69 void SearchDialog::OnClose()
74 void SearchDialog::OnSearch()
77 Fields[0]=checkBox_Title->isChecked();
78 Fields[1]=checkBox_Username->isChecked();
79 Fields[2]=checkBox_URL->isChecked();
80 Fields[3]=checkBox_Password->isChecked();
81 Fields[4]=checkBox_Comment->isChecked();
82 Fields[5]=checkBox_Attachment->isChecked();
83 Result=db->search(group,Edit_Search->text(),checkBox_Cs->isChecked(),checkBox_regExp->isChecked(),checkBox_Recursive->isChecked(),Fields);
87 void SearchDialog::paintEvent(QPaintEvent *event){
88 QDialog::paintEvent(event);
89 QPainter painter(this);
90 painter.setClipRegion(event->region());
91 painter.drawPixmap(QPoint(0,0),BannerPixmap);