/***************************************************************************
 *   Copyright (C) 2005 by xavier helluy   *
 *   xavier.helluy@web.de   *
 *                                                                         *
 *   This program 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.                                   *
 *                                                                         *
 *   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.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/

#ifndef CLUCENEGUISEARCHHELPER_H
#define CLUCENEGUISEARCHHELPER_H

#include "queryfield.h"
#include <qptrlist.h> 
#include <kdialogbase.h>
#include <qscrollview.h>


//manages the query-fields widgets
//FIXME: the dialog still does not resize nicely
// calculatesize adapted from kpovmodeler : PMDialogEditContent
class CLuceneGuiSearchHelper: public QScrollView
{
	Q_OBJECT
	public:
		CLuceneGuiSearchHelper( QWidget* parent, const char* name = 0 );
		
		//contains a list of all query-fields widgets
		QPtrList<QueryField> m_queryFieldList;
		
		//those should help for the drawing of the widgets		
		int m_minimumWidth;
		int m_minimumHeight;
		int m_contentWidth;
		int m_contentHeight;
		int m_convenienceWidth;
		int m_convenienceHeight;
		void getMinWidthAndMinHeight();
		
		//layout A contains layout B and a stretcher
		QVBoxLayout * layoutA;
		//layout B contains the scollview containing all the widgets
		QVBoxLayout * layoutB;
		QWidget * a;
		void resizeEvent( QResizeEvent* );
		
	public slots:

		void slotRemoveQueryField(int itemNum);
		void slotAddQueryFieldBelow();
		void slotAddQueryField(QString pluginName);
		void calculateSize( );

	signals:
		void sizeChanged(int);//emitted when a field is added or removed

	protected:
//  		void resizeEvent( QResizeEvent* );
	private:
		QWidget* m_pContents;
		bool m_initGUI;
		bool m_booleanSearchOn;
};

#endif
