You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.0 KiB
156 lines
5.0 KiB
/***************************************************************************
|
|
kxearchiveextssettings.cpp
|
|
--------------------
|
|
begin : Tue Dec 02 2003
|
|
copyright : (C) 2003 by The KXMLEditor Team
|
|
email : hartig@users.sourceforge.net
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* 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. *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
#include "kxearchiveextssettings.h"
|
|
#include "kxearchiveextssettingspage.h"
|
|
|
|
#include <klocale.h>
|
|
#include <kconfig.h>
|
|
|
|
#include <qframe.h>
|
|
#include <qlistbox.h>
|
|
#include <qlineedit.h>
|
|
#include <qpushbutton.h>
|
|
|
|
#define CONF_ENTRY_NAME_EXTS_TARGZ "Extensions"
|
|
|
|
KXEArchiveExtsSettings::KXEArchiveExtsSettings( QObject * pParent, const char * pszName )
|
|
: KXESettings( "TarGz Extensions", pParent, pszName ),
|
|
m_pDialogPage(0)
|
|
{
|
|
}
|
|
|
|
|
|
void KXEArchiveExtsSettings::write( KConfig * pConfig ) const
|
|
{
|
|
pConfig->writeEntry( CONF_ENTRY_NAME_EXTS_TARGZ, m_lstExtensions );
|
|
}
|
|
|
|
|
|
void KXEArchiveExtsSettings::read( const KConfig * pConfig )
|
|
{
|
|
m_lstExtensions = pConfig->readListEntry( CONF_ENTRY_NAME_EXTS_TARGZ );
|
|
}
|
|
|
|
QString KXEArchiveExtsSettings::dialogPageName() const
|
|
{
|
|
return i18n( "Archive Extensions" );
|
|
}
|
|
|
|
QString KXEArchiveExtsSettings::dialogPageHeader() const
|
|
{
|
|
return i18n( "Specify Archive Extensions" );
|
|
}
|
|
|
|
QString KXEArchiveExtsSettings::dialogPageIcon() const
|
|
{
|
|
return "filetypes";
|
|
}
|
|
|
|
QWidget * KXEArchiveExtsSettings::dialogPage( QFrame * pParent )
|
|
{
|
|
if ( ! m_pDialogPage )
|
|
{
|
|
// create the page if necessary
|
|
m_pDialogPage = new KXEArchiveExtsSettingsPage( pParent, "archive extensions config.dialog page" );
|
|
|
|
// and fill its widgets with the corresponding values
|
|
updatePage();
|
|
|
|
connect( m_pDialogPage->m_pExtensions, SIGNAL(highlighted(const QString&)), this, SLOT(slotPageEditExtension(const QString&)) );
|
|
connect( m_pDialogPage->m_pBtnNew, SIGNAL(clicked()), this, SLOT(slotPageAddExtension()) );
|
|
connect( m_pDialogPage->m_pBtnDelete, SIGNAL(clicked()), this, SLOT(slotPageDeleteExtension()) );
|
|
connect( m_pDialogPage->m_pExtension, SIGNAL(textChanged(const QString&)), this, SLOT(slotPageUpdateExtension(const QString&)) );
|
|
|
|
connect( m_pDialogPage->m_pBtnNew, SIGNAL(clicked()), this, SIGNAL(sigDialogPageChanged()) );
|
|
connect( m_pDialogPage->m_pBtnDelete, SIGNAL(clicked()), this, SIGNAL(sigDialogPageChanged()) );
|
|
}
|
|
|
|
return m_pDialogPage;
|
|
}
|
|
|
|
|
|
void KXEArchiveExtsSettings::setFromPage()
|
|
{
|
|
if ( m_pDialogPage )
|
|
{
|
|
m_lstExtensions.clear();
|
|
QListBoxItem * pTmpItem = m_pDialogPage->m_pExtensions->firstItem();
|
|
while ( pTmpItem )
|
|
{
|
|
m_lstExtensions << pTmpItem->text();
|
|
pTmpItem = pTmpItem->next();
|
|
}
|
|
}
|
|
}
|
|
|
|
void KXEArchiveExtsSettings::updatePage() const
|
|
{
|
|
if ( m_pDialogPage )
|
|
{
|
|
m_pDialogPage->m_pExtensions->clear();
|
|
m_pDialogPage->m_pExtensions->insertStringList( m_lstExtensions );
|
|
m_pDialogPage->m_pExtension->setDisabled( true );
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// additional slots for the corresponding configuration dialog page //
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
void KXEArchiveExtsSettings::slotPageEditExtension( const QString & strText )
|
|
{
|
|
m_pDialogPage->m_pExtension->setText( strText );
|
|
m_pDialogPage->m_pExtension->setEnabled( true );
|
|
m_pDialogPage->m_pExtension->setFocus();
|
|
}
|
|
|
|
void KXEArchiveExtsSettings::slotPageAddExtension()
|
|
{
|
|
m_pDialogPage->m_pExtensions->insertItem( "zip", 0 );
|
|
m_pDialogPage->m_pExtensions->setCurrentItem( 0 );
|
|
m_pDialogPage->m_pExtension->selectAll();
|
|
m_pDialogPage->m_pExtension->setFocus();
|
|
m_pDialogPage->m_pExtension->setEnabled( true );
|
|
}
|
|
|
|
void KXEArchiveExtsSettings::slotPageDeleteExtension()
|
|
{
|
|
m_pDialogPage->m_pExtensions->removeItem( m_pDialogPage->m_pExtensions->currentItem() );
|
|
|
|
if ( m_pDialogPage->m_pExtensions->count() == 0 )
|
|
{
|
|
m_pDialogPage->m_pExtension->clear();
|
|
m_pDialogPage->m_pExtension->setDisabled( true );
|
|
}
|
|
else
|
|
m_pDialogPage->m_pExtensions->setSelected( m_pDialogPage->m_pExtensions->currentItem(), true );
|
|
}
|
|
|
|
void KXEArchiveExtsSettings::slotPageUpdateExtension( const QString & strText )
|
|
{
|
|
if ( ( m_pDialogPage->m_pExtensions->count() > 0 ) &&
|
|
( m_pDialogPage->m_pExtensions->currentText() != m_pDialogPage->m_pExtension->text() ) )
|
|
{
|
|
m_pDialogPage->m_pExtensions->changeItem( strText, m_pDialogPage->m_pExtensions->currentItem() );
|
|
emit sigDialogPageChanged();
|
|
}
|
|
}
|
|
|
|
#include "kxearchiveextssettings.moc"
|