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

« back to all changes in this revision

Viewing changes to libs/plasma/widgets/layout.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:
2
2
 *   Copyright 2007 by Matias Valdenegro T. <mvaldenegro@informatica.utem.cl>
3
3
 *
4
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 version 2 as
6
 
 *   published by the Free Software Foundation
 
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
 
7
9
 *
8
10
 *   This program is distributed in the hope that it will be useful,
9
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
21
23
#include <math.h>
22
24
 
23
25
#include <QtCore/QList>
 
26
#include <QtCore/QTimeLine>
 
27
#include <QtDebug>
 
28
 
 
29
#include "widget.h"
 
30
#include "layoutanimator.h"
24
31
 
25
32
namespace Plasma
26
33
{
52
59
{
53
60
}
54
61
 
 
62
void Layout::setParent(LayoutItem *parent) {
 
63
    d->parent = parent;
 
64
}
 
65
 
55
66
Layout::~Layout()
56
67
{
57
68
    if (parent()) {
60
71
    delete d;
61
72
}
62
73
 
 
74
bool Layout::isEmpty() const 
 
75
{
 
76
    return count() == 0;
 
77
}
 
78
 
63
79
void Layout::update()
64
80
{
65
 
    // this will force an update
66
 
    setGeometry( parent()->geometry() );
67
 
}
 
81
 
 
82
    setGeometry(geometry());
 
83
 
 
84
}
 
85
void Layout::invalidate()
 
86
{
 
87
    // find and update the top level layout
 
88
    Layout *layout = this;
 
89
    Layout *parentLayout = 0;
 
90
 
 
91
    do {
 
92
        parentLayout = dynamic_cast<Layout*>(layout->parent());
 
93
        if (parentLayout) {
 
94
            layout = parentLayout;
 
95
        }
 
96
    } while (parentLayout);
 
97
 
 
98
    layout->update();
 
99
}
 
100
 
68
101
 
69
102
LayoutAnimator* Layout::animator() const
70
103
{
71
104
    return d->animator;
72
105
}
73
106
 
74
 
void Layout::setAnimator(LayoutAnimator* animator)
 
107
void Layout::setAnimator(LayoutAnimator *animator)
75
108
{
76
109
    d->animator = animator;
77
110
}
78
111
 
79
112
qreal Layout::margin() const
80
113
{
81
 
        return d->margin;
 
114
    return d->margin;
82
115
}
83
116
 
84
117
void Layout::setMargin(qreal m)
85
118
{
86
 
        d->margin = m;
 
119
    d->margin = m;
87
120
}
88
121
 
89
122
qreal Layout::spacing() const
90
123
{
91
 
        return d->spacing;
 
124
    return d->spacing;
92
125
}
93
126
 
94
127
void Layout::setSpacing(qreal s)
95
128
{
96
 
        d->spacing = s;
 
129
    d->spacing = s;
97
130
}
98
131
 
99
132
LayoutItem *Layout::parent() const
100
133
{
101
 
        return d->parent;
 
134
    return d->parent;
102
135
}
103
136
 
104
137
QSizeF Layout::minimumSize() const
110
143
    return QSizeF(INFINITY,INFINITY);
111
144
}
112
145
 
 
146
void Layout::startAnimation() 
 
147
{
 
148
    if (animator() && animator()->timeLine()) {
 
149
        animator()->timeLine()->setCurrentTime(0);
 
150
        if (animator()->timeLine()->state() == QTimeLine::NotRunning) {
 
151
            animator()->timeLine()->start();
 
152
        }
 
153
    }
 
154
}
 
155
 
113
156
}