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

« back to all changes in this revision

Viewing changes to libs/widgets/KoPageLayoutDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* This file is part of the KDE project
2
 
 * Copyright (C) 2007 Thomas Zander <zander@kde.org>
 
2
 * Copyright (C) 2007,2010 Thomas Zander <zander@kde.org>
3
3
 *
4
4
 * This library is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU Library General Public
23
23
#include "KoPagePreviewWidget.h"
24
24
 
25
25
#include <klocale.h>
 
26
#include <kdebug.h>
26
27
 
27
28
#include <QCheckBox>
28
29
#include <QDialogButtonBox>
32
33
class KoPageLayoutDialog::Private
33
34
{
34
35
public:
 
36
    Private() : pageLayoutWidget(0), documentCheckBox(0) {}
35
37
    KoPageLayout layout;
36
38
    KoPageLayoutWidget *pageLayoutWidget;
37
 
    QCheckBox* documentCheckBox;
 
39
    QCheckBox *documentCheckBox;
38
40
};
39
41
 
40
42
 
63
65
    prev->setPageLayout(d->layout);
64
66
    lay->addWidget(prev);
65
67
 
66
 
    for (int i = 0; i < children().count(); ++i) {
67
 
        if (QDialogButtonBox* buttonBox = qobject_cast<QDialogButtonBox*>(children()[i])) {
68
 
            d->documentCheckBox = new QCheckBox(i18n("Apply to document"), buttonBox);
69
 
            buttonBox->addButton(d->documentCheckBox, QDialogButtonBox::ResetRole);
70
 
            break;
71
 
        }
72
 
    }
73
 
 
74
 
    connect (d->documentCheckBox, SIGNAL(toggled(bool)),
75
 
            d->pageLayoutWidget, SLOT(setApplyToDocument(bool)));
76
68
    connect (d->pageLayoutWidget, SIGNAL(layoutChanged(const KoPageLayout&)),
77
69
            prev, SLOT(setPageLayout(const KoPageLayout&)));
78
70
    connect (d->pageLayoutWidget, SIGNAL(layoutChanged(const KoPageLayout&)),
108
100
 
109
101
bool KoPageLayoutDialog::applyToDocument() const
110
102
{
111
 
    return d->documentCheckBox->isChecked();
 
103
    return d->documentCheckBox && d->documentCheckBox->isChecked();
 
104
}
 
105
 
 
106
void KoPageLayoutDialog::showApplyToDocument(bool on)
 
107
{
 
108
    if (on && d->documentCheckBox == 0) {
 
109
        for (int i = 0; i < children().count(); ++i) {
 
110
            if (QDialogButtonBox *buttonBox = qobject_cast<QDialogButtonBox*>(children()[i])) {
 
111
                d->documentCheckBox = new QCheckBox(i18n("Apply to document"), buttonBox);
 
112
                d->documentCheckBox->setChecked(true);
 
113
                buttonBox->addButton(d->documentCheckBox, QDialogButtonBox::ResetRole);
 
114
                break;
 
115
            }
 
116
        }
 
117
 
 
118
        Q_ASSERT(d->pageLayoutWidget);
 
119
        connect (d->documentCheckBox, SIGNAL(toggled(bool)),
 
120
                d->pageLayoutWidget, SLOT(setApplyToDocument(bool)));
 
121
    } else if (d->documentCheckBox) {
 
122
        d->documentCheckBox->setVisible(on);
 
123
    }
112
124
}
113
125
 
114
126
void KoPageLayoutDialog::showTextDirection(bool on)
135
147
{
136
148
    d->pageLayoutWidget->setPageSpread(pageSpread);
137
149
}
 
150
 
 
151