| 1 |
/* |
| 2 |
* Copyright 2013 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program 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 |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Author: Zsombor Egri <[email protected]> |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "ulitemlayout.h" |
| 20 |
|
| 21 |
/*! |
| 22 |
* \qmltype ItemLayout |
| 23 |
* \instantiates ULItemLayout |
| 24 |
* \inqmlmodule Lomiri.Layouts 1.0 |
| 25 |
* \ingroup lomiri-layouts |
| 26 |
* \brief ItemLayout defines a new size & position of a single Item, for the purposes |
| 27 |
* of specifying layouts. This is to be used within a ConditionalLayout definition. |
| 28 |
* |
| 29 |
* Use ItemLayout to define the size and position of a single item within a layout. |
| 30 |
* The item name to be positioned should be specified in item property, |
| 31 |
* which should correspond to the string specified in \b Layouts.item attached to |
| 32 |
* an Item in the default layout. The Item with Layouts.item attached is reparented |
| 33 |
* into ItemLayout and it is anchor filled to it. |
| 34 |
* |
| 35 |
* Example: |
| 36 |
* \qml |
| 37 |
* import QtQuick 2.4 |
| 38 |
* import Lomiri.Layouts 0.1 |
| 39 |
* |
| 40 |
* Layouts { |
| 41 |
* id: layouts |
| 42 |
* width: units.gu(50) |
| 43 |
* height: units.gu(50) |
| 44 |
* layouts: [ |
| 45 |
* ConditionalLayout { |
| 46 |
* when: layouts.width > units.gu(40) |
| 47 |
* Row { |
| 48 |
* width: parent.width |
| 49 |
* ItemLayout { |
| 50 |
* item: "input" |
| 51 |
* width: units.gu(30) |
| 52 |
* height: units.gu(20) |
| 53 |
* } |
| 54 |
* TextArea { |
| 55 |
* text: "extra component" |
| 56 |
* } |
| 57 |
* } |
| 58 |
* } |
| 59 |
* ] |
| 60 |
* // default layout |
| 61 |
* TextInput { |
| 62 |
* anchors.fill: parent |
| 63 |
* text: "input" |
| 64 |
* Layouts.item: "input" |
| 65 |
* } |
| 66 |
* } |
| 67 |
* \endqml |
| 68 |
*/ |
| 69 |
|
| 70 |
ULItemLayout::ULItemLayout(QQuickItem *parent) |
| 71 |
: QQuickItem(parent) |
| 72 |
{ |
| 73 |
} |
| 74 |
|
| 75 |
ULItemLayout::~ULItemLayout() |
| 76 |
{ |
| 77 |
} |
| 78 |
|
| 79 |
/*! |
| 80 |
* \qmlproperty string ItemLayout::item |
| 81 |
* The property holds the item name to be positioned in the fragment. |
| 82 |
*/ |
| 83 |
QString ULItemLayout::item() const |
| 84 |
{ |
| 85 |
return m_itemName; |
| 86 |
} |
| 87 |
void ULItemLayout::setItem(const QString &value) |
| 88 |
{ |
| 89 |
if (value == m_itemName) { |
| 90 |
return; |
| 91 |
} |
| 92 |
m_itemName = value; |
| 93 |
} |