| 1 | /* |
|---|
| 2 | * This file is part of Licq, an instant messaging client for UNIX. |
|---|
| 3 | * Copyright (C) 2006 Licq developers |
|---|
| 4 | * |
|---|
| 5 | * Licq is free software; you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | * (at your option) any later version. |
|---|
| 9 | * |
|---|
| 10 | * Licq is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with Licq; if not, write to the Free Software |
|---|
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #ifndef TREEPAGER_H |
|---|
| 21 | #define TREEPAGER_H |
|---|
| 22 | |
|---|
| 23 | #include <QMap> |
|---|
| 24 | #include <QWidget> |
|---|
| 25 | |
|---|
| 26 | class QStackedLayout; |
|---|
| 27 | class QTreeWidget; |
|---|
| 28 | class QTreeWidgetItem; |
|---|
| 29 | |
|---|
| 30 | namespace LicqQtGui |
|---|
| 31 | { |
|---|
| 32 | /** |
|---|
| 33 | * Widget for showing one of multiple pages at a time using a tree list for page selection. |
|---|
| 34 | * Intended mainly for option dialogs. |
|---|
| 35 | */ |
|---|
| 36 | class TreePager : public QWidget |
|---|
| 37 | { |
|---|
| 38 | Q_OBJECT |
|---|
| 39 | |
|---|
| 40 | public: |
|---|
| 41 | /** |
|---|
| 42 | * Standard contructor. |
|---|
| 43 | */ |
|---|
| 44 | TreePager(QWidget* parent = NULL); |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * Adds a page to this control. |
|---|
| 48 | * |
|---|
| 49 | * @param page The widget containing the page |
|---|
| 50 | * @param title Title to display in the tree list. |
|---|
| 51 | * @param parent Parent page if this is a sub page or NULL to make it a top level page. |
|---|
| 52 | */ |
|---|
| 53 | void addPage(QWidget* page, QString title, /* QIcon icon, */ QWidget* parent = NULL); |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * Changes which page to show. |
|---|
| 57 | * |
|---|
| 58 | * @param page A page to show. Must have been added to this control. |
|---|
| 59 | */ |
|---|
| 60 | void showPage(QWidget* page); |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| 63 | * Get current visible page |
|---|
| 64 | * |
|---|
| 65 | * @return Current page |
|---|
| 66 | */ |
|---|
| 67 | QWidget* currentPage() const; |
|---|
| 68 | |
|---|
| 69 | signals: |
|---|
| 70 | /** |
|---|
| 71 | * Current page has changed |
|---|
| 72 | * |
|---|
| 73 | * @param page New current page |
|---|
| 74 | */ |
|---|
| 75 | void currentPageChanged(QWidget* page); |
|---|
| 76 | |
|---|
| 77 | private: |
|---|
| 78 | QStackedLayout* myPageStack; |
|---|
| 79 | QTreeWidget* myTreeList; |
|---|
| 80 | QMap<QTreeWidgetItem*, QWidget*> myPageMap; |
|---|
| 81 | |
|---|
| 82 | private slots: |
|---|
| 83 | |
|---|
| 84 | /** |
|---|
| 85 | * Handler for selection changes in the tree list. |
|---|
| 86 | * Updates which page to show. |
|---|
| 87 | */ |
|---|
| 88 | void flipPage(QTreeWidgetItem* selection); |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | } // namespace LicqQtGui |
|---|
| 92 | |
|---|
| 93 | #endif |
|---|