21 #include "statusbarextension.h"
23 #include <tqvaluelist.h>
24 #include <tqobjectlist.h>
26 #include <kstatusbar.h>
27 #include <tdemainwindow.h>
29 #include <tdelibs_export.h>
30 #include <tdeparts/part.h>
31 #include <tdeparts/event.h>
33 using namespace KParts;
39 class KParts::StatusBarItem {
42 : m_widget(0), m_visible(false)
44 StatusBarItem( TQWidget * widget,
int stretch,
bool permanent )
45 : m_widget(widget), m_stretch(stretch), m_permanent(permanent), m_visible(false)
48 TQWidget * widget()
const {
return m_widget; }
54 sb->addWidget( m_widget, m_stretch, m_permanent );
63 sb->removeWidget( m_widget );
79 : TQObject(parent,
name), m_statusBar(0), d(0)
81 parent->installEventFilter(
this);
84 StatusBarExtension::~StatusBarExtension()
91 if ( !obj || obj->childrenListObject().isEmpty() )
96 const TQObjectList children = obj->childrenListObject();
97 TQObjectListIt it( children );
98 for (; it.current(); ++it )
99 if ( it.current()->inherits(
"KParts::StatusBarExtension" ) )
105 bool StatusBarExtension::eventFilter(TQObject * watched, TQEvent* ev)
107 if ( !GUIActivateEvent::test( ev ) ||
108 !watched->inherits(
"KParts::ReadOnlyPart") )
109 return TQObject::eventFilter(watched, ev);
113 return TQObject::eventFilter(watched, ev);
117 if ( gae->activated() )
119 TQValueListIterator<StatusBarItem> it = m_statusBarItems.begin();
120 for ( ; it != m_statusBarItems.end() ; ++it )
121 (*it).ensureItemShown( sb );
125 TQValueListIterator<StatusBarItem> it = m_statusBarItems.begin();
126 for ( ; it != m_statusBarItems.end() ; ++it )
127 (*it).ensureItemHidden( sb );
136 if ( !m_statusBar ) {
147 m_statusBar = status;
152 m_statusBarItems.append( StatusBarItem( widget, stretch, permanent ) );
153 TQValueListIterator<StatusBarItem> it = m_statusBarItems.fromLast();
157 (*it).ensureItemShown( sb );
163 TQValueListIterator<StatusBarItem> it = m_statusBarItems.begin();
164 for ( ; it != m_statusBarItems.end() ; ++it )
165 if ( (*it).widget() == widget )
168 (*it).ensureItemHidden( sb );
169 m_statusBarItems.remove( it );
172 if ( it == m_statusBarItems.end() )
173 kdWarning(1000) <<
"StatusBarExtension::removeStatusBarItem. Widget not found : " << widget <<
endl;
176 #include "statusbarextension.moc"
This event is sent to a Part when its GUI has been activated or deactivated.
Base class for any "viewer" part.
An extension for KParts that allows more sophisticated statusbar handling.
void addStatusBarItem(TQWidget *widget, int stretch, bool permanent)
This adds a widget to the statusbar for this part.
KStatusBar * statusBar() const
void setStatusBar(KStatusBar *status)
This allows the hosting application to set a particular KStatusBar for this part.
void removeStatusBarItem(TQWidget *widget)
Remove a widget from the statusbar for this part.
static StatusBarExtension * childObject(TQObject *obj)
Queries obj for a child object which inherits from this BrowserExtension class.
kndbgstream & endl(kndbgstream &s)
kdbgstream kdWarning(int area=0)
TQString name(StdAccel id)