Skip to content
Snippets Groups Projects
centralwidget.h 3.2 KiB
Newer Older
/**************************************************************************
con's avatar
con committed
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
**
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
**
**************************************************************************/
con's avatar
con committed

#ifndef CENTRALWIDGET_H
#define CENTRALWIDGET_H

#include <find/ifindsupport.h>
con's avatar
con committed

#include <QtGui/QWidget>

QT_FORWARD_DECLARE_CLASS(QEvent)
QT_FORWARD_DECLARE_CLASS(QAction)
QT_FORWARD_DECLARE_CLASS(QStackedWidget)
QT_FORWARD_DECLARE_CLASS(QFocusEvent)
con's avatar
con committed

namespace Help {
    namespace Internal {
con's avatar
con committed

hjk's avatar
hjk committed
class HelpViewer;
con's avatar
con committed
class PrintHelper;

class CentralWidget : public QWidget
{
    Q_OBJECT

public:
    CentralWidget(QWidget *parent = 0);
con's avatar
con committed
    ~CentralWidget();

    static CentralWidget *instance();

con's avatar
con committed
    bool hasSelection() const;
    bool isForwardAvailable() const;
    bool isBackwardAvailable() const;

    HelpViewer *viewerAt(int index) const;
con's avatar
con committed
    HelpViewer *currentHelpViewer() const;
Patrick Star's avatar
Patrick Star committed

    void addPage(HelpViewer *page, bool fromSearch = false);
    void removePage(int index);

    int currentIndex() const;
    void setCurrentPage(HelpViewer *page);

    bool find(const QString &txt, Find::FindFlags findFlags,
        bool incremental);
con's avatar
con committed

public slots:
    void copy();
    void home();

con's avatar
con committed
    void zoomIn();
    void zoomOut();
    void resetZoom();

    void forward();
    void nextPage();

    void backward();
con's avatar
con committed
    void previousPage();
con's avatar
con committed
    void print();
    void pageSetup();
    void printPreview();
con's avatar
con committed
    void setSource(const QUrl &url);
    void setSourceFromSearch(const QUrl &url);
    void showTopicChooser(const QMap<QString, QUrl> &links, const QString &key);
con's avatar
con committed

protected:
    void focusInEvent(QFocusEvent *event);

signals:
    void openFindToolBar();
    void currentViewerChanged();
con's avatar
con committed
    void sourceChanged(const QUrl &url);
    void forwardAvailable(bool available);
    void backwardAvailable(bool available);
con's avatar
con committed
private slots:
    void highlightSearchTerms();
con's avatar
con committed
    void printPreview(QPrinter *printer);
    void handleSourceChanged(const QUrl &url);
con's avatar
con committed

private:
    void initPrinter();
    void connectSignals(HelpViewer *page);
    bool eventFilter(QObject *object, QEvent *e);
con's avatar
con committed

private:
    QPrinter *printer;
    QStackedWidget *m_stackedWidget;
con's avatar
con committed
};

    } // namespace Internal
} // namespace Help
con's avatar
con committed

#endif  // CENTRALWIDGET_H