~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to lib/kopalette/kotoolboxpalette.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
 
3
 *
 
4
   This library is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License version 2, as published by the Free Software Foundation.
 
7
 
 
8
   This library is distributed in the hope that it will be useful,
 
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
   Library General Public License for more details.
 
12
 
 
13
   You should have received a copy of the GNU Library General Public License
 
14
   along with this library; see the file COPYING.LIB.  If not, write to
 
15
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
 
 
17
 */
 
18
 
 
19
 
 
20
#include <qdockwindow.h>
 
21
#include <qtoolbox.h>
 
22
 
 
23
#include <kopalette.h>
 
24
#include <kopalettemanager.h>
 
25
#include <kotoolboxpalette.h>
 
26
 
 
27
KoToolBoxPalette::KoToolBoxPalette(QWidget * parent, const char * name)
 
28
    : KoPalette(parent, name)
 
29
{
 
30
    m_page = new QToolBox(this);
 
31
    m_page->unsetFont();
 
32
    setMainWidget(m_page);
 
33
    m_style = PALETTE_TOOLBOX;
 
34
}
 
35
 
 
36
KoToolBoxPalette::~KoToolBoxPalette()
 
37
{
 
38
}
 
39
 
 
40
 
 
41
void KoToolBoxPalette::resetFont()
 
42
{
 
43
    KoPalette::resetFont();
 
44
    m_page->unsetFont();
 
45
}
 
46
 
 
47
 
 
48
void KoToolBoxPalette::plug(QWidget *w, const QString & label, int position)
 
49
{
 
50
    w->unsetFont();
 
51
    m_page->insertItem( position, w,  label );
 
52
}
 
53
 
 
54
 
 
55
void KoToolBoxPalette::unplug(const QWidget *w)
 
56
{
 
57
    m_page->removeItem( const_cast<QWidget*>(w) );
 
58
}
 
59
 
 
60
void KoToolBoxPalette::showPage(QWidget *w)
 
61
{
 
62
    m_page->setCurrentItem( w );
 
63
}
 
64
 
 
65
 
 
66
int KoToolBoxPalette::indexOf(QWidget *w)
 
67
{
 
68
    if (m_hiddenPages.find(w) != m_hiddenPages.end()) {
 
69
        return m_page->indexOf(w);
 
70
    }
 
71
    else {
 
72
        return m_page->indexOf(w);
 
73
    }
 
74
}
 
75
 
 
76
 
 
77
void KoToolBoxPalette::makeVisible(bool v)
 
78
{
 
79
    if (v && m_page->count() > 0) {
 
80
        show();
 
81
    }
 
82
    else {
 
83
        hide();
 
84
    }
 
85
}
 
86
 
 
87
bool KoToolBoxPalette::isHidden(QWidget * w)
 
88
{
 
89
    return (m_hiddenPages.find(w) != m_hiddenPages.end());
 
90
}
 
91
 
 
92
void KoToolBoxPalette::togglePageHidden(QWidget *w)
 
93
{
 
94
    if (m_hiddenPages.find(w) != m_hiddenPages.end()) {
 
95
        int i = *m_hiddenPages.find(w);
 
96
        m_page->insertItem(i, w, w->caption());
 
97
        show();
 
98
    }
 
99
    else {
 
100
        int i = m_page->indexOf(w);
 
101
        m_page->removeItem(w);
 
102
        m_hiddenPages[w] = i;
 
103
        if (m_page->count() == 0) {
 
104
            hide();
 
105
        }
 
106
    }
 
107
 
 
108
}
 
109
 
 
110
void KoToolBoxPalette::hidePage( QWidget * w)
 
111
{
 
112
    if (m_hiddenPages.find(w) != m_hiddenPages.end()) return;
 
113
    int i = m_page->indexOf(w);
 
114
    m_page->removeItem(w);
 
115
    m_hiddenPages[w] = i;
 
116
    if (m_page->count() == 0) {
 
117
        hide();
 
118
    }
 
119
}
 
120
 
 
121
#include "kotoolboxpalette.moc"