/* Copyright 2003 Rikard Björklind, Mikael Gransell This file is part of dc-qt. dc-qt is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. dc-qt 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 dc-qt; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "searchwdgt.h" #include #include #include #include #include #include #include #include #include SearchWdgt::SearchWdgt(QWidget *parent, const char *name) : QWidget(parent,name) { QGroupBox *gbox = new QGroupBox(2,Qt::Vertical,"Search options",this,"searchgroupbox"); QGridLayout *gl = new QGridLayout(this, 1,1); QHBox *s = new QHBox(gbox); new QLabel("Search:",s); searchEdit = new QLineEdit(s); searchEdit->setFocus(); sbtn = new QPushButton("&Search",s); msbtn = new QPushButton("&Multihub",s); sbtn->setDefault(true); connect(searchEdit,SIGNAL(returnPressed()), this, SLOT(commit())); connect(sbtn,SIGNAL(pressed()), this, SLOT(commit())); connect(msbtn,SIGNAL(pressed()), this, SLOT(mcommit())); QHBox *t = new QHBox(gbox); new QLabel("Type:",t); lbox = new QComboBox(t); lbox->insertItem("Any"); lbox->insertItem("Audio"); lbox->insertItem("Compressed"); lbox->insertItem("Documents"); lbox->insertItem("Executables"); lbox->insertItem("Pictures"); lbox->insertItem("Videos"); lbox->insertItem("Folders"); new QLabel("Size",t); sbox = new QComboBox(t); sbox->insertItem("At least"); sbox->insertItem("At most"); spin = new QSpinBox(t); spin->setMaxValue(100000); ubox = new QComboBox(t); ubox->insertItem("kb"); ubox->insertItem("mb"); // gl->addWidget(s,0,0); // gl->addWidget(t,1,0); gl->addWidget(gbox,0,0); } void SearchWdgt::commit() { QString c; if(sbox->currentItem()==0) c = "L"; else c = "M"; int m = 1024; if(ubox->currentItem()==1) m*=1024; int cp = (lbox->currentItem()+1); const QString s = "*" + searchEdit->text() + "*" + QString::number(cp) + "*" + c + "*" + QString::number(spin->value()*m); emit newSearch(s,false); } void SearchWdgt::mcommit() { QString c; if(sbox->currentItem()==0) c = "L"; else c = "M"; int m = 1024; if(ubox->currentItem()==1) m*=1024; int cp = (lbox->currentItem()+1); const QString s = "*" + searchEdit->text() + "*" + QString::number(cp) + "*" + c + "*" + QString::number(spin->value()*m); emit newSearch(s,true); }