• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeplasma-addons API Reference
  • KDE Home
  • Contact Us
 

GroupingDesktop

  • sources
  • kde-4.12
  • kdeplasma-addons
  • containments
  • groupingdesktop
  • lib
  • groupexplorer
groupexplorer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007 by Ivan Cukic <ivan.cukic+kde@gmail.com>
3  * Copyright (C) 2009 by Ana CecĂ­lia Martins <anaceciliamb@gmail.com>
4  * Copyright 2010 Chani Armitage <chani@kde.org>
5  * Copyright 2010 Giulio Camuffo <giuliocamuffo@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Library/Lesser General Public License
9  * version 2, or (at your option) any later version, as published by the
10  * Free Software Foundation
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details
16  *
17  * You should have received a copy of the GNU Library/Lesser General Public
18  * License along with this program; if not, write to the
19  * Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #include "groupexplorer.h"
24 
25 #include <QGraphicsLinearLayout>
26 
27 #include <KIcon>
28 
29 #include <Plasma/Corona>
30 #include <Plasma/Containment>
31 #include <Plasma/ToolButton>
32 
33 #include "groupiconlist.h"
34 
35 class GroupExplorerPrivate
36 {
37  public:
38  GroupExplorerPrivate(GroupExplorer *w)
39  : q(w),
40  containment(0),
41  iconSize(16) //FIXME bad!
42  {
43  }
44 
45  void init();
46  void containmentDestroyed();
47  void setOrientation(Qt::Orientation orientation);
48 
49  GroupExplorer *q;
50  Plasma::ToolButton *close;
51  Plasma::Containment *containment;
52 
54  GroupIconList *groupList;
55  QGraphicsLinearLayout *filteringLayout;
56  QGraphicsLinearLayout *mainLayout;
57  int iconSize;
58 };
59 
60 void GroupExplorerPrivate::init()
61 {
62  //init widgets
63  mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
64  mainLayout->setSpacing(0);
65  filteringLayout = new QGraphicsLinearLayout(Qt::Horizontal);
66  groupList = new GroupIconList(Plasma::BottomEdge);
67  close = new Plasma::ToolButton;
68  close->setIcon(KIcon("dialog-close"));
69 
70  QObject::connect(close, SIGNAL(clicked()), q, SIGNAL(closeClicked()));
71 
72  mainLayout->addItem(filteringLayout);
73  mainLayout->addItem(groupList);
74  groupList->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
75  mainLayout->setAlignment(groupList, Qt::AlignTop | Qt::AlignHCenter);
76 
77  q->setLayout(mainLayout);
78 }
79 
80 void GroupExplorerPrivate::setOrientation(Qt::Orientation orientation)
81 {
82  if (orientation == Qt::Horizontal) {
83 // mainLayout->removeItem(filteringWidget);
84  mainLayout->removeItem(close);
85  filteringLayout->addStretch();
86  filteringLayout->addItem(close);
87  filteringLayout->setAlignment(close, Qt::AlignVCenter | Qt::AlignHCenter);
88  } else {
89  filteringLayout->removeAt(0);
90  filteringLayout->removeItem(close);
91 // mainLayout->insertItem(0, filteringWidget);
92  mainLayout->addItem(close);
93  mainLayout->setStretchFactor(groupList, 10);
94  }
95 }
96 
97 void GroupExplorerPrivate::containmentDestroyed()
98 {
99  containment = 0;
100 }
101 
102 GroupExplorer::GroupExplorer(Plasma::Location location)
103  : QGraphicsWidget(0),
104  d(new GroupExplorerPrivate(this))
105 {
106  d->init();
107  setLocation(location);
108 }
109 
110 GroupExplorer::~GroupExplorer()
111 {
112  delete d;
113 }
114 
115 void GroupExplorer::setLocation(Plasma::Location location)
116 {
117  d->setOrientation(location == Plasma::LeftEdge || location == Plasma::RightEdge ? Qt::Vertical : Qt::Horizontal);
118  d->groupList->setLocation(location);
119  d->groupList->updateList();
120 }
121 
122 void GroupExplorer::setIconSize(int size)
123 {
124  d->groupList->setIconSize(size);
125  adjustSize();
126 }
127 
128 void GroupExplorer::setContainment(Plasma::Containment *containment)
129 {
130  if (d->containment != containment) {
131  if (d->containment) {
132  d->containment->disconnect(this);
133  }
134 
135  d->containment = containment;
136 
137  if (d->containment) {
138  connect(d->containment, SIGNAL(destroyed(QObject*)), this, SLOT(containmentDestroyed()));
139  connect(d->containment, SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), this, SLOT(immutabilityChanged(Plasma::ImmutabilityType)));
140  }
141  }
142 }
143 
144 void GroupExplorer::showEvent(QShowEvent *e)
145 {
146  QGraphicsWidget::showEvent(e);
147 }
148 
149 void GroupExplorer::immutabilityChanged(Plasma::ImmutabilityType type)
150 {
151  if (type != Plasma::Mutable) {
152  emit closeClicked();
153  }
154 }
155 
156 #include "groupexplorer.moc"
GroupExplorer::~GroupExplorer
~GroupExplorer()
Definition: groupexplorer.cpp:110
GroupIconList
Definition: groupiconlist.h:42
groupiconlist.h
GroupExplorer::setLocation
void setLocation(Plasma::Location location)
set orientation
Definition: groupexplorer.cpp:115
GroupExplorer::immutabilityChanged
void immutabilityChanged(Plasma::ImmutabilityType type)
Definition: groupexplorer.cpp:149
groupexplorer.h
GroupExplorer::setIconSize
void setIconSize(int size)
Sets the icon size.
Definition: groupexplorer.cpp:122
GroupExplorer::GroupExplorer
GroupExplorer(Plasma::Location location)
Definition: groupexplorer.cpp:102
GroupExplorer::setContainment
void setContainment(Plasma::Containment *containment)
Changes the current containment you've got to call this at least once so that it can access the coron...
Definition: groupexplorer.cpp:128
GroupExplorer
Definition: groupexplorer.h:33
GroupExplorer::showEvent
void showEvent(QShowEvent *e)
Definition: groupexplorer.cpp:144
GroupExplorer::closeClicked
void closeClicked()
QGraphicsWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon Oct 13 2014 22:55:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

GroupingDesktop

Skip menu "GroupingDesktop"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeplasma-addons API Reference

Skip menu "kdeplasma-addons API Reference"
  •     GroupingDesktop
  •   liblancelot

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal