Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

categoryfilterimpl.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the OPIE Project
00003                              
00004                =.            Copyright (c)  2002 Andy Qua <andy.qua@blueyonder.co.uk>
00005              .=l.                                Dan Williams <drw@handhelds.org>
00006            .>+-=
00007  _;:,     .>    :=|.         This file is free software; you can
00008 .> <`_,   >  .   <=          redistribute it and/or modify it under
00009 :`=1 )Y*s>-.--   :           the terms of the GNU General Public
00010 .="- .-=="i,     .._         License as published by the Free Software
00011  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00012      ._= =}       :          or (at your option) any later version.
00013     .%`+i>       _;_.
00014     .i_,=:_.      -<s.       This file is distributed in the hope that
00015      +  .  -:.       =       it will be useful, but WITHOUT ANY WARRANTY;
00016     : ..    .:,     . . .    without even the implied warranty of
00017     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00018   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU General
00019 ..}^=.=       =       ;      Public License for more details.
00020 ++=   -.     .`     .:
00021  :     =  ...= . :.=-        You should have received a copy of the GNU
00022  -.   .:....=;==+<;          General Public License along with this file;
00023   -_. . .   )=.  =           see the file COPYING. If not, write to the
00024     --        :-=`           Free Software Foundation, Inc.,
00025                              59 Temple Place - Suite 330,
00026                              Boston, MA 02111-1307, USA.
00027 
00028 */
00029 
00030 #include "categoryfilterimpl.h"
00031 
00032 /* OPIE */
00033 #include <qpe/qpeapplication.h>
00034 
00035 /* QT */
00036 #include <qgroupbox.h>
00037 #include <qlayout.h>
00038 #include <qlistbox.h>
00039 #include <qstring.h>
00040 
00041 
00042 CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name )
00043         : QDialog( parent, name, true )
00044 {
00045     setCaption( tr( "Category Filter" ) );
00046 
00047     QVBoxLayout *layout = new QVBoxLayout( this );
00048     layout->setMargin( 2 );
00049     layout->setSpacing( 4 );
00050 
00051     QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this );
00052     grpbox->layout()->setSpacing( 2 );
00053     grpbox->layout()->setMargin( 4 );
00054     layout->addWidget( grpbox );
00055 
00056     QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
00057 
00058     lstCategories = new QListBox( grpbox );
00059     lstCategories->setSelectionMode( QListBox::Multi );
00060     grplayout->addWidget( lstCategories );
00061 
00062     // Split up categories and add them to the listbox
00063     int start = 1;
00064 
00065     QString item;
00066     int end;
00067     QString finditem;
00068     do
00069     {
00070         end = categories.find( "#", start );
00071         item = categories.mid( start, end - start );
00072         if ( item != "" )
00073         {
00074             lstCategories->insertItem( item );
00075             finditem = QString( "#%1#" ).arg( item );
00076             if ( selectedCategories.find( finditem ) != -1 )
00077                 lstCategories->setSelected( lstCategories->count()-1, true );
00078         }
00079 
00080         start = end + 1;
00081     }
00082     while ( start < (int)categories.length() );
00083 
00084     lstCategories->sort( true );
00085 
00086     QPEApplication::showDialog( this );
00087 }
00088 
00089 CategoryFilterImpl :: ~CategoryFilterImpl()
00090 {}
00091 
00092 QString CategoryFilterImpl :: getSelectedFilter()
00093 {
00094     // Grab cetegories from listbox
00095     QString ret = "#";
00096 
00097     for ( int i = 0 ; i < (int)lstCategories->count() ; ++i )
00098     {
00099         if ( lstCategories->isSelected( i ) )
00100         {
00101             ret.append( lstCategories->text( i ) );
00102             ret.append( "#" );
00103         }
00104     }
00105 
00106     if ( ret == "#" )
00107         ret = "";
00108     return ret;
00109 }

Generated on Sat Nov 5 16:17:46 2005 for OPIE by  doxygen 1.4.2