author | ar <ar> | 2004-06-02 22:20:53 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-02 22:20:53 (UTC) |
commit | 9135254f2b593741cf7b0ffd80bb8bb63986333d (patch) (side-by-side diff) | |
tree | 98248548d823b97970b2240695c958b7ce440a9d /libopie2/opieui | |
parent | 8fe425e226eefcd652c4cb875d68fbd886d4c42c (diff) | |
download | opie-9135254f2b593741cf7b0ffd80bb8bb63986333d.zip opie-9135254f2b593741cf7b0ffd80bb8bb63986333d.tar.gz opie-9135254f2b593741cf7b0ffd80bb8bb63986333d.tar.bz2 |
- convert to odebug framework
-rw-r--r-- | libopie2/opieui/big-screen/osplitter.cpp | 25 | ||||
-rw-r--r-- | libopie2/opieui/big-screen/owidgetstack.cpp | 5 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 5 | ||||
-rw-r--r-- | libopie2/opieui/olistview.cpp | 16 | ||||
-rw-r--r-- | libopie2/opieui/opopupmenu.cpp | 30 | ||||
-rw-r--r-- | libopie2/opieui/otaskbarapplet.h | 10 |
6 files changed, 50 insertions, 41 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp index f0287ed..f50e7f0 100644 --- a/libopie2/opieui/big-screen/osplitter.cpp +++ b/libopie2/opieui/big-screen/osplitter.cpp @@ -1,639 +1,640 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "osplitter.h" /* OPIE */ #include <opie2/otabwidget.h> +#include <opie2/odebug.h> /* QT */ #include <qvaluelist.h> #include <qvbox.h> using namespace Opie::Ui; using namespace Opie::Ui::Internal; /** * * This is the constructor of OSplitter * You might want to call setSizeChange to tell * OSplitter to change its layout when a specefic * mark was crossed. OSplitter sets a default value. * * You cann add widget with addWidget to the OSplitter. * OSplitter supports also grouping of Splitters where they * can share one OTabBar in small screen mode. This can be used * for email clients like vies but see the example. * * @param orient The orientation wether to layout horizontal or vertical * @param parent The parent of this widget * @param name The name passed on to QObject * @param fl Additional widgets flags passed to QWidget * * @short single c'tor of the OSplitter */ OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) : QFrame( parent, name, fl ) { m_orient = orient; m_hbox = 0; m_size_policy = 330; setFontPropagation( AllChildren ); setPalettePropagation( AllChildren ); /* start by default with the tab widget */ m_tabWidget = 0; m_parentTab = 0; changeTab(); } /** * Destructor destructs this object and cleans up. All child * widgets will be deleted * @see addWidget */ OSplitter::~OSplitter() { - qWarning("Deleted Splitter"); + owarn << "Deleted Splitter" << oendl; m_splitter.setAutoDelete( true ); m_splitter.clear(); delete m_hbox; delete m_tabWidget; } /** * Sets the label for the Splitter. This label will be used * if a parent splitter is arranged as TabWidget but * this splitter is in fullscreen mode. Then a tab with OSplitter::label() * and iconName() gets added. * * @param name The name of the Label */ void OSplitter::setLabel( const QString& name ) { m_name = name; } /** * @see setLabel but this is for the icon retrieved by Resource * * @param name The name of the icon in example ( "zoom" ) */ void OSplitter::setIconName( const QString& name ) { m_icon = name; } /** * returns the iconName * @see setIconName */ QString OSplitter::iconName()const { return m_icon; } /** * returns the label set with setLabel * @see setLabel */ QString OSplitter::label()const { return m_name; } /** * This function sets the size change policy of the splitter. * If this size marked is crossed the splitter will relayout. * Note: that depending on the set Orientation it'll either look * at the width or height. * Note: If you want to from side to side view to tabbed view you need * to make sure that the size you supply is not smaller than the minimum * size of your added widgets. Note that if you use widgets like QComboBoxes * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy * * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. * @return void */ void OSplitter::setSizeChange( int width_height ) { m_size_policy = width_height; QSize sz(width(), height() ); QResizeEvent ev(sz, sz ); resizeEvent(&ev); } /** * This functions allows to add another OSplitter and to share * the OTabBar in small screen mode. The ownerships gets transfered. * OSplitters are always added after normal widget items */ void OSplitter::addWidget( OSplitter* split ) { m_splitter.append( split ); /* * set tab widget */ if (m_tabWidget ) setTabWidget( m_parentTab ); else { OSplitterContainer con; con.widget =split; addToBox( con ); } } /* * If in a tab it should be removed * and if in a hbox the reparent kills it too */ /** * This removes the splitter again. You currently need to call this * before you delete or otherwise you can get mem corruption * or other weird behaviour. * Owner ship gets transfered back to you it's current parent * is 0 */ void OSplitter::removeWidget( OSplitter* split) { split->setTabWidget( 0 ); split->reparent( 0, 0, QPoint(0, 0) ); } /** * Adds a widget to the Splitter. The widgets gets inserted * at the end of either the Box or TabWidget. * Ownership gets transfered and the widgets gets reparented. * Note: icon and label is only available on small screensizes * if size is smaller than the mark * Warning: No null checking of the widget is done. Only on debug * a message will be outputtet * * @param wid The widget which will be added * @param icon The icon of the possible Tab * @param label The label of the possible Tab */ void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) { #ifdef DEBUG if (!wid ) { - qWarning("Widget is not valid!"); + owarn << "Widget is not valid!" << oendl; return; } #endif OSplitterContainer cont; cont.widget = wid; cont.icon =icon; cont.name = label; m_container.append( cont ); /* * */ if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) setTabWidget( m_parentTab ); else { if (m_hbox ) addToBox( cont ); else addToTab( cont ); } } /** * Removes the widget from the tab widgets if necessary. * OSplitter drops ownership of this widget and the widget * will be reparented i tto 0. * The widget will not be deleted. * * @param w The widget to be removed */ void OSplitter::removeWidget( QWidget* w) { ContainerList::Iterator it; for ( it = m_container.begin(); it != m_container.end(); ++it ) if ( (*it).widget == w ) break; if (it == m_container.end() ) return; /* only tab needs to be removed.. box recognizes it */ if ( !m_hbox ) removeFromTab( w ); /* Find reparent it and remove it from our list */ w->reparent( 0, 0, QPoint(0, 0)); it = m_container.remove( it ); } /** * This method will give focus to the widget. If in a tabwidget * the tabbar will be changed * * @param w The widget which will be set the current one */ void OSplitter::setCurrentWidget( QWidget* w) { if (m_tabWidget ) m_tabWidget->setCurrentTab( w ); // else // m_hbox->setFocus( w ); } /** * This is an overloaded member function and only differs in the * argument it takes. * Searches list of widgets for label. It'll pick the first label it finds * * @param label Label to look for. First match will be taken */ void OSplitter::setCurrentWidget( const QString& label ) { ContainerList::Iterator it; for (it = m_container.begin(); it != m_container.end(); ++it ) { if ( (*it).name == label ) { setCurrentWidget( (*it).widget ); break; } } } /** * This will only work when the TabWidget is active * If everything is visible this signal is kindly ignored * @see OTabWidget::setCurrentTab(int) * * @param tab The tab to make current */ void OSplitter::setCurrentWidget( int tab ) { if (m_tabWidget ) m_tabWidget->setCurrentTab( tab ); } /** * return the currently activated widget if in tab widget mode * or null because all widgets are visible */ QWidget* OSplitter::currentWidget() const { if (m_tabWidget) return m_tabWidget->currentWidget(); else if (m_parentTab ) return m_parentTab->currentWidget(); return 0l; } /* wrong */ #if 0 /** * @reimplented for internal reasons * returns the sizeHint of one of its sub widgets */ QSize OSplitter::sizeHint()const { if (m_parentTab ) return QFrame::sizeHint(); if (m_hbox ) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } QSize OSplitter::minimumSizeHint()const { if (m_parentTab ) return QFrame::minimumSizeHint(); if (m_hbox) return m_hbox->sizeHint(); else return m_tabWidget->sizeHint(); } #endif /** * @reimplemented for internal reasons */ void OSplitter::resizeEvent( QResizeEvent* res ) { QFrame::resizeEvent( res ); /* * */ - // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); + // owarn << "Old size was width = " << res->oldSize().width() << " height = " << res->oldSize().height() << "" << oendl; bool mode = true; - qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); + owarn << "New size is width = " << res->size().width() << " height = " << res->size().height() << " " << name() << "" << oendl; if ( res->size().width() > m_size_policy && m_orient == Horizontal ) { changeHBox(); mode = false; } else if ( (res->size().width() <= m_size_policy && m_orient == Horizontal ) || (res->size().height() <= m_size_policy && m_orient == Vertical ) ) { changeTab(); } else if ( res->size().height() > m_size_policy && m_orient == Vertical ) { - qWarning("Changng to vbox %s", name() ); + owarn << "Changng to vbox " << name() << "" << oendl; changeVBox(); mode = false; } emit sizeChanged(mode, m_orient ); } /* * Adds a container to a tab either the parent tab * or our own */ void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con ) { QWidget *wid = con.widget; // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); if (m_parentTab ) m_parentTab->addTab( wid, con.icon, con.name ); else m_tabWidget->addTab( wid, con.icon, con.name ); } /* * adds a container to the box */ void OSplitter::addToBox( const Opie::Ui::Internal::OSplitterContainer& con ) { QWidget* wid = con.widget; wid->reparent(m_hbox, 0, QPoint(0, 0) ); } /* * Removes a widget from the tab */ void OSplitter::removeFromTab( QWidget* wid ) { if (m_parentTab ) m_parentTab->removePage( wid ); else m_tabWidget->removePage( wid ); } /* * switches over to a OTabWidget layout * it is recursive */ void OSplitter::changeTab() { /* if we're the owner of the tab widget */ if (m_tabWidget ) { raise(); show(); m_tabWidget->setGeometry( frameRect() ); return; } - qWarning(" New Tab Widget %s", name() ); + owarn << " New Tab Widget " << name() << "" << oendl; /* * and add all widgets this will reparent them * delete m_hbox set it to 0 * */ OTabWidget *tab; if ( m_parentTab ) { hide(); tab = m_parentTab; /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ if (!m_container.isEmpty() ) { ContainerList::Iterator it = m_container.begin(); for (; it != m_container.end(); ++it ) m_parentTab->removePage( (*it).widget ); } } else tab = m_tabWidget = new OTabWidget( this ); connect(tab, SIGNAL(currentChanged(QWidget*) ), this, SIGNAL(currentChanged(QWidget*) ) ); for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { - qWarning("Widget is %s", (*it).name.latin1() ); + owarn << "Widget is " << (*it).name << "" << oendl; addToTab( (*it) ); } for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { split->reparent(this, 0, QPoint(0, 0) ); split->setTabWidget( tab ); } delete m_hbox; m_hbox = 0; if (!m_tabWidget ) return; m_tabWidget->setGeometry( frameRect() ); m_tabWidget->show(); } /* * changes over to a box * this is recursive as well */ void OSplitter::changeHBox() { if (m_hbox ) { m_hbox->setGeometry( frameRect() ); return; } - qWarning("new HBox %s", name() ); + owarn << "new HBox " << name() << "" << oendl; m_hbox = new QHBox( this ); commonChangeBox(); } void OSplitter::changeVBox() { if (m_hbox ) { m_hbox->setGeometry( frameRect() ); return; } - qWarning("New VBOX %s", name() ); + owarn << "New VBOX " << name() << "" << oendl; m_hbox = new QVBox( this ); commonChangeBox(); } /* * common box code * first remove and add children * the other splitters * it is recursive as well due the call to setTabWidget */ void OSplitter::commonChangeBox() { - qWarning(" Name of Splitters is %s", name() ); + owarn << " Name of Splitters is " << name() << "" << oendl; for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) { /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ if (m_parentTab ) removeFromTab( (*it).widget ); - qWarning("Adding to box %s", (*it).name.latin1() ); + owarn << "Adding to box " << (*it).name << "" << oendl; addToBox( (*it) ); } for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) { /* tell them the world had changed */ split->setTabWidget( 0 ); OSplitterContainer con; con.widget = split; // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) // : static_cast<QWidget*>(split->m_hbox); addToBox( con ); } if (m_parentTab ) m_parentTab->addTab(m_hbox, iconName(), label() ); else { - qWarning(" setting Box geometry for %s", name() ); + owarn << " setting Box geometry for " << name() << "" << oendl; m_hbox->setGeometry( frameRect() ); m_hbox->show(); delete m_tabWidget; m_tabWidget = 0; show(); // also show this widget } } /* * sets the tabwidget, removes tabs, and relayouts the widget */ void OSplitter::setTabWidget( OTabWidget* wid) { /* clean up cause m_parentTab will not be available for us */ if ( m_parentTab ) { if (m_hbox ) m_parentTab->removePage( m_hbox ); else if (!m_container.isEmpty() ) { ContainerList::Iterator it = m_container.begin(); for ( ; it != m_container.end(); ++it ) m_parentTab->removePage( (*it).widget ); } } /* the parent Splitter changed so either make us indepent or dep */ m_parentTab = wid; QWidget *tab = m_tabWidget; QWidget *box = m_hbox; m_hbox = 0; m_tabWidget = 0; if ( layoutMode() ) changeTab(); else if (m_orient == Horizontal ) changeHBox(); else changeVBox(); /* our own crap is added and children from change* */ delete tab; delete box; } #if 0 void OSplitter::reparentAll() { if (m_container.isEmpty() ) return; ContainerList::Iterator it = m_container.begin(); for ( ; it != m_container.end(); ++it ) (*it).wid->reparent(0, 0, QPoint(0, 0) ); } #endif /** * @internal */ bool OSplitter::layoutMode()const { if ( size().width() > m_size_policy && m_orient == Horizontal ) { return false; } else if ( size().height() > m_size_policy && m_orient == Vertical ) { return false; } return true; } diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp index a0a6355..de7f83f 100644 --- a/libopie2/opieui/big-screen/owidgetstack.cpp +++ b/libopie2/opieui/big-screen/owidgetstack.cpp @@ -1,126 +1,129 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "owidgetstack.h" +/* OPIE */ +#include <opie2/odebug.h> + /* QT */ #include <qapplication.h> #include <qwidgetstack.h> namespace Opie { namespace Ui { const int mode_size = 330; /** * This is the standard widget. For simple usage see the example. Normally this widget * is the central widget of a QMainWindow. * Use removeWidget before you delete a widget yourself. OWidgetStack does not * yet recognize removal of children. * * @param parent The parent widget. It maybe 0 but then you need to take care of deletion. * Or you use QPEApplication::showMainWidget(). * @param name Name will be passed on to QObject * @param fl Additional window flags passed to QFrame. see @Qt::WFlags */ OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl) : QFrame( parent, name, fl ) { m_last = m_mWidget = 0; m_forced = false; QApplication::desktop()->installEventFilter( this ); setFontPropagation ( AllChildren ); setPalettePropagation( AllChildren ); /* sets m_mode and initializes more */ /* if you change this call change switchTop as well */ m_stack = 0; switchStack(); } /** * The destructor. It deletes also all added widgets. * */ OWidgetStack::~OWidgetStack() { if (m_mode == BigScreen && !m_list.isEmpty() ) { QMap<int, QWidget*>::Iterator it = m_list.begin(); for ( ; it != m_list.end(); ++it ) delete it.data(); } m_list.clear(); } /** * return the mode of the desktop. There are currently two modes. SmallScreen * with a normal PDA resolution and BigScreen with resolutions greater than * 330 for width and height. * You can also force the mode this widget is in with forceMode() * Note that NoForce will be never returned from here */ enum OWidgetStack::Mode OWidgetStack::mode()const { return m_mode; } /** * You can also force one of the modes and then * this widget stops on listening to size changes. You * can revert to the scanning behaviour by setting mode * to NoForce */ void OWidgetStack::forceMode( enum Mode mode) { m_forced = mode != NoForce; /* we need to see which mode we're in */ if (!m_forced ) { if ( QApplication::desktop()->width() >= mode_size ) mode = BigScreen; else mode = SmallScreen; } switch( mode ) { case NoForce: case SmallScreen: switchStack(); break; case BigScreen: switchTop(); break; } m_mode = mode; } /** * Adds a widget to the stack. The first widget added is considered * to be the mainwindow. This is important because if Opie is in @@ -214,193 +217,193 @@ QSizeHint OWidgetStack::minimumSizeHint()const { QWidget* OWidgetStack::widget( int id) const { return m_list[id]; } /** * Tries to find the assigned id for the widget * or returns -1 if no widget could be found * @param wid The widget to look for */ int OWidgetStack::id( QWidget* wid)const{ if (m_list.isEmpty() ) return -1; QMap<int, QWidget*>::ConstIterator it = m_list.begin(); for ( ; it != m_list.end(); ++it ) if ( it.data() == wid ) break; /* if not at the end return the key */ return it == m_list.end() ? -1 : it.key(); } /** * This function returns the currently visible * widget. In BigScreen mode the mainwindow * is returned */ QWidget* OWidgetStack::visibleWidget()const { if (m_mode == SmallScreen ) return m_stack->visibleWidget(); else return m_mWidget; } /** * This method raises the widget wit the specefic id. * Note that in BigScreen mode the widget is made visible * but the other ( previous) visible widget(s) will not * be made invisible. If you need this use hideWidget(). * * @param id Raise the widget with id */ void OWidgetStack::raiseWidget( int id) { return raiseWidget( widget( id ) ); } /** * This is an overloaded function and only differs in its parameters. * @see raiseWidget( int ) */ void OWidgetStack::raiseWidget( QWidget* wid) { m_last = wid; if (m_mode == SmallScreen ) m_stack->raiseWidget( wid ); else { int ide; emit aboutToShow( wid ); /* if someone is connected and the widget is actually available */ if ( receivers( SIGNAL(aboutToShow(int) ) ) && ( (ide = id( wid ) ) != -1 ) ) emit aboutToShow( ide ); /* ### FIXME PLACE THE WIDGET right */ wid->show(); } } /** * This will hide the currently visible widget * and raise the widget specified by the parameter. * Note that this method does not use visibleWIdget but remembers * the last raisedWidget */ void OWidgetStack::hideWidget( int id) { /* hiding our main widget wouldn't be smart */ if ( m_mode == BigScreen && m_last != m_mWidget ) m_last->hide(); raiseWidget( id ); } /** * This is overloaded and only differs in the parameters * it takes. */ void OWidgetStack::hideWidget( QWidget* wid) { /* still not smart */ if ( m_mode == BigScreen && m_last != m_mWidget ) m_last->hide(); raiseWidget( wid ); } bool OWidgetStack::eventFilter( QObject* obj, QEvent* e) { - qWarning(" %s %s", obj->name(), obj->className() ); + owarn << " " << obj->name() << " " << obj->className() << "" << oendl; if ( e->type() == QEvent::Resize ) { QResizeEvent *res = static_cast<QResizeEvent*>( e ); QSize size = res->size(); if ( size.width() >= mode_size ) switchTop(); else switchStack(); } return false; } /** * @internal_resons */ void OWidgetStack::resizeEvent( QResizeEvent* ev ) { QFrame::resizeEvent( ev ); if (m_mode == SmallScreen ) m_stack->setGeometry( frameRect() ); else if (m_mWidget ) m_mWidget->setGeometry( frameRect() ); } /** * setMainWindow gives the OWidgetStack a hint which * window should always stay inside the stack. * Normally the first added widget is considered to be * the mainwindow but you can change this with this * function. * If in BigScreen mode the current mainwindow will be reparented * and hidden. The position will be taken by the new one. * If the old MainWindow was hidden the new window will * also be hidden. If the window was visible the new mainwindow * will be made visible too and the old one hidden. If there * was no mainwindow it will be hidden as well. * * @param wid The new mainwindow */ void OWidgetStack::setMainWindow( QWidget* wid ) { if (m_mode == BigScreen ) { bool wasVisible = false; if (m_mWidget ) { wasVisible = !m_mWidget->isHidden(); /* hidden by default */ m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) ); } wid->reparent(this, 0, frameRect().topLeft() ); if (wasVisible) wid->show(); } m_mWidget = wid; } /** * this is an overloaded member and only differs * in the type of arguments. * @see setMainWindow(QWidget*) */ void OWidgetStack::setMainWindow( int id) { setMainWindow( widget( id ) ); } /* * this function switches to a stack ;) */ void OWidgetStack::switchStack() { if (m_stack ) { m_stack->setGeometry( frameRect() ); return; } m_mode = SmallScreen; m_stack = new QWidgetStack(this); connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), this, SIGNAL(aboutToShow(QWidget*) ) ); connect(m_stack, SIGNAL(aboutToShow(int) ), this, SIGNAL(aboutToShow(int) ) ); /* now reparent the widgets... luckily QWidgetSatck does most of the work */ if (m_list.isEmpty() ) return; QMap<int, QWidget*>::Iterator it = m_list.begin(); for ( ; it != m_list.end(); ++it ) m_stack->addWidget( it.data(), it.key() ); } /* diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index a9ec8c4..1f6ca05 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -1,134 +1,135 @@ /* =. This file is part of the OPIE Project .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* hacky but we need to get FileSelector::filter */ #define private public #include <qpe/fileselector.h> #undef private #include "ofileselector_p.h" /* OPIE */ #include <opie2/ofileselector.h> +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> #include <qpe/mimetype.h> #include <qpe/resource.h> #include <qpe/storage.h> /* QT */ #include <qcombobox.h> #include <qdir.h> #include <qhbox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qpopupmenu.h> #include <qwidgetstack.h> #include <qregexp.h> #include <qobjectlist.h> using namespace Opie::Ui::Internal; namespace Opie { namespace Ui { namespace Internal { OFileViewInterface::OFileViewInterface( OFileSelector* selector ) : m_selector( selector ) {} OFileViewInterface::~OFileViewInterface() {} QString OFileViewInterface::name()const { return m_name; } void OFileViewInterface::setName( const QString& name ) { m_name = name; } OFileSelector* OFileViewInterface::selector()const { return m_selector; } DocLnk OFileViewInterface::selectedDocument()const { return DocLnk( selectedName() ); } bool OFileViewInterface::showNew()const { return selector()->showNew(); } bool OFileViewInterface::showClose()const { return selector()->showClose(); } MimeTypes OFileViewInterface::mimeTypes()const { return selector()->mimeTypes(); } QStringList OFileViewInterface::currentMimeType()const { return selector()->currentMimeType(); } void OFileViewInterface::activate( const QString& ) { // not implemented here } void OFileViewInterface::ok() { emit selector()->ok(); } void OFileViewInterface::cancel() { emit selector()->cancel(); } void OFileViewInterface::closeMe() { emit selector()->closeMe(); } void OFileViewInterface::fileSelected( const QString& str) { emit selector()->fileSelected( str); } @@ -453,221 +454,221 @@ void OFileViewFileListView::reread( bool all ) * It is a symlink we try to resolve it now but don't let us attack by DOS * */ if( fi->isSymLink() ) { QString file = fi->dirPath( true ) + "/" + fi->readLink(); for( int i = 0; i<=4; i++) { // 5 tries to prevent dos QFileInfo info( file ); if( !info.exists() ) { addSymlink( fi, TRUE ); break; } else if( info.isDir() ) { addDir( fi, TRUE ); break; } else if( info.isFile() ) { addFile( fi, TRUE ); break; } else if( info.isSymLink() ) { file = info.dirPath(true ) + "/" + info.readLink() ; break; } else if( i == 4) { // couldn't resolve symlink add it as symlink addSymlink( fi ); } } // off for loop for symlink resolving } else if( fi->isDir() ) addDir( fi ); else if( fi->isFile() ) addFile( fi ); ++it; } // of while loop m_view->sort(); } int OFileViewFileListView::fileCount()const { return m_view->childCount(); } QString OFileViewFileListView::currentDir()const { return m_currentDir; } OFileSelector* OFileViewFileListView::selector() { return m_sel; } bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *k = (QKeyEvent *)e; if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); return true; } } return false; } void OFileViewFileListView::connectSlots() { connect(m_view, SIGNAL(clicked(QListViewItem*) ), this, SLOT(slotCurrentChanged(QListViewItem*) ) ); connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); } void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { if (!item) return; #if 0 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); if (!sel->isDir() ) { selector()->m_lneEdit->setText( sel->text(1) ); // if in fileselector mode we will emit selected if ( selector()->mode() == OFileSelector::FileSelector ) { - qWarning("slot Current Changed"); + owarn << "slot Current Changed" << oendl; QStringList str = QStringList::split("->", sel->text(1) ); QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); } } #endif } void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { if (!item || ( button != Qt::LeftButton) ) return; OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); if (!sel->isLocked() ) { QStringList str = QStringList::split("->", sel->text(1) ); if (sel->isDir() ) { m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } else { // file - qWarning("slot Clicked"); + owarn << "slot Clicked" << oendl; selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); emit selector()->fileSelected( path ); DocLnk lnk( path ); emit selector()->fileSelected( lnk ); } } // not locked } void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { MimeType type( info->absFilePath() ); if (!compliesMime( type.id() ) ) return; QPixmap pix = type.pixmap(); QString dir, name; bool locked; if ( pix.isNull() ) { QWMatrix matrix; QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); matrix.scale( .4, .4 ); pix = pixer.xForm( matrix ); } dir = info->dirPath( true ); locked = false; if ( symlink ) name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); else { name = info->fileName(); if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { locked = true; pix = Resource::loadPixmap("locked"); } } (void)new OFileSelectorItem( m_view, pix, name, info->lastModified().toString(), QString::number( info->size() ), dir, locked ); } void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { bool locked = false; QString name; QPixmap pix; if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { locked = true; if ( symlink ) pix = Resource::loadPixmap( "opie/symlink" ); else pix = Resource::loadPixmap( "lockedfolder" ); } else pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : info->fileName(); (void)new OFileSelectorItem( m_view, pix, name, info->lastModified().toString(), QString::number( info->size() ), info->dirPath( true ), locked, true ); } void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { } void OFileViewFileListView::cdUP() { QDir dir( m_currentDir ); dir.cdUp(); if (!dir.exists() ) m_currentDir = "/"; else m_currentDir = dir.absPath(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::cdHome() { m_currentDir = QDir::homeDirPath(); emit selector()->dirSelected( m_currentDir ); reread( m_all ); } void OFileViewFileListView::cdDoc() { diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index d7c92fd..0b3bdea 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp @@ -94,193 +94,193 @@ int OListView::addColumn( const QIconSet& iconset, const QString& label, int wid header()->setStretchEnabled( true, columns()-1 ); } #endif return result; } void OListView::removeColumn( int index ) { QListView::removeColumn(index); #if QT_VERSION > 290 if ( m_fullWidth && index == columns() ) { header()->setStretchEnabled( true, columns()-1 ); } #endif } const QColor& OListView::alternateBackground() const { return m_alternateBackground; } void OListView::setAlternateBackground( const QColor &c ) { m_alternateBackground = c; repaint(); } const QPen& OListView::columnSeparator() const { return m_columnSeparator; } void OListView::setColumnSeparator( const QPen& p ) { m_columnSeparator = p; repaint(); } void OListView::expand(QListViewItem *item) { ((OListViewItem*)item)->expand(); } OListViewItem* OListView::childFactory() { return new OListViewItem( this ); } #ifndef QT_NO_DATASTREAM void OListView::serializeTo( QDataStream& s ) const { #warning Caution... the binary format is still under construction... odebug << "storing OListView..." << oendl; // store number of columns and the labels s << columns(); for ( int i = 0; i < columns(); ++i ) s << columnText( i ); // calculate the number of top-level items to serialize int items = 0; QListViewItem* item = firstChild(); while ( item ) { item = item->nextSibling(); items++; } // store number of items and the items itself s << items; item = firstChild(); for ( int i = 0; i < items; ++i ) { s << *static_cast<OListViewItem*>( item ); item = item->nextSibling(); } odebug << "OListview stored." << oendl; } void OListView::serializeFrom( QDataStream& s ) { #warning Caution... the binary format is still under construction... odebug << "loading OListView..." << oendl; int cols; s >> cols; odebug << "read number of columns = " << cols << oendl; while ( columns() < cols ) addColumn( QString::null ); for ( int i = 0; i < cols; ++i ) { QString coltext; s >> coltext; - qDebug( "read text '%s' for column %d", (const char*) coltext, i ); + odebug << "read text '" << coltext << "' for column " << i << "" << oendl; setColumnText( i, coltext ); } int items; s >> items; odebug << "read number of items = " << items << oendl; for ( int i = 0; i < items; ++i ) { OListViewItem* item = childFactory(); s >> *item; } odebug << "OListView loaded." << oendl; } void OListView::expand() { odebug << "OListView::expand" << oendl; QListViewItemIterator it( this ); while ( it.current() ) { it.current()->setOpen( true ); ++it; } } void OListView::collapse() { odebug << "OListView::collapse" << oendl; QListViewItemIterator it( this ); while ( it.current() ) { it.current()->setOpen( false ); ++it; } } QDataStream& operator<<( QDataStream& s, const OListView& lv ) { lv.serializeTo( s ); } QDataStream& operator>>( QDataStream& s, OListView& lv ) { lv.serializeFrom( s ); } #endif // QT_NO_DATASTREAM /*====================================================================================== * OListViewItem *======================================================================================*/ OListViewItem::OListViewItem(QListView *parent) : QListViewItem(parent) { init(); } OListViewItem::OListViewItem(QListViewItem *parent) : QListViewItem(parent) { init(); } OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) : QListViewItem(parent, after) { init(); } OListViewItem::OListViewItem(QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) { init(); } OListViewItem::OListViewItem(QListViewItem *parent, QString label1, QString label2, QString label3, QString label4, QString label5, QString label6, QString label7, QString label8) @@ -349,416 +349,416 @@ bool OListViewItem::isAlternate() if (parent()) { item = static_cast<OListViewItem *>(parent()); if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; item = static_cast<OListViewItem *>(parent()->firstChild()); /* if ( !item.inherits( "OListViewItem" ) item = 0; */ } else { item = static_cast<OListViewItem *>(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; item = static_cast<OListViewItem *>(item->nextSibling()); /* if (!item.inherits( "OListViewItem" ) ) break; */ } } return m_odd; } void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); if (pm && !pm->isNull()) { _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); } else if ( isAlternate() ) { _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); } QListViewItem::paintCell( p, _cg, column, width, alignment ); //FIXME: Use styling here! const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); p->setPen( pen ); p->drawLine( width-1, 0, width-1, height() ); } OListViewItem* OListViewItem::childFactory() { return new OListViewItem( this ); } #ifndef QT_NO_DATASTREAM void OListViewItem::serializeTo( QDataStream& s ) const { #warning Caution... the binary format is still under construction... odebug << "storing OListViewItem..." << oendl; // store item text for ( int i = 0; i < listView()->columns(); ++i ) { s << text( i ); } // calculate the number of children to serialize int items = 0; QListViewItem* item = firstChild(); while ( item ) { item = item->nextSibling(); items++; } // store number of items and the items itself s << items; item = firstChild(); for ( int i = 0; i < items; ++i ) { s << *static_cast<OListViewItem*>( item ); item = item->nextSibling(); } odebug << "OListviewItem stored." << oendl; } void OListViewItem::serializeFrom( QDataStream& s ) { #warning Caution... the binary format is still under construction... odebug << "loading OListViewItem..." << oendl; for ( int i = 0; i < listView()->columns(); ++i ) { QString coltext; s >> coltext; - qDebug( "read text '%s' for column %d", (const char*) coltext, i ); + odebug << "read text '" << coltext << "' for column " << i << "" << oendl; setText( i, coltext ); } int items; s >> items; - qDebug( "read number of items = %d", items ); + odebug << "read number of items = " << items << "" << oendl; for ( int i = 0; i < items; ++i ) { OListViewItem* item = childFactory(); s >> (*item); } odebug << "OListViewItem loaded." << oendl; } QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) { lvi.serializeTo( s ); } QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) { lvi.serializeFrom( s ); } #endif // QT_NO_DATASTREAM /*====================================================================================== * OCheckListItem *======================================================================================*/ OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t ) :QCheckListItem( parent, text, t ) { init(); } OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t) :QCheckListItem( parent, text, t ) { init(); } OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t ) :QCheckListItem( parent, text, t ) { init(); } OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p ) :QCheckListItem( parent, text, p ) { init(); } OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p ) :QCheckListItem( parent, text, p ) { init(); } OCheckListItem::~OCheckListItem() { } void OCheckListItem::init() { m_known = false; } const QColor &OCheckListItem::backgroundColor() { return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : listView()->viewport()->colorGroup().base(); } bool OCheckListItem::isAlternate() { OListView *lv = static_cast<OListView*>( listView() ); // check if the item above is an OCheckListItem OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() ); /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/ // check if we have a valid alternate background color if (!(lv && lv->alternateBackground().isValid())) return false; m_known = above ? above->m_known : true; if (m_known) { m_odd = above ? !above->m_odd : false; } else { OCheckListItem *item; bool previous = true; if (parent()) { item = static_cast<OCheckListItem *>(parent()); if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd; item = static_cast<OCheckListItem *>(parent()->firstChild()); /* if ( !item.inherits( "OCheckListItem" ) item = 0; */ } else { item = static_cast<OCheckListItem *>(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; item = static_cast<OCheckListItem *>(item->nextSibling()); /* if (!item.inherits( "OCheckListItem" ) ) break; */ } } return m_odd; } void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); if (pm && !pm->isNull()) { _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); } else if ( isAlternate() ) { _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); } QCheckListItem::paintCell( p, _cg, column, width, alignment ); //FIXME: Use styling here! const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); p->setPen( pen ); p->drawLine( width-1, 0, width-1, height() ); } /*====================================================================================== * ONamedListView *======================================================================================*/ ONamedListView::ONamedListView( QWidget *parent, const char *name ) :OListView( parent, name ) { } ONamedListView::~ONamedListView() { } void ONamedListView::addColumns( const QStringList& columns ) { for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) { - qDebug( "adding column %s", (const char*) *it ); + odebug << "adding column " << *it << "" << oendl; addColumn( *it ); } } int ONamedListView::findColumn( const QString& text ) const { //FIXME: If used excessively, this will slow down performance of updates //FIXME: because of the linear search over all column texts. //FIXME: I will optimize later by using a hash map. for ( int i = 0; i < columns(); ++i ) if ( columnText( i ) == text ) return i; return -1; } ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const { return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); } ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const { ONamedListViewItem* result; while ( item && item->text( column ) != text ) { - qDebug( "checked %s", (const char*) item->text( column ) ); + odebug << "checked " << item->text( column ) << "" << oendl; if ( recurse < 0 || recurse > 0 ) { - qDebug( "recursion is %d - recursing into...", recurse ); + odebug << "recursion is " << recurse << " - recursing into..." << oendl; result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); if ( result ) return result; } item = (ONamedListViewItem*) item->itemBelow(); } if ( item && item->text( column ) == text ) return item; else return 0; } ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const { int col = findColumn( column ); if ( col != -1 ) return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); else return 0; } ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const { int col = findColumn( column ); if ( col != -1 ) return find( item, col, text, recurse ); else return 0; } /*====================================================================================== * ONamedListViewItem *======================================================================================*/ ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) :OListViewItem( parent ) { setText( texts ); } ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) :OListViewItem( parent ) { setText( texts ); } ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) :OListViewItem( parent, after ) { setText( texts ); } ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) :OListViewItem( parent, after ) { setText( texts ); } ONamedListViewItem::~ONamedListViewItem() { } void ONamedListViewItem::setText( const QStringList& texts ) { int col = 0; for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) { - qDebug( "setting column %d = text %s", col, (const char*) *it ); + odebug << "setting column " << col << " = text " << *it << "" << oendl; OListViewItem::setText( col++, *it ); } } void ONamedListViewItem::setText( const QString& column, const QString& text ) { //FIXME: If used excessively, this will slow down performance of updates //FIXME: because of the linear search over all column texts. //FIXME: I will optimize later by using a hash map. int col = ( (ONamedListView*) listView() )->findColumn( column ); if ( col != -1 ) OListViewItem::setText( col, text ); else - qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); + owarn << "ONamedListViewItem::setText(): Warning! Columntext '" << column << "' not found." << oendl; } ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const { return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); } ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const { int col = ( (ONamedListView*) listView() )->findColumn( column ); if ( col != -1 ) return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); else return 0; } } } diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp index 3ab8490..50c613f 100644 --- a/libopie2/opieui/opopupmenu.cpp +++ b/libopie2/opieui/opopupmenu.cpp @@ -1,360 +1,360 @@ /* This file is part of the KDE libraries Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* QT */ +/* OPIE */ +#include <opie2/opopupmenu.h> +#include <opie2/oconfig.h> +#include <opie2/odebug.h> +/* QT */ #include <qdrawutil.h> #include <qtimer.h> -/* OPIE */ - -#include <opie2/opopupmenu.h> -#include <opie2/oconfig.h> using namespace Opie::Core; using namespace Opie::Ui; OPopupTitle::OPopupTitle(QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, const QColor &/* color */, const QColor &/* textColor */, QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, const QColor &/* textColor */, QWidget *parent, const char *name) : QWidget(parent, name) { setMinimumSize(16, fontMetrics().height()+8); } void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) { titleStr = text; if (icon) miniicon = *icon; else miniicon.resize(0, 0); int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::setText( const QString &text ) { titleStr = text; int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::setIcon( const QPixmap &pix ) { miniicon = pix; int w = miniicon.width()+fontMetrics().width(titleStr); int h = QMAX( fontMetrics().height(), miniicon.height() ); setMinimumSize( w+16, h+8 ); } void OPopupTitle::paintEvent(QPaintEvent *) { QRect r(rect()); QPainter p(this); #if QT_VERSION > 290 qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); #else #warning OPopupMenu is not fully functional on Qt2 #endif if (!miniicon.isNull()) p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); if (!titleStr.isNull()) { p.setPen(palette().active().text()); QFont f = p.font(); f.setBold(true); p.setFont(f); if(!miniicon.isNull()) { p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), height(), AlignLeft | AlignVCenter | SingleLine, titleStr); } else { p.drawText(0, 0, width(), height(), AlignCenter | SingleLine, titleStr); } } p.setPen(palette().active().highlight()); p.drawLine(0, 0, r.right(), 0); } QSize OPopupTitle::sizeHint() const { return(minimumSize()); } class OPopupMenu::OPopupMenuPrivate { public: OPopupMenuPrivate () : noMatches(false) , shortcuts(false) , autoExec(false) , lastHitIndex(-1) , m_ctxMenu(0) {} - + ~OPopupMenuPrivate () { delete m_ctxMenu; } QString m_lastTitle; // variables for keyboard navigation QTimer clearTimer; bool noMatches : 1; bool shortcuts : 1; bool autoExec : 1; QString keySeq; QString originalText; int lastHitIndex; // support for RMB menus on menus QPopupMenu* m_ctxMenu; static bool s_continueCtxMenuShow; static int s_highlightedItem; static OPopupMenu* s_contextedMenu; }; int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1); OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0); bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true); OPopupMenu::OPopupMenu(QWidget *parent, const char *name) : QPopupMenu(parent, name) { d = new OPopupMenuPrivate; resetKeyboardVars(); connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); } OPopupMenu::~OPopupMenu() { if (OPopupMenuPrivate::s_contextedMenu == this) { OPopupMenuPrivate::s_contextedMenu = 0; OPopupMenuPrivate::s_highlightedItem = -1; } - + delete d; } int OPopupMenu::insertTitle(const QString &text, int id, int index) { OPopupTitle *titleItem = new OPopupTitle(); titleItem->setTitle(text); int ret = insertItem(titleItem, id, index); setItemEnabled(id, false); return ret; } int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id, int index) { OPopupTitle *titleItem = new OPopupTitle(); titleItem->setTitle(text, &icon); int ret = insertItem(titleItem, id, index); setItemEnabled(id, false); return ret; } void OPopupMenu::changeTitle(int id, const QString &text) { QMenuItem *item = findItem(id); if(item){ if(item->widget()) ((OPopupTitle *)item->widget())->setTitle(text); #ifndef NDEBUG else - qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); + owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl; #endif } #ifndef NDEBUG else - qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); + owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl; #endif } void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text) { QMenuItem *item = findItem(id); if(item){ if(item->widget()) ((OPopupTitle *)item->widget())->setTitle(text, &icon); #ifndef NDEBUG else - qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); + owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl; #endif } #ifndef NDEBUG else - qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); + owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl; #endif } QString OPopupMenu::title(int id) const { if(id == -1) // obsolete return(d->m_lastTitle); QMenuItem *item = findItem(id); if(item){ if(item->widget()) return(((OPopupTitle *)item->widget())->title()); else - qWarning("OPopupMenu: title() called with non-title id %d.", id); + owarn << "OPopupMenu: title() called with non-title id " << id << "." << oendl; } else - qWarning("OPopupMenu: title() called with invalid id %d.", id); + owarn << "OPopupMenu: title() called with invalid id " << id << "." << oendl; return(QString::null); } QPixmap OPopupMenu::titlePixmap(int id) const { QMenuItem *item = findItem(id); if(item){ if(item->widget()) return(((OPopupTitle *)item->widget())->icon()); else - qWarning("KPopupMenu: titlePixmap() called with non-title id %d.", id); + owarn << "KPopupMenu: titlePixmap() called with non-title id " << id << "." << oendl; } else - qWarning("KPopupMenu: titlePixmap() called with invalid id %d.", id); + owarn << "KPopupMenu: titlePixmap() called with invalid id " << id << "." << oendl; QPixmap tmp; return(tmp); } /** * This is re-implemented for keyboard navigation. */ void OPopupMenu::closeEvent(QCloseEvent*e) { if (d->shortcuts) resetKeyboardVars(); QPopupMenu::closeEvent(e); } void OPopupMenu::keyPressEvent(QKeyEvent* e) { if (!d->shortcuts) { // continue event processing by Qpopup //e->ignore(); QPopupMenu::keyPressEvent(e); return; } int i = 0; bool firstpass = true; QString keyString = e->text(); // check for common commands dealt with by QPopup int key = e->key(); if (key == Key_Escape || key == Key_Return || key == Key_Enter || key == Key_Up || key == Key_Down || key == Key_Left || key == Key_Right || key == Key_F1) { resetKeyboardVars(); // continue event processing by Qpopup //e->ignore(); QPopupMenu::keyPressEvent(e); return; } // check to see if the user wants to remove a key from the sequence (backspace) // or clear the sequence (delete) if (!d->keySeq.isNull()) { if (key == Key_Backspace) { if (d->keySeq.length() == 1) { resetKeyboardVars(); return; } // keep the last sequence in keyString keyString = d->keySeq.left(d->keySeq.length() - 1); // allow sequence matching to be tried again resetKeyboardVars(); } else if (key == Key_Delete) { resetKeyboardVars(); // clear active item setActiveItem(0); return; } else if (d->noMatches) { // clear if there are no matches resetKeyboardVars(); // clear active item setActiveItem(0); } else { // the key sequence is not a null string // therefore the lastHitIndex is valid i = d->lastHitIndex; } } else if (key == Key_Backspace && parentMenu) { // backspace with no chars in the buffer... go back a menu. hide(); resetKeyboardVars(); return; } d->keySeq += keyString; int seqLen = d->keySeq.length(); for (; i < (int)count(); i++) { // compare typed text with text of this entry int j = idAt(i); // don't search disabled entries if (!isItemEnabled(j)) continue; QString thisText; diff --git a/libopie2/opieui/otaskbarapplet.h b/libopie2/opieui/otaskbarapplet.h index 77cc461..75c07d1 100644 --- a/libopie2/opieui/otaskbarapplet.h +++ b/libopie2/opieui/otaskbarapplet.h @@ -1,130 +1,134 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. 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 ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OTASKBARAPPLET_H #define OTASKBARAPPLET_H +/* OPIE */ +#include <opie2/odebug.h> + #include <qpe/taskbarappletinterface.h> #include <qpe/qcom.h> +/* QT */ #include <qwidget.h> class QMouseEvent; namespace Opie { namespace Ui { namespace Internal { /*====================================================================================== * OTaskbarAppletWrapper *======================================================================================*/ class OTaskbarAppletWrapperPrivate; template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface { public: OTaskbarAppletWrapper():_applet( 0 ) { } virtual ~OTaskbarAppletWrapper() { delete _applet; } QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) { - qDebug( "OTaskbarAppletWrapper::queryInterface()" ); + odebug << "OTaskbarAppletWrapper::queryInterface()" << oendl; *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_TaskbarApplet ) *iface = this; - else - return QS_FALSE; + else + return QS_FALSE; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_REFCOUNT virtual T* applet( QWidget* parent ) { if ( !_applet ) _applet = new T( parent ); return _applet; } virtual int position() const { return T::position(); } private: T* _applet; OTaskbarAppletWrapperPrivate *d; }; } /*====================================================================================== * OTaskbarApplet *======================================================================================*/ // Must be inline until after we shipped Opie 1.0 // Having OTaskBarApplet reside in libopieui2 is not possible // until we link the launcher binary against libopieui2 - // otherwise the necessary symbols are not present, when // the dynamic loader [dlopen] tries to resolve an applet which // inherits OTaskbarApplet class OTaskbarApplet : public QWidget { public: OTaskbarApplet( QWidget* parent, const char* name = 0 ); virtual ~OTaskbarApplet(); protected: virtual void popup( QWidget* widget ); private: class Private; Private *d; }; } } #define EXPORT_OPIE_APPLET_v1( AppLet ) \ Q_EXPORT_INTERFACE() { \ Q_CREATE_INSTANCE( Opie::Ui::Internal::OTaskbarAppletWrapper<AppLet> ) \ } #endif |