KDevelop API Documentation

closer_dialogimpl.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Jens Dagerbo                                    *
00003  *   jens.dagerbo@swipnet.se                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include <qstringlist.h>
00013 #include <qlistview.h>
00014 #include <qheader.h>
00015 #include <qcheckbox.h>
00016 
00017 #include <kdebug.h>
00018 
00019 #include "closer_dialogimpl.h"
00020 
00021 
00022 class CheckURL : public QCheckListItem
00023 {
00024 public:
00025     CheckURL( QListView * lv, KURL const & url )
00026         : QCheckListItem( lv, url.fileName(), QCheckListItem::CheckBox),
00027         _url( url )
00028     {}
00029 
00030     KURL const & url() const { return _url; }
00031 
00032     void showPath( bool showPaths )
00033     {
00034         if ( showPaths )
00035         {
00036             setText( 0, _url.path() );
00037         }
00038         else
00039         {
00040             setText( 0, _url.fileName() );
00041         }
00042     }
00043 
00044 private:
00045     KURL _url;
00046 };
00047 
00048 
00049 CloserDialogImpl::CloserDialogImpl( KURL::List const & fileList )
00050     : CloserDialog( 0, 0, false, 0 )
00051 {
00052     files_listview->addColumn( "" );
00053     files_listview->header()->hide();
00054 
00055     KURL::List::ConstIterator it = fileList.begin();
00056     while ( it != fileList.end() )
00057     {
00058         QCheckListItem * x = new CheckURL( files_listview, *it );
00059         x->setOn( true );
00060         ++it;
00061     }
00062 
00063     connect( this->path_check, SIGNAL( toggled( bool ) ), this, SLOT( togglePaths( bool ) ) );
00064 }
00065 
00066 CloserDialogImpl::~CloserDialogImpl()
00067 {
00068 }
00069 
00070 void CloserDialogImpl::togglePaths( bool showPaths )
00071 {
00072     QListViewItemIterator it( files_listview );
00073     while ( it.current() )
00074     {
00075         CheckURL * item = static_cast<CheckURL*>( it.current() );
00076         item->showPath( showPaths );
00077         ++it;
00078     }
00079 }
00080 
00081 KURL::List CloserDialogImpl::getCheckedFiles()
00082 {
00083     KURL::List checkedFiles;
00084 
00085     CheckURL const * item = static_cast<CheckURL*>( files_listview->firstChild() );
00086     while ( item )
00087     {
00088         if ( item->isOn() )
00089         {
00090             checkedFiles << item->url();
00091         }
00092         item = static_cast<CheckURL*>( item->nextSibling() );
00093     }
00094     return checkedFiles;
00095 }
00096 
00097 #include "closer_dialogimpl.moc"
00098 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:38 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003