~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy

« back to all changes in this revision

Viewing changes to libs/plasma/widgets/freelayout.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-10-11 14:04:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071011140448-v0eb7lxbb24zagca
Tags: 3.94.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2007 by Robert Knight <robertknight@gmail.com>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License as
 
6
 *   published by the Free Software Foundation; either version 2, or
 
7
 *   (at your option) any later version.
 
8
 
 
9
 *
 
10
 *   This program 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 Library General Public
 
16
 *   License along with this program; if not, write to the
 
17
 *   Free Software Foundation, Inc.,
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 */
 
20
 
 
21
#include <plasma/plasma_export.h>
 
22
#include <plasma/widgets/layout.h>
 
23
 
 
24
#include "freelayout.h"
 
25
 
 
26
namespace Plasma
 
27
{
 
28
 
 
29
class FreeLayout::Private
 
30
{
 
31
public:
 
32
    QList<LayoutItem*> children;
 
33
    QRectF geometry;
 
34
};
 
35
 
 
36
FreeLayout::FreeLayout(LayoutItem *parent)
 
37
    : Layout(parent),
 
38
      d(new Private)
 
39
{
 
40
}
 
41
 
 
42
FreeLayout::~FreeLayout()
 
43
{
 
44
    delete d;
 
45
}
 
46
 
 
47
Qt::Orientations FreeLayout::expandingDirections() const
 
48
{
 
49
    return Qt::Horizontal | Qt::Vertical;
 
50
}
 
51
 
 
52
void FreeLayout::addItem(LayoutItem *item)
 
53
{
 
54
    d->children << item;
 
55
    item->setManagingLayout(this);
 
56
}
 
57
 
 
58
void FreeLayout::removeItem(LayoutItem *item)
 
59
{
 
60
    d->children.removeAll(item);
 
61
}
 
62
 
 
63
int FreeLayout::indexOf(LayoutItem *item) const
 
64
{
 
65
    return d->children.indexOf(item);
 
66
}
 
67
 
 
68
LayoutItem * FreeLayout::itemAt(int i) const
 
69
{
 
70
    return d->children[i];
 
71
}
 
72
 
 
73
int FreeLayout::count() const
 
74
{
 
75
    return d->children.count();
 
76
}
 
77
 
 
78
LayoutItem * FreeLayout::takeAt(int i)
 
79
{
 
80
    return d->children.takeAt(i);
 
81
}
 
82
 
 
83
void FreeLayout::setGeometry(const QRectF &geometry)
 
84
{
 
85
    foreach (LayoutItem *child , d->children) {
 
86
        if (child->geometry().size() != child->sizeHint()) {
 
87
            child->setGeometry(QRectF(child->geometry().topLeft(),child->sizeHint()));
 
88
        }
 
89
    }
 
90
    d->geometry = geometry;
 
91
}
 
92
 
 
93
QRectF FreeLayout::geometry() const
 
94
{
 
95
    return d->geometry;
 
96
}
 
97
 
 
98
QSizeF FreeLayout::sizeHint() const
 
99
{
 
100
    return maximumSize();
 
101
}
 
102
 
 
103
}
 
104