~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to importer/dialogpage.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
Import upstream version 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
 
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
2
2
/*
3
3
Gwenview: an image viewer
4
4
Copyright 2009 Aurélien Gâteau <agateau@kde.org>
33
33
// Local
34
34
#include <ui_dialogpage.h>
35
35
 
36
 
 
37
 
namespace Gwenview {
38
 
 
 
36
namespace Gwenview
 
37
{
39
38
 
40
39
struct DialogPagePrivate : public Ui_DialogPage {
41
 
        QVBoxLayout* mLayout;
42
 
        QList<KPushButton*> mButtons;
43
 
        QSignalMapper* mMapper;
44
 
        QEventLoop* mEventLoop;
 
40
    QVBoxLayout* mLayout;
 
41
    QList<KPushButton*> mButtons;
 
42
    QSignalMapper* mMapper;
 
43
    QEventLoop* mEventLoop;
45
44
};
46
45
 
47
 
 
48
46
DialogPage::DialogPage(QWidget* parent)
49
47
: QWidget(parent)
50
 
, d(new DialogPagePrivate) {
51
 
        d->setupUi(this);
52
 
        d->mLayout = new QVBoxLayout(d->mButtonContainer);
53
 
        d->mMapper = new QSignalMapper(this);
54
 
        connect(d->mMapper, SIGNAL(mapped(int)), SLOT(slotMapped(int)));
55
 
}
56
 
 
57
 
 
58
 
DialogPage::~DialogPage() {
59
 
        delete d;
60
 
}
61
 
 
62
 
 
63
 
void DialogPage::removeButtons() {
64
 
        qDeleteAll(d->mButtons);
65
 
        d->mButtons.clear();
66
 
}
67
 
 
68
 
 
69
 
void DialogPage::setText(const QString& text) {
70
 
        d->mLabel->setText(text);
71
 
}
72
 
 
73
 
 
74
 
int DialogPage::addButton(const KGuiItem& item) {
75
 
        int id = d->mButtons.size();
76
 
        KPushButton* button = new KPushButton(item);
77
 
        button->setFixedHeight(button->sizeHint().height() * 2);
78
 
 
79
 
        connect(button, SIGNAL(clicked()), d->mMapper, SLOT(map()));
80
 
        d->mLayout->addWidget(button);
81
 
        d->mMapper->setMapping(button, id);
82
 
        d->mButtons << button;
83
 
        return id;
84
 
}
85
 
 
86
 
 
87
 
int DialogPage::exec() {
88
 
        QEventLoop loop;
89
 
        d->mEventLoop = &loop;
90
 
        return loop.exec();
91
 
}
92
 
 
93
 
 
94
 
void DialogPage::slotMapped(int value) {
95
 
        d->mEventLoop->exit(value);
96
 
}
97
 
 
 
48
, d(new DialogPagePrivate)
 
49
{
 
50
    d->setupUi(this);
 
51
    d->mLayout = new QVBoxLayout(d->mButtonContainer);
 
52
    d->mMapper = new QSignalMapper(this);
 
53
    connect(d->mMapper, SIGNAL(mapped(int)), SLOT(slotMapped(int)));
 
54
}
 
55
 
 
56
DialogPage::~DialogPage()
 
57
{
 
58
    delete d;
 
59
}
 
60
 
 
61
void DialogPage::removeButtons()
 
62
{
 
63
    qDeleteAll(d->mButtons);
 
64
    d->mButtons.clear();
 
65
}
 
66
 
 
67
void DialogPage::setText(const QString& text)
 
68
{
 
69
    d->mLabel->setText(text);
 
70
}
 
71
 
 
72
int DialogPage::addButton(const KGuiItem& item)
 
73
{
 
74
    int id = d->mButtons.size();
 
75
    KPushButton* button = new KPushButton(item);
 
76
    button->setFixedHeight(button->sizeHint().height() * 2);
 
77
 
 
78
    connect(button, SIGNAL(clicked()), d->mMapper, SLOT(map()));
 
79
    d->mLayout->addWidget(button);
 
80
    d->mMapper->setMapping(button, id);
 
81
    d->mButtons << button;
 
82
    return id;
 
83
}
 
84
 
 
85
int DialogPage::exec()
 
86
{
 
87
    QEventLoop loop;
 
88
    d->mEventLoop = &loop;
 
89
    return loop.exec();
 
90
}
 
91
 
 
92
void DialogPage::slotMapped(int value)
 
93
{
 
94
    d->mEventLoop->exit(value);
 
95
}
98
96
 
99
97
} // namespace