summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/ktoolbar.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/ktoolbar.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdeui/ktoolbar.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 09ad0c8..35d4916 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -497,769 +497,769 @@ KAnimWidget *KToolBar::animatedWidget( int id )
void KToolBar::addConnection (int id, const char *signal,
const QObject *receiver, const char *slot)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
if ( (*it) )
connect( (*it), signal, receiver, slot );
}
void KToolBar::setItemEnabled( int id, bool enabled )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
if ( (*it) )
(*it)->setEnabled( enabled );
}
void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setPixmap( _pixmap );
}
void KToolBar::setButtonIcon( int id, const QString& _icon )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setIcon( _icon );
}
void KToolBar::setButtonIconSet( int id, const QIconSet& iconset )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setIconSet( iconset );
}
void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setDelayedPopup( _popup, toggle );
}
void KToolBar::setAutoRepeat (int id, bool flag)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setAutoRepeat( flag );
}
void KToolBar::setToggle (int id, bool flag )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setToggle( flag );
}
void KToolBar::toggleButton (int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->toggle();
}
void KToolBar::setButton (int id, bool flag)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->on( flag );
}
bool KToolBar::isButtonOn (int id) const
{
Id2WidgetMap::ConstIterator it = id2widget.find( id );
if ( it == id2widget.end() )
return false;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
return button ? button->isOn() : false;
}
void KToolBar::setLinedText (int id, const QString& text)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
QLineEdit * lineEdit = (QLineEdit *)( *it );
if ( lineEdit )
lineEdit->setText( text );
}
QString KToolBar::getLinedText (int id) const
{
Id2WidgetMap::ConstIterator it = id2widget.find( id );
if ( it == id2widget.end() )
return QString::null;
//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
QLineEdit * lineEdit = (QLineEdit *)( *it );
return lineEdit ? lineEdit->text() : QString::null;
}
void KToolBar::insertComboItem (int id, const QString& text, int index)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
QComboBox * comboBox = (QComboBox *)( *it );
if (comboBox)
comboBox->insertItem( text, index );
}
void KToolBar::insertComboList (int id, const QStringList &list, int index)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
QComboBox * comboBox = (QComboBox *)( *it );
if (comboBox)
comboBox->insertStringList( list, index );
}
void KToolBar::removeComboItem (int id, int index)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
QComboBox * comboBox = (QComboBox *)( *it );
if (comboBox)
comboBox->removeItem( index );
}
void KToolBar::setCurrentComboItem (int id, int index)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
QComboBox * comboBox = (QComboBox *)( *it );
if (comboBox)
comboBox->setCurrentItem( index );
}
void KToolBar::changeComboItem (int id, const QString& text, int index)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
QComboBox * comboBox = (QComboBox *)( *it );
if (comboBox)
comboBox->changeItem( text, index );
}
void KToolBar::clearCombo (int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
QComboBox * comboBox = (QComboBox *)( *it );
if (comboBox)
comboBox->clear();
}
QString KToolBar::getComboItem (int id, int index) const
{
Id2WidgetMap::ConstIterator it = id2widget.find( id );
if ( it == id2widget.end() )
return QString::null;
//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
QComboBox * comboBox = (QComboBox *)( *it );
return comboBox ? comboBox->text( index ) : QString::null;
}
KComboBox * KToolBar::getCombo(int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return 0;
//US return dynamic_cast<KComboBox *>( *it );
return (KComboBox *)( *it );
}
KLineEdit * KToolBar::getLined (int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return 0;
//US return dynamic_cast<KLineEdit *>( *it );
return (KLineEdit *)( *it );
}
KToolBarButton * KToolBar::getButton (int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return 0;
//US return dynamic_cast<KToolBarButton *>( *it );
return (KToolBarButton *)( *it );
}
void KToolBar::alignItemRight (int id, bool right )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
if ( rightAligned && !right && (*it) == rightAligned )
rightAligned = 0;
if ( (*it) && right )
rightAligned = (*it);
}
QWidget *KToolBar::getWidget (int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
return ( it == id2widget.end() ) ? 0 : (*it);
}
void KToolBar::setItemAutoSized (int id, bool yes )
{
QWidget *w = getWidget(id);
if ( w && yes )
setStretchableWidget( w );
}
void KToolBar::clear ()
{
QToolBar::clear();
widget2id.clear();
id2widget.clear();
}
void KToolBar::removeItem(int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
{
kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
return;
}
QWidget * w = (*it);
id2widget.remove( id );
widget2id.remove( w );
widgets.removeRef( w );
delete w;
}
void KToolBar::removeItemDelayed(int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
{
kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
return;
}
QWidget * w = (*it);
id2widget.remove( id );
widget2id.remove( w );
widgets.removeRef( w );
w->blockSignals(true);
d->idleButtons.append(w);
layoutTimer->start( 50, TRUE );
}
void KToolBar::hideItem (int id)
{
QWidget *w = getWidget(id);
if ( w )
w->hide();
}
void KToolBar::showItem (int id)
{
QWidget *w = getWidget(id);
if ( w )
w->show();
}
int KToolBar::itemIndex (int id)
{
QWidget *w = getWidget(id);
return w ? widgets.findRef(w) : -1;
}
void KToolBar::setFullSize(bool flag )
{
setHorizontalStretchable( flag );
setVerticalStretchable( flag );
}
bool KToolBar::fullSize() const
{
return isHorizontalStretchable() || isVerticalStretchable();
}
void KToolBar::enableMoving(bool flag )
{
//US setMovingEnabled(flag);
this->mainWindow()->setToolBarsMovable(flag);
}
void KToolBar::setBarPos (BarPosition bpos)
{
if ( !mainWindow() )
return;
//US mainWindow()->moveDockWindow( this, (Dock)bpos );
mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos );
}
-KToolBar::BarPosition KToolBar::barPos() const
+const KToolBar::BarPosition KToolBar::barPos()
{
if ( !(QMainWindow*)mainWindow() )
return KToolBar::Top;
//US Dock dock;
QMainWindow::ToolBarDock dock;
int dm1, dm2;
bool dm3;
((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 );
//US if ( dock == DockUnmanaged ) {
if ( dock == QMainWindow::Unmanaged ) {
return (KToolBar::BarPosition)Top;
}
return (BarPosition)dock;
}
bool KToolBar::enable(BarStatus stat)
{
bool mystat = isVisible();
if ( (stat == Toggle && mystat) || stat == Hide )
hide();
else
show();
return isVisible() == mystat;
}
void KToolBar::setMaxHeight ( int h )
{
setMaximumHeight( h );
}
int KToolBar::maxHeight()
{
return maximumHeight();
}
void KToolBar::setMaxWidth (int dw)
{
setMaximumWidth( dw );
}
int KToolBar::maxWidth()
{
return maximumWidth();
}
void KToolBar::setTitle (const QString& _title)
{
setLabel( _title );
}
void KToolBar::enableFloating (bool )
{
}
void KToolBar::setIconText(IconText it)
{
setIconText( it, true );
}
void KToolBar::setIconText(IconText icontext, bool update)
{
bool doUpdate=false;
if (icontext != d->m_iconText) {
d->m_iconText = icontext;
doUpdate=true;
}
if (update == false)
return;
if (doUpdate)
emit modechange(); // tell buttons what happened
// ugly hack to force a QMainWindow::triggerLayout( TRUE )
if ( mainWindow() ) {
QMainWindow *mw = mainWindow();
mw->setUpdatesEnabled( FALSE );
mw->setToolBarsMovable( !mw->toolBarsMovable() );
mw->setToolBarsMovable( !mw->toolBarsMovable() );
mw->setUpdatesEnabled( TRUE );
}
}
KToolBar::IconText KToolBar::iconText() const
{
return d->m_iconText;
}
void KToolBar::setIconSize(int size)
{
setIconSize( size, true );
}
void KToolBar::setIconSize(int size, bool update)
{
bool doUpdate=false;
if ( size != d->m_iconSize ) {
d->m_iconSize = size;
doUpdate=true;
}
if (update == false)
return;
if (doUpdate)
emit modechange(); // tell buttons what happened
// ugly hack to force a QMainWindow::triggerLayout( TRUE )
if ( mainWindow() ) {
QMainWindow *mw = mainWindow();
mw->setUpdatesEnabled( FALSE );
mw->setToolBarsMovable( !mw->toolBarsMovable() );
mw->setToolBarsMovable( !mw->toolBarsMovable() );
mw->setUpdatesEnabled( TRUE );
}
}
int KToolBar::iconSize() const
{
/*US
if ( !d->m_iconSize ) // default value?
{
if (!::qstrcmp(QObject::name(), "mainToolBar"))
return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
else
return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
}
return d->m_iconSize;
*/
int ret = 18;
if ( QApplication::desktop()->width() > 320 )
ret = 30;
return ret;
}
void KToolBar::setEnableContextMenu(bool enable )
{
d->m_enableContext = enable;
}
bool KToolBar::contextMenuEnabled() const
{
return d->m_enableContext;
}
void KToolBar::setItemNoStyle(int id, bool no_style )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if (button)
button->setNoStyle( no_style );
}
void KToolBar::setFlat (bool flag)
{
if ( !mainWindow() )
return;
if ( flag )
//US mainWindow()->moveDockWindow( this, DockMinimized );
mainWindow()->moveToolBar( this, QMainWindow::Minimized );
else
//US mainWindow()->moveDockWindow( this, DockTop );
mainWindow()->moveToolBar( this, QMainWindow::Top );
// And remember to save the new look later
/*US
if ( mainWindow()->inherits( "KMainWindow" ) )
static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
*/
}
int KToolBar::count() const
{
return id2widget.count();
}
void KToolBar::saveState()
{
/*US
// first, try to save to the xml file
if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
// go down one level to get to the right tags
QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
elem = elem.firstChild().toElement();
QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
QDomElement current;
// now try to find our toolbar
d->modified = false;
for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
current = elem;
if ( current.tagName().lower() != "toolbar" )
continue;
QString curname(current.attribute( "name" ));
if ( curname == barname ) {
saveState( current );
break;
}
}
// if we didn't make changes, then just return
if ( !d->modified )
return;
// now we load in the (non-merged) local file
QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
QDomDocument local;
local.setContent(local_xml);
// make sure we don't append if this toolbar already exists locally
bool just_append = true;
elem = local.documentElement().toElement();
KXMLGUIFactory::removeDOMComments( elem );
elem = elem.firstChild().toElement();
for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
if ( elem.tagName().lower() != "toolbar" )
continue;
QString curname(elem.attribute( "name" ));
if ( curname == barname ) {
just_append = false;
local.documentElement().replaceChild( current, elem );
break;
}
}
if (just_append)
local.documentElement().appendChild( current );
KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
return;
}
*/
// if that didn't work, we save to the config file
KConfig *config = KGlobal::config();
saveSettings(config, QString::null);
config->sync();
}
QString KToolBar::settingsGroup()
{
QString configGroup;
if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
configGroup = "Toolbar style";
else
configGroup = QString(name()) + " Toolbar style";
if ( this->mainWindow() )
{
configGroup.prepend(" ");
configGroup.prepend( this->mainWindow()->name() );
}
return configGroup;
}
void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
{
QString configGroup = _configGroup;
if (configGroup.isEmpty())
configGroup = settingsGroup();
//kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
QString position, icontext;
int index;
getAttributes( position, icontext, index );
//kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
KConfigGroupSaver saver(config, configGroup);
if ( position != d->PositionDefault )
config->writeEntry("Position", position);
else
config->deleteEntry("Position");
if ( icontext != d->IconTextDefault )
config->writeEntry("IconText", icontext);
else
config->deleteEntry("IconText");
if ( iconSize() != d->IconSizeDefault )
config->writeEntry("IconSize", iconSize());
else
config->deleteEntry("IconSize");
if ( isHidden() != d->HiddenDefault )
config->writeEntry("Hidden", isHidden());
else
config->deleteEntry("Hidden");
if ( index != d->IndexDefault )
config->writeEntry( "Index", index );
else
config->deleteEntry("Index");
//US the older version of KDE (used on the Zaurus) has no Offset property
/* if ( offset() != d->OffsetDefault )
config->writeEntry( "Offset", offset() );
else
*/
config->deleteEntry("Offset");
//US the older version of KDE (used on the Zaurus) has no NewLine property
/*
if ( newLine() != d->NewLineDefault )
config->writeEntry( "NewLine", newLine() );
else
*/
config->deleteEntry("NewLine");
}
void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
{
d->m_xmlguiClient = client;
}
void KToolBar::setText( const QString & txt )
{
//US setLabel( txt + " ( " + kapp->caption() + " ) " );
setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
}
QString KToolBar::text() const
{
return label();
}
void KToolBar::doConnections( KToolBarButton *button )
{
connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
}
void KToolBar::mousePressEvent ( QMouseEvent *m )
{
if ( !mainWindow() )
return;
QMainWindow *mw = mainWindow();
if ( mw->toolBarsMovable() && d->m_enableContext ) {
if ( m->button() == RightButton ) {
int i = contextMenu()->exec( m->globalPos(), 0 );
switch ( i ) {
case -1:
return; // popup cancelled
case CONTEXT_LEFT:
//US mw->moveDockWindow( this, DockLeft );
mw->moveToolBar( this, QMainWindow::Left );
break;
case CONTEXT_RIGHT:
//US mw->moveDockWindow( this, DockRight );
mw->moveToolBar( this, QMainWindow::Right );
break;
case CONTEXT_TOP:
//US mw->moveDockWindow( this, DockTop );