Home · All Classes · Grouped Classes · Annotated · Functions

changelistener.cpp Example File
content/changelistener/changelistener.cpp

    /****************************************************************************
    **
    ** Copyright (C) 2000-2007 TROLLTECH ASA. All rights reserved.
    **
    ** This file is part of the Opensource Edition of the Qtopia Toolkit.
    **
    ** $TROLLTECH_DUAL_LICENSE$
    **
    ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    **
    ****************************************************************************/

    #include "changelistener.h"
    #include "changelistener_p.h"
    #include <QSoftMenuBar>
    #include <QVBoxLayout>
    #include <QLabel>
    #include <QCloseEvent>
    #include <QShowEvent>

    /*!
     * \internal
     *  Constructs a ChangeListener which is a child of 'parent', with the
     *  name 'name' and widget flags set to 'f'
     */
    ChangeListener::ChangeListener( QWidget *parent, Qt::WFlags f )
        : QWidget( parent, f )
        , priv(0)
    {
        priv = new ChangeListenerPrivate(this);

        // Construct context menu, available to the user via Qtopia's soft menu bar.
        QMenu *menu = QSoftMenuBar::menuFor(this);
        Q_UNUSED(menu); // Normally, we would use "menu" to add more actions.
        // The context menu will not be active unless it has at least one action.
        // Tell Qtopia to provide the "Help" option, which will enable the user to
        // read the Help documentation for this application.
        QSoftMenuBar::setHelpEnabled(this,true);
        // To add further actions, see QWidget::insertAction(QAction *,QAction *)

        QVBoxLayout *layout = new QVBoxLayout;
        setLayout(layout);

        // The only widget that we want to see is the image label.
        layout->addWidget(priv->imageLabel);
    }

    /*
     * \internal
     *  Destroys the object and frees any allocated resources
     */
    /*
    ChangeListener::~ChangeListener()
    {
        // No need to delete "priv" as it has been reparented to "this" and will
        // be deleted automatically. Normally would leave the dtor out.
    }
    */

    /*!
      \internal
      When the ChangeListener shows, start generating documents. In a real application,
      you would want the ChangeListener to stop generating when the window becomes hidden, too.
    */
    void ChangeListener::showEvent(QShowEvent *e)
    {
        QWidget::showEvent(e);
        priv->startGenerating();
    }

    /*!
      \internal
      When the ChangeListener closes, stop generating documents.
    */
    void ChangeListener::closeEvent(QCloseEvent *e)
    {
        priv->stopGenerating();
        QWidget::closeEvent(e);
    }


Copyright © 2007 Trolltech Trademarks
Qtopia 4.3.0