You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.4 KiB
C++
96 lines
2.4 KiB
C++
/* This file is part of the KDE project
|
|
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
|
|
|
|
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, version 2.
|
|
|
|
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; see the file COPYING. If not, write to
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include "collectioncombo.h"
|
|
|
|
#include <kdatastream.h>
|
|
|
|
using namespace KMrml;
|
|
|
|
CollectionCombo::CollectionCombo( TQWidget *parent, const char *name )
|
|
: KComboBox( false, parent, name ),
|
|
m_collections( 0L )
|
|
{
|
|
connect( this, TQT_SIGNAL( activated( const TQString& ) ),
|
|
TQT_SLOT( slotActivated( const TQString& ) ));
|
|
}
|
|
|
|
CollectionCombo::~CollectionCombo()
|
|
{
|
|
}
|
|
|
|
void CollectionCombo::setCollections( const CollectionList *collections )
|
|
{
|
|
assert( collections != 0L );
|
|
|
|
clear();
|
|
m_collections = collections;
|
|
insertStringList( collections->itemNames() );
|
|
// #### block signals here?
|
|
}
|
|
|
|
void CollectionCombo::setCurrent( const Collection& coll )
|
|
{
|
|
setCurrentItem( coll.name() );
|
|
}
|
|
|
|
Collection CollectionCombo::current() const
|
|
{
|
|
return m_collections->findByName( currentText() );
|
|
}
|
|
|
|
void CollectionCombo::slotActivated( const TQString& name )
|
|
{
|
|
Collection coll = m_collections->findByName( name );
|
|
emit selected( coll );
|
|
}
|
|
|
|
TQDataStream& KMrml::operator<<( TQDataStream& stream,
|
|
const CollectionCombo& combo )
|
|
{
|
|
int count = combo.count();
|
|
stream << count;
|
|
for ( int i = 0; i < count; i++ )
|
|
stream << combo.text( i );
|
|
|
|
stream << combo.currentItem();
|
|
return stream;
|
|
}
|
|
|
|
TQDataStream& KMrml::operator>>( TQDataStream& stream, CollectionCombo& combo )
|
|
{
|
|
combo.clear();
|
|
|
|
int count;
|
|
stream >> count;
|
|
TQString text;
|
|
for ( int i = 0; i < count; i++ )
|
|
{
|
|
stream >> text;
|
|
combo.insertItem( text );
|
|
}
|
|
|
|
int current;
|
|
stream >> current;
|
|
combo.setCurrentItem( current );
|
|
|
|
return stream;
|
|
}
|
|
|
|
#include "collectioncombo.moc"
|