SVN_SILENT made messages (.desktop file)
[kdeadmin.git] / kpackage / search.cpp
blob61e2a9cb8e57078b957c1b5e66dc1199ba9a8be4
1 /*
2 ** Copyright (C) 1999,2000 Toivo Pedaste <toivo@ucs.uwa.edu.au>
3 **
4 */
6 /*
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program in a file called COPYING; if not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 ** MA 02110-1301, USA.
24 ** Bug reports and questions can be sent to kde-devel@kde.org
27 #include "search.h"
29 #include "kpackage.h"
30 #include "managementWidget.h"
31 #include <klocale.h>
32 #include <QtGui/QLineEdit>
33 #include <QtGui/QCheckBox>
34 #include <QtGui/QFrame>
35 #include <Qt3Support/Q3GroupBox>
36 //Added by qt3to4:
37 #include <QtGui/QVBoxLayout>
38 #include <QtGui/QHBoxLayout>
40 Search::Search(QWidget *parent, const char *)
41 : KDialog(parent)
43 setCaption( i18n("Find Package") );
44 setButtons( User1 | Close );
45 setDefaultButton( User1 );
46 setButtonGuiItem( User1, KGuiItem( i18n("&Find"), "edit-find") );
47 QFrame *page = new QFrame( this );
48 setMainWidget( page );
50 setFocusPolicy(Qt::StrongFocus);
52 QVBoxLayout* vtop = new QVBoxLayout( page, 10, 10, "vtop");
54 Q3GroupBox *frame1 = new Q3GroupBox(i18n("Find Package"), page, "frame1");
55 vtop->addWidget(frame1,1);
56 QVBoxLayout* vf = new QVBoxLayout( frame1, 20, 10, "vf");
58 value = new QLineEdit( frame1, "v");
59 vf->addWidget(value,0);
60 value->setFocus();
61 value->setFixedHeight(value->sizeHint().height());
62 value->setMinimumWidth(250);
63 connect(value, SIGNAL(textChanged(const QString &)),this, SLOT(textChanged(const QString &)));
65 QHBoxLayout* hc = new QHBoxLayout( );
66 vf->addLayout(hc,0);
68 substr = new QCheckBox(i18n("Sub string"), frame1, "substr");
69 substr->setChecked(true);
70 hc->addWidget(substr,1,Qt::AlignLeft);
71 substr->setFixedSize(substr->sizeHint());
72 hc->addStretch(1);
74 wrap = new QCheckBox(i18n("Wrap search"), frame1, "wrap");
75 wrap->setChecked(true);
76 hc->addWidget(wrap,1,Qt::AlignRight);
77 wrap->setFixedSize(wrap->sizeHint());
79 enableButton( User1, false );
81 connect(this, SIGNAL(user1Clicked()), this, SLOT(ok_slot()));
82 connect(this, SIGNAL(closeClicked()), this, SLOT(done_slot()));
84 show();
87 Search::~Search()
91 void Search::textChanged(const QString &text)
93 enableButton( User1, !text.isEmpty() );
96 void Search::ok_slot()
98 Q3ListViewItem *pkg;
100 QString to_find = value->text();
101 to_find = to_find.trimmed();
103 pkg = kpackage->management->search(to_find,
104 substr->isChecked(),false,false);
105 if (pkg == 0 && wrap->isChecked()) {
106 pkg = kpackage->management->search(to_find,
107 substr->isChecked(),true,false);
109 if (pkg == 0)
110 KpMsg(i18n("Note"),
111 i18n("%1 was not found.", to_find),true);
114 void Search::done_slot()
116 hide();
119 #include "search.moc"